[
  {
    "path": ".gitattributes",
    "content": "bin/* binary"
  },
  {
    "path": ".gitignore",
    "content": "## Ignore Visual Studio temporary files, build results, and\n## files generated by popular Visual Studio add-ons.\n\n# User-specific files\n*.suo\n*.user\n*.userosscache\n*.sln.docstates\nsrc/.vs/*\n\n# Build results\n[Dd]ebug/\n[Dd]ebugPublic/\n[Rr]elease/\n[Rr]eleases/\nx64/\nx86/\nbuild/\nbld/\n[Bb]in/\n[Oo]bj/\n\n# Roslyn cache directories\n*.ide/\n\n# MSTest test Results\n[Tt]est[Rr]esult*/\n[Bb]uild[Ll]og.*\n\n#NUNIT\n*.VisualState.xml\nTestResult.xml\n\n# Build Results of an ATL Project\n[Dd]ebugPS/\n[Rr]eleasePS/\ndlldata.c\n\n*_i.c\n*_p.c\n*_i.h\n*.ilk\n*.meta\n*.obj\n*.pch\n*.pdb\n*.pgc\n*.pgd\n*.rsp\n*.sbr\n*.tlb\n*.tli\n*.tlh\n*.tmp\n*.tmp_proj\n*.log\n*.vspscc\n*.vssscc\n.builds\n*.pidb\n*.svclog\n*.scc\n\n# Chutzpah Test files\n_Chutzpah*\n\n# Visual C++ cache files\nipch/\n*.aps\n*.ncb\n*.opensdf\n*.sdf\n*.cachefile\n\n# Visual Studio profiler\n*.psess\n*.vsp\n*.vspx\n\n# TFS 2012 Local Workspace\n$tf/\n\n# Guidance Automation Toolkit\n*.gpState\n\n# ReSharper is a .NET coding add-in\n_ReSharper*/\n*.[Rr]e[Ss]harper\n*.DotSettings.user\n\n# JustCode is a .NET coding addin-in\n.JustCode\n\n# TeamCity is a build add-in\n_TeamCity*\n\n# DotCover is a Code Coverage Tool\n*.dotCover\n\n# NCrunch\n_NCrunch_*\n.*crunch*.local.xml\n\n# MightyMoose\n*.mm.*\nAutoTest.Net/\n\n# Web workbench (sass)\n.sass-cache/\n\n# Installshield output folder\n[Ee]xpress/\n\n# DocProject is a documentation generator add-in\nDocProject/buildhelp/\nDocProject/Help/*.HxT\nDocProject/Help/*.HxC\nDocProject/Help/*.hhc\nDocProject/Help/*.hhk\nDocProject/Help/*.hhp\nDocProject/Help/Html2\nDocProject/Help/html\n\n# Click-Once directory\npublish/\n\n# Publish Web Output\n*.[Pp]ublish.xml\n*.azurePubxml\n# TODO: Comment the next line if you want to checkin your web deploy settings \n# but database connection strings (with potential passwords) will be unencrypted\n*.pubxml\n*.publishproj\n\n# NuGet Packages\n*.nupkg\n# The packages folder can be ignored because of Package Restore\n**/packages/*\n# except build/, which is used as an MSBuild target.\n!**/packages/build/\n# If using the old MSBuild-Integrated Package Restore, uncomment this:\n#!**/packages/repositories.config\n\n# Windows Azure Build Output\ncsx/\n*.build.csdef\n\n# Windows Store app package directory\nAppPackages/\n\n# Others\nsql/\n*.Cache\nClientBin/\n[Ss]tyle[Cc]op.*\n~$*\n*~\n*.dbmdl\n*.dbproj.schemaview\n*.pfx\n*.publishsettings\nnode_modules/\n\n# RIA/Silverlight projects\nGenerated_Code/\n\n# Backup & report files from converting an old project file\n# to a newer Visual Studio version. Backup files are not needed,\n# because we have git ;-)\n_UpgradeReport_Files/\nBackup*/\nUpgradeLog*.XML\nUpgradeLog*.htm\n\n# SQL Server files\n*.mdf\n*.ldf\n\n# Business Intelligence projects\n*.rdl.data\n*.bim.layout\n*.bim_*.settings\n\n# Microsoft Fakes\nFakesAssemblies/\n\n# =========================\n# Operating System Files\n# =========================\n\n# OSX\n# =========================\n\n.DS_Store\n.AppleDouble\n.LSOverride\n\n# Thumbnails\n._*\n\n# Files that might appear on external disk\n.Spotlight-V100\n.Trashes\n\n# Directories potentially created on remote AFP share\n.AppleDB\n.AppleDesktop\nNetwork Trash Folder\nTemporary Items\n.apdisk\n\n# Windows\n# =========================\n\n# Windows image file caches\nThumbs.db\nehthumbs.db\n\n# Folder config file\nDesktop.ini\n\n# Recycle Bin used on file shares\n$RECYCLE.BIN/\n\n# Windows Installer files\n*.cab\n*.msi\n*.msm\n*.msp\n\n# Windows shortcuts\n*.lnk\n\n\n"
  },
  {
    "path": ".gitmodules",
    "content": "[submodule \"src/Wrapper/glsl-optimizer\"]\n\tpath = src/Wrapper/glsl-optimizer\n\turl = https://github.com/jbarczak/glsl-optimizer\n[submodule \"src/Wrapper/GLSlang\"]\n\tpath = src/Wrapper/GLSlang\n\turl = https://github.com/jbarczak/GLSlang\n"
  },
  {
    "path": "Distribute.bat",
    "content": "echo off\nmkdir Pyramid\nmkdir Pyramid\\bin\nmkdir Pyramid\\src\nmkdir Pyramid\\src\\Backends\nmkdir Pyramid\\src\\Languages\nmkdir Pyramid\\src\\MainUI\nmkdir Pyramid\\src\\Properties\nmkdir Pyramid\\src\\Wrapper\nmkdir Pyramid\\src\\Wrapper\\glsl-optimizer\nmkdir Pyramid\\src\\Wrapper\\GLSlang\ncp -r bin/* Pyramid/bin\ncp -r LICENSE.txt Pyramid/LICENSE.txt\ncp -r README.txt Pyramid/README.txt\ncp src/*.cs   Pyramid/src\ncp src/*.resx Pyramid/src\ncp src/Backends/*.cs   Pyramid/src/Backends\ncp src/Backends/*.resx   Pyramid/src/Backends\ncp src/Languages/*.cs   Pyramid/src/Languages\ncp src/Languages/*.resx   Pyramid/src/Languages\ncp src/MainUI/*.cs Pyramid/src/MainUI\ncp src/MainUI/*.resx Pyramid/src/MainUI\ncp src/App.config Pyramid/src/App.config\ncp src/*.csproj Pyramid/src\ncp src/Pyramid.sln Pyramid/src/Pyramid.sln\ncp -r src/Properties/* Pyramid/src/Properties\ncp src/Wrapper/*.cpp Pyramid/src/Wrapper\ncp src/Wrapper/*.h  Pyramid/src/Wrapper\ncp src/Wrapper/Wrapper.vcxproj Pyramid/src/Wrapper\ncp src/Wrapper/Wrapper.vcxproj.filters Pyramid/src/Wrapper\ncp -r src/Wrapper/glsl-optimizer Pyramid/src/Wrapper\ncp src/Wrapper/GLSlang/glslang_vs2013.vcxproj Pyramid/src/Wrapper/GLSlang/glslang_vs2013.vcxproj\ncp -r src/Wrapper/GLSlang/glslang          Pyramid/src/Wrapper/GLSlang\ncp -r src/Wrapper/GLSlang/OGLCompilersDLL  Pyramid/src/Wrapper/GLSlang\ncp -r src/Wrapper/GLSlang/tools            Pyramid/src/Wrapper/GLSlang\n\n"
  },
  {
    "path": "LICENSE.txt",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<http://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<http://www.gnu.org/philosophy/why-not-lgpl.html>.\n"
  },
  {
    "path": "README.md",
    "content": "# Pyramid\n\nPyramid is a free, open GUI tool for offline shader validation and analysis. The UI takes HLSL or GLSL as input, and runs them through various shader\ncompilers and static analyzers.\n\nHere is Pyramid, showing HLSL shader compiled and disassembled for AMD's GCN, and a GLSL shader compiled and disassembled for PowerVR 6 *(click for full-size image)*:\n\n[![AMD GCN from HLSL](doc/ui-hlsl-amddxx-thumb.png)](doc/ui-hlsl-amddxx.png?raw=1)\n[![PowerVR disassembly from GLSL](doc/ui-glsl-powervr-thumb.png)](doc/ui-glsl-powervr.png?raw=1)\n\nCurrently, Pyramid supports these tools:\n\n* HLSL:\n\t* Microsoft D3D compiler *(d3dcompiler_47)*: for showing D3D assembly.\n\t* AMD DXX driver *(Catalyst 14.9)*, used for GCN disassembly and [shader execution simulation](http://www.joshbarczak.com/blog/?p=823).\n\t* AMD [CodeXL analyzer](http://developer.amd.com/tools-and-sdks/opencl-zone/codexl/) *(version 1.5)*.\n    * glslang HLSL front end (2017 January build)\n    * [DXC] (https://github.com/microsoft/DirectXShadercompiler)\n    * [Intel Shader Analyzer](http://github.com/GameTechDev/IntelShaderAnalyzer)\n* GLSL:\n\t* Khronos reference [glslang](https://github.com/KhronosGroup/glslang) validator *(2017 January build)*.\n\t* Imagination [PowerVR Rogue compiler](https://community.imgtec.com/developers/powervr/tools/pvrshadereditor/) *(version 3.4)*.\n\t* ARM [Mali offline compiler](http://malideveloper.arm.com/resources/tools/mali-offline-compiler/) *(version 4.6)*.\n\t* [glsl-optimizer](https://github.com/aras-p/glsl-optimizer) *(2015 November build)*.\n\nAll the above tools are included under bin/ folder for convenience. These are all publicly available binaries, but I do not own them, maintain them,\nand am not responsible for them.  If you like you can use the Options screen to point Pyramid at different versions of the tools.\n\nPyramid is intended to eventually support arbitrary languages and glue together tools and disassemblers from all over\nthe graphics world.\n \nIHVs:  You want developers scrutinizing the ISA for your GPUs.  You know you do :) I will work with you to incorporate your disassemblers into this tool.  I am willing to jump through hoops to make this happen, just tell me what I need to do.\n\n\n## Obtaining Pyramid\n\nThe best way to obtain a copy is to ask github to download a zip of the repository.  The `bin` directory will be updated periodically with an up to date binary.  \n\nPyramid is built against .NET framework 4.5 and runs on Windows.  If you don't have it, you need to go get it.  Otherwise, just put the contents of `bin` wherever\nyou like, there is no installer.\n\nPyramid will create a configuration file under `AppData\\Local\\Pyramid`.  At runtime, it will also create and delete temporary files in this location.  Apart from that,\nthere are no other changes made to the system.  In particular, there is no registry nonsense.\n\nPyramid is distributed as is. There is no warranty of any kind. I will not guarantee timely support, but I will be happy to accept bug fixes, patches, or contributions.\n[License](LICENSE.txt) is GPL.\n\nYou may send constructive feedback to:  jbarcz1@gmail.com\n\n\n\n## Building it Yourself\n\nDue to my use of submodules, downloading a zip will not get you the full source.\n\nThe best way to obtain the full source is to install git, open a shell, and type:\n\n    git clone --recurse https://github.com/jbarczak/Pyramid\n\nThis will ensure that all of the submodules are downloaded.  github does not include submodules when you download a zip.\n\nI use and recommend MSysGit:  https://msysgit.github.io/\n\nPyramid was developed using VC++ 2013 express edition (Desktop).  It runs correctly on my machine (Windows 8.1 with VC++ express installed).  \n\nThe build products will be copied from `src/bin` into `bin` on each compile.  \n\nBy default, Pyramid uses relative paths to look for all of the external binaries.  For debugging, it's best to point the working directory at `bin` so that they will be found.  Alternatively, you can use the options menu to replace the paths with absolutes.\n"
  },
  {
    "path": "shims/atidxx_shim/ShimDLL.cpp",
    "content": "\n#define _CRT_SECURE_NO_DEPRECATE\n\n#include <Windows.h>\n#include <stdio.h>\n#include <stdarg.h>\n#include <malloc.h>\n#include \"elf.h\"\n#include <time.h>\n#include \"d3d11tokenizedprogramformat.hpp\"\n\nstruct esi_struct;\nstruct edi_struct;\n\n#define CALL __cdecl\ntypedef DWORD (CALL *COMPILE_SHADER)( esi_struct*, edi_struct* );\ntypedef void  (CALL *FREE_SHADER)   (void*);\n\nstatic FILE*            g_pLog = 0;\nstatic COMPILE_SHADER   g_pCompileShader = 0;\nstatic FREE_SHADER      g_pFreeShader = 0;\nstatic HMODULE          g_hAMDDriver = 0;\nstatic CRITICAL_SECTION g_Lock;\n\nclass ScopedLock\n{\npublic:\n    ScopedLock() { EnterCriticalSection(&g_Lock); }\n    ~ScopedLock() { LeaveCriticalSection(&g_Lock); }\n};\n\n\nvoid Log( const char* Format, ... )\n{\n    va_list vl;\n    va_start(vl,Format);\n\n    int n = _vscprintf( Format, vl );\n    char* p = (char*) malloc( n+1 );\n    vsprintf(p,Format,vl);\n    printf(p);\n    OutputDebugStringA(p);\n    if( g_pLog )\n        fprintf( g_pLog, p );\n\n    free(p);\n\n    va_end(vl);\n}\n\n\nenum\n{\n    INVALID_ARG = 0x80070057,\n    UNSPECIFIED_ERROR = 0x80004005,\n};\n\n\nstruct esi_struct\n{ \n    DWORD        d0; // esi    Two dwords here that get passed into a call (pointer and size)?  asic info?\n    DWORD        d1; // esi+4\n    DWORD*       pShaderBlob;               // esi+8  If this is zero, return error ... pointer to D3D bytecode?\n    DWORD        nShaderBlobLengthInBytes; // esi+10h.  If this is non-zero, go to (53581b4e) (jumps over the esi+14h test)\n    void *  oddball;                        // esi+14h.  If this is non-zero, error, but only if esi+10 is also \n    DWORD mystery0;\n\n    void Print( )\n    {\n        Log( \"esi_struct at: 0x%08x { 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x }\\n\", \n            this, d0,d1,pShaderBlob,nShaderBlobLengthInBytes,\n            oddball, mystery0 );\n    }\n\n};  \n\n\nstruct edi_struct\n{\n    DWORD size; // 12\n    Elf32_Ehdr* pHeader;\n    DWORD nDataSize;\n\n    void Print( )\n    {\n        Log(\"edi_struct at (0x%08x): { 0x%08x 0x%08x  0x%08x }\\n\", this, size, pHeader,nDataSize );\n    }\n\n    void PrintSections( )\n    {\n        char* pHeaderBytes = (char*)pHeader;\n        Elf32_Shdr* pSections = (Elf32_Shdr*) (pHeaderBytes + pHeader->e_shoff);\n\n        Elf32_Shdr* pStringTable = pSections + pHeader->e_shstrndx;\n        char* pElfStringTable = pHeaderBytes + pStringTable->sh_offset;\n        for( DWORD i=0; i<pHeader->e_shnum; i++ )\n        {\n            DWORD nString = pSections[i].sh_name;\n            char* p = pElfStringTable + pSections[i].sh_name;\n            char* pSectionData = pHeaderBytes + pSections[i].sh_offset;\n            \n            Log(\"ELF Section: %u named: %s   (%u bytes)\\n\", i, p, pSections[i].sh_size );\n        }\n\n    }\n\n    void PrintGoryDetails( )\n    {\n        char* pHeaderBytes = (char*)pHeader;\n        Elf32_Shdr* pSections = (Elf32_Shdr*) (pHeaderBytes + pHeader->e_shoff);\n\n        Elf32_Shdr* pStringTable = pSections + pHeader->e_shstrndx;\n        char* pElfStringTable = pHeaderBytes + pStringTable->sh_offset;\n        for( DWORD i=0; i<pHeader->e_shnum; i++ )\n        {\n            DWORD nString = pSections[i].sh_name;\n            char* p = pElfStringTable + pSections[i].sh_name;\n            char* pSectionData = pHeaderBytes + pSections[i].sh_offset;\n            \n            Log(\"ELF Section: %u named: %s   (%u bytes)\\n\", i, p, pSections[i].sh_size );\n            Log(\"********************\\n\");\n            if( pSections[i].sh_size % 4 == 0 )\n            {\n                for( DWORD k=0; k<pSections[i].sh_size; k += 4 )\n                    Log( \"%08x\\n\", *((DWORD*)(pSectionData+k)) );\n            }\n\n            Log(\"ASCII: \\\"\");\n            for( DWORD k=0; k<pSections[i].sh_size; k++ )\n                Log( \"%c\", pSectionData[k] );\n                \n            Log(\"\\\"\\n\");\n        }\n\n    }\n\n}; \n\n\n\n\nextern \"C\" {\n\nstatic HRESULT Test(  esi_struct* esi, edi_struct* edi )\n{\n    const size_t PAD_SIZE   = 2048;\n    unsigned char* p = (unsigned char*) malloc( PAD_SIZE );\n    for( size_t i=0; i<PAD_SIZE; i++ )\n        p[i] = rand();\n\n    size_t offs = rand() % (PAD_SIZE-(sizeof(edi_struct)+sizeof(esi_struct)));\n    edi_struct* new_edi = (edi_struct*) (p+offs);\n    esi_struct* new_esi = (esi_struct*) (new_edi+1);\n    *new_edi = *edi;\n    *new_esi = *esi;\n\n    HRESULT h = g_pCompileShader(new_esi,new_edi);\n    if( !SUCCEEDED(h) )\n        Log(\" FAIL\\n\");\n\n    *edi = *new_edi;\n    free(p);\n    return h;\n}\n\n__declspec(dllexport) DWORD CALL AmdDxGsaCompileShader( esi_struct* esi, edi_struct* edi )\n{\n    //edi_struct first_one = *edi;\n    //g_pCompileShader(esi,&first_one);\n\n    //for( int i=0; i<10000; i++ )\n    //{\n    //    edi_struct current = *edi;\n    //    Test(esi,&current);\n    //    if( current.nDataSize != first_one.nDataSize || memcmp(current.pHeader,first_one.pHeader,current.nDataSize) != 0 )\n    //        Log(\"Results differ\\n\");\n    //    g_pFreeShader( current.pHeader);\n    //}\n\n    //*edi = first_one;\n    //return S_OK;\n\n    HRESULT h;\n    Log(\"Asic numbers: %u,%u\\n\", esi->d0, esi->d1);\n    h = g_pCompileShader(esi,edi);\n\n    return h;\n}\n\n__declspec(dllexport) void CALL AmdDxGsaFreeCompiledShader( void* p )\n{\n    ScopedLock l;\n\n    if( g_pFreeShader )\n        g_pFreeShader(p);\n}\n\n}\n\n\nBOOL WINAPI DllMain(\n  _In_  HINSTANCE hinstDLL,\n  _In_  DWORD fdwReason,\n  _In_  LPVOID lpvReserved\n)\n{\n    switch( fdwReason )\n    {\n    case DLL_PROCESS_ATTACH:\n        {\n            InitializeCriticalSection(&g_Lock);\n            \n            g_pLog = fopen(\"ShimLog.txt\", \"a\" );\n            if( !g_pLog )\n                Log(\"Failed to open log\\n\");\n\n            HMODULE hAMDDriver = LoadLibrary( \"real_driver.dll\" );\n            if( !hAMDDriver )\n                return UNSPECIFIED_ERROR;\n\n            FARPROC pCompile = GetProcAddress( hAMDDriver, \"AmdDxGsaCompileShader\" );\n            FARPROC pFree    = GetProcAddress( hAMDDriver, \"AmdDxGsaFreeCompiledShader\" );\n            if( !pCompile || !pFree )\n            {\n                FreeLibrary(hAMDDriver);\n                return FALSE;\n            }\n\n            g_pCompileShader = (COMPILE_SHADER) pCompile;\n            g_pFreeShader = (FREE_SHADER) pFree;\n            Log(\"**************************************************************************\\n\");\n            Log(\"Pyramid driver shim has loaded\\n\");\n            Log(\"Command line: %s\\n\", GetCommandLineA() );\n        }\n        break;\n\n    case DLL_PROCESS_DETACH:\n       \n        DeleteCriticalSection( &g_Lock );\n        if( g_hAMDDriver )\n        {\n            FreeLibrary(g_hAMDDriver);\n            g_pFreeShader=0;\n            g_pCompileShader=0;\n            g_hAMDDriver=0;\n            Log(\"Pyramid driver shim has unloaded\\n\");\n        }\n        if( g_pLog )\n        {\n            fclose(g_pLog);\n            g_pLog=0;\n        }\n\n        break;\n    }\n\n    return TRUE;\n}\n\n\n"
  },
  {
    "path": "shims/atidxx_shim/ShimDLL.sln",
    "content": "﻿\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio Express 2013 for Windows Desktop\nVisualStudioVersion = 12.0.21005.1\nMinimumVisualStudioVersion = 10.0.40219.1\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"ShimDLL\", \"ShimDLL.vcxproj\", \"{FCD07E16-50F2-49AF-BF11-F50A9FBAA5AC}\"\nEndProject\nGlobal\n\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n\t\tDebug|Win32 = Debug|Win32\n\t\tRelease|Win32 = Release|Win32\n\tEndGlobalSection\n\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n\t\t{FCD07E16-50F2-49AF-BF11-F50A9FBAA5AC}.Debug|Win32.ActiveCfg = Debug|Win32\n\t\t{FCD07E16-50F2-49AF-BF11-F50A9FBAA5AC}.Debug|Win32.Build.0 = Debug|Win32\n\t\t{FCD07E16-50F2-49AF-BF11-F50A9FBAA5AC}.Release|Win32.ActiveCfg = Release|Win32\n\t\t{FCD07E16-50F2-49AF-BF11-F50A9FBAA5AC}.Release|Win32.Build.0 = Release|Win32\n\tEndGlobalSection\n\tGlobalSection(SolutionProperties) = preSolution\n\t\tHideSolutionNode = FALSE\n\tEndGlobalSection\nEndGlobal\n"
  },
  {
    "path": "shims/atidxx_shim/ShimDLL.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project DefaultTargets=\"Build\" ToolsVersion=\"12.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup Label=\"ProjectConfigurations\">\n    <ProjectConfiguration Include=\"Debug|Win32\">\n      <Configuration>Debug</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|Win32\">\n      <Configuration>Release</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n  </ItemGroup>\n  <PropertyGroup Label=\"Globals\">\n    <ProjectGuid>{FCD07E16-50F2-49AF-BF11-F50A9FBAA5AC}</ProjectGuid>\n    <RootNamespace>ShimDLL</RootNamespace>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <UseDebugLibraries>true</UseDebugLibraries>\n    <PlatformToolset>v120</PlatformToolset>\n    <CharacterSet>NotSet</CharacterSet>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <UseDebugLibraries>false</UseDebugLibraries>\n    <PlatformToolset>v120</PlatformToolset>\n    <WholeProgramOptimization>true</WholeProgramOptimization>\n    <CharacterSet>NotSet</CharacterSet>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n  <ImportGroup Label=\"ExtensionSettings\">\n  </ImportGroup>\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <PropertyGroup Label=\"UserMacros\" />\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\n    <TargetName>atidxx32</TargetName>\n    <OutDir>C:\\Users\\jbarczak\\Documents\\Projects\\Blog\\reverse_engineering_gsa\\bin</OutDir>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\n    <TargetName>atidxx32</TargetName>\n  </PropertyGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\n    <ClCompile>\n      <WarningLevel>Level3</WarningLevel>\n      <Optimization>Disabled</Optimization>\n      <SDLCheck>true</SDLCheck>\n      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\n    </ClCompile>\n    <Link>\n      <GenerateDebugInformation>true</GenerateDebugInformation>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\n    <ClCompile>\n      <WarningLevel>Level3</WarningLevel>\n      <Optimization>MaxSpeed</Optimization>\n      <FunctionLevelLinking>true</FunctionLevelLinking>\n      <IntrinsicFunctions>true</IntrinsicFunctions>\n      <SDLCheck>true</SDLCheck>\n      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\n    </ClCompile>\n    <Link>\n      <GenerateDebugInformation>true</GenerateDebugInformation>\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\n      <OptimizeReferences>true</OptimizeReferences>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemGroup>\n    <ClCompile Include=\"ShimDLL.cpp\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"elf.h\" />\n  </ItemGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n  <ImportGroup Label=\"ExtensionTargets\">\n  </ImportGroup>\n</Project>"
  },
  {
    "path": "shims/atidxx_shim/elf.h",
    "content": "/*\n * CDDL HEADER START\n *\n * The contents of this file are subject to the terms of the\n * Common Development and Distribution License (the \"License\").\n * You may not use this file except in compliance with the License.\n *\n * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE\n * or http://www.opensolaris.org/os/licensing.\n * See the License for the specific language governing permissions\n * and limitations under the License.\n *\n * When distributing Covered Code, include this CDDL HEADER in each\n * file and include the License file at usr/src/OPENSOLARIS.LICENSE.\n * If applicable, add the following below this CDDL HEADER, with the\n * fields enclosed by brackets \"[]\" replaced with your own identifying\n * information: Portions Copyright [yyyy] [name of copyright owner]\n *\n * CDDL HEADER END\n */\n/*\n * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.\n * Use is subject to license terms.\n */\n\n/*\tCopyright (c) 1984, 1986, 1987, 1988, 1989 AT&T\t*/\n/*\t  All Rights Reserved  \t*/\n\n\n#ifndef _SYS_ELF_H\n#define\t_SYS_ELF_H\n\n#include <inttypes.h>\n\n/* Type for a 16-bit quantity.  */\ntypedef uint16_t Elf32_Half;\ntypedef uint16_t Elf64_Half;\n \n/* Types for signed and unsigned 32-bit quantities.  */\ntypedef uint32_t Elf32_Word;\ntypedef int32_t  Elf32_Sword;\ntypedef uint32_t Elf64_Word;\ntypedef int32_t  Elf64_Sword;\n \n/* Types for signed and unsigned 64-bit quantities.  */\ntypedef uint64_t Elf32_Xword;\ntypedef int64_t  Elf32_Sxword;\ntypedef uint64_t Elf64_Xword;\ntypedef int64_t  Elf64_Sxword;\n\n/* Type of addresses.  */\ntypedef uint32_t Elf32_Addr;\ntypedef uint64_t Elf64_Addr;\n\n/* Type of file offsets.  */\ntypedef uint32_t Elf32_Off;\ntypedef uint64_t Elf64_Off;\n\n\n#ifdef\t__cplusplus\nextern \"C\" {\n#endif\n\n#define\tELF32_FSZ_ADDR\t4\n#define\tELF32_FSZ_HALF\t2\n#define\tELF32_FSZ_OFF\t4\n#define\tELF32_FSZ_SWORD\t4\n#define\tELF32_FSZ_WORD\t4\n\n#define\tELF64_FSZ_ADDR\t8\n#define\tELF64_FSZ_HALF\t2\n#define\tELF64_FSZ_OFF\t8\n#define\tELF64_FSZ_SWORD\t4\n#define\tELF64_FSZ_WORD\t4\n#define\tELF64_FSZ_SXWORD 8\n#define\tELF64_FSZ_XWORD\t8\n\n/*\n *\t\"Enumerations\" below use ...NUM as the number of\n *\tvalues in the list.  It should be 1 greater than the\n *\thighest \"real\" value.\n */\n\n/*\n *\tELF header\n */\n\n#define\tEI_NIDENT\t16\n\ntypedef struct {\n\tunsigned char\te_ident[EI_NIDENT];\t/* ident bytes */\n\tElf32_Half\te_type;\t\t\t/* file type */\n\tElf32_Half\te_machine;\t\t/* target machine */\n\tElf32_Word\te_version;\t\t/* file version */\n\tElf32_Addr\te_entry;\t\t/* start address */\n\tElf32_Off\te_phoff;\t\t/* phdr file offset */\n\tElf32_Off\te_shoff;\t\t/* shdr file offset */\n\tElf32_Word\te_flags;\t\t/* file flags */\n\tElf32_Half\te_ehsize;\t\t/* sizeof ehdr */\n\tElf32_Half\te_phentsize;\t\t/* sizeof phdr */\n\tElf32_Half\te_phnum;\t\t/* number phdrs */\n\tElf32_Half\te_shentsize;\t\t/* sizeof shdr */\n\tElf32_Half\te_shnum;\t\t/* number shdrs */\n\tElf32_Half\te_shstrndx;\t\t/* shdr string index */\n} Elf32_Ehdr;\n\n#define\tEI_MAG0\t\t0\t/* e_ident[] indexes */\n#define\tEI_MAG1\t\t1\n#define\tEI_MAG2\t\t2\n#define\tEI_MAG3\t\t3\n#define\tEI_CLASS\t4\t/* File class */\n#define\tEI_DATA\t\t5\t/* Data encoding */\n#define\tEI_VERSION\t6\t/* File version */\n#define\tEI_OSABI\t7\t/* Operating system/ABI identification */\n#define\tEI_ABIVERSION\t8\t/* ABI version */\n#define\tEI_PAD\t\t9\t/* Start of padding bytes */\n\n#define\tELFMAG0\t\t0x7f\t\t/* EI_MAG */\n#define\tELFMAG1\t\t'E'\n#define\tELFMAG2\t\t'L'\n#define\tELFMAG3\t\t'F'\n#define\tELFMAG\t\t\"\\177ELF\"\n#define\tSELFMAG\t\t4\n\n#define\tELFCLASSNONE\t0\t\t/* EI_CLASS */\n#define\tELFCLASS32\t1\n#define\tELFCLASS64\t2\n#define\tELFCLASSNUM\t3\n\n#define\tELFDATANONE\t0\t\t/* EI_DATA */\n#define\tELFDATA2LSB\t1\n#define\tELFDATA2MSB\t2\n#define\tELFDATANUM\t3\n\n#define\tET_NONE\t\t0\t\t/* e_type */\n#define\tET_REL\t\t1\n#define\tET_EXEC\t\t2\n#define\tET_DYN\t\t3\n#define\tET_CORE\t\t4\n#define\tET_NUM\t\t5\n#define\tET_LOOS\t\t0xfe00\t\t/* OS specific range */\n#define\tET_LOSUNW\t0xfeff\n#define\tET_SUNWPSEUDO\t0xfeff\n#define\tET_HISUNW\t0xfeff\n#define\tET_HIOS\t\t0xfeff\n#define\tET_LOPROC\t0xff00\t\t/* processor specific range */\n#define\tET_HIPROC\t0xffff\n\n#define\tET_LOPROC\t0xff00\t\t/* processor specific range */\n#define\tET_HIPROC\t0xffff\n\n#define\tEM_NONE\t\t0\t\t/* e_machine */\n#define\tEM_M32\t\t1\t\t/* AT&T WE 32100 */\n#define\tEM_SPARC\t2\t\t/* Sun SPARC */\n#define\tEM_386\t\t3\t\t/* Intel 80386 */\n#define\tEM_68K\t\t4\t\t/* Motorola 68000 */\n#define\tEM_88K\t\t5\t\t/* Motorola 88000 */\n#define\tEM_486\t\t6\t\t/* Intel 80486 */\n#define\tEM_860\t\t7\t\t/* Intel i860 */\n#define\tEM_MIPS\t\t8\t\t/* MIPS RS3000 Big-Endian */\n#define\tEM_S370\t\t9\t\t/* IBM System/370 Processor */\n#define\tEM_MIPS_RS3_LE\t10\t\t/* MIPS RS3000 Little-Endian */\n#define\tEM_RS6000\t11\t\t/* RS6000 */\n#define\tEM_UNKNOWN12\t12\n#define\tEM_UNKNOWN13\t13\n#define\tEM_UNKNOWN14\t14\n#define\tEM_PA_RISC\t15\t\t/* PA-RISC */\n#define\tEM_PARISC\tEM_PA_RISC\t/* Alias: GNU compatibility */\n#define\tEM_nCUBE\t16\t\t/* nCUBE */\n#define\tEM_VPP500\t17\t\t/* Fujitsu VPP500 */\n#define\tEM_SPARC32PLUS\t18\t\t/* Sun SPARC 32+ */\n#define\tEM_960\t\t19\t\t/* Intel 80960 */\n#define\tEM_PPC\t\t20\t\t/* PowerPC */\n#define\tEM_PPC64\t21\t\t/* 64-bit PowerPC */\n#define\tEM_S390\t\t22\t\t/* IBM System/390 Processor */\n#define\tEM_UNKNOWN22\tEM_S390\t\t/* Alias: Older published name */\n#define\tEM_UNKNOWN23\t23\n#define\tEM_UNKNOWN24\t24\n#define\tEM_UNKNOWN25\t25\n#define\tEM_UNKNOWN26\t26\n#define\tEM_UNKNOWN27\t27\n#define\tEM_UNKNOWN28\t28\n#define\tEM_UNKNOWN29\t29\n#define\tEM_UNKNOWN30\t30\n#define\tEM_UNKNOWN31\t31\n#define\tEM_UNKNOWN32\t32\n#define\tEM_UNKNOWN33\t33\n#define\tEM_UNKNOWN34\t34\n#define\tEM_UNKNOWN35\t35\n#define\tEM_V800\t\t36\t\t/* NEX V800 */\n#define\tEM_FR20\t\t37\t\t/* Fujitsu FR20 */\n#define\tEM_RH32\t\t38\t\t/* TRW RH-32 */\n#define\tEM_RCE\t\t39\t\t/* Motorola RCE */\n#define\tEM_ARM\t\t40\t\t/* Advanced RISC Marchines ARM */\n#define\tEM_ALPHA\t41\t\t/* Digital Alpha */\n#define\tEM_SH\t\t42\t\t/* Hitachi SH */\n#define\tEM_SPARCV9\t43\t\t/* Sun SPARC V9 (64-bit) */\n#define\tEM_TRICORE\t44\t\t/* Siemens Tricore embedded processor */\n#define\tEM_ARC\t\t45\t\t/* Argonaut RISC Core, */\n\t\t\t\t\t/*\tArgonaut Technologies Inc. */\n#define\tEM_H8_300\t46\t\t/* Hitachi H8/300 */\n#define\tEM_H8_300H\t47\t\t/* Hitachi H8/300H */\n#define\tEM_H8S\t\t48\t\t/* Hitachi H8S */\n#define\tEM_H8_500\t49\t\t/* Hitachi H8/500 */\n#define\tEM_IA_64\t50\t\t/* Intel IA64 */\n#define\tEM_MIPS_X\t51\t\t/* Stanford MIPS-X */\n#define\tEM_COLDFIRE\t52\t\t/* Motorola ColdFire */\n#define\tEM_68HC12\t53\t\t/* Motorola M68HC12 */\n#define\tEM_MMA\t\t54\t\t/* Fujitsu MMA Mulimedia Accelerator */\n#define\tEM_PCP\t\t55\t\t/* Siemens PCP */\n#define\tEM_NCPU\t\t56\t\t/* Sony nCPU embedded RISC processor */\n#define\tEM_NDR1\t\t57\t\t/* Denso NDR1 microprocessor */\n#define\tEM_STARCORE\t58\t\t/* Motorola Star*Core processor */\n#define\tEM_ME16\t\t59\t\t/* Toyota ME16 processor */\n#define\tEM_ST100\t60\t\t/* STMicroelectronics ST100 processor */\n#define\tEM_TINYJ\t61\t\t/* Advanced Logic Corp. TinyJ */\n\t\t\t\t\t/*\tembedded processor family */\n#define\tEM_AMD64\t62\t\t/* AMDs x86-64 architecture */\n#define\tEM_X86_64\tEM_AMD64\t/* (compatibility) */\n\n#define\tEM_PDSP\t\t63\t\t/* Sony DSP Processor */\n#define\tEM_UNKNOWN64\t64\n#define\tEM_UNKNOWN65\t65\n#define\tEM_FX66\t\t66\t\t/* Siemens FX66 microcontroller */\n#define\tEM_ST9PLUS\t67\t\t/* STMicroelectronics ST9+8/16 bit */\n\t\t\t\t\t/*\tmicrocontroller */\n#define\tEM_ST7\t\t68\t\t/* STMicroelectronics ST7 8-bit */\n\t\t\t\t\t/*\tmicrocontroller */\n#define\tEM_68HC16\t69\t\t/* Motorola MC68HC16 Microcontroller */\n#define\tEM_68HC11\t70\t\t/* Motorola MC68HC11 Microcontroller */\n#define\tEM_68HC08\t71\t\t/* Motorola MC68HC08 Microcontroller */\n#define\tEM_68HC05\t72\t\t/* Motorola MC68HC05 Microcontroller */\n#define\tEM_SVX\t\t73\t\t/* Silicon Graphics SVx */\n#define\tEM_ST19\t\t74\t\t/* STMicroelectronics ST19 8-bit */\n\t\t\t\t\t/*\tmicrocontroller */\n#define\tEM_VAX\t\t75\t\t/* Digital VAX */\n#define\tEM_CRIS\t\t76\t\t/* Axis Communications 32-bit */\n\t\t\t\t\t/*\tembedded processor */\n#define\tEM_JAVELIN\t77\t\t/* Infineon Technologies 32-bit */\n\t\t\t\t\t/*\tembedded processor */\n#define\tEM_FIREPATH\t78\t\t/* Element 14 64-bit DSP Processor */\n#define\tEM_ZSP\t\t79\t\t/* LSI Logic 16-bit DSP Processor */\n#define\tEM_MMIX\t\t80\t\t/* Donald Knuth's educational */\n\t\t\t\t\t/*\t64-bit processor */\n#define\tEM_HUANY\t81\t\t/* Harvard University */\n\t\t\t\t\t/*\tmachine-independent */\n\t\t\t\t\t/*\tobject files */\n#define\tEM_PRISM\t82\t\t/* SiTera Prism */\n#define\tEM_AVR\t\t83\t\t/* Atmel AVR 8-bit microcontroller */\n#define\tEM_FR30\t\t84\t\t/* Fujitsu FR30 */\n#define\tEM_D10V\t\t85\t\t/* Mitsubishi D10V */\n#define\tEM_D30V\t\t86\t\t/* Mitsubishi D30V */\n#define\tEM_V850\t\t87\t\t/* NEC v850 */\n#define\tEM_M32R\t\t88\t\t/* Mitsubishi M32R */\n#define\tEM_MN10300\t89\t\t/* Matsushita MN10300 */\n#define\tEM_MN10200\t90\t\t/* Matsushita MN10200 */\n#define\tEM_PJ\t\t91\t\t/* picoJava */\n#define\tEM_OPENRISC\t92\t\t/* OpenRISC 32-bit embedded processor */\n#define\tEM_ARC_A5\t93\t\t/* ARC Cores Tangent-A5 */\n#define\tEM_XTENSA\t94\t\t/* Tensilica Xtensa architecture */\n#define\tEM_NUM\t\t95\n\n#define\tEV_NONE\t\t0\t\t/* e_version, EI_VERSION */\n#define\tEV_CURRENT\t1\n#define\tEV_NUM\t\t2\n\n\n#define\tELFOSABI_NONE\t\t0\t/* No extensions or unspecified */\n#define\tELFOSABI_SYSV\t\tELFOSABI_NONE\n#define\tELFOSABI_HPUX\t\t1\t/* Hewlett-Packard HP-UX */\n#define\tELFOSABI_NETBSD\t\t2\t/* NetBSD */\n#define\tELFOSABI_LINUX\t\t3\t/* Linux */\n#define\tELFOSABI_UNKNOWN4\t4\n#define\tELFOSABI_UNKNOWN5\t5\n#define\tELFOSABI_SOLARIS\t6\t/* Sun Solaris */\n#define\tELFOSABI_AIX\t\t7\t/* AIX */\n#define\tELFOSABI_IRIX\t\t8\t/* IRIX */\n#define\tELFOSABI_FREEBSD\t9\t/* FreeBSD */\n#define\tELFOSABI_TRU64\t\t10\t/* Compaq TRU64 UNIX */\n#define\tELFOSABI_MODESTO\t11\t/* Novell Modesto */\n#define\tELFOSABI_OPENBSD\t12\t/* Open BSD */\n#define\tELFOSABI_OPENVMS\t13\t/* Open VMS */\n#define\tELFOSABI_NSK\t\t14\t/* Hewlett-Packard Non-Stop Kernel */\n#define\tELFOSABI_AROS\t\t15\t/* Amiga Research OS */\n#define\tELFOSABI_ARM\t\t97\t/* ARM */\n#define\tELFOSABI_STANDALONE\t255\t/* standalone (embedded) application */\n\n/*\n *\tProgram header\n */\n\ntypedef struct {\n\tElf32_Word\tp_type;\t\t/* entry type */\n\tElf32_Off\tp_offset;\t/* file offset */\n\tElf32_Addr\tp_vaddr;\t/* virtual address */\n\tElf32_Addr\tp_paddr;\t/* physical address */\n\tElf32_Word\tp_filesz;\t/* file size */\n\tElf32_Word\tp_memsz;\t/* memory size */\n\tElf32_Word\tp_flags;\t/* entry flags */\n\tElf32_Word\tp_align;\t/* memory/file alignment */\n} Elf32_Phdr;\n\n#if defined(_LP64) || defined(_LONGLONG_TYPE)\ntypedef struct {\n\tElf64_Word\tp_type;\t\t/* entry type */\n\tElf64_Word\tp_flags;\t/* entry flags */\n\tElf64_Off\tp_offset;\t/* file offset */\n\tElf64_Addr\tp_vaddr;\t/* virtual address */\n\tElf64_Addr\tp_paddr;\t/* physical address */\n\tElf64_Xword\tp_filesz;\t/* file size */\n\tElf64_Xword\tp_memsz;\t/* memory size */\n\tElf64_Xword\tp_align;\t/* memory/file alignment */\n} Elf64_Phdr;\n#endif\t/* defined(_LP64) || defined(_LONGLONG_TYPE) */\n\n\n#define\tPT_NULL\t\t0\t\t/* p_type */\n#define\tPT_LOAD\t\t1\n#define\tPT_DYNAMIC\t2\n#define\tPT_INTERP\t3\n#define\tPT_NOTE\t\t4\n#define\tPT_SHLIB\t5\n#define\tPT_PHDR\t\t6\n#define\tPT_TLS\t\t7\n#define\tPT_NUM\t\t8\n\n#define\tPT_LOOS\t\t0x60000000\t/* OS specific range */\n\n/*\n * Note: The amd64 psABI defines that the UNWIND program header\n *\t should reside in the OS specific range of the program\n *\t headers.\n */\n#define\tPT_SUNW_UNWIND\t0x6464e550\t/* amd64 UNWIND program header */\n#define\tPT_GNU_EH_FRAME\tPT_SUNW_UNWIND\n\n\n#define\tPT_LOSUNW\t0x6ffffffa\n#define\tPT_SUNWBSS\t0x6ffffffa\t/* Sun Specific segment */\n#define\tPT_SUNWSTACK\t0x6ffffffb\t/* describes the stack segment */\n#define\tPT_SUNWDTRACE\t0x6ffffffc\t/* private */\n#define\tPT_SUNWCAP\t0x6ffffffd\t/* hard/soft capabilities segment */\n#define\tPT_HISUNW\t0x6fffffff\n#define\tPT_HIOS\t\t0x6fffffff\n\n#define\tPT_LOPROC\t0x70000000\t/* processor specific range */\n#define\tPT_HIPROC\t0x7fffffff\n\n#define\tPF_R\t\t0x4\t\t/* p_flags */\n#define\tPF_W\t\t0x2\n#define\tPF_X\t\t0x1\n\n#define\tPF_MASKOS\t0x0ff00000\t/* OS specific values */\n#define\tPF_MASKPROC\t0xf0000000\t/* processor specific values */\n\n#define\tPF_SUNW_FAILURE\t0x00100000\t/* mapping absent due to failure */\n\n#define\tPN_XNUM\t\t0xffff\t\t/* extended program header index */\n\n/*\n *\tSection header\n */\n\ntypedef struct {\n\tElf32_Word\tsh_name;\t/* section name */\n\tElf32_Word\tsh_type;\t/* SHT_... */\n\tElf32_Word\tsh_flags;\t/* SHF_... */\n\tElf32_Addr\tsh_addr;\t/* virtual address */\n\tElf32_Off\tsh_offset;\t/* file offset */\n\tElf32_Word\tsh_size;\t/* section size */\n\tElf32_Word\tsh_link;\t/* misc info */\n\tElf32_Word\tsh_info;\t/* misc info */\n\tElf32_Word\tsh_addralign;\t/* memory alignment */\n\tElf32_Word\tsh_entsize;\t/* entry size if table */\n} Elf32_Shdr;\n\n#if defined(_LP64) || defined(_LONGLONG_TYPE)\ntypedef struct {\n\tElf64_Word\tsh_name;\t/* section name */\n\tElf64_Word\tsh_type;\t/* SHT_... */\n\tElf64_Xword\tsh_flags;\t/* SHF_... */\n\tElf64_Addr\tsh_addr;\t/* virtual address */\n\tElf64_Off\tsh_offset;\t/* file offset */\n\tElf64_Xword\tsh_size;\t/* section size */\n\tElf64_Word\tsh_link;\t/* misc info */\n\tElf64_Word\tsh_info;\t/* misc info */\n\tElf64_Xword\tsh_addralign;\t/* memory alignment */\n\tElf64_Xword\tsh_entsize;\t/* entry size if table */\n} Elf64_Shdr;\n#endif\t/* defined(_LP64) || defined(_LONGLONG_TYPE) */\n\n#define\tSHT_NULL\t\t0\t\t/* sh_type */\n#define\tSHT_PROGBITS\t\t1\n#define\tSHT_SYMTAB\t\t2\n#define\tSHT_STRTAB\t\t3\n#define\tSHT_RELA\t\t4\n#define\tSHT_HASH\t\t5\n#define\tSHT_DYNAMIC\t\t6\n#define\tSHT_NOTE\t\t7\n#define\tSHT_NOBITS\t\t8\n#define\tSHT_REL\t\t\t9\n#define\tSHT_SHLIB\t\t10\n#define\tSHT_DYNSYM\t\t11\n#define\tSHT_UNKNOWN12\t\t12\n#define\tSHT_UNKNOWN13\t\t13\n#define\tSHT_INIT_ARRAY\t\t14\n#define\tSHT_FINI_ARRAY\t\t15\n#define\tSHT_PREINIT_ARRAY\t16\n#define\tSHT_GROUP\t\t17\n#define\tSHT_SYMTAB_SHNDX\t18\n#define\tSHT_NUM\t\t\t19\n\n/* Solaris ABI specific values */\n#define\tSHT_LOOS\t\t0x60000000\t/* OS specific range */\n#define\tSHT_LOSUNW\t\t0x6ffffff1\n#define\tSHT_SUNW_symsort\t0x6ffffff1\n#define\tSHT_SUNW_tlssort\t0x6ffffff2\n#define\tSHT_SUNW_LDYNSYM\t0x6ffffff3\n#define\tSHT_SUNW_dof\t\t0x6ffffff4\n#define\tSHT_SUNW_cap\t\t0x6ffffff5\n#define\tSHT_SUNW_SIGNATURE\t0x6ffffff6\n#define\tSHT_SUNW_ANNOTATE\t0x6ffffff7\n#define\tSHT_SUNW_DEBUGSTR\t0x6ffffff8\n#define\tSHT_SUNW_DEBUG\t\t0x6ffffff9\n#define\tSHT_SUNW_move\t\t0x6ffffffa\n#define\tSHT_SUNW_COMDAT\t\t0x6ffffffb\n#define\tSHT_SUNW_syminfo\t0x6ffffffc\n#define\tSHT_SUNW_verdef\t\t0x6ffffffd\n#define\tSHT_SUNW_verneed\t0x6ffffffe\n#define\tSHT_SUNW_versym\t\t0x6fffffff\n#define\tSHT_HISUNW\t\t0x6fffffff\n#define\tSHT_HIOS\t\t0x6fffffff\n\n/* GNU/Linux ABI specific values */\n#define\tSHT_GNU_verdef\t\t0x6ffffffd\n#define\tSHT_GNU_verneed\t\t0x6ffffffe\n#define\tSHT_GNU_versym\t\t0x6fffffff\n\n#define\tSHT_LOPROC\t0x70000000\t/* processor specific range */\n#define\tSHT_HIPROC\t0x7fffffff\n\n#define\tSHT_LOUSER\t0x80000000\n#define\tSHT_HIUSER\t0xffffffff\n\n#define\tSHF_WRITE\t\t0x01\t\t/* sh_flags */\n#define\tSHF_ALLOC\t\t0x02\n#define\tSHF_EXECINSTR\t\t0x04\n#define\tSHF_MERGE\t\t0x10\n#define\tSHF_STRINGS\t\t0x20\n#define\tSHF_INFO_LINK\t\t0x40\n#define\tSHF_LINK_ORDER\t\t0x80\n#define\tSHF_OS_NONCONFORMING\t0x100\n#define\tSHF_GROUP\t\t0x200\n#define\tSHF_TLS\t\t\t0x400\n\n#define\tSHF_MASKOS\t0x0ff00000\t/* OS specific values */\n\n\n#define\tSHF_MASKPROC\t0xf0000000\t/* processor specific values */\n\n#define\tSHN_UNDEF\t0\t\t/* special section numbers */\n#define\tSHN_LORESERVE\t0xff00\n#define\tSHN_LOPROC\t0xff00\t\t/* processor specific range */\n#define\tSHN_HIPROC\t0xff1f\n#define\tSHN_LOOS\t0xff20\t\t/* OS specific range */\n#define\tSHN_LOSUNW\t0xff3f\n#define\tSHN_SUNW_IGNORE\t0xff3f\n#define\tSHN_HISUNW\t0xff3f\n#define\tSHN_HIOS\t0xff3f\n#define\tSHN_ABS\t\t0xfff1\n#define\tSHN_COMMON\t0xfff2\n#if defined(__APPLE__)\n#define SHN_MACHO_64\t0xfffd\t\t/* Mach-o_64 direct string access */\n#define SHN_MACHO\t0xfffe\t\t/* Mach-o direct string access */\n#endif /* __APPLE__ */\n#define\tSHN_XINDEX\t0xffff\t\t/* extended sect index */\n#define\tSHN_HIRESERVE\t0xffff\n\n\n\n/*\n *\tSymbol table\n */\n\ntypedef struct {\n\tElf32_Word\tst_name;\n\tElf32_Addr\tst_value;\n\tElf32_Word\tst_size;\n\tunsigned char\tst_info;\t/* bind, type: ELF_32_ST_... */\n\tunsigned char\tst_other;\n\tElf32_Half\tst_shndx;\t/* SHN_... */\n} Elf32_Sym;\n\n#if defined(_LP64) || defined(_LONGLONG_TYPE)\ntypedef struct {\n#if !defined(__APPLE__)\n\tElf64_Word\tst_name;\n#else\n\tElf64_Sxword\tst_name;\n#endif /* __APPLE__ */\n\tunsigned char\tst_info;\t/* bind, type: ELF_64_ST_... */\n\tunsigned char\tst_other;\n\tElf64_Half\tst_shndx;\t/* SHN_... */\n\tElf64_Addr\tst_value;\n\tElf64_Xword\tst_size;\n} Elf64_Sym;\n#endif\t/* defined(_LP64) || defined(_LONGLONG_TYPE) */\n\n#define\tSTN_UNDEF\t0\n\n/*\n *\tThe macros compose and decompose values for S.st_info\n *\n *\tbind = ELF32_ST_BIND(S.st_info)\n *\ttype = ELF32_ST_TYPE(S.st_info)\n *\tS.st_info = ELF32_ST_INFO(bind, type)\n */\n\n#define\tELF32_ST_BIND(info)\t\t((info) >> 4)\n#define\tELF32_ST_TYPE(info)\t\t((info) & 0xf)\n#define\tELF32_ST_INFO(bind, type)\t(((bind)<<4)+((type)&0xf))\n\n#define\tELF64_ST_BIND(info)\t\t((info) >> 4)\n#define\tELF64_ST_TYPE(info)\t\t((info) & 0xf)\n#define\tELF64_ST_INFO(bind, type)\t(((bind)<<4)+((type)&0xf))\n\n\n#define\tSTB_LOCAL\t0\t\t/* BIND */\n#define\tSTB_GLOBAL\t1\n#define\tSTB_WEAK\t2\n#define\tSTB_NUM\t\t3\n\n#define\tSTB_LOPROC\t13\t\t/* processor specific range */\n#define\tSTB_HIPROC\t15\n\n#define\tSTT_NOTYPE\t0\t\t/* TYPE */\n#define\tSTT_OBJECT\t1\n#define\tSTT_FUNC\t2\n#define\tSTT_SECTION\t3\n#define\tSTT_FILE\t4\n#define\tSTT_COMMON\t5\n#define\tSTT_TLS\t\t6\n#define\tSTT_NUM\t\t7\n\n#define\tSTT_LOPROC\t13\t\t/* processor specific range */\n#define\tSTT_HIPROC\t15\n\n/*\n *\tThe macros decompose values for S.st_other\n *\n *\tvisibility = ELF32_ST_VISIBILITY(S.st_other)\n */\n#define\tELF32_ST_VISIBILITY(other)\t((other)&0x7)\n#define\tELF64_ST_VISIBILITY(other)\t((other)&0x7)\n\n#define\tSTV_DEFAULT\t0\n#define\tSTV_INTERNAL\t1\n#define\tSTV_HIDDEN\t2\n#define\tSTV_PROTECTED\t3\n#define\tSTV_EXPORTED\t4\n#define\tSTV_SINGLETON\t5\n#define\tSTV_ELIMINATE\t6\n\n#define\tSTV_NUM\t\t7\n\n/*\n *\tRelocation\n */\n\ntypedef struct {\n\tElf32_Addr\tr_offset;\n\tElf32_Word\tr_info;\t\t/* sym, type: ELF32_R_... */\n} Elf32_Rel;\n\ntypedef struct {\n\tElf32_Addr\tr_offset;\n\tElf32_Word\tr_info;\t\t/* sym, type: ELF32_R_... */\n\tElf32_Sword\tr_addend;\n} Elf32_Rela;\n\n#if defined(_LP64) || defined(_LONGLONG_TYPE)\ntypedef struct {\n\tElf64_Addr\tr_offset;\n\tElf64_Xword\tr_info;\t\t/* sym, type: ELF64_R_... */\n} Elf64_Rel;\n\ntypedef struct {\n\tElf64_Addr\tr_offset;\n\tElf64_Xword\tr_info;\t\t/* sym, type: ELF64_R_... */\n\tElf64_Sxword\tr_addend;\n} Elf64_Rela;\n#endif\t/* defined(_LP64) || defined(_LONGLONG_TYPE) */\n\n\n/*\n *\tThe macros compose and decompose values for Rel.r_info, Rela.f_info\n *\n *\tsym = ELF32_R_SYM(R.r_info)\n *\ttype = ELF32_R_TYPE(R.r_info)\n *\tR.r_info = ELF32_R_INFO(sym, type)\n */\n\n#define\tELF32_R_SYM(info)\t((info)>>8)\n#define\tELF32_R_TYPE(info)\t((unsigned char)(info))\n#define\tELF32_R_INFO(sym, type)\t(((sym)<<8)+(unsigned char)(type))\n\n#define\tELF64_R_SYM(info)\t((info)>>32)\n#define\tELF64_R_TYPE(info)    \t((Elf64_Word)(info))\n#define\tELF64_R_INFO(sym, type)\t(((Elf64_Xword)(sym)<<32)+(Elf64_Xword)(type))\n\n\n/*\n * The r_info field is composed of two 32-bit components: the symbol\n * table index and the relocation type.  The relocation type for SPARC V9\n * is further decomposed into an 8-bit type identifier and a 24-bit type\n * dependent data field.  For the existing Elf32 relocation types,\n * that data field is zero.\n */\n#define\tELF64_R_TYPE_DATA(info)\t(((Elf64_Xword)(info)<<32)>>40)\n#define\tELF64_R_TYPE_ID(info)\t(((Elf64_Xword)(info)<<56)>>56)\n#define\tELF64_R_TYPE_INFO(data, type)\t\\\n\t\t(((Elf64_Xword)(data)<<8)+(Elf64_Xword)(type))\n\n\n/*\n * Section Group Flags (SHT_GROUP)\n */\n#define\tGRP_COMDAT\t0x01\n\n\n/*\n *\tNote entry header\n */\n\ntypedef struct {\n\tElf32_Word\tn_namesz;\t/* length of note's name */\n\tElf32_Word\tn_descsz;\t/* length of note's \"desc\" */\n\tElf32_Word\tn_type;\t\t/* type of note */\n} Elf32_Nhdr;\n\n#if defined(_LP64) || defined(_LONGLONG_TYPE)\ntypedef struct {\n\tElf64_Word\tn_namesz;\t/* length of note's name */\n\tElf64_Word\tn_descsz;\t/* length of note's \"desc\" */\n\tElf64_Word\tn_type;\t\t/* type of note */\n} Elf64_Nhdr;\n#endif\t/* defined(_LP64) || defined(_LONGLONG_TYPE) */\n\n/*\n *\tMove entry\n */\n#if defined(_LP64) || defined(_LONGLONG_TYPE)\ntypedef struct {\n\tElf32_Lword\tm_value;\t/* symbol value */\n\tElf32_Word \tm_info;\t\t/* size + index */\n\tElf32_Word\tm_poffset;\t/* symbol offset */\n\tElf32_Half\tm_repeat;\t/* repeat count */\n\tElf32_Half\tm_stride;\t/* stride info */\n} Elf32_Move;\n\n/*\n *\tThe macros compose and decompose values for Move.r_info\n *\n *\tsym = ELF32_M_SYM(M.m_info)\n *\tsize = ELF32_M_SIZE(M.m_info)\n *\tM.m_info = ELF32_M_INFO(sym, size)\n */\n#define\tELF32_M_SYM(info)\t((info)>>8)\n#define\tELF32_M_SIZE(info)\t((unsigned char)(info))\n#define\tELF32_M_INFO(sym, size)\t(((sym)<<8)+(unsigned char)(size))\n\ntypedef struct {\n\tElf64_Lword\tm_value;\t/* symbol value */\n\tElf64_Xword \tm_info;\t\t/* size + index */\n\tElf64_Xword\tm_poffset;\t/* symbol offset */\n\tElf64_Half\tm_repeat;\t/* repeat count */\n\tElf64_Half\tm_stride;\t/* stride info */\n} Elf64_Move;\n#define\tELF64_M_SYM(info)\t((info)>>8)\n#define\tELF64_M_SIZE(info)\t((unsigned char)(info))\n#define\tELF64_M_INFO(sym, size)\t(((sym)<<8)+(unsigned char)(size))\n\n#endif\t/* defined(_LP64) || defined(_LONGLONG_TYPE) */\n\n\n/*\n *\tHardware/Software capabilities entry\n */\n#ifndef\t_ASM\ntypedef struct {\n\tElf32_Word\tc_tag;\t\t/* how to interpret value */\n\tunion {\n\t\tElf32_Word\tc_val;\n\t\tElf32_Addr\tc_ptr;\n\t} c_un;\n} Elf32_Cap;\n\n#if defined(_LP64) || defined(_LONGLONG_TYPE)\ntypedef struct {\n\tElf64_Xword\tc_tag;\t\t/* how to interpret value */\n\tunion {\n\t\tElf64_Xword\tc_val;\n\t\tElf64_Addr\tc_ptr;\n\t} c_un;\n} Elf64_Cap;\n#endif\t/* defined(_LP64) || defined(_LONGLONG_TYPE) */\n#endif\n\n#define\tCA_SUNW_NULL\t0\n#define\tCA_SUNW_HW_1\t1\t\t/* first hardware capabilities entry */\n#define\tCA_SUNW_SF_1\t2\t\t/* first software capabilities entry */\n\n/*\n * Define software capabilities (CA_SUNW_SF_1 values).  Note, hardware\n * capabilities (CA_SUNW_HW_1 values) are taken directly from sys/auxv_$MACH.h.\n */\n#define\tSF1_SUNW_FPKNWN\t0x001\t\t/* use/non-use of frame pointer is */\n#define\tSF1_SUNW_FPUSED\t0x002\t\t/*\tknown, and frame pointer is */\n\t\t\t\t\t/*\tin use */\n#define\tSF1_SUNW_MASK\t0x003\t\t/* known software capabilities mask */\n\n\n/*\n *\tKnown values for note entry types (e_type == ET_CORE)\n */\n\n#define\tNT_PRSTATUS\t1\t/* prstatus_t\t<sys/old_procfs.h>\t*/\n#define\tNT_PRFPREG\t2\t/* prfpregset_t\t<sys/old_procfs.h>\t*/\n#define\tNT_PRPSINFO\t3\t/* prpsinfo_t\t<sys/old_procfs.h>\t*/\n#define\tNT_PRXREG\t4\t/* prxregset_t\t<sys/procfs.h>\t\t*/\n#define\tNT_PLATFORM\t5\t/* string from sysinfo(SI_PLATFORM)\t*/\n#define\tNT_AUXV\t\t6\t/* auxv_t array\t<sys/auxv.h>\t\t*/\n#define\tNT_GWINDOWS\t7\t/* gwindows_t\tSPARC only\t\t*/\n#define\tNT_ASRS\t\t8\t/* asrset_t\tSPARC V9 only\t\t*/\n#define\tNT_LDT\t\t9\t/* ssd array\t<sys/sysi86.h> IA32 only */\n#define\tNT_PSTATUS\t10\t/* pstatus_t\t<sys/procfs.h>\t\t*/\n#define\tNT_PSINFO\t13\t/* psinfo_t\t<sys/procfs.h>\t\t*/\n#define\tNT_PRCRED\t14\t/* prcred_t\t<sys/procfs.h>\t\t*/\n#define\tNT_UTSNAME\t15\t/* struct utsname <sys/utsname.h>\t*/\n#define\tNT_LWPSTATUS\t16\t/* lwpstatus_t\t<sys/procfs.h>\t\t*/\n#define\tNT_LWPSINFO\t17\t/* lwpsinfo_t\t<sys/procfs.h>\t\t*/\n#define\tNT_PRPRIV\t18\t/* prpriv_t\t<sys/procfs.h>\t\t*/\n#define\tNT_PRPRIVINFO\t19\t/* priv_impl_info_t <sys/priv.h>\t*/\n#define\tNT_CONTENT\t20\t/* core_content_t <sys/corectl.h>\t*/\n#define\tNT_ZONENAME\t21\t/* string from getzonenamebyid(3C)\t*/\n#define\tNT_NUM\t\t21\n\n\n#ifdef _KERNEL\n/*\n * The following routine checks the processor-specific\n * fields of an ELF header.\n */\nint\telfheadcheck(unsigned char, Elf32_Half, Elf32_Word);\n#endif\n\n#ifdef\t__cplusplus\n}\n#endif\n\n#if defined(ELF_TARGET_ALL) || defined(ELF_TARGET_SPARC)\n#include <sys/elf_SPARC.h>\n#endif\n\n#if defined(ELF_TARGET_ALL) || defined(ELF_TARGET_386)\n\n#if !defined(__APPLE__)\n#include <sys/elf_386.h>\n#else /* is Apple Mac OS X */\n#include \"elf_386.h\" /* In lieu of Solaris <sys/elf_386.h> */\n#endif /* __APPLE__ */\n#endif\n\n#if defined(ELF_TARGET_ALL) || defined(ELF_TARGET_AMD64)\n#include <sys/elf_amd64.h>\n#endif\n\n#endif\t/* _SYS_ELF_H */"
  },
  {
    "path": "src/App.config",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<configuration>\n    <startup> \n        \n    <supportedRuntime version=\"v4.0\" sku=\".NETFramework,Version=v4.5\"/></startup>\n</configuration>\n"
  },
  {
    "path": "src/Backends/AMDDriverBackend.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Windows.Forms;\n\nnamespace Pyramid\n{\n    class AMDDriverResultSet : IResultSet\n    {\n        private AMDDriverResultsPanel m_Results;\n        private TextBox m_Analysis = new TextBox();\n\n        public string Name { get { return \"AMDDXX\"; } }\n        public Control AnalysisPanel { get { return m_Analysis; } }\n        public Control ResultsPanel { get { return m_Results; } }\n\n        public AMDDriverResultSet( IDXShaderReflection reflection )\n        {\n            m_Results = new AMDDriverResultsPanel(reflection);\n            m_Analysis.Dock      = DockStyle.Fill;\n            m_Analysis.ReadOnly  = true;\n            m_Analysis.Multiline = true;\n            m_Analysis.Font = new System.Drawing.Font(\"Lucida Console\", 8);\n\n            m_Results.AsicChanged += delegate(IAMDShader sh)\n            {\n                m_Analysis.Text = sh.PrintStats();\n            };\n        }\n\n        public void Add( IAMDShader sh )\n        {\n            m_Results.AddResult(sh);\n        }\n    }\n\n    class AMDDriverBackendOptions : IBackendOptions\n    {\n        private List<string> m_RequestedAsics;\n\n        public AMDDriverBackendOptions(List<string> requestedAsics)\n        {\n            m_RequestedAsics = (requestedAsics != null) ? requestedAsics : new List<string>();\n        }\n\n        public List<string> Asics { get { return m_RequestedAsics; } }\n    }\n\n    class AMDDriverBackend : IBackend\n    {\n        private List<string> m_SupportedAsics = new List<string>();\n        private ID3DCompiler m_FXC = null;\n        private IAMDDriver m_Driver = null;\n\n        public string Name { get { return \"AMDDXX\"; } }\n        public IEnumerable<string> Asics { get { return m_SupportedAsics; } }\n\n        public AMDDriverBackend( IAMDDriver driver, ID3DCompiler fxc  )\n        {\n            m_FXC = fxc;\n            m_Driver = driver;\n\n            if (m_Driver != null)\n            {\n                foreach (IAMDAsic asic in m_Driver.Asics)\n                {\n                    m_SupportedAsics.Add(asic.Name);\n                }\n            }\n        }\n\n        private bool CompileForAsic(List<string> asics, string asic)\n        {\n            if (asics == null || asics.Count == 0)\n                return true;\n\n            return asics.Contains(asic);\n        }\n\n        public IResultSet Compile(IShader shaderObj, IBackendOptions options)\n        {\n            if ( !(shaderObj is HLSLShader ) )\n                return null;\n\n            HLSLShader shaderHLSL = shaderObj as HLSLShader;\n            IHLSLOptions hlslOpts = shaderHLSL.CompileOptions;\n            AMDDriverBackendOptions backendOptions = options as AMDDriverBackendOptions;\n            string shader = shaderObj.Code;\n\n            if (shaderHLSL.WasCompiledWithErrors)\n                return null;\n\n            try\n            {\n                // compile here if we must.  Recycle existing blob if we can\n                IDXShaderBlob blob = shaderHLSL.CompiledBlob;\n                if ( blob == null )\n                {\n                    if (!shaderHLSL.Compile(m_FXC, null))\n                        return null;\n                    blob = shaderHLSL.CompiledBlob;\n                }\n                if (!(blob is IDXBCShaderBlob))\n                    return null;\n\n                IDXBCShaderBlob dxcBlob = blob as IDXBCShaderBlob;\n\n                IDXShaderReflection reflect = dxcBlob.Reflect();\n\n                IDXShaderBlob exe = dxcBlob.GetExecutableBlob();\n                if (exe == null)\n                    return null;\n\n                byte[] bytes = exe.ReadBytes();\n\n                AMDDriverResultSet rs = new AMDDriverResultSet(reflect );\n\n                foreach (IAMDAsic a in m_Driver.Asics)\n                {\n                    if (CompileForAsic(backendOptions.Asics, a.Name))\n                    {\n                        IAMDShader sh = m_Driver.CompileDXBlob(a, bytes, reflect);\n                        rs.Add(sh);\n                    }\n                }\n\n                return rs;\n            }\n            catch( System.Exception ex )\n            {\n                MessageBox.Show(ex.Message);\n                return null;\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "src/Backends/AMDDriverResultsPanel.Designer.cs",
    "content": "﻿namespace Pyramid\n{\n    partial class AMDDriverResultsPanel\n    {\n        /// <summary> \n        /// Required designer variable.\n        /// </summary>\n        private System.ComponentModel.IContainer components = null;\n\n        /// <summary> \n        /// Clean up any resources being used.\n        /// </summary>\n        /// <param name=\"disposing\">true if managed resources should be disposed; otherwise, false.</param>\n        protected override void Dispose(bool disposing)\n        {\n            if (disposing && (components != null))\n            {\n                components.Dispose();\n            }\n            base.Dispose(disposing);\n        }\n\n        #region Component Designer generated code\n\n        /// <summary> \n        /// Required method for Designer support - do not modify \n        /// the contents of this method with the code editor.\n        /// </summary>\n        private void InitializeComponent()\n        {\n            this.tabControl1 = new System.Windows.Forms.TabControl();\n            this.tabPage2 = new System.Windows.Forms.TabPage();\n            this.txtISA = new System.Windows.Forms.TextBox();\n            this.tabPage1 = new System.Windows.Forms.TabPage();\n            this.txtHex = new System.Windows.Forms.TextBox();\n            this.tabPage3 = new System.Windows.Forms.TabPage();\n            this.txtEncodings = new System.Windows.Forms.TextBox();\n            this.label1 = new System.Windows.Forms.Label();\n            this.cmbAsic = new System.Windows.Forms.ComboBox();\n            this.btnScrutinize = new System.Windows.Forms.Button();\n            this.tabControl1.SuspendLayout();\n            this.tabPage2.SuspendLayout();\n            this.tabPage1.SuspendLayout();\n            this.tabPage3.SuspendLayout();\n            this.SuspendLayout();\n            // \n            // tabControl1\n            // \n            this.tabControl1.Alignment = System.Windows.Forms.TabAlignment.Bottom;\n            this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) \n            | System.Windows.Forms.AnchorStyles.Left) \n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.tabControl1.Controls.Add(this.tabPage2);\n            this.tabControl1.Controls.Add(this.tabPage1);\n            this.tabControl1.Controls.Add(this.tabPage3);\n            this.tabControl1.Location = new System.Drawing.Point(3, 38);\n            this.tabControl1.Name = \"tabControl1\";\n            this.tabControl1.SelectedIndex = 0;\n            this.tabControl1.Size = new System.Drawing.Size(320, 185);\n            this.tabControl1.TabIndex = 5;\n            // \n            // tabPage2\n            // \n            this.tabPage2.Controls.Add(this.txtISA);\n            this.tabPage2.Location = new System.Drawing.Point(4, 4);\n            this.tabPage2.Name = \"tabPage2\";\n            this.tabPage2.Padding = new System.Windows.Forms.Padding(3);\n            this.tabPage2.Size = new System.Drawing.Size(312, 159);\n            this.tabPage2.TabIndex = 1;\n            this.tabPage2.Text = \"Asm\";\n            this.tabPage2.UseVisualStyleBackColor = true;\n            // \n            // txtISA\n            // \n            this.txtISA.Dock = System.Windows.Forms.DockStyle.Fill;\n            this.txtISA.Font = new System.Drawing.Font(\"Lucida Console\", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\n            this.txtISA.Location = new System.Drawing.Point(3, 3);\n            this.txtISA.Multiline = true;\n            this.txtISA.Name = \"txtISA\";\n            this.txtISA.ReadOnly = true;\n            this.txtISA.ScrollBars = System.Windows.Forms.ScrollBars.Both;\n            this.txtISA.Size = new System.Drawing.Size(306, 153);\n            this.txtISA.TabIndex = 0;\n            // \n            // tabPage1\n            // \n            this.tabPage1.Controls.Add(this.txtHex);\n            this.tabPage1.Location = new System.Drawing.Point(4, 4);\n            this.tabPage1.Name = \"tabPage1\";\n            this.tabPage1.Padding = new System.Windows.Forms.Padding(3);\n            this.tabPage1.Size = new System.Drawing.Size(312, 159);\n            this.tabPage1.TabIndex = 0;\n            this.tabPage1.Text = \"Hex\";\n            this.tabPage1.UseVisualStyleBackColor = true;\n            // \n            // txtHex\n            // \n            this.txtHex.Dock = System.Windows.Forms.DockStyle.Fill;\n            this.txtHex.Font = new System.Drawing.Font(\"Lucida Console\", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\n            this.txtHex.Location = new System.Drawing.Point(3, 3);\n            this.txtHex.Multiline = true;\n            this.txtHex.Name = \"txtHex\";\n            this.txtHex.ReadOnly = true;\n            this.txtHex.ScrollBars = System.Windows.Forms.ScrollBars.Both;\n            this.txtHex.Size = new System.Drawing.Size(306, 153);\n            this.txtHex.TabIndex = 0;\n            // \n            // tabPage3\n            // \n            this.tabPage3.Controls.Add(this.txtEncodings);\n            this.tabPage3.Location = new System.Drawing.Point(4, 4);\n            this.tabPage3.Name = \"tabPage3\";\n            this.tabPage3.Padding = new System.Windows.Forms.Padding(3);\n            this.tabPage3.Size = new System.Drawing.Size(312, 159);\n            this.tabPage3.TabIndex = 2;\n            this.tabPage3.Text = \"Encodings\";\n            this.tabPage3.UseVisualStyleBackColor = true;\n            // \n            // txtEncodings\n            // \n            this.txtEncodings.Dock = System.Windows.Forms.DockStyle.Fill;\n            this.txtEncodings.Font = new System.Drawing.Font(\"Lucida Console\", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\n            this.txtEncodings.Location = new System.Drawing.Point(3, 3);\n            this.txtEncodings.Multiline = true;\n            this.txtEncodings.Name = \"txtEncodings\";\n            this.txtEncodings.ReadOnly = true;\n            this.txtEncodings.ScrollBars = System.Windows.Forms.ScrollBars.Both;\n            this.txtEncodings.Size = new System.Drawing.Size(306, 153);\n            this.txtEncodings.TabIndex = 1;\n            // \n            // label1\n            // \n            this.label1.AutoSize = true;\n            this.label1.Location = new System.Drawing.Point(8, 14);\n            this.label1.Name = \"label1\";\n            this.label1.Size = new System.Drawing.Size(27, 13);\n            this.label1.TabIndex = 4;\n            this.label1.Text = \"Asic\";\n            // \n            // cmbAsic\n            // \n            this.cmbAsic.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) \n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.cmbAsic.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\n            this.cmbAsic.FormattingEnabled = true;\n            this.cmbAsic.Location = new System.Drawing.Point(47, 11);\n            this.cmbAsic.Name = \"cmbAsic\";\n            this.cmbAsic.Size = new System.Drawing.Size(199, 21);\n            this.cmbAsic.TabIndex = 3;\n            this.cmbAsic.SelectedIndexChanged += new System.EventHandler(this.cmbAsic_SelectedIndexChanged);\n            // \n            // btnScrutinize\n            // \n            this.btnScrutinize.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\n            this.btnScrutinize.Location = new System.Drawing.Point(252, 7);\n            this.btnScrutinize.Name = \"btnScrutinize\";\n            this.btnScrutinize.Size = new System.Drawing.Size(64, 27);\n            this.btnScrutinize.TabIndex = 7;\n            this.btnScrutinize.Text = \"Scrutinize\";\n            this.btnScrutinize.UseVisualStyleBackColor = true;\n            this.btnScrutinize.Click += new System.EventHandler(this.btnScrutinize_Click);\n            // \n            // AMDDriverResultsPanel\n            // \n            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\n            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\n            this.Controls.Add(this.btnScrutinize);\n            this.Controls.Add(this.tabControl1);\n            this.Controls.Add(this.label1);\n            this.Controls.Add(this.cmbAsic);\n            this.Name = \"AMDDriverResultsPanel\";\n            this.Size = new System.Drawing.Size(326, 235);\n            this.tabControl1.ResumeLayout(false);\n            this.tabPage2.ResumeLayout(false);\n            this.tabPage2.PerformLayout();\n            this.tabPage1.ResumeLayout(false);\n            this.tabPage1.PerformLayout();\n            this.tabPage3.ResumeLayout(false);\n            this.tabPage3.PerformLayout();\n            this.ResumeLayout(false);\n            this.PerformLayout();\n\n        }\n\n        #endregion\n\n        private System.Windows.Forms.TabControl tabControl1;\n        private System.Windows.Forms.TabPage tabPage2;\n        private System.Windows.Forms.TextBox txtISA;\n        private System.Windows.Forms.TabPage tabPage1;\n        private System.Windows.Forms.TextBox txtHex;\n        private System.Windows.Forms.Label label1;\n        private System.Windows.Forms.ComboBox cmbAsic;\n        private System.Windows.Forms.TabPage tabPage3;\n        private System.Windows.Forms.TextBox txtEncodings;\n        private System.Windows.Forms.Button btnScrutinize;\n\n    }\n}\n"
  },
  {
    "path": "src/Backends/AMDDriverResultsPanel.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Drawing;\nusing System.Data;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Windows.Forms;\n\nnamespace Pyramid\n{\n    public partial class AMDDriverResultsPanel : UserControl\n    {\n        private List<IAMDShader> m_Shaders = new List<IAMDShader>();\n        \n        IDXShaderReflection m_DXReflection;\n\n        public delegate void AsicChangedDelegate(IAMDShader shader);\n        public event AsicChangedDelegate AsicChanged;\n        \n        public AMDDriverResultsPanel( IDXShaderReflection shader )\n        {\n            InitializeComponent();\n            m_DXReflection = shader;\n            btnScrutinize.Enabled =  (shader.GetShaderType() == HLSLShaderType.VERTEX ||\n                                      shader.GetShaderType() == HLSLShaderType.PIXEL ||\n                                      shader.GetShaderType() == HLSLShaderType.COMPUTE );\n        }\n\n        public void AddResult(IAMDShader shader)\n        {\n            m_Shaders.Add(shader);\n            cmbAsic.Items.Add(shader.Asic.Name);\n            if (cmbAsic.Items.Count == 1)\n                cmbAsic.SelectedIndex = 0;\n        }\n\n        private string HexDump( IAMDShader sh )\n        {\n            byte[] bytes = sh.ReadISABytes();\n            int nBytes = bytes.Length;\n            StringBuilder str = new StringBuilder();\n\n            if (nBytes % 4 == 0)\n            {\n                for (int i = 0; i < nBytes; i += 4)\n                {\n                    int n = bytes[i] |\n                             bytes[i + 1] << 8 |\n                             bytes[i + 2] << 16 |\n                             bytes[i + 3] << 24;\n                    str.AppendFormat(\"{0:X8} \", n);\n                    str.AppendLine();\n                }\n            }\n            else\n            {\n                for (int i = 0; i < nBytes; i++)\n                {\n                    if (i % 8 == 0)\n                        str.AppendLine();\n                    str.AppendFormat(\"{0:X2} \", bytes[i]);\n                }\n            }\n            str.AppendLine();\n            return str.ToString();\n        }\n\n        private void cmbAsic_SelectedIndexChanged(object sender, EventArgs e)\n        {\n            int i = cmbAsic.SelectedIndex;\n            if (i >= 0 && i < m_Shaders.Count)\n            {\n                txtHex.Text = HexDump(m_Shaders[i]);\n                txtEncodings.Text = m_Shaders[i].ListEncodings();\n                txtISA.Text = m_Shaders[i].Disassemble();\n            }\n            else\n            {\n                txtHex.Text = \"\";\n                txtISA.Text = \"\";\n            }\n            AsicChanged(m_Shaders[i]);\n        }\n\n        private void btnScrutinize_Click(object sender, EventArgs e)\n        {\n            int i = cmbAsic.SelectedIndex;\n            if (i >= 0 && i < m_Shaders.Count)\n            {\n                IAMDShader sh = m_Shaders[cmbAsic.SelectedIndex];\n\n                Scrutinizer.IScrutinizer backend     = sh.CreateScrutinizer();\n                List<Scrutinizer.IInstruction> Ops   = backend.BuildProgram();\n                List<Scrutinizer.IInstruction> Fetch = backend.BuildDXFetchShader(m_DXReflection);\n\n                Scrutinizer.UI.ScrutinizerForm f = new Scrutinizer.UI.ScrutinizerForm(Fetch, Ops, backend);\n                f.ShowDialog();\n            }\n          \n        }\n\n    }\n}\n"
  },
  {
    "path": "src/Backends/AMDDriverResultsPanel.resx",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n  <!-- \n    Microsoft ResX Schema \n    \n    Version 2.0\n    \n    The primary goals of this format is to allow a simple XML format \n    that is mostly human readable. The generation and parsing of the \n    various data types are done through the TypeConverter classes \n    associated with the data types.\n    \n    Example:\n    \n    ... ado.net/XML headers & schema ...\n    <resheader name=\"resmimetype\">text/microsoft-resx</resheader>\n    <resheader name=\"version\">2.0</resheader>\n    <resheader name=\"reader\">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\n    <resheader name=\"writer\">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\n    <data name=\"Name1\"><value>this is my long string</value><comment>this is a comment</comment></data>\n    <data name=\"Color1\" type=\"System.Drawing.Color, System.Drawing\">Blue</data>\n    <data name=\"Bitmap1\" mimetype=\"application/x-microsoft.net.object.binary.base64\">\n        <value>[base64 mime encoded serialized .NET Framework object]</value>\n    </data>\n    <data name=\"Icon1\" type=\"System.Drawing.Icon, System.Drawing\" mimetype=\"application/x-microsoft.net.object.bytearray.base64\">\n        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\n        <comment>This is a comment</comment>\n    </data>\n                \n    There are any number of \"resheader\" rows that contain simple \n    name/value pairs.\n    \n    Each data row contains a name, and value. The row also contains a \n    type or mimetype. Type corresponds to a .NET class that support \n    text/value conversion through the TypeConverter architecture. \n    Classes that don't support this are serialized and stored with the \n    mimetype set.\n    \n    The mimetype is used for serialized objects, and tells the \n    ResXResourceReader how to depersist the object. This is currently not \n    extensible. For a given mimetype the value must be set accordingly:\n    \n    Note - application/x-microsoft.net.object.binary.base64 is the format \n    that the ResXResourceWriter will generate, however the reader can \n    read any of the formats listed below.\n    \n    mimetype: application/x-microsoft.net.object.binary.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\n            : and then encoded with base64 encoding.\n    \n    mimetype: application/x-microsoft.net.object.soap.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\n            : and then encoded with base64 encoding.\n\n    mimetype: application/x-microsoft.net.object.bytearray.base64\n    value   : The object must be serialized into a byte array \n            : using a System.ComponentModel.TypeConverter\n            : and then encoded with base64 encoding.\n    -->\n  <xsd:schema id=\"root\" xmlns=\"\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">\n    <xsd:import namespace=\"http://www.w3.org/XML/1998/namespace\" />\n    <xsd:element name=\"root\" msdata:IsDataSet=\"true\">\n      <xsd:complexType>\n        <xsd:choice maxOccurs=\"unbounded\">\n          <xsd:element name=\"metadata\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" use=\"required\" type=\"xsd:string\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"assembly\">\n            <xsd:complexType>\n              <xsd:attribute name=\"alias\" type=\"xsd:string\" />\n              <xsd:attribute name=\"name\" type=\"xsd:string\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"data\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n                <xsd:element name=\"comment\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"2\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" msdata:Ordinal=\"1\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" msdata:Ordinal=\"3\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" msdata:Ordinal=\"4\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"resheader\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" />\n            </xsd:complexType>\n          </xsd:element>\n        </xsd:choice>\n      </xsd:complexType>\n    </xsd:element>\n  </xsd:schema>\n  <resheader name=\"resmimetype\">\n    <value>text/microsoft-resx</value>\n  </resheader>\n  <resheader name=\"version\">\n    <value>2.0</value>\n  </resheader>\n  <resheader name=\"reader\">\n    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n  <resheader name=\"writer\">\n    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n  <metadata name=\"txtISA.Locked\" type=\"System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\">\n    <value>True</value>\n  </metadata>\n  <metadata name=\"txtISA.Locked\" type=\"System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\">\n    <value>True</value>\n  </metadata>\n  <metadata name=\"txtHex.Locked\" type=\"System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\">\n    <value>True</value>\n  </metadata>\n  <metadata name=\"txtHex.Locked\" type=\"System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\">\n    <value>True</value>\n  </metadata>\n  <metadata name=\"txtEncodings.Locked\" type=\"System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\">\n    <value>True</value>\n  </metadata>\n  <metadata name=\"txtEncodings.Locked\" type=\"System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\">\n    <value>True</value>\n  </metadata>\n</root>"
  },
  {
    "path": "src/Backends/CodeXLAnalysisPanel.Designer.cs",
    "content": "﻿namespace Pyramid\n{\n    partial class CodeXLAnalysisPanel\n    {\n        /// <summary> \n        /// Required designer variable.\n        /// </summary>\n        private System.ComponentModel.IContainer components = null;\n\n        /// <summary> \n        /// Clean up any resources being used.\n        /// </summary>\n        /// <param name=\"disposing\">true if managed resources should be disposed; otherwise, false.</param>\n        protected override void Dispose(bool disposing)\n        {\n            if (disposing && (components != null))\n            {\n                components.Dispose();\n            }\n            base.Dispose(disposing);\n        }\n\n        #region Component Designer generated code\n\n        /// <summary> \n        /// Required method for Designer support - do not modify \n        /// the contents of this method with the code editor.\n        /// </summary>\n        private void InitializeComponent()\n        {\n            this.listView1 = new System.Windows.Forms.ListView();\n            this.Key = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));\n            this.Value = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));\n            this.SuspendLayout();\n            // \n            // listView1\n            // \n            this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {\n            this.Key,\n            this.Value});\n            this.listView1.Dock = System.Windows.Forms.DockStyle.Fill;\n            this.listView1.Location = new System.Drawing.Point(0, 0);\n            this.listView1.Name = \"listView1\";\n            this.listView1.Size = new System.Drawing.Size(316, 225);\n            this.listView1.TabIndex = 0;\n            this.listView1.UseCompatibleStateImageBehavior = false;\n            this.listView1.View = System.Windows.Forms.View.Details;\n            // \n            // Key\n            // \n            this.Key.Text = \"Key\";\n            this.Key.Width = 95;\n            // \n            // Value\n            // \n            this.Value.Text = \"Value\";\n            this.Value.Width = 98;\n            // \n            // AMDAnalysisPanel\n            // \n            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\n            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\n            this.Controls.Add(this.listView1);\n            this.Name = \"AMDAnalysisPanel\";\n            this.Size = new System.Drawing.Size(316, 225);\n            this.ResumeLayout(false);\n\n        }\n\n        #endregion\n\n        private System.Windows.Forms.ListView listView1;\n        private System.Windows.Forms.ColumnHeader Key;\n        private System.Windows.Forms.ColumnHeader Value;\n\n    }\n}\n"
  },
  {
    "path": "src/Backends/CodeXLAnalysisPanel.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Drawing;\nusing System.Data;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Windows.Forms;\n\nnamespace Pyramid\n{\n    public partial class CodeXLAnalysisPanel : UserControl\n    {\n        private Dictionary<string, List<KeyValuePair<string,string>>> m_DataSet = new Dictionary<string, List<KeyValuePair<string,string>>>();\n\n        public CodeXLAnalysisPanel()\n        {\n            InitializeComponent();\n        }\n\n        public void AddResult(string asic, Dictionary<string, string> vals)\n        {\n            List<KeyValuePair<string,string>> items = new List<KeyValuePair<string,string>>();\n\n            items.Add(new KeyValuePair<string,string>(\"Asic\", asic));\n            items.AddRange(vals);\n            m_DataSet.Add(asic, items);\n            if (m_DataSet.Count == 1)\n                PopulateListView(items);\n        }\n\n        public void SetAsic(string asic)\n        {\n            listView1.Items.Clear();\n            List<KeyValuePair<string,string>> items;\n            if (m_DataSet.TryGetValue(asic, out items))\n                PopulateListView(items);\n        }\n\n        private void PopulateListView(List<KeyValuePair<string, string>> items)\n        {\n            foreach (KeyValuePair<string, string> p in items)\n            {\n                string[] arr = new string[2]; //ahoy!\n                arr[0] = p.Key;\n                arr[1] = p.Value;\n                listView1.Items.Add(new ListViewItem(arr));\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "src/Backends/CodeXLAnalysisPanel.resx",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n  <!-- \n    Microsoft ResX Schema \n    \n    Version 2.0\n    \n    The primary goals of this format is to allow a simple XML format \n    that is mostly human readable. The generation and parsing of the \n    various data types are done through the TypeConverter classes \n    associated with the data types.\n    \n    Example:\n    \n    ... ado.net/XML headers & schema ...\n    <resheader name=\"resmimetype\">text/microsoft-resx</resheader>\n    <resheader name=\"version\">2.0</resheader>\n    <resheader name=\"reader\">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\n    <resheader name=\"writer\">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\n    <data name=\"Name1\"><value>this is my long string</value><comment>this is a comment</comment></data>\n    <data name=\"Color1\" type=\"System.Drawing.Color, System.Drawing\">Blue</data>\n    <data name=\"Bitmap1\" mimetype=\"application/x-microsoft.net.object.binary.base64\">\n        <value>[base64 mime encoded serialized .NET Framework object]</value>\n    </data>\n    <data name=\"Icon1\" type=\"System.Drawing.Icon, System.Drawing\" mimetype=\"application/x-microsoft.net.object.bytearray.base64\">\n        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\n        <comment>This is a comment</comment>\n    </data>\n                \n    There are any number of \"resheader\" rows that contain simple \n    name/value pairs.\n    \n    Each data row contains a name, and value. The row also contains a \n    type or mimetype. Type corresponds to a .NET class that support \n    text/value conversion through the TypeConverter architecture. \n    Classes that don't support this are serialized and stored with the \n    mimetype set.\n    \n    The mimetype is used for serialized objects, and tells the \n    ResXResourceReader how to depersist the object. This is currently not \n    extensible. For a given mimetype the value must be set accordingly:\n    \n    Note - application/x-microsoft.net.object.binary.base64 is the format \n    that the ResXResourceWriter will generate, however the reader can \n    read any of the formats listed below.\n    \n    mimetype: application/x-microsoft.net.object.binary.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\n            : and then encoded with base64 encoding.\n    \n    mimetype: application/x-microsoft.net.object.soap.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\n            : and then encoded with base64 encoding.\n\n    mimetype: application/x-microsoft.net.object.bytearray.base64\n    value   : The object must be serialized into a byte array \n            : using a System.ComponentModel.TypeConverter\n            : and then encoded with base64 encoding.\n    -->\n  <xsd:schema id=\"root\" xmlns=\"\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">\n    <xsd:import namespace=\"http://www.w3.org/XML/1998/namespace\" />\n    <xsd:element name=\"root\" msdata:IsDataSet=\"true\">\n      <xsd:complexType>\n        <xsd:choice maxOccurs=\"unbounded\">\n          <xsd:element name=\"metadata\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" use=\"required\" type=\"xsd:string\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"assembly\">\n            <xsd:complexType>\n              <xsd:attribute name=\"alias\" type=\"xsd:string\" />\n              <xsd:attribute name=\"name\" type=\"xsd:string\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"data\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n                <xsd:element name=\"comment\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"2\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" msdata:Ordinal=\"1\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" msdata:Ordinal=\"3\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" msdata:Ordinal=\"4\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"resheader\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" />\n            </xsd:complexType>\n          </xsd:element>\n        </xsd:choice>\n      </xsd:complexType>\n    </xsd:element>\n  </xsd:schema>\n  <resheader name=\"resmimetype\">\n    <value>text/microsoft-resx</value>\n  </resheader>\n  <resheader name=\"version\">\n    <value>2.0</value>\n  </resheader>\n  <resheader name=\"reader\">\n    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n  <resheader name=\"writer\">\n    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n</root>"
  },
  {
    "path": "src/Backends/CodeXLBackend.cs",
    "content": "﻿\nusing System.Diagnostics;\nusing System.Collections.Generic;\nusing System.IO;\nusing System;\nusing System.Windows.Forms;\n\nnamespace Pyramid\n{\n\n    class CodeXLResultSet : IResultSet\n    {\n        private AMDResultsPanel m_ResultsPanel ;\n        private CodeXLAnalysisPanel m_AnalysisPanel;\n\n        public CodeXLResultSet()\n        {\n            m_ResultsPanel = new AMDResultsPanel();\n            m_AnalysisPanel = new CodeXLAnalysisPanel();\n            m_ResultsPanel.AsicChanged +=\n                delegate(string asic)\n                {\n                    m_AnalysisPanel.SetAsic(asic);\n                };\n        }\n\n        public Control ResultsPanel  { get { return m_ResultsPanel; } }\n        public Control AnalysisPanel { get { return m_AnalysisPanel; } }\n        public string Name { get { return \"CodeXL\"; } }\n        public int ResultCount { get { return m_ResultsPanel.ResultCount; } }\n\n        public void AddCompileResult( string asic, string il, string isa )\n        {\n            m_ResultsPanel.AddResult(asic, il, isa);\n        }\n\n        public void AddAnalysisResult( string asic, Dictionary<string,string> vals )\n        {\n            m_AnalysisPanel.AddResult(asic, vals);\n        }\n\n        public void DisplayAsic(string asic)\n        {\n            m_AnalysisPanel.SetAsic(asic);\n            m_ResultsPanel.SetAsic(asic);\n        }\n    }\n\n    class CodeXLBackendOptions : IBackendOptions\n    {\n        private List<string> m_RequestedAsics;\n\n        public CodeXLBackendOptions(List<string> requestedAsics)\n        {\n            m_RequestedAsics = (requestedAsics != null) ? requestedAsics : new List<string>();\n        }\n\n        public List<string> Asics { get { return m_RequestedAsics; } }\n    }\n\n    class CodeXLBackend : IBackend\n    {\n        private List<string> m_SupportedAsics = new List<string>();\n        private string m_CodeXL = \"\";\n        private string m_D3DCompiler = \"\";\n        private string m_TempPath = \"\";\n\n        public string Name { get { return \"CodeXL\"; } }\n        public IEnumerable<string> Asics { get { return m_SupportedAsics; } }\n\n        public static List<String> GetSupportedAsics( string CodeXLPath, string d3dpath  )\n        {\n            // try to run CodeXLAnalyzer to get the asic list\n            // -s \"HLSL\" --DXLocation s -l\"\n            string CommandLine = string.Format(\"-s \\\"HLSL\\\" --DXLocation {0} -l\", d3dpath);\n            List<String> asics = new List<string>();\n\n            ProcessStartInfo pi = new ProcessStartInfo();\n            pi.RedirectStandardOutput = true;\n            pi.RedirectStandardInput = true;\n            pi.RedirectStandardError = true;\n            pi.CreateNoWindow = true;\n            pi.Arguments = CommandLine;\n            pi.FileName = CodeXLPath;\n            pi.UseShellExecute = false;\n\n            try\n            {\n                Process p = Process.Start(pi);\n                p.WaitForExit();\n\n                while (!p.StandardOutput.EndOfStream)\n                {\n                    string s = p.StandardOutput.ReadLine();\n                    asics.Add(s.TrimEnd().TrimStart());\n                }\n\n                // skip whatever text they're emitting, up to 'Devices:'\n                while (!asics[0].Equals(\"Devices:\"))\n                    asics.RemoveAt(0);\n                asics.RemoveAt(0); // remove 'Devices'\n\n                p.Close();\n            }\n            catch (Exception e)\n            {\n                MessageBox.Show(e.Message, \"uh-oh, couldn't get CodeXL asic list\", MessageBoxButtons.OK, MessageBoxIcon.Error);\n            }\n            return asics;\n        }\n\n        public CodeXLBackend( string CodeXLPath, string D3DCompilerPath, string TempPath )\n        {\n            m_SupportedAsics = GetSupportedAsics(CodeXLPath, D3DCompilerPath);\n\n            m_CodeXL        = CodeXLPath;\n            m_D3DCompiler   = D3DCompilerPath;\n            m_TempPath      = TempPath;\n        }\n\n        private bool CompileForAsic( List<string> asics, string asic )\n        {\n            if (asics == null || asics.Count == 0)\n                return true;\n\n            return asics.Contains(asic);\n        }\n\n        public IResultSet Compile(IShader shader, IBackendOptions options)\n        {\n            if ( !(shader is HLSLShader) || !(options is CodeXLBackendOptions) )\n                return null;\n\n            // TODO: Modify CodeXL backend so that it re-uses blob from\n            //    FXC backend where available.  It'd be nice not to have to \n            //    have CodeXL recompile it for us\n            HLSLShader shaderHLSL = shader as HLSLShader;\n            IHLSLOptions hlslOpts = shaderHLSL.CompileOptions;\n            CodeXLBackendOptions backendOptions = options as CodeXLBackendOptions;\n            string text = shader.Code;\n\n            if (shaderHLSL.WasCompiledWithErrors)\n                return null;\n\n            string tmpFile = Path.Combine(m_TempPath, \"PYRAMID_amdcodexl\");\n            try\n            {\n                StreamWriter stream = File.CreateText(tmpFile);\n                stream.Write(text);\n                stream.Close();\n            }\n            catch (Exception e)\n            {\n                MessageBox.Show(e.Message, \"uh-oh, couldn't create temp file\", MessageBoxButtons.OK, MessageBoxIcon.Error);\n                return null;\n            }\n\n            string isaPath = Path.Combine(m_TempPath, \"pyramid.isa\");\n            string analysisPath = Path.Combine(m_TempPath, \"analysis\");\n            string CommandLine = \"-s \\\"HLSL\\\"\";\n            CommandLine = String.Concat( CommandLine, String.Format( \" -p {0}\",hlslOpts.Target.ToString()) );\n            CommandLine = String.Concat( CommandLine, String.Format( \" -f {0} \",hlslOpts.EntryPoint ));\n            CommandLine = String.Concat( CommandLine, String.Format( \" --DXLocation \\\"{0}\\\"\",m_D3DCompiler ));\n            CommandLine = String.Concat( CommandLine, String.Format( \" --isa \\\"{0}\\\"\",isaPath ));\n            CommandLine = String.Concat( CommandLine, String.Format( \" -a \\\"{0}\\\"\",analysisPath ));\n            CommandLine = String.Concat( CommandLine, String.Format( \" --DXFlags {0} \",hlslOpts.GetD3DCompileFlagBits() ));\n\n            CommandLine = String.Concat(CommandLine, tmpFile);\n\n            foreach (string asic in m_SupportedAsics)\n            {\n                if (CompileForAsic(backendOptions.Asics, asic))\n                {\n                    CommandLine = String.Concat(CommandLine, \" -c \", asic, \" \");\n                }\n            }\n            \n            ProcessStartInfo pi = new ProcessStartInfo();\n            pi.RedirectStandardOutput = true;\n            pi.RedirectStandardInput = true;\n            pi.RedirectStandardError = true;\n            pi.CreateNoWindow = true;\n            pi.Arguments = CommandLine;\n            pi.FileName = m_CodeXL;\n            pi.UseShellExecute = false;\n\n            string output;\n            try\n            {\n                int TimeOut = 15000; // TODO: Put in options\n                Process p = Process.Start(pi);\n                output = p.StandardOutput.ReadToEnd();\n                if (p.WaitForExit(TimeOut))\n                {\n                    MessageBox.Show(\"CodeXL took more than 15 seconds\");\n                }\n                p.Close();\n                File.Delete(tmpFile);\n            }\n            catch( Exception e )\n            {\n                MessageBox.Show(e.Message, \"uh-oh, couldn't run CodeXL\", MessageBoxButtons.OK, MessageBoxIcon.Error);\n                return null;\n            }\n\n            // Compile results are emitted in one set of files per asic\n            string defaultAsic = \"\";\n            CodeXLResultSet results  = new CodeXLResultSet();\n            foreach (string asic in m_SupportedAsics)\n            {\n                if (!CompileForAsic(backendOptions.Asics, asic))\n                {\n                    continue;\n                }\n\n                if (defaultAsic == \"\")\n                {\n                    defaultAsic = asic;\n                }\n\n                string isaFile = Path.Combine(m_TempPath, String.Format(\"{0}_pyramid.isa\", asic));\n\n                try\n                {\n                    string isa = File.ReadAllText(isaFile);\n                    results.AddCompileResult(asic, \"CodeXL doesn't support IL output for HLSL\", isa);\n\n                    File.Delete(isaFile);\n                }\n                catch (Exception )\n                {      \n                    // may occur in the event of a compile error. \n                }\n            }\n\n            // Analysis results are emitted in a big CSV file\n            try\n            {\n                string[] lines = File.ReadAllLines(analysisPath);\n                File.Delete(analysisPath);\n\n                try\n                {\n                    // first line is column names\n                    string columns = lines[0];\n                    string[] cols = columns.Split(',');\n\n                    // first column is asic, remaining columns are fields we want to display\n                    for (int i = 1; i < lines.Length; i++)\n                    {\n                        string[] data = lines[i].Split(',');\n                        string asic = data[0];\n                        Dictionary<string, string> vals = new Dictionary<string, string>();\n                        for (int j = 1; j < cols.Length; j++)\n                        {\n                            if( !String.IsNullOrEmpty(data[j]) && !String.IsNullOrEmpty(cols[j]))\n                                vals.Add(cols[j], data[j]);\n                        }\n\n                        results.AddAnalysisResult(asic, vals);\n                    }\n                }\n                catch( Exception e )\n                {\n                    MessageBox.Show(e.Message, \"uh-oh. Couldn't parse CodeXL analysis file.  Did it change?\", MessageBoxButtons.OK, MessageBoxIcon.Error);\n                }\n            }\n            catch( Exception )\n            {\n                // compile error\n            }\n\n            if (results.ResultCount > 0)\n            {\n                results.DisplayAsic(defaultAsic);\n                return results;\n            }\n            else\n                return null;\n        }\n    }\n\n\n}\n\n"
  },
  {
    "path": "src/Backends/CodeXLResultsPanel.Designer.cs",
    "content": "﻿namespace Pyramid\n{\n    partial class AMDResultsPanel\n    {\n        /// <summary> \n        /// Required designer variable.\n        /// </summary>\n        private System.ComponentModel.IContainer components = null;\n\n        /// <summary> \n        /// Clean up any resources being used.\n        /// </summary>\n        /// <param name=\"disposing\">true if managed resources should be disposed; otherwise, false.</param>\n        protected override void Dispose(bool disposing)\n        {\n            if (disposing && (components != null))\n            {\n                components.Dispose();\n            }\n            base.Dispose(disposing);\n        }\n\n        #region Component Designer generated code\n\n        /// <summary> \n        /// Required method for Designer support - do not modify \n        /// the contents of this method with the code editor.\n        /// </summary>\n        private void InitializeComponent()\n        {\n            this.cmbAsic = new System.Windows.Forms.ComboBox();\n            this.label1 = new System.Windows.Forms.Label();\n            this.tabControl1 = new System.Windows.Forms.TabControl();\n            this.tabPage2 = new System.Windows.Forms.TabPage();\n            this.txtISA = new System.Windows.Forms.TextBox();\n            this.tabPage1 = new System.Windows.Forms.TabPage();\n            this.txtIL = new System.Windows.Forms.TextBox();\n            this.tabPage3 = new System.Windows.Forms.TabPage();\n            this.txtLiveReg = new System.Windows.Forms.TextBox();\n            this.tabPage4 = new System.Windows.Forms.TabPage();\n            this.txtToolOutput = new System.Windows.Forms.TextBox();\n            this.tabControl1.SuspendLayout();\n            this.tabPage2.SuspendLayout();\n            this.tabPage1.SuspendLayout();\n            this.tabPage3.SuspendLayout();\n            this.tabPage4.SuspendLayout();\n            this.SuspendLayout();\n            // \n            // cmbAsic\n            // \n            this.cmbAsic.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) \n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.cmbAsic.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\n            this.cmbAsic.FormattingEnabled = true;\n            this.cmbAsic.Location = new System.Drawing.Point(55, 8);\n            this.cmbAsic.Name = \"cmbAsic\";\n            this.cmbAsic.Size = new System.Drawing.Size(166, 21);\n            this.cmbAsic.TabIndex = 0;\n            this.cmbAsic.SelectedIndexChanged += new System.EventHandler(this.cmbAsic_SelectedIndexChanged);\n            // \n            // label1\n            // \n            this.label1.AutoSize = true;\n            this.label1.Location = new System.Drawing.Point(16, 11);\n            this.label1.Name = \"label1\";\n            this.label1.Size = new System.Drawing.Size(27, 13);\n            this.label1.TabIndex = 1;\n            this.label1.Text = \"Asic\";\n            // \n            // tabControl1\n            // \n            this.tabControl1.Alignment = System.Windows.Forms.TabAlignment.Bottom;\n            this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) \n            | System.Windows.Forms.AnchorStyles.Left) \n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.tabControl1.Controls.Add(this.tabPage2);\n            this.tabControl1.Controls.Add(this.tabPage1);\n            this.tabControl1.Controls.Add(this.tabPage3);\n            this.tabControl1.Controls.Add(this.tabPage4);\n            this.tabControl1.Location = new System.Drawing.Point(3, 35);\n            this.tabControl1.Name = \"tabControl1\";\n            this.tabControl1.SelectedIndex = 0;\n            this.tabControl1.Size = new System.Drawing.Size(232, 186);\n            this.tabControl1.TabIndex = 2;\n            // \n            // tabPage2\n            // \n            this.tabPage2.Controls.Add(this.txtISA);\n            this.tabPage2.Location = new System.Drawing.Point(4, 4);\n            this.tabPage2.Name = \"tabPage2\";\n            this.tabPage2.Padding = new System.Windows.Forms.Padding(3);\n            this.tabPage2.Size = new System.Drawing.Size(224, 160);\n            this.tabPage2.TabIndex = 1;\n            this.tabPage2.Text = \"ISA\";\n            this.tabPage2.UseVisualStyleBackColor = true;\n            // \n            // txtISA\n            // \n            this.txtISA.Dock = System.Windows.Forms.DockStyle.Fill;\n            this.txtISA.Font = new System.Drawing.Font(\"Lucida Console\", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\n            this.txtISA.Location = new System.Drawing.Point(3, 3);\n            this.txtISA.Multiline = true;\n            this.txtISA.Name = \"txtISA\";\n            this.txtISA.ReadOnly = true;\n            this.txtISA.ScrollBars = System.Windows.Forms.ScrollBars.Both;\n            this.txtISA.Size = new System.Drawing.Size(218, 154);\n            this.txtISA.TabIndex = 0;\n            // \n            // tabPage1\n            // \n            this.tabPage1.Controls.Add(this.txtIL);\n            this.tabPage1.Location = new System.Drawing.Point(4, 4);\n            this.tabPage1.Name = \"tabPage1\";\n            this.tabPage1.Padding = new System.Windows.Forms.Padding(3);\n            this.tabPage1.Size = new System.Drawing.Size(224, 160);\n            this.tabPage1.TabIndex = 0;\n            this.tabPage1.Text = \"IL\";\n            this.tabPage1.UseVisualStyleBackColor = true;\n            // \n            // txtIL\n            // \n            this.txtIL.Dock = System.Windows.Forms.DockStyle.Fill;\n            this.txtIL.Font = new System.Drawing.Font(\"Lucida Console\", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\n            this.txtIL.Location = new System.Drawing.Point(3, 3);\n            this.txtIL.Multiline = true;\n            this.txtIL.Name = \"txtIL\";\n            this.txtIL.ReadOnly = true;\n            this.txtIL.ScrollBars = System.Windows.Forms.ScrollBars.Both;\n            this.txtIL.Size = new System.Drawing.Size(218, 154);\n            this.txtIL.TabIndex = 0;\n            // \n            // tabPage3\n            // \n            this.tabPage3.Controls.Add(this.txtLiveReg);\n            this.tabPage3.Location = new System.Drawing.Point(4, 4);\n            this.tabPage3.Name = \"tabPage3\";\n            this.tabPage3.Padding = new System.Windows.Forms.Padding(3);\n            this.tabPage3.Size = new System.Drawing.Size(224, 160);\n            this.tabPage3.TabIndex = 2;\n            this.tabPage3.Text = \"LiveReg\";\n            this.tabPage3.UseVisualStyleBackColor = true;\n            // \n            // txtLiveReg\n            // \n            this.txtLiveReg.Dock = System.Windows.Forms.DockStyle.Fill;\n            this.txtLiveReg.Font = new System.Drawing.Font(\"Lucida Console\", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\n            this.txtLiveReg.Location = new System.Drawing.Point(3, 3);\n            this.txtLiveReg.Multiline = true;\n            this.txtLiveReg.Name = \"txtLiveReg\";\n            this.txtLiveReg.ReadOnly = true;\n            this.txtLiveReg.ScrollBars = System.Windows.Forms.ScrollBars.Both;\n            this.txtLiveReg.Size = new System.Drawing.Size(218, 154);\n            this.txtLiveReg.TabIndex = 1;\n            // \n            // tabPage4\n            // \n            this.tabPage4.Controls.Add(this.txtToolOutput);\n            this.tabPage4.Location = new System.Drawing.Point(4, 4);\n            this.tabPage4.Name = \"tabPage4\";\n            this.tabPage4.Padding = new System.Windows.Forms.Padding(3);\n            this.tabPage4.Size = new System.Drawing.Size(224, 160);\n            this.tabPage4.TabIndex = 3;\n            this.tabPage4.Text = \"Output\";\n            this.tabPage4.UseVisualStyleBackColor = true;\n            // \n            // txtToolOutput\n            // \n            this.txtToolOutput.Dock = System.Windows.Forms.DockStyle.Fill;\n            this.txtToolOutput.Font = new System.Drawing.Font(\"Lucida Console\", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\n            this.txtToolOutput.Location = new System.Drawing.Point(3, 3);\n            this.txtToolOutput.Multiline = true;\n            this.txtToolOutput.Name = \"txtToolOutput\";\n            this.txtToolOutput.ReadOnly = true;\n            this.txtToolOutput.ScrollBars = System.Windows.Forms.ScrollBars.Both;\n            this.txtToolOutput.Size = new System.Drawing.Size(218, 154);\n            this.txtToolOutput.TabIndex = 2;\n            // \n            // AMDResultsPanel\n            // \n            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\n            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\n            this.Controls.Add(this.tabControl1);\n            this.Controls.Add(this.label1);\n            this.Controls.Add(this.cmbAsic);\n            this.Name = \"AMDResultsPanel\";\n            this.Size = new System.Drawing.Size(238, 236);\n            this.tabControl1.ResumeLayout(false);\n            this.tabPage2.ResumeLayout(false);\n            this.tabPage2.PerformLayout();\n            this.tabPage1.ResumeLayout(false);\n            this.tabPage1.PerformLayout();\n            this.tabPage3.ResumeLayout(false);\n            this.tabPage3.PerformLayout();\n            this.tabPage4.ResumeLayout(false);\n            this.tabPage4.PerformLayout();\n            this.ResumeLayout(false);\n            this.PerformLayout();\n\n        }\n\n        #endregion\n\n        private System.Windows.Forms.ComboBox cmbAsic;\n        private System.Windows.Forms.Label label1;\n        private System.Windows.Forms.TabControl tabControl1;\n        private System.Windows.Forms.TabPage tabPage1;\n        private System.Windows.Forms.TabPage tabPage2;\n        private System.Windows.Forms.TextBox txtIL;\n        private System.Windows.Forms.TextBox txtISA;\n        private System.Windows.Forms.TabPage tabPage3;\n        private System.Windows.Forms.TextBox txtLiveReg;\n        private System.Windows.Forms.TabPage tabPage4;\n        private System.Windows.Forms.TextBox txtToolOutput;\n    }\n}\n"
  },
  {
    "path": "src/Backends/CodeXLResultsPanel.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Drawing;\nusing System.Data;\nusing System.Text;\nusing System.Windows.Forms;\n\nnamespace Pyramid\n{\n    public partial class AMDResultsPanel : UserControl\n    {\n        private List<String> m_IL    = new List<string>();\n        private List<String> m_ISA   = new List<string>();\n        private List<string> m_LiveReg = new List<String>();\n        public AMDResultsPanel()\n        {\n            InitializeComponent();\n        }\n\n        public int ResultCount { get { return m_IL.Count;  } }\n\n        public delegate void AsicChangedDelegate( string asic );\n        public event AsicChangedDelegate AsicChanged;\n        public void SetToolOutput( string output )\n        {\n            txtToolOutput.Text = output;\n        }\n        public void AddResult(string Asic, string IL, string ISA)\n        {\n            m_IL.Add(IL);\n            m_ISA.Add(ISA);\n            m_LiveReg.Add(\"\");\n            cmbAsic.Items.Add(Asic);\n            if (cmbAsic.Items.Count == 1)\n                cmbAsic.SelectedIndex = 0;\n        }\n\n        public void AddResult(string Asic, string IL, string ISA, string LiveReg)\n        {\n            m_IL.Add(IL);\n            m_ISA.Add(ISA);\n            m_LiveReg.Add(LiveReg);\n            cmbAsic.Items.Add(Asic);\n            if (cmbAsic.Items.Count == 1)\n                cmbAsic.SelectedIndex = 0;\n        }\n\n\n        public void SetAsic(string name)\n        {\n            int index = cmbAsic.Items.IndexOf(name);\n\n            if (index == -1)\n            {\n                txtIL.Text = \"\";\n                txtISA.Text = \"\";\n                txtLiveReg.Text = \"\";\n                return;\n            }\n\n            // invokes handler below indirectly\n            cmbAsic.SelectedIndex = index;\n        }\n\n        private void cmbAsic_SelectedIndexChanged(object sender, EventArgs e)\n        {\n            txtIL.Text  = m_IL[cmbAsic.SelectedIndex];\n            txtISA.Text = m_ISA[cmbAsic.SelectedIndex];\n            txtLiveReg.Text = m_LiveReg[cmbAsic.SelectedIndex];\n            if( AsicChanged != null )\n                AsicChanged((string)cmbAsic.SelectedItem);\n        }\n    }\n}\n"
  },
  {
    "path": "src/Backends/CodeXLResultsPanel.resx",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n  <!-- \n    Microsoft ResX Schema \n    \n    Version 2.0\n    \n    The primary goals of this format is to allow a simple XML format \n    that is mostly human readable. The generation and parsing of the \n    various data types are done through the TypeConverter classes \n    associated with the data types.\n    \n    Example:\n    \n    ... ado.net/XML headers & schema ...\n    <resheader name=\"resmimetype\">text/microsoft-resx</resheader>\n    <resheader name=\"version\">2.0</resheader>\n    <resheader name=\"reader\">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\n    <resheader name=\"writer\">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\n    <data name=\"Name1\"><value>this is my long string</value><comment>this is a comment</comment></data>\n    <data name=\"Color1\" type=\"System.Drawing.Color, System.Drawing\">Blue</data>\n    <data name=\"Bitmap1\" mimetype=\"application/x-microsoft.net.object.binary.base64\">\n        <value>[base64 mime encoded serialized .NET Framework object]</value>\n    </data>\n    <data name=\"Icon1\" type=\"System.Drawing.Icon, System.Drawing\" mimetype=\"application/x-microsoft.net.object.bytearray.base64\">\n        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\n        <comment>This is a comment</comment>\n    </data>\n                \n    There are any number of \"resheader\" rows that contain simple \n    name/value pairs.\n    \n    Each data row contains a name, and value. The row also contains a \n    type or mimetype. Type corresponds to a .NET class that support \n    text/value conversion through the TypeConverter architecture. \n    Classes that don't support this are serialized and stored with the \n    mimetype set.\n    \n    The mimetype is used for serialized objects, and tells the \n    ResXResourceReader how to depersist the object. This is currently not \n    extensible. For a given mimetype the value must be set accordingly:\n    \n    Note - application/x-microsoft.net.object.binary.base64 is the format \n    that the ResXResourceWriter will generate, however the reader can \n    read any of the formats listed below.\n    \n    mimetype: application/x-microsoft.net.object.binary.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\n            : and then encoded with base64 encoding.\n    \n    mimetype: application/x-microsoft.net.object.soap.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\n            : and then encoded with base64 encoding.\n\n    mimetype: application/x-microsoft.net.object.bytearray.base64\n    value   : The object must be serialized into a byte array \n            : using a System.ComponentModel.TypeConverter\n            : and then encoded with base64 encoding.\n    -->\n  <xsd:schema id=\"root\" xmlns=\"\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">\n    <xsd:import namespace=\"http://www.w3.org/XML/1998/namespace\" />\n    <xsd:element name=\"root\" msdata:IsDataSet=\"true\">\n      <xsd:complexType>\n        <xsd:choice maxOccurs=\"unbounded\">\n          <xsd:element name=\"metadata\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" use=\"required\" type=\"xsd:string\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"assembly\">\n            <xsd:complexType>\n              <xsd:attribute name=\"alias\" type=\"xsd:string\" />\n              <xsd:attribute name=\"name\" type=\"xsd:string\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"data\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n                <xsd:element name=\"comment\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"2\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" msdata:Ordinal=\"1\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" msdata:Ordinal=\"3\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" msdata:Ordinal=\"4\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"resheader\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" />\n            </xsd:complexType>\n          </xsd:element>\n        </xsd:choice>\n      </xsd:complexType>\n    </xsd:element>\n  </xsd:schema>\n  <resheader name=\"resmimetype\">\n    <value>text/microsoft-resx</value>\n  </resheader>\n  <resheader name=\"version\">\n    <value>2.0</value>\n  </resheader>\n  <resheader name=\"reader\">\n    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n  <resheader name=\"writer\">\n    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n  <metadata name=\"txtISA.Locked\" type=\"System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\">\n    <value>True</value>\n  </metadata>\n  <metadata name=\"txtIL.Locked\" type=\"System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\">\n    <value>True</value>\n  </metadata>\n  <metadata name=\"txtLiveReg.Locked\" type=\"System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\">\n    <value>True</value>\n  </metadata>\n  <metadata name=\"txtToolOutput.Locked\" type=\"System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\">\n    <value>True</value>\n  </metadata>\n</root>"
  },
  {
    "path": "src/Backends/FXCBackend.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.Windows.Forms;\nusing System.Diagnostics;\nusing System.IO;\n\nnamespace Pyramid\n{\n    class FXCResultSet : IResultSet\n    {\n        private FXCResultsPanel m_Panel = null;\n\n        public FXCResultSet(HLSLShader shader)\n        {\n            m_Panel = new FXCResultsPanel(shader);\n        }\n\n        public string Name { get { return \"D3DCompiler\"; } }\n        public Control AnalysisPanel { get { return null; } }\n        public Control ResultsPanel { get { return m_Panel; } }\n    };\n\n    class D3DCompilerBackend : IBackend\n    {\n        private ID3DCompiler m_Compiler;\n        private IDXILCompiler m_DXIL;\n\n        public string Name { get { return \"D3DCompiler\"; } }\n\n        public D3DCompilerBackend( ID3DCompiler comp, IDXILCompiler dxil )\n        {\n            m_Compiler = comp;\n            m_DXIL = dxil;\n        }\n\n        public IResultSet Compile(IShader shader, IBackendOptions options)\n        {\n            if (!(shader is HLSLShader ) )\n                return null;\n\n            HLSLShader hlsl       = (HLSLShader)shader;\n            IHLSLOptions hlslOpts = hlsl.CompileOptions;\n            string text = hlsl.Code;\n\n            if (!hlsl.WasCompiled)\n                hlsl.Compile(m_Compiler, m_DXIL);\n\n            if (!hlsl.RootSigWasCompiled)\n                hlsl.CompileRootSignature(m_DXIL);\n\n            return new FXCResultSet(hlsl);\n        }\n    }\n\n   \n}\n"
  },
  {
    "path": "src/Backends/FXCResultsPanel.Designer.cs",
    "content": "﻿namespace Pyramid\n{\n    partial class FXCResultsPanel\n    {\n        /// <summary> \n        /// Required designer variable.\n        /// </summary>\n        private System.ComponentModel.IContainer components = null;\n\n        /// <summary> \n        /// Clean up any resources being used.\n        /// </summary>\n        /// <param name=\"disposing\">true if managed resources should be disposed; otherwise, false.</param>\n        protected override void Dispose(bool disposing)\n        {\n            if (disposing && (components != null))\n            {\n                components.Dispose();\n            }\n            base.Dispose(disposing);\n        }\n\n        #region Component Designer generated code\n\n        /// <summary> \n        /// Required method for Designer support - do not modify \n        /// the contents of this method with the code editor.\n        /// </summary>\n        private void InitializeComponent()\n        {\n            this.tabControl1 = new System.Windows.Forms.TabControl();\n            this.asmPage = new System.Windows.Forms.TabPage();\n            this.txtASM = new System.Windows.Forms.TextBox();\n            this.hexPage = new System.Windows.Forms.TabPage();\n            this.txtHex = new System.Windows.Forms.TextBox();\n            this.messagesPage = new System.Windows.Forms.TabPage();\n            this.txtMessages = new System.Windows.Forms.TextBox();\n            this.rootSigPage = new System.Windows.Forms.TabPage();\n            this.exportPage = new System.Windows.Forms.TabPage();\n            this.txtRootSig = new System.Windows.Forms.TextBox();\n            this.btnExportBytecode = new System.Windows.Forms.Button();\n            this.btnExportRootSig = new System.Windows.Forms.Button();\n            this.btnExportCPP = new System.Windows.Forms.Button();\n            this.tabControl1.SuspendLayout();\n            this.asmPage.SuspendLayout();\n            this.hexPage.SuspendLayout();\n            this.messagesPage.SuspendLayout();\n            this.rootSigPage.SuspendLayout();\n            this.exportPage.SuspendLayout();\n            this.SuspendLayout();\n            // \n            // tabControl1\n            // \n            this.tabControl1.Controls.Add(this.asmPage);\n            this.tabControl1.Controls.Add(this.hexPage);\n            this.tabControl1.Controls.Add(this.messagesPage);\n            this.tabControl1.Controls.Add(this.rootSigPage);\n            this.tabControl1.Controls.Add(this.exportPage);\n            this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;\n            this.tabControl1.Location = new System.Drawing.Point(0, 0);\n            this.tabControl1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);\n            this.tabControl1.Name = \"tabControl1\";\n            this.tabControl1.SelectedIndex = 0;\n            this.tabControl1.Size = new System.Drawing.Size(200, 185);\n            this.tabControl1.TabIndex = 0;\n            // \n            // asmPage\n            // \n            this.asmPage.Controls.Add(this.txtASM);\n            this.asmPage.Location = new System.Drawing.Point(4, 25);\n            this.asmPage.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);\n            this.asmPage.Name = \"asmPage\";\n            this.asmPage.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);\n            this.asmPage.Size = new System.Drawing.Size(192, 156);\n            this.asmPage.TabIndex = 0;\n            this.asmPage.Text = \"ASM\";\n            this.asmPage.UseVisualStyleBackColor = true;\n            // \n            // txtASM\n            // \n            this.txtASM.Dock = System.Windows.Forms.DockStyle.Fill;\n            this.txtASM.Location = new System.Drawing.Point(4, 4);\n            this.txtASM.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);\n            this.txtASM.Multiline = true;\n            this.txtASM.Name = \"txtASM\";\n            this.txtASM.ReadOnly = true;\n            this.txtASM.ScrollBars = System.Windows.Forms.ScrollBars.Both;\n            this.txtASM.Size = new System.Drawing.Size(184, 148);\n            this.txtASM.TabIndex = 0;\n            // \n            // hexPage\n            // \n            this.hexPage.Controls.Add(this.txtHex);\n            this.hexPage.Location = new System.Drawing.Point(4, 25);\n            this.hexPage.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);\n            this.hexPage.Name = \"hexPage\";\n            this.hexPage.Size = new System.Drawing.Size(192, 156);\n            this.hexPage.TabIndex = 2;\n            this.hexPage.Text = \"Hex\";\n            this.hexPage.UseVisualStyleBackColor = true;\n            // \n            // txtHex\n            // \n            this.txtHex.Dock = System.Windows.Forms.DockStyle.Fill;\n            this.txtHex.Font = new System.Drawing.Font(\"Lucida Console\", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\n            this.txtHex.Location = new System.Drawing.Point(0, 0);\n            this.txtHex.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);\n            this.txtHex.Multiline = true;\n            this.txtHex.Name = \"txtHex\";\n            this.txtHex.ReadOnly = true;\n            this.txtHex.ScrollBars = System.Windows.Forms.ScrollBars.Both;\n            this.txtHex.Size = new System.Drawing.Size(192, 156);\n            this.txtHex.TabIndex = 3;\n            // \n            // messagesPage\n            // \n            this.messagesPage.Controls.Add(this.txtMessages);\n            this.messagesPage.Location = new System.Drawing.Point(4, 25);\n            this.messagesPage.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);\n            this.messagesPage.Name = \"messagesPage\";\n            this.messagesPage.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);\n            this.messagesPage.Size = new System.Drawing.Size(192, 156);\n            this.messagesPage.TabIndex = 1;\n            this.messagesPage.Text = \"Messages\";\n            this.messagesPage.UseVisualStyleBackColor = true;\n            // \n            // txtMessages\n            // \n            this.txtMessages.Dock = System.Windows.Forms.DockStyle.Fill;\n            this.txtMessages.Location = new System.Drawing.Point(4, 4);\n            this.txtMessages.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);\n            this.txtMessages.Multiline = true;\n            this.txtMessages.Name = \"txtMessages\";\n            this.txtMessages.ReadOnly = true;\n            this.txtMessages.ScrollBars = System.Windows.Forms.ScrollBars.Both;\n            this.txtMessages.Size = new System.Drawing.Size(184, 148);\n            this.txtMessages.TabIndex = 1;\n            // \n            // rootSigPage\n            // \n            this.rootSigPage.Controls.Add(this.txtRootSig);\n            this.rootSigPage.Location = new System.Drawing.Point(4, 25);\n            this.rootSigPage.Name = \"rootSigPage\";\n            this.rootSigPage.Size = new System.Drawing.Size(192, 156);\n            this.rootSigPage.TabIndex = 3;\n            this.rootSigPage.Text = \"RootSig\";\n            this.rootSigPage.UseVisualStyleBackColor = true;\n            // \n            // exportPage\n            // \n            this.exportPage.Controls.Add(this.btnExportCPP);\n            this.exportPage.Controls.Add(this.btnExportRootSig);\n            this.exportPage.Controls.Add(this.btnExportBytecode);\n            this.exportPage.Location = new System.Drawing.Point(4, 25);\n            this.exportPage.Name = \"exportPage\";\n            this.exportPage.Size = new System.Drawing.Size(192, 156);\n            this.exportPage.TabIndex = 4;\n            this.exportPage.Text = \"Export\";\n            this.exportPage.UseVisualStyleBackColor = true;\n            // \n            // txtRootSig\n            // \n            this.txtRootSig.Dock = System.Windows.Forms.DockStyle.Fill;\n            this.txtRootSig.Font = new System.Drawing.Font(\"Consolas\", 8.5F);\n            this.txtRootSig.Location = new System.Drawing.Point(0, 0);\n            this.txtRootSig.Margin = new System.Windows.Forms.Padding(4);\n            this.txtRootSig.Multiline = true;\n            this.txtRootSig.Name = \"txtRootSig\";\n            this.txtRootSig.ReadOnly = true;\n            this.txtRootSig.ScrollBars = System.Windows.Forms.ScrollBars.Both;\n            this.txtRootSig.Size = new System.Drawing.Size(192, 156);\n            this.txtRootSig.TabIndex = 2;\n            // \n            // btnExportBytecode\n            // \n            this.btnExportBytecode.Location = new System.Drawing.Point(12, 18);\n            this.btnExportBytecode.Name = \"btnExportBytecode\";\n            this.btnExportBytecode.Size = new System.Drawing.Size(134, 35);\n            this.btnExportBytecode.TabIndex = 0;\n            this.btnExportBytecode.Text = \"Save Bytecode\";\n            this.btnExportBytecode.UseVisualStyleBackColor = true;\n            this.btnExportBytecode.Click += new System.EventHandler(this.btnExportBytecode_Click);\n            // \n            // btnExportRootSig\n            // \n            this.btnExportRootSig.Location = new System.Drawing.Point(12, 59);\n            this.btnExportRootSig.Name = \"btnExportRootSig\";\n            this.btnExportRootSig.Size = new System.Drawing.Size(134, 35);\n            this.btnExportRootSig.TabIndex = 1;\n            this.btnExportRootSig.Text = \"Save RootSig\";\n            this.btnExportRootSig.UseVisualStyleBackColor = true;\n            this.btnExportRootSig.Click += new System.EventHandler(this.btnExportRootSig_Click);\n            // \n            // btnExportCPP\n            // \n            this.btnExportCPP.Location = new System.Drawing.Point(12, 100);\n            this.btnExportCPP.Name = \"btnExportCPP\";\n            this.btnExportCPP.Size = new System.Drawing.Size(134, 35);\n            this.btnExportCPP.TabIndex = 2;\n            this.btnExportCPP.Text = \"Create .cpp File\";\n            this.btnExportCPP.UseVisualStyleBackColor = true;\n            this.btnExportCPP.Click += new System.EventHandler(this.btnExportCPP_Click);\n            // \n            // FXCResultsPanel\n            // \n            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);\n            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\n            this.Controls.Add(this.tabControl1);\n            this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);\n            this.Name = \"FXCResultsPanel\";\n            this.Size = new System.Drawing.Size(200, 185);\n            this.tabControl1.ResumeLayout(false);\n            this.asmPage.ResumeLayout(false);\n            this.asmPage.PerformLayout();\n            this.hexPage.ResumeLayout(false);\n            this.hexPage.PerformLayout();\n            this.messagesPage.ResumeLayout(false);\n            this.messagesPage.PerformLayout();\n            this.rootSigPage.ResumeLayout(false);\n            this.rootSigPage.PerformLayout();\n            this.exportPage.ResumeLayout(false);\n            this.ResumeLayout(false);\n\n        }\n\n        #endregion\n\n        private System.Windows.Forms.TabControl tabControl1;\n        private System.Windows.Forms.TabPage messagesPage;\n        private System.Windows.Forms.TextBox txtASM;\n        private System.Windows.Forms.TextBox txtMessages;\n        private System.Windows.Forms.TabPage hexPage;\n        private System.Windows.Forms.TextBox txtHex;\n        private System.Windows.Forms.TabPage asmPage;\n        private System.Windows.Forms.TabPage rootSigPage;\n        private System.Windows.Forms.TextBox txtRootSig;\n        private System.Windows.Forms.TabPage exportPage;\n        private System.Windows.Forms.Button btnExportCPP;\n        private System.Windows.Forms.Button btnExportRootSig;\n        private System.Windows.Forms.Button btnExportBytecode;\n    }\n}\n"
  },
  {
    "path": "src/Backends/FXCResultsPanel.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Drawing;\nusing System.Data;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Windows.Forms;\n\nusing System.IO;\n\n\nnamespace Pyramid\n{\n    public partial class FXCResultsPanel : UserControl\n    {\n        private IDXShaderBlob m_Shader;\n        private IDXBlob m_RootSignature;\n\n        private static void HexBumpBlob( StringBuilder str, byte[] bytes )\n        {\n            int nBytes = bytes.Length;\n\n            if (nBytes % 4 == 0)\n            {\n                for (int i = 0; i < nBytes; i += 4)\n                {\n                    int n = bytes[i] |\n                             bytes[i + 1] << 8 |\n                             bytes[i + 2] << 16 |\n                             bytes[i + 3] << 24;\n\n                    char c0 = Convert.ToChar(bytes[i]);\n                    char c1 = Convert.ToChar(bytes[i+1]);\n                    char c2 = Convert.ToChar(bytes[i+2]);\n                    char c3 = Convert.ToChar(bytes[i+3]);\n                    c0 = (c0 < 0x20 || c0 > 127) ? '.' : c0;\n                    c1 = (c1 < 0x20 || c1 > 127) ? '.' : c1;\n                    c2 = (c2 < 0x20 || c2 > 127) ? '.' : c2;\n                    c3 = (c3 < 0x20 || c3 > 127) ? '.' : c3;\n                    str.AppendFormat(\"{0:X8}  '{1} {2} {3} {4}' \", n, c0,c1,c2,c3 );\n                    str.AppendLine();\n                }\n            }\n            else\n            {\n                for( int i=0; i<nBytes; i++ )\n                {\n                    if (i % 8 == 0)\n                        str.AppendLine();\n                    str.AppendFormat(\"{0:X2} \", bytes[i]);\n                }\n            }\n            str.AppendLine();\n        }\n\n        public FXCResultsPanel( HLSLShader shader )\n        {\n            string error = shader.Messages;\n            IDXShaderBlob blob = shader.CompiledBlob;\n            m_Shader = blob;\n            InitializeComponent();\n            txtMessages.Text = error;\n\n            if (blob == null)\n            {\n                tabControl1.TabPages.Remove(hexPage);\n                tabControl1.TabPages.Remove(asmPage);               \n            }\n            else\n            {\n                txtASM.Text = blob.Disassemble();\n\n                // generate a blob dump\n                try\n                {\n                    byte[] rawBytes = blob.ReadBytes();\n\n                    StringBuilder str = new StringBuilder();\n                    str.AppendFormat(\"Blob size is {0} ({1:X}) bytes\", rawBytes.Length, rawBytes.Length);\n                    str.AppendLine();\n                    HexBumpBlob(str, rawBytes);\n\n                    if (blob is IDXBCShaderBlob)\n                    {\n                        IDXBCShaderBlob blobDXBC = blob as IDXBCShaderBlob;\n                        IDXBCShaderBlob strip = blobDXBC.Strip();\n                        IDXBCShaderBlob sig = strip.GetSignatureBlob();\n\n                        byte[] stripBytes = strip.ReadBytes();\n                        byte[] sigBytes = sig.ReadBytes();\n\n                        str.AppendFormat(\"Stripped blob size is {0} ({1:x}) bytes\", stripBytes.Length, stripBytes.Length);\n                        str.AppendLine();\n                        HexBumpBlob(str, stripBytes);\n\n                        str.AppendFormat(\"Signature blob size is {0} ({1:x}) bytes\", sigBytes.Length, sigBytes.Length);\n                        str.AppendLine();\n                        HexBumpBlob(str, sigBytes);\n\n                    }\n                    \n                    txtHex.Text = str.ToString();\n                    \n                }\n                catch( Exception ex )\n                {\n                    txtHex.Text = String.Format(\"EXCEPTION while generating hex dump: {0}\", ex.Message);\n                }                \n            }\n\n            IDXBlob rsBlob = shader.CompiledRootSig;\n            m_RootSignature = rsBlob;\n            txtMessages.Text = String.Concat(txtMessages.Text, shader.RootSigMessages);\n\n            if (rsBlob == null)\n            {\n                tabControl1.TabPages.Remove(rootSigPage);              \n            }\n            else\n            {\n                try\n                {\n                    byte[] rawBytes = rsBlob.ReadBytes();\n\n                    StringBuilder str = new StringBuilder();\n                    str.AppendFormat(\"RootSig blob size is {0} ({1:X}) bytes\", rawBytes.Length, rawBytes.Length);\n                    str.AppendLine();\n\n                    HexBumpBlob(str, rawBytes);\n\n                    txtRootSig.Text = str.ToString();\n                }\n                catch (Exception ex)\n                {\n                    txtRootSig.Text = String.Format(\"EXCEPTION while generating rootsig dump: {0}\", ex.Message);\n                }\n            }\n\n        }\n\n        private void btnExportBytecode_Click(object sender, EventArgs e)\n        {\n            if (m_Shader != null)\n            {\n                SaveFileDialog save = new SaveFileDialog();\n                if (save.ShowDialog() != DialogResult.Cancel)\n                {\n                    File.WriteAllBytes(save.FileName, m_Shader.ReadBytes());\n                }\n            }\n        }\n\n        private void btnExportRootSig_Click(object sender, EventArgs e)\n        {\n            if (m_RootSignature != null)\n            {\n                SaveFileDialog save = new SaveFileDialog();\n                if (save.ShowDialog() != DialogResult.Cancel)\n                {\n                    File.WriteAllBytes(save.FileName, m_RootSignature.ReadBytes());\n                }\n            }\n        }\n\n\n        private static void DeclareByteArray(StringBuilder str, byte[] bytes, string name)\n        {\n            int nBytes = bytes.Length;\n            str.AppendFormat(\"static const unsigned char {0}[{1}] = {{\", name, nBytes );\n            str.AppendLine();\n\n            for( int i=0; i<nBytes; i += 32 )\n            {\n                str.Append(\"    \");\n                for( int j=0; j<32; j++ )\n                {\n                    if (i + j >= nBytes)\n                        break;\n                    str.AppendFormat(\"{0,-3}, \", bytes[i + j]);\n                }\n                str.AppendLine();\n            }\n            str.Append(\"};\");\n            str.AppendLine();\n        }\n\n        private void btnExportCPP_Click(object sender, EventArgs e)\n        {\n            SaveFileDialog save = new SaveFileDialog();\n            if (save.ShowDialog() != DialogResult.Cancel)\n            {\n                StringBuilder str = new StringBuilder();\n\n                if ( m_Shader != null )\n                {\n                    str.Append(\"#if 0\");\n                    str.AppendLine();\n                    str.Append(m_Shader.Disassemble());\n                    str.AppendLine();\n                    str.Append(\"#endif\");\n                    str.AppendLine();\n\n                    byte[] byteCode = m_Shader.ReadBytes();\n                    DeclareByteArray(str, byteCode, \"Bytecode\");\n                }\n\n                if( m_RootSignature != null )\n                {\n                    byte[] byteCode = m_RootSignature.ReadBytes();\n                    DeclareByteArray(str, byteCode, \"RootSig\");\n                }\n\n                File.WriteAllText(save.FileName, str.ToString());\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "src/Backends/FXCResultsPanel.resx",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n  <!-- \n    Microsoft ResX Schema \n    \n    Version 2.0\n    \n    The primary goals of this format is to allow a simple XML format \n    that is mostly human readable. The generation and parsing of the \n    various data types are done through the TypeConverter classes \n    associated with the data types.\n    \n    Example:\n    \n    ... ado.net/XML headers & schema ...\n    <resheader name=\"resmimetype\">text/microsoft-resx</resheader>\n    <resheader name=\"version\">2.0</resheader>\n    <resheader name=\"reader\">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\n    <resheader name=\"writer\">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\n    <data name=\"Name1\"><value>this is my long string</value><comment>this is a comment</comment></data>\n    <data name=\"Color1\" type=\"System.Drawing.Color, System.Drawing\">Blue</data>\n    <data name=\"Bitmap1\" mimetype=\"application/x-microsoft.net.object.binary.base64\">\n        <value>[base64 mime encoded serialized .NET Framework object]</value>\n    </data>\n    <data name=\"Icon1\" type=\"System.Drawing.Icon, System.Drawing\" mimetype=\"application/x-microsoft.net.object.bytearray.base64\">\n        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\n        <comment>This is a comment</comment>\n    </data>\n                \n    There are any number of \"resheader\" rows that contain simple \n    name/value pairs.\n    \n    Each data row contains a name, and value. The row also contains a \n    type or mimetype. Type corresponds to a .NET class that support \n    text/value conversion through the TypeConverter architecture. \n    Classes that don't support this are serialized and stored with the \n    mimetype set.\n    \n    The mimetype is used for serialized objects, and tells the \n    ResXResourceReader how to depersist the object. This is currently not \n    extensible. For a given mimetype the value must be set accordingly:\n    \n    Note - application/x-microsoft.net.object.binary.base64 is the format \n    that the ResXResourceWriter will generate, however the reader can \n    read any of the formats listed below.\n    \n    mimetype: application/x-microsoft.net.object.binary.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\n            : and then encoded with base64 encoding.\n    \n    mimetype: application/x-microsoft.net.object.soap.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\n            : and then encoded with base64 encoding.\n\n    mimetype: application/x-microsoft.net.object.bytearray.base64\n    value   : The object must be serialized into a byte array \n            : using a System.ComponentModel.TypeConverter\n            : and then encoded with base64 encoding.\n    -->\n  <xsd:schema id=\"root\" xmlns=\"\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">\n    <xsd:import namespace=\"http://www.w3.org/XML/1998/namespace\" />\n    <xsd:element name=\"root\" msdata:IsDataSet=\"true\">\n      <xsd:complexType>\n        <xsd:choice maxOccurs=\"unbounded\">\n          <xsd:element name=\"metadata\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" use=\"required\" type=\"xsd:string\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"assembly\">\n            <xsd:complexType>\n              <xsd:attribute name=\"alias\" type=\"xsd:string\" />\n              <xsd:attribute name=\"name\" type=\"xsd:string\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"data\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n                <xsd:element name=\"comment\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"2\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" msdata:Ordinal=\"1\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" msdata:Ordinal=\"3\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" msdata:Ordinal=\"4\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"resheader\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" />\n            </xsd:complexType>\n          </xsd:element>\n        </xsd:choice>\n      </xsd:complexType>\n    </xsd:element>\n  </xsd:schema>\n  <resheader name=\"resmimetype\">\n    <value>text/microsoft-resx</value>\n  </resheader>\n  <resheader name=\"version\">\n    <value>2.0</value>\n  </resheader>\n  <resheader name=\"reader\">\n    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n  <resheader name=\"writer\">\n    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n</root>"
  },
  {
    "path": "src/Backends/GLSLOptimizerBackend.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.Windows.Forms;\n\nnamespace Pyramid\n{\n    class GLSLOptimizerResultSet : IResultSet\n    {\n        private TextBox m_AnalysisPanel = new TextBox();\n        private TabControl m_ResultsPanel = new TabControl();\n        \n        public GLSLOptimizerResultSet(GLSLOptimizer.IShader shader)\n        {\n            m_ResultsPanel.Dock = DockStyle.Fill;\n            TabPage page;\n\n            string AnalysisText=\"\";\n            if( !shader.HadError )\n            {\n                AnalysisText = String.Format(\"GLSLOptimizer stats:\\r\\nMathOps:\\t{0}\\r\\nTextureOps:\\t{1}\\r\\nFlowOps:\\t{2}\\r\\n\",\n                                             shader.MathOps,\n                                             shader.TextureOps,\n                                             shader.ControlFlowOps);\n                \n                m_ResultsPanel.TabPages.Add(\"Optimized Output\");\n                page = m_ResultsPanel.TabPages[m_ResultsPanel.TabPages.Count - 1];\n                TextBox txtOutput = new TextBox();\n                txtOutput.ReadOnly = true;\n                txtOutput.Dock = DockStyle.Fill;\n                txtOutput.Multiline = true;\n                txtOutput.ScrollBars = ScrollBars.Both;\n                txtOutput.Text = shader.Output.Replace(\"\\n\", Environment.NewLine) ;\n                txtOutput.WordWrap = false;\n                page.Controls.Add(txtOutput);\n\n                m_ResultsPanel.TabPages.Add(\"Raw Output\");\n                page = m_ResultsPanel.TabPages[m_ResultsPanel.TabPages.Count - 1];\n                TextBox txtRawOutput = new TextBox();\n                txtRawOutput.ReadOnly = true;\n                txtRawOutput.Dock = DockStyle.Fill;\n                txtRawOutput.Multiline = true;\n                txtRawOutput.ScrollBars = ScrollBars.Both;\n                txtRawOutput.Text = shader.RawOutput.Replace(\"\\n\",Environment.NewLine);\n                txtRawOutput.WordWrap = false;\n                page.Controls.Add(txtRawOutput);\n            }\n\n            m_ResultsPanel.TabPages.Add(\"Log\");\n            page = m_ResultsPanel.TabPages[m_ResultsPanel.TabPages.Count - 1];\n            TextBox txtLog = new TextBox();\n            txtLog.ReadOnly = true;\n            txtLog.Dock = DockStyle.Fill;\n            txtLog.Multiline = true;\n            txtLog.ScrollBars = ScrollBars.Both;\n            txtLog.WordWrap = false;\n            txtLog.Text = shader.Log.Replace(\"\\n\", Environment.NewLine);\n           \n            page.Controls.Add(txtLog);\n\n            m_AnalysisPanel.ReadOnly = true;\n            m_AnalysisPanel.Dock = DockStyle.Fill;\n            m_AnalysisPanel.Text = AnalysisText;\n            m_AnalysisPanel.Multiline = true;\n            m_AnalysisPanel.Font = new System.Drawing.Font(\"Lucida Console\", 8);\n        }\n\n        public string Name { get { return \"GLSLOptimizer\"; } }\n        public Control AnalysisPanel { get { return m_AnalysisPanel; } }\n        public Control ResultsPanel { get { return m_ResultsPanel; } }\n    };\n\n    class GLSLOptimizerBackend : IBackend\n    {\n        private Dictionary<GLSLOptimizer.Target, GLSLOptimizer.IOptimizer> m_Optimizers =\n            new Dictionary<GLSLOptimizer.Target, GLSLOptimizer.IOptimizer>();\n\n        public string Name { get { return \"GLSLOptimizer\"; } }\n\n        public GLSLOptimizerBackend(IWrapper wrapper)\n        {\n            foreach( GLSLOptimizer.Target t in Enum.GetValues(typeof(GLSLOptimizer.Target)))\n                m_Optimizers.Add( t, wrapper.CreateGLSLOptimizer(t));\n        }\n\n        public IResultSet Compile(IShader shader, IBackendOptions options)\n        {\n            if ( !(shader is GLSLShader ) )\n                return null;\n\n            GLSLShader sh = (GLSLShader)shader;\n            IGLSLOptions glOpts = sh.CompileOptions;\n            if (glOpts.OptimizerOptions == null)\n                return null;\n\n            GLSLOptimizer.IOptimizer optimizer = m_Optimizers[glOpts.OptimizerTarget];\n            return new GLSLOptimizerResultSet( optimizer.Optimize(sh.Code, glOpts.OptimizerOptions) );\n        }\n    }\n}\n"
  },
  {
    "path": "src/Backends/GLSlangBackend.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.Windows.Forms;\n\nnamespace Pyramid\n{\n    class GLSlangBackend : IBackend\n    {\n        private GLSlang.ICompiler m_Compiler;\n        private GLSlang.IConfig m_Config;\n\n      \n\n        private class GLSLangResultSet : IResultSet\n        {\n            private GLSlangResultsPanel m_Results = null;\n\n            public string Name { get { return \"GLSlang\"; } }\n            public Control AnalysisPanel { get { return null; } }\n            public Control ResultsPanel { get { return m_Results;  } }\n            public GLSLangResultSet(GLSlang.IShader shader)\n            {\n                m_Results = new GLSlangResultsPanel(shader, shader.CompileSPIRV());\n\n            }\n        }\n        \n        public string Name { get { return \"GLSlang\"; } }\n\n        public GLSlangBackend( IWrapper wrapper, IIncludeHandler handler )\n        {\n            m_Compiler = wrapper.CreateGLSlangCompiler(handler);\n            m_Config = m_Compiler.CreateDefaultConfig();\n        }\n\n        public IResultSet Compile(IShader shader, IBackendOptions options)\n        {\n            if (shader is GLSLShader)\n            {\n                GLSLShader sh = (GLSLShader)shader;\n                IGLSLOptions glOpts = sh.CompileOptions;\n\n                GLSlang.IShader result = m_Compiler.Compile(sh.Code, glOpts.ShaderType, m_Config, shader.SourceFilePath );\n                return new GLSLangResultSet(result);\n            }\n            else if( shader is HLSLShader )\n            {\n                HLSLShader sh = (HLSLShader)shader;\n                IHLSLOptions hlslOpts = sh.CompileOptions;\n\n                GLSlang.IShader result = m_Compiler.CompileHLSL(sh.Code, hlslOpts, m_Config, shader.SourceFilePath  );\n                return new GLSLangResultSet(result);\n            }\n            else\n            {\n                return null;\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "src/Backends/GLSlangResultsPanel.Designer.cs",
    "content": "﻿namespace Pyramid\n{\n    partial class GLSlangResultsPanel\n    {\n        /// <summary> \n        /// Required designer variable.\n        /// </summary>\n        private System.ComponentModel.IContainer components = null;\n\n        /// <summary> \n        /// Clean up any resources being used.\n        /// </summary>\n        /// <param name=\"disposing\">true if managed resources should be disposed; otherwise, false.</param>\n        protected override void Dispose(bool disposing)\n        {\n            if (disposing && (components != null))\n            {\n                components.Dispose();\n            }\n            base.Dispose(disposing);\n        }\n\n        #region Component Designer generated code\n\n        /// <summary> \n        /// Required method for Designer support - do not modify \n        /// the contents of this method with the code editor.\n        /// </summary>\n        private void InitializeComponent()\n        {\n            this.textBox1 = new System.Windows.Forms.TextBox();\n            this.button1 = new System.Windows.Forms.Button();\n            this.SuspendLayout();\n            // \n            // textBox1\n            // \n            this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) \n            | System.Windows.Forms.AnchorStyles.Left) \n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.textBox1.Location = new System.Drawing.Point(3, 2);\n            this.textBox1.Multiline = true;\n            this.textBox1.Name = \"textBox1\";\n            this.textBox1.ReadOnly = true;\n            this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both;\n            this.textBox1.Size = new System.Drawing.Size(206, 152);\n            this.textBox1.TabIndex = 0;\n            this.textBox1.WordWrap = false;\n            // \n            // button1\n            // \n            this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));\n            this.button1.Location = new System.Drawing.Point(141, 158);\n            this.button1.Name = \"button1\";\n            this.button1.Size = new System.Drawing.Size(66, 21);\n            this.button1.TabIndex = 1;\n            this.button1.Text = \"Export\";\n            this.button1.UseVisualStyleBackColor = true;\n            this.button1.Click += new System.EventHandler(this.button1_Click);\n            // \n            // GLSlangResultsPanel\n            // \n            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\n            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\n            this.Controls.Add(this.button1);\n            this.Controls.Add(this.textBox1);\n            this.Name = \"GLSlangResultsPanel\";\n            this.Size = new System.Drawing.Size(212, 183);\n            this.ResumeLayout(false);\n            this.PerformLayout();\n\n        }\n\n        #endregion\n\n        private System.Windows.Forms.TextBox textBox1;\n        private System.Windows.Forms.Button button1;\n    }\n}\n"
  },
  {
    "path": "src/Backends/GLSlangResultsPanel.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Drawing;\nusing System.Data;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Windows.Forms;\n\nnamespace Pyramid\n{\n    public partial class GLSlangResultsPanel : UserControl\n    {\n        private GLSlang.IShader m_Shader;\n        private SPIRV.IProgram m_SPIRV;\n        public GLSlangResultsPanel(GLSlang.IShader shader, SPIRV.IProgram spirv)\n        {\n            InitializeComponent();\n\n            m_Shader = shader;\n            m_SPIRV = spirv;\n            if (spirv != null)\n            {\n                textBox1.Text = spirv.Disassemble();\n                button1.Enabled = true;\n            }\n            else\n            {\n                textBox1.Text = shader.InfoLog.Replace(\"\\n\", Environment.NewLine);\n                button1.Enabled = false;\n            }\n        }\n\n        private void button1_Click(object sender, EventArgs e)\n        {\n            SaveFileDialog sd = new SaveFileDialog();\n            sd.Title = \"Export SPIRV Binary\";\n            if( sd.ShowDialog() != DialogResult.Cancel )\n            {\n                try\n                {\n                    System.IO.File.WriteAllBytes(sd.FileName, m_SPIRV.GetBytes());\n                }\n                catch (System.Exception ex)\n                {\n                    MessageBox.Show(ex.Message);\n                }\n            }\n\n        }\n    }\n}\n"
  },
  {
    "path": "src/Backends/GLSlangResultsPanel.resx",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n  <!-- \n    Microsoft ResX Schema \n    \n    Version 2.0\n    \n    The primary goals of this format is to allow a simple XML format \n    that is mostly human readable. The generation and parsing of the \n    various data types are done through the TypeConverter classes \n    associated with the data types.\n    \n    Example:\n    \n    ... ado.net/XML headers & schema ...\n    <resheader name=\"resmimetype\">text/microsoft-resx</resheader>\n    <resheader name=\"version\">2.0</resheader>\n    <resheader name=\"reader\">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\n    <resheader name=\"writer\">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\n    <data name=\"Name1\"><value>this is my long string</value><comment>this is a comment</comment></data>\n    <data name=\"Color1\" type=\"System.Drawing.Color, System.Drawing\">Blue</data>\n    <data name=\"Bitmap1\" mimetype=\"application/x-microsoft.net.object.binary.base64\">\n        <value>[base64 mime encoded serialized .NET Framework object]</value>\n    </data>\n    <data name=\"Icon1\" type=\"System.Drawing.Icon, System.Drawing\" mimetype=\"application/x-microsoft.net.object.bytearray.base64\">\n        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\n        <comment>This is a comment</comment>\n    </data>\n                \n    There are any number of \"resheader\" rows that contain simple \n    name/value pairs.\n    \n    Each data row contains a name, and value. The row also contains a \n    type or mimetype. Type corresponds to a .NET class that support \n    text/value conversion through the TypeConverter architecture. \n    Classes that don't support this are serialized and stored with the \n    mimetype set.\n    \n    The mimetype is used for serialized objects, and tells the \n    ResXResourceReader how to depersist the object. This is currently not \n    extensible. For a given mimetype the value must be set accordingly:\n    \n    Note - application/x-microsoft.net.object.binary.base64 is the format \n    that the ResXResourceWriter will generate, however the reader can \n    read any of the formats listed below.\n    \n    mimetype: application/x-microsoft.net.object.binary.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\n            : and then encoded with base64 encoding.\n    \n    mimetype: application/x-microsoft.net.object.soap.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\n            : and then encoded with base64 encoding.\n\n    mimetype: application/x-microsoft.net.object.bytearray.base64\n    value   : The object must be serialized into a byte array \n            : using a System.ComponentModel.TypeConverter\n            : and then encoded with base64 encoding.\n    -->\n  <xsd:schema id=\"root\" xmlns=\"\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">\n    <xsd:import namespace=\"http://www.w3.org/XML/1998/namespace\" />\n    <xsd:element name=\"root\" msdata:IsDataSet=\"true\">\n      <xsd:complexType>\n        <xsd:choice maxOccurs=\"unbounded\">\n          <xsd:element name=\"metadata\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" use=\"required\" type=\"xsd:string\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"assembly\">\n            <xsd:complexType>\n              <xsd:attribute name=\"alias\" type=\"xsd:string\" />\n              <xsd:attribute name=\"name\" type=\"xsd:string\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"data\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n                <xsd:element name=\"comment\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"2\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" msdata:Ordinal=\"1\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" msdata:Ordinal=\"3\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" msdata:Ordinal=\"4\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"resheader\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" />\n            </xsd:complexType>\n          </xsd:element>\n        </xsd:choice>\n      </xsd:complexType>\n    </xsd:element>\n  </xsd:schema>\n  <resheader name=\"resmimetype\">\n    <value>text/microsoft-resx</value>\n  </resheader>\n  <resheader name=\"version\">\n    <value>2.0</value>\n  </resheader>\n  <resheader name=\"reader\">\n    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n  <resheader name=\"writer\">\n    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n</root>"
  },
  {
    "path": "src/Backends/IBackend.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.Windows.Forms;\n\nnamespace Pyramid\n{\n    public interface IResultSet\n    {\n        string Name { get; }\n        Control AnalysisPanel { get; }\n        Control ResultsPanel { get; }\n    }\n\n    public interface IBackendOptions\n    {\n\n    }\n\n    public interface IBackend\n    {\n        string Name { get; }\n        IResultSet Compile(IShader shader, IBackendOptions options);\n    }\n}\n"
  },
  {
    "path": "src/Backends/IntelShaderAnalyzerBackend.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.IO;\nusing System.Windows.Forms;\nusing System.Diagnostics;\n\nnamespace Pyramid\n{\n    class IntelShaderAnalyzerResultSet : IResultSet\n    {\n        public string Name { get { return \"IntelShaderAnalyzer\"; } }\n        public Control AnalysisPanel { get { return m_Analysis; } }\n        public Control ResultsPanel { get { return m_Results; } }\n        private TextBox m_Analysis = new TextBox();\n        private IntelShaderAnalyzerResultsPanel m_Results = null;\n\n        public IntelShaderAnalyzerResultSet(IntelShaderAnalyzerResultsPanel panel )\n        {\n            m_Results = panel;\n            m_Analysis.Dock = DockStyle.Fill;\n            m_Analysis.ReadOnly = true;\n            m_Analysis.Multiline = true;\n            m_Analysis.Font = new System.Drawing.Font(\"Lucida Console\", 8);\n        }\n       \n    }\n\n    public class IntelShaderAnalyzerBackend : IBackend\n    {\n        private string m_ToolPath;\n        private string m_TempPath;\n\n        public IntelShaderAnalyzerBackend(Options PyramidOpts)\n        {\n            m_ToolPath = PyramidOpts.IntelShaderAnalyzerPath;\n            m_TempPath = PyramidOpts.TempPath;\n        }\n\n        public string Name { get { return \"IGC\"; } }\n\n        public List<string> GetAsicList()\n        {\n            try\n            {\n                ProcessStartInfo pi = new ProcessStartInfo();\n                pi.RedirectStandardOutput = true;\n                pi.RedirectStandardInput = false;\n                pi.RedirectStandardError = true;\n                pi.CreateNoWindow = true;\n                pi.Arguments = \"--list-asics\";\n                pi.FileName = m_ToolPath;\n                pi.UseShellExecute = false;\n\n                Process p = Process.Start(pi);\n                int pid = p.Id;\n\n                // NOTE: Must read stdout before waiting for exit\n                //  If we don't, then the process will hang if some stdout buffer fills up\n                //  lame....\n                string stdout = p.StandardOutput.ReadToEnd();\n\n                p.WaitForExit();\n\n                p.Close();\n\n                string[] lines = stdout.Split(\n                    new[] { \"\\r\\n\", \"\\r\", \"\\n\" },\n                    StringSplitOptions.None\n                );\n\n                List<String> asics = new List<string>();\n                foreach( string s in lines )\n                {\n                    string asic = s.Trim();\n                    if (!string.IsNullOrEmpty(asic))\n                        asics.Add(asic);\n                }\n\n                return asics;\n            }\n            catch( System.Exception ex )\n            {\n                MessageBox.Show(\"Failed to get asic list from IntelShaderAnalyzer\");\n                return new List<string>();\n            }\n        }\n\n        public IResultSet Compile(IShader shader, IBackendOptions options)\n        {\n            if (shader.Language == Languages.HLSL)\n                return CompileHLSL(shader as HLSLShader, options);\n            else\n                return null;\n        }\n\n        private IResultSet CompileHLSL(HLSLShader shader, IBackendOptions opts)\n        {\n            if (shader.CompiledBlob == null)\n                return null;\n\n            if (shader.CompiledBlob is IDXILShaderBlob &&\n                shader.CompiledRootSig == null)\n                return null;\n\n            try\n            {          \n                List<string> tempFilesToDelete = new List<string>();\n\n                string byteCodeFile = Path.Combine(m_TempPath, \"IGCShader\");\n                string rootSigFile  = Path.Combine(m_TempPath, \"IGCRS\");\n                File.WriteAllBytes( byteCodeFile, shader.CompiledBlob.ReadBytes()   );\n                tempFilesToDelete.Add(byteCodeFile);\n                \n                if( shader.CompiledRootSig != null )\n                {\n                    File.WriteAllBytes(rootSigFile, shader.CompiledRootSig.ReadBytes());\n                    tempFilesToDelete.Add(rootSigFile);\n                }\n\n                string commandline11 = \"\";\n                string commandline12 = \"\";\n                if (shader.CompiledBlob is IDXBCShaderBlob)\n                {\n                    commandline11 = String.Format(\"--api dx11 \\\"{0}\\\"\", byteCodeFile);\n                    commandline12 = String.Format(\"--api dx12 \\\"{0}\\\" --rootsig_file \\\"{1}\\\"\", byteCodeFile, rootSigFile);\n                }\n                else\n                {\n                    commandline12 = String.Format(\"--api dx12 \\\"{0}\\\" --rootsig_file \\\"{1}\\\"\", byteCodeFile, rootSigFile);\n                }\n\n                List<string> asics = GetAsicList();\n                \n                foreach (string asic in asics)\n                {\n                    commandline11 = String.Concat(commandline11, String.Format(\" --asic {0} \", asic));\n                    commandline12 = String.Concat(commandline12, String.Format(\" --asic {0} \", asic));\n                }\n\n                string isaDir11 = Path.Combine(m_TempPath, \"IntelISA_11\\\\\");\n                string isaDir12 = Path.Combine(m_TempPath, \"IntelISA_12\\\\\");\n\n                Directory.CreateDirectory(isaDir11);\n                Directory.CreateDirectory(isaDir12);\n\n                // NOTE: Extra \\ is required because DOS command interpretter parses \\\" as a double quote\n                commandline11 = String.Concat(commandline11, String.Format(\"--isa \\\"{0}\\\\\\\"\", isaDir11));\n                commandline12 = String.Concat(commandline12, String.Format(\"--isa \\\"{0}\\\\\\\"\", isaDir12));\n\n                string stdout = \"\";\n                List<string> dx11Files = new List<string>();\n                List<string> dx12Files = new List<string>();\n\n                // DX11 requires DXBC\n                if( shader.CompiledBlob is IDXBCShaderBlob)\n                {\n                    ProcessStartInfo pi = new ProcessStartInfo();\n                    pi.RedirectStandardOutput = true;\n                    pi.RedirectStandardInput = false;\n                    pi.RedirectStandardError = true;\n                    pi.CreateNoWindow = true;\n                    pi.Arguments = commandline11;\n                    pi.FileName = m_ToolPath;\n                    pi.UseShellExecute = false;\n\n                    Process p = Process.Start(pi);\n                    int pid = p.Id;\n\n                    // NOTE: Must read stdout before waiting for exit\n                    //  If we don't, then the process will hang if some stdout buffer fills up\n                    //  lame....\n                    stdout = String.Concat(\"DX11 COMMAND LINE:\", commandline11, Environment.NewLine);\n                    stdout = String.Concat(stdout, p.StandardOutput.ReadToEnd());\n\n                    p.WaitForExit();\n                    p.Close();\n\n                    foreach (string asic in asics)\n                        dx11Files.Add(String.Concat(isaDir11, asic, \".asm\"));\n                }\n\n                // DX12 requires a root signature\n                if( shader.CompiledRootSig != null )\n                {\n                    ProcessStartInfo pi = new ProcessStartInfo();\n                    pi.RedirectStandardOutput = true;\n                    pi.RedirectStandardInput = false;\n                    pi.RedirectStandardError = true;\n                    pi.CreateNoWindow = true;\n                    pi.Arguments = commandline12;\n                    pi.FileName = m_ToolPath;\n                    pi.UseShellExecute = false;\n\n                    Process p = Process.Start(pi);\n                    int pid = p.Id;\n\n                    // NOTE: Must read stdout before waiting for exit\n                    //  If we don't, then the process will hang if some stdout buffer fills up\n                    //  lame....\n\n                    stdout = String.Concat(stdout, string.Concat(\"DX12 COMMAND LINE: \", commandline12, Environment.NewLine));\n                    stdout = String.Concat(stdout, Environment.NewLine);\n                    stdout = String.Concat(stdout, p.StandardOutput.ReadToEnd());\n\n                    p.WaitForExit();\n                    p.Close();\n                    foreach (string asic in asics)\n                        dx12Files.Add(String.Concat(isaDir12, asic, \".asm\"));\n\n                }\n\n                tempFilesToDelete.AddRange(dx11Files);\n                tempFilesToDelete.AddRange(dx12Files);\n\n                IntelShaderAnalyzerResultsPanel panel = new IntelShaderAnalyzerResultsPanel(stdout,asics);\n                panel.AddResults(\"DX11\", dx11Files);\n                panel.AddResults(\"DX12\", dx12Files);\n\n                // cleanup the temp files\n                foreach (string file in tempFilesToDelete)\n                    File.Delete(file);\n                \n                Directory.Delete(Path.Combine(m_TempPath, \"IntelISA_11\"));\n                Directory.Delete(Path.Combine(m_TempPath, \"IntelISA_12\"));\n\n                return new IntelShaderAnalyzerResultSet(panel);\n            }\n            catch (Exception ex)\n            {\n                MessageBox.Show(ex.Message, \"uh-oh, Couldn't run IntelShaderAnalyzer\", MessageBoxButtons.OK, MessageBoxIcon.Error);\n                return null;\n            }\n        }\n    };\n}\n"
  },
  {
    "path": "src/Backends/IntelShaderAnalyzerResultsPanel.Designer.cs",
    "content": "﻿namespace Pyramid\n{\n    partial class IntelShaderAnalyzerResultsPanel\n    {\n        /// <summary> \n        /// Required designer variable.\n        /// </summary>\n        private System.ComponentModel.IContainer components = null;\n\n        /// <summary> \n        /// Clean up any resources being used.\n        /// </summary>\n        /// <param name=\"disposing\">true if managed resources should be disposed; otherwise, false.</param>\n        protected override void Dispose(bool disposing)\n        {\n            if (disposing && (components != null))\n            {\n                components.Dispose();\n            }\n            base.Dispose(disposing);\n        }\n\n        #region Component Designer generated code\n\n        /// <summary> \n        /// Required method for Designer support - do not modify \n        /// the contents of this method with the code editor.\n        /// </summary>\n        private void InitializeComponent()\n        {\n            this.cmbOutputFile = new System.Windows.Forms.ComboBox();\n            this.cmbAPI = new System.Windows.Forms.ComboBox();\n            this.tabControl1 = new System.Windows.Forms.TabControl();\n            this.tabPage1 = new System.Windows.Forms.TabPage();\n            this.tabPage2 = new System.Windows.Forms.TabPage();\n            this.txtAsm = new System.Windows.Forms.TextBox();\n            this.txtMessages = new System.Windows.Forms.TextBox();\n            this.tabControl1.SuspendLayout();\n            this.tabPage1.SuspendLayout();\n            this.tabPage2.SuspendLayout();\n            this.SuspendLayout();\n            // \n            // cmbOutputFile\n            // \n            this.cmbOutputFile.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\n            this.cmbOutputFile.FormattingEnabled = true;\n            this.cmbOutputFile.Location = new System.Drawing.Point(161, 19);\n            this.cmbOutputFile.Margin = new System.Windows.Forms.Padding(4);\n            this.cmbOutputFile.Name = \"cmbOutputFile\";\n            this.cmbOutputFile.Size = new System.Drawing.Size(250, 24);\n            this.cmbOutputFile.TabIndex = 5;\n            this.cmbOutputFile.SelectedIndexChanged += new System.EventHandler(this.cmbOutputFile_SelectedIndexChanged);\n            // \n            // cmbAPI\n            // \n            this.cmbAPI.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\n            this.cmbAPI.FormattingEnabled = true;\n            this.cmbAPI.Location = new System.Drawing.Point(35, 19);\n            this.cmbAPI.Margin = new System.Windows.Forms.Padding(4);\n            this.cmbAPI.Name = \"cmbAPI\";\n            this.cmbAPI.Size = new System.Drawing.Size(104, 24);\n            this.cmbAPI.TabIndex = 6;\n            this.cmbAPI.SelectedIndexChanged += new System.EventHandler(this.cmbAPI_SelectedIndexChanged);\n            // \n            // tabControl1\n            // \n            this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) \n            | System.Windows.Forms.AnchorStyles.Left) \n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.tabControl1.Controls.Add(this.tabPage1);\n            this.tabControl1.Controls.Add(this.tabPage2);\n            this.tabControl1.Location = new System.Drawing.Point(3, 50);\n            this.tabControl1.Name = \"tabControl1\";\n            this.tabControl1.SelectedIndex = 0;\n            this.tabControl1.Size = new System.Drawing.Size(620, 409);\n            this.tabControl1.TabIndex = 7;\n            // \n            // tabPage1\n            // \n            this.tabPage1.Controls.Add(this.txtAsm);\n            this.tabPage1.Location = new System.Drawing.Point(4, 25);\n            this.tabPage1.Name = \"tabPage1\";\n            this.tabPage1.Padding = new System.Windows.Forms.Padding(3);\n            this.tabPage1.Size = new System.Drawing.Size(612, 380);\n            this.tabPage1.TabIndex = 0;\n            this.tabPage1.Text = \"Asm\";\n            this.tabPage1.UseVisualStyleBackColor = true;\n            this.tabPage1.Click += new System.EventHandler(this.tabPage1_Click);\n            // \n            // tabPage2\n            // \n            this.tabPage2.Controls.Add(this.txtMessages);\n            this.tabPage2.Location = new System.Drawing.Point(4, 25);\n            this.tabPage2.Name = \"tabPage2\";\n            this.tabPage2.Padding = new System.Windows.Forms.Padding(3);\n            this.tabPage2.Size = new System.Drawing.Size(612, 380);\n            this.tabPage2.TabIndex = 1;\n            this.tabPage2.Text = \"Messages\";\n            this.tabPage2.UseVisualStyleBackColor = true;\n            // \n            // txtAsm\n            // \n            this.txtAsm.Dock = System.Windows.Forms.DockStyle.Fill;\n            this.txtAsm.Font = new System.Drawing.Font(\"Consolas\", 9F);\n            this.txtAsm.Location = new System.Drawing.Point(3, 3);\n            this.txtAsm.Margin = new System.Windows.Forms.Padding(4);\n            this.txtAsm.Multiline = true;\n            this.txtAsm.Name = \"txtAsm\";\n            this.txtAsm.ReadOnly = true;\n            this.txtAsm.ScrollBars = System.Windows.Forms.ScrollBars.Both;\n            this.txtAsm.Size = new System.Drawing.Size(606, 374);\n            this.txtAsm.TabIndex = 5;\n            this.txtAsm.WordWrap = false;\n            // \n            // txtMessages\n            // \n            this.txtMessages.Dock = System.Windows.Forms.DockStyle.Fill;\n            this.txtMessages.Font = new System.Drawing.Font(\"Consolas\", 9F);\n            this.txtMessages.Location = new System.Drawing.Point(3, 3);\n            this.txtMessages.Margin = new System.Windows.Forms.Padding(4);\n            this.txtMessages.Multiline = true;\n            this.txtMessages.Name = \"txtMessages\";\n            this.txtMessages.ReadOnly = true;\n            this.txtMessages.ScrollBars = System.Windows.Forms.ScrollBars.Both;\n            this.txtMessages.Size = new System.Drawing.Size(606, 374);\n            this.txtMessages.TabIndex = 6;\n            // \n            // IntelShaderAnalyzerResultsPanel\n            // \n            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);\n            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\n            this.Controls.Add(this.tabControl1);\n            this.Controls.Add(this.cmbAPI);\n            this.Controls.Add(this.cmbOutputFile);\n            this.Name = \"IntelShaderAnalyzerResultsPanel\";\n            this.Size = new System.Drawing.Size(623, 462);\n            this.tabControl1.ResumeLayout(false);\n            this.tabPage1.ResumeLayout(false);\n            this.tabPage1.PerformLayout();\n            this.tabPage2.ResumeLayout(false);\n            this.tabPage2.PerformLayout();\n            this.ResumeLayout(false);\n\n        }\n\n        #endregion\n        private System.Windows.Forms.ComboBox cmbOutputFile;\n        private System.Windows.Forms.ComboBox cmbAPI;\n        private System.Windows.Forms.TabControl tabControl1;\n        private System.Windows.Forms.TabPage tabPage1;\n        private System.Windows.Forms.TabPage tabPage2;\n        private System.Windows.Forms.TextBox txtAsm;\n        private System.Windows.Forms.TextBox txtMessages;\n    }\n}\n"
  },
  {
    "path": "src/Backends/IntelShaderAnalyzerResultsPanel.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Drawing;\nusing System.Data;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Windows.Forms;\nusing System.IO;\n\nnamespace Pyramid\n{\n    public partial class IntelShaderAnalyzerResultsPanel : UserControl\n    {\n        public IntelShaderAnalyzerResultsPanel( string stdout, List<string> asics )\n        {\n            InitializeComponent();\n            txtMessages.Text = stdout;\n            tabPage1.Visible = false;\n\n            foreach( string asic in asics )\n                cmbOutputFile.Items.Add(asic);\n\n            cmbOutputFile.SelectedIndex = 0;\n        }\n\n        private Dictionary<string, Dictionary<string,string> > m_APISets = new Dictionary<string, Dictionary<string,string>>();\n        \n        public void AddResults( string api, List<string> files )\n        {\n            if (files.Count == 0)\n                return;\n\n            Dictionary<string, string> asicFiles = new Dictionary<string, string>();\n            foreach( string path in files )\n            {\n                string asic = Path.GetFileNameWithoutExtension(path);\n                if (File.Exists(path))\n                {\n                    string asm = File.ReadAllText(path);\n                    asicFiles.Add(asic, asm);\n                }\n            }\n            \n            m_APISets.Add(api, asicFiles);\n            cmbAPI.Items.Add(api);\n            cmbAPI.SelectedIndex = 0;\n\n            RefreshAsm();\n        }\n\n        private void RefreshAsm()\n        {\n            txtAsm.Text = \"\";\n            if( cmbAPI.SelectedItem != null && cmbOutputFile.SelectedItem != null )\n            {\n                Dictionary<String, String> Files;\n                if (m_APISets.TryGetValue((string)cmbAPI.SelectedItem, out Files))\n                {\n                    string text;\n                    if (Files.TryGetValue((string)cmbOutputFile.SelectedItem, out text))\n                    {\n                        txtAsm.Text = text;\n                    }\n                }\n            }\n        }\n\n        private void tabPage1_Click(object sender, EventArgs e)\n        {\n\n        }\n\n        private void cmbAPI_SelectedIndexChanged(object sender, EventArgs e)\n        {\n            RefreshAsm();\n        }\n\n        private void cmbOutputFile_SelectedIndexChanged(object sender, EventArgs e)\n        {\n            RefreshAsm();\n        }\n    }\n}\n"
  },
  {
    "path": "src/Backends/IntelShaderAnalyzerResultsPanel.resx",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n  <!-- \n    Microsoft ResX Schema \n    \n    Version 2.0\n    \n    The primary goals of this format is to allow a simple XML format \n    that is mostly human readable. The generation and parsing of the \n    various data types are done through the TypeConverter classes \n    associated with the data types.\n    \n    Example:\n    \n    ... ado.net/XML headers & schema ...\n    <resheader name=\"resmimetype\">text/microsoft-resx</resheader>\n    <resheader name=\"version\">2.0</resheader>\n    <resheader name=\"reader\">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\n    <resheader name=\"writer\">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\n    <data name=\"Name1\"><value>this is my long string</value><comment>this is a comment</comment></data>\n    <data name=\"Color1\" type=\"System.Drawing.Color, System.Drawing\">Blue</data>\n    <data name=\"Bitmap1\" mimetype=\"application/x-microsoft.net.object.binary.base64\">\n        <value>[base64 mime encoded serialized .NET Framework object]</value>\n    </data>\n    <data name=\"Icon1\" type=\"System.Drawing.Icon, System.Drawing\" mimetype=\"application/x-microsoft.net.object.bytearray.base64\">\n        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\n        <comment>This is a comment</comment>\n    </data>\n                \n    There are any number of \"resheader\" rows that contain simple \n    name/value pairs.\n    \n    Each data row contains a name, and value. The row also contains a \n    type or mimetype. Type corresponds to a .NET class that support \n    text/value conversion through the TypeConverter architecture. \n    Classes that don't support this are serialized and stored with the \n    mimetype set.\n    \n    The mimetype is used for serialized objects, and tells the \n    ResXResourceReader how to depersist the object. This is currently not \n    extensible. For a given mimetype the value must be set accordingly:\n    \n    Note - application/x-microsoft.net.object.binary.base64 is the format \n    that the ResXResourceWriter will generate, however the reader can \n    read any of the formats listed below.\n    \n    mimetype: application/x-microsoft.net.object.binary.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\n            : and then encoded with base64 encoding.\n    \n    mimetype: application/x-microsoft.net.object.soap.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\n            : and then encoded with base64 encoding.\n\n    mimetype: application/x-microsoft.net.object.bytearray.base64\n    value   : The object must be serialized into a byte array \n            : using a System.ComponentModel.TypeConverter\n            : and then encoded with base64 encoding.\n    -->\n  <xsd:schema id=\"root\" xmlns=\"\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">\n    <xsd:import namespace=\"http://www.w3.org/XML/1998/namespace\" />\n    <xsd:element name=\"root\" msdata:IsDataSet=\"true\">\n      <xsd:complexType>\n        <xsd:choice maxOccurs=\"unbounded\">\n          <xsd:element name=\"metadata\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" use=\"required\" type=\"xsd:string\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"assembly\">\n            <xsd:complexType>\n              <xsd:attribute name=\"alias\" type=\"xsd:string\" />\n              <xsd:attribute name=\"name\" type=\"xsd:string\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"data\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n                <xsd:element name=\"comment\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"2\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" msdata:Ordinal=\"1\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" msdata:Ordinal=\"3\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" msdata:Ordinal=\"4\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"resheader\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" />\n            </xsd:complexType>\n          </xsd:element>\n        </xsd:choice>\n      </xsd:complexType>\n    </xsd:element>\n  </xsd:schema>\n  <resheader name=\"resmimetype\">\n    <value>text/microsoft-resx</value>\n  </resheader>\n  <resheader name=\"version\">\n    <value>2.0</value>\n  </resheader>\n  <resheader name=\"reader\">\n    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n  <resheader name=\"writer\">\n    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n</root>"
  },
  {
    "path": "src/Backends/MaliSCBackend.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Diagnostics;\nusing System.Windows.Forms;\nusing System.Text.RegularExpressions;\n\nnamespace Pyramid\n{\n    public class MaliSCResultSet : IResultSet\n    {\n        public string Name { get { return \"MaliSC\"; } }\n        public Control AnalysisPanel { get; private set; }\n        public Control ResultsPanel { get; private set; }\n\n        public MaliSCResultSet()\n        {\n            AnalysisPanel = null;\n            ResultsPanel  = new MaliSCResultsPanel();\n        }\n        public void Add(string core, string output)\n        {\n            MaliSCResultsPanel rp = ResultsPanel as MaliSCResultsPanel;\n            rp.AddResult(core, output);\n        }\n    }\n\n    public class MaliSCBackend : IBackend\n    {\n        private string m_MaliRoot = \"\";\n        private string m_TempPath = \"\";\n        private List<string> m_Asics = new List<string>();\n\n        public MaliSCBackend(string MaliRoot, string TempPath)\n        {\n            m_MaliRoot = MaliRoot;\n            m_TempPath = TempPath;\n\n            // get asic list\n            string CommandLine = string.Format(\"--help\");\n\n            ProcessStartInfo pi = new ProcessStartInfo();\n            pi.RedirectStandardOutput = true;\n            pi.RedirectStandardInput = true;\n            pi.RedirectStandardError = true;\n            pi.EnvironmentVariables.Add(\"MALICM_LOCATION\", m_MaliRoot);\n            pi.CreateNoWindow = true;\n            pi.Arguments = CommandLine;\n            pi.FileName = Path.Combine(MaliRoot, \"malisc.exe\");\n            pi.UseShellExecute = false;\n\n            try\n            {\n                Process p = Process.Start(pi);\n                p.WaitForExit();\n\n                // malisc frontend prints a giant help-text string.\n                //  amidst the noise, we'll find a list of supported cores\n                //\n                //  We'll let them use defaults for driver revision and HW revision\n                //   because permuting over all that stuff is probably fruitless\n                //\n                string output = p.StandardOutput.ReadToEnd();\n                int idx = output.IndexOf(\"[-c <\");\n                string trimmed = output.Substring(output.IndexOf(\"[-c\"));\n                trimmed = trimmed.Substring(0, trimmed.IndexOf(\"]\"));\n                trimmed = trimmed.Substring(trimmed.IndexOf(\"<\"));\n                trimmed = trimmed.Substring(0, trimmed.IndexOf(\">\"));\n                trimmed = trimmed.Substring(1);\n\n                string[] asics = trimmed.Split('|');\n                foreach (string s in asics)\n                    m_Asics.Add(s.Trim());\n            }\n            catch (Exception e)\n            {\n                MessageBox.Show(e.Message, \"uh-oh, couldn't get MaliSC asic list\", MessageBoxButtons.OK, MessageBoxIcon.Error);\n            }\n        }\n\n        public string Name { get { return \"MaliSC\"; } }\n\n        public IResultSet Compile(IShader sh, IBackendOptions options)\n        {\n            if (sh.Language != Languages.GLSL)\n                return null;\n\n            GLSLShader glShader = (GLSLShader)sh;\n            IGLSLOptions glOpts = glShader.CompileOptions;\n            string shader = glShader.Code;\n\n            string shaderType = \"\";\n            switch( glOpts.ShaderType )\n            {\n            case GLSLShaderType.VERTEX:   shaderType = \"--vertex\";   break;\n            case GLSLShaderType.FRAGMENT: shaderType = \"--fragment\"; break;\n            case GLSLShaderType.COMPUTE:  shaderType = \"--compute\";  break;\n            default:\n                return null;\n            }\n\n            string tmpFile         = Path.Combine(m_TempPath, \"PYRAMID_mali\");\n            try\n            {\n                StreamWriter stream = File.CreateText(tmpFile);\n                stream.Write(shader);\n                stream.Close();\n            }\n            catch (Exception e)\n            {\n                MessageBox.Show(e.Message, \"uh-oh, couldn't create temp file\", MessageBoxButtons.OK, MessageBoxIcon.Error);\n                return null;\n            }\n\n            MaliSCResultSet rs = new MaliSCResultSet();\n            try\n            {\n                foreach (string asic in m_Asics)\n                {\n                    string commandline = String.Format(\"-V {0} -c {1} {2}\", shaderType, asic, tmpFile);\n                    ProcessStartInfo pi = new ProcessStartInfo();\n                    pi.RedirectStandardOutput = true;\n                    pi.RedirectStandardInput = true;\n                    pi.RedirectStandardError = true;\n                    pi.EnvironmentVariables.Add(\"MALICM_LOCATION\", m_MaliRoot);\n                    pi.CreateNoWindow = true;\n                    pi.Arguments = commandline;\n                    pi.FileName = Path.Combine(m_MaliRoot, \"malisc.exe\");\n                    pi.UseShellExecute = false;\n\n                    Process p = Process.Start(pi);\n                    string output = p.StandardOutput.ReadToEnd();\n                    p.WaitForExit();\n\n                    rs.Add(asic, output);\n                }\n            }\n            catch (System.Exception e)\n            {\n                MessageBox.Show(e.Message, \"uh-oh, couldn't run MaliSC\", MessageBoxButtons.OK, MessageBoxIcon.Error);\n            }\n\n            File.Delete(tmpFile);\n\n            return rs;\n        }\n    }\n}\n"
  },
  {
    "path": "src/Backends/MaliSCResultsPanel.Designer.cs",
    "content": "﻿namespace Pyramid\n{\n    partial class MaliSCResultsPanel\n    {\n        /// <summary> \n        /// Required designer variable.\n        /// </summary>\n        private System.ComponentModel.IContainer components = null;\n\n        /// <summary> \n        /// Clean up any resources being used.\n        /// </summary>\n        /// <param name=\"disposing\">true if managed resources should be disposed; otherwise, false.</param>\n        protected override void Dispose(bool disposing)\n        {\n            if (disposing && (components != null))\n            {\n                components.Dispose();\n            }\n            base.Dispose(disposing);\n        }\n\n        #region Component Designer generated code\n\n        /// <summary> \n        /// Required method for Designer support - do not modify \n        /// the contents of this method with the code editor.\n        /// </summary>\n        private void InitializeComponent()\n        {\n            this.txtOutput = new System.Windows.Forms.TextBox();\n            this.label1 = new System.Windows.Forms.Label();\n            this.cmbCore = new System.Windows.Forms.ComboBox();\n            this.SuspendLayout();\n            // \n            // txtOutput\n            // \n            this.txtOutput.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) \n            | System.Windows.Forms.AnchorStyles.Left) \n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.txtOutput.Location = new System.Drawing.Point(3, 32);\n            this.txtOutput.Multiline = true;\n            this.txtOutput.Name = \"txtOutput\";\n            this.txtOutput.ReadOnly = true;\n            this.txtOutput.ScrollBars = System.Windows.Forms.ScrollBars.Both;\n            this.txtOutput.Size = new System.Drawing.Size(393, 283);\n            this.txtOutput.TabIndex = 0;\n            // \n            // label1\n            // \n            this.label1.AutoSize = true;\n            this.label1.Location = new System.Drawing.Point(8, 11);\n            this.label1.Name = \"label1\";\n            this.label1.Size = new System.Drawing.Size(29, 13);\n            this.label1.TabIndex = 1;\n            this.label1.Text = \"Core\";\n            // \n            // cmbCore\n            // \n            this.cmbCore.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\n            this.cmbCore.FormattingEnabled = true;\n            this.cmbCore.Location = new System.Drawing.Point(43, 5);\n            this.cmbCore.Name = \"cmbCore\";\n            this.cmbCore.Size = new System.Drawing.Size(207, 21);\n            this.cmbCore.TabIndex = 2;\n            this.cmbCore.SelectedIndexChanged += new System.EventHandler(this.cmbCore_SelectedIndexChanged);\n            // \n            // MaliSCResultsPanel\n            // \n            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\n            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\n            this.Controls.Add(this.cmbCore);\n            this.Controls.Add(this.label1);\n            this.Controls.Add(this.txtOutput);\n            this.Name = \"MaliSCResultsPanel\";\n            this.Size = new System.Drawing.Size(399, 318);\n            this.ResumeLayout(false);\n            this.PerformLayout();\n\n        }\n\n        #endregion\n\n        private System.Windows.Forms.TextBox txtOutput;\n        private System.Windows.Forms.Label label1;\n        private System.Windows.Forms.ComboBox cmbCore;\n\n    }\n}\n"
  },
  {
    "path": "src/Backends/MaliSCResultsPanel.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Drawing;\nusing System.Data;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Windows.Forms;\n\nnamespace Pyramid\n{\n    public partial class MaliSCResultsPanel : UserControl\n    {\n        private List<string> m_Cores = new List<string>();\n        private List<string> m_Output = new List<string>();\n\n        public MaliSCResultsPanel()\n        {\n            InitializeComponent();\n        }\n\n        public void AddResult(string core, string output)\n        {\n            m_Cores.Add(core);\n            m_Output.Add(output);\n            cmbCore.Items.Add(core);\n            if (cmbCore.Items.Count == 1)\n                cmbCore.SelectedIndex = 0;\n        }\n\n        private void cmbCore_SelectedIndexChanged(object sender, EventArgs e)\n        {\n            txtOutput.Text = m_Output[m_Cores.IndexOf(cmbCore.Text)];\n        }\n    }\n}\n"
  },
  {
    "path": "src/Backends/MaliSCResultsPanel.resx",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n  <!-- \n    Microsoft ResX Schema \n    \n    Version 2.0\n    \n    The primary goals of this format is to allow a simple XML format \n    that is mostly human readable. The generation and parsing of the \n    various data types are done through the TypeConverter classes \n    associated with the data types.\n    \n    Example:\n    \n    ... ado.net/XML headers & schema ...\n    <resheader name=\"resmimetype\">text/microsoft-resx</resheader>\n    <resheader name=\"version\">2.0</resheader>\n    <resheader name=\"reader\">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\n    <resheader name=\"writer\">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\n    <data name=\"Name1\"><value>this is my long string</value><comment>this is a comment</comment></data>\n    <data name=\"Color1\" type=\"System.Drawing.Color, System.Drawing\">Blue</data>\n    <data name=\"Bitmap1\" mimetype=\"application/x-microsoft.net.object.binary.base64\">\n        <value>[base64 mime encoded serialized .NET Framework object]</value>\n    </data>\n    <data name=\"Icon1\" type=\"System.Drawing.Icon, System.Drawing\" mimetype=\"application/x-microsoft.net.object.bytearray.base64\">\n        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\n        <comment>This is a comment</comment>\n    </data>\n                \n    There are any number of \"resheader\" rows that contain simple \n    name/value pairs.\n    \n    Each data row contains a name, and value. The row also contains a \n    type or mimetype. Type corresponds to a .NET class that support \n    text/value conversion through the TypeConverter architecture. \n    Classes that don't support this are serialized and stored with the \n    mimetype set.\n    \n    The mimetype is used for serialized objects, and tells the \n    ResXResourceReader how to depersist the object. This is currently not \n    extensible. For a given mimetype the value must be set accordingly:\n    \n    Note - application/x-microsoft.net.object.binary.base64 is the format \n    that the ResXResourceWriter will generate, however the reader can \n    read any of the formats listed below.\n    \n    mimetype: application/x-microsoft.net.object.binary.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\n            : and then encoded with base64 encoding.\n    \n    mimetype: application/x-microsoft.net.object.soap.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\n            : and then encoded with base64 encoding.\n\n    mimetype: application/x-microsoft.net.object.bytearray.base64\n    value   : The object must be serialized into a byte array \n            : using a System.ComponentModel.TypeConverter\n            : and then encoded with base64 encoding.\n    -->\n  <xsd:schema id=\"root\" xmlns=\"\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">\n    <xsd:import namespace=\"http://www.w3.org/XML/1998/namespace\" />\n    <xsd:element name=\"root\" msdata:IsDataSet=\"true\">\n      <xsd:complexType>\n        <xsd:choice maxOccurs=\"unbounded\">\n          <xsd:element name=\"metadata\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" use=\"required\" type=\"xsd:string\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"assembly\">\n            <xsd:complexType>\n              <xsd:attribute name=\"alias\" type=\"xsd:string\" />\n              <xsd:attribute name=\"name\" type=\"xsd:string\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"data\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n                <xsd:element name=\"comment\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"2\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" msdata:Ordinal=\"1\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" msdata:Ordinal=\"3\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" msdata:Ordinal=\"4\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"resheader\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" />\n            </xsd:complexType>\n          </xsd:element>\n        </xsd:choice>\n      </xsd:complexType>\n    </xsd:element>\n  </xsd:schema>\n  <resheader name=\"resmimetype\">\n    <value>text/microsoft-resx</value>\n  </resheader>\n  <resheader name=\"version\">\n    <value>2.0</value>\n  </resheader>\n  <resheader name=\"reader\">\n    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n  <resheader name=\"writer\">\n    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n</root>"
  },
  {
    "path": "src/Backends/PVRResultsPanel.Designer.cs",
    "content": "﻿namespace Pyramid\n{\n    partial class PVRResultsPanel\n    {\n        /// <summary> \n        /// Required designer variable.\n        /// </summary>\n        private System.ComponentModel.IContainer components = null;\n\n        /// <summary> \n        /// Clean up any resources being used.\n        /// </summary>\n        /// <param name=\"disposing\">true if managed resources should be disposed; otherwise, false.</param>\n        protected override void Dispose(bool disposing)\n        {\n            if (disposing && (components != null))\n            {\n                components.Dispose();\n            }\n            base.Dispose(disposing);\n        }\n\n        #region Component Designer generated code\n\n        /// <summary> \n        /// Required method for Designer support - do not modify \n        /// the contents of this method with the code editor.\n        /// </summary>\n        private void InitializeComponent()\n        {\n            this.label1 = new System.Windows.Forms.Label();\n            this.cmbCompiler = new System.Windows.Forms.ComboBox();\n            this.tabControl1 = new System.Windows.Forms.TabControl();\n            this.tabPage1 = new System.Windows.Forms.TabPage();\n            this.tabPage2 = new System.Windows.Forms.TabPage();\n            this.txtASM = new System.Windows.Forms.TextBox();\n            this.txtOutput = new System.Windows.Forms.TextBox();\n            this.tabControl1.SuspendLayout();\n            this.tabPage1.SuspendLayout();\n            this.tabPage2.SuspendLayout();\n            this.SuspendLayout();\n            // \n            // label1\n            // \n            this.label1.AutoSize = true;\n            this.label1.Location = new System.Drawing.Point(5, 9);\n            this.label1.Name = \"label1\";\n            this.label1.Size = new System.Drawing.Size(47, 13);\n            this.label1.TabIndex = 0;\n            this.label1.Text = \"Compiler\";\n            // \n            // cmbCompiler\n            // \n            this.cmbCompiler.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) \n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.cmbCompiler.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\n            this.cmbCompiler.FormattingEnabled = true;\n            this.cmbCompiler.Location = new System.Drawing.Point(54, 5);\n            this.cmbCompiler.Name = \"cmbCompiler\";\n            this.cmbCompiler.Size = new System.Drawing.Size(164, 21);\n            this.cmbCompiler.TabIndex = 1;\n            this.cmbCompiler.SelectedIndexChanged += new System.EventHandler(this.cmbCompiler_SelectedIndexChanged);\n            // \n            // tabControl1\n            // \n            this.tabControl1.Alignment = System.Windows.Forms.TabAlignment.Bottom;\n            this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) \n            | System.Windows.Forms.AnchorStyles.Left) \n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.tabControl1.Controls.Add(this.tabPage1);\n            this.tabControl1.Controls.Add(this.tabPage2);\n            this.tabControl1.Location = new System.Drawing.Point(10, 31);\n            this.tabControl1.Name = \"tabControl1\";\n            this.tabControl1.SelectedIndex = 0;\n            this.tabControl1.Size = new System.Drawing.Size(207, 190);\n            this.tabControl1.TabIndex = 2;\n            // \n            // tabPage1\n            // \n            this.tabPage1.Controls.Add(this.txtASM);\n            this.tabPage1.Location = new System.Drawing.Point(4, 4);\n            this.tabPage1.Name = \"tabPage1\";\n            this.tabPage1.Padding = new System.Windows.Forms.Padding(3);\n            this.tabPage1.Size = new System.Drawing.Size(199, 164);\n            this.tabPage1.TabIndex = 0;\n            this.tabPage1.Text = \"ASM\";\n            this.tabPage1.UseVisualStyleBackColor = true;\n            // \n            // tabPage2\n            // \n            this.tabPage2.Controls.Add(this.txtOutput);\n            this.tabPage2.Location = new System.Drawing.Point(4, 4);\n            this.tabPage2.Name = \"tabPage2\";\n            this.tabPage2.Padding = new System.Windows.Forms.Padding(3);\n            this.tabPage2.Size = new System.Drawing.Size(199, 164);\n            this.tabPage2.TabIndex = 1;\n            this.tabPage2.Text = \"Output\";\n            this.tabPage2.UseVisualStyleBackColor = true;\n            // \n            // txtASM\n            // \n            this.txtASM.Dock = System.Windows.Forms.DockStyle.Fill;\n            this.txtASM.Location = new System.Drawing.Point(3, 3);\n            this.txtASM.Multiline = true;\n            this.txtASM.Name = \"txtASM\";\n            this.txtASM.ReadOnly = true;\n            this.txtASM.ScrollBars = System.Windows.Forms.ScrollBars.Both;\n            this.txtASM.Size = new System.Drawing.Size(193, 158);\n            this.txtASM.TabIndex = 0;\n            // \n            // txtOutput\n            // \n            this.txtOutput.Dock = System.Windows.Forms.DockStyle.Fill;\n            this.txtOutput.Location = new System.Drawing.Point(3, 3);\n            this.txtOutput.Multiline = true;\n            this.txtOutput.Name = \"txtOutput\";\n            this.txtOutput.ReadOnly = true;\n            this.txtOutput.ScrollBars = System.Windows.Forms.ScrollBars.Both;\n            this.txtOutput.Size = new System.Drawing.Size(193, 158);\n            this.txtOutput.TabIndex = 1;\n            // \n            // PVRResultsPanel\n            // \n            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\n            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\n            this.Controls.Add(this.tabControl1);\n            this.Controls.Add(this.cmbCompiler);\n            this.Controls.Add(this.label1);\n            this.Name = \"PVRResultsPanel\";\n            this.Size = new System.Drawing.Size(228, 232);\n            this.tabControl1.ResumeLayout(false);\n            this.tabPage1.ResumeLayout(false);\n            this.tabPage1.PerformLayout();\n            this.tabPage2.ResumeLayout(false);\n            this.tabPage2.PerformLayout();\n            this.ResumeLayout(false);\n            this.PerformLayout();\n\n        }\n\n        #endregion\n\n        private System.Windows.Forms.Label label1;\n        private System.Windows.Forms.ComboBox cmbCompiler;\n        private System.Windows.Forms.TabControl tabControl1;\n        private System.Windows.Forms.TabPage tabPage1;\n        private System.Windows.Forms.TabPage tabPage2;\n        private System.Windows.Forms.TextBox txtASM;\n        private System.Windows.Forms.TextBox txtOutput;\n    }\n}\n"
  },
  {
    "path": "src/Backends/PVRResultsPanel.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Text;\nusing System.Windows.Forms;\n\nnamespace Pyramid\n{\n    public partial class PVRResultsPanel : UserControl\n    {\n        private List<string> m_ASM = new List<string>();\n        private List<string> m_Output = new List<string>();\n\n        public PVRResultsPanel()\n        {\n            InitializeComponent();\n        }\n\n        public void AddResult( string compiler, string output, string asm )\n        {\n            m_ASM.Add(asm);\n            m_Output.Add( output );\n            cmbCompiler.Items.Add(compiler);\n            if( cmbCompiler.Items.Count == 1 )\n                cmbCompiler.SelectedIndex = 0;\n        }\n\n        private void cmbCompiler_SelectedIndexChanged(object sender, EventArgs e)\n        {\n            txtASM.Text    = m_ASM[cmbCompiler.SelectedIndex];\n            txtOutput.Text = m_Output[cmbCompiler.SelectedIndex];\n        }\n    }\n}\n"
  },
  {
    "path": "src/Backends/PVRResultsPanel.resx",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n  <!-- \n    Microsoft ResX Schema \n    \n    Version 2.0\n    \n    The primary goals of this format is to allow a simple XML format \n    that is mostly human readable. The generation and parsing of the \n    various data types are done through the TypeConverter classes \n    associated with the data types.\n    \n    Example:\n    \n    ... ado.net/XML headers & schema ...\n    <resheader name=\"resmimetype\">text/microsoft-resx</resheader>\n    <resheader name=\"version\">2.0</resheader>\n    <resheader name=\"reader\">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\n    <resheader name=\"writer\">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\n    <data name=\"Name1\"><value>this is my long string</value><comment>this is a comment</comment></data>\n    <data name=\"Color1\" type=\"System.Drawing.Color, System.Drawing\">Blue</data>\n    <data name=\"Bitmap1\" mimetype=\"application/x-microsoft.net.object.binary.base64\">\n        <value>[base64 mime encoded serialized .NET Framework object]</value>\n    </data>\n    <data name=\"Icon1\" type=\"System.Drawing.Icon, System.Drawing\" mimetype=\"application/x-microsoft.net.object.bytearray.base64\">\n        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\n        <comment>This is a comment</comment>\n    </data>\n                \n    There are any number of \"resheader\" rows that contain simple \n    name/value pairs.\n    \n    Each data row contains a name, and value. The row also contains a \n    type or mimetype. Type corresponds to a .NET class that support \n    text/value conversion through the TypeConverter architecture. \n    Classes that don't support this are serialized and stored with the \n    mimetype set.\n    \n    The mimetype is used for serialized objects, and tells the \n    ResXResourceReader how to depersist the object. This is currently not \n    extensible. For a given mimetype the value must be set accordingly:\n    \n    Note - application/x-microsoft.net.object.binary.base64 is the format \n    that the ResXResourceWriter will generate, however the reader can \n    read any of the formats listed below.\n    \n    mimetype: application/x-microsoft.net.object.binary.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\n            : and then encoded with base64 encoding.\n    \n    mimetype: application/x-microsoft.net.object.soap.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\n            : and then encoded with base64 encoding.\n\n    mimetype: application/x-microsoft.net.object.bytearray.base64\n    value   : The object must be serialized into a byte array \n            : using a System.ComponentModel.TypeConverter\n            : and then encoded with base64 encoding.\n    -->\n  <xsd:schema id=\"root\" xmlns=\"\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">\n    <xsd:import namespace=\"http://www.w3.org/XML/1998/namespace\" />\n    <xsd:element name=\"root\" msdata:IsDataSet=\"true\">\n      <xsd:complexType>\n        <xsd:choice maxOccurs=\"unbounded\">\n          <xsd:element name=\"metadata\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" use=\"required\" type=\"xsd:string\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"assembly\">\n            <xsd:complexType>\n              <xsd:attribute name=\"alias\" type=\"xsd:string\" />\n              <xsd:attribute name=\"name\" type=\"xsd:string\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"data\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n                <xsd:element name=\"comment\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"2\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" msdata:Ordinal=\"1\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" msdata:Ordinal=\"3\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" msdata:Ordinal=\"4\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"resheader\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" />\n            </xsd:complexType>\n          </xsd:element>\n        </xsd:choice>\n      </xsd:complexType>\n    </xsd:element>\n  </xsd:schema>\n  <resheader name=\"resmimetype\">\n    <value>text/microsoft-resx</value>\n  </resheader>\n  <resheader name=\"version\">\n    <value>2.0</value>\n  </resheader>\n  <resheader name=\"reader\">\n    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n  <resheader name=\"writer\">\n    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n  <metadata name=\"txtASM.Locked\" type=\"System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\">\n    <value>True</value>\n  </metadata>\n  <metadata name=\"txtOutput.Locked\" type=\"System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\">\n    <value>True</value>\n  </metadata>\n</root>"
  },
  {
    "path": "src/Backends/PowerVRBackend.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Diagnostics;\nusing System.Windows.Forms;\n\n\nnamespace Pyramid\n{\n    class PVRResultSet : IResultSet\n    {\n        private PVRResultsPanel m_Results = new PVRResultsPanel();\n\n        public string Name { get { return \"PowerVR\"; } }\n        public Control AnalysisPanel { get { return null; } }\n        public Control ResultsPanel { get { return m_Results; } }\n\n        public PVRResultsPanel PVRResultsPanel { get { return m_Results; } }\n    };\n\n    class PowerVRBackend : IBackend\n    {\n        private List<string> m_Compilers = new List<String>();\n        private string m_TempPath;\n\n        public string Name { get { return \"PowerVR\"; } }\n\n        public PowerVRBackend( string CompilerDir, string tempDir )\n        {\n            CompilerDir = Path.GetFullPath(CompilerDir);\n            m_TempPath = tempDir;\n\n            if (!Directory.Exists(CompilerDir))\n            {\n                MessageBox.Show(\"PowerVR compiler directory doesn't exist\", \"uh-oh\", MessageBoxButtons.OK, MessageBoxIcon.Error);\n                return;\n            }\n\n            foreach (string s in Directory.EnumerateFiles(CompilerDir))\n            {\n                string ext = Path.GetExtension(s);\n                if( ext.Equals(\".exe\") )\n                {\n                    ProcessStartInfo pi = new ProcessStartInfo();\n                    pi.RedirectStandardOutput = true;\n                    pi.RedirectStandardInput = true;\n                    pi.RedirectStandardError = true;\n                    pi.CreateNoWindow = true;\n                    pi.Arguments = \"-?\";\n                    pi.FileName = s;\n                    pi.UseShellExecute = false;\n\n                    try\n                    {\n                        Process p = Process.Start(pi);\n                        p.WaitForExit();\n\n                        string output = p.StandardError.ReadToEnd();\n                        if (!output.Contains(\"PVR GLSL-ES compiler for\"))\n                            continue;\n                        if (!output.Contains(\"-disasm\"))\n                            continue;\n\n                        m_Compilers.Add(s);\n                    }\n                    catch (System.Exception )\n                    {\n                        continue;\n                    }\n                }\n            }\n\n        }\n\n        public IResultSet Compile(IShader sh, IBackendOptions options)\n        {\n            if (sh.Language != Languages.GLSL)\n                return null;\n\n            GLSLShader glShader = (GLSLShader)sh;\n            IGLSLOptions glOpts = glShader.CompileOptions;\n            string shader = glShader.Code;\n\n            \n            string shaderSwitch = \"\";\n            switch (glOpts.ShaderType)\n            {\n                case GLSLShaderType.VERTEX:   shaderSwitch = \"-v\"; break;\n                case GLSLShaderType.FRAGMENT: shaderSwitch = \"-f\"; break;\n                case GLSLShaderType.COMPUTE:  shaderSwitch = \"-c\"; break;\n                default:\n                    return null;\n            }\n\n            string tmpFile         = Path.Combine(m_TempPath, \"PYRAMID_pvr\");\n            string dummyOutputFile = Path.Combine(m_TempPath, \"PYRAMID_pvr.out\");\n            string disasmFile      = Path.Combine(m_TempPath, \"PYRAMID_pvr.disasm\");\n            try\n            {\n                StreamWriter stream = File.CreateText(tmpFile);\n                stream.Write(shader);\n                stream.Close();\n            }\n            catch (Exception e)\n            {\n                MessageBox.Show(e.Message, \"uh-oh, couldn't create temp file\", MessageBoxButtons.OK, MessageBoxIcon.Error);\n                return null;\n            }\n\n            string args = String.Format(\"{0} {1} {2} -disasm\", tmpFile, dummyOutputFile, shaderSwitch);\n          \n\n            PVRResultSet rs = new PVRResultSet();\n\n            foreach (string s in m_Compilers)\n            {\n                ProcessStartInfo pi = new ProcessStartInfo();\n                pi.RedirectStandardOutput = true;\n                pi.RedirectStandardInput = true;\n                pi.RedirectStandardError = true;\n                pi.CreateNoWindow = true;\n                pi.Arguments = args;\n                pi.FileName  = s;\n                pi.UseShellExecute = false;\n\n                try\n                {\n                    Process p= Process.Start(pi);\n                    \n                    string asm = \"No Output\";\n                    string output = p.StandardError.ReadToEnd();\n                    string compiler = Path.GetFileNameWithoutExtension(s);\n\n                    p.WaitForExit();\n\n                    if (File.Exists(disasmFile))\n                    {\n                        asm = File.ReadAllText(disasmFile);\n                        File.Delete(disasmFile);\n                    }\n\n                    rs.PVRResultsPanel.AddResult(compiler, output, asm);\n                }\n                catch (System.Exception)\n                {\n                    continue;\n                }\n            }\n\n            File.Delete(tmpFile);\n\n            return rs;\n        }\n\n    }\n}\n"
  },
  {
    "path": "src/Backends/RGABackend.cs",
    "content": "﻿\nusing System.Diagnostics;\nusing System.Collections.Generic;\nusing System.IO;\nusing System;\nusing System.Windows.Forms;\n\nnamespace Pyramid\n{\n    class RGAResult\n    {\n        public string Isa { get; private set; }\n        public string Il { get; private set; }\n        public string Analysis { get; private set; }\n        public string LiveReg { get; private set; }\n        public string Asic { get; private set; }\n\n        public RGAResult( string asic, string path )\n        {\n            Asic = asic;\n\n            string isaFile      = Path.ChangeExtension(path, \".isa\");\n            string analysisFile = Path.ChangeExtension(path, \".analysis\");\n            string ilFile       = Path.ChangeExtension(path, \".il\");\n            string liveRegFile  = Path.ChangeExtension(path, \".livereg\");\n\n            if (File.Exists(isaFile))\n            {\n                this.Isa = File.ReadAllText(isaFile);\n                File.Delete(isaFile);\n            }\n            if (File.Exists(analysisFile))\n            {\n                this.Analysis = File.ReadAllText(analysisFile);\n                File.Delete(analysisFile);\n            }\n\n            if (File.Exists(ilFile))\n            {\n                this.Il = File.ReadAllText(ilFile);\n                File.Delete(ilFile);\n            }\n\n            if (File.Exists(liveRegFile))\n            {\n                this.LiveReg = File.ReadAllText(liveRegFile);\n                File.Delete(liveRegFile);\n            }\n        }\n    }\n\n    class GenericTextResultSet : IResultSet\n    {\n        public GenericTextResultSet(string name, string text)\n        {\n            Name = name;\n            RichTextBox results = new RichTextBox();\n            results.Dock = DockStyle.Fill;\n            results.ReadOnly = true;\n            results.Multiline = true;\n            results.Font = new System.Drawing.Font(\"Lucida Console\", 8);\n            results.Text = text;\n            results.ScrollBars = RichTextBoxScrollBars.Both;\n\n            ResultsPanel = results;\n        }\n        public Control ResultsPanel { get; private set; }\n        public Control AnalysisPanel { get { return null; } }\n        public string Name { get; private set; }\n        \n    }\n\n    class RGAResultSet : IResultSet\n    {\n        private AMDResultsPanel m_ResultsPanel;\n        private TextBox m_Analysis = new TextBox();\n        private Dictionary<string, RGAResult> m_ResultMap = new Dictionary<string, RGAResult>();\n\n        public RGAResultSet( string name, string toolOutput )\n        {\n            m_ResultsPanel = new AMDResultsPanel();\n            m_ResultsPanel.SetToolOutput(toolOutput);\n          \n            m_Analysis.Dock = DockStyle.Fill;\n            m_Analysis.ReadOnly = true;\n            m_Analysis.Multiline = true;\n            m_Analysis.Font = new System.Drawing.Font(\"Lucida Console\", 8);\n            m_Analysis.ScrollBars = ScrollBars.Both;\n            m_ResultsPanel.AsicChanged += delegate(string asic)\n            {\n                m_Analysis.Text = m_ResultMap[asic].Analysis;\n            };\n\n            Name = name;\n        }\n\n        public Control ResultsPanel { get { return m_ResultsPanel; } }\n        public Control AnalysisPanel { get { return m_Analysis; } }\n        public string Name { get; private set; }\n        public int ResultCount { get { return m_ResultsPanel.ResultCount; } }\n\n        public void AddCompileResult( RGAResult result )\n        {\n            m_ResultMap.Add(result.Asic, result);\n            m_ResultsPanel.AddResult(result.Asic, result.Il, result.Isa);\n        }\n\n        public void DisplayAsic(string asic)\n        {\n            m_ResultsPanel.SetAsic(asic);\n            m_Analysis.Text = m_ResultMap[asic].Analysis;\n        }\n    }\n\n    class RGABackendOptions : IBackendOptions\n    {\n        private Options m_Opts;\n\n        public RGABackendOptions( Options opts )\n        {\n            m_Opts = opts;\n                \n        }\n\n        public bool ShouldCompileForAsic( string asic)\n        {\n            return !m_Opts.IsRGAAsicDisabled(asic);\n           \n        }\n    }\n\n    class RGABackend : IBackend\n    {\n        private List<string> m_SupportedAsics = new List<string>();\n        private string m_RGAPath = \"\";\n        private string m_TempPath = \"\";\n        private GLSlang.ICompiler m_GLSLang;\n        private GLSlang.IConfig m_GLSLangConfig;\n\n        public string Name { get { return \"RGA_Vulkan\"; } }\n        public IEnumerable<string> Asics { get { return m_SupportedAsics; } }\n\n        public static List<string> GetAsicList( string RGAPath )\n        {\n            string CommandLine = string.Format(\"-s vulkan -l\");\n            List<string> asics = new List<string>();\n\n            ProcessStartInfo pi = new ProcessStartInfo();\n            pi.RedirectStandardOutput = true;\n            pi.RedirectStandardInput = true;\n            pi.RedirectStandardError = true;\n            pi.CreateNoWindow = true;\n            pi.Arguments = CommandLine;\n            pi.FileName = RGAPath;\n            pi.UseShellExecute = false;\n            try\n            {\n                Process p = Process.Start(pi);\n                \n                while (!p.StandardOutput.EndOfStream)\n                {\n                    // Output is of the form:\n                    // \n                    //name (graphics ip)\n                    //\\tproduct_name\n                    //\\tproduct_name\n                    // ....\n                    //\n                    string s = p.StandardOutput.ReadLine();\n                    if (s.Length == 0)\n                        continue; // blank line\n                    if (s[0] == '\\t')\n                        continue; // indented product name\n\n                    // grab the asic name, ignore everything after\n                    int len = s.IndexOf(' ');\n                    if (len > 0)\n                        s = s.Substring(0, len);\n\n                    asics.Add(s);\n                }\n\n                p.WaitForExit();\n                p.Close();\n            }\n            catch (Exception e)\n            {\n                MessageBox.Show(e.Message, \"uh-oh, couldn't get RGA asic list\", MessageBoxButtons.OK, MessageBoxIcon.Error);\n            }\n\n            return asics;\n        }\n\n        public RGABackend(string RGAPath, string TempPath, IWrapper wrapper, IIncludeHandler handler )\n        {\n            m_SupportedAsics = GetAsicList(RGAPath);\n            m_RGAPath = RGAPath;\n            m_TempPath = TempPath;\n\n            m_GLSLang = wrapper.CreateGLSlangCompiler(handler);\n            m_GLSLangConfig = m_GLSLang.CreateDefaultConfig();\n        }\n\n        private string GetRGAShaderType(GLSLShaderType eShaderType)\n        {\n            string sType = \"\";\n            switch (eShaderType)\n            {\n                default:\n                    return \"\";\n                case GLSLShaderType.VERTEX: sType = \"vert\"; break;\n                case GLSLShaderType.FRAGMENT: sType = \"frag\"; break;\n                case GLSLShaderType.GEOMETRY: sType = \"geom\"; break;\n                case GLSLShaderType.TESS_CONTROL: sType = \"tesc\"; break;\n                case GLSLShaderType.TESS_EVALUATION: sType = \"tese\"; break;\n                case GLSLShaderType.COMPUTE: sType = \"comp\"; break;\n            }\n            return sType;\n        }\n\n        GLSlang.IShader CompileShader( IShader shader )\n        {\n            if (shader is HLSLShader)\n            {\n                // pass the shader through GLSLang's hlsl front end\n                HLSLShader hlsl = shader as HLSLShader;\n                return m_GLSLang.CompileHLSL(shader.Code, hlsl.CompileOptions, m_GLSLangConfig, shader.SourceFilePath);\n            }\n            else if( shader is GLSLShader )\n            {\n                GLSLShader glsl = shader as GLSLShader;\n                return m_GLSLang.Compile(shader.Code, glsl.CompileOptions.ShaderType, m_GLSLangConfig, glsl.SourceFilePath);\n            }\n            else\n            {\n                throw new System.Exception(\"Bad shader type?!?\");\n            }\n        }\n\n        public IResultSet Compile(IShader shader, IBackendOptions options)\n        {\n            if( !(options is RGABackendOptions))\n                return null;\n            if (!(shader is HLSLShader || shader is GLSLShader))\n                return null;\n\n            RGABackendOptions backendOptions = options as RGABackendOptions;\n                \n            string tmpFile = Path.Combine(m_TempPath, \"PYRAMID_amdrga\");\n            \n            // pass the shader through GLSLang's hlsl front end\n            GLSlang.IShader glShader = CompileShader(shader);\n            if (glShader.HasErrors)\n                return new GenericTextResultSet(this.Name, glShader.InfoLog);\n\n            string sType = GetRGAShaderType(glShader.ShaderType);\n\n            // get the SPIR-V\n            SPIRV.IProgram spirv = glShader.CompileSPIRV();\n            if (spirv == null)\n                return new GenericTextResultSet(this.Name, \"Error generating SPIR-V\");\n\n            // dump the SPIR-V to disk\n            try\n            {\n                File.WriteAllBytes(tmpFile, spirv.GetBytes());\n            }\n            catch (Exception e)\n            {\n                MessageBox.Show(e.Message, \"uh-oh, couldn't create temp file\", MessageBoxButtons.OK, MessageBoxIcon.Error);\n                return null;\n            }\n\n            // send the SPIR-V to RGA\n            string CommandLine = String.Format(\" -s vulkan-spv {0}\", tmpFile);\n            \n\n            string isaPath = Path.Combine(m_TempPath, \"pyramid.isa\");\n            string analysisPath = Path.Combine(m_TempPath, \"pyramid.analysis\");\n            string ilPath = Path.Combine(m_TempPath, \"pyramid.il\");\n            string liveRegPath = Path.Combine(m_TempPath, \"pyramid.livereg\");\n            CommandLine = String.Concat(CommandLine, String.Format(\" --isa \\\"{0}\\\" \", isaPath));\n            CommandLine = String.Concat(CommandLine, String.Format(\" -a \\\"{0}\\\" \", analysisPath));\n            CommandLine = String.Concat(CommandLine, String.Format(\" --il \\\"{0}\\\" \", ilPath));\n            CommandLine = String.Concat(CommandLine, String.Format(\" --livereg \\\"{0}\\\" \", liveRegPath));\n            \n            List<string> asicsToCompile = new List<String>();\n            foreach (string asic in m_SupportedAsics)\n            {\n                if ( backendOptions.ShouldCompileForAsic(asic))\n                {\n                    asicsToCompile.Add(asic);\n                    CommandLine = String.Concat(CommandLine, \" -c \", asic, \" \");\n                }\n            }\n\n            if (asicsToCompile.Count == 0)\n                return null;\n\n            string defaultAsic = asicsToCompile[0];\n\n\n            ProcessStartInfo pi = new ProcessStartInfo();\n            pi.RedirectStandardOutput = true;\n            pi.RedirectStandardInput = true;\n            pi.RedirectStandardError = false;\n            pi.CreateNoWindow = true;\n            pi.Arguments = CommandLine;\n            pi.FileName = m_RGAPath;\n            pi.UseShellExecute = false;\n\n            string output;\n            try\n            {\n                Process p = Process.Start(pi);\n                output = p.StandardOutput.ReadToEnd();\n                \n                int TIMEOUT = 60000;\n                p.WaitForExit(TIMEOUT);\n                \n                p.Close();\n                File.Delete(tmpFile);\n            }\n            catch (Exception e)\n            {\n                MessageBox.Show(e.Message, \"uh-oh, couldn't run CodeXL\", MessageBoxButtons.OK, MessageBoxIcon.Error);\n                return null;\n            }\n\n            output = String.Format(@\"Arguments:\n                                    ----------\n                                    {0}\n                                    Output:\n                                    -------\n                                    {1}\", CommandLine, output);\n           \n            // Compile results are emitted in one set of files per asic\n            RGAResultSet results = new RGAResultSet(this.Name, output);\n           \n            foreach (string asic in asicsToCompile)\n            {\n                string path = Path.Combine( m_TempPath, String.Format(\"{0}_{1}_pyramid\", asic, sType) );\n\n                try\n                {\n                    RGAResult result = new RGAResult(asic, path);\n                    results.AddCompileResult(result);\n                }\n                catch (Exception ex)\n                {\n                    // may occur on compile error\n                }\n            }\n\n\n            if (results.ResultCount > 0)\n            {\n                results.DisplayAsic(defaultAsic);\n                return results;\n            }\n            else\n                return null;\n            \n        }\n    }\n\n\n}\n\n"
  },
  {
    "path": "src/GLSLOptimizer.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\n\nnamespace Pyramid\n{\n    namespace GLSLOptimizer\n    {        \n        public enum Target\n        {\n            OPENGL      = 0,\n            OPENGL_ES2  = 1,\n            OPENGL_ES3  = 2\n        };\n\n        public enum ShaderType\n        {\n            VERTEX   = 0,\n            FRAGMENT = 1,\n        };\n\n        public interface IOptions\n        {\n            ShaderType ShaderType { get; }\n            uint MaxUnrollIterations { get; }\n        }\n\n   \n        public interface IShader\n        {\n            bool HadError { get; }\n            string Output { get; }\n            string RawOutput { get; }\n            string Log { get; }\n            IEnumerable<string> Inputs { get;}\n            int MathOps { get; }\n            int TextureOps { get; }\n            int ControlFlowOps { get; }\n        };\n\n        public interface IOptimizer\n        {\n            IShader Optimize(string text, IOptions opts);\n        };\n\n    }\n}"
  },
  {
    "path": "src/GLSLTypes.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Pyramid\n{\n    public enum GLSLShaderType\n    {\n        VERTEX = 0,\n        FRAGMENT = 1,\n        TESS_CONTROL = 2,\n        TESS_EVALUATION = 3,\n        GEOMETRY = 4,\n        COMPUTE = 5,\n    }\n\n    public interface IGLSLOptions : ICompileOptions\n    {\n        GLSLShaderType ShaderType { get; }\n        GLSLOptimizer.Target OptimizerTarget { get; }\n        GLSLOptimizer.IOptions OptimizerOptions { get; }\n    }\n\n    public class GLSLShader : IShader\n    {\n        public GLSLShader(string code, IGLSLOptions opts, string path )\n        {\n            CompileOptions = opts;\n            Code = code;\n            SourceFilePath = path;\n        }\n\n        public Languages Language { get { return Languages.GLSL; } }\n        public IGLSLOptions CompileOptions { get; private set; }\n        public string Code { get; private set; }\n        public string SourceFilePath { get; private set; }\n    };\n}\n"
  },
  {
    "path": "src/GLSlang.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\n\n\nnamespace Pyramid\n{\n    namespace GLSlang\n    {\n        public interface IShader\n        {\n            GLSLShaderType ShaderType { get; }\n            bool HasErrors { get; }\n            string InfoLog { get; }\n            string InfoDebugLog { get; }\n            SPIRV.IProgram CompileSPIRV();\n        }\n\n        public interface IConfig\n        {\n        }\n\n        public interface ICompiler\n        {\n            IConfig CreateConfig(string text);\n            IConfig CreateDefaultConfig();\n            IShader Compile(string text, GLSLShaderType eType, IConfig config, string filePath);\n            IShader CompileHLSL(string text, IHLSLOptions opts, IConfig config, string filePath );\n        }\n    }\n}\n"
  },
  {
    "path": "src/HLSLTypes.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace Pyramid\n{\n    public enum HLSLTarget\n    {\n        vs_3_0,\n        vs_4_0,\n        vs_4_1,\n        vs_5_0,\n        vs_5_1,\n        vs_6_0,\n        vs_6_1,\n        vs_6_2,\n\n        ps_3_0,\n        ps_4_0,\n        ps_4_1,\n        ps_5_0,\n        ps_5_1,\n        ps_6_0,\n        ps_6_1,\n        ps_6_2,\n\n        gs_4_0,\n        gs_4_1,\n        gs_5_0,\n        gs_5_1,\n        gs_6_0,\n        gs_6_1,\n        gs_6_2,\n\n        hs_5_0,\n        hs_5_1,\n        hs_6_0,\n        hs_6_1,\n        hs_6_2,\n\n        ds_5_0,\n        ds_5_1,\n        ds_6_0,\n        ds_6_1,\n        ds_6_2,\n\n        cs_4_0,\n        cs_4_1,\n        cs_5_0,\n        cs_5_1,\n        cs_6_0,\n        cs_6_1,\n        cs_6_2,\n    };\n\n    public enum RootSignatureTarget\n    {\n        rootsig_1_0,\n        rootsig_1_1,\n    }\n\n    public enum HLSLOptimizationLevel\n    {\n        SKIP,\n        LEVEL0,\n        LEVEL1,\n        LEVEL2,\n        LEVEL3\n    };\n\n    public enum HLSLShaderType\n    {\n        VERTEX,\n        PIXEL,\n        GEOMETRY,\n        DOMAIN,\n        HULL,\n        COMPUTE\n    };\n\n    public interface IHLSLOptions : ICompileOptions\n    {\n        string EntryPoint { get; }\n        HLSLTarget Target { get; }\n        RootSignatureTarget RootSigTarget { get; }\n        HLSLShaderType ShaderType { get; }\n        HLSLOptimizationLevel OptimizationLevel { get; }\n        bool Compatibility { get; }\n        string RootSigMacro { get; }\n\n        string GetFXCCommandLine(string shaderFile);\n        uint GetD3DCompileFlagBits();\n    }\n\n    public interface IDXShaderReflection\n    {\n        HLSLShaderType GetShaderType();\n        uint GetThreadsPerGroup();\n    };\n\n    public interface IDXBlob\n    {\n        byte[] ReadBytes();\n    }\n\n    public interface IDXShaderBlob : IDXBlob\n    {\n        string Disassemble();\n        IDXBlob ExtractRootSignature();\n    }\n\n    public interface IDXILShaderBlob : IDXShaderBlob\n    {\n    }\n\n    public interface IDXBCShaderBlob : IDXShaderBlob\n    {\n        IDXBCShaderBlob GetSignatureBlob();\n        IDXBCShaderBlob GetExecutableBlob();\n        IDXBCShaderBlob Strip();\n        IDXShaderReflection Reflect();\n    }\n\n\n    public class HLSLShader : IShader\n    {\n        public HLSLShader(string code, IHLSLOptions opts ,string path)\n        {\n            CompileOptions = opts;\n            Code = code;\n            WasCompiled = false;\n            RootSigWasCompiled = false;\n            RootSigHasError = false;\n            SourceFilePath = path;\n        }\n\n        public Languages Language { get { return Languages.HLSL; } }\n        public IHLSLOptions CompileOptions { get; private set; }\n        public string Code { get; private set; }\n        public IDXShaderBlob CompiledBlob { get; private set; }\n        public string Messages { get; private set; }\n        public string SourceFilePath { get; private set; }\n\n\n        public bool CompileRootSignature( IDXILCompiler compiler )\n        {\n            if( compiler != null )\n            {\n                IDXBlob blob;\n                string msg;\n                RootSigHasError = !compiler.CompileRootSignature(this.Code, this.CompileOptions, this.SourceFilePath, out blob, out msg);\n                RootSigMessages = msg;\n                CompiledRootSig = blob;\n                RootSigWasCompiled = true;\n                return !RootSigHasError;\n            }\n            else\n            {\n                return false;\n            }\n        }\n        \n        public bool Compile( ID3DCompiler compiler, IDXILCompiler dxil )\n        {\n            if( CompileOptions.Target.ToString()[3] == '6' )\n            {\n                if (dxil == null)\n                    return false;\n\n                IDXILShaderBlob blob;\n                string msg;\n                HasError = !dxil.Compile(this.Code, this.CompileOptions, this.SourceFilePath, out blob, out msg);\n                WasCompiled = true;\n                Messages = msg;\n                CompiledBlob = blob;\n            }\n            else\n            {\n                if( compiler == null )\n                    return false;\n\n                IDXBCShaderBlob blob;\n                string msg;\n                HasError = !compiler.Compile(this.Code, this.CompileOptions, this.SourceFilePath, out blob, out msg);\n                WasCompiled = true;\n                Messages = msg;\n                CompiledBlob = blob;\n            }\n\n            // check for embedded root signature and pull it out if there is one\n            if( CompiledBlob != null )\n            {\n                IDXBlob rs = CompiledBlob.ExtractRootSignature();\n                if (rs != null)\n                {\n                    RootSigWasCompiled = true;\n                    RootSigHasError = false;\n                    CompiledRootSig = rs;\n                }\n            }\n\n            return !HasError;\n\n        }\n\n        public IDXBlob CompiledRootSig { get; private set; }\n        public bool RootSigWasCompiled { get; private set; }\n        public bool RootSigHasError { get; private set; }\n        public string RootSigMessages { get; private set; }\n\n        public bool WasCompiled { get; private set; }\n        public bool HasError { get; private set; }\n        public bool WasCompiledWithErrors { get { return WasCompiled && HasError; } }\n    };\n\n    public interface ID3DCompiler\n    {\n        bool CompileRootSignature(string text,\n                                 IHLSLOptions opts,\n                                 string fileName,\n                                 out IDXBlob blob,\n                                 out string Messages);\n\n        bool Compile(string text,\n                     IHLSLOptions opts,\n                     string fileName,\n                     out IDXBCShaderBlob blob,\n                     out string Messages);\n    };\n\n    public interface IDXILCompiler \n    {\n        bool CompileRootSignature(string text,\n                             IHLSLOptions opts,\n                             string fileName,\n                             out IDXBlob blob,\n                             out string Messages);\n\n        bool Compile(string text,\n                     IHLSLOptions opts,\n                     string fileName,\n                     out IDXILShaderBlob blob,\n                     out string Messages);\n    };\n\n}\n"
  },
  {
    "path": "src/IAMDDriver.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Pyramid\n{\n    public interface IAMDAsic\n    {\n        string Name { get; }\n    };\n\n\n    public interface IAMDShader \n    {\n        IAMDAsic Asic { get; }\n        byte[] ReadISABytes();\n        string Disassemble();\n        string ListEncodings();\n        string PrintStats( );\n        Scrutinizer.IScrutinizer CreateScrutinizer( );\n    };\n\n    public interface IAMDDriver\n    {\n        IEnumerable<IAMDAsic> Asics { get; }\n\n        /// <summary>\n        ///  Compile a DX shader blob and return the \n        /// </summary>\n        /// <param name=\"blob\"></param>\n        /// <returns></returns>\n        IAMDShader CompileDXBlob(IAMDAsic asic, byte[] blob, IDXShaderReflection reflect );\n    }\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Configuration/AssemblyInfo.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 1618 $</version>\n// </file>\n\nusing System;\nusing System.Reflection;\nusing System.Runtime.CompilerServices;\n\n[assembly: CLSCompliant(true)]\n[assembly: StringFreezing()]\n\n[assembly: AssemblyTitle(\"ICSharpCode.TextEditor\")]\n[assembly: AssemblyDescription(\"A .NET text editor control\")]\n[assembly: AssemblyConfiguration(\"\")]\n[assembly: AssemblyTrademark(\"\")]\n[assembly: AssemblyCulture(\"\")]\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/GlobalAssemblyInfo.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Daniel Grunwald\" email=\"daniel@danielgrunwald.de\"/>\n//     <version>$Revision: 1040 $</version>\n// </file>\n\n/////////////////////////////////////////////////////////////////////////////////////////////\n/////////////////////////////////////////////////////////////////////////////////////////////\n//                                                                                         //\n// DO NOT EDIT GlobalAssemblyInfo.cs, it is recreated using AssemblyInfo.template whenever //\n// StartUp is compiled.                                                                    //\n//                                                                                         //\n/////////////////////////////////////////////////////////////////////////////////////////////\n/////////////////////////////////////////////////////////////////////////////////////////////\n\nusing System.Reflection;\n\n[assembly: System.Runtime.InteropServices.ComVisible(false)]\n[assembly: AssemblyCompany(\"ic#code\")]\n[assembly: AssemblyProduct(\"SharpDevelop\")]\n[assembly: AssemblyCopyright(\"2000-2008 AlphaSierraPapa\")]\n[assembly: AssemblyVersion(RevisionClass.FullVersion)]\n\ninternal static class RevisionClass\n{\n\tpublic const string Major = \"3\";\n\tpublic const string Minor = \"0\";\n\tpublic const string Build = \"0\";\n\tpublic const string Revision = \"3437\";\n\t\n\tpublic const string MainVersion = Major + \".\" + Minor;\n\tpublic const string FullVersion = Major + \".\" + Minor + \".\" + Build + \".\" + Revision;\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/ICSharpCode.TextEditor.csproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\" ToolsVersion=\"12.0\">\n  <PropertyGroup>\n    <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>\n    <Platform Condition=\" '$(Platform)' == '' \">AnyCPU</Platform>\n    <ProductVersion>9.0.21022</ProductVersion>\n    <SchemaVersion>2.0</SchemaVersion>\n    <ProjectGuid>{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}</ProjectGuid>\n    <AssemblyName>ICSharpCode.TextEditor</AssemblyName>\n    <OutputTarget>Library</OutputTarget>\n    <WarningLevel>4</WarningLevel>\n    <NoStdLib>False</NoStdLib>\n    <NoConfig>False</NoConfig>\n    <RunPostBuildEvent>OnSuccessfulBuild</RunPostBuildEvent>\n    <OutputType>Library</OutputType>\n    <SignAssembly>true</SignAssembly>\n    <AssemblyOriginatorKeyFile>Resources\\ICSharpCode.TextEditor.snk</AssemblyOriginatorKeyFile>\n    <RootNamespace>ICSharpCode.TextEditor</RootNamespace>\n    <RegisterForComInterop>False</RegisterForComInterop>\n    <GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>\n    <BaseAddress>98041856</BaseAddress>\n    <PlatformTarget>AnyCPU</PlatformTarget>\n    <FileAlignment>4096</FileAlignment>\n    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>\n    <FileUpgradeFlags>\n    </FileUpgradeFlags>\n    <UpgradeBackupLocation>\n    </UpgradeBackupLocation>\n    <OldToolsVersion>3.5</OldToolsVersion>\n  </PropertyGroup>\n  <PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' \">\n    <Optimize>False</Optimize>\n    <AllowUnsafeBlocks>False</AllowUnsafeBlocks>\n    <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>\n    <OutputPath>bin\\Debug\\</OutputPath>\n    <DefineConstants>TRACE;DEBUG</DefineConstants>\n    <TreatWarningsAsErrors>false</TreatWarningsAsErrors>\n    <CodeAnalysisRules>-Microsoft.Design#CA1012;-Microsoft.Design#CA2210;-Microsoft.Design#CA1040;-Microsoft.Design#CA1005;-Microsoft.Design#CA1020;-Microsoft.Design#CA1021;-Microsoft.Design#CA1010;-Microsoft.Design#CA1011;-Microsoft.Design#CA1009;-Microsoft.Design#CA1050;-Microsoft.Design#CA1026;-Microsoft.Design#CA1019;-Microsoft.Design#CA1031;-Microsoft.Design#CA1047;-Microsoft.Design#CA1000;-Microsoft.Design#CA1048;-Microsoft.Design#CA1051;-Microsoft.Design#CA1002;-Microsoft.Design#CA1061;-Microsoft.Design#CA1006;-Microsoft.Design#CA1046;-Microsoft.Design#CA1045;-Microsoft.Design#CA1038;-Microsoft.Design#CA1008;-Microsoft.Design#CA1028;-Microsoft.Design#CA1004;-Microsoft.Design#CA1035;-Microsoft.Design#CA1063;-Microsoft.Design#CA1032;-Microsoft.Design#CA1023;-Microsoft.Design#CA1033;-Microsoft.Design#CA1039;-Microsoft.Design#CA1016;-Microsoft.Design#CA1014;-Microsoft.Design#CA1017;-Microsoft.Design#CA1018;-Microsoft.Design#CA1027;-Microsoft.Design#CA1059;-Microsoft.Design#CA1060;-Microsoft.Design#CA1034;-Microsoft.Design#CA1013;-Microsoft.Design#CA1036;-Microsoft.Design#CA1044;-Microsoft.Design#CA1041;-Microsoft.Design#CA1025;-Microsoft.Design#CA1052;-Microsoft.Design#CA1053;-Microsoft.Design#CA1057;-Microsoft.Design#CA1058;-Microsoft.Design#CA1001;-Microsoft.Design#CA1049;-Microsoft.Design#CA1054;-Microsoft.Design#CA1056;-Microsoft.Design#CA1055;-Microsoft.Design#CA1030;-Microsoft.Design#CA1003;-Microsoft.Design#CA1007;-Microsoft.Design#CA1043;-Microsoft.Design#CA1024;-Microsoft.Design#CA1062;-Microsoft.Globalization#CA1301;-Microsoft.Globalization#CA1302;-Microsoft.Globalization#CA1303;-Microsoft.Globalization#CA1306;-Microsoft.Globalization#CA1304;-Microsoft.Globalization#CA1305;-Microsoft.Globalization#CA1300;-Microsoft.Mobility#CA1600;-Microsoft.Mobility#CA1601;-Microsoft.Naming#CA1718;-Microsoft.Naming#CA1720;-Microsoft.Naming#CA1700;-Microsoft.Naming#CA1712;-Microsoft.Naming#CA1713;-Microsoft.Naming#CA1709;-Microsoft.Naming#CA1708;-Microsoft.Naming#CA1715;-Microsoft.Naming#CA1710;-Microsoft.Naming#CA1707;-Microsoft.Naming#CA1722;-Microsoft.Naming#CA1711;-Microsoft.Naming#CA1716;-Microsoft.Naming#CA1705;-Microsoft.Naming#CA1725;-Microsoft.Naming#CA1719;-Microsoft.Naming#CA1721;-Microsoft.Naming#CA1706;-Microsoft.Naming#CA1724;-Microsoft.Naming#CA1726;-Microsoft.Performance#CA1809;-Microsoft.Performance#CA1811;-Microsoft.Performance#CA1812;-Microsoft.Performance#CA1807;-Microsoft.Performance#CA1813;-Microsoft.Performance#CA1823;-Microsoft.Performance#CA1816;-Microsoft.Performance#CA1817;-Microsoft.Performance#CA1800;-Microsoft.Performance#CA1818;-Microsoft.Performance#CA1805;-Microsoft.Performance#CA1810;-Microsoft.Performance#CA1822;-Microsoft.Performance#CA1815;-Microsoft.Performance#CA1814;-Microsoft.Performance#CA1819;-Microsoft.Performance#CA1804;-Microsoft.Performance#CA1820;-Microsoft.Performance#CA1802;-Microsoft.Security#CA2116;-Microsoft.Security#CA2117;-Microsoft.Security#CA2105;-Microsoft.Security#CA2115;-Microsoft.Security#CA2104;-Microsoft.Security#CA2122;-Microsoft.Security#CA2114;-Microsoft.Security#CA2123;-Microsoft.Security#CA2111;-Microsoft.Security#CA2108;-Microsoft.Security#CA2107;-Microsoft.Security#CA2103;-Microsoft.Security#CA2100;-Microsoft.Security#CA2118;-Microsoft.Security#CA2109;-Microsoft.Security#CA2119;-Microsoft.Security#CA2106;-Microsoft.Security#CA2112;-Microsoft.Security#CA2110;-Microsoft.Security#CA2120;-Microsoft.Security#CA2101;-Microsoft.Security#CA2121;-Microsoft.Security#CA2126;-Microsoft.Security#CA2124;-Microsoft.Usage#CA2209;-Microsoft.Usage#CA2236;-Microsoft.Usage#CA2227;-Microsoft.Usage#CA2213;-Microsoft.Usage#CA2216;-Microsoft.Usage#CA2215;-Microsoft.Usage#CA2214;-Microsoft.Usage#CA2222;-Microsoft.Usage#CA2202;-Microsoft.Usage#CA1806;-Microsoft.Usage#CA2217;-Microsoft.Usage#CA2212;-Microsoft.Usage#CA2219;-Microsoft.Usage#CA2201;-Microsoft.Usage#CA2228;-Microsoft.Usage#CA2221;-Microsoft.Usage#CA2220;-Microsoft.Usage#CA2240;-Microsoft.Usage#CA2229;-Microsoft.Usage#CA2238;-Microsoft.Usage#CA2207;-Microsoft.Usage#CA2208;-Microsoft.Usage#CA2235;-Microsoft.Usage#CA2237;-Microsoft.Usage#CA2232;-Microsoft.Usage#CA2223;-Microsoft.Usage#CA2211;-Microsoft.Usage#CA2233;-Microsoft.Usage#CA2225;-Microsoft.Usage#CA2226;-Microsoft.Usage#CA2231;-Microsoft.Usage#CA2224;-Microsoft.Usage#CA2218;-Microsoft.Usage#CA2234;-Microsoft.Usage#CA2241;-Microsoft.Usage#CA2239;-Microsoft.Usage#CA2200;-Microsoft.Usage#CA1801;-Microsoft.Usage#CA2205;-Microsoft.Usage#CA2230</CodeAnalysisRules>\n    <WarningLevel>2</WarningLevel>\n  </PropertyGroup>\n  <PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' \">\n    <Optimize>true</Optimize>\n    <AllowUnsafeBlocks>False</AllowUnsafeBlocks>\n    <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>\n    <OutputPath>bin\\Release\\</OutputPath>\n    <TreatWarningsAsErrors>False</TreatWarningsAsErrors>\n    <DefineConstants>TRACE</DefineConstants>\n  </PropertyGroup>\n  <PropertyGroup Condition=\" '$(Configuration)' == 'Debug' \">\n    <DebugType>Full</DebugType>\n    <DebugSymbols>true</DebugSymbols>\n  </PropertyGroup>\n  <PropertyGroup Condition=\" '$(Configuration)' == 'Release' \">\n    <DebugType>None</DebugType>\n    <DebugSymbols>False</DebugSymbols>\n  </PropertyGroup>\n  <ItemGroup>\n    <Reference Include=\"System\" />\n    <Reference Include=\"System.Drawing\" />\n    <Reference Include=\"System.Windows.Forms\" />\n    <Reference Include=\"System.Xml\" />\n  </ItemGroup>\n  <ItemGroup>\n    <Compile Include=\"GlobalAssemblyInfo.cs\" />\n    <Compile Include=\"Src\\Actions\\FindReplaceAction.cs\" />\n    <Compile Include=\"Src\\Document\\DefaultDocument.cs\" />\n    <Compile Include=\"Src\\Document\\DocumentEventArgs.cs\" />\n    <Compile Include=\"Src\\Document\\DocumentFactory.cs\" />\n    <Compile Include=\"Src\\Document\\HighlightingStrategy\\HighlightingDefinitionInvalidException.cs\" />\n    <Compile Include=\"Src\\Document\\IDocument.cs\" />\n    <Compile Include=\"Src\\Document\\ISegment.cs\" />\n    <Compile Include=\"Src\\Document\\LineManager\\DeferredEventList.cs\" />\n    <Compile Include=\"Src\\Document\\LineManager\\LineSegmentTree.cs\" />\n    <Compile Include=\"Src\\Document\\TextAnchor.cs\" />\n    <Compile Include=\"Src\\Document\\TextLocation.cs\" />\n    <Compile Include=\"Src\\Document\\TextUtilities.cs\" />\n    <Compile Include=\"Src\\Document\\BookmarkManager\\BookmarkManager.cs\" />\n    <Compile Include=\"Src\\Document\\BookmarkManager\\BookmarkManagerMemento.cs\" />\n    <Compile Include=\"Src\\Document\\FormattingStrategy\\DefaultFormattingStrategy.cs\" />\n    <Compile Include=\"Src\\Document\\FormattingStrategy\\IFormattingStrategy.cs\" />\n    <Compile Include=\"Src\\Document\\HighlightingStrategy\\DefaultHighlightingStrategy.cs\" />\n    <Compile Include=\"Src\\Document\\HighlightingStrategy\\FontContainer.cs\" />\n    <Compile Include=\"Src\\Document\\HighlightingStrategy\\HighlightBackground.cs\" />\n    <Compile Include=\"Src\\Document\\HighlightingStrategy\\HighlightColor.cs\" />\n    <Compile Include=\"Src\\Document\\HighlightingStrategy\\HighlightInfo.cs\" />\n    <Compile Include=\"Src\\Document\\HighlightingStrategy\\HighlightingColorNotFoundException.cs\" />\n    <Compile Include=\"Src\\Document\\HighlightingStrategy\\HighlightingDefinitionParser.cs\" />\n    <Compile Include=\"Src\\Document\\HighlightingStrategy\\HighlightingManager.cs\" />\n    <Compile Include=\"Src\\Document\\HighlightingStrategy\\HighlightingStrategyFactory.cs\" />\n    <Compile Include=\"Src\\Document\\HighlightingStrategy\\HighlightRuleSet.cs\" />\n    <Compile Include=\"Src\\Document\\HighlightingStrategy\\IHighlightingStrategy.cs\" />\n    <Compile Include=\"Src\\Document\\HighlightingStrategy\\NextMarker.cs\" />\n    <Compile Include=\"Src\\Document\\HighlightingStrategy\\PrevMarker.cs\" />\n    <Compile Include=\"Src\\Document\\HighlightingStrategy\\Span.cs\" />\n    <Compile Include=\"Src\\Document\\HighlightingStrategy\\TextWord.cs\" />\n    <Compile Include=\"Src\\Document\\LineManager\\LineManager.cs\" />\n    <Compile Include=\"Src\\Document\\LineManager\\LineSegment.cs\" />\n    <Compile Include=\"Src\\Document\\LineManager\\LineManagerEventArgs.cs\" />\n    <Compile Include=\"Src\\Document\\TextBufferStrategy\\GapTextBufferStrategy.cs\" />\n    <Compile Include=\"Src\\Document\\TextBufferStrategy\\ITextBufferStrategy.cs\" />\n    <Compile Include=\"Src\\Document\\TextBufferStrategy\\StringTextBufferStrategy.cs\" />\n    <Compile Include=\"Src\\Gui\\FindReplaceForm\\FindAndReplaceForm.cs\">\n      <SubType>Form</SubType>\n    </Compile>\n    <Compile Include=\"Src\\Gui\\FindReplaceForm\\FindAndReplaceForm.Designer.cs\">\n      <DependentUpon>FindAndReplaceForm.cs</DependentUpon>\n    </Compile>\n    <Compile Include=\"Src\\Util\\AugmentableRedBlackTree.cs\" />\n    <Compile Include=\"Src\\Util\\CheckedList.cs\" />\n    <Compile Include=\"Src\\Util\\LoggingService.cs\" />\n    <Compile Include=\"Src\\Util\\LookupTable.cs\" />\n    <Compile Include=\"Src\\Util\\MouseWheelHandler.cs\" />\n    <Compile Include=\"Src\\Util\\RedBlackTreeIterator.cs\" />\n    <Compile Include=\"Src\\Util\\TextUtility.cs\" />\n    <Compile Include=\"Src\\Undo\\UndoableDelete.cs\" />\n    <Compile Include=\"Src\\Undo\\UndoableInsert.cs\" />\n    <Compile Include=\"Src\\Undo\\UndoableReplace.cs\" />\n    <Compile Include=\"Src\\Actions\\ClipBoardActions.cs\" />\n    <Compile Include=\"Src\\Actions\\CaretActions.cs\" />\n    <Compile Include=\"Src\\Actions\\HomeEndActions.cs\" />\n    <Compile Include=\"Src\\Actions\\IEditAction.cs\" />\n    <Compile Include=\"Src\\Actions\\MiscActions.cs\" />\n    <Compile Include=\"Src\\Actions\\SelectionActions.cs\" />\n    <Compile Include=\"Src\\Document\\Selection\\ISelection.cs\" />\n    <Compile Include=\"Src\\Document\\Selection\\DefaultSelection.cs\" />\n    <Compile Include=\"Src\\Document\\FoldingStrategy\\IFoldingStrategy.cs\" />\n    <Compile Include=\"Src\\Document\\FoldingStrategy\\IndentFoldingStrategy.cs\" />\n    <Compile Include=\"Src\\Gui\\Ime.cs\" />\n    <Compile Include=\"Src\\Gui\\TextAreaUpdate.cs\" />\n    <Compile Include=\"Src\\Document\\Selection\\SelectionManager.cs\" />\n    <Compile Include=\"Src\\Gui\\CompletionWindow\\ICompletionData.cs\" />\n    <Compile Include=\"Src\\Gui\\CompletionWindow\\ICompletionDataProvider.cs\" />\n    <Compile Include=\"Src\\Gui\\CompletionWindow\\CodeCompletionWindow.cs\">\n      <SubType>Form</SubType>\n    </Compile>\n    <Compile Include=\"Src\\Gui\\CompletionWindow\\DeclarationViewWindow.cs\">\n      <SubType>Form</SubType>\n    </Compile>\n    <Compile Include=\"Src\\Gui\\InsightWindow\\IInsightDataProvider.cs\" />\n    <Compile Include=\"Src\\Gui\\InsightWindow\\InsightWindow.cs\">\n      <SubType>Form</SubType>\n    </Compile>\n    <Compile Include=\"Src\\Util\\RtfWriter.cs\" />\n    <Compile Include=\"Src\\Document\\FoldingStrategy\\FoldingManager.cs\" />\n    <Compile Include=\"Src\\Document\\AbstractSegment.cs\" />\n    <Compile Include=\"Src\\Document\\FoldingStrategy\\FoldMarker.cs\" />\n    <Compile Include=\"Src\\Util\\TipPainter.cs\" />\n    <Compile Include=\"Src\\Util\\TipSection.cs\" />\n    <Compile Include=\"Src\\Util\\TipText.cs\" />\n    <Compile Include=\"Src\\Util\\TipSplitter.cs\" />\n    <Compile Include=\"Src\\Util\\TipSpacer.cs\" />\n    <Compile Include=\"Src\\Util\\TipPainterTools.cs\" />\n    <Compile Include=\"Src\\Document\\ITextEditorProperties.cs\" />\n    <Compile Include=\"Src\\Gui\\Caret.cs\" />\n    <Compile Include=\"Src\\Gui\\TextArea.cs\">\n      <SubType>Component</SubType>\n    </Compile>\n    <Compile Include=\"Src\\Gui\\TextEditorControl.cs\">\n      <SubType>UserControl</SubType>\n    </Compile>\n    <Compile Include=\"Src\\Gui\\TextEditorControlBase.cs\">\n      <SubType>UserControl</SubType>\n    </Compile>\n    <Compile Include=\"Src\\Gui\\TextAreaClipboardHandler.cs\" />\n    <Compile Include=\"Src\\Gui\\TextView.cs\" />\n    <Compile Include=\"Src\\Gui\\GutterMargin.cs\" />\n    <Compile Include=\"Src\\Gui\\AbstractMargin.cs\" />\n    <Compile Include=\"Src\\Undo\\IUndoableOperation.cs\" />\n    <Compile Include=\"Src\\Undo\\UndoQueue.cs\" />\n    <Compile Include=\"Src\\Undo\\UndoStack.cs\" />\n    <Compile Include=\"Src\\Gui\\TextAreaControl.cs\">\n      <SubType>Component</SubType>\n    </Compile>\n    <Compile Include=\"Src\\Gui\\TextAreaMouseHandler.cs\" />\n    <Compile Include=\"Src\\Document\\HighlightingStrategy\\SyntaxModes\\ISyntaxModeFileProvider.cs\" />\n    <Compile Include=\"Src\\Document\\HighlightingStrategy\\SyntaxModes\\SyntaxMode.cs\" />\n    <Compile Include=\"Src\\Document\\HighlightingStrategy\\SyntaxModes\\ResourceSyntaxModeProvider.cs\" />\n    <Compile Include=\"Src\\Gui\\IconBarMargin.cs\" />\n    <Compile Include=\"Src\\Gui\\FoldMargin.cs\" />\n    <Compile Include=\"Src\\Document\\HighlightingStrategy\\SyntaxModes\\FileSyntaxModeProvider.cs\" />\n    <Compile Include=\"Src\\Document\\Selection\\ColumnRange.cs\" />\n    <Compile Include=\"Src\\Gui\\TextAreaDragDropHandler.cs\" />\n    <Compile Include=\"Src\\Gui\\BracketHighlighter.cs\" />\n    <Compile Include=\"Src\\Actions\\BookmarkActions.cs\" />\n    <Compile Include=\"Src\\Actions\\FoldActions.cs\" />\n    <Compile Include=\"Src\\Actions\\FormatActions.cs\" />\n    <Compile Include=\"Src\\Document\\DefaultTextEditorProperties.cs\" />\n    <Compile Include=\"Src\\Document\\MarkerStrategy\\MarkerStrategy.cs\" />\n    <Compile Include=\"Src\\Document\\MarkerStrategy\\TextMarker.cs\" />\n    <Compile Include=\"Src\\Gui\\CompletionWindow\\AbstractCompletionWindow.cs\">\n      <SubType>Form</SubType>\n    </Compile>\n    <Compile Include=\"Src\\Gui\\CompletionWindow\\CodeCompletionListView.cs\">\n      <SubType>UserControl</SubType>\n    </Compile>\n    <Compile Include=\"Src\\Gui\\BrushRegistry.cs\" />\n    <Compile Include=\"Src\\Gui\\HRuler.cs\">\n      <SubType>Component</SubType>\n    </Compile>\n    <Compile Include=\"Src\\Document\\BookmarkManager\\Bookmark.cs\" />\n    <Compile Include=\"Src\\Document\\BookmarkManager\\BookmarkEventHandler.cs\" />\n    <Compile Include=\"Configuration\\AssemblyInfo.cs\" />\n    <EmbeddedResource Include=\"Resources\\CPP-Mode.xshd\" />\n    <EmbeddedResource Include=\"Resources\\GLSL-Mode.xshd\">\n      <SubType>Designer</SubType>\n    </EmbeddedResource>\n    <EmbeddedResource Include=\"Resources\\HLSL-Mode.xshd\" />\n    <EmbeddedResource Include=\"Src\\Gui\\FindReplaceForm\\FindAndReplaceForm.resx\">\n      <DependentUpon>FindAndReplaceForm.cs</DependentUpon>\n    </EmbeddedResource>\n    <None Include=\"Resources\\ICSharpCode.TextEditor.snk\" />\n    <EmbeddedResource Include=\"Resources\\TextEditorControl.bmp\" />\n    <EmbeddedResource Include=\"Resources\\Mode.xsd\">\n      <SubType>\n      </SubType>\n    </EmbeddedResource>\n    <EmbeddedResource Include=\"Resources\\RightArrow.cur\" />\n    <EmbeddedResource Include=\"Resources\\SyntaxModes.xml\" />\n    <Compile Include=\"Src\\Util\\FileReader.cs\" />\n    <Compile Include=\"Src\\Gui\\DrawableLine.cs\" />\n    <Compile Include=\"Src\\Gui\\ToolTipRequestEventArgs.cs\" />\n    <Compile Include=\"Src\\Document\\HighlightingStrategy\\SpanStack.cs\" />\n    <Compile Include=\"Src\\Util\\WeakCollection.cs\" />\n  </ItemGroup>\n  <Import Project=\"$(MSBuildBinPath)\\Microsoft.CSharp.targets\" />\n  <PropertyGroup>\n    <PreBuildEvent>rem ..\\src\\Tools\\UpdateAssemblyInfo\\bin\\Debug\\UpdateAssemblyInfo.exe</PreBuildEvent>\n  </PropertyGroup>\n  <PropertyGroup>\n    <PostBuildEvent>copy $(TargetPath) $(SolutionDir)\\..\\bin</PostBuildEvent>\n  </PropertyGroup>\n</Project>"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Resources/CPP-Mode.xshd",
    "content": "<?xml version=\"1.0\"?>\n<!-- syntaxdefinition for C/C++ 2001 by Andrea Paatz and Mike Krueger -->\n\n<SyntaxDefinition name = \"C++.NET\" extensions = \".c;.h;.cc;.C;.cpp;.hpp\">\n\t\n\t<Properties>\n\t\t<Property name=\"LineComment\" value=\"//\"/>\n\t</Properties>\n\t\n\t<Digits name = \"Digits\" bold = \"false\" italic = \"false\" color = \"DarkBlue\"/>\n\t\n\t<RuleSets>\n\t\t<RuleSet ignorecase = \"false\">\n\t\t\t<Delimiters>~!%^*()-+=|\\#/{}[]:;\"'&lt;&gt; , .?</Delimiters>\n\t\t\n\t\t\t<Span name = \"PreprocessorDirectives\" bold=\"false\" italic=\"false\" color=\"Green\" stopateol = \"true\">\n\t\t\t\t<Begin>#</Begin>\n\t\t\t</Span>\n\t\t\t\n\t\t\t<Span name = \"LineComment\" bold = \"false\" italic = \"false\" color = \"Green\" stopateol = \"true\">\n\t\t\t\t<Begin>//</Begin>\n\t\t\t</Span>\n\t\t\t\n\t\t\t<Span name = \"BlockComment\" bold = \"false\" italic = \"false\" color = \"Green\" stopateol = \"false\">\n\t\t\t\t<Begin>/*</Begin>\n\t\t\t\t<End>*/</End>\n\t\t\t</Span>\n\t\t\t\n\t\t\t<Span name = \"String\" bold = \"false\" italic = \"false\" color = \"Magenta\" stopateol = \"true\" escapecharacter=\"\\\">\n\t\t\t\t<Begin>\"</Begin>\n\t\t\t\t<End>\"</End>\n\t\t\t</Span>\n\t\t\t\n\t\t\t<Span name = \"Char\" bold = \"false\" italic = \"false\" color = \"Magenta\" stopateol = \"true\" escapecharacter=\"\\\">\n\t\t\t\t<Begin>&apos;</Begin>\n\t\t\t\t<End>&apos;</End>\n\t\t\t</Span>\n\t\t\t\n\t\t\t<MarkPrevious bold = \"true\" italic = \"false\" color = \"MidnightBlue\">(</MarkPrevious>\n\t\t\t\n\t\t\t<KeyWords name = \"Punctuation\" bold = \"false\" italic = \"false\" color = \"DarkGreen\">\n\t\t\t\t<Key word = \"?\" />\n\t\t\t\t<Key word = \",\" />\n\t\t\t\t<Key word = \".\" />\n\t\t\t\t<Key word = \";\" />\n\t\t\t\t<Key word = \"(\" />\n\t\t\t\t<Key word = \")\" />\n\t\t\t\t<Key word = \"[\" />\n\t\t\t\t<Key word = \"]\" />\n\t\t\t\t<Key word = \"{\" />\n\t\t\t\t<Key word = \"}\" />\n\t\t\t\t<Key word = \"+\" />\n\t\t\t\t<Key word = \"-\" />\n\t\t\t\t<Key word = \"/\" />\n\t\t\t\t<Key word = \"%\" />\n\t\t\t\t<Key word = \"*\" />\n\t\t\t\t<Key word = \"&lt;\" />\n\t\t\t\t<Key word = \"&gt;\" />\n\t\t\t\t<Key word = \"^\" />\n\t\t\t\t<Key word = \"=\" />\n\t\t\t\t<Key word = \"~\" />\n\t\t\t\t<Key word = \"!\" />\n\t\t\t\t<Key word = \"|\" />\n\t\t\t\t<Key word = \"&amp;\" />\n\t\t\t</KeyWords>\n\t\t\t\n\t\t\t<KeyWords name = \"ManagedKeyWords\" bold=\"true\" italic=\"false\" color=\"Black\">\n\t\t\t\t<Key word = \"__abstract\" />\n\t\t\t\t<Key word = \"__box\" />\n\t\t\t\t<Key word = \"__delegate\" />\n\t\t\t\t<Key word = \"__gc\" />\n\t\t\t\t<Key word = \"__identifier\" />\n\t\t\t\t<Key word = \"__nogc\" />\n\t\t\t\t<Key word = \"__pin\" />\n\t\t\t\t<Key word = \"__property\" />\n\t\t\t\t<Key word = \"__sealed\" />\n\t\t\t\t<Key word = \"__try_cast\" />\n\t\t\t\t<Key word = \"__typeof\" />\n\t\t\t\t<Key word = \"__value\" />\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<Key word = \"__event\" />\n\t\t\t\t<Key word = \"__hook\" />\n\t\t\t\t<Key word = \"__raise\" />\n\t\t\t\t<Key word = \"__unhook\" />\n\t\t\t\t\n\t\t\t\t<Key word = \"__interface\" />\n\t\t\t</KeyWords>\n\t\t\t\n\t\t\t<KeyWords name = \"AccessKeywords\" bold=\"true\" italic=\"false\" color=\"Black\">\n\t\t\t\t<Key word = \"this\" />\n\t\t\t</KeyWords>\n\t\t\t\n\t\t\t<KeyWords name = \"OperatorKeywords\" bold=\"true\" italic=\"false\" color=\"DarkCyan\">\n\t\t\t\t<Key word = \"and\" />\n\t\t\t\t<Key word = \"and_eq\" />\n\t\t\t\t\n\t\t\t\t<Key word = \"bitand\" />\n\t\t\t\t<Key word = \"bitor\" />\n\t\t\t\t\n\t\t\t\t<Key word = \"new\" />\n\t\t\t\t<Key word = \"not\" />\n\t\t\t\t<Key word = \"not_eq\" />\n\t\t\t\t<Key word = \"or\" />\n\t\t\t\t<Key word = \"or_eq\" />\n\t\t\t\t<Key word = \"xor\" />\n\t\t\t\t<Key word = \"xor_eq\" />\n\t\t\t</KeyWords>\n\t\t\t\n\t\t\t<KeyWords name = \"NameSpaces\" bold=\"true\" italic=\"false\" color=\"Green\">\n\t\t\t\t<Key word = \"using\" />\n\t\t\t\t<Key word = \"namespace\" />\n\t\t\t</KeyWords>\n\t\t\t\n\t\t\t<KeyWords name = \"Friends\" bold=\"false\" italic=\"false\" color=\"Brown\">\n\t\t\t\t<Key word = \"friend\" />\n\t\t\t</KeyWords>\n\t\t\t\n\t\t\t<KeyWords name = \"AccessModifiers\" bold=\"true\" italic=\"false\" color=\"Blue\">\n\t\t\t\t<Key word = \"private\" />\n\t\t\t\t<Key word = \"protected\" />\n\t\t\t\t<Key word = \"public\" />\n\t\t\t\n\t\t\t\t<Key word = \"const\" />\n\t\t\t\t<Key word = \"volatile\" />\n\t\t\t\t\n\t\t\t\t<Key word = \"static\" />\n\t\t\t</KeyWords>\n\t\t\t\n\t\t\t<KeyWords name = \"Types\" bold=\"false\" italic=\"false\" color=\"Red\">\n\t\t\t\t<Key word = \"bool\" />\n\t\t\t\t<Key word = \"char\" />\n\t\t\t\t<Key word = \"unsigned\" />\n\t\t\t\t<Key word = \"union\" />\n\t\t\t\t<Key word = \"virtual\" />\n\t\t\t\t<Key word = \"double\" />\n\t\t\t\t<Key word = \"float\" />\n\t\t\t\t<Key word = \"short\" />\n\t\t\t\t<Key word = \"signed\" />\n\t\t\t\t<Key word = \"void\" />\n\t\t\t\t<Key word = \"class\" />\n\t\t\t\t\n\t\t\t\t<Key word = \"enum\" />\n\t\t\t\t<Key word = \"struct\" />\n\t\t\t</KeyWords>\n\t\t\t\n\t\t\t<KeyWords name = \"Literals\" bold=\"true\" italic=\"false\" color=\"Black\">\n\t\t\t\t<Key word = \"false\" />\n\t\t\t\t<Key word = \"true\" />\n\t\t\t</KeyWords>\n\t\t\t\n\t\t\t<KeyWords name = \"IterationStatements\" bold=\"true\" italic=\"false\" color=\"Blue\">\n\t\t\t\t<Key word = \"do\" />\n\t\t\t\t<Key word = \"for\" />\n\t\t\t\t<Key word = \"while\" />\n\t\t\t</KeyWords>\n\t\t\t\n\t\t\t<KeyWords name = \"JumpStatements\" bold=\"false\" italic=\"false\" color=\"Navy\">\n\t\t\t\t<Key word = \"break\" />\n\t\t\t\t<Key word = \"continue\" />\n\t\t\t\t<Key word = \"goto\" />\n\t\t\t\t<Key word = \"return\" />\n\t\t\t</KeyWords>\n\t\t\t\n\t\t\t<KeyWords name = \"ExceptionHandlingStatements\" bold=\"true\" italic=\"false\" color=\"Teal\">\n\t\t\t\t<Key word = \"catch\" />\n\t\t\t\t<Key word = \"throw\" />\n\t\t\t\t<Key word = \"try\" />\n\t\t\t</KeyWords>\n\t\t\t\n\t\t\t<KeyWords name = \"SelectionStatements\" bold=\"true\" italic=\"false\" color=\"Blue\">\n\t\t\t\t<Key word = \"case\" />\n\t\t\t\t<Key word = \"else\" />\n\t\t\t\t<Key word = \"if\" />\n\t\t\t\t<Key word = \"switch\" />\n\t\t\t\t<Key word = \"default\" />\n\t\t\t</KeyWords>\n\t\t\t\n\t\t\t<KeyWords name = \"KEYWORD1\" bold=\"true\" italic=\"false\" color=\"Blue\">\n\t\t\t\t<Key word = \"asm\" />\n\t\t\t\t<Key word = \"auto\" />\n\t\t\t\t<Key word = \"compl\" />\n\t\t\t\t<Key word = \"mutable\" />\n\t\t\t\t<Key word = \"const_cast\" />\n\t\t\t\t<Key word = \"delete\" />\n\t\t\t\t<Key word = \"dynamic_cast\" />\n\t\t\t\t<Key word = \"explicit\" />\n\t\t\t\t<Key word = \"export\" />\n\t\t\t\t<Key word = \"extern\" />\n\t\t\t\t<Key word = \"inline\" />\n\t\t\t\t<Key word = \"int\" />\n\t\t\t\t<Key word = \"long\" />\n\t\t\t\t<Key word = \"operator\" />\n\t\t\t\t<Key word = \"register\" />\n\t\t\t\t<Key word = \"reinterpret_cast\" />\n\t\t\t\t<Key word = \"sizeof\" />\n\t\t\t\t<Key word = \"static_cast\" />\n\t\t\t\t<Key word = \"template\" />\n\t\t\t\t<Key word = \"typedef\" />\n\t\t\t\t<Key word = \"typeid\" />\n\t\t\t\t<Key word = \"typename\" />\n\t\t\t</KeyWords>\n\t\t</RuleSet>\n\t</RuleSets>\n</SyntaxDefinition>\n\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Resources/GLSL-Mode.xshd",
    "content": "<?xml version=\"1.0\"?>\n<!-- syntaxdefinition for GLSL by Josh Barczak -->\n\n<SyntaxDefinition name = \"GLSL\" extensions = \".glsl\">\n\t\n\t<Properties>\n\t\t<Property name=\"LineComment\" value=\"//\"/>\n\t</Properties>\n\t\n\t<Digits name = \"Digits\" bold = \"false\" italic = \"false\" color = \"DarkBlue\"/>\n\t\n\t<RuleSets>\n\t\t<RuleSet ignorecase = \"false\">\n\t\t\t<Delimiters>~!%^*()-+=|\\#/{}[]:;\"'&lt;&gt; , .?</Delimiters>\n\t\t\n\t\t\t<Span name = \"PreprocessorDirectives\" bold=\"false\" italic=\"false\" color=\"Green\" stopateol = \"true\">\n\t\t\t\t<Begin>#</Begin>\n\t\t\t</Span>\n\t\t\t\n\t\t\t<Span name = \"LineComment\" bold = \"false\" italic = \"false\" color = \"Green\" stopateol = \"true\">\n\t\t\t\t<Begin>//</Begin>\n\t\t\t</Span>\n\t\t\t\n\t\t\t<Span name = \"BlockComment\" bold = \"false\" italic = \"false\" color = \"Green\" stopateol = \"false\">\n\t\t\t\t<Begin>/*</Begin>\n\t\t\t\t<End>*/</End>\n\t\t\t</Span>\n\t\t\t\n\t\t\t<Span name = \"String\" bold = \"false\" italic = \"false\" color = \"Magenta\" stopateol = \"true\" escapecharacter=\"\\\">\n\t\t\t\t<Begin>\"</Begin>\n\t\t\t\t<End>\"</End>\n\t\t\t</Span>\n\t\t\t\n\t\t\t<Span name = \"Char\" bold = \"false\" italic = \"false\" color = \"Magenta\" stopateol = \"true\" escapecharacter=\"\\\">\n\t\t\t\t<Begin>&apos;</Begin>\n\t\t\t\t<End>&apos;</End>\n\t\t\t</Span>\n\t\t\t\n\t\t\t<MarkPrevious bold = \"true\" italic = \"false\" color = \"MidnightBlue\">(</MarkPrevious>\n\t\t\t\n\t\t\t<KeyWords name = \"Punctuation\" bold = \"false\" italic = \"false\" color = \"DarkGreen\">\n\t\t\t\t<Key word = \"?\" />\n\t\t\t\t<Key word = \",\" />\n\t\t\t\t<Key word = \".\" />\n\t\t\t\t<Key word = \";\" />\n\t\t\t\t<Key word = \"(\" />\n\t\t\t\t<Key word = \")\" />\n\t\t\t\t<Key word = \"[\" />\n\t\t\t\t<Key word = \"]\" />\n\t\t\t\t<Key word = \"{\" />\n\t\t\t\t<Key word = \"}\" />\n\t\t\t\t<Key word = \"+\" />\n\t\t\t\t<Key word = \"-\" />\n\t\t\t\t<Key word = \"/\" />\n\t\t\t\t<Key word = \"%\" />\n\t\t\t\t<Key word = \"*\" />\n\t\t\t\t<Key word = \"&lt;\" />\n\t\t\t\t<Key word = \"&gt;\" />\n\t\t\t\t<Key word = \"^\" />\n\t\t\t\t<Key word = \"=\" />\n\t\t\t\t<Key word = \"~\" />\n\t\t\t\t<Key word = \"!\" />\n\t\t\t\t<Key word = \"|\" />\n\t\t\t\t<Key word = \"&amp;\" />\n\t\t\t</KeyWords>\n\t\t\n\t\n\t\t\t\n\t\t\t<KeyWords name = \"Qualifiers\" bold=\"true\" italic=\"false\" color=\"Blue\">\n                <Key word = \"attribute\" />\n                <Key word = \"coherent\" />\n                <Key word = \"volatile\" />\n                <Key word = \"restrict\" />\n                <Key word = \"readonly\" />\n                <Key word = \"writeonly\" />\n                <Key word = \"layout\" />\n                <Key word = \"const\" />\n                <Key word = \"uniform\" />\n                <Key word = \"varying\" />               \n                <Key word = \"centroid\" />\n                <Key word = \"flat\" />\n                <Key word = \"smooth\" />\n                <Key word = \"noperspective\" />\n                <Key word = \"sample\" />\n                <Key word = \"patch\" />\n                <Key word = \"in\" />\n                <Key word = \"inout\" />\n                <Key word = \"out\" />\n                <Key word = \"precise\" />\n                <Key word = \"invariant\" />\n                <Key word = \"lowp\" />\n                <Key word = \"mediump\" />\n                <Key word = \"highp\" />\n                <Key word = \"precision\" />\n                <Key word = \"subroutine\" />\n            </KeyWords>\n\t\t\t\n\t\t\t<KeyWords name = \"Types\" bold=\"false\" italic=\"false\" color=\"Red\">\n\t\t\t\t<Key word = \"bool\" />\n\t\t\t\t<Key word = \"double\" />\n                <Key word = \"float\" />\n\t\t\t\t<Key word = \"short\" />\n                <Key word = \"uint\" />\n                <Key word = \"int\" />\n                <Key word = \"buffer\" />\n                <Key word = \"void\" />\n                <Key word = \"vec2\" />\n                <Key word = \"vec3\" />\n                <Key word = \"vec4\" />\n                <Key word = \"dvec2\" />\n                <Key word = \"dvec3\" />\n                <Key word = \"dvec4\" />\n                <Key word = \"ivec2\" />\n                <Key word = \"ivec3\" />\n                <Key word = \"ivec4\" />\n                <Key word = \"uvec2\" />\n                <Key word = \"uvec3\" />\n                <Key word = \"uvec4\" />\n                <Key word = \"bvec2\" />\n                <Key word = \"bvec3\" />\n                <Key word = \"bvec4\" />\n                <Key word = \"mat2\" />\n                <Key word = \"mat3\" />\n                <Key word = \"mat4\" />\n                <Key word = \"dmat2\" />\n                <Key word = \"dmat3\" />\n                <Key word = \"dmat4\" />\n                <Key word = \"mat2x2\" />\n                <Key word = \"mat3x2\" />\n                <Key word = \"mat4x2\" />\n                <Key word = \"mat2x3\" />\n                <Key word = \"mat3x3\" />\n                <Key word = \"mat4x3\" />\n                <Key word = \"mat2x4\" />\n                <Key word = \"mat3x4\" />\n                <Key word = \"mat4x4\" />\n                <Key word = \"dmat2x4\" />\n                <Key word = \"dmat3x4\" />\n                <Key word = \"dmat4x4\" />\n                <Key word = \"dmat2x2\" />\n                <Key word = \"dmat3x2\" />\n                <Key word = \"dmat4x2\" />\n                <Key word = \"dmat2x3\" />\n                <Key word = \"dmat3x3\" />\n                <Key word = \"dmat4x3\" />\n                <Key word = \"struct\" />\n                <Key word = \"atomic_uint\" />\n                <Key word = \"sampler1D\" />\n                <Key word = \"sampler2D\" />\n                <Key word = \"sampler2DRECT\" />\n                <Key word = \"sampler3D\" />\n                <Key word = \"samplerCube\" />\n                <Key word = \"sampler1DArray\" />\n                <Key word = \"sampler2DArray\" />\n                <Key word = \"samplerCubeArray\" />\n                <Key word = \"samplerBuffer\" />\n                <Key word = \"sampler2DMS\" />\n                <Key word = \"sampler2DMSArray\" />\n                <Key word = \"image1D\" />\n                <Key word = \"image2D\" />\n                <Key word = \"image2DRECT\" />\n                <Key word = \"image3D\" />\n                <Key word = \"imageCube\" />\n                <Key word = \"image1DArray\" />\n                <Key word = \"image2DArray\" />\n                <Key word = \"imageCubeArray\" />\n                <Key word = \"imageBuffer\" />\n                <Key word = \"image2DMS\" />\n                <Key word = \"image2DMSArray\" />\n                <Key word = \"isampler1D\" />\n                <Key word = \"isampler2D\" />\n                <Key word = \"isampler2DRECT\" />\n                <Key word = \"isampler3D\" />\n                <Key word = \"isamplerCube\" />\n                <Key word = \"isampler1DArray\" />\n                <Key word = \"isampler2DArray\" />\n                <Key word = \"isamplerCubeArray\" />\n                <Key word = \"isamplerBuffer\" />\n                <Key word = \"isampler2DMS\" />\n                <Key word = \"isampler2DMSArray\" />\n                <Key word = \"iimage1D\" />\n                <Key word = \"iimage2D\" />\n                <Key word = \"iimage2DRECT\" />\n                <Key word = \"iimage3D\" />\n                <Key word = \"iimageCube\" />\n                <Key word = \"iimage1DArray\" />\n                <Key word = \"iimage2DArray\" />\n                <Key word = \"iimageCubeArray\" />\n                <Key word = \"iimageBuffer\" />\n                <Key word = \"iimage2DMS\" />\n                <Key word = \"iimage2DMSArray\" />\n                <Key word = \"usampler1D\" />\n                <Key word = \"usampler2D\" />\n                <Key word = \"usampler2DRECT\" />\n                <Key word = \"usampler3D\" />\n                <Key word = \"usamplerCube\" />\n                <Key word = \"usampler1DArray\" />\n                <Key word = \"usampler2DArray\" />\n                <Key word = \"usamplerCubeArray\" />\n                <Key word = \"usamplerBuffer\" />\n                <Key word = \"usampler2DMS\" />\n                <Key word = \"usampler2DMSArray\" />\n                <Key word = \"uimage1D\" />\n                <Key word = \"uimage2D\" />\n                <Key word = \"uimage2DRECT\" />\n                <Key word = \"uimage3D\" />\n                <Key word = \"uimageCube\" />\n                <Key word = \"uimage1DArray\" />\n                <Key word = \"uimage2DArray\" />\n                <Key word = \"uimageCubeArray\" />\n                <Key word = \"uimageBuffer\" />\n                <Key word = \"uimage2DMS\" />\n                <Key word = \"uimage2DMSArray\" />\n                <Key word = \"sampler1DShadow\" />\n                <Key word = \"sampler2DShadow\" />\n                <Key word = \"sampler2DRECTShadow\" />\n                <Key word = \"sampler3DShadow\" />\n                <Key word = \"samplerCubeShadow\" />\n                <Key word = \"sampler1DArrayShadow\" />\n                <Key word = \"sampler2DArrayShadow\" />\n                <Key word = \"samplerCubeArrayShadow\" />\n            </KeyWords>\n\t\t\t\n\t\t\t<KeyWords name = \"Literals\" bold=\"true\" italic=\"false\" color=\"Black\">\n\t\t\t\t<Key word = \"false\" />\n\t\t\t\t<Key word = \"true\" />\n\t\t\t</KeyWords>\n\t\t\t\n\t\t\t<KeyWords name = \"IterationStatements\" bold=\"true\" italic=\"false\" color=\"Blue\">\n\t\t\t\t<Key word = \"do\" />\n\t\t\t\t<Key word = \"for\" />\n\t\t\t\t<Key word = \"while\" />\n\t\t\t</KeyWords>\n\n            <KeyWords name = \"Intrinsics\" bold=\"true\" italic=\"false\" color=\"Blue\">\n                <Key word = \"degrees\" />\n                <Key word = \"radians\" />\n                <Key word = \"sin\" />\n                <Key word = \"cos\" />\n                <Key word = \"tan\" />\n                <Key word = \"sinh\" />\n                <Key word = \"cosh\" />\n                <Key word = \"tanh\" />\n                <Key word = \"asin\" />\n                <Key word = \"acos\" />\n                <Key word = \"atan\" />\n                <Key word = \"asinh\" />\n                <Key word = \"acosh\" />\n                <Key word = \"atanh\" />\n                <Key word = \"log\" />\n                <Key word = \"log2\" />\n                <Key word = \"exp\" />\n                <Key word = \"exp2\" />\n                <Key word = \"pow\" />\n                <Key word = \"inversesqrt\" />\n                <Key word = \"sqrt\" />\n                <Key word = \"abs\" />\n                <Key word = \"floor\" />\n                <Key word = \"ceil\" />\n                <Key word = \"sign\" />\n                <Key word = \"round\" />\n                <Key word = \"roundEven\" />\n                <Key word = \"trunc\" />\n                <Key word = \"fract\" />\n                <Key word = \"mod\" />\n                <Key word = \"modf\" />\n                <Key word = \"min\" />\n                <Key word = \"max\" />\n                <Key word = \"clamp\" />\n                <Key word = \"mix\" />\n                <Key word = \"step\" />\n                <Key word = \"smoothstep\" />\n                <Key word = \"isinf\" />\n                <Key word = \"isnan\" />\n                <Key word = \"fma\" />\n                <Key word = \"floatBitsToInt\" />\n                <Key word = \"floatBitsToUInt\" />\n                <Key word = \"intBitsToFloat\" />\n                <Key word = \"uintBitsToFloat\" />\n                <Key word = \"frexp\" />\n                <Key word = \"ldexp\" />\n                <Key word = \"faceforward\" />\n                <Key word = \"reflect\" />\n                <Key word = \"refract\" />\n                <Key word = \"dot\" />\n                <Key word = \"cross\" />\n                <Key word = \"length\" />\n                <Key word = \"normalize\" />\n                <Key word = \"distance\" />\n                <Key word = \"determinant\" />\n                <Key word = \"transpose\" />\n                <Key word = \"outerProduct\" />\n                <Key word = \"inverse\" />\n                <Key word = \"matrixCompMult\" />\n                <Key word = \"lessThan\" />\n                <Key word = \"lessThanEqual\" />\n                <Key word = \"greaterThan\" />\n                <Key word = \"greaterThanEqual\" />\n                <Key word = \"equal\" />\n                <Key word = \"notEqual\" />\n                <Key word = \"any\" />\n                <Key word = \"all\" />\n                <Key word = \"not\" />\n                <Key word = \"textureSize\" />\n                <Key word = \"textureQueryLod\" />\n                <Key word = \"textureQueryLevels\" />\n                <Key word = \"textureSamples\" />\n                <Key word = \"texture\" />\n                <Key word = \"textureProj\" />\n                <Key word = \"textureLod\" />\n                <Key word = \"textureOffset\" />\n                <Key word = \"texelFetch\" />\n                <Key word = \"texelFetchOffset\" />\n                <Key word = \"textureLodOffset\" />\n                <Key word = \"textureProjOffset\" />\n                <Key word = \"textureProjLod\" />\n                <Key word = \"textureProjLodOffset\" />\n                <Key word = \"textureGrad\" />\n                <Key word = \"textureGradOffset\" />\n                <Key word = \"textureProjGrad\" />\n                <Key word = \"textureProjGradOffset\" />\n                <Key word = \"textureGather\" />\n                <Key word = \"textureGatherOffset\" />\n                <Key word = \"textureGatherOffsets\" />\n                <Key word = \"atomicCounterIncrement\" />\n                <Key word = \"atomicCounterDecrement\" />\n                <Key word = \"atomicCounter\" />\n                <Key word = \"atomicAdd\" />\n                <Key word = \"atomicMin\" />\n                <Key word = \"atomicMax\" />\n                <Key word = \"atomicAnd\" />\n                <Key word = \"atomicOr\" />\n                <Key word = \"atomicXor\" />\n                <Key word = \"atomicExchange\" />\n                <Key word = \"atomicCompSwap\" />\n                <Key word = \"imageSize\" />\n                <Key word = \"imageSamples\" />\n                <Key word = \"imageLoad\" />\n                <Key word = \"imageStore\" />\n                <Key word = \"imageAtomicAdd\" />\n                <Key word = \"imageAtomicMin\" />\n                <Key word = \"imageAtomicMax\" />\n                <Key word = \"imageAtomicAnd\" />\n                <Key word = \"imageAtomicOr\" />\n                <Key word = \"imageAtomicXor\" />\n                <Key word = \"imageAtomicExchange\" />\n                <Key word = \"imageAtomicCompSwap\" />\n                <Key word = \"dFdx\" />\n                <Key word = \"dFdy\" />\n                <Key word = \"dFdxCoarse\" />\n                <Key word = \"dFdyCoarse\" />\n                <Key word = \"dFdxFine\" />\n                <Key word = \"dFdyFine\" />\n                <Key word = \"fwidth\" />\n                <Key word = \"fwidthFine\" />\n                <Key word = \"fwidthCoarse\" />\n                <Key word = \"interpolateAtCentroid\" />\n                <Key word = \"interpolateAtSample\" />\n                <Key word = \"interpolateAtOffset\" />\n                <Key word = \"EmitStreamVertex\" />\n                <Key word = \"EndStreamPrimitive\" />\n                <Key word = \"EmitVertex\" />\n                <Key word = \"EndPrimitive\" />\n                <Key word = \"barrier\" />\n                <Key word = \"memoryBarrier\" />\n                <Key word = \"memoryBarrierAtomicCounter\" />\n                <Key word = \"memoryBarrierShared\" />\n                <Key word = \"memoryBarrierBuffer\" />\n                <Key word = \"memoryBarrierImage\" />\n                <Key word = \"groupMemoryBarrier\" />\n            </KeyWords>\n\n\n            <KeyWords name = \"BuiltInVars\" bold=\"false\" italic=\"false\" color=\"DarkBlue\">\n                <Key word = \"gl_NumWorkGroups\" />\n                <Key word = \"gl_WorkGroupSize\" />\n                <Key word = \"gl_WorkGroupID\" />\n                <Key word = \"gl_LocalInvocationID\" />\n                <Key word = \"gl_GlobalInvocationID\" />\n                <Key word = \"gl_LocalInvocationIndex\" />\n                <Key word = \"gl_VertexID\" />\n                <Key word = \"gl_InstanceID\" />\n                <Key word = \"gl_InvocationID\" />\n                <Key word = \"gl_PrimitiveIDIn\" />\n                <Key word = \"gl_PrimitiveID\" />\n                <Key word = \"gl_Layer\" />\n                <Key word = \"gl_ViewportIndex\" />\n                <Key word = \"gl_PatchVerticesIn\" />\n                <Key word = \"gl_Position\" />\n                <Key word = \"gl_PointSize\" />\n                <Key word = \"gl_ClipDistance\" />\n                <Key word = \"gl_TessLevelOuter\" />\n                <Key word = \"gl_TessLevelInner\" />\n                <Key word = \"gl_TessCoord\" />\n                <Key word = \"gl_FragCoord\" />\n                <Key word = \"gl_FragColor\" />\n                <Key word = \"gl_FragDepth\" />\n                <Key word = \"gl_FrontFacing\" />\n                <Key word = \"gl_PointCoord\" />\n                <Key word = \"gl_SampleID\" />\n                <Key word = \"gl_SamplePosition\" />\n                <Key word = \"gl_SampleMaskIn\" />\n                <Key word = \"gl_SampleMask\" />\n            </KeyWords>\n\n            <KeyWords name = \"JumpStatements\" bold=\"false\" italic=\"false\" color=\"Blue\">\n\t\t\t\t<Key word = \"break\" />\n\t\t\t\t<Key word = \"continue\" />\n\t\t\t\t<Key word = \"discard\" />\n                <Key word = \"export\" />\n\t\t\t\t<Key word = \"return\" />\n\t\t\t</KeyWords>\n\t\t\t\n\t\t\t<KeyWords name = \"SelectionStatements\" bold=\"true\" italic=\"false\" color=\"Blue\">\n\t\t\t\t<Key word = \"case\" />\n\t\t\t\t<Key word = \"else\" />\n\t\t\t\t<Key word = \"if\" />\n\t\t\t\t<Key word = \"switch\" />\n\t\t\t\t<Key word = \"default\" />\n\t\t\t</KeyWords>\n\t\t\t\n\t\t\t\n\t\t</RuleSet>\n\t</RuleSets>\n</SyntaxDefinition>\n\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Resources/HLSL-Mode.xshd",
    "content": "<?xml version=\"1.0\"?>\n<!-- syntaxdefinition for HLSL by Josh Barczak -->\n\n<SyntaxDefinition name = \"HLSL\" extensions = \".hlsl\">\n\t\n\t<Properties>\n\t\t<Property name=\"LineComment\" value=\"//\"/>\n\t</Properties>\n\t\n\t<Digits name = \"Digits\" bold = \"false\" italic = \"false\" color = \"DarkBlue\"/>\n\t\n\t<RuleSets>\n\t\t<RuleSet ignorecase = \"false\">\n\t\t\t<Delimiters>~!%^*()-+=|\\#/{}[]:;\"'&lt;&gt; , .?</Delimiters>\n\t\t\n\t\t\t<Span name = \"PreprocessorDirectives\" bold=\"false\" italic=\"false\" color=\"Green\" stopateol = \"true\">\n\t\t\t\t<Begin>#</Begin>\n\t\t\t</Span>\n\t\t\t\n\t\t\t<Span name = \"LineComment\" bold = \"false\" italic = \"false\" color = \"Green\" stopateol = \"true\">\n\t\t\t\t<Begin>//</Begin>\n\t\t\t</Span>\n\t\t\t\n\t\t\t<Span name = \"BlockComment\" bold = \"false\" italic = \"false\" color = \"Green\" stopateol = \"false\">\n\t\t\t\t<Begin>/*</Begin>\n\t\t\t\t<End>*/</End>\n\t\t\t</Span>\n\t\t\t\n\t\t\t<Span name = \"String\" bold = \"false\" italic = \"false\" color = \"Magenta\" stopateol = \"true\" escapecharacter=\"\\\">\n\t\t\t\t<Begin>\"</Begin>\n\t\t\t\t<End>\"</End>\n\t\t\t</Span>\n\t\t\t\n\t\t\t<Span name = \"Char\" bold = \"false\" italic = \"false\" color = \"Magenta\" stopateol = \"true\" escapecharacter=\"\\\">\n\t\t\t\t<Begin>&apos;</Begin>\n\t\t\t\t<End>&apos;</End>\n\t\t\t</Span>\n\t\t\t\n\t\t\t<MarkPrevious bold = \"true\" italic = \"false\" color = \"MidnightBlue\">(</MarkPrevious>\n\t\t\t\n\t\t\t<KeyWords name = \"Punctuation\" bold = \"false\" italic = \"false\" color = \"DarkGreen\">\n\t\t\t\t<Key word = \"?\" />\n\t\t\t\t<Key word = \",\" />\n\t\t\t\t<Key word = \".\" />\n\t\t\t\t<Key word = \";\" />\n\t\t\t\t<Key word = \"(\" />\n\t\t\t\t<Key word = \")\" />\n\t\t\t\t<Key word = \"[\" />\n\t\t\t\t<Key word = \"]\" />\n\t\t\t\t<Key word = \"{\" />\n\t\t\t\t<Key word = \"}\" />\n\t\t\t\t<Key word = \"+\" />\n\t\t\t\t<Key word = \"-\" />\n\t\t\t\t<Key word = \"/\" />\n\t\t\t\t<Key word = \"%\" />\n\t\t\t\t<Key word = \"*\" />\n\t\t\t\t<Key word = \"&lt;\" />\n\t\t\t\t<Key word = \"&gt;\" />\n\t\t\t\t<Key word = \"^\" />\n\t\t\t\t<Key word = \"=\" />\n\t\t\t\t<Key word = \"~\" />\n\t\t\t\t<Key word = \"!\" />\n\t\t\t\t<Key word = \"|\" />\n\t\t\t\t<Key word = \"&amp;\" />\n\t\t\t</KeyWords>\n\t\t\n\t\n\t\t\t\n\t\t\t<KeyWords name = \"AccessModifiers\" bold=\"true\" italic=\"false\" color=\"Blue\">\n\t\t\t\t<Key word = \"const\" />\n                <Key word = \"column_major\" />\n                <Key word = \"row_major\" />\n\t\t\t\t<Key word = \"static\" />\n                <Key word = \"centroid\" />\n                <Key word = \"sample\" />\n                <Key word = \"nointerpolation\" />\n                <Key word = \"extern\" />\n                <Key word = \"groupshared\" />\n                <Key word = \"in\" />\n                <Key word = \"inout\" />\n                <Key word = \"out\" />\n                <Key word = \"linear\" />\n                <Key word = \"noperspective\" />\n                <Key word = \"line\" />\n                <Key word = \"lineadj\" />\n                <Key word = \"point\" />\n                <Key word = \"triangle\" />\n                <Key word = \"triangleadj\" />\n                <Key word = \"packoffset\" />\n                <Key word = \"register\" />\n                <Key word = \"precise\" />\n                <Key word = \"snorm\" />\n                <Key word = \"shared\" />\n                <Key word = \"uniform\" />\n\t\t\t</KeyWords>\n\t\t\t\n\t\t\t<KeyWords name = \"Types\" bold=\"false\" italic=\"false\" color=\"Red\">\n\t\t\t\t<Key word = \"bool\" />\n\t\t\t\t<Key word = \"double\" />\n                <Key word = \"dword\" />\n                <Key word = \"float\" />\n\t\t\t\t<Key word = \"short\" />\n\t\t\t\t<Key word = \"signed\" />\n                <Key word = \"half\" />\n                <Key word = \"unsigned\" />\n\t\t\t\t<Key word = \"void\" />\n\t\t\t\t<Key word = \"class\" />\n                <Key word = \"interface\" />\n                <Key word = \"matrix\" />\n                <Key word = \"min16float\" />\n                <Key word = \"min10float\" />\n                <Key word = \"min16int\" />\n                <Key word = \"min12int\" />\n                <Key word = \"min16uint\" />\n\t\t\t\t<Key word = \"struct\" />\n                <Key word = \"AppendStructuredBuffer\" />\n                <Key word = \"cbuffer\" />\n                <Key word = \"tbuffer\" />\n                <Key word = \"ConsumeStructuredBuffer\" />\n                <Key word = \"Buffer\" />\n                <Key word = \"ByteAddressBuffer\" />\n                <Key word = \"InputPatch\" />\n                <Key word = \"OutputPatch\" />\n                <Key word = \"LineStream\" />\n                <Key word = \"PointStream\" />\n                <Key word = \"TriangleStream\" />\n                <Key word = \"RWBuffer\" />\n                <Key word = \"RWByteAddressBuffer\" />\n                <Key word = \"RWStructuredBuffer\" />\n                <Key word = \"RWTexture1D\" />\n                <Key word = \"RWTexture2D\" />\n                <Key word = \"RWTexture2DArray\" />\n                <Key word = \"RWTexture3D\" />\n                <Key word = \"Buffer\" />\n                <Key word = \"ByteAddressBuffer\" />\n                <Key word = \"StructuredBuffer\" />\n                <Key word = \"Texture1D\" />\n                <Key word = \"Texture2D\" />\n                <Key word = \"Texture2DMS\" />\n                <Key word = \"Texture2DMSArray\" />\n                <Key word = \"Texture2DArray\" />\n                <Key word = \"Texture3D\" />\n                <Key word = \"TextureCube\" />\n                <Key word = \"TextureCubeArray\" />\n                <Key word = \"sampler\" />\n                <Key word = \"SamplerState\" />\n                <Key word = \"SamplerComparisonState\" />\n                <Key word = \"StructuredBuffer\" />\n                <Key word = \"typedef\" />\n                <Key word = \"uint\" />\n                <Key word = \"int\" />\n                <Key word = \"vector\" />\n                <Key word = \"float2\" />\n                <Key word = \"float3\" />\n                <Key word = \"float4\" />\n                <Key word = \"double2\" />\n                <Key word = \"double3\" />\n                <Key word = \"double4\" />\n                <Key word = \"int2\" />\n                <Key word = \"int3\" />\n                <Key word = \"int4\" />\n                <Key word = \"uint2\" />\n                <Key word = \"uint3\" />\n                <Key word = \"uint4\" />\n                <Key word = \"bool2\" />\n                <Key word = \"bool3\" />\n                <Key word = \"bool4\" />\n                <Key word = \"float2x2\" />\n                <Key word = \"float3x2\" />\n                <Key word = \"float4x2\" />\n                <Key word = \"double2x2\" />\n                <Key word = \"double3x2\" />\n                <Key word = \"double4x2\" />\n                <Key word = \"int2x2\" />\n                <Key word = \"int3x2\" />\n                <Key word = \"int4x2\" />\n                <Key word = \"uint2x2\" />\n                <Key word = \"uint3x2\" />\n                <Key word = \"uint4x2\" />\n                <Key word = \"bool2x2\" />\n                <Key word = \"bool3x2\" />\n                <Key word = \"bool4x2\" />\n                <Key word = \"float2x3\" />\n                <Key word = \"float3x3\" />\n                <Key word = \"float4x3\" />\n                <Key word = \"double2x3\" />\n                <Key word = \"double3x3\" />\n                <Key word = \"double4x3\" />\n                <Key word = \"int2x3\" />\n                <Key word = \"int3x3\" />\n                <Key word = \"int4x3\" />\n                <Key word = \"uint2x3\" />\n                <Key word = \"uint3x3\" />\n                <Key word = \"uint4x3\" />\n                <Key word = \"bool2x3\" />\n                <Key word = \"bool3x3\" />\n                <Key word = \"bool4x3\" />\n                <Key word = \"float2x4\" />\n                <Key word = \"float3x4\" />\n                <Key word = \"float4x4\" />\n                <Key word = \"double2x4\" />\n                <Key word = \"double3x4\" />\n                <Key word = \"double4x4\" />\n                <Key word = \"int2x4\" />\n                <Key word = \"int3x4\" />\n                <Key word = \"int4x4\" />\n                <Key word = \"uint2x4\" />\n                <Key word = \"uint3x4\" />\n                <Key word = \"uint4x4\" />\n                <Key word = \"bool2x4\" />\n                <Key word = \"bool3x4\" />\n                <Key word = \"bool4x4\" />\n            </KeyWords>\n\t\t\t\n\t\t\t<KeyWords name = \"Literals\" bold=\"true\" italic=\"false\" color=\"Black\">\n\t\t\t\t<Key word = \"false\" />\n\t\t\t\t<Key word = \"true\" />\n\t\t\t</KeyWords>\n\t\t\t\n\t\t\t<KeyWords name = \"IterationStatements\" bold=\"true\" italic=\"false\" color=\"Blue\">\n\t\t\t\t<Key word = \"do\" />\n\t\t\t\t<Key word = \"for\" />\n\t\t\t\t<Key word = \"while\" />\n\t\t\t</KeyWords>\n\n            <KeyWords name = \"Intrinsics\" bold=\"true\" italic=\"false\" color=\"Blue\">\n                <Key word = \"GetRenderTargetSampleCount\" />\n                <Key word = \"GetRenderTargetSamplePosition\" />\n                <Key word = \"GroupMemoryBarrierWithGroupSync\" />\n                <Key word = \"GroupMemoryBarrier\" />\n                <Key word = \"InterlockedAdd\" />\n                <Key word = \"InterlockedAnd\" />\n                <Key word = \"InterlockedCompareExchange\" />\n                <Key word = \"InterlockedCompareStore\" />\n                <Key word = \"InterlockedExchange\" />\n                <Key word = \"InterlockedMin\" />\n                <Key word = \"InterlockedMax\" />\n                <Key word = \"InterlockedOr\" />\n                <Key word = \"InterlockedXor\" />\n                <Key word = \"abs\" />\n                <Key word = \"clamp\" />\n                <Key word = \"saturate\" />\n                <Key word = \"all\" />\n                <Key word = \"any\" />\n                <Key word = \"clip\" />\n                <Key word = \"dot\" />\n                <Key word = \"cross\" />\n                <Key word = \"length\" />\n                <Key word = \"normalize\" />\n                <Key word = \"ddx\" />\n                <Key word = \"ddy\" />\n                <Key word = \"fwidth\" />\n                <Key word = \"ddx_coarse\" />\n                <Key word = \"ddy_coarse\" />\n                <Key word = \"ddx_fine\" />\n                <Key word = \"ddy_fine\" />\n                <Key word = \"faceforward\" />\n                <Key word = \"dst\" />\n                <Key word = \"distance\" />\n                <Key word = \"determinant\" />\n                <Key word = \"transpose\" />\n                <Key word = \"reflect\" />\n                <Key word = \"refract\" />\n                <Key word = \"step\" />\n                <Key word = \"smoothstep\" />\n                <Key word = \"lerp\" />\n                <Key word = \"lit\" />\n                <Key word = \"mul\" />\n                <Key word = \"log\" />\n                <Key word = \"log10\" />\n                <Key word = \"log2\" />\n                <Key word = \"exp\" />\n                <Key word = \"exp2\" />\n                <Key word = \"pow\" />\n                <Key word = \"rsqrt\" />\n                <Key word = \"sqrt\" />\n                <Key word = \"rcp\" />\n                <Key word = \"degrees\" />\n                <Key word = \"radians\" />\n                <Key word = \"sin\" />\n                <Key word = \"cos\" />\n                <Key word = \"sincos\" />\n                <Key word = \"tan\" />\n                <Key word = \"sinh\" />\n                <Key word = \"cosh\" />\n                <Key word = \"tanh\" />\n                <Key word = \"asin\" />\n                <Key word = \"acos\" />\n                <Key word = \"atan\" />\n                <Key word = \"atan2\" />\n                <Key word = \"floor\" />\n                <Key word = \"ceil\" />\n                <Key word = \"frac\" />\n                <Key word = \"sign\" />\n                <Key word = \"fmod\" />\n                <Key word = \"modf\" />\n                <Key word = \"msad4\" />\n                <Key word = \"round\" />\n                <Key word = \"frexp\" />\n                <Key word = \"ldexp\" />\n                <Key word = \"isfinite\" />\n                <Key word = \"isinf\" />\n                <Key word = \"isnan\" />\n                <Key word = \"fma\" />\n                <Key word = \"trunc\" />\n                <Key word = \"min\" />\n                <Key word = \"max\" />\n                <Key word = \"countbits\" />\n                <Key word = \"firstbithigh\" />\n                <Key word = \"firstbitlow\" />\n                <Key word = \"reversebits\" />\n                <Key word = \"f16to32\" />\n                <Key word = \"f32to16\" />\n                <Key word = \"asint\" />\n                <Key word = \"asuint\" />\n                <Key word = \"asfloat\" />\n                <Key word = \"asdouble\" />\n\n            </KeyWords>\n\t\t\t\n            <KeyWords name = \"JumpStatements\" bold=\"false\" italic=\"false\" color=\"Blue\">\n\t\t\t\t<Key word = \"break\" />\n\t\t\t\t<Key word = \"continue\" />\n\t\t\t\t<Key word = \"discard\" />\n                <Key word = \"export\" />\n\t\t\t\t<Key word = \"return\" />\n\t\t\t</KeyWords>\n\t\t\t\n\t\t\t<KeyWords name = \"SelectionStatements\" bold=\"true\" italic=\"false\" color=\"Blue\">\n\t\t\t\t<Key word = \"case\" />\n\t\t\t\t<Key word = \"else\" />\n\t\t\t\t<Key word = \"if\" />\n\t\t\t\t<Key word = \"switch\" />\n\t\t\t\t<Key word = \"default\" />\n\t\t\t</KeyWords>\n\t\t\t\n\t\t\t\n\t\t</RuleSet>\n\t</RuleSets>\n</SyntaxDefinition>\n\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Resources/Mode.xsd",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" >\n\t<xsd:annotation>\n\t\t<xsd:documentation>\n\t\tThis schema defines the syntax for mode definitions in SharpDevelop.\n\t\tThe schema can be simplified quite a bit but it does the job as is.\n\t\t\n\t\t\n\t\tIf you are using this file as a reference it is probably easiest to scroll to\n\t\tthe botton to find the definition of the root element called SyntaxDefinition and\n\t\tthen unwind the different type definitions and refernces.\n\t\t\n\t\tNote on coloring:\n\t\tMany tags define how some symbol should be colored. If a specific symbol\n\t\tcan not be matched onto either a Span definition, Keyword, or a Digit/Number it\n\t\twill be rendered in the current default color. Which is the default color of the\n\t\tcurrent span or the default color of the mode as a whole if no span has been entered.\n\t\t</xsd:documentation>\n\t</xsd:annotation>\n\t\n\t<!-- Defines the default rendering of the mode -->\n\t<xsd:complexType name=\"EnvironmentEntry\">\n\t\t<xsd:attribute name=\"bold\" type=\"xsd:boolean\" />\n\t\t<xsd:attribute name=\"italic\" type=\"xsd:boolean\" />\n\t\t<xsd:attribute name=\"color\" type=\"xsd:string\" />\n\t\t<xsd:attribute name=\"bgcolor\" type=\"xsd:string\" />\n\t</xsd:complexType>\n\t\n\t<xsd:complexType name=\"CustomEnvironmentEntry\">\n\t\t<xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" />\n\t\t<xsd:attribute name=\"bold\" type=\"xsd:boolean\" />\n\t\t<xsd:attribute name=\"italic\" type=\"xsd:boolean\" />\n\t\t<xsd:attribute name=\"color\" type=\"xsd:string\" />\n\t\t<xsd:attribute name=\"bgcolor\" type=\"xsd:string\" />\n\t</xsd:complexType>\n\t\n\t<!-- The environment tag defines the coloring of various attributes in SharpDevelop -->\n\t<xsd:complexType name=\"Environment\">\n\t\t\n\t\t<xsd:choice minOccurs=\"0\" maxOccurs=\"unbounded\">\n\t\t\t<xsd:element name=\"Default\" type=\"EnvironmentEntry\" minOccurs=\"0\" maxOccurs=\"1\" />\n\t\t\t<xsd:element name=\"Selection\" type=\"EnvironmentEntry\" minOccurs=\"0\" maxOccurs=\"1\"/>\n\t\t\t<xsd:element name=\"VRuler\" type=\"EnvironmentEntry\" minOccurs=\"0\" maxOccurs=\"1\"/>\n\t\t\t<xsd:element name=\"InvalidLines\" type=\"EnvironmentEntry\" minOccurs=\"0\" maxOccurs=\"1\"/>\n\t\t\t<xsd:element name=\"CaretMarker\" type=\"EnvironmentEntry\" minOccurs=\"0\" maxOccurs=\"1\"/>\n\t\t\t\n\t\t\t<xsd:element name=\"LineNumbers\" type=\"EnvironmentEntry\" minOccurs=\"0\" maxOccurs=\"1\"/>\n\t\t\t\n\t\t\t<xsd:element name=\"FoldLine\" type=\"EnvironmentEntry\" minOccurs=\"0\" maxOccurs=\"1\"/>\n\t\t\t<xsd:element name=\"FoldMarker\" type=\"EnvironmentEntry\" minOccurs=\"0\" maxOccurs=\"1\"/>\n\t\t\t<xsd:element name=\"SelectedFoldLine\" type=\"EnvironmentEntry\" minOccurs=\"0\" maxOccurs=\"1\"/>\n\t\t\t\n\t\t\t<xsd:element name=\"EOLMarkers\" type=\"EnvironmentEntry\" minOccurs=\"0\" maxOccurs=\"1\"/>\n\t\t\t<xsd:element name=\"SpaceMarkers\" type=\"EnvironmentEntry\" minOccurs=\"0\" maxOccurs=\"1\"/>\n\t\t\t<xsd:element name=\"TabMarkers\" type=\"EnvironmentEntry\" minOccurs=\"0\" maxOccurs=\"1\"/>\n\t\t\t\n\t\t\t<xsd:element name=\"Custom\" type=\"CustomEnvironmentEntry\" minOccurs=\"0\" maxOccurs=\"unbounded\"/>\n\t\t</xsd:choice>\n\t</xsd:complexType>\n\t\n\t<xsd:complexType name=\"Properties\">\n\t\t<xsd:sequence>\n\t\t\t<xsd:element name=\"Property\" type=\"Property\" minOccurs=\"0\" maxOccurs=\"unbounded\"/>\n\t\t</xsd:sequence>\n\t</xsd:complexType>\n\t\n\t<xsd:complexType name=\"Property\">\n\t\t<!-- The actual KeyWord, typically reserved words or symbols in a programming language -->\n\t\t<xsd:attribute name=\"name\" type=\"xsd:string\" />\n\t\t<xsd:attribute name=\"value\" type=\"xsd:string\" />\n\t</xsd:complexType>\n\t\n\t<!-- The Digits tag defines the color for rendering Digits-->\n\t<xsd:complexType name=\"Digits\">\n\t\t<xsd:attribute name=\"name\" type=\"xsd:string\" />\n\t\t<xsd:attribute name=\"bold\" type=\"xsd:boolean\" />\n\t\t<xsd:attribute name=\"italic\" type=\"xsd:boolean\" />\n\t\t<xsd:attribute name=\"color\" type=\"xsd:string\" />\n\t\t<xsd:attribute name=\"bgcolor\" type=\"xsd:string\" />\n\t</xsd:complexType>\n\t\n\t<!-- Defines the delimiting characters of the syntax, e.g., the characters that, \"break up\" a line\n    into separate symbols, typically key words. It is not necessary, or desirable to include the\n    characters that denot the start or end of a span. Space and Tab are implicitly defined as delimeters\n    and they don't need to be includeded explicitly (this will probably be changed at some future time).-->\n\t<xsd:complexType name=\"Delimiters\">\n\t\t<xsd:simpleContent>\n\t\t\t<xsd:extension base=\"xsd:string\">\n\t\t\t</xsd:extension>\n\t\t</xsd:simpleContent>\n\t</xsd:complexType>\n\t\n\t<!-- The beginning symbol of a Span -->\n\t<xsd:complexType name=\"Begin\">\n\t\t<xsd:simpleContent>\n\t\t\t<xsd:extension base=\"xsd:string\">\n\t\t\t\t<xsd:attribute name=\"singleword\" type=\"xsd:boolean\" />\n\t\t\t\t<xsd:attribute name=\"startofline\" type=\"xsd:boolean\" />\n\t\t\t\t<!-- The default rendering style for the Begin symbol. If not specified\n\t\t\t\t\t the defaul rendering style for the span will be used. -->\n\t\t\t\t<xsd:attribute name=\"bold\" type=\"xsd:boolean\" />\n\t\t\t\t<xsd:attribute name=\"italic\" type=\"xsd:boolean\" />\n\t\t\t\t<xsd:attribute name=\"color\" type=\"xsd:string\" />\n\t\t\t\t<xsd:attribute name=\"bgcolor\" type=\"xsd:string\" />\n\t\t\t</xsd:extension>\n\t\t</xsd:simpleContent>\n\t</xsd:complexType>\n\t\n\t<!-- The end symbol of a Span -->\n\t<xsd:complexType name=\"End\">\n\t\t<xsd:simpleContent>\n\t\t\t<xsd:extension base=\"xsd:string\">\n\t\t\t\t<xsd:attribute name=\"singleword\" type=\"xsd:boolean\" />\n\t\t\t\t<!-- The default rendering style for the End symbol. If not specified\n\t\t\t\t\t the defaul rendering style for the span will be used. -->\n\t\t\t\t<xsd:attribute name=\"bold\" type=\"xsd:boolean\" />\n\t\t\t\t<xsd:attribute name=\"italic\" type=\"xsd:boolean\" />\n\t\t\t\t<xsd:attribute name=\"color\" type=\"xsd:string\" />\n\t\t\t\t<xsd:attribute name=\"bgcolor\" type=\"xsd:string\" />\n\t\t\t</xsd:extension>\n\t\t</xsd:simpleContent>\n\t</xsd:complexType>\n\t\n\t<xsd:complexType name=\"Span\">\n\t\t<xsd:sequence>\n\t\t\t<!-- Defines the symbol that indicates the beginning of the span. -->\n\t\t\t<xsd:element name=\"Begin\" type=\"Begin\" />\n\t\t\t<!-- Defines the symbol that indicates the end of the span. May be omitted for\n\t\t\t\t one-line spans. -->\n\t\t\t<xsd:element name=\"End\" minOccurs=\"0\" type=\"End\" />\n\t\t</xsd:sequence>\n\t\t<!-- The name of the span definition -->\n\t\t<xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" />\n\t\t<!-- Defines the rule set that is applicable in the Span. May be omitted. -->\n\t\t<xsd:attribute name=\"rule\" type=\"xsd:string\" />\n\t\t<!-- Defines wether the Span should terminate automatically at the end of line. Typical examples\n       \t\t include one-line comments such as // in C++ or REM in Windows .Bat files. -->\n\t\t<xsd:attribute name=\"stopateol\" type=\"xsd:boolean\" />\n\t\t\n\t\t<!-- OBSOLUTE: Defines whether C-style escape sequences using \\ are applicable or not in the span. -->\n\t\t<xsd:attribute name=\"noescapesequences\" type=\"xsd:boolean\" />\n\t\t\n\t\t<!-- defines the escape character -->\n\t\t<xsd:attribute name=\"escapecharacter\" type=\"xsd:string\" />\n\t\t\n\t\t<!-- The default rendering style for the span -->\n\t\t<xsd:attribute name=\"bold\" type=\"xsd:boolean\" />\n\t\t<xsd:attribute name=\"italic\" type=\"xsd:boolean\" />\n\t\t<xsd:attribute name=\"color\" type=\"xsd:string\" />\n\t\t<xsd:attribute name=\"bgcolor\" type=\"xsd:string\" />\n\t</xsd:complexType>\n\t\n\t<xsd:complexType name=\"MarkPrevious\">\n\t\t<xsd:simpleContent>\n\t\t\t<xsd:extension base=\"xsd:string\">\n\t\t\t\t<!-- Svante Lidman, looking in the code it is a bit unclear what the intent is here... -->\n\t\t\t\t<xsd:attribute name=\"markmarker\" type=\"xsd:boolean\" />\n\t\t\t\t<!-- The rendering style to be used -->\n\t\t\t\t<xsd:attribute name=\"bold\" type=\"xsd:boolean\" />\n\t\t\t\t<xsd:attribute name=\"italic\" type=\"xsd:boolean\" />\n\t\t\t\t<xsd:attribute name=\"color\" type=\"xsd:string\" />\n\t\t\t\t<xsd:attribute name=\"bgcolor\" type=\"xsd:string\" />\n\t\t\t</xsd:extension>\n\t\t</xsd:simpleContent>\n\t</xsd:complexType>\n\t\n\t<!-- Allows you to define the coloring of the symbol that follows a specified symbol -->\n\t<xsd:complexType name=\"MarkFollowing\">\n\t\t<xsd:simpleContent>\n\t\t\t<xsd:extension base=\"xsd:string\">\n\t\t\t\t<!-- Svante Lidman, looking in the code it is a bit unclear what the intent is here... -->\n\t\t\t\t<xsd:attribute name=\"markmarker\" type=\"xsd:boolean\" />\n\t\t\t\t<!-- The rendering style to be used -->\n\t\t\t\t<xsd:attribute name=\"bold\" type=\"xsd:boolean\" />\n\t\t\t\t<xsd:attribute name=\"italic\" type=\"xsd:boolean\" />\n\t\t\t\t<xsd:attribute name=\"color\" type=\"xsd:string\" />\n\t\t\t\t<xsd:attribute name=\"bgcolor\" type=\"xsd:string\" />\n\t\t\t</xsd:extension>\n\t\t</xsd:simpleContent>\n\t</xsd:complexType>\n\t\n\t<xsd:complexType name=\"Key\">\n\t\t<!-- The actual KeyWord, typically reserved words or symbols in a programming language -->\n\t\t<xsd:attribute name=\"word\" type=\"xsd:string\" />\n\t</xsd:complexType>\n\t\n\t\n\t<!-- A grouping of keywords that sholuld be colored the same way -->\n\t<xsd:complexType name=\"KeyWords\">\n\t\t<xsd:sequence>\n\t\t\t<!-- allow groups with 0 keywords: this simplifies the syntax highlighting editor -->\n\t\t\t<!-- A KeyWord -->\n\t\t\t<xsd:element name=\"Key\" type=\"Key\" minOccurs=\"0\" maxOccurs=\"unbounded\">\n\t\t\t</xsd:element>\n\t\t</xsd:sequence>\n\t\t<!-- The name of the KeyWord group -->\n\t\t<xsd:attribute name=\"name\" type=\"xsd:string\" />\n\t\t<!-- The rendering style of the  KeyWord group -->\n\t\t<xsd:attribute name=\"bold\" type=\"xsd:boolean\" />\n\t\t<xsd:attribute name=\"italic\" type=\"xsd:boolean\" />\n\t\t<xsd:attribute name=\"color\" type=\"xsd:string\" />\n\t\t<xsd:attribute name=\"bgcolor\" type=\"xsd:string\" />\n\t</xsd:complexType>\n\t\n\t<xsd:complexType name=\"RuleSet\">\n\t\t<xsd:sequence>\n\t\t\t<!-- Defines the delimiting characters of the syntax, e.g., the characters that, \"break up\" a line\n        \t\t into separate symbols, typically key words. It is not necessary, or desirable to include the\n        \t\t characters that denot the start or end of a span. Space and Tab are implicitly defined as delimeters\n        \t\t and they don't need to be includeded explicitly (this will probably be changed at some future time).-->\n\t\t\t<xsd:element name=\"Delimiters\" type=\"Delimiters\" minOccurs=\"0\" maxOccurs=\"1\">\n\t\t\t</xsd:element>\n\t\t\t<!-- A Span tag defines a scope, or what can be seen as a separate parsing context where a different set of\n            \t highlighting rules are applicable compared to the text where the span is found. \n            \t Examples of spans include:\n            \t - A string in a language as C\n            \t - A <script> tag in Html\n            \t - The internals of a tag in XML (between < and >).\n            \t A span can have a rule set associated with it that defines the highlighting rules that are applicable\n            \t in the span. -->\n\t\t\t<xsd:element name=\"Span\" type=\"Span\" minOccurs=\"0\" maxOccurs=\"unbounded\">\n\t\t\t</xsd:element>\n\t\t\t<!-- The MarkPrevious tag allows you to define the coloring of the item that preceeds a specific\n            \t symbol. An example of where this comes in handy is when coloring the contents of an XML-tag,\n            \t in particular the attributes and attribute names. The following definition:\n            \t <MarkPrevious bold=\"false\" italic=\"false\" color=\"Red\">=</MarkPrevious>\n\t\t\t\t will make teh highlighter color words that are followed by an = to be colored in Red.\n\t\t\t\t You can see this in this file if you view it with the default XML-mode in SharpDevelop. -->\n\t\t\t<xsd:element name=\"MarkPrevious\" type=\"MarkPrevious\" minOccurs=\"0\" maxOccurs=\"unbounded\">\n\t\t\t</xsd:element>\n\t\t\t<!-- The MarkFollowing tag works similarly as the MarkPrevious tag but relates to the coloring\n            of the symbol that follows the specified symbol. -->\n\t\t\t<xsd:element name=\"MarkFollowing\" type=\"MarkFollowing\" minOccurs=\"0\" maxOccurs=\"unbounded\">\n\t\t\t</xsd:element>\n\t\t\t<!-- Defines a group of keywords that should be colored the same way -->\n\t\t\t<xsd:element name=\"KeyWords\" type=\"KeyWords\" minOccurs=\"0\" maxOccurs=\"unbounded\">\n\t\t\t</xsd:element>\n\t\t</xsd:sequence>\n\t\t<!-- The name of the RuleSet. Used when you refer to the RuleSet in the rule attribute of a Span tag.\n        \t Each mode file should have a rule definition without a defined name. This denotes the default rule\n        \t set for the mode. -->\n\t\t<xsd:attribute name=\"name\" type=\"xsd:string\" />\n\t\t<!-- Allows you to use another mode, defined in another file as a RuleSet. For an example see the\n        \t use of the JavaScript mode from the HTML-mode. -->\n\t\t<xsd:attribute name=\"reference\" type=\"xsd:string\" />\n\t\t<!-- Defines whether case is significant for matching keywords in the mode. -->\n\t\t<xsd:attribute name=\"ignorecase\" type=\"xsd:boolean\" />\n\t\t<!-- OBSOLETE: noescapesequences -->\n\t\t<xsd:attribute name=\"noescapesequences\" type=\"xsd:boolean\" />\n\t\t<!-- defines the escape character -->\n\t\t<xsd:attribute name=\"escapecharacter\" type=\"xsd:string\" />\n\t</xsd:complexType>\n\t\n\t<!-- The RuleSets tag is just a grouping of the set of RuleSets for a mode. -->\n\t<xsd:complexType name=\"RuleSets\">\n\t\t<xsd:sequence minOccurs=\"0\" maxOccurs=\"unbounded\">\n\t\t\t<!-- Any number of RuleSet tag can be defined in a mode -->\n\t\t\t<xsd:element name=\"RuleSet\" type=\"RuleSet\" minOccurs=\"1\" maxOccurs=\"unbounded\">\n\t\t\t</xsd:element>\n\t\t</xsd:sequence>\n\t</xsd:complexType>\n\t\n\t<!-- SyntaxDefinition is the root-element in a mode definition file -->\n\t<xsd:element name=\"SyntaxDefinition\">\n\t\t<xsd:complexType>\n\t\t\t<xsd:sequence>\n\t\t\t\t<!-- The Environment tag defines colors, for various standard elements in the SharpDevelop GUI, if\n\t\t\t\t     not given the default values are used. -->\n\t\t\t\t<xsd:element name=\"Environment\" type=\"Environment\" minOccurs=\"0\" maxOccurs=\"1\"/>\n\t\t\t\t\n\t\t\t\t<!-- The Properties section defines properties which are bound to the highlighting -->\n\t\t\t\t<xsd:element name=\"Properties\" type=\"Properties\" minOccurs=\"0\" maxOccurs=\"1\" />\n\t\t\t\t\n\t\t\t\t<!-- The Digits tag defines the color for rendering Digits-->\n\t\t\t\t<xsd:element name=\"Digits\" type=\"Digits\" minOccurs=\"0\" maxOccurs=\"1\"/>\n\t\t\t\t\n\t\t\t\t<!-- The RuleSets tag defines the rule sets that are used in the mode. Note that all modes are defined in\n\t\t\t\t\t a flat structture even if they are used recursively. For an example of a mode that uses\n\t\t\t\t\t multiple rule sets see the XML-mode. There is a top level rule-set and and another rule-set\n\t\t\t\t\t that handles highligting within a tag, i.e., between < and >. -->\n\t\t\t\t<xsd:element name=\"RuleSets\" type=\"RuleSets\" />\n\t\t\t</xsd:sequence>\n\t\t\t<!-- The name of the mode. This is used when you, in the defintion of a RuleSet refers to another\n\t\t\t\t mode. I.e., one that is defined in an external file. For an example of this see the HTML-Mode that\n\t\t\t\t uses the JavaScript-mode this way. -->\n\t\t\t<xsd:attribute name=\"name\" type=\"xsd:string\" />\n\t\t\t<!-- The file extensions that the mode is applicable for. Extensions must be written with lower case and\n\t\t\t\t should include the ., as in .txt. If several extensions are applicable they should be separeated with | -->\n\t\t\t<xsd:attribute name=\"extensions\" type=\"xsd:string\" />\n\t\t\t<!-- Name of a syntax mode where rulesets, spans, keywords and other settings are imported from -->\n\t\t\t<xsd:attribute name=\"extends\" type=\"xsd:string\" />\n\t\t</xsd:complexType>\n\t</xsd:element>\n\n</xsd:schema>\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Resources/SyntaxModes.xml",
    "content": "<SyntaxModes version=\"1.0\">\n\n    <Mode file       = \"HLSL-Mode.xshd\"\n          name       = \"HLSL\"\n          extensions = \".hlsl\"/>\n    \n    <Mode file       = \"GLSL-Mode.xshd\"\n          name       = \"GLSL\"\n          extensions = \".glsl\"/>\n    \n    <Mode file       = \"CPP-Mode.xshd\"\n\t      name       = \"C++.NET\"\n\t      extensions = \".c;.h;.cc;.C;.cpp;.hpp\"/>\n\n</SyntaxModes>\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Actions/BookmarkActions.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 3272 $</version>\n// </file>\n\nusing System;\nusing ICSharpCode.TextEditor.Document;\n\nnamespace ICSharpCode.TextEditor.Actions \n{\n\tpublic class ToggleBookmark : AbstractEditAction\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\ttextArea.Document.BookmarkManager.ToggleMarkAt(textArea.Caret.Position);\n\t\t\ttextArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, textArea.Caret.Line));\n\t\t\ttextArea.Document.CommitUpdate();\n\t\t\t\n\t\t}\n\t}\n\t\n\tpublic class GotoPrevBookmark : AbstractEditAction\n\t{\n\t\tPredicate<Bookmark> predicate = null;\n\t\t\n\t\tpublic GotoPrevBookmark(Predicate<Bookmark> predicate)\n\t\t{\n\t\t\tthis.predicate = predicate;\n\t\t}\n\t\t\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tBookmark mark = textArea.Document.BookmarkManager.GetPrevMark(textArea.Caret.Line, predicate);\n\t\t\tif (mark != null) {\n\t\t\t\ttextArea.Caret.Position = mark.Location;\n\t\t\t\ttextArea.SelectionManager.ClearSelection();\n\t\t\t\ttextArea.SetDesiredColumn();\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic class GotoNextBookmark : AbstractEditAction\n\t{\n\t\tPredicate<Bookmark> predicate = null;\n\t\t\n\t\tpublic GotoNextBookmark(Predicate<Bookmark> predicate)\n\t\t{\n\t\t\tthis.predicate = predicate;\n\t\t}\n\t\t\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tBookmark mark = textArea.Document.BookmarkManager.GetNextMark(textArea.Caret.Line, predicate);\n\t\t\tif (mark != null) {\n\t\t\t\ttextArea.Caret.Position = mark.Location;\n\t\t\t\ttextArea.SelectionManager.ClearSelection();\n\t\t\t\ttextArea.SetDesiredColumn();\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic class ClearAllBookmarks : AbstractEditAction\n\t{\n\t\tPredicate<Bookmark> predicate = null;\n\t\t\n\t\tpublic ClearAllBookmarks(Predicate<Bookmark> predicate)\n\t\t{\n\t\t\tthis.predicate = predicate;\n\t\t}\n\t\t\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\ttextArea.Document.BookmarkManager.RemoveMarks(predicate);\n\t\t\ttextArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea));\n\t\t\ttextArea.Document.CommitUpdate();\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Actions/CaretActions.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 2681 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\nusing System.Drawing;\n\nusing ICSharpCode.TextEditor.Document;\n\nnamespace ICSharpCode.TextEditor.Actions\n{\n\tpublic class CaretLeft : AbstractEditAction\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tTextLocation position = textArea.Caret.Position;\n\t\t\tList<FoldMarker> foldings = textArea.Document.FoldingManager.GetFoldedFoldingsWithEnd(position.Y);\n\t\t\tFoldMarker justBeforeCaret = null;\n\t\t\tforeach (FoldMarker fm in foldings) {\n\t\t\t\tif (fm.EndColumn == position.X) {\n\t\t\t\t\tjustBeforeCaret = fm;\n\t\t\t\t\tbreak; // the first folding found is the folding with the smallest Startposition\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (justBeforeCaret != null) {\n\t\t\t\tposition.Y = justBeforeCaret.StartLine;\n\t\t\t\tposition.X = justBeforeCaret.StartColumn;\n\t\t\t} else {\n\t\t\t\tif (position.X > 0) {\n\t\t\t\t\t--position.X;\n\t\t\t\t} else if (position.Y  > 0) {\n\t\t\t\t\tLineSegment lineAbove = textArea.Document.GetLineSegment(position.Y - 1);\n\t\t\t\t\tposition = new TextLocation(lineAbove.Length, position.Y - 1);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\ttextArea.Caret.Position = position;\n\t\t\ttextArea.SetDesiredColumn();\n\t\t}\n\t}\n\t\n\tpublic class CaretRight : AbstractEditAction\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tLineSegment curLine = textArea.Document.GetLineSegment(textArea.Caret.Line);\n\t\t\tTextLocation position = textArea.Caret.Position;\n\t\t\tList<FoldMarker> foldings = textArea.Document.FoldingManager.GetFoldedFoldingsWithStart(position.Y);\n\t\t\tFoldMarker justBehindCaret = null;\n\t\t\tforeach (FoldMarker fm in foldings) {\n\t\t\t\tif (fm.StartColumn == position.X) {\n\t\t\t\t\tjustBehindCaret = fm;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (justBehindCaret != null) {\n\t\t\t\tposition.Y = justBehindCaret.EndLine;\n\t\t\t\tposition.X = justBehindCaret.EndColumn;\n\t\t\t} else { // no folding is interesting\n\t\t\t\tif (position.X < curLine.Length || textArea.TextEditorProperties.AllowCaretBeyondEOL) {\n\t\t\t\t\t++position.X;\n\t\t\t\t} else if (position.Y + 1 < textArea.Document.TotalNumberOfLines) {\n\t\t\t\t\t++position.Y;\n\t\t\t\t\tposition.X = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\ttextArea.Caret.Position = position;\n\t\t\ttextArea.SetDesiredColumn();\n\t\t}\n\t}\n\t\n\tpublic class CaretUp : AbstractEditAction\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tTextLocation position = textArea.Caret.Position;\n\t\t\tint lineNr = position.Y;\n\t\t\tint visualLine = textArea.Document.GetVisibleLine(lineNr);\n\t\t\tif (visualLine > 0) {\n\t\t\t\tPoint pos = new Point(textArea.TextView.GetDrawingXPos(lineNr, position.X),\n\t\t\t\t                      textArea.TextView.DrawingPosition.Y + (visualLine - 1) * textArea.TextView.FontHeight - textArea.TextView.TextArea.VirtualTop.Y);\n\t\t\t\ttextArea.Caret.Position = textArea.TextView.GetLogicalPosition(pos);\n\t\t\t\ttextArea.SetCaretToDesiredColumn();\n\t\t\t}\n//\t\t\tif (textArea.Caret.Line  > 0) {\n//\t\t\t\ttextArea.SetCaretToDesiredColumn(textArea.Caret.Line - 1);\n//\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic class CaretDown : AbstractEditAction\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tTextLocation position = textArea.Caret.Position;\n\t\t\tint lineNr = position.Y;\n\t\t\tint visualLine = textArea.Document.GetVisibleLine(lineNr);\n\t\t\tif (visualLine < textArea.Document.GetVisibleLine(textArea.Document.TotalNumberOfLines)) {\n\t\t\t\tPoint pos = new Point(textArea.TextView.GetDrawingXPos(lineNr, position.X),\n\t\t\t\t                      textArea.TextView.DrawingPosition.Y\n\t\t\t\t                      + (visualLine + 1) * textArea.TextView.FontHeight\n\t\t\t\t                      - textArea.TextView.TextArea.VirtualTop.Y);\n\t\t\t\ttextArea.Caret.Position = textArea.TextView.GetLogicalPosition(pos);\n\t\t\t\ttextArea.SetCaretToDesiredColumn();\n\t\t\t}\n//\t\t\tif (textArea.Caret.Line + 1 < textArea.Document.TotalNumberOfLines) {\n//\t\t\t\ttextArea.SetCaretToDesiredColumn(textArea.Caret.Line + 1);\n//\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic class WordRight : CaretRight\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tLineSegment line   = textArea.Document.GetLineSegment(textArea.Caret.Position.Y);\n\t\t\tTextLocation oldPos = textArea.Caret.Position;\n\t\t\tTextLocation newPos;\n\t\t\tif (textArea.Caret.Column >= line.Length) {\n\t\t\t\tnewPos = new TextLocation(0, textArea.Caret.Line + 1);\n\t\t\t} else {\n\t\t\t\tint nextWordStart = TextUtilities.FindNextWordStart(textArea.Document, textArea.Caret.Offset);\n\t\t\t\tnewPos = textArea.Document.OffsetToPosition(nextWordStart);\n\t\t\t}\n\t\t\t\n\t\t\t// handle fold markers\n\t\t\tList<FoldMarker> foldings = textArea.Document.FoldingManager.GetFoldingsFromPosition(newPos.Y, newPos.X);\n\t\t\tforeach (FoldMarker marker in foldings) {\n\t\t\t\tif (marker.IsFolded) {\n\t\t\t\t\tif (oldPos.X == marker.StartColumn && oldPos.Y == marker.StartLine) {\n\t\t\t\t\t\tnewPos = new TextLocation(marker.EndColumn, marker.EndLine);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnewPos = new TextLocation(marker.StartColumn, marker.StartLine);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\ttextArea.Caret.Position = newPos;\n\t\t\ttextArea.SetDesiredColumn();\n\t\t}\n\t}\n\t\n\tpublic class WordLeft : CaretLeft\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tTextLocation oldPos = textArea.Caret.Position;\n\t\t\tif (textArea.Caret.Column == 0) {\n\t\t\t\tbase.Execute(textArea);\n\t\t\t} else {\n\t\t\t\tLineSegment line   = textArea.Document.GetLineSegment(textArea.Caret.Position.Y);\n\t\t\t\t\n\t\t\t\tint prevWordStart = TextUtilities.FindPrevWordStart(textArea.Document, textArea.Caret.Offset);\n\t\t\t\t\n\t\t\t\tTextLocation newPos = textArea.Document.OffsetToPosition(prevWordStart);\n\t\t\t\t\n\t\t\t\t// handle fold markers\n\t\t\t\tList<FoldMarker> foldings = textArea.Document.FoldingManager.GetFoldingsFromPosition(newPos.Y, newPos.X);\n\t\t\t\tforeach (FoldMarker marker in foldings) {\n\t\t\t\t\tif (marker.IsFolded) {\n\t\t\t\t\t\tif (oldPos.X == marker.EndColumn && oldPos.Y == marker.EndLine) {\n\t\t\t\t\t\t\tnewPos = new TextLocation(marker.StartColumn, marker.StartLine);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnewPos = new TextLocation(marker.EndColumn, marker.EndLine);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ttextArea.Caret.Position = newPos;\n\t\t\t\ttextArea.SetDesiredColumn();\n\t\t\t}\n\t\t\t\n\t\t\t\n\t\t}\n\t}\n\t\n\tpublic class ScrollLineUp : AbstractEditAction\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\ttextArea.AutoClearSelection = false;\n\t\t\t\n\t\t\ttextArea.MotherTextAreaControl.VScrollBar.Value = Math.Max(textArea.MotherTextAreaControl.VScrollBar.Minimum,\n\t\t\t                                                           textArea.VirtualTop.Y - textArea.TextView.FontHeight);\n\t\t}\n\t}\n\t\n\tpublic class ScrollLineDown : AbstractEditAction\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\ttextArea.AutoClearSelection = false;\n\t\t\ttextArea.MotherTextAreaControl.VScrollBar.Value = Math.Min(textArea.MotherTextAreaControl.VScrollBar.Maximum,\n\t\t\t                                                           textArea.VirtualTop.Y + textArea.TextView.FontHeight);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Actions/ClipBoardActions.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 1965 $</version>\n// </file>\n\nusing System;\n\nnamespace ICSharpCode.TextEditor.Actions \n{\n\tpublic class Cut : AbstractEditAction\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tif (textArea.Document.ReadOnly) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttextArea.ClipboardHandler.Cut(null, null);\n\t\t}\n\t}\n\t\n\tpublic class Copy : AbstractEditAction\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\ttextArea.AutoClearSelection = false;\n\t\t\ttextArea.ClipboardHandler.Copy(null, null);\n\t\t}\n\t}\n\n\tpublic class Paste : AbstractEditAction\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tif (textArea.Document.ReadOnly) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttextArea.ClipboardHandler.Paste(null, null);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Actions/FindReplaceAction.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace ICSharpCode.TextEditor.Actions\n{\n    public class FindReplaceAction : AbstractEditAction\n    {\n        public override void Execute(TextArea textArea)\n        {\n            ICSharpCode.TextEditor.FindAndReplaceForm frm = new FindAndReplaceForm();\n            frm.ShowFor(textArea.MotherTextEditorControl, false);\n        }\n    }\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Actions/FoldActions.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 2972 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\nusing ICSharpCode.TextEditor.Document;\n\nnamespace ICSharpCode.TextEditor.Actions\n{\n\tpublic class ToggleFolding : AbstractEditAction\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tList<FoldMarker> foldMarkers = textArea.Document.FoldingManager.GetFoldingsWithStart(textArea.Caret.Line);\n\t\t\tif (foldMarkers.Count != 0) {\n\t\t\t\tforeach (FoldMarker fm in foldMarkers)\n\t\t\t\t\tfm.IsFolded = !fm.IsFolded;\n\t\t\t} else {\n\t\t\t\tfoldMarkers = textArea.Document.FoldingManager.GetFoldingsContainsLineNumber(textArea.Caret.Line);\n\t\t\t\tif (foldMarkers.Count != 0) {\n\t\t\t\t\tFoldMarker innerMost = foldMarkers[0];\n\t\t\t\t\tfor (int i = 1; i < foldMarkers.Count; i++) {\n\t\t\t\t\t\tif (new TextLocation(foldMarkers[i].StartColumn, foldMarkers[i].StartLine) >\n\t\t\t\t\t\t    new TextLocation(innerMost.StartColumn, innerMost.StartLine))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tinnerMost = foldMarkers[i];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tinnerMost.IsFolded = !innerMost.IsFolded;\n\t\t\t\t}\n\t\t\t}\n\t\t\ttextArea.Document.FoldingManager.NotifyFoldingsChanged(EventArgs.Empty);\n\t\t}\n\t}\n\t\n\tpublic class ToggleAllFoldings : AbstractEditAction\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tbool doFold = true;\n\t\t\tforeach (FoldMarker fm in  textArea.Document.FoldingManager.FoldMarker) {\n\t\t\t\tif (fm.IsFolded) {\n\t\t\t\t\tdoFold = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tforeach (FoldMarker fm in  textArea.Document.FoldingManager.FoldMarker) {\n\t\t\t\tfm.IsFolded = doFold;\n\t\t\t}\n\t\t\ttextArea.Document.FoldingManager.NotifyFoldingsChanged(EventArgs.Empty);\n\t\t}\n\t}\n\t\n\tpublic class ShowDefinitionsOnly : AbstractEditAction\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tforeach (FoldMarker fm in  textArea.Document.FoldingManager.FoldMarker) {\n\t\t\t\tfm.IsFolded = fm.FoldType == FoldType.MemberBody || fm.FoldType == FoldType.Region;\n\t\t\t}\n\t\t\ttextArea.Document.FoldingManager.NotifyFoldingsChanged(EventArgs.Empty);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Actions/FormatActions.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 2640 $</version>\n// </file>\n\nusing System;\nusing System.Text;\nusing ICSharpCode.TextEditor.Document;\n\nnamespace ICSharpCode.TextEditor.Actions \n{\n\tpublic abstract class AbstractLineFormatAction : AbstractEditAction\n\t{\n\t\tprotected TextArea textArea;\n\t\tabstract protected void Convert(IDocument document, int startLine, int endLine);\n\t\t\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tthis.textArea = textArea;\n\t\t\ttextArea.BeginUpdate();\n\t\t\ttextArea.Document.UndoStack.StartUndoGroup();\n\t\t\tif (textArea.SelectionManager.HasSomethingSelected) {\n\t\t\t\tforeach (ISelection selection in textArea.SelectionManager.SelectionCollection) {\n\t\t\t\t\tConvert(textArea.Document, selection.StartPosition.Y, selection.EndPosition.Y);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tConvert(textArea.Document, 0, textArea.Document.TotalNumberOfLines - 1);\n\t\t\t}\n\t\t\ttextArea.Document.UndoStack.EndUndoGroup();\n\t\t\ttextArea.Caret.ValidateCaretPos();\n\t\t\ttextArea.EndUpdate();\n\t\t\ttextArea.Refresh();\n\t\t}\n\t}\n\t\n\tpublic abstract class AbstractSelectionFormatAction : AbstractEditAction\n\t{\n\t\tprotected TextArea textArea;\n\t\tabstract protected void Convert(IDocument document, int offset, int length);\n\t\t\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tthis.textArea = textArea;\n\t\t\ttextArea.BeginUpdate();\n\t\t\tif (textArea.SelectionManager.HasSomethingSelected) {\n\t\t\t\tforeach (ISelection selection in textArea.SelectionManager.SelectionCollection) {\n\t\t\t\t\tConvert(textArea.Document, selection.Offset, selection.Length);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tConvert(textArea.Document, 0, textArea.Document.TextLength);\n\t\t\t}\n\t\t\ttextArea.Caret.ValidateCaretPos();\n\t\t\ttextArea.EndUpdate();\n\t\t\ttextArea.Refresh();\n\t\t}\n\t}\n\t\n\tpublic class RemoveLeadingWS : AbstractLineFormatAction\n\t{\n\t\tprotected override void Convert(IDocument document, int y1, int y2) \n\t\t{\n\t\t\tfor (int i = y1; i < y2; ++i) {\n\t\t\t\tLineSegment line = document.GetLineSegment(i);\n\t\t\t\tint removeNumber = 0;\n\t\t\t\tfor (int x = line.Offset; x < line.Offset + line.Length && Char.IsWhiteSpace(document.GetCharAt(x)); ++x) {\n\t\t\t\t\t++removeNumber;\n\t\t\t\t}\n\t\t\t\tif (removeNumber > 0) {\n\t\t\t\t\tdocument.Remove(line.Offset, removeNumber);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic class RemoveTrailingWS : AbstractLineFormatAction\n\t{\n\t\tprotected override void Convert(IDocument document, int y1, int y2) \n\t\t{\n\t\t\tfor (int i = y2 - 1; i >= y1; --i) {\n\t\t\t\tLineSegment line = document.GetLineSegment(i);\n\t\t\t\tint removeNumber = 0;\n\t\t\t\tfor (int x = line.Offset + line.Length - 1; x >= line.Offset && Char.IsWhiteSpace(document.GetCharAt(x)); --x) {\n\t\t\t\t\t++removeNumber;\n\t\t\t\t}\n\t\t\t\tif (removeNumber > 0) {\n\t\t\t\t\tdocument.Remove(line.Offset + line.Length - removeNumber, removeNumber);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\t\n\tpublic class ToUpperCase : AbstractSelectionFormatAction\n\t{\n\t\tprotected override void Convert(IDocument document, int startOffset, int length)\n\t\t{\n\t\t\tstring what = document.GetText(startOffset, length).ToUpper();\n\t\t\tdocument.Replace(startOffset, length, what);\n\t\t}\n\t}\n\t\n\tpublic class ToLowerCase : AbstractSelectionFormatAction\n\t{\n\t\tprotected override void Convert(IDocument document, int startOffset, int length)\n\t\t{\n\t\t\tstring what = document.GetText(startOffset, length).ToLower();\n\t\t\tdocument.Replace(startOffset, length, what);\n\t\t}\n\t}\n\t\n\tpublic class InvertCaseAction : AbstractSelectionFormatAction\n\t{\n\t\tprotected override void Convert(IDocument document, int startOffset, int length)\n\t\t{\n\t\t\tStringBuilder what = new StringBuilder(document.GetText(startOffset, length));\n\t\t\t\n\t\t\tfor (int i = 0; i < what.Length; ++i) {\n\t\t\t\twhat[i] = Char.IsUpper(what[i]) ? Char.ToLower(what[i]) : Char.ToUpper(what[i]);\n\t\t\t}\n\t\t\t\n\t\t\tdocument.Replace(startOffset, length, what.ToString());\n\t\t}\n\t}\n\t\n\tpublic class CapitalizeAction : AbstractSelectionFormatAction\n\t{\n\t\tprotected override void Convert(IDocument document, int startOffset, int length)\n\t\t{\n\t\t\tStringBuilder what = new StringBuilder(document.GetText(startOffset, length));\n\t\t\t\n\t\t\tfor (int i = 0; i < what.Length; ++i) {\n\t\t\t\tif (!Char.IsLetter(what[i]) && i < what.Length - 1) {\n\t\t\t\t\twhat[i + 1] = Char.ToUpper(what[i + 1]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tdocument.Replace(startOffset, length, what.ToString());\n\t\t}\n\t\t\n\t}\n\t\n\tpublic class ConvertTabsToSpaces : AbstractSelectionFormatAction\n\t{\n\t\tprotected override void Convert(IDocument document, int startOffset, int length)\n\t\t{\n\t\t\tstring what = document.GetText(startOffset, length);\n\t\t\tstring spaces = new string(' ', document.TextEditorProperties.TabIndent);\n\t\t\tdocument.Replace(startOffset, length, what.Replace(\"\\t\", spaces));\n\t\t}\n\t}\n\t\n\tpublic class ConvertSpacesToTabs : AbstractSelectionFormatAction\n\t{\n\t\tprotected override void Convert(IDocument document, int startOffset, int length)\n\t\t{\n\t\t\tstring what = document.GetText(startOffset, length);\n\t\t\tstring spaces = new string(' ', document.TextEditorProperties.TabIndent);\n\t\t\tdocument.Replace(startOffset, length, what.Replace(spaces, \"\\t\"));\n\t\t}\n\t}\n\t\n\tpublic class ConvertLeadingTabsToSpaces : AbstractLineFormatAction\n\t{\n\t\tprotected override void Convert(IDocument document, int y1, int y2) \n\t\t{\n\t\t\tfor (int i = y2; i >= y1; --i) {\n\t\t\t\tLineSegment line = document.GetLineSegment(i);\n\t\t\t\t\n\t\t\t\tif(line.Length > 0) {\n\t\t\t\t\t// count how many whitespace characters there are at the start\n\t\t\t\t\tint whiteSpace = 0;\n\t\t\t\t\tfor(whiteSpace = 0; whiteSpace < line.Length && Char.IsWhiteSpace(document.GetCharAt(line.Offset + whiteSpace)); whiteSpace++) {\n\t\t\t\t\t\t// deliberately empty\n\t\t\t\t\t}\n\t\t\t\t\tif(whiteSpace > 0) {\n\t\t\t\t\t\tstring newLine = document.GetText(line.Offset,whiteSpace);\n\t\t\t\t\t\tstring newPrefix = newLine.Replace(\"\\t\",new string(' ', document.TextEditorProperties.TabIndent));\n\t\t\t\t\t\tdocument.Replace(line.Offset,whiteSpace,newPrefix);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic class ConvertLeadingSpacesToTabs : AbstractLineFormatAction\n\t{\n\t\tprotected override void Convert(IDocument document, int y1, int y2) \n\t\t{\n\t\t\tfor (int i = y2; i >= y1; --i) {\n\t\t\t\tLineSegment line = document.GetLineSegment(i);\n\t\t\t\tif(line.Length > 0) {\n\t\t\t\t\t// note: some users may prefer a more radical ConvertLeadingSpacesToTabs that\n\t\t\t\t\t// means there can be no spaces before the first character even if the spaces\n\t\t\t\t\t// didn't add up to a whole number of tabs\n\t\t\t\t\tstring newLine = TextUtilities.LeadingWhiteSpaceToTabs(document.GetText(line.Offset,line.Length), document.TextEditorProperties.TabIndent);\n\t\t\t\t\tdocument.Replace(line.Offset,line.Length,newLine);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/// <summary>\n\t/// This is a sample editaction plugin, it indents the selected area.\n\t/// </summary>\n\tpublic class FormatBuffer : AbstractLineFormatAction\n\t{\n\t\tprotected override void Convert(IDocument document, int startLine, int endLine)\n\t\t{\n\t\t\tdocument.FormattingStrategy.IndentLines(textArea, startLine, endLine);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Actions/HomeEndActions.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 2659 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\nusing System.Drawing;\n\nusing ICSharpCode.TextEditor.Document;\n\nnamespace ICSharpCode.TextEditor.Actions\n{\n\tpublic class Home : AbstractEditAction\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tLineSegment curLine;\n\t\t\tTextLocation       newPos = textArea.Caret.Position;\n\t\t\tbool        jumpedIntoFolding = false;\n\t\t\tdo {\n\t\t\t\tcurLine = textArea.Document.GetLineSegment(newPos.Y);\n\t\t\t\t\n\t\t\t\tif (TextUtilities.IsEmptyLine(textArea.Document, newPos.Y)) {\n\t\t\t\t\tif (newPos.X != 0) {\n\t\t\t\t\t\tnewPos.X = 0;\n\t\t\t\t\t} else  {\n\t\t\t\t\t\tnewPos.X = curLine.Length;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tint firstCharOffset = TextUtilities.GetFirstNonWSChar(textArea.Document, curLine.Offset);\n\t\t\t\t\tint firstCharColumn = firstCharOffset - curLine.Offset;\n\t\t\t\t\t\n\t\t\t\t\tif (newPos.X == firstCharColumn) {\n\t\t\t\t\t\tnewPos.X = 0;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnewPos.X = firstCharColumn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tList<FoldMarker> foldings = textArea.Document.FoldingManager.GetFoldingsFromPosition(newPos.Y, newPos.X);\n\t\t\t\tjumpedIntoFolding = false;\n\t\t\t\tforeach (FoldMarker foldMarker in foldings) {\n\t\t\t\t\tif (foldMarker.IsFolded) {\n\t\t\t\t\t\tnewPos = new TextLocation(foldMarker.StartColumn, foldMarker.StartLine);\n\t\t\t\t\t\tjumpedIntoFolding = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t} while (jumpedIntoFolding);\n\t\t\t\n\t\t\tif (newPos != textArea.Caret.Position) {\n\t\t\t\ttextArea.Caret.Position = newPos;\n\t\t\t\ttextArea.SetDesiredColumn();\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic class End : AbstractEditAction\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tLineSegment curLine;\n\t\t\tTextLocation newPos = textArea.Caret.Position;\n\t\t\tbool jumpedIntoFolding = false;\n\t\t\tdo {\n\t\t\t\tcurLine  = textArea.Document.GetLineSegment(newPos.Y);\n\t\t\t\tnewPos.X = curLine.Length;\n\t\t\t\t\n\t\t\t\tList<FoldMarker> foldings = textArea.Document.FoldingManager.GetFoldingsFromPosition(newPos.Y, newPos.X);\n\t\t\t\tjumpedIntoFolding = false;\n\t\t\t\tforeach (FoldMarker foldMarker in foldings) {\n\t\t\t\t\tif (foldMarker.IsFolded) {\n\t\t\t\t\t\tnewPos = new TextLocation(foldMarker.EndColumn, foldMarker.EndLine);\n\t\t\t\t\t\tjumpedIntoFolding = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} while (jumpedIntoFolding);\n\t\t\t\n\t\t\tif (newPos != textArea.Caret.Position) {\n\t\t\t\ttextArea.Caret.Position = newPos;\n\t\t\t\ttextArea.SetDesiredColumn();\n\t\t\t}\n\t\t}\n\t}\n\t\n\t\n\tpublic class MoveToStart : AbstractEditAction\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tif (textArea.Caret.Line != 0 || textArea.Caret.Column != 0) {\n\t\t\t\ttextArea.Caret.Position = new TextLocation(0, 0);\n\t\t\t\ttextArea.SetDesiredColumn();\n\t\t\t}\n\t\t}\n\t}\n\t\n\t\n\tpublic class MoveToEnd : AbstractEditAction\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tTextLocation endPos = textArea.Document.OffsetToPosition(textArea.Document.TextLength);\n\t\t\tif (textArea.Caret.Position != endPos) {\n\t\t\t\ttextArea.Caret.Position = endPos;\n\t\t\t\ttextArea.SetDesiredColumn();\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Actions/IEditAction.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 1965 $</version>\n// </file>\n\nusing System;\nusing System.Windows.Forms;\n\nnamespace ICSharpCode.TextEditor.Actions\n{\n\t/// <summary>\n\t/// To define a new key for the textarea, you must write a class which\n\t/// implements this interface.\n\t/// </summary>\n\tpublic interface IEditAction\n\t{\n\t\t/// <value>\n\t\t/// An array of keys on which this edit action occurs.\n\t\t/// </value>\n\t\tKeys[] Keys {\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// When the key which is defined per XML is pressed, this method will be launched.\n\t\t/// </remarks>\n\t\tvoid Execute(TextArea textArea);\n\t}\n\t\n\t/// <summary>\n\t/// To define a new key for the textarea, you must write a class which\n\t/// implements this interface.\n\t/// </summary>\n\tpublic abstract class AbstractEditAction : IEditAction\n\t{\n\t\tKeys[] keys = null;\n\t\t\n\t\t/// <value>\n\t\t/// An array of keys on which this edit action occurs.\n\t\t/// </value>\n\t\tpublic Keys[] Keys {\n\t\t\tget {\n\t\t\t\treturn keys;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tkeys = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// When the key which is defined per XML is pressed, this method will be launched.\n\t\t/// </remarks>\n\t\tpublic abstract void Execute(TextArea textArea);\n\t}\t\t\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Actions/MiscActions.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 3205 $</version>\n// </file>\n\nusing System;\nusing System.Diagnostics;\nusing System.Drawing;\nusing System.Text;\n\nusing ICSharpCode.TextEditor.Document;\n\nnamespace ICSharpCode.TextEditor.Actions\n{\n\tpublic class Tab : AbstractEditAction\n\t{\n\t\tpublic static string GetIndentationString(IDocument document)\n\t\t{\n\t\t\treturn GetIndentationString(document, null);\n\t\t}\n\t\t\n\t\tpublic static string GetIndentationString(IDocument document, TextArea textArea)\n\t\t{\n\t\t\tStringBuilder indent = new StringBuilder();\n\t\t\t\n\t\t\tif (document.TextEditorProperties.ConvertTabsToSpaces) {\n\t\t\t\tint tabIndent = document.TextEditorProperties.IndentationSize;\n\t\t\t\tif (textArea != null) {\n\t\t\t\t\tint column = textArea.TextView.GetVisualColumn(textArea.Caret.Line, textArea.Caret.Column);\n\t\t\t\t\tindent.Append(new String(' ', tabIndent - column % tabIndent));\n\t\t\t\t} else {\n\t\t\t\t\tindent.Append(new String(' ', tabIndent));\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tindent.Append('\\t');\n\t\t\t}\n\t\t\treturn indent.ToString();\n\t\t}\n\t\t\n\t\tvoid InsertTabs(IDocument document, ISelection selection, int y1, int y2)\n\t\t{\n\t\t\tstring indentationString = GetIndentationString(document);\n\t\t\tfor (int i = y2; i >= y1; --i) {\n\t\t\t\tLineSegment line = document.GetLineSegment(i);\n\t\t\t\tif (i == y2 && i == selection.EndPosition.Y && selection.EndPosition.X  == 0) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// this bit is optional - but useful if you are using block tabbing to sort out\n\t\t\t\t// a source file with a mixture of tabs and spaces\n//\t\t\t\tstring newLine = document.GetText(line.Offset,line.Length);\n//\t\t\t\tdocument.Replace(line.Offset,line.Length,newLine);\n\t\t\t\t\n\t\t\t\tdocument.Insert(line.Offset, indentationString);\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid InsertTabAtCaretPosition(TextArea textArea)\n\t\t{\n\t\t\tswitch (textArea.Caret.CaretMode) {\n\t\t\t\tcase CaretMode.InsertMode:\n\t\t\t\t\ttextArea.InsertString(GetIndentationString(textArea.Document, textArea));\n\t\t\t\t\tbreak;\n\t\t\t\tcase CaretMode.OverwriteMode:\n\t\t\t\t\tstring indentStr = GetIndentationString(textArea.Document, textArea);\n\t\t\t\t\ttextArea.ReplaceChar(indentStr[0]);\n\t\t\t\t\tif (indentStr.Length > 1) {\n\t\t\t\t\t\ttextArea.InsertString(indentStr.Substring(1));\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\ttextArea.SetDesiredColumn();\n\t\t}\n\t\t/// <remarks>\n\t\t/// Executes this edit action\n\t\t/// </remarks>\n\t\t/// <param name=\"textArea\">The <see cref=\"ItextArea\"/> which is used for callback purposes</param>\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tif (textArea.Document.ReadOnly) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttextArea.Document.UndoStack.StartUndoGroup();\n\t\t\tif (textArea.SelectionManager.HasSomethingSelected) {\n\t\t\t\tforeach (ISelection selection in textArea.SelectionManager.SelectionCollection) {\n\t\t\t\t\tint startLine = selection.StartPosition.Y;\n\t\t\t\t\tint endLine   = selection.EndPosition.Y;\n\t\t\t\t\tif (startLine != endLine) {\n\t\t\t\t\t\ttextArea.BeginUpdate();\n\t\t\t\t\t\tInsertTabs(textArea.Document, selection, startLine, endLine);\n\t\t\t\t\t\ttextArea.Document.UpdateQueue.Clear();\n\t\t\t\t\t\ttextArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.LinesBetween, startLine, endLine));\n\t\t\t\t\t\ttextArea.EndUpdate();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tInsertTabAtCaretPosition(textArea);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ttextArea.Document.CommitUpdate();\n\t\t\t\ttextArea.AutoClearSelection = false;\n\t\t\t} else {\n\t\t\t\tInsertTabAtCaretPosition(textArea);\n\t\t\t}\n\t\t\ttextArea.Document.UndoStack.EndUndoGroup();\n\t\t}\n\t}\n\t\n\tpublic class ShiftTab : AbstractEditAction\n\t{\n\t\tvoid RemoveTabs(IDocument document, ISelection selection, int y1, int y2)\n\t\t{\n\t\t\tdocument.UndoStack.StartUndoGroup();\n\t\t\tfor (int i = y2; i >= y1; --i) {\n\t\t\t\tLineSegment line = document.GetLineSegment(i);\n\t\t\t\tif (i == y2 && line.Offset == selection.EndOffset) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (line.Length > 0) {\n\t\t\t\t\t/**** TextPad Strategy:\n\t\t\t\t\t/// first convert leading whitespace to tabs (controversial! - not all editors work like this)\n\t\t\t\t\tstring newLine = TextUtilities.LeadingWhiteSpaceToTabs(document.GetText(line.Offset,line.Length),document.Properties.Get(\"TabIndent\", 4));\n\t\t\t\t\tif(newLine.Length > 0 && newLine[0] == '\\t') {\n\t\t\t\t\t\tdocument.Replace(line.Offset,line.Length,newLine.Substring(1));\n\t\t\t\t\t\t++redocounter;\n\t\t\t\t\t}\n\t\t\t\t\telse if(newLine.Length > 0 && newLine[0] == ' ') {\n\t\t\t\t\t\t/// there were just some leading spaces but less than TabIndent of them\n\t\t\t\t\t\tint leadingSpaces = 1;\n\t\t\t\t\t\tfor(leadingSpaces = 1; leadingSpaces < newLine.Length && newLine[leadingSpaces] == ' '; leadingSpaces++) {\n\t\t\t\t\t\t\t/// deliberately empty\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdocument.Replace(line.Offset,line.Length,newLine.Substring(leadingSpaces));\n\t\t\t\t\t\t++redocounter;\n\t\t\t\t\t}\n\t\t\t\t\t/// else\n\t\t\t\t\t/// there were no leading tabs or spaces on this line so do nothing\n\t\t\t\t\t/// MS Visual Studio 6 strategy:\n\t\t\t\t\t ****/\n//\t\t\t\t\tstring temp = document.GetText(line.Offset,line.Length);\n\t\t\t\t\tif (line.Length > 0) {\n\t\t\t\t\t\tint charactersToRemove = 0;\n\t\t\t\t\t\tif(document.GetCharAt(line.Offset) == '\\t') { // first character is a tab - just remove it\n\t\t\t\t\t\t\tcharactersToRemove = 1;\n\t\t\t\t\t\t} else if(document.GetCharAt(line.Offset) == ' ') {\n\t\t\t\t\t\t\tint leadingSpaces = 1;\n\t\t\t\t\t\t\tint tabIndent = document.TextEditorProperties.IndentationSize;\n\t\t\t\t\t\t\tfor (leadingSpaces = 1; leadingSpaces < line.Length && document.GetCharAt(line.Offset + leadingSpaces) == ' '; leadingSpaces++) {\n\t\t\t\t\t\t\t\t// deliberately empty\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif(leadingSpaces >= tabIndent) {\n\t\t\t\t\t\t\t\t// just remove tabIndent\n\t\t\t\t\t\t\t\tcharactersToRemove = tabIndent;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if(line.Length > leadingSpaces && document.GetCharAt(line.Offset + leadingSpaces) == '\\t') {\n\t\t\t\t\t\t\t\t// remove the leading spaces and the following tab as they add up\n\t\t\t\t\t\t\t\t// to just one tab stop\n\t\t\t\t\t\t\t\tcharactersToRemove = leadingSpaces+1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t// just remove the leading spaces\n\t\t\t\t\t\t\t\tcharactersToRemove = leadingSpaces;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (charactersToRemove > 0) {\n\t\t\t\t\t\t\tdocument.Remove(line.Offset,charactersToRemove);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tdocument.UndoStack.EndUndoGroup();\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// Executes this edit action\n\t\t/// </remarks>\n\t\t/// <param name=\"textArea\">The <see cref=\"ItextArea\"/> which is used for callback purposes</param>\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tif (textArea.SelectionManager.HasSomethingSelected) {\n\t\t\t\tforeach (ISelection selection in textArea.SelectionManager.SelectionCollection) {\n\t\t\t\t\tint startLine = selection.StartPosition.Y;\n\t\t\t\t\tint endLine   = selection.EndPosition.Y;\n\t\t\t\t\ttextArea.BeginUpdate();\n\t\t\t\t\tRemoveTabs(textArea.Document, selection, startLine, endLine);\n\t\t\t\t\ttextArea.Document.UpdateQueue.Clear();\n\t\t\t\t\ttextArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.LinesBetween, startLine, endLine));\n\t\t\t\t\ttextArea.EndUpdate();\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\ttextArea.AutoClearSelection = false;\n\t\t\t} else {\n\t\t\t\t// Pressing Shift-Tab with nothing selected the cursor will move back to the\n\t\t\t\t// previous tab stop. It will stop at the beginning of the line. Also, the desired\n\t\t\t\t// column is updated to that column.\n\t\t\t\tLineSegment line = textArea.Document.GetLineSegmentForOffset(textArea.Caret.Offset);\n\t\t\t\tstring startOfLine = textArea.Document.GetText(line.Offset,textArea.Caret.Offset - line.Offset);\n\t\t\t\tint tabIndent = textArea.Document.TextEditorProperties.IndentationSize;\n\t\t\t\tint currentColumn = textArea.Caret.Column;\n\t\t\t\tint remainder = currentColumn % tabIndent;\n\t\t\t\tif (remainder == 0) {\n\t\t\t\t\ttextArea.Caret.DesiredColumn = Math.Max(0, currentColumn - tabIndent);\n\t\t\t\t} else {\n\t\t\t\t\ttextArea.Caret.DesiredColumn = Math.Max(0, currentColumn - remainder);\n\t\t\t\t}\n\t\t\t\ttextArea.SetCaretToDesiredColumn();\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic class ToggleComment : AbstractEditAction\n\t{\n\t\t/// <remarks>\n\t\t/// Executes this edit action\n\t\t/// </remarks>\n\t\t/// <param name=\"textArea\">The <see cref=\"ItextArea\"/> which is used for callback purposes</param>\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tif (textArea.Document.ReadOnly) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tif (textArea.Document.HighlightingStrategy.Properties.ContainsKey(\"LineComment\")) {\n\t\t\t\tnew ToggleLineComment().Execute(textArea);\n\t\t\t} else if (textArea.Document.HighlightingStrategy.Properties.ContainsKey(\"BlockCommentBegin\") &&\n\t\t\t           textArea.Document.HighlightingStrategy.Properties.ContainsKey(\"BlockCommentBegin\")) {\n\t\t\t\tnew ToggleBlockComment().Execute(textArea);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic class ToggleLineComment : AbstractEditAction\n\t{\n\t\tint firstLine;\n\t\tint lastLine;\n\t\t\n\t\tvoid RemoveCommentAt(IDocument document, string comment, ISelection selection, int y1, int y2)\n\t\t{\n\t\t\tfirstLine = y1;\n\t\t\tlastLine  = y2;\n\t\t\t\n\t\t\tfor (int i = y2; i >= y1; --i) {\n\t\t\t\tLineSegment line = document.GetLineSegment(i);\n\t\t\t\tif (selection != null && i == y2 && line.Offset == selection.Offset + selection.Length) {\n\t\t\t\t\t--lastLine;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tstring lineText = document.GetText(line.Offset, line.Length);\n\t\t\t\tif (lineText.Trim().StartsWith(comment)) {\n\t\t\t\t\tdocument.Remove(line.Offset + lineText.IndexOf(comment), comment.Length);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid SetCommentAt(IDocument document, string comment, ISelection selection, int y1, int y2)\n\t\t{\n\t\t\tfirstLine = y1;\n\t\t\tlastLine  = y2;\n\t\t\t\n\t\t\tfor (int i = y2; i >= y1; --i) {\n\t\t\t\tLineSegment line = document.GetLineSegment(i);\n\t\t\t\tif (selection != null && i == y2 && line.Offset == selection.Offset + selection.Length) {\n\t\t\t\t\t--lastLine;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tstring lineText = document.GetText(line.Offset, line.Length);\n\t\t\t\tdocument.Insert(line.Offset, comment);\n\t\t\t}\n\t\t}\n\t\t\n\t\tbool ShouldComment(IDocument document, string comment, ISelection selection, int startLine, int endLine)\n\t\t{\n\t\t\tfor (int i = endLine; i >= startLine; --i) {\n\t\t\t\tLineSegment line = document.GetLineSegment(i);\n\t\t\t\tif (selection != null && i == endLine && line.Offset == selection.Offset + selection.Length) {\n\t\t\t\t\t--lastLine;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tstring lineText = document.GetText(line.Offset, line.Length);\n\t\t\t\tif (!lineText.Trim().StartsWith(comment)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// Executes this edit action\n\t\t/// </remarks>\n\t\t/// <param name=\"textArea\">The <see cref=\"ItextArea\"/> which is used for callback purposes</param>\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tif (textArea.Document.ReadOnly) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tstring comment = null;\n\t\t\tif (textArea.Document.HighlightingStrategy.Properties.ContainsKey(\"LineComment\")) {\n\t\t\t\tcomment = textArea.Document.HighlightingStrategy.Properties[\"LineComment\"].ToString();\n\t\t\t}\n\t\t\t\n\t\t\tif (comment == null || comment.Length == 0) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\ttextArea.Document.UndoStack.StartUndoGroup();\n\t\t\tif (textArea.SelectionManager.HasSomethingSelected) {\n\t\t\t\tbool shouldComment = true;\n\t\t\t\tforeach (ISelection selection in textArea.SelectionManager.SelectionCollection) {\n\t\t\t\t\tif (!ShouldComment(textArea.Document, comment, selection, selection.StartPosition.Y, selection.EndPosition.Y)) {\n\t\t\t\t\t\tshouldComment = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tforeach (ISelection selection in textArea.SelectionManager.SelectionCollection) {\n\t\t\t\t\ttextArea.BeginUpdate();\n\t\t\t\t\tif (shouldComment) {\n\t\t\t\t\t\tSetCommentAt(textArea.Document, comment, selection, selection.StartPosition.Y, selection.EndPosition.Y);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tRemoveCommentAt(textArea.Document, comment, selection, selection.StartPosition.Y, selection.EndPosition.Y);\n\t\t\t\t\t}\n\t\t\t\t\ttextArea.Document.UpdateQueue.Clear();\n\t\t\t\t\ttextArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.LinesBetween, firstLine, lastLine));\n\t\t\t\t\ttextArea.EndUpdate();\n\t\t\t\t}\n\t\t\t\ttextArea.Document.CommitUpdate();\n\t\t\t\ttextArea.AutoClearSelection = false;\n\t\t\t} else {\n\t\t\t\ttextArea.BeginUpdate();\n\t\t\t\tint caretLine = textArea.Caret.Line;\n\t\t\t\tif (ShouldComment(textArea.Document, comment, null, caretLine, caretLine)) {\n\t\t\t\t\tSetCommentAt(textArea.Document, comment, null, caretLine, caretLine);\n\t\t\t\t} else {\n\t\t\t\t\tRemoveCommentAt(textArea.Document, comment, null, caretLine, caretLine);\n\t\t\t\t}\n\t\t\t\ttextArea.Document.UpdateQueue.Clear();\n\t\t\t\ttextArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, caretLine));\n\t\t\t\ttextArea.EndUpdate();\n\t\t\t}\n\t\t\ttextArea.Document.UndoStack.EndUndoGroup();\n\t\t}\n\t}\n\t\n\tpublic class ToggleBlockComment : AbstractEditAction\n\t{\n\t\t/// <remarks>\n\t\t/// Executes this edit action\n\t\t/// </remarks>\n\t\t/// <param name=\"textArea\">The <see cref=\"ItextArea\"/> which is used for callback purposes</param>\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tif (textArea.Document.ReadOnly) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tstring commentStart = null;\n\t\t\tif (textArea.Document.HighlightingStrategy.Properties.ContainsKey(\"BlockCommentBegin\")) {\n\t\t\t\tcommentStart = textArea.Document.HighlightingStrategy.Properties[\"BlockCommentBegin\"].ToString();\n\t\t\t}\n\t\t\t\n\t\t\tstring commentEnd = null;\n\t\t\tif (textArea.Document.HighlightingStrategy.Properties.ContainsKey(\"BlockCommentEnd\")) {\n\t\t\t\tcommentEnd = textArea.Document.HighlightingStrategy.Properties[\"BlockCommentEnd\"].ToString();\n\t\t\t}\n\t\t\t\n\t\t\tif (commentStart == null || commentStart.Length == 0 || commentEnd == null || commentEnd.Length == 0) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tint selectionStartOffset;\n\t\t\tint selectionEndOffset;\n\t\t\t\n\t\t\tif (textArea.SelectionManager.HasSomethingSelected) {\n\t\t\t\tselectionStartOffset = textArea.SelectionManager.SelectionCollection[0].Offset;\n\t\t\t\tselectionEndOffset = textArea.SelectionManager.SelectionCollection[textArea.SelectionManager.SelectionCollection.Count - 1].EndOffset;\n\t\t\t} else {\n\t\t\t\tselectionStartOffset = textArea.Caret.Offset;\n\t\t\t\tselectionEndOffset = selectionStartOffset;\n\t\t\t}\n\t\t\t\n\t\t\tBlockCommentRegion commentRegion = FindSelectedCommentRegion(textArea.Document, commentStart, commentEnd, selectionStartOffset, selectionEndOffset);\n\t\t\t\n\t\t\ttextArea.Document.UndoStack.StartUndoGroup();\n\t\t\tif (commentRegion != null) {\n\t\t\t\tRemoveComment(textArea.Document, commentRegion);\n\t\t\t} else if (textArea.SelectionManager.HasSomethingSelected) {\n\t\t\t\tSetCommentAt(textArea.Document, selectionStartOffset, selectionEndOffset, commentStart, commentEnd);\n\t\t\t}\n\t\t\ttextArea.Document.UndoStack.EndUndoGroup();\n\t\t\t\n\t\t\ttextArea.Document.CommitUpdate();\n\t\t\ttextArea.AutoClearSelection = false;\n\t\t}\n\t\t\n\t\tpublic static BlockCommentRegion FindSelectedCommentRegion(IDocument document, string commentStart, string commentEnd, int selectionStartOffset, int selectionEndOffset)\n\t\t{\n\t\t\tif (document.TextLength == 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\t\n\t\t\t// Find start of comment in selected text.\n\t\t\t\n\t\t\tint commentEndOffset = -1;\n\t\t\tstring selectedText = document.GetText(selectionStartOffset, selectionEndOffset - selectionStartOffset);\n\t\t\t\n\t\t\tint commentStartOffset = selectedText.IndexOf(commentStart);\n\t\t\tif (commentStartOffset >= 0) {\n\t\t\t\tcommentStartOffset += selectionStartOffset;\n\t\t\t}\n\n\t\t\t// Find end of comment in selected text.\n\t\t\t\n\t\t\tif (commentStartOffset >= 0) {\n\t\t\t\tcommentEndOffset = selectedText.IndexOf(commentEnd, commentStartOffset + commentStart.Length - selectionStartOffset);\n\t\t\t} else {\n\t\t\t\tcommentEndOffset = selectedText.IndexOf(commentEnd);\n\t\t\t}\n\t\t\t\n\t\t\tif (commentEndOffset >= 0) {\n\t\t\t\tcommentEndOffset += selectionStartOffset;\n\t\t\t}\n\t\t\t\n\t\t\t// Find start of comment before or partially inside the\n\t\t\t// selected text.\n\t\t\t\n\t\t\tint commentEndBeforeStartOffset = -1;\n\t\t\tif (commentStartOffset == -1) {\n\t\t\t\tint offset = selectionEndOffset + commentStart.Length - 1;\n\t\t\t\tif (offset > document.TextLength) {\n\t\t\t\t\toffset = document.TextLength;\n\t\t\t\t}\n\t\t\t\tstring text = document.GetText(0, offset);\n\t\t\t\tcommentStartOffset = text.LastIndexOf(commentStart);\n\t\t\t\tif (commentStartOffset >= 0) {\n\t\t\t\t\t// Find end of comment before comment start.\n\t\t\t\t\tcommentEndBeforeStartOffset = text.IndexOf(commentEnd, commentStartOffset, selectionStartOffset - commentStartOffset);\n\t\t\t\t\tif (commentEndBeforeStartOffset > commentStartOffset) {\n\t\t\t\t\t\tcommentStartOffset = -1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t// Find end of comment after or partially after the\n\t\t\t// selected text.\n\t\t\t\n\t\t\tif (commentEndOffset == -1) {\n\t\t\t\tint offset = selectionStartOffset + 1 - commentEnd.Length;\n\t\t\t\tif (offset < 0) {\n\t\t\t\t\toffset = selectionStartOffset;\n\t\t\t\t}\n\t\t\t\tstring text = document.GetText(offset, document.TextLength - offset);\n\t\t\t\tcommentEndOffset = text.IndexOf(commentEnd);\n\t\t\t\tif (commentEndOffset >= 0) {\n\t\t\t\t\tcommentEndOffset += offset;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (commentStartOffset != -1 && commentEndOffset != -1) {\n\t\t\t\treturn new BlockCommentRegion(commentStart, commentEnd, commentStartOffset, commentEndOffset);\n\t\t\t}\n\t\t\t\n\t\t\treturn null;\n\t\t}\n\t\t\n\n\t\tvoid SetCommentAt(IDocument document, int offsetStart, int offsetEnd, string commentStart, string commentEnd)\n\t\t{\n\t\t\tdocument.Insert(offsetEnd, commentEnd);\n\t\t\tdocument.Insert(offsetStart, commentStart);\n\t\t}\n\t\t\n\t\tvoid RemoveComment(IDocument document, BlockCommentRegion commentRegion)\n\t\t{\n\t\t\tdocument.Remove(commentRegion.EndOffset, commentRegion.CommentEnd.Length);\n\t\t\tdocument.Remove(commentRegion.StartOffset, commentRegion.CommentStart.Length);\n\t\t}\n\t}\n\t\n\tpublic class BlockCommentRegion\n\t{\n\t\tstring commentStart = String.Empty;\n\t\tstring commentEnd = String.Empty;\n\t\tint startOffset = -1;\n\t\tint endOffset = -1;\n\t\t\n\t\t/// <summary>\n\t\t/// The end offset is the offset where the comment end string starts from.\n\t\t/// </summary>\n\t\tpublic BlockCommentRegion(string commentStart, string commentEnd, int startOffset, int endOffset)\n\t\t{\n\t\t\tthis.commentStart = commentStart;\n\t\t\tthis.commentEnd = commentEnd;\n\t\t\tthis.startOffset = startOffset;\n\t\t\tthis.endOffset = endOffset;\n\t\t}\n\t\t\n\t\tpublic string CommentStart {\n\t\t\tget {\n\t\t\t\treturn commentStart;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic string CommentEnd {\n\t\t\tget {\n\t\t\t\treturn commentEnd;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int StartOffset {\n\t\t\tget {\n\t\t\t\treturn startOffset;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int EndOffset {\n\t\t\tget {\n\t\t\t\treturn endOffset;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic override int GetHashCode()\n\t\t{\n\t\t\tint hashCode = 0;\n\t\t\tunchecked {\n\t\t\t\tif (commentStart != null) hashCode += 1000000007 * commentStart.GetHashCode();\n\t\t\t\tif (commentEnd != null) hashCode += 1000000009 * commentEnd.GetHashCode();\n\t\t\t\thashCode += 1000000021 * startOffset.GetHashCode();\n\t\t\t\thashCode += 1000000033 * endOffset.GetHashCode();\n\t\t\t}\n\t\t\treturn hashCode;\n\t\t}\n\t\t\n\t\tpublic override bool Equals(object obj)\n\t\t{\n\t\t\tBlockCommentRegion other = obj as BlockCommentRegion;\n\t\t\tif (other == null) return false;\n\t\t\treturn this.commentStart == other.commentStart && this.commentEnd == other.commentEnd && this.startOffset == other.startOffset && this.endOffset == other.endOffset;\n\t\t}\n\t}\n\t\n\tpublic class IndentSelection : AbstractEditAction\n\t{\n\t\t/// <remarks>\n\t\t/// Executes this edit action\n\t\t/// </remarks>\n\t\t/// <param name=\"textArea\">The <see cref=\"ItextArea\"/> which is used for callback purposes</param>\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tif (textArea.Document.ReadOnly) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttextArea.BeginUpdate();\n\t\t\tif (textArea.SelectionManager.HasSomethingSelected) {\n\t\t\t\tforeach (ISelection selection in textArea.SelectionManager.SelectionCollection) {\n\t\t\t\t\ttextArea.Document.FormattingStrategy.IndentLines(textArea, selection.StartPosition.Y, selection.EndPosition.Y);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttextArea.Document.FormattingStrategy.IndentLines(textArea, 0, textArea.Document.TotalNumberOfLines - 1);\n\t\t\t}\n\t\t\ttextArea.EndUpdate();\n\t\t\ttextArea.Refresh();\n\t\t}\n\t}\n\t\n\tpublic class Backspace : AbstractEditAction\n\t{\n\t\t/// <remarks>\n\t\t/// Executes this edit action\n\t\t/// </remarks>\n\t\t/// <param name=\"textArea\">The <see cref=\"ItextArea\"/> which is used for callback purposes</param>\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tif (textArea.SelectionManager.HasSomethingSelected) {\n\t\t\t\tDelete.DeleteSelection(textArea);\n\t\t\t} else {\n\t\t\t\tif (textArea.Caret.Offset > 0 && !textArea.IsReadOnly(textArea.Caret.Offset - 1)) {\n\t\t\t\t\ttextArea.BeginUpdate();\n\t\t\t\t\tint curLineNr     = textArea.Document.GetLineNumberForOffset(textArea.Caret.Offset);\n\t\t\t\t\tint curLineOffset = textArea.Document.GetLineSegment(curLineNr).Offset;\n\t\t\t\t\t\n\t\t\t\t\tif (curLineOffset == textArea.Caret.Offset) {\n\t\t\t\t\t\tLineSegment line = textArea.Document.GetLineSegment(curLineNr - 1);\n\t\t\t\t\t\tbool lastLine = curLineNr == textArea.Document.TotalNumberOfLines;\n\t\t\t\t\t\tint lineEndOffset = line.Offset + line.Length;\n\t\t\t\t\t\tint lineLength = line.Length;\n\t\t\t\t\t\ttextArea.Document.Remove(lineEndOffset, curLineOffset - lineEndOffset);\n\t\t\t\t\t\ttextArea.Caret.Position = new TextLocation(lineLength, curLineNr - 1);\n\t\t\t\t\t\ttextArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.PositionToEnd, new TextLocation(0, curLineNr - 1)));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tint caretOffset = textArea.Caret.Offset - 1;\n\t\t\t\t\t\ttextArea.Caret.Position = textArea.Document.OffsetToPosition(caretOffset);\n\t\t\t\t\t\ttextArea.Document.Remove(caretOffset, 1);\n\t\t\t\t\t\t\n\t\t\t\t\t\ttextArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.PositionToLineEnd, new TextLocation(textArea.Caret.Offset - textArea.Document.GetLineSegment(curLineNr).Offset, curLineNr)));\n\t\t\t\t\t}\n\t\t\t\t\ttextArea.EndUpdate();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic class Delete : AbstractEditAction\n\t{\n\t\tinternal static void DeleteSelection(TextArea textArea)\n\t\t{\n\t\t\tDebug.Assert(textArea.SelectionManager.HasSomethingSelected);\n\t\t\tif (textArea.SelectionManager.SelectionIsReadonly)\n\t\t\t\treturn;\n\t\t\ttextArea.BeginUpdate();\n\t\t\ttextArea.Caret.Position = textArea.SelectionManager.SelectionCollection[0].StartPosition;\n\t\t\ttextArea.SelectionManager.RemoveSelectedText();\n\t\t\ttextArea.ScrollToCaret();\n\t\t\ttextArea.EndUpdate();\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// Executes this edit action\n\t\t/// </remarks>\n\t\t/// <param name=\"textArea\">The <see cref=\"ItextArea\"/> which is used for callback purposes</param>\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tif (textArea.SelectionManager.HasSomethingSelected) {\n\t\t\t\tDeleteSelection(textArea);\n\t\t\t} else {\n\t\t\t\tif (textArea.IsReadOnly(textArea.Caret.Offset))\n\t\t\t\t\treturn;\n\t\t\t\t\n\t\t\t\tif (textArea.Caret.Offset < textArea.Document.TextLength) {\n\t\t\t\t\ttextArea.BeginUpdate();\n\t\t\t\t\tint curLineNr   = textArea.Document.GetLineNumberForOffset(textArea.Caret.Offset);\n\t\t\t\t\tLineSegment curLine = textArea.Document.GetLineSegment(curLineNr);\n\t\t\t\t\t\n\t\t\t\t\tif (curLine.Offset + curLine.Length == textArea.Caret.Offset) {\n\t\t\t\t\t\tif (curLineNr + 1 < textArea.Document.TotalNumberOfLines) {\n\t\t\t\t\t\t\tLineSegment nextLine = textArea.Document.GetLineSegment(curLineNr + 1);\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\ttextArea.Document.Remove(textArea.Caret.Offset, nextLine.Offset - textArea.Caret.Offset);\n\t\t\t\t\t\t\ttextArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.PositionToEnd, new TextLocation(0, curLineNr)));\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttextArea.Document.Remove(textArea.Caret.Offset, 1);\n//\t\t\t\t\t\ttextArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.PositionToLineEnd, new TextLocation(textArea.Caret.Offset - textArea.Document.GetLineSegment(curLineNr).Offset, curLineNr)));\n\t\t\t\t\t}\n\t\t\t\t\ttextArea.UpdateMatchingBracket();\n\t\t\t\t\ttextArea.EndUpdate();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic class MovePageDown : AbstractEditAction\n\t{\n\t\t/// <remarks>\n\t\t/// Executes this edit action\n\t\t/// </remarks>\n\t\t/// <param name=\"textArea\">The <see cref=\"ItextArea\"/> which is used for callback purposes</param>\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tint curLineNr           = textArea.Caret.Line;\n\t\t\tint requestedLineNumber = Math.Min(textArea.Document.GetNextVisibleLineAbove(curLineNr, textArea.TextView.VisibleLineCount), textArea.Document.TotalNumberOfLines - 1);\n\t\t\t\n\t\t\tif (curLineNr != requestedLineNumber) {\n\t\t\t\ttextArea.Caret.Position = new TextLocation(0, requestedLineNumber);\n\t\t\t\ttextArea.SetCaretToDesiredColumn();\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic class MovePageUp : AbstractEditAction\n\t{\n\t\t/// <remarks>\n\t\t/// Executes this edit action\n\t\t/// </remarks>\n\t\t/// <param name=\"textArea\">The <see cref=\"ItextArea\"/> which is used for callback purposes</param>\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tint curLineNr           = textArea.Caret.Line;\n\t\t\tint requestedLineNumber = Math.Max(textArea.Document.GetNextVisibleLineBelow(curLineNr, textArea.TextView.VisibleLineCount), 0);\n\t\t\t\n\t\t\tif (curLineNr != requestedLineNumber) {\n\t\t\t\ttextArea.Caret.Position = new TextLocation(0, requestedLineNumber);\n\t\t\t\ttextArea.SetCaretToDesiredColumn();\n\t\t\t}\n\t\t}\n\t}\n\tpublic class Return : AbstractEditAction\n\t{\n\t\t/// <remarks>\n\t\t/// Executes this edit action\n\t\t/// </remarks>\n\t\t/// <param name=\"textArea\">The <see cref=\"TextArea\"/> which is used for callback purposes</param>\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tif (textArea.Document.ReadOnly) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttextArea.BeginUpdate();\n\t\t\ttextArea.Document.UndoStack.StartUndoGroup();\n\t\t\ttry {\n\t\t\t\tif (textArea.HandleKeyPress('\\n'))\n\t\t\t\t\treturn;\n\t\t\t\t\n\t\t\t\ttextArea.InsertString(Environment.NewLine);\n\t\t\t\t\n\t\t\t\tint curLineNr = textArea.Caret.Line;\n\t\t\t\ttextArea.Document.FormattingStrategy.FormatLine(textArea, curLineNr, textArea.Caret.Offset, '\\n');\n\t\t\t\ttextArea.SetDesiredColumn();\n\t\t\t\t\n\t\t\t\ttextArea.Document.UpdateQueue.Clear();\n\t\t\t\ttextArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.PositionToEnd, new TextLocation(0, curLineNr - 1)));\n\t\t\t} finally {\n\t\t\t\ttextArea.Document.UndoStack.EndUndoGroup();\n\t\t\t\ttextArea.EndUpdate();\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic class ToggleEditMode : AbstractEditAction\n\t{\n\t\t/// <remarks>\n\t\t/// Executes this edit action\n\t\t/// </remarks>\n\t\t/// <param name=\"textArea\">The <see cref=\"ItextArea\"/> which is used for callback purposes</param>\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tif (textArea.Document.ReadOnly) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tswitch (textArea.Caret.CaretMode) {\n\t\t\t\tcase CaretMode.InsertMode:\n\t\t\t\t\ttextArea.Caret.CaretMode = CaretMode.OverwriteMode;\n\t\t\t\t\tbreak;\n\t\t\t\tcase CaretMode.OverwriteMode:\n\t\t\t\t\ttextArea.Caret.CaretMode = CaretMode.InsertMode;\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic class Undo : AbstractEditAction\n\t{\n\t\t/// <remarks>\n\t\t/// Executes this edit action\n\t\t/// </remarks>\n\t\t/// <param name=\"textArea\">The <see cref=\"ItextArea\"/> which is used for callback purposes</param>\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\ttextArea.MotherTextEditorControl.Undo();\n\t\t}\n\t}\n\t\n\tpublic class Redo : AbstractEditAction\n\t{\n\t\t/// <remarks>\n\t\t/// Executes this edit action\n\t\t/// </remarks>\n\t\t/// <param name=\"textArea\">The <see cref=\"ItextArea\"/> which is used for callback purposes</param>\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\ttextArea.MotherTextEditorControl.Redo();\n\t\t}\n\t}\n\t\n\t/// <summary>\n\t/// handles the ctrl-backspace key\n\t/// functionality attempts to roughly mimic MS Developer studio\n\t/// I will implement this as deleting back to the point that ctrl-leftarrow would\n\t/// take you to\n\t/// </summary>\n\tpublic class WordBackspace : AbstractEditAction\n\t{\n\t\t/// <remarks>\n\t\t/// Executes this edit action\n\t\t/// </remarks>\n\t\t/// <param name=\"textArea\">The <see cref=\"ItextArea\"/> which is used for callback purposes</param>\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\t// if anything is selected we will just delete it first\n\t\t\tif (textArea.SelectionManager.HasSomethingSelected) {\n\t\t\t\tDelete.DeleteSelection(textArea);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttextArea.BeginUpdate();\n\t\t\t// now delete from the caret to the beginning of the word\n\t\t\tLineSegment line =\n\t\t\t\ttextArea.Document.GetLineSegmentForOffset(textArea.Caret.Offset);\n\t\t\t// if we are not at the beginning of a line\n\t\t\tif (textArea.Caret.Offset > line.Offset) {\n\t\t\t\tint prevWordStart = TextUtilities.FindPrevWordStart(textArea.Document,\n\t\t\t\t                                                    textArea.Caret.Offset);\n\t\t\t\tif (prevWordStart < textArea.Caret.Offset) {\n\t\t\t\t\tif (!textArea.IsReadOnly(prevWordStart, textArea.Caret.Offset - prevWordStart)) {\n\t\t\t\t\t\ttextArea.Document.Remove(prevWordStart,\n\t\t\t\t\t\t                         textArea.Caret.Offset - prevWordStart);\n\t\t\t\t\t\ttextArea.Caret.Position = textArea.Document.OffsetToPosition(prevWordStart);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t// if we are now at the beginning of a line\n\t\t\tif (textArea.Caret.Offset == line.Offset) {\n\t\t\t\t// if we are not on the first line\n\t\t\t\tint curLineNr = textArea.Document.GetLineNumberForOffset(textArea.Caret.Offset);\n\t\t\t\tif (curLineNr > 0) {\n\t\t\t\t\t// move to the end of the line above\n\t\t\t\t\tLineSegment lineAbove = textArea.Document.GetLineSegment(curLineNr - 1);\n\t\t\t\t\tint endOfLineAbove = lineAbove.Offset + lineAbove.Length;\n\t\t\t\t\tint charsToDelete = textArea.Caret.Offset - endOfLineAbove;\n\t\t\t\t\tif (!textArea.IsReadOnly(endOfLineAbove, charsToDelete)) {\n\t\t\t\t\t\ttextArea.Document.Remove(endOfLineAbove, charsToDelete);\n\t\t\t\t\t\ttextArea.Caret.Position = textArea.Document.OffsetToPosition(endOfLineAbove);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttextArea.SetDesiredColumn();\n\t\t\ttextArea.EndUpdate();\n\t\t\t// if there are now less lines, we need this or there are redraw problems\n\t\t\ttextArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.PositionToEnd, new TextLocation(0, textArea.Document.GetLineNumberForOffset(textArea.Caret.Offset))));\n\t\t\ttextArea.Document.CommitUpdate();\n\t\t}\n\t}\n\t\n\t/// <summary>\n\t/// handles the ctrl-delete key\n\t/// functionality attempts to mimic MS Developer studio\n\t/// I will implement this as deleting forwardto the point that\n\t/// ctrl-leftarrow would take you to\n\t/// </summary>\n\tpublic class DeleteWord : Delete\n\t{\n\t\t/// <remarks>\n\t\t/// Executes this edit action\n\t\t/// </remarks>\n\t\t/// <param name=\"textArea\">The <see cref=\"ItextArea\"/> which is used for callback purposes</param>\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tif (textArea.SelectionManager.HasSomethingSelected) {\n\t\t\t\tDeleteSelection(textArea);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// if anything is selected we will just delete it first\n\t\t\ttextArea.BeginUpdate();\n\t\t\t// now delete from the caret to the beginning of the word\n\t\t\tLineSegment line = textArea.Document.GetLineSegmentForOffset(textArea.Caret.Offset);\n\t\t\tif(textArea.Caret.Offset == line.Offset + line.Length) {\n\t\t\t\t// if we are at the end of a line\n\t\t\t\tbase.Execute(textArea);\n\t\t\t} else {\n\t\t\t\tint nextWordStart = TextUtilities.FindNextWordStart(textArea.Document,\n\t\t\t\t                                                    textArea.Caret.Offset);\n\t\t\t\tif(nextWordStart > textArea.Caret.Offset) {\n\t\t\t\t\tif (!textArea.IsReadOnly(textArea.Caret.Offset, nextWordStart - textArea.Caret.Offset)) {\n\t\t\t\t\t\ttextArea.Document.Remove(textArea.Caret.Offset, nextWordStart - textArea.Caret.Offset);\n\t\t\t\t\t\t// cursor never moves with this command\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttextArea.UpdateMatchingBracket();\n\t\t\ttextArea.EndUpdate();\n\t\t\t// if there are now less lines, we need this or there are redraw problems\n\t\t\ttextArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.PositionToEnd, new TextLocation(0, textArea.Document.GetLineNumberForOffset(textArea.Caret.Offset))));\n\t\t\ttextArea.Document.CommitUpdate();\n\t\t}\n\t}\n\t\n\tpublic class DeleteLine : AbstractEditAction\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tint lineNr = textArea.Caret.Line;\n\t\t\tLineSegment line = textArea.Document.GetLineSegment(lineNr);\n\t\t\tif (textArea.IsReadOnly(line.Offset, line.Length))\n\t\t\t\treturn;\n\t\t\ttextArea.Document.Remove(line.Offset, line.TotalLength);\n\t\t\ttextArea.Caret.Position = textArea.Document.OffsetToPosition(line.Offset);\n\n\t\t\ttextArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.PositionToEnd, new TextLocation(0, lineNr)));\n\t\t\ttextArea.UpdateMatchingBracket();\n\t\t\ttextArea.Document.CommitUpdate();\n\t\t}\n\t}\n\t\n\tpublic class DeleteToLineEnd : AbstractEditAction\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tint lineNr = textArea.Caret.Line;\n\t\t\tLineSegment line = textArea.Document.GetLineSegment(lineNr);\n\t\t\t\n\t\t\tint numRemove = (line.Offset + line.Length) - textArea.Caret.Offset;\n\t\t\tif (numRemove > 0 && !textArea.IsReadOnly(textArea.Caret.Offset, numRemove)) {\n\t\t\t\ttextArea.Document.Remove(textArea.Caret.Offset, numRemove);\n\t\t\t\ttextArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, new TextLocation(0, lineNr)));\n\t\t\t\ttextArea.Document.CommitUpdate();\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic class GotoMatchingBrace : AbstractEditAction\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tBracketHighlight highlight = textArea.FindMatchingBracketHighlight();\n\t\t\tif (highlight != null) {\n\t\t\t\tTextLocation p1 = new TextLocation(highlight.CloseBrace.X + 1, highlight.CloseBrace.Y);\n\t\t\t\tTextLocation p2 = new TextLocation(highlight.OpenBrace.X + 1, highlight.OpenBrace.Y);\n\t\t\t\tif (p1 == textArea.Caret.Position) {\n\t\t\t\t\tif (textArea.Document.TextEditorProperties.BracketMatchingStyle == BracketMatchingStyle.After) {\n\t\t\t\t\t\ttextArea.Caret.Position = p2;\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttextArea.Caret.Position = new TextLocation(p2.X - 1, p2.Y);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (textArea.Document.TextEditorProperties.BracketMatchingStyle == BracketMatchingStyle.After) {\n\t\t\t\t\t\ttextArea.Caret.Position = p1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttextArea.Caret.Position = new TextLocation(p1.X - 1, p1.Y);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ttextArea.SetDesiredColumn();\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Actions/SelectionActions.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 2659 $</version>\n// </file>\n\nusing System;\nusing System.Drawing;\nusing ICSharpCode.TextEditor.Document;\n\nnamespace ICSharpCode.TextEditor.Actions\n{\n\tpublic class ShiftCaretRight : CaretRight\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tTextLocation oldCaretPos  = textArea.Caret.Position;\n\t\t\tbase.Execute(textArea);\n\t\t\ttextArea.AutoClearSelection = false;\n\t\t\ttextArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);\n\t\t}\n\t}\n\t\n\tpublic class ShiftCaretLeft : CaretLeft\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tTextLocation oldCaretPos  = textArea.Caret.Position;\n\t\t\tbase.Execute(textArea);\n\t\t\ttextArea.AutoClearSelection = false;\n\t\t\ttextArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);\n\t\t}\n\t}\n\t\n\tpublic class ShiftCaretUp : CaretUp\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tTextLocation oldCaretPos  = textArea.Caret.Position;\n\t\t\tbase.Execute(textArea);\n\t\t\ttextArea.AutoClearSelection = false;\n\t\t\ttextArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);\n\t\t}\n\t}\n\t\n\tpublic class ShiftCaretDown : CaretDown\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tTextLocation oldCaretPos  = textArea.Caret.Position;\n\t\t\tbase.Execute(textArea);\n\t\t\ttextArea.AutoClearSelection = false;\n\t\t\ttextArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);\n\t\t}\n\t}\n\t\n\tpublic class ShiftWordRight : WordRight\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tTextLocation oldCaretPos  = textArea.Caret.Position;\n\t\t\tbase.Execute(textArea);\n\t\t\ttextArea.AutoClearSelection = false;\n\t\t\ttextArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);\n\t\t}\n\t}\n\t\n\tpublic class ShiftWordLeft : WordLeft\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tTextLocation oldCaretPos  = textArea.Caret.Position;\n\t\t\tbase.Execute(textArea);\n\t\t\ttextArea.AutoClearSelection = false;\n\t\t\ttextArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);\n\t\t}\n\t}\n\t\n\tpublic class ShiftHome : Home\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tTextLocation oldCaretPos  = textArea.Caret.Position;\n\t\t\tbase.Execute(textArea);\n\t\t\ttextArea.AutoClearSelection = false;\n\t\t\ttextArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);\n\t\t}\n\t}\n\t\n\tpublic class ShiftEnd : End\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tTextLocation oldCaretPos  = textArea.Caret.Position;\n\t\t\tbase.Execute(textArea);\n\t\t\ttextArea.AutoClearSelection = false;\n\t\t\ttextArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);\n\t\t}\n\t}\n\t\n\tpublic class ShiftMoveToStart : MoveToStart\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tTextLocation oldCaretPos  = textArea.Caret.Position;\n\t\t\tbase.Execute(textArea);\n\t\t\ttextArea.AutoClearSelection = false;\n\t\t\ttextArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);\n\t\t}\n\t}\n\t\n\tpublic class ShiftMoveToEnd : MoveToEnd\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tTextLocation oldCaretPos  = textArea.Caret.Position;\n\t\t\tbase.Execute(textArea);\n\t\t\ttextArea.AutoClearSelection = false;\n\t\t\ttextArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);\n\t\t}\n\t}\n\t\n\tpublic class ShiftMovePageUp : MovePageUp\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tTextLocation oldCaretPos  = textArea.Caret.Position;\n\t\t\tbase.Execute(textArea);\n\t\t\ttextArea.AutoClearSelection = false;\n\t\t\ttextArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);\n\t\t}\n\t}\n\t\n\tpublic class ShiftMovePageDown : MovePageDown\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\tTextLocation oldCaretPos  = textArea.Caret.Position;\n\t\t\tbase.Execute(textArea);\n\t\t\ttextArea.AutoClearSelection = false;\n\t\t\ttextArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);\n\t\t}\n\t}\n\t\n\tpublic class SelectWholeDocument : AbstractEditAction\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\ttextArea.AutoClearSelection = false;\n\t\t\tTextLocation startPoint = new TextLocation(0, 0);\n\t\t\tTextLocation endPoint   = textArea.Document.OffsetToPosition(textArea.Document.TextLength);\n\t\t\tif (textArea.SelectionManager.HasSomethingSelected) {\n\t\t\t\tif (textArea.SelectionManager.SelectionCollection[0].StartPosition == startPoint &&\n\t\t\t\t    textArea.SelectionManager.SelectionCollection[0].EndPosition   == endPoint) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\ttextArea.Caret.Position = textArea.SelectionManager.NextValidPosition(endPoint.Y);\n\t\t\ttextArea.SelectionManager.ExtendSelection(startPoint, endPoint);\n\t\t\t// after a SelectWholeDocument selection, the caret is placed correctly,\n\t\t\t// but it is not positioned internally.  The effect is when the cursor\n\t\t\t// is moved up or down a line, the caret will take on the column that\n\t\t\t// it was in before the SelectWholeDocument\n\t\t\ttextArea.SetDesiredColumn();\n\t\t}\n\t}\n\t\n\tpublic class ClearAllSelections : AbstractEditAction\n\t{\n\t\tpublic override void Execute(TextArea textArea)\n\t\t{\n\t\t\ttextArea.SelectionManager.ClearSelection();\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/AbstractSegment.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 1965 $</version>\n// </file>\n\nusing System;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\t/// <summary>\n\t/// This interface is used to describe a span inside a text sequence\n\t/// </summary>\n\tpublic class AbstractSegment : ISegment\n\t{\n\t\t[CLSCompliant(false)]\n\t\tprotected int offset = -1;\n\t\t[CLSCompliant(false)]\n\t\tprotected int length = -1;\n\t\t\n\t\t#region ICSharpCode.TextEditor.Document.ISegment interface implementation\n\t\tpublic virtual int Offset {\n\t\t\tget {\n\t\t\t\treturn offset;\n\t\t\t}\n\t\t\tset {\n\t\t\t\toffset = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic virtual int Length {\n\t\t\tget {\n\t\t\t\treturn length;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tlength = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\t#endregion\n\t\t\n\t\tpublic override string ToString()\n\t\t{\n\t\t\treturn String.Format(\"[AbstractSegment: Offset = {0}, Length = {1}]\",\n\t\t\t                     Offset,\n\t\t\t                     Length);\n\t\t}\n\t\t\n\t\t\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/BookmarkManager/Bookmark.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 3272 $</version>\n// </file>\n\nusing System;\nusing System.Drawing;\nusing SWF = System.Windows.Forms;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\t/// <summary>\n\t/// Description of Bookmark.\n\t/// </summary>\n\tpublic class Bookmark\n\t{\n\t\tIDocument document;\n\t\tTextAnchor anchor;\n\t\tTextLocation location;\n\t\tbool isEnabled = true;\n\t\t\n\t\tpublic IDocument Document {\n\t\t\tget {\n\t\t\t\treturn document;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tif (document != value) {\n\t\t\t\t\tif (anchor != null) {\n\t\t\t\t\t\tlocation = anchor.Location;\n\t\t\t\t\t\tanchor = null;\n\t\t\t\t\t}\n\t\t\t\t\tdocument = value;\n\t\t\t\t\tCreateAnchor();\n\t\t\t\t\tOnDocumentChanged(EventArgs.Empty);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid CreateAnchor()\n\t\t{\n\t\t\tif (document != null) {\n\t\t\t\tLineSegment line = document.GetLineSegment(Math.Max(0, Math.Min(location.Line, document.TotalNumberOfLines-1)));\n\t\t\t\tanchor = line.CreateAnchor(Math.Max(0, Math.Min(location.Column, line.Length)));\n\t\t\t\t// after insertion: keep bookmarks after the initial whitespace (see DefaultFormattingStrategy.SmartReplaceLine)\n\t\t\t\tanchor.MovementType = AnchorMovementType.AfterInsertion;\n\t\t\t\tanchor.Deleted += AnchorDeleted;\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid AnchorDeleted(object sender, EventArgs e)\n\t\t{\n\t\t\tdocument.BookmarkManager.RemoveMark(this);\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Gets the TextAnchor used for this bookmark.\n\t\t/// Is null if the bookmark is not connected to a document.\n\t\t/// </summary>\n\t\tpublic TextAnchor Anchor {\n\t\t\tget { return anchor; }\n\t\t}\n\t\t\n\t\tpublic TextLocation Location {\n\t\t\tget {\n\t\t\t\tif (anchor != null)\n\t\t\t\t\treturn anchor.Location;\n\t\t\t\telse\n\t\t\t\t\treturn location;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tlocation = value;\n\t\t\t\tCreateAnchor();\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic event EventHandler DocumentChanged;\n\t\t\n\t\tprotected virtual void OnDocumentChanged(EventArgs e)\n\t\t{\n\t\t\tif (DocumentChanged != null) {\n\t\t\t\tDocumentChanged(this, e);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic bool IsEnabled {\n\t\t\tget {\n\t\t\t\treturn isEnabled;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tif (isEnabled != value) {\n\t\t\t\t\tisEnabled = value;\n\t\t\t\t\tif (document != null) {\n\t\t\t\t\t\tdocument.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, LineNumber));\n\t\t\t\t\t\tdocument.CommitUpdate();\n\t\t\t\t\t}\n\t\t\t\t\tOnIsEnabledChanged(EventArgs.Empty);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic event EventHandler IsEnabledChanged;\n\t\t\n\t\tprotected virtual void OnIsEnabledChanged(EventArgs e)\n\t\t{\n\t\t\tif (IsEnabledChanged != null) {\n\t\t\t\tIsEnabledChanged(this, e);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int LineNumber {\n\t\t\tget {\n\t\t\t\tif (anchor != null)\n\t\t\t\t\treturn anchor.LineNumber;\n\t\t\t\telse\n\t\t\t\t\treturn location.Line;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int ColumnNumber {\n\t\t\tget {\n\t\t\t\tif (anchor != null)\n\t\t\t\t\treturn anchor.ColumnNumber;\n\t\t\t\telse\n\t\t\t\t\treturn location.Column;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Gets if the bookmark can be toggled off using the 'set/unset bookmark' command.\n\t\t/// </summary>\n\t\tpublic virtual bool CanToggle {\n\t\t\tget {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic Bookmark(IDocument document, TextLocation location) : this(document, location, true)\n\t\t{\n\t\t}\n\t\t\n\t\tpublic Bookmark(IDocument document, TextLocation location, bool isEnabled)\n\t\t{\n\t\t\tthis.document = document;\n\t\t\tthis.isEnabled = isEnabled;\n\t\t\tthis.Location = location;\n\t\t}\n\t\t\n\t\tpublic virtual bool Click(SWF.Control parent, SWF.MouseEventArgs e)\n\t\t{\n\t\t\tif (e.Button == SWF.MouseButtons.Left && CanToggle) {\n\t\t\t\tdocument.BookmarkManager.RemoveMark(this);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\tpublic virtual void Draw(IconBarMargin margin, Graphics g, Point p)\n\t\t{\n\t\t\tmargin.DrawBookmark(g, p.Y, isEnabled);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/BookmarkManager/BookmarkEventHandler.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 915 $</version>\n// </file>\n\nusing System;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\tpublic delegate void BookmarkEventHandler(object sender, BookmarkEventArgs e);\n\t\n\t/// <summary>\n\t/// Description of BookmarkEventHandler.\n\t/// </summary>\n\tpublic class BookmarkEventArgs : EventArgs\n\t{\n\t\tBookmark bookmark;\n\t\t\n\t\tpublic Bookmark Bookmark {\n\t\t\tget {\n\t\t\t\treturn bookmark;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic BookmarkEventArgs(Bookmark bookmark)\n\t\t{\n\t\t\tthis.bookmark = bookmark;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/BookmarkManager/BookmarkManager.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 3272 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\nusing System.Collections.ObjectModel;\nusing ICSharpCode.TextEditor.Util;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\tpublic interface IBookmarkFactory\n\t{\n\t\tBookmark CreateBookmark(IDocument document, TextLocation location);\n\t}\n\t\n\t/// <summary>\n\t/// This class handles the bookmarks for a buffer\n\t/// </summary>\n\tpublic class BookmarkManager\n\t{\n\t\tIDocument      document;\n\t\t#if DEBUG\n\t\tIList<Bookmark> bookmark = new CheckedList<Bookmark>();\n\t\t#else\n\t\tList<Bookmark> bookmark = new List<Bookmark>();\n\t\t#endif\n\t\t\n\t\t/// <value>\n\t\t/// Contains all bookmarks\n\t\t/// </value>\n\t\tpublic ReadOnlyCollection<Bookmark> Marks {\n\t\t\tget {\n\t\t\t\treturn new ReadOnlyCollection<Bookmark>(bookmark);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic IDocument Document {\n\t\t\tget {\n\t\t\t\treturn document;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Creates a new instance of <see cref=\"BookmarkManager\"/>\n\t\t/// </summary>\n\t\tinternal BookmarkManager(IDocument document, LineManager lineTracker)\n\t\t{\n\t\t\tthis.document = document;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Gets/Sets the bookmark factory used to create bookmarks for \"ToggleMarkAt\".\n\t\t/// </summary>\n\t\tpublic IBookmarkFactory Factory { get; set;}\n\t\t\n\t\t/// <summary>\n\t\t/// Sets the mark at the line <code>location.Line</code> if it is not set, if the\n\t\t/// line is already marked the mark is cleared.\n\t\t/// </summary>\n\t\tpublic void ToggleMarkAt(TextLocation location)\n\t\t{\n\t\t\tBookmark newMark;\n\t\t\tif (Factory != null) {\n\t\t\t\tnewMark = Factory.CreateBookmark(document, location);\n\t\t\t} else {\n\t\t\t\tnewMark = new Bookmark(document, location);\n\t\t\t}\n\t\t\t\n\t\t\tType newMarkType = newMark.GetType();\n\t\t\t\n\t\t\tfor (int i = 0; i < bookmark.Count; ++i) {\n\t\t\t\tBookmark mark = bookmark[i];\n\t\t\t\t\n\t\t\t\tif (mark.LineNumber == location.Line && mark.CanToggle && mark.GetType() == newMarkType) {\n\t\t\t\t\tbookmark.RemoveAt(i);\n\t\t\t\t\tOnRemoved(new BookmarkEventArgs(mark));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tbookmark.Add(newMark);\n\t\t\tOnAdded(new BookmarkEventArgs(newMark));\n\t\t}\n\t\t\n\t\tpublic void AddMark(Bookmark mark)\n\t\t{\n\t\t\tbookmark.Add(mark);\n\t\t\tOnAdded(new BookmarkEventArgs(mark));\n\t\t}\n\t\t\n\t\tpublic void RemoveMark(Bookmark mark)\n\t\t{\n\t\t\tbookmark.Remove(mark);\n\t\t\tOnRemoved(new BookmarkEventArgs(mark));\n\t\t}\n\t\t\n\t\tpublic void RemoveMarks(Predicate<Bookmark> predicate)\n\t\t{\n\t\t\tfor (int i = 0; i < bookmark.Count; ++i) {\n\t\t\t\tBookmark bm = bookmark[i];\n\t\t\t\tif (predicate(bm)) {\n\t\t\t\t\tbookmark.RemoveAt(i--);\n\t\t\t\t\tOnRemoved(new BookmarkEventArgs(bm));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <returns>\n\t\t/// true, if a mark at mark exists, otherwise false\n\t\t/// </returns>\n\t\tpublic bool IsMarked(int lineNr)\n\t\t{\n\t\t\tfor (int i = 0; i < bookmark.Count; ++i) {\n\t\t\t\tif (bookmark[i].LineNumber == lineNr) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// Clears all bookmark\n\t\t/// </remarks>\n\t\tpublic void Clear()\n\t\t{\n\t\t\tforeach (Bookmark mark in bookmark) {\n\t\t\t\tOnRemoved(new BookmarkEventArgs(mark));\n\t\t\t}\n\t\t\tbookmark.Clear();\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// The lowest mark, if no marks exists it returns -1\n\t\t/// </value>\n\t\tpublic Bookmark GetFirstMark(Predicate<Bookmark> predicate)\n\t\t{\n\t\t\tif (bookmark.Count < 1) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tBookmark first = null;\n\t\t\tfor (int i = 0; i < bookmark.Count; ++i) {\n\t\t\t\tif (predicate(bookmark[i]) && bookmark[i].IsEnabled && (first == null || bookmark[i].LineNumber < first.LineNumber)) {\n\t\t\t\t\tfirst = bookmark[i];\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn first;\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// The highest mark, if no marks exists it returns -1\n\t\t/// </value>\n\t\tpublic Bookmark GetLastMark(Predicate<Bookmark> predicate)\n\t\t{\n\t\t\tif (bookmark.Count < 1) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tBookmark last = null;\n\t\t\tfor (int i = 0; i < bookmark.Count; ++i) {\n\t\t\t\tif (predicate(bookmark[i]) && bookmark[i].IsEnabled && (last == null || bookmark[i].LineNumber > last.LineNumber)) {\n\t\t\t\t\tlast = bookmark[i];\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn last;\n\t\t}\n\t\tbool AcceptAnyMarkPredicate(Bookmark mark)\n\t\t{\n\t\t\treturn true;\n\t\t}\n\t\tpublic Bookmark GetNextMark(int curLineNr)\n\t\t{\n\t\t\treturn GetNextMark(curLineNr, AcceptAnyMarkPredicate);\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// returns first mark higher than <code>lineNr</code>\n\t\t/// </remarks>\n\t\t/// <returns>\n\t\t/// returns the next mark > cur, if it not exists it returns FirstMark()\n\t\t/// </returns>\n\t\tpublic Bookmark GetNextMark(int curLineNr, Predicate<Bookmark> predicate)\n\t\t{\n\t\t\tif (bookmark.Count == 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\t\n\t\t\tBookmark next = GetFirstMark(predicate);\n\t\t\tforeach (Bookmark mark in bookmark) {\n\t\t\t\tif (predicate(mark) && mark.IsEnabled && mark.LineNumber > curLineNr) {\n\t\t\t\t\tif (mark.LineNumber < next.LineNumber || next.LineNumber <= curLineNr) {\n\t\t\t\t\t\tnext = mark;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn next;\n\t\t}\n\t\t\n\t\tpublic Bookmark GetPrevMark(int curLineNr)\n\t\t{\n\t\t\treturn GetPrevMark(curLineNr, AcceptAnyMarkPredicate);\n\t\t}\n\t\t/// <remarks>\n\t\t/// returns first mark lower than <code>lineNr</code>\n\t\t/// </remarks>\n\t\t/// <returns>\n\t\t/// returns the next mark lower than cur, if it not exists it returns LastMark()\n\t\t/// </returns>\n\t\tpublic Bookmark GetPrevMark(int curLineNr, Predicate<Bookmark> predicate)\n\t\t{\n\t\t\tif (bookmark.Count == 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\t\n\t\t\tBookmark prev = GetLastMark(predicate);\n\t\t\t\n\t\t\tforeach (Bookmark mark in bookmark) {\n\t\t\t\tif (predicate(mark) && mark.IsEnabled && mark.LineNumber < curLineNr) {\n\t\t\t\t\tif (mark.LineNumber > prev.LineNumber || prev.LineNumber >= curLineNr) {\n\t\t\t\t\t\tprev = mark;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn prev;\n\t\t}\n\t\t\n\t\tprotected virtual void OnRemoved(BookmarkEventArgs e)\n\t\t{\n\t\t\tif (Removed != null) {\n\t\t\t\tRemoved(this, e);\n\t\t\t}\n\t\t}\n\t\t\n\t\tprotected virtual void OnAdded(BookmarkEventArgs e)\n\t\t{\n\t\t\tif (Added != null) {\n\t\t\t\tAdded(this, e);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic event BookmarkEventHandler Removed;\n\t\tpublic event BookmarkEventHandler Added;\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/BookmarkManager/BookmarkManagerMemento.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 915 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\nusing System.Xml;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\t/// <summary>\n\t/// This class is used for storing the state of a bookmark manager \n\t/// </summary>\n\tpublic class BookmarkManagerMemento\n\t{\n\t\tList<int> bookmarks = new List<int>();\n\t\t\n\t\t/// <value>\n\t\t/// Contains all bookmarks as int values\n\t\t/// </value>\n\t\tpublic List<int> Bookmarks {\n\t\t\tget {\n\t\t\t\treturn bookmarks;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tbookmarks = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Validates all bookmarks if they're in range of the document.\n\t\t/// (removing all bookmarks &lt; 0 and bookmarks &gt; max. line number\n\t\t/// </summary>\n\t\tpublic void CheckMemento(IDocument document)\n\t\t{\n\t\t\tfor (int i = 0; i < bookmarks.Count; ++i) {\n\t\t\t\tint mark = (int)bookmarks[i];\n\t\t\t\tif (mark < 0 || mark >= document.TotalNumberOfLines) {\n\t\t\t\t\tbookmarks.RemoveAt(i);\n\t\t\t\t\t--i;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Creates a new instance of <see cref=\"BookmarkManagerMemento\"/>\n\t\t/// </summary>\n\t\tpublic BookmarkManagerMemento()\n\t\t{\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Creates a new instance of <see cref=\"BookmarkManagerMemento\"/>\n\t\t/// </summary>\n\t\tpublic BookmarkManagerMemento(XmlElement element)\n\t\t{\n\t\t\tforeach (XmlElement el in element.ChildNodes) {\n\t\t\t\tbookmarks.Add(Int32.Parse(el.Attributes[\"line\"].InnerText));\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Creates a new instance of <see cref=\"BookmarkManagerMemento\"/>\n\t\t/// </summary>\n\t\tpublic BookmarkManagerMemento(List<int> bookmarks)\n\t\t{\n\t\t\tthis.bookmarks = bookmarks;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Converts a xml element to a <see cref=\"BookmarkManagerMemento\"/> object\n\t\t/// </summary>\n\t\tpublic object FromXmlElement(XmlElement element)\n\t\t{\n\t\t\treturn new BookmarkManagerMemento(element);\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Converts this <see cref=\"BookmarkManagerMemento\"/> to a xml element\n\t\t/// </summary>\n\t\tpublic XmlElement ToXmlElement(XmlDocument doc)\n\t\t{\n\t\t\tXmlElement bookmarknode  = doc.CreateElement(\"Bookmarks\");\n\t\t\t\n\t\t\tforeach (int line in bookmarks) {\n\t\t\t\tXmlElement markNode = doc.CreateElement(\"Mark\");\n\t\t\t\t\n\t\t\t\tXmlAttribute lineAttr = doc.CreateAttribute(\"line\");\n\t\t\t\tlineAttr.InnerText = line.ToString();\n\t\t\t\tmarkNode.Attributes.Append(lineAttr);\n\t\t\t\t\t\t\n\t\t\t\tbookmarknode.AppendChild(markNode);\n\t\t\t}\n\t\t\t\n\t\t\treturn bookmarknode;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/DefaultDocument.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 3205 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Drawing;\n\nusing ICSharpCode.TextEditor.Undo;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\t/// <summary>\n\t/// Describes the caret marker\n\t/// </summary>\n\tpublic enum LineViewerStyle {\n\t\t/// <summary>\n\t\t/// No line viewer will be displayed\n\t\t/// </summary>\n\t\tNone,\n\t\t\n\t\t/// <summary>\n\t\t/// The row in which the caret is will be marked\n\t\t/// </summary>\n\t\tFullRow\n\t}\n\n\t/// <summary>\n\t/// Describes the indent style\n\t/// </summary>\n\tpublic enum IndentStyle {\n\t\t/// <summary>\n\t\t/// No indentation occurs\n\t\t/// </summary>\n\t\tNone,\n\t\t\n\t\t/// <summary>\n\t\t/// The indentation from the line above will be\n\t\t/// taken to indent the curent line\n\t\t/// </summary>\n\t\tAuto,\n\t\t\n\t\t/// <summary>\n\t\t/// Inteligent, context sensitive indentation will occur\n\t\t/// </summary>\n\t\tSmart\n\t}\n\t\n\t/// <summary>\n\t/// Describes the bracket highlighting style\n\t/// </summary>\n\tpublic enum BracketHighlightingStyle {\n\t\t\n\t\t/// <summary>\n\t\t/// Brackets won't be highlighted\n\t\t/// </summary>\n\t\tNone,\n\t\t\n\t\t/// <summary>\n\t\t/// Brackets will be highlighted if the caret is on the bracket\n\t\t/// </summary>\n\t\tOnBracket,\n\t\t\n\t\t/// <summary>\n\t\t/// Brackets will be highlighted if the caret is after the bracket\n\t\t/// </summary>\n\t\tAfterBracket\n\t}\n\n\t/// <summary>\n\t/// Describes the selection mode of the text area\n\t/// </summary>\n\tpublic enum DocumentSelectionMode {\n\t\t/// <summary>\n\t\t/// The 'normal' selection mode.\n\t\t/// </summary>\n\t\tNormal,\n\t\t\n\t\t/// <summary>\n\t\t/// Selections will be added to the current selection or new\n\t\t/// ones will be created (multi-select mode)\n\t\t/// </summary>\n\t\tAdditive\n\t}\n\t\n\t/// <summary>\n\t/// The default <see cref=\"IDocument\"/> implementation.\n\t/// </summary>\n\tinternal sealed class DefaultDocument : IDocument\n\t{\n\t\tbool readOnly = false;\n\t\t\n\t\tLineManager           lineTrackingStrategy;\n\t\tBookmarkManager       bookmarkManager;\n\t\tITextBufferStrategy   textBufferStrategy;\n\t\tIFormattingStrategy   formattingStrategy;\n\t\tFoldingManager        foldingManager;\n\t\tUndoStack             undoStack = new UndoStack();\n\t\tITextEditorProperties textEditorProperties = new DefaultTextEditorProperties();\n\t\tMarkerStrategy        markerStrategy;\n\t\t\n\t\tpublic LineManager LineManager {\n\t\t\tget { return lineTrackingStrategy; }\n\t\t\tset { lineTrackingStrategy = value; }\n\t\t}\n\t\t\n\t\tpublic event EventHandler<LineLengthChangeEventArgs> LineLengthChanged {\n\t\t\tadd { lineTrackingStrategy.LineLengthChanged += value; }\n\t\t\tremove { lineTrackingStrategy.LineLengthChanged -= value; }\n\t\t}\n\t\tpublic event EventHandler<LineCountChangeEventArgs> LineCountChanged {\n\t\t\tadd { lineTrackingStrategy.LineCountChanged += value; }\n\t\t\tremove { lineTrackingStrategy.LineCountChanged -= value; }\n\t\t}\n\t\tpublic event EventHandler<LineEventArgs> LineDeleted {\n\t\t\tadd { lineTrackingStrategy.LineDeleted += value; }\n\t\t\tremove { lineTrackingStrategy.LineDeleted -= value; }\n\t\t}\n\t\t\n\t\tpublic MarkerStrategy MarkerStrategy {\n\t\t\tget { return markerStrategy; }\n\t\t\tset { markerStrategy = value; }\n\t\t}\n\t\t\n\t\tpublic ITextEditorProperties TextEditorProperties {\n\t\t\tget {\n\t\t\t\treturn textEditorProperties;\n\t\t\t}\n\t\t\tset {\n\t\t\t\ttextEditorProperties = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic UndoStack UndoStack {\n\t\t\tget {\n\t\t\t\treturn undoStack;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic IList<LineSegment> LineSegmentCollection {\n\t\t\tget {\n\t\t\t\treturn lineTrackingStrategy.LineSegmentCollection;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic bool ReadOnly {\n\t\t\tget {\n\t\t\t\treturn readOnly;\n\t\t\t}\n\t\t\tset {\n\t\t\t\treadOnly = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic ITextBufferStrategy TextBufferStrategy {\n\t\t\tget {\n\t\t\t\treturn textBufferStrategy;\n\t\t\t}\n\t\t\tset {\n\t\t\t\ttextBufferStrategy = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic IFormattingStrategy FormattingStrategy {\n\t\t\tget {\n\t\t\t\treturn formattingStrategy;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tformattingStrategy = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic FoldingManager FoldingManager {\n\t\t\tget {\n\t\t\t\treturn foldingManager;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tfoldingManager = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic IHighlightingStrategy HighlightingStrategy {\n\t\t\tget {\n\t\t\t\treturn lineTrackingStrategy.HighlightingStrategy;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tlineTrackingStrategy.HighlightingStrategy = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int TextLength {\n\t\t\tget {\n\t\t\t\treturn textBufferStrategy.Length;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic BookmarkManager BookmarkManager {\n\t\t\tget {\n\t\t\t\treturn bookmarkManager;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tbookmarkManager = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\tpublic string TextContent {\n\t\t\tget {\n\t\t\t\treturn GetText(0, textBufferStrategy.Length);\n\t\t\t}\n\t\t\tset {\n\t\t\t\tDebug.Assert(textBufferStrategy != null);\n\t\t\t\tDebug.Assert(lineTrackingStrategy != null);\n\t\t\t\tOnDocumentAboutToBeChanged(new DocumentEventArgs(this, 0, 0, value));\n\t\t\t\ttextBufferStrategy.SetContent(value);\n\t\t\t\tlineTrackingStrategy.SetContent(value);\n\t\t\t\tundoStack.ClearAll();\n\t\t\t\t\n\t\t\t\tOnDocumentChanged(new DocumentEventArgs(this, 0, 0, value));\n\t\t\t\tOnTextContentChanged(EventArgs.Empty);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic void Insert(int offset, string text)\n\t\t{\n\t\t\tif (readOnly) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tOnDocumentAboutToBeChanged(new DocumentEventArgs(this, offset, -1, text));\n\t\t\t\n\t\t\ttextBufferStrategy.Insert(offset, text);\n\t\t\tlineTrackingStrategy.Insert(offset, text);\n\t\t\t\n\t\t\tundoStack.Push(new UndoableInsert(this, offset, text));\n\t\t\t\n\t\t\tOnDocumentChanged(new DocumentEventArgs(this, offset, -1, text));\n\t\t}\n\t\t\n\t\tpublic void Remove(int offset, int length)\n\t\t{\n\t\t\tif (readOnly) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tOnDocumentAboutToBeChanged(new DocumentEventArgs(this, offset, length));\n\t\t\tundoStack.Push(new UndoableDelete(this, offset, GetText(offset, length)));\n\t\t\t\n\t\t\ttextBufferStrategy.Remove(offset, length);\n\t\t\tlineTrackingStrategy.Remove(offset, length);\n\t\t\t\n\t\t\tOnDocumentChanged(new DocumentEventArgs(this, offset, length));\n\t\t}\n\t\t\n\t\tpublic void Replace(int offset, int length, string text)\n\t\t{\n\t\t\tif (readOnly) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tOnDocumentAboutToBeChanged(new DocumentEventArgs(this, offset, length, text));\n\t\t\tundoStack.Push(new UndoableReplace(this, offset, GetText(offset, length), text));\n\t\t\t\n\t\t\ttextBufferStrategy.Replace(offset, length, text);\n\t\t\tlineTrackingStrategy.Replace(offset, length, text);\n\t\t\t\n\t\t\tOnDocumentChanged(new DocumentEventArgs(this, offset, length, text));\n\t\t}\n\t\t\n\t\tpublic char GetCharAt(int offset)\n\t\t{\n\t\t\treturn textBufferStrategy.GetCharAt(offset);\n\t\t}\n\t\t\n\t\tpublic string GetText(int offset, int length)\n\t\t{\n\t\t\t#if DEBUG\n\t\t\tif (length < 0) throw new ArgumentOutOfRangeException(\"length\", length, \"length < 0\");\n\t\t\t#endif\n\t\t\treturn textBufferStrategy.GetText(offset, length);\n\t\t}\n\t\tpublic string GetText(ISegment segment)\n\t\t{\n\t\t\treturn GetText(segment.Offset, segment.Length);\n\t\t}\n\t\t\n\t\tpublic int TotalNumberOfLines {\n\t\t\tget {\n\t\t\t\treturn lineTrackingStrategy.TotalNumberOfLines;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int GetLineNumberForOffset(int offset)\n\t\t{\n\t\t\treturn lineTrackingStrategy.GetLineNumberForOffset(offset);\n\t\t}\n\t\t\n\t\tpublic LineSegment GetLineSegmentForOffset(int offset)\n\t\t{\n\t\t\treturn lineTrackingStrategy.GetLineSegmentForOffset(offset);\n\t\t}\n\t\t\n\t\tpublic LineSegment GetLineSegment(int line)\n\t\t{\n\t\t\treturn lineTrackingStrategy.GetLineSegment(line);\n\t\t}\n\t\t\n\t\tpublic int GetFirstLogicalLine(int lineNumber)\n\t\t{\n\t\t\treturn lineTrackingStrategy.GetFirstLogicalLine(lineNumber);\n\t\t}\n\t\t\n\t\tpublic int GetLastLogicalLine(int lineNumber)\n\t\t{\n\t\t\treturn lineTrackingStrategy.GetLastLogicalLine(lineNumber);\n\t\t}\n\t\t\n\t\tpublic int GetVisibleLine(int lineNumber)\n\t\t{\n\t\t\treturn lineTrackingStrategy.GetVisibleLine(lineNumber);\n\t\t}\n\t\t\n//\t\tpublic int GetVisibleColumn(int logicalLine, int logicalColumn)\n//\t\t{\n//\t\t\treturn lineTrackingStrategy.GetVisibleColumn(logicalLine, logicalColumn);\n//\t\t}\n//\n\t\tpublic int GetNextVisibleLineAbove(int lineNumber, int lineCount)\n\t\t{\n\t\t\treturn lineTrackingStrategy.GetNextVisibleLineAbove(lineNumber, lineCount);\n\t\t}\n\t\t\n\t\tpublic int GetNextVisibleLineBelow(int lineNumber, int lineCount)\n\t\t{\n\t\t\treturn lineTrackingStrategy.GetNextVisibleLineBelow(lineNumber, lineCount);\n\t\t}\n\t\t\n\t\tpublic TextLocation OffsetToPosition(int offset)\n\t\t{\n\t\t\tint lineNr = GetLineNumberForOffset(offset);\n\t\t\tLineSegment line = GetLineSegment(lineNr);\n\t\t\treturn new TextLocation(offset - line.Offset, lineNr);\n\t\t}\n\t\t\n\t\tpublic int PositionToOffset(TextLocation p)\n\t\t{\n\t\t\tif (p.Y >= this.TotalNumberOfLines) {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tLineSegment line = GetLineSegment(p.Y);\n\t\t\treturn Math.Min(this.TextLength, line.Offset + Math.Min(line.Length, p.X));\n\t\t}\n\t\t\n\t\tpublic void UpdateSegmentListOnDocumentChange<T>(List<T> list, DocumentEventArgs e) where T : ISegment\n\t\t{\n\t\t\tint removedCharacters = e.Length > 0 ? e.Length : 0;\n\t\t\tint insertedCharacters = e.Text != null ? e.Text.Length : 0;\n\t\t\tfor (int i = 0; i < list.Count; ++i) {\n\t\t\t\tISegment s = list[i];\n\t\t\t\tint segmentStart = s.Offset;\n\t\t\t\tint segmentEnd = s.Offset + s.Length;\n\t\t\t\t\n\t\t\t\tif (e.Offset <= segmentStart) {\n\t\t\t\t\tsegmentStart -= removedCharacters;\n\t\t\t\t\tif (segmentStart < e.Offset)\n\t\t\t\t\t\tsegmentStart = e.Offset;\n\t\t\t\t}\n\t\t\t\tif (e.Offset < segmentEnd) {\n\t\t\t\t\tsegmentEnd -= removedCharacters;\n\t\t\t\t\tif (segmentEnd < e.Offset)\n\t\t\t\t\t\tsegmentEnd = e.Offset;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tDebug.Assert(segmentStart <= segmentEnd);\n\t\t\t\t\n\t\t\t\tif (segmentStart == segmentEnd) {\n\t\t\t\t\tlist.RemoveAt(i);\n\t\t\t\t\t--i;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (e.Offset <= segmentStart)\n\t\t\t\t\tsegmentStart += insertedCharacters;\n\t\t\t\tif (e.Offset < segmentEnd)\n\t\t\t\t\tsegmentEnd += insertedCharacters;\n\t\t\t\t\n\t\t\t\tDebug.Assert(segmentStart < segmentEnd);\n\t\t\t\t\n\t\t\t\ts.Offset = segmentStart;\n\t\t\t\ts.Length = segmentEnd - segmentStart;\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid OnDocumentAboutToBeChanged(DocumentEventArgs e)\n\t\t{\n\t\t\tif (DocumentAboutToBeChanged != null) {\n\t\t\t\tDocumentAboutToBeChanged(this, e);\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid OnDocumentChanged(DocumentEventArgs e)\n\t\t{\n\t\t\tif (DocumentChanged != null) {\n\t\t\t\tDocumentChanged(this, e);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic event DocumentEventHandler DocumentAboutToBeChanged;\n\t\tpublic event DocumentEventHandler DocumentChanged;\n\t\t\n\t\t// UPDATE STUFF\n\t\tList<TextAreaUpdate> updateQueue = new List<TextAreaUpdate>();\n\t\t\n\t\tpublic List<TextAreaUpdate> UpdateQueue {\n\t\t\tget {\n\t\t\t\treturn updateQueue;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic void RequestUpdate(TextAreaUpdate update)\n\t\t{\n\t\t\tif (updateQueue.Count == 1 && updateQueue[0].TextAreaUpdateType == TextAreaUpdateType.WholeTextArea) {\n\t\t\t\t// if we're going to update the whole text area, we don't need to store detail updates\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (update.TextAreaUpdateType == TextAreaUpdateType.WholeTextArea) {\n\t\t\t\t// if we're going to update the whole text area, we don't need to store detail updates\n\t\t\t\tupdateQueue.Clear();\n\t\t\t}\n\t\t\tupdateQueue.Add(update);\n\t\t}\n\t\t\n\t\tpublic void CommitUpdate()\n\t\t{\n\t\t\tif (UpdateCommited != null) {\n\t\t\t\tUpdateCommited(this, EventArgs.Empty);\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid OnTextContentChanged(EventArgs e)\n\t\t{\n\t\t\tif (TextContentChanged != null) {\n\t\t\t\tTextContentChanged(this, e);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic event EventHandler UpdateCommited;\n\t\tpublic event EventHandler TextContentChanged;\n\t\t\n\t\t[Conditional(\"DEBUG\")]\n\t\tinternal static void ValidatePosition(IDocument document, TextLocation position)\n\t\t{\n\t\t\tdocument.GetLineSegment(position.Line);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/DefaultTextEditorProperties.cs",
    "content": "// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"none\" email=\"\"/>\n//     <version>$Revision: 3205 $</version>\n// </file>\n\nusing System;\nusing System.Drawing;\nusing System.Text;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\tpublic enum BracketMatchingStyle {\n\t\tBefore,\n\t\tAfter\n\t}\n\t\n\tpublic class DefaultTextEditorProperties : ITextEditorProperties\n\t{\n\t\tint                   tabIndent             = 4;\n\t\tint                   indentationSize       = 4;\n\t\tIndentStyle           indentStyle           = IndentStyle.Smart;\n\t\tDocumentSelectionMode documentSelectionMode = DocumentSelectionMode.Normal;\n\t\tEncoding              encoding              = System.Text.Encoding.UTF8;\n\t\tBracketMatchingStyle  bracketMatchingStyle  = BracketMatchingStyle.After;\n\t\tFontContainer fontContainer;\n\t\tstatic Font DefaultFont;\n\t\t\n\t\tpublic DefaultTextEditorProperties()\n\t\t{\n\t\t\tif (DefaultFont == null) {\n\t\t\t\tDefaultFont = new Font(\"Courier New\", 10);\n\t\t\t}\n\t\t\tthis.fontContainer = new FontContainer(DefaultFont);\n\t\t}\n\t\t\n\t\tbool        allowCaretBeyondEOL = false;\n\t\t\n\t\tbool        showMatchingBracket = true;\n\t\tbool        showLineNumbers     = true;\n\t\t\n\t\tbool        showSpaces          = false;\n\t\tbool        showTabs            = false;\n\t\tbool        showEOLMarker       = false;\n\t\t\n\t\tbool        showInvalidLines    = false;\n\t\t\n\t\tbool        isIconBarVisible    = false;\n\t\tbool        enableFolding       = true;\n\t\tbool        showHorizontalRuler = false;\n\t\tbool        showVerticalRuler   = true;\n\t\tbool        convertTabsToSpaces = false;\n\t\tSystem.Drawing.Text.TextRenderingHint textRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault;\n\t\tbool        mouseWheelScrollDown = true;\n\t\tbool        mouseWheelTextZoom   = true;\n\t\t\n\t\tbool        hideMouseCursor      = false;\n\t\tbool        cutCopyWholeLine     = true;\n\t\t\n\t\tint         verticalRulerRow    = 80;\n\t\tLineViewerStyle  lineViewerStyle = LineViewerStyle.None;\n\t\tstring      lineTerminator = \"\\r\\n\";\n\t\tbool        autoInsertCurlyBracket = true;\n\t\tbool        supportReadOnlySegments = false;\n\t\t\n\t\tpublic int TabIndent {\n\t\t\tget {\n\t\t\t\treturn tabIndent;\n\t\t\t}\n\t\t\tset {\n\t\t\t\ttabIndent = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int IndentationSize {\n\t\t\tget { return indentationSize; }\n\t\t\tset { indentationSize = value; }\n\t\t}\n\t\t\n\t\tpublic IndentStyle IndentStyle {\n\t\t\tget {\n\t\t\t\treturn indentStyle;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tindentStyle = value;\n\t\t\t}\n\t\t}\n\t\tpublic DocumentSelectionMode DocumentSelectionMode {\n\t\t\tget {\n\t\t\t\treturn documentSelectionMode;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tdocumentSelectionMode = value;\n\t\t\t}\n\t\t}\n\t\tpublic bool AllowCaretBeyondEOL {\n\t\t\tget {\n\t\t\t\treturn allowCaretBeyondEOL;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tallowCaretBeyondEOL = value;\n\t\t\t}\n\t\t}\n\t\tpublic bool ShowMatchingBracket {\n\t\t\tget {\n\t\t\t\treturn showMatchingBracket;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tshowMatchingBracket = value;\n\t\t\t}\n\t\t}\n\t\tpublic bool ShowLineNumbers {\n\t\t\tget {\n\t\t\t\treturn showLineNumbers;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tshowLineNumbers = value;\n\t\t\t}\n\t\t}\n\t\tpublic bool ShowSpaces {\n\t\t\tget {\n\t\t\t\treturn showSpaces;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tshowSpaces = value;\n\t\t\t}\n\t\t}\n\t\tpublic bool ShowTabs {\n\t\t\tget {\n\t\t\t\treturn showTabs;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tshowTabs = value;\n\t\t\t}\n\t\t}\n\t\tpublic bool ShowEOLMarker {\n\t\t\tget {\n\t\t\t\treturn showEOLMarker;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tshowEOLMarker = value;\n\t\t\t}\n\t\t}\n\t\tpublic bool ShowInvalidLines {\n\t\t\tget {\n\t\t\t\treturn showInvalidLines;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tshowInvalidLines = value;\n\t\t\t}\n\t\t}\n\t\tpublic bool IsIconBarVisible {\n\t\t\tget {\n\t\t\t\treturn isIconBarVisible;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tisIconBarVisible = value;\n\t\t\t}\n\t\t}\n\t\tpublic bool EnableFolding {\n\t\t\tget {\n\t\t\t\treturn enableFolding;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tenableFolding = value;\n\t\t\t}\n\t\t}\n\t\tpublic bool ShowHorizontalRuler {\n\t\t\tget {\n\t\t\t\treturn showHorizontalRuler;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tshowHorizontalRuler = value;\n\t\t\t}\n\t\t}\n\t\tpublic bool ShowVerticalRuler {\n\t\t\tget {\n\t\t\t\treturn showVerticalRuler;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tshowVerticalRuler = value;\n\t\t\t}\n\t\t}\n\t\tpublic bool ConvertTabsToSpaces {\n\t\t\tget {\n\t\t\t\treturn convertTabsToSpaces;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tconvertTabsToSpaces = value;\n\t\t\t}\n\t\t}\n\t\tpublic System.Drawing.Text.TextRenderingHint TextRenderingHint {\n\t\t\tget { return textRenderingHint; }\n\t\t\tset { textRenderingHint = value; }\n\t\t}\n\t\t\n\t\tpublic bool MouseWheelScrollDown {\n\t\t\tget {\n\t\t\t\treturn mouseWheelScrollDown;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tmouseWheelScrollDown = value;\n\t\t\t}\n\t\t}\n\t\tpublic bool MouseWheelTextZoom {\n\t\t\tget {\n\t\t\t\treturn mouseWheelTextZoom;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tmouseWheelTextZoom = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic bool HideMouseCursor {\n\t\t\tget {\n\t\t\t\treturn hideMouseCursor;\n\t\t\t}\n\t\t\tset {\n\t\t\t\thideMouseCursor = value;\n\t\t\t}\n\t\t}\n\n\t\tpublic bool CutCopyWholeLine {\n\t\t\tget {\n\t\t\t\treturn cutCopyWholeLine;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tcutCopyWholeLine = value;\n\t\t\t}\n\t\t}\n\n\t\tpublic Encoding Encoding {\n\t\t\tget {\n\t\t\t\treturn encoding;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tencoding = value;\n\t\t\t}\n\t\t}\n\t\tpublic int VerticalRulerRow {\n\t\t\tget {\n\t\t\t\treturn verticalRulerRow;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tverticalRulerRow = value;\n\t\t\t}\n\t\t}\n\t\tpublic LineViewerStyle LineViewerStyle {\n\t\t\tget {\n\t\t\t\treturn lineViewerStyle;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tlineViewerStyle = value;\n\t\t\t}\n\t\t}\n\t\tpublic string LineTerminator {\n\t\t\tget {\n\t\t\t\treturn lineTerminator;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tlineTerminator = value;\n\t\t\t}\n\t\t}\n\t\tpublic bool AutoInsertCurlyBracket {\n\t\t\tget {\n\t\t\t\treturn autoInsertCurlyBracket;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tautoInsertCurlyBracket = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic Font Font {\n\t\t\tget {\n\t\t\t\treturn fontContainer.DefaultFont;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tfontContainer.DefaultFont = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic FontContainer FontContainer {\n\t\t\tget {\n\t\t\t\treturn fontContainer;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic BracketMatchingStyle  BracketMatchingStyle {\n\t\t\tget {\n\t\t\t\treturn bracketMatchingStyle;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tbracketMatchingStyle = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic bool SupportReadOnlySegments {\n\t\t\tget {\n\t\t\t\treturn supportReadOnlySegments;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tsupportReadOnlySegments = value;\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/DocumentEventArgs.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 915 $</version>\n// </file>\n\nusing System;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\t/// <summary>\n\t/// This delegate is used for document events.\n\t/// </summary>\n\tpublic delegate void DocumentEventHandler(object sender, DocumentEventArgs e);\n\t\n\t/// <summary>\n\t/// This class contains more information on a document event\n\t/// </summary>\n\tpublic class DocumentEventArgs : EventArgs\n\t{\n\t\tIDocument document;\n\t\tint       offset;\n\t\tint       length;\n\t\tstring    text;\n\t\t\n\t\t/// <returns>\n\t\t/// always a valid Document which is related to the Event.\n\t\t/// </returns>\n\t\tpublic IDocument Document {\n\t\t\tget {\n\t\t\t\treturn document;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <returns>\n\t\t/// -1 if no offset was specified for this event\n\t\t/// </returns>\n\t\tpublic int Offset {\n\t\t\tget {\n\t\t\t\treturn offset;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <returns>\n\t\t/// null if no text was specified for this event\n\t\t/// </returns>\n\t\tpublic string Text {\n\t\t\tget {\n\t\t\t\treturn text;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <returns>\n\t\t/// -1 if no length was specified for this event\n\t\t/// </returns>\n\t\tpublic int Length {\n\t\t\tget {\n\t\t\t\treturn length;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Creates a new instance off <see cref=\"DocumentEventArgs\"/>\n\t\t/// </summary>\n\t\tpublic DocumentEventArgs(IDocument document) : this(document, -1, -1, null)\n\t\t{\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Creates a new instance off <see cref=\"DocumentEventArgs\"/>\n\t\t/// </summary>\n\t\tpublic DocumentEventArgs(IDocument document, int offset) : this(document, offset, -1, null)\n\t\t{\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Creates a new instance off <see cref=\"DocumentEventArgs\"/>\n\t\t/// </summary>\n\t\tpublic DocumentEventArgs(IDocument document, int offset, int length) : this(document, offset, length, null)\n\t\t{\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Creates a new instance off <see cref=\"DocumentEventArgs\"/>\n\t\t/// </summary>\n\t\tpublic DocumentEventArgs(IDocument document, int offset, int length, string text)\n\t\t{\n\t\t\tthis.document = document;\n\t\t\tthis.offset   = offset;\n\t\t\tthis.length   = length;\n\t\t\tthis.text     = text;\n\t\t}\n\t\tpublic override string ToString()\n\t\t{\n\t\t\treturn String.Format(\"[DocumentEventArgs: Document = {0}, Offset = {1}, Text = {2}, Length = {3}]\",\n\t\t\t                     Document,\n\t\t\t                     Offset,\n\t\t\t                     Text,\n\t\t\t                     Length);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/DocumentFactory.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 3205 $</version>\n// </file>\n\nusing System;\nusing System.Text;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\t/// <summary>\n\t/// This interface represents a container which holds a text sequence and\n\t/// all necessary information about it. It is used as the base for a text editor.\n\t/// </summary>\n\tpublic class DocumentFactory\n\t{\n\t\t/// <remarks>\n\t\t/// Creates a new <see cref=\"IDocument\"/> object. Only create\n\t\t/// <see cref=\"IDocument\"/> with this method.\n\t\t/// </remarks>\n\t\tpublic IDocument CreateDocument()\n\t\t{\n\t\t\tDefaultDocument doc = new DefaultDocument();\n\t\t\tdoc.TextBufferStrategy  = new GapTextBufferStrategy();\n\t\t\tdoc.FormattingStrategy  = new DefaultFormattingStrategy();\n\t\t\tdoc.LineManager         = new LineManager(doc, null);\n\t\t\tdoc.FoldingManager      = new FoldingManager(doc, doc.LineManager);\n\t\t\tdoc.FoldingManager.FoldingStrategy       = null; //new ParserFoldingStrategy();\n\t\t\tdoc.MarkerStrategy      = new MarkerStrategy(doc);\n\t\t\tdoc.BookmarkManager     = new BookmarkManager(doc, doc.LineManager);\n\t\t\treturn doc;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Creates a new document and loads the given file\n\t\t/// </summary>\n\t\tpublic IDocument CreateFromTextBuffer(ITextBufferStrategy textBuffer)\n\t\t{\n\t\t\tDefaultDocument doc = (DefaultDocument)CreateDocument();\n\t\t\tdoc.TextContent = textBuffer.GetText(0, textBuffer.Length);\n\t\t\tdoc.TextBufferStrategy = textBuffer;\n\t\t\treturn doc;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Creates a new document and loads the given file\n\t\t/// </summary>\n\t\tpublic IDocument CreateFromFile(string fileName)\n\t\t{\n\t\t\tIDocument document = CreateDocument();\n\t\t\tdocument.TextContent = Util.FileReader.ReadFileContent(fileName, Encoding.Default);\n\t\t\treturn document;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/FoldingStrategy/FoldMarker.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 2063 $</version>\n// </file>\n\nusing System;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\tpublic enum FoldType {\n\t\tUnspecified,\n\t\tMemberBody,\n\t\tRegion,\n\t\tTypeBody\n\t}\n\t\n\tpublic class FoldMarker : AbstractSegment, IComparable\n\t{\n\t\tbool      isFolded = false;\n\t\tstring    foldText = \"...\";\n\t\tFoldType  foldType = FoldType.Unspecified;\n\t\tIDocument document = null;\n\t\tint startLine = -1, startColumn, endLine = -1, endColumn;\n\t\t\n\t\tstatic void GetPointForOffset(IDocument document, int offset, out int line, out int column)\n\t\t{\n\t\t\tif (offset > document.TextLength) {\n\t\t\t\tline = document.TotalNumberOfLines + 1;\n\t\t\t\tcolumn = 1;\n\t\t\t} else if (offset < 0) {\n\t\t\t\tline = -1;\n\t\t\t\tcolumn = -1;\n\t\t\t} else {\n\t\t\t\tline = document.GetLineNumberForOffset(offset);\n\t\t\t\tcolumn = offset - document.GetLineSegment(line).Offset;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic FoldType FoldType {\n\t\t\tget { return foldType; }\n\t\t\tset { foldType = value; }\n\t\t}\n\t\t\n\t\tpublic int StartLine {\n\t\t\tget {\n\t\t\t\tif (startLine < 0) {\n\t\t\t\t\tGetPointForOffset(document, offset, out startLine, out startColumn);\n\t\t\t\t}\n\t\t\t\treturn startLine;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int StartColumn {\n\t\t\tget {\n\t\t\t\tif (startLine < 0) {\n\t\t\t\t\tGetPointForOffset(document, offset, out startLine, out startColumn);\n\t\t\t\t}\n\t\t\t\treturn startColumn;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int EndLine {\n\t\t\tget {\n\t\t\t\tif (endLine < 0) {\n\t\t\t\t\tGetPointForOffset(document, offset + length, out endLine, out endColumn);\n\t\t\t\t}\n\t\t\t\treturn endLine;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int EndColumn {\n\t\t\tget {\n\t\t\t\tif (endLine < 0) {\n\t\t\t\t\tGetPointForOffset(document, offset + length, out endLine, out endColumn);\n\t\t\t\t}\n\t\t\t\treturn endColumn;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic override int Offset {\n\t\t\tget { return base.Offset; }\n\t\t\tset {\n\t\t\t\tbase.Offset = value;\n\t\t\t\tstartLine = -1; endLine = -1;\n\t\t\t}\n\t\t}\n\t\tpublic override int Length {\n\t\t\tget { return base.Length; }\n\t\t\tset {\n\t\t\t\tbase.Length = value;\n\t\t\t\tendLine = -1;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic bool IsFolded {\n\t\t\tget {\n\t\t\t\treturn isFolded;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tisFolded = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic string FoldText {\n\t\t\tget {\n\t\t\t\treturn foldText;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic string InnerText {\n\t\t\tget {\n\t\t\t\treturn document.GetText(offset, length);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic FoldMarker(IDocument document, int offset, int length, string foldText, bool isFolded)\n\t\t{\n\t\t\tthis.document = document;\n\t\t\tthis.offset   = offset;\n\t\t\tthis.length   = length;\n\t\t\tthis.foldText = foldText;\n\t\t\tthis.isFolded = isFolded;\n\t\t}\n\t\t\n\t\tpublic FoldMarker(IDocument document, int startLine, int startColumn, int endLine, int endColumn) : this(document, startLine, startColumn, endLine, endColumn, FoldType.Unspecified)\n\t\t{\n\t\t}\n\t\t\n\t\tpublic FoldMarker(IDocument document, int startLine, int startColumn, int endLine, int endColumn, FoldType foldType)  : this(document, startLine, startColumn, endLine, endColumn, foldType, \"...\")\n\t\t{\n\t\t}\n\t\t\n\t\tpublic FoldMarker(IDocument document, int startLine, int startColumn, int endLine, int endColumn, FoldType foldType, string foldText) : this(document, startLine, startColumn, endLine, endColumn, foldType, foldText, false)\n\t\t{\n\t\t}\n\t\t\n\t\tpublic FoldMarker(IDocument document, int startLine, int startColumn, int endLine, int endColumn, FoldType foldType, string foldText, bool isFolded)\n\t\t{\n\t\t\tthis.document = document;\n\t\t\t\n\t\t\tstartLine = Math.Min(document.TotalNumberOfLines - 1, Math.Max(startLine, 0));\n\t\t\tISegment startLineSegment = document.GetLineSegment(startLine);\n\t\t\t\n\t\t\tendLine = Math.Min(document.TotalNumberOfLines - 1, Math.Max(endLine, 0));\n\t\t\tISegment endLineSegment   = document.GetLineSegment(endLine);\n\t\t\t\n\t\t\t// Prevent the region from completely disappearing\n\t\t\tif (string.IsNullOrEmpty(foldText)) {\n\t\t\t\tfoldText = \"...\";\n\t\t\t}\n\t\t\t\n\t\t\tthis.FoldType = foldType;\n\t\t\tthis.foldText = foldText;\n\t\t\tthis.offset = startLineSegment.Offset + Math.Min(startColumn, startLineSegment.Length);\n\t\t\tthis.length = (endLineSegment.Offset + Math.Min(endColumn, endLineSegment.Length)) - this.offset;\n\t\t\tthis.isFolded = isFolded;\n\t\t}\n\t\t\n\t\tpublic int CompareTo(object o)\n\t\t{\n\t\t\tif (!(o is FoldMarker)) {\n\t\t\t\tthrow new ArgumentException();\n\t\t\t}\n\t\t\tFoldMarker f = (FoldMarker)o;\n\t\t\tif (offset != f.offset) {\n\t\t\t\treturn offset.CompareTo(f.offset);\n\t\t\t}\n\t\t\t\n\t\t\treturn length.CompareTo(f.length);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/FoldingStrategy/FoldingManager.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 2691 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\nusing System.Drawing;\nusing System.Text;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\tpublic class FoldingManager\n\t{\n\t\tList<FoldMarker>    foldMarker      = new List<FoldMarker>();\n\t\tList<FoldMarker>    foldMarkerByEnd = new List<FoldMarker>();\n\t\tIFoldingStrategy    foldingStrategy = null;\n\t\tIDocument document;\n\t\t\n\t\tpublic IList<FoldMarker> FoldMarker {\n\t\t\tget {\n\t\t\t\treturn foldMarker.AsReadOnly();\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic IFoldingStrategy FoldingStrategy {\n\t\t\tget {\n\t\t\t\treturn foldingStrategy;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tfoldingStrategy = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tinternal FoldingManager(IDocument document, LineManager lineTracker)\n\t\t{\n\t\t\tthis.document = document;\n\t\t\tdocument.DocumentChanged += new DocumentEventHandler(DocumentChanged);\n\t\t\t\n//\t\t\tlineTracker.LineCountChanged  += new LineManagerEventHandler(LineManagerLineCountChanged);\n//\t\t\tlineTracker.LineLengthChanged += new LineLengthEventHandler(LineManagerLineLengthChanged);\n//\t\t\tfoldMarker.Add(new FoldMarker(0, 5, 3, 5));\n//\n//\t\t\tfoldMarker.Add(new FoldMarker(5, 5, 10, 3));\n//\t\t\tfoldMarker.Add(new FoldMarker(6, 0, 8, 2));\n//\n//\t\t\tFoldMarker fm1 = new FoldMarker(10, 4, 10, 7);\n//\t\t\tFoldMarker fm2 = new FoldMarker(10, 10, 10, 14);\n//\n//\t\t\tfm1.IsFolded = true;\n//\t\t\tfm2.IsFolded = true;\n//\n//\t\t\tfoldMarker.Add(fm1);\n//\t\t\tfoldMarker.Add(fm2);\n//\t\t\tfoldMarker.Sort();\n\t\t}\n\t\t\n\t\tvoid DocumentChanged(object sender, DocumentEventArgs e)\n\t\t{\n\t\t\tint oldCount = foldMarker.Count;\n\t\t\tdocument.UpdateSegmentListOnDocumentChange(foldMarker, e);\n\t\t\tif (oldCount != foldMarker.Count) {\n\t\t\t\tdocument.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea));\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic List<FoldMarker> GetFoldingsFromPosition(int line, int column)\n\t\t{\n\t\t\tList<FoldMarker> foldings = new List<FoldMarker>();\n\t\t\tif (foldMarker != null) {\n\t\t\t\tfor (int i = 0; i < foldMarker.Count; ++i) {\n\t\t\t\t\tFoldMarker fm = foldMarker[i];\n\t\t\t\t\tif ((fm.StartLine == line && column > fm.StartColumn && !(fm.EndLine == line && column >= fm.EndColumn)) ||\n\t\t\t\t\t    (fm.EndLine == line && column < fm.EndColumn && !(fm.StartLine == line && column <= fm.StartColumn)) ||\n\t\t\t\t\t    (line > fm.StartLine && line < fm.EndLine)) {\n\t\t\t\t\t\tfoldings.Add(fm);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn foldings;\n\t\t}\n\t\t\n\t\tclass StartComparer : IComparer<FoldMarker>\n\t\t{\n\t\t\tpublic readonly static StartComparer Instance = new StartComparer();\n\t\t\t\n\t\t\tpublic int Compare(FoldMarker x, FoldMarker y)\n\t\t\t{\n\t\t\t\tif (x.StartLine < y.StartLine)\n\t\t\t\t\treturn -1;\n\t\t\t\telse if (x.StartLine == y.StartLine)\n\t\t\t\t\treturn x.StartColumn.CompareTo(y.StartColumn);\n\t\t\t\telse\n\t\t\t\t\treturn 1;\n\t\t\t}\n\t\t}\n\t\t\n\t\tclass EndComparer : IComparer<FoldMarker>\n\t\t{\n\t\t\tpublic readonly static EndComparer Instance = new EndComparer();\n\t\t\t\n\t\t\tpublic int Compare(FoldMarker x, FoldMarker y)\n\t\t\t{\n\t\t\t\tif (x.EndLine < y.EndLine)\n\t\t\t\t\treturn -1;\n\t\t\t\telse if (x.EndLine == y.EndLine)\n\t\t\t\t\treturn x.EndColumn.CompareTo(y.EndColumn);\n\t\t\t\telse\n\t\t\t\t\treturn 1;\n\t\t\t}\n\t\t}\n\t\t\n\t\tList<FoldMarker> GetFoldingsByStartAfterColumn(int lineNumber, int column, bool forceFolded)\n\t\t{\n\t\t\tList<FoldMarker> foldings = new List<FoldMarker>();\n\t\t\t\n\t\t\tif (foldMarker != null) {\n\t\t\t\tint index = foldMarker.BinarySearch(\n\t\t\t\t\tnew FoldMarker(document, lineNumber, column, lineNumber, column),\n\t\t\t\t\tStartComparer.Instance);\n\t\t\t\tif (index < 0) index = ~index;\n\t\t\t\t\n\t\t\t\tfor (; index < foldMarker.Count; index++) {\n\t\t\t\t\tFoldMarker fm = foldMarker[index];\n\t\t\t\t\tif (fm.StartLine > lineNumber)\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tif (fm.StartColumn <= column)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif (!forceFolded || fm.IsFolded)\n\t\t\t\t\t\tfoldings.Add(fm);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn foldings;\n\t\t}\n\t\t\n\t\tpublic List<FoldMarker> GetFoldingsWithStart(int lineNumber)\n\t\t{\n\t\t\treturn GetFoldingsByStartAfterColumn(lineNumber, -1, false);\n\t\t}\n\t\t\n\t\tpublic List<FoldMarker> GetFoldedFoldingsWithStart(int lineNumber)\n\t\t{\n\t\t\treturn GetFoldingsByStartAfterColumn(lineNumber, -1, true);\n\t\t}\n\t\t\n\t\tpublic List<FoldMarker> GetFoldedFoldingsWithStartAfterColumn(int lineNumber, int column)\n\t\t{\n\t\t\treturn GetFoldingsByStartAfterColumn(lineNumber, column, true);\n\t\t}\n\t\t\n\t\tList<FoldMarker> GetFoldingsByEndAfterColumn(int lineNumber, int column, bool forceFolded)\n\t\t{\n\t\t\tList<FoldMarker> foldings = new List<FoldMarker>();\n\t\t\t\n\t\t\tif (foldMarker != null) {\n\t\t\t\tint index =  foldMarkerByEnd.BinarySearch(\n\t\t\t\t\tnew FoldMarker(document, lineNumber, column, lineNumber, column),\n\t\t\t\t\tEndComparer.Instance);\n\t\t\t\tif (index < 0) index = ~index;\n\t\t\t\t\n\t\t\t\tfor (; index < foldMarkerByEnd.Count; index++) {\n\t\t\t\t\tFoldMarker fm = foldMarkerByEnd[index];\n\t\t\t\t\tif (fm.EndLine > lineNumber)\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tif (fm.EndColumn <= column)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif (!forceFolded || fm.IsFolded)\n\t\t\t\t\t\tfoldings.Add(fm);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn foldings;\n\t\t}\n\t\t\n\t\tpublic List<FoldMarker> GetFoldingsWithEnd(int lineNumber)\n\t\t{\n\t\t\treturn GetFoldingsByEndAfterColumn(lineNumber, -1, false);\n\t\t}\n\t\t\n\t\tpublic List<FoldMarker> GetFoldedFoldingsWithEnd(int lineNumber)\n\t\t{\n\t\t\treturn GetFoldingsByEndAfterColumn(lineNumber, -1, true);\n\t\t}\n\t\t\n\t\tpublic bool IsFoldStart(int lineNumber)\n\t\t{\n\t\t\treturn GetFoldingsWithStart(lineNumber).Count > 0;\n\t\t}\n\t\t\n\t\tpublic bool IsFoldEnd(int lineNumber)\n\t\t{\n\t\t\treturn GetFoldingsWithEnd(lineNumber).Count > 0;\n\t\t}\n\t\t\n\t\tpublic List<FoldMarker> GetFoldingsContainsLineNumber(int lineNumber)\n\t\t{\n\t\t\tList<FoldMarker> foldings = new List<FoldMarker>();\n\t\t\tif (foldMarker != null) {\n\t\t\t\tforeach (FoldMarker fm in foldMarker) {\n\t\t\t\t\tif (fm.StartLine < lineNumber && lineNumber < fm.EndLine) {\n\t\t\t\t\t\tfoldings.Add(fm);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn foldings;\n\t\t}\n\t\t\n\t\tpublic bool IsBetweenFolding(int lineNumber)\n\t\t{\n\t\t\treturn GetFoldingsContainsLineNumber(lineNumber).Count > 0;\n\t\t}\n\t\t\n\t\tpublic bool IsLineVisible(int lineNumber)\n\t\t{\n\t\t\tforeach (FoldMarker fm in GetFoldingsContainsLineNumber(lineNumber)) {\n\t\t\t\tif (fm.IsFolded)\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\t\n\t\tpublic List<FoldMarker> GetTopLevelFoldedFoldings()\n\t\t{\n\t\t\tList<FoldMarker> foldings = new List<FoldMarker>();\n\t\t\tif (foldMarker != null) {\n\t\t\t\tPoint end = new Point(0, 0);\n\t\t\t\tforeach (FoldMarker fm in foldMarker) {\n\t\t\t\t\tif (fm.IsFolded && (fm.StartLine > end.Y || fm.StartLine == end.Y && fm.StartColumn >= end.X)) {\n\t\t\t\t\t\tfoldings.Add(fm);\n\t\t\t\t\t\tend = new Point(fm.EndColumn, fm.EndLine);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn foldings;\n\t\t}\n\t\t\n\t\tpublic void UpdateFoldings(string fileName, object parseInfo)\n\t\t{\n\t\t\tUpdateFoldings(foldingStrategy.GenerateFoldMarkers(document, fileName, parseInfo));\n\t\t}\n\t\t\n\t\tpublic void UpdateFoldings(List<FoldMarker> newFoldings)\n\t\t{\n\t\t\tint oldFoldingsCount = foldMarker.Count;\n\t\t\tlock (this) {\n\t\t\t\tif (newFoldings != null && newFoldings.Count != 0) {\n\t\t\t\t\tnewFoldings.Sort();\n\t\t\t\t\tif (foldMarker.Count == newFoldings.Count) {\n\t\t\t\t\t\tfor (int i = 0; i < foldMarker.Count; ++i) {\n\t\t\t\t\t\t\tnewFoldings[i].IsFolded = foldMarker[i].IsFolded;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfoldMarker = newFoldings;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfor (int i = 0, j = 0; i < foldMarker.Count && j < newFoldings.Count;) {\n\t\t\t\t\t\t\tint n = newFoldings[j].CompareTo(foldMarker[i]);\n\t\t\t\t\t\t\tif (n > 0) {\n\t\t\t\t\t\t\t\t++i;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tif (n == 0) {\n\t\t\t\t\t\t\t\t\tnewFoldings[j].IsFolded = foldMarker[i].IsFolded;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t++j;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (newFoldings != null) {\n\t\t\t\t\tfoldMarker = newFoldings;\n\t\t\t\t\tfoldMarkerByEnd = new List<FoldMarker>(newFoldings);\n\t\t\t\t\tfoldMarkerByEnd.Sort(EndComparer.Instance);\n\t\t\t\t} else {\n\t\t\t\t\tfoldMarker.Clear();\n\t\t\t\t\tfoldMarkerByEnd.Clear();\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (oldFoldingsCount != foldMarker.Count) {\n\t\t\t\tdocument.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea));\n\t\t\t\tdocument.CommitUpdate();\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic string SerializeToString()\n\t\t{\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\tforeach (FoldMarker marker in this.foldMarker) {\n\t\t\t\tsb.Append(marker.Offset);sb.Append(\"\\n\");\n\t\t\t\tsb.Append(marker.Length);sb.Append(\"\\n\");\n\t\t\t\tsb.Append(marker.FoldText);sb.Append(\"\\n\");\n\t\t\t\tsb.Append(marker.IsFolded);sb.Append(\"\\n\");\n\t\t\t}\n\t\t\treturn sb.ToString();\n\t\t}\n\t\t\n\t\tpublic void DeserializeFromString(string str)\n\t\t{\n\t\t\ttry {\n\t\t\t\tstring[] lines = str.Split('\\n');\n\t\t\t\tfor (int i = 0; i < lines.Length && lines[i].Length > 0; i += 4) {\n\t\t\t\t\tint    offset = Int32.Parse(lines[i]);\n\t\t\t\t\tint    length = Int32.Parse(lines[i + 1]);\n\t\t\t\t\tstring text   = lines[i + 2];\n\t\t\t\t\tbool isFolded = Boolean.Parse(lines[i + 3]);\n\t\t\t\t\tbool found    = false;\n\t\t\t\t\tforeach (FoldMarker marker in foldMarker) {\n\t\t\t\t\t\tif (marker.Offset == offset && marker.Length == length) {\n\t\t\t\t\t\t\tmarker.IsFolded = isFolded;\n\t\t\t\t\t\t\tfound = true;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (!found) {\n\t\t\t\t\t\tfoldMarker.Add(new FoldMarker(document, offset, length, text, isFolded));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (lines.Length > 0) {\n\t\t\t\t\tNotifyFoldingsChanged(EventArgs.Empty);\n\t\t\t\t}\n\t\t\t} catch (Exception) {\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic void NotifyFoldingsChanged(EventArgs e)\n\t\t{\n\t\t\tif (FoldingsChanged != null) {\n\t\t\t\tFoldingsChanged(this, e);\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\tpublic event EventHandler FoldingsChanged;\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/FoldingStrategy/IFoldingStrategy.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 1965 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\t/// <summary>\n\t/// This interface is used for the folding capabilities\n\t/// of the textarea.\n\t/// </summary>\n\tpublic interface IFoldingStrategy\n\t{\n\t\t/// <remarks>\n\t\t/// Calculates the fold level of a specific line.\n\t\t/// </remarks>\n\t\tList<FoldMarker> GenerateFoldMarkers(IDocument document, string fileName, object parseInformation);\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/FoldingStrategy/IndentFoldingStrategy.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 915 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\t/// <summary>\n\t/// A simple folding strategy which calculates the folding level\n\t/// using the indent level of the line.\n\t/// </summary>\n\tpublic class IndentFoldingStrategy : IFoldingStrategy\n\t{\n\t\tpublic List<FoldMarker> GenerateFoldMarkers(IDocument document, string fileName, object parseInformation)\n\t\t{\n\t\t\tList<FoldMarker> l = new List<FoldMarker>();\n\t\t\tStack<int> offsetStack = new Stack<int>();\n\t\t\tStack<string> textStack = new Stack<string>();\n\t\t\t//int level = 0;\n\t\t\t//foreach (LineSegment segment in document.LineSegmentCollection) {\n\t\t\t//\t\n\t\t\t//}\n\t\t\treturn l;\n\t\t}\n\t\t\n\t\tint GetLevel(IDocument document, int offset)\n\t\t{\n\t\t\tint level = 0;\n\t\t\tint spaces = 0;\n\t\t\tfor (int i = offset; i < document.TextLength; ++i) {\n\t\t\t\tchar c = document.GetCharAt(i);\n\t\t\t\tif (c == '\\t' || (c == ' ' && ++spaces == 4)) {\n\t\t\t\t\tspaces = 0;\n\t\t\t\t\t++level;\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn level;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/FormattingStrategy/DefaultFormattingStrategy.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 3272 $</version>\n// </file>\n\nusing System;\nusing System.Text;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\t/// <summary>\n\t/// This class handles the auto and smart indenting in the textbuffer while\n\t/// you type.\n\t/// </summary>\n\tpublic class DefaultFormattingStrategy : IFormattingStrategy\n\t{\n\t\t/// <summary>\n\t\t/// Creates a new instance off <see cref=\"DefaultFormattingStrategy\"/>\n\t\t/// </summary>\n\t\tpublic DefaultFormattingStrategy()\n\t\t{\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// returns the whitespaces which are before a non white space character in the line line\n\t\t/// as a string.\n\t\t/// </summary>\n\t\tprotected string GetIndentation(TextArea textArea, int lineNumber)\n\t\t{\n\t\t\tif (lineNumber < 0 || lineNumber > textArea.Document.TotalNumberOfLines) {\n\t\t\t\tthrow new ArgumentOutOfRangeException(\"lineNumber\");\n\t\t\t}\n\t\t\t\n\t\t\tstring lineText = TextUtilities.GetLineAsString(textArea.Document, lineNumber);\n\t\t\tStringBuilder whitespaces = new StringBuilder();\n\t\t\t\n\t\t\tforeach (char ch in lineText) {\n\t\t\t\tif (Char.IsWhiteSpace(ch)) {\n\t\t\t\t\twhitespaces.Append(ch);\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn whitespaces.ToString();\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Could be overwritten to define more complex indenting.\n\t\t/// </summary>\n\t\tprotected virtual int AutoIndentLine(TextArea textArea, int lineNumber)\n\t\t{\n\t\t\tstring indentation = lineNumber != 0 ? GetIndentation(textArea, lineNumber - 1) : \"\";\n\t\t\tif(indentation.Length > 0) {\n\t\t\t\tstring newLineText = indentation + TextUtilities.GetLineAsString(textArea.Document, lineNumber).Trim();\n\t\t\t\tLineSegment oldLine  = textArea.Document.GetLineSegment(lineNumber);\n\t\t\t\tSmartReplaceLine(textArea.Document, oldLine, newLineText);\n\t\t\t}\n\t\t\treturn indentation.Length;\n\t\t}\n\t\t\n\t\tstatic readonly char[] whitespaceChars = {' ', '\\t'};\n\t\t\n\t\t/// <summary>\n\t\t/// Replaces the text in a line.\n\t\t/// If only whitespace at the beginning and end of the line was changed, this method\n\t\t/// only adjusts the whitespace and doesn't replace the other text.\n\t\t/// </summary>\n\t\tpublic static void SmartReplaceLine(IDocument document, LineSegment line, string newLineText)\n\t\t{\n\t\t\tif (document == null)\n\t\t\t\tthrow new ArgumentNullException(\"document\");\n\t\t\tif (line == null)\n\t\t\t\tthrow new ArgumentNullException(\"line\");\n\t\t\tif (newLineText == null)\n\t\t\t\tthrow new ArgumentNullException(\"newLineText\");\n\t\t\tstring newLineTextTrim = newLineText.Trim(whitespaceChars);\n\t\t\tstring oldLineText = document.GetText(line);\n\t\t\tif (oldLineText == newLineText)\n\t\t\t\treturn;\n\t\t\tint pos = oldLineText.IndexOf(newLineTextTrim);\n\t\t\tif (newLineTextTrim.Length > 0 && pos >= 0) {\n\t\t\t\tdocument.UndoStack.StartUndoGroup();\n\t\t\t\ttry {\n\t\t\t\t\t// find whitespace at beginning\n\t\t\t\t\tint startWhitespaceLength = 0;\n\t\t\t\t\twhile (startWhitespaceLength < newLineText.Length) {\n\t\t\t\t\t\tchar c = newLineText[startWhitespaceLength];\n\t\t\t\t\t\tif (c != ' ' && c != '\\t')\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tstartWhitespaceLength++;\n\t\t\t\t\t}\n\t\t\t\t\t// find whitespace at end\n\t\t\t\t\tint endWhitespaceLength = newLineText.Length - newLineTextTrim.Length - startWhitespaceLength;\n\t\t\t\t\t\n\t\t\t\t\t// replace whitespace sections\n\t\t\t\t\tint lineOffset = line.Offset;\n\t\t\t\t\tdocument.Replace(lineOffset + pos + newLineTextTrim.Length, line.Length - pos - newLineTextTrim.Length, newLineText.Substring(newLineText.Length - endWhitespaceLength));\n\t\t\t\t\tdocument.Replace(lineOffset, pos, newLineText.Substring(0, startWhitespaceLength));\n\t\t\t\t} finally {\n\t\t\t\t\tdocument.UndoStack.EndUndoGroup();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tdocument.Replace(line.Offset, line.Length, newLineText);\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Could be overwritten to define more complex indenting.\n\t\t/// </summary>\n\t\tprotected virtual int SmartIndentLine(TextArea textArea, int line)\n\t\t{\n\t\t\treturn AutoIndentLine(textArea, line); // smart = autoindent in normal texts\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// This function formats a specific line after <code>ch</code> is pressed.\n\t\t/// </summary>\n\t\t/// <returns>\n\t\t/// the caret delta position the caret will be moved this number\n\t\t/// of bytes (e.g. the number of bytes inserted before the caret, or\n\t\t/// removed, if this number is negative)\n\t\t/// </returns>\n\t\tpublic virtual void FormatLine(TextArea textArea, int line, int cursorOffset, char ch)\n\t\t{\n\t\t\tif (ch == '\\n') {\n\t\t\t\ttextArea.Caret.Column = IndentLine(textArea, line);\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// This function sets the indentation level in a specific line\n\t\t/// </summary>\n\t\t/// <returns>\n\t\t/// the number of inserted characters.\n\t\t/// </returns>\n\t\tpublic int IndentLine(TextArea textArea, int line)\n\t\t{\n\t\t\ttextArea.Document.UndoStack.StartUndoGroup();\n\t\t\tint result;\n\t\t\tswitch (textArea.Document.TextEditorProperties.IndentStyle) {\n\t\t\t\tcase IndentStyle.None:\n\t\t\t\t\tresult = 0;\n\t\t\t\t\tbreak;\n\t\t\t\tcase IndentStyle.Auto:\n\t\t\t\t\tresult = AutoIndentLine(textArea, line);\n\t\t\t\t\tbreak;\n\t\t\t\tcase IndentStyle.Smart:\n\t\t\t\t\tresult = SmartIndentLine(textArea, line);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new NotSupportedException(\"Unsupported value for IndentStyle: \" + textArea.Document.TextEditorProperties.IndentStyle);\n\t\t\t}\n\t\t\ttextArea.Document.UndoStack.EndUndoGroup();\n\t\t\treturn result;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// This function sets the indentlevel in a range of lines.\n\t\t/// </summary>\n\t\tpublic virtual void IndentLines(TextArea textArea, int begin, int end)\n\t\t{\n\t\t\ttextArea.Document.UndoStack.StartUndoGroup();\n\t\t\tfor (int i = begin; i <= end; ++i) {\n\t\t\t\tIndentLine(textArea, i);\n\t\t\t}\n\t\t\ttextArea.Document.UndoStack.EndUndoGroup();\n\t\t}\n\t\t\n\t\tpublic virtual int SearchBracketBackward(IDocument document, int offset, char openBracket, char closingBracket)\n\t\t{\n\t\t\tint brackets = -1;\n\t\t\t// first try \"quick find\" - find the matching bracket if there is no string/comment in the way\n\t\t\tfor (int i = offset; i >= 0; --i) {\n\t\t\t\tchar ch = document.GetCharAt(i);\n\t\t\t\tif (ch == openBracket) {\n\t\t\t\t\t++brackets;\n\t\t\t\t\tif (brackets == 0) return i;\n\t\t\t\t} else if (ch == closingBracket) {\n\t\t\t\t\t--brackets;\n\t\t\t\t} else if (ch == '\"') {\n\t\t\t\t\tbreak;\n\t\t\t\t} else if (ch == '\\'') {\n\t\t\t\t\tbreak;\n\t\t\t\t} else if (ch == '/' && i > 0) {\n\t\t\t\t\tif (document.GetCharAt(i - 1) == '/') break;\n\t\t\t\t\tif (document.GetCharAt(i - 1) == '*') break;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn -1;\n\t\t}\n\t\t\n\t\tpublic virtual int SearchBracketForward(IDocument document, int offset, char openBracket, char closingBracket)\n\t\t{\n\t\t\tint brackets = 1;\n\t\t\t// try \"quick find\" - find the matching bracket if there is no string/comment in the way\n\t\t\tfor (int i = offset; i < document.TextLength; ++i) {\n\t\t\t\tchar ch = document.GetCharAt(i);\n\t\t\t\tif (ch == openBracket) {\n\t\t\t\t\t++brackets;\n\t\t\t\t} else if (ch == closingBracket) {\n\t\t\t\t\t--brackets;\n\t\t\t\t\tif (brackets == 0) return i;\n\t\t\t\t} else if (ch == '\"') {\n\t\t\t\t\tbreak;\n\t\t\t\t} else if (ch == '\\'') {\n\t\t\t\t\tbreak;\n\t\t\t\t} else if (ch == '/' && i > 0) {\n\t\t\t\t\tif (document.GetCharAt(i - 1) == '/') break;\n\t\t\t\t} else if (ch == '*' && i > 0) {\n\t\t\t\t\tif (document.GetCharAt(i - 1) == '/') break;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn -1;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/FormattingStrategy/IFormattingStrategy.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 2640 $</version>\n// </file>\n\nusing System;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\t/// <summary>\n\t/// This interface handles the auto and smart indenting and formating\n\t/// in the document while  you type. Language bindings could overwrite this \n\t/// interface and define their own indentation/formating.\n\t/// </summary>\n\tpublic interface IFormattingStrategy\n\t{\n\t\t/// <summary>\n\t\t/// This function formats a specific line after <code>ch</code> is pressed.\n\t\t/// </summary>\n\t\tvoid FormatLine(TextArea textArea, int line, int caretOffset, char charTyped);\n\t\t\n\t\t/// <summary>\n\t\t/// This function sets the indentation level in a specific line\n\t\t/// </summary>\n\t\t/// <returns>\n\t\t/// The target caret position (length of new indentation).\n\t\t/// </returns>\n\t\tint IndentLine(TextArea textArea, int line);\n\t\t\n\t\t/// <summary>\n\t\t/// This function sets the indentlevel in a range of lines.\n\t\t/// </summary>\n\t\tvoid IndentLines(TextArea textArea, int begin, int end);\n\t\t\n\t\t/// <summary>\n\t\t/// Finds the offset of the opening bracket in the block defined by offset skipping\n\t\t/// brackets in strings and comments.\n\t\t/// </summary>\n\t\t/// <param name=\"document\">The document to search in.</param>\n\t\t/// <param name=\"offset\">The offset of an position in the block or the offset of the closing bracket.</param>\n\t\t/// <param name=\"openBracket\">The character for the opening bracket.</param>\n\t\t/// <param name=\"closingBracket\">The character for the closing bracket.</param>\n\t\t/// <returns>Returns the offset of the opening bracket or -1 if no matching bracket was found.</returns>\n\t\tint SearchBracketBackward(IDocument document, int offset, char openBracket, char closingBracket);\n\t\t\n\t\t/// <summary>\n\t\t/// Finds the offset of the closing bracket in the block defined by offset skipping\n\t\t/// brackets in strings and comments.\n\t\t/// </summary>\n\t\t/// <param name=\"document\">The document to search in.</param>\n\t\t/// <param name=\"offset\">The offset of an position in the block or the offset of the opening bracket.</param>\n\t\t/// <param name=\"openBracket\">The character for the opening bracket.</param>\n\t\t/// <param name=\"closingBracket\">The character for the closing bracket.</param>\n\t\t/// <returns>Returns the offset of the closing bracket or -1 if no matching bracket was found.</returns>\n\t\tint SearchBracketForward(IDocument document, int offset, char openBracket, char closingBracket);\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/DefaultHighlightingStrategy.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 3036 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Drawing;\nusing System.Windows.Forms;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\tpublic class DefaultHighlightingStrategy : IHighlightingStrategyUsingRuleSets\n\t{\n\t\tstring    name;\n\t\tList<HighlightRuleSet> rules = new List<HighlightRuleSet>();\n\t\t\n\t\tDictionary<string, HighlightColor> environmentColors = new Dictionary<string, HighlightColor>();\n\t\tDictionary<string, string> properties       = new Dictionary<string, string>();\n\t\tstring[]  extensions;\n\t\t\n\t\tHighlightColor   digitColor;\n\t\tHighlightRuleSet defaultRuleSet = null;\n\t\t\n\t\tpublic HighlightColor DigitColor {\n\t\t\tget {\n\t\t\t\treturn digitColor;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tdigitColor = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic IEnumerable<KeyValuePair<string, HighlightColor>> EnvironmentColors {\n\t\t\tget {\n\t\t\t\treturn environmentColors;\n\t\t\t}\n\t\t}\n\t\t\n\t\tprotected void ImportSettingsFrom(DefaultHighlightingStrategy source)\n\t\t{\n\t\t\tif (source == null)\n\t\t\t\tthrow new ArgumentNullException(\"source\");\n\t\t\tproperties = source.properties;\n\t\t\textensions = source.extensions;\n\t\t\tdigitColor = source.digitColor;\n\t\t\tdefaultRuleSet = source.defaultRuleSet;\n\t\t\tname = source.name;\n\t\t\trules = source.rules;\n\t\t\tenvironmentColors = source.environmentColors;\n\t\t\tdefaultTextColor = source.defaultTextColor;\n\t\t}\n\t\t\n\t\tpublic DefaultHighlightingStrategy() : this(\"Default\")\n\t\t{\n\t\t}\n\t\t\n\t\tpublic DefaultHighlightingStrategy(string name)\n\t\t{\n\t\t\tthis.name = name;\n\t\t\t\n\t\t\tdigitColor       = new HighlightColor(SystemColors.WindowText, false, false);\n\t\t\tdefaultTextColor = new HighlightColor(SystemColors.WindowText, false, false);\n\t\t\t\n\t\t\t// set small 'default color environment'\n\t\t\tenvironmentColors[\"Default\"]          = new HighlightBackground(\"WindowText\", \"Window\", false, false);\n\t\t\tenvironmentColors[\"Selection\"]        = new HighlightColor(\"HighlightText\", \"Highlight\", false, false);\n\t\t\tenvironmentColors[\"VRuler\"]           = new HighlightColor(\"ControlLight\", \"Window\", false, false);\n\t\t\tenvironmentColors[\"InvalidLines\"]     = new HighlightColor(Color.Red, false, false);\n\t\t\tenvironmentColors[\"CaretMarker\"]      = new HighlightColor(Color.Yellow, false, false);\n\t\t\tenvironmentColors[\"LineNumbers\"]      = new HighlightBackground(\"ControlDark\", \"Window\", false, false);\n\t\t\t\n\t\t\tenvironmentColors[\"FoldLine\"]         = new HighlightColor(Color.FromArgb(0x80, 0x80, 0x80), Color.Black, false, false);\n\t\t\tenvironmentColors[\"FoldMarker\"]       = new HighlightColor(Color.FromArgb(0x80, 0x80, 0x80), Color.White, false, false);\n\t\t\tenvironmentColors[\"SelectedFoldLine\"] = new HighlightColor(Color.Black, false, false);\n\t\t\tenvironmentColors[\"EOLMarkers\"]       = new HighlightColor(\"ControlLight\", \"Window\", false, false);\n\t\t\tenvironmentColors[\"SpaceMarkers\"]     = new HighlightColor(\"ControlLight\", \"Window\", false, false);\n\t\t\tenvironmentColors[\"TabMarkers\"]       = new HighlightColor(\"ControlLight\", \"Window\", false, false);\n\t\t\t\n\t\t}\n\t\t\n\t\tpublic Dictionary<string, string> Properties {\n\t\t\tget {\n\t\t\t\treturn properties;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic string Name\n\t\t{\n\t\t\tget {\n\t\t\t\treturn name;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic string[] Extensions\n\t\t{\n\t\t\tset {\n\t\t\t\textensions = value;\n\t\t\t}\n\t\t\tget {\n\t\t\t\treturn extensions;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic List<HighlightRuleSet> Rules {\n\t\t\tget {\n\t\t\t\treturn rules;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic HighlightRuleSet FindHighlightRuleSet(string name)\n\t\t{\n\t\t\tforeach(HighlightRuleSet ruleSet in rules) {\n\t\t\t\tif (ruleSet.Name == name) {\n\t\t\t\t\treturn ruleSet;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\t\n\t\tpublic void AddRuleSet(HighlightRuleSet aRuleSet)\n\t\t{\n\t\t\tHighlightRuleSet existing = FindHighlightRuleSet(aRuleSet.Name);\n\t\t\tif (existing != null) {\n\t\t\t\texisting.MergeFrom(aRuleSet);\n\t\t\t} else {\n\t\t\t\trules.Add(aRuleSet);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic void ResolveReferences()\n\t\t{\n\t\t\t// Resolve references from Span definitions to RuleSets\n\t\t\tResolveRuleSetReferences();\n\t\t\t// Resolve references from RuleSet defintitions to Highlighters defined in an external mode file\n\t\t\tResolveExternalReferences();\n\t\t}\n\t\t\n\t\tvoid ResolveRuleSetReferences()\n\t\t{\n\t\t\tforeach (HighlightRuleSet ruleSet in Rules) {\n\t\t\t\tif (ruleSet.Name == null) {\n\t\t\t\t\tdefaultRuleSet = ruleSet;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tforeach (Span aSpan in ruleSet.Spans) {\n\t\t\t\t\tif (aSpan.Rule != null) {\n\t\t\t\t\t\tbool found = false;\n\t\t\t\t\t\tforeach (HighlightRuleSet refSet in Rules) {\n\t\t\t\t\t\t\tif (refSet.Name == aSpan.Rule) {\n\t\t\t\t\t\t\t\tfound = true;\n\t\t\t\t\t\t\t\taSpan.RuleSet = refSet;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!found) {\n\t\t\t\t\t\t\taSpan.RuleSet = null;\n\t\t\t\t\t\t\tthrow new HighlightingDefinitionInvalidException(\"The RuleSet \" + aSpan.Rule + \" could not be found in mode definition \" + this.Name);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\taSpan.RuleSet = null;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (defaultRuleSet == null) {\n\t\t\t\tthrow new HighlightingDefinitionInvalidException(\"No default RuleSet is defined for mode definition \" + this.Name);\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid ResolveExternalReferences()\n\t\t{\n\t\t\tforeach (HighlightRuleSet ruleSet in Rules) {\n\t\t\t\truleSet.Highlighter = this;\n\t\t\t\tif (ruleSet.Reference != null) {\n\t\t\t\t\tIHighlightingStrategy highlighter = HighlightingManager.Manager.FindHighlighter (ruleSet.Reference);\n\t\t\t\t\t\n\t\t\t\t\tif (highlighter == null)\n\t\t\t\t\t\tthrow new HighlightingDefinitionInvalidException(\"The mode defintion \" + ruleSet.Reference + \" which is refered from the \" + this.Name + \" mode definition could not be found\");\n\t\t\t\t\tif (highlighter is IHighlightingStrategyUsingRuleSets)\n\t\t\t\t\t\truleSet.Highlighter = (IHighlightingStrategyUsingRuleSets)highlighter;\n\t\t\t\t\telse\n\t\t\t\t\t\tthrow new HighlightingDefinitionInvalidException(\"The mode defintion \" + ruleSet.Reference + \" which is refered from the \" + this.Name + \" mode definition does not implement IHighlightingStrategyUsingRuleSets\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n//\t\tinternal void SetDefaultColor(HighlightBackground color)\n//\t\t{\n//\t\t\treturn (HighlightColor)environmentColors[name];\n//\t\t\tdefaultColor = color;\n//\t\t}\n\t\t\n\t\tHighlightColor defaultTextColor;\n\t\t\n\t\tpublic HighlightColor DefaultTextColor {\n\t\t\tget {\n\t\t\t\treturn defaultTextColor;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic void SetColorFor(string name, HighlightColor color)\n\t\t{\n\t\t\tif (name == \"Default\")\n\t\t\t\tdefaultTextColor = new HighlightColor(color.Color, color.Bold, color.Italic);\n\t\t\tenvironmentColors[name] = color;\n\t\t}\n\n\t\tpublic HighlightColor GetColorFor(string name)\n\t\t{\n\t\t\tHighlightColor color;\n\t\t\tif (environmentColors.TryGetValue(name, out color))\n\t\t\t\treturn color;\n\t\t\telse\n\t\t\t\treturn defaultTextColor;\n\t\t}\n\t\t\n\t\tpublic HighlightColor GetColor(IDocument document, LineSegment currentSegment, int currentOffset, int currentLength)\n\t\t{\n\t\t\treturn GetColor(defaultRuleSet, document, currentSegment, currentOffset, currentLength);\n\t\t}\n\n\t\tprotected virtual HighlightColor GetColor(HighlightRuleSet ruleSet, IDocument document, LineSegment currentSegment, int currentOffset, int currentLength)\n\t\t{\n\t\t\tif (ruleSet != null) {\n\t\t\t\tif (ruleSet.Reference != null) {\n\t\t\t\t\treturn ruleSet.Highlighter.GetColor(document, currentSegment, currentOffset, currentLength);\n\t\t\t\t} else {\n\t\t\t\t\treturn (HighlightColor)ruleSet.KeyWords[document,  currentSegment, currentOffset, currentLength];\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\t\n\t\tpublic HighlightRuleSet GetRuleSet(Span aSpan)\n\t\t{\n\t\t\tif (aSpan == null) {\n\t\t\t\treturn this.defaultRuleSet;\n\t\t\t} else {\n\t\t\t\tif (aSpan.RuleSet != null)\n\t\t\t\t{\n\t\t\t\t\tif (aSpan.RuleSet.Reference != null) {\n\t\t\t\t\t\treturn aSpan.RuleSet.Highlighter.GetRuleSet(null);\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn aSpan.RuleSet;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Line state variable\n\t\tprotected LineSegment currentLine;\n\t\tprotected int currentLineNumber;\n\t\t\n\t\t// Span stack state variable\n\t\tprotected SpanStack currentSpanStack;\n\n\t\tpublic virtual void MarkTokens(IDocument document)\n\t\t{\n\t\t\tif (Rules.Count == 0) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tint lineNumber = 0;\n\t\t\t\n\t\t\twhile (lineNumber < document.TotalNumberOfLines) {\n\t\t\t\tLineSegment previousLine = (lineNumber > 0 ? document.GetLineSegment(lineNumber - 1) : null);\n\t\t\t\tif (lineNumber >= document.LineSegmentCollection.Count) { // may be, if the last line ends with a delimiter\n\t\t\t\t\tbreak;                                                // then the last line is not in the collection :)\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tcurrentSpanStack = ((previousLine != null && previousLine.HighlightSpanStack != null) ? previousLine.HighlightSpanStack.Clone() : null);\n\t\t\t\t\n\t\t\t\tif (currentSpanStack != null) {\n\t\t\t\t\twhile (!currentSpanStack.IsEmpty && currentSpanStack.Peek().StopEOL)\n\t\t\t\t\t{\n\t\t\t\t\t\tcurrentSpanStack.Pop();\n\t\t\t\t\t}\n\t\t\t\t\tif (currentSpanStack.IsEmpty) currentSpanStack = null;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tcurrentLine = (LineSegment)document.LineSegmentCollection[lineNumber];\n\t\t\t\t\n\t\t\t\tif (currentLine.Length == -1) { // happens when buffer is empty !\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tcurrentLineNumber = lineNumber;\n\t\t\t\tList<TextWord> words = ParseLine(document);\n\t\t\t\t// Alex: clear old words\n\t\t\t\tif (currentLine.Words != null) {\n\t\t\t\t\tcurrentLine.Words.Clear();\n\t\t\t\t}\n\t\t\t\tcurrentLine.Words = words;\n\t\t\t\tcurrentLine.HighlightSpanStack = (currentSpanStack==null || currentSpanStack.IsEmpty) ? null : currentSpanStack;\n\t\t\t\t\n\t\t\t\t++lineNumber;\n\t\t\t}\n\t\t\tdocument.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea));\n\t\t\tdocument.CommitUpdate();\n\t\t\tcurrentLine = null;\n\t\t}\n\t\t\n\t\tbool MarkTokensInLine(IDocument document, int lineNumber, ref bool spanChanged)\n\t\t{\n\t\t\tcurrentLineNumber = lineNumber;\n\t\t\tbool processNextLine = false;\n\t\t\tLineSegment previousLine = (lineNumber > 0 ? document.GetLineSegment(lineNumber - 1) : null);\n\t\t\t\n\t\t\tcurrentSpanStack = ((previousLine != null && previousLine.HighlightSpanStack != null) ? previousLine.HighlightSpanStack.Clone() : null);\n\t\t\tif (currentSpanStack != null) {\n\t\t\t\twhile (!currentSpanStack.IsEmpty && currentSpanStack.Peek().StopEOL) {\n\t\t\t\t\tcurrentSpanStack.Pop();\n\t\t\t\t}\n\t\t\t\tif (currentSpanStack.IsEmpty) {\n\t\t\t\t\tcurrentSpanStack = null;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tcurrentLine = (LineSegment)document.LineSegmentCollection[lineNumber];\n\t\t\t\n\t\t\tif (currentLine.Length == -1) { // happens when buffer is empty !\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\t\n\t\t\tList<TextWord> words = ParseLine(document);\n\t\t\t\n\t\t\tif (currentSpanStack != null && currentSpanStack.IsEmpty) {\n\t\t\t\tcurrentSpanStack = null;\n\t\t\t}\n\t\t\t\n\t\t\t// Check if the span state has changed, if so we must re-render the next line\n\t\t\t// This check may seem utterly complicated but I didn't want to introduce any function calls\n\t\t\t// or allocations here for perf reasons.\n\t\t\tif(currentLine.HighlightSpanStack != currentSpanStack) {\n\t\t\t\tif (currentLine.HighlightSpanStack == null) {\n\t\t\t\t\tprocessNextLine = false;\n\t\t\t\t\tforeach (Span sp in currentSpanStack) {\n\t\t\t\t\t\tif (!sp.StopEOL) {\n\t\t\t\t\t\t\tspanChanged = true;\n\t\t\t\t\t\t\tprocessNextLine = true;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (currentSpanStack == null) {\n\t\t\t\t\tprocessNextLine = false;\n\t\t\t\t\tforeach (Span sp in currentLine.HighlightSpanStack) {\n\t\t\t\t\t\tif (!sp.StopEOL) {\n\t\t\t\t\t\t\tspanChanged = true;\n\t\t\t\t\t\t\tprocessNextLine = true;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tSpanStack.Enumerator e1 = currentSpanStack.GetEnumerator();\n\t\t\t\t\tSpanStack.Enumerator e2 = currentLine.HighlightSpanStack.GetEnumerator();\n\t\t\t\t\tbool done = false;\n\t\t\t\t\twhile (!done) {\n\t\t\t\t\t\tbool blockSpanIn1 = false;\n\t\t\t\t\t\twhile (e1.MoveNext()) {\n\t\t\t\t\t\t\tif (!((Span)e1.Current).StopEOL) {\n\t\t\t\t\t\t\t\tblockSpanIn1 = true;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbool blockSpanIn2 = false;\n\t\t\t\t\t\twhile (e2.MoveNext()) {\n\t\t\t\t\t\t\tif (!((Span)e2.Current).StopEOL) {\n\t\t\t\t\t\t\t\tblockSpanIn2 = true;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (blockSpanIn1 || blockSpanIn2) {\n\t\t\t\t\t\t\tif (blockSpanIn1 && blockSpanIn2) {\n\t\t\t\t\t\t\t\tif (e1.Current != e2.Current) {\n\t\t\t\t\t\t\t\t\tdone = true;\n\t\t\t\t\t\t\t\t\tprocessNextLine = true;\n\t\t\t\t\t\t\t\t\tspanChanged = true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tspanChanged = true;\n\t\t\t\t\t\t\t\tdone = true;\n\t\t\t\t\t\t\t\tprocessNextLine = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdone = true;\n\t\t\t\t\t\t\tprocessNextLine = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tprocessNextLine = false;\n\t\t\t}\n\t\t\t\n\t\t\t//// Alex: remove old words\n\t\t\tif (currentLine.Words!=null) currentLine.Words.Clear();\n\t\t\tcurrentLine.Words = words;\n\t\t\tcurrentLine.HighlightSpanStack = (currentSpanStack != null && !currentSpanStack.IsEmpty) ? currentSpanStack : null;\n\t\t\t\n\t\t\treturn processNextLine;\n\t\t}\n\t\t\n\t\tpublic virtual void MarkTokens(IDocument document, List<LineSegment> inputLines)\n\t\t{\n\t\t\tif (Rules.Count == 0) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tDictionary<LineSegment, bool> processedLines = new Dictionary<LineSegment, bool>();\n\t\t\t\n\t\t\tbool spanChanged = false;\n\t\t\tint documentLineSegmentCount = document.LineSegmentCollection.Count;\n\t\t\t\n\t\t\tforeach (LineSegment lineToProcess in inputLines) {\n\t\t\t\tif (!processedLines.ContainsKey(lineToProcess)) {\n\t\t\t\t\tint lineNumber = lineToProcess.LineNumber;\n\t\t\t\t\tbool processNextLine = true;\n\t\t\t\t\t\n\t\t\t\t\tif (lineNumber != -1) {\n\t\t\t\t\t\twhile (processNextLine && lineNumber < documentLineSegmentCount) {\n\t\t\t\t\t\t\tprocessNextLine = MarkTokensInLine(document, lineNumber, ref spanChanged);\n\t\t\t\t\t\t\tprocessedLines[currentLine] = true;\n\t\t\t\t\t\t\t++lineNumber;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (spanChanged || inputLines.Count > 20) {\n\t\t\t\t// if the span was changed (more than inputLines lines had to be reevaluated)\n\t\t\t\t// or if there are many lines in inputLines, it's faster to update the whole\n\t\t\t\t// text area instead of many small segments\n\t\t\t\tdocument.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea));\n\t\t\t} else {\n//\t\t\t\tdocument.Caret.ValidateCaretPos();\n//\t\t\t\tdocument.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, document.GetLineNumberForOffset(document.Caret.Offset)));\n//\n\t\t\t\tforeach (LineSegment lineToProcess in inputLines) {\n\t\t\t\t\tdocument.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, lineToProcess.LineNumber));\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t\tdocument.CommitUpdate();\n\t\t\tcurrentLine = null;\n\t\t}\n\t\t\n\t\t// Span state variables\n\t\tprotected bool inSpan;\n\t\tprotected Span activeSpan;\n\t\tprotected HighlightRuleSet activeRuleSet;\n\t\t\n\t\t// Line scanning state variables\n\t\tprotected int currentOffset;\n\t\tprotected int currentLength;\n\t\t\n\t\tvoid UpdateSpanStateVariables()\n\t\t{\n\t\t\tinSpan = (currentSpanStack != null && !currentSpanStack.IsEmpty);\n\t\t\tactiveSpan = inSpan ? currentSpanStack.Peek() : null;\n\t\t\tactiveRuleSet = GetRuleSet(activeSpan);\n\t\t}\n\n\t\tList<TextWord> ParseLine(IDocument document)\n\t\t{\n\t\t\tList<TextWord> words = new List<TextWord>();\n\t\t\tHighlightColor markNext = null;\n\t\t\t\n\t\t\tcurrentOffset = 0;\n\t\t\tcurrentLength = 0;\n\t\t\tUpdateSpanStateVariables();\n\t\t\t\n\t\t\tint currentLineLength = currentLine.Length;\n\t\t\tint currentLineOffset = currentLine.Offset;\n\t\t\t\n\t\t\tfor (int i = 0; i < currentLineLength; ++i) {\n\t\t\t\tchar ch = document.GetCharAt(currentLineOffset + i);\n\t\t\t\tswitch (ch) {\n\t\t\t\t\tcase '\\n':\n\t\t\t\t\tcase '\\r':\n\t\t\t\t\t\tPushCurWord(document, ref markNext, words);\n\t\t\t\t\t\t++currentOffset;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase ' ':\n\t\t\t\t\t\tPushCurWord(document, ref markNext, words);\n\t\t\t\t\t\tif (activeSpan != null && activeSpan.Color.HasBackground) {\n\t\t\t\t\t\t\twords.Add(new TextWord.SpaceTextWord(activeSpan.Color));\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\twords.Add(TextWord.Space);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t++currentOffset;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '\\t':\n\t\t\t\t\t\tPushCurWord(document, ref markNext, words);\n\t\t\t\t\t\tif (activeSpan != null && activeSpan.Color.HasBackground) {\n\t\t\t\t\t\t\twords.Add(new TextWord.TabTextWord(activeSpan.Color));\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\twords.Add(TextWord.Tab);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t++currentOffset;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// handle escape characters\n\t\t\t\t\t\t\tchar escapeCharacter = '\\0';\n\t\t\t\t\t\t\tif (activeSpan != null && activeSpan.EscapeCharacter != '\\0') {\n\t\t\t\t\t\t\t\tescapeCharacter = activeSpan.EscapeCharacter;\n\t\t\t\t\t\t\t} else if (activeRuleSet != null) {\n\t\t\t\t\t\t\t\tescapeCharacter = activeRuleSet.EscapeCharacter;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (escapeCharacter != '\\0' && escapeCharacter == ch) {\n\t\t\t\t\t\t\t\t// we found the escape character\n\t\t\t\t\t\t\t\tif (activeSpan != null && activeSpan.End != null && activeSpan.End.Length == 1\n\t\t\t\t\t\t\t\t    && escapeCharacter == activeSpan.End[0])\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t// the escape character is a end-doubling escape character\n\t\t\t\t\t\t\t\t\t// it may count as escape only when the next character is the escape, too\n\t\t\t\t\t\t\t\t\tif (i + 1 < currentLineLength) {\n\t\t\t\t\t\t\t\t\t\tif (document.GetCharAt(currentLineOffset + i + 1) == escapeCharacter) {\n\t\t\t\t\t\t\t\t\t\t\tcurrentLength += 2;\n\t\t\t\t\t\t\t\t\t\t\tPushCurWord(document, ref markNext, words);\n\t\t\t\t\t\t\t\t\t\t\t++i;\n\t\t\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t// this is a normal \\-style escape\n\t\t\t\t\t\t\t\t\t++currentLength;\n\t\t\t\t\t\t\t\t\tif (i + 1 < currentLineLength) {\n\t\t\t\t\t\t\t\t\t\t++currentLength;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tPushCurWord(document, ref markNext, words);\n\t\t\t\t\t\t\t\t\t++i;\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t// highlight digits\n\t\t\t\t\t\t\tif (!inSpan && (Char.IsDigit(ch) || (ch == '.' && i + 1 < currentLineLength && Char.IsDigit(document.GetCharAt(currentLineOffset + i + 1)))) && currentLength == 0) {\n\t\t\t\t\t\t\t\tbool ishex = false;\n\t\t\t\t\t\t\t\tbool isfloatingpoint = false;\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tif (ch == '0' && i + 1 < currentLineLength && Char.ToUpper(document.GetCharAt(currentLineOffset + i + 1)) == 'X') { // hex digits\n\t\t\t\t\t\t\t\t\tconst string hex = \"0123456789ABCDEF\";\n\t\t\t\t\t\t\t\t\t++currentLength;\n\t\t\t\t\t\t\t\t\t++i; // skip 'x'\n\t\t\t\t\t\t\t\t\t++currentLength;\n\t\t\t\t\t\t\t\t\tishex = true;\n\t\t\t\t\t\t\t\t\twhile (i + 1 < currentLineLength && hex.IndexOf(Char.ToUpper(document.GetCharAt(currentLineOffset + i + 1))) != -1) {\n\t\t\t\t\t\t\t\t\t\t++i;\n\t\t\t\t\t\t\t\t\t\t++currentLength;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t++currentLength;\n\t\t\t\t\t\t\t\t\twhile (i + 1 < currentLineLength && Char.IsDigit(document.GetCharAt(currentLineOffset + i + 1))) {\n\t\t\t\t\t\t\t\t\t\t++i;\n\t\t\t\t\t\t\t\t\t\t++currentLength;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (!ishex && i + 1 < currentLineLength && document.GetCharAt(currentLineOffset + i + 1) == '.') {\n\t\t\t\t\t\t\t\t\tisfloatingpoint = true;\n\t\t\t\t\t\t\t\t\t++i;\n\t\t\t\t\t\t\t\t\t++currentLength;\n\t\t\t\t\t\t\t\t\twhile (i + 1 < currentLineLength && Char.IsDigit(document.GetCharAt(currentLineOffset + i + 1))) {\n\t\t\t\t\t\t\t\t\t\t++i;\n\t\t\t\t\t\t\t\t\t\t++currentLength;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tif (i + 1 < currentLineLength && Char.ToUpper(document.GetCharAt(currentLineOffset + i + 1)) == 'E') {\n\t\t\t\t\t\t\t\t\tisfloatingpoint = true;\n\t\t\t\t\t\t\t\t\t++i;\n\t\t\t\t\t\t\t\t\t++currentLength;\n\t\t\t\t\t\t\t\t\tif (i + 1 < currentLineLength && (document.GetCharAt(currentLineOffset + i + 1) == '+' || document.GetCharAt(currentLine.Offset + i + 1) == '-')) {\n\t\t\t\t\t\t\t\t\t\t++i;\n\t\t\t\t\t\t\t\t\t\t++currentLength;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\twhile (i + 1 < currentLine.Length && Char.IsDigit(document.GetCharAt(currentLineOffset + i + 1))) {\n\t\t\t\t\t\t\t\t\t\t++i;\n\t\t\t\t\t\t\t\t\t\t++currentLength;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tif (i + 1 < currentLine.Length) {\n\t\t\t\t\t\t\t\t\tchar nextch = Char.ToUpper(document.GetCharAt(currentLineOffset + i + 1));\n\t\t\t\t\t\t\t\t\tif (nextch == 'F' || nextch == 'M' || nextch == 'D') {\n\t\t\t\t\t\t\t\t\t\tisfloatingpoint = true;\n\t\t\t\t\t\t\t\t\t\t++i;\n\t\t\t\t\t\t\t\t\t\t++currentLength;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tif (!isfloatingpoint) {\n\t\t\t\t\t\t\t\t\tbool isunsigned = false;\n\t\t\t\t\t\t\t\t\tif (i + 1 < currentLineLength && Char.ToUpper(document.GetCharAt(currentLineOffset + i + 1)) == 'U') {\n\t\t\t\t\t\t\t\t\t\t++i;\n\t\t\t\t\t\t\t\t\t\t++currentLength;\n\t\t\t\t\t\t\t\t\t\tisunsigned = true;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (i + 1 < currentLineLength && Char.ToUpper(document.GetCharAt(currentLineOffset + i + 1)) == 'L') {\n\t\t\t\t\t\t\t\t\t\t++i;\n\t\t\t\t\t\t\t\t\t\t++currentLength;\n\t\t\t\t\t\t\t\t\t\tif (!isunsigned && i + 1 < currentLineLength && Char.ToUpper(document.GetCharAt(currentLineOffset + i + 1)) == 'U') {\n\t\t\t\t\t\t\t\t\t\t\t++i;\n\t\t\t\t\t\t\t\t\t\t\t++currentLength;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\twords.Add(new TextWord(document, currentLine, currentOffset, currentLength, DigitColor, false));\n\t\t\t\t\t\t\t\tcurrentOffset += currentLength;\n\t\t\t\t\t\t\t\tcurrentLength = 0;\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Check for SPAN ENDs\n\t\t\t\t\t\t\tif (inSpan) {\n\t\t\t\t\t\t\t\tif (activeSpan.End != null && activeSpan.End.Length > 0) {\n\t\t\t\t\t\t\t\t\tif (MatchExpr(currentLine, activeSpan.End, i, document, activeSpan.IgnoreCase)) {\n\t\t\t\t\t\t\t\t\t\tPushCurWord(document, ref markNext, words);\n\t\t\t\t\t\t\t\t\t\tstring regex = GetRegString(currentLine, activeSpan.End, i, document);\n\t\t\t\t\t\t\t\t\t\tcurrentLength += regex.Length;\n\t\t\t\t\t\t\t\t\t\twords.Add(new TextWord(document, currentLine, currentOffset, currentLength, activeSpan.EndColor, false));\n\t\t\t\t\t\t\t\t\t\tcurrentOffset += currentLength;\n\t\t\t\t\t\t\t\t\t\tcurrentLength = 0;\n\t\t\t\t\t\t\t\t\t\ti += regex.Length - 1;\n\t\t\t\t\t\t\t\t\t\tcurrentSpanStack.Pop();\n\t\t\t\t\t\t\t\t\t\tUpdateSpanStateVariables();\n\t\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t// check for SPAN BEGIN\n\t\t\t\t\t\t\tif (activeRuleSet != null) {\n\t\t\t\t\t\t\t\tforeach (Span span in activeRuleSet.Spans) {\n\t\t\t\t\t\t\t\t\tif ((!span.IsBeginSingleWord || currentLength == 0)\n\t\t\t\t\t\t\t\t\t    && (!span.IsBeginStartOfLine.HasValue || span.IsBeginStartOfLine.Value == (currentLength == 0 && words.TrueForAll(delegate(TextWord textWord) { return textWord.Type != TextWordType.Word; })))\n\t\t\t\t\t\t\t\t\t    && MatchExpr(currentLine, span.Begin, i, document, activeRuleSet.IgnoreCase)) {\n\t\t\t\t\t\t\t\t\t\tPushCurWord(document, ref markNext, words);\n\t\t\t\t\t\t\t\t\t\tstring regex = GetRegString(currentLine, span.Begin, i, document);\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tif (!OverrideSpan(regex, document, words, span, ref i)) {\n\t\t\t\t\t\t\t\t\t\t\tcurrentLength += regex.Length;\n\t\t\t\t\t\t\t\t\t\t\twords.Add(new TextWord(document, currentLine, currentOffset, currentLength, span.BeginColor, false));\n\t\t\t\t\t\t\t\t\t\t\tcurrentOffset += currentLength;\n\t\t\t\t\t\t\t\t\t\t\tcurrentLength = 0;\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\ti += regex.Length - 1;\n\t\t\t\t\t\t\t\t\t\t\tif (currentSpanStack == null) {\n\t\t\t\t\t\t\t\t\t\t\t\tcurrentSpanStack = new SpanStack();\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tcurrentSpanStack.Push(span);\n\t\t\t\t\t\t\t\t\t\t\tspan.IgnoreCase = activeRuleSet.IgnoreCase;\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\tUpdateSpanStateVariables();\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tgoto skip;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t// check if the char is a delimiter\n\t\t\t\t\t\t\tif (activeRuleSet != null && (int)ch < 256 && activeRuleSet.Delimiters[(int)ch]) {\n\t\t\t\t\t\t\t\tPushCurWord(document, ref markNext, words);\n\t\t\t\t\t\t\t\tif (currentOffset + currentLength +1 < currentLine.Length) {\n\t\t\t\t\t\t\t\t\t++currentLength;\n\t\t\t\t\t\t\t\t\tPushCurWord(document, ref markNext, words);\n\t\t\t\t\t\t\t\t\tgoto skip;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t++currentLength;\n\t\t\t\t\t\t\tskip: continue;\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tPushCurWord(document, ref markNext, words);\n\t\t\t\n\t\t\tOnParsedLine(document, currentLine, words);\n\t\t\t\n\t\t\treturn words;\n\t\t}\n\t\t\n\t\tprotected virtual void OnParsedLine(IDocument document, LineSegment currentLine, List<TextWord> words)\n\t\t{\n\t\t}\n\t\t\n\t\tprotected virtual bool OverrideSpan(string spanBegin, IDocument document, List<TextWord> words, Span span, ref int lineOffset)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// pushes the curWord string on the word list, with the\n\t\t/// correct color.\n\t\t/// </summary>\n\t\tvoid PushCurWord(IDocument document, ref HighlightColor markNext, List<TextWord> words)\n\t\t{\n\t\t\t// Svante Lidman : Need to look through the next prev logic.\n\t\t\tif (currentLength > 0) {\n\t\t\t\tif (words.Count > 0 && activeRuleSet != null) {\n\t\t\t\t\tTextWord prevWord = null;\n\t\t\t\t\tint pInd = words.Count - 1;\n\t\t\t\t\twhile (pInd >= 0) {\n\t\t\t\t\t\tif (!((TextWord)words[pInd]).IsWhiteSpace) {\n\t\t\t\t\t\t\tprevWord = (TextWord)words[pInd];\n\t\t\t\t\t\t\tif (prevWord.HasDefaultColor) {\n\t\t\t\t\t\t\t\tPrevMarker marker = (PrevMarker)activeRuleSet.PrevMarkers[document, currentLine, currentOffset, currentLength];\n\t\t\t\t\t\t\t\tif (marker != null) {\n\t\t\t\t\t\t\t\t\tprevWord.SyntaxColor = marker.Color;\n//\t\t\t\t\t\t\t\t\tdocument.Caret.ValidateCaretPos();\n//\t\t\t\t\t\t\t\t\tdocument.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, document.GetLineNumberForOffset(document.Caret.Offset)));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpInd--;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (inSpan) {\n\t\t\t\t\tHighlightColor c = null;\n\t\t\t\t\tbool hasDefaultColor = true;\n\t\t\t\t\tif (activeSpan.Rule == null) {\n\t\t\t\t\t\tc = activeSpan.Color;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tc = GetColor(activeRuleSet, document, currentLine, currentOffset, currentLength);\n\t\t\t\t\t\thasDefaultColor = false;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif (c == null) {\n\t\t\t\t\t\tc = activeSpan.Color;\n\t\t\t\t\t\tif (c.Color == Color.Transparent) {\n\t\t\t\t\t\t\tc = this.DefaultTextColor;\n\t\t\t\t\t\t}\n\t\t\t\t\t\thasDefaultColor = true;\n\t\t\t\t\t}\n\t\t\t\t\twords.Add(new TextWord(document, currentLine, currentOffset, currentLength, markNext != null ? markNext : c, hasDefaultColor));\n\t\t\t\t} else {\n\t\t\t\t\tHighlightColor c = markNext != null ? markNext : GetColor(activeRuleSet, document, currentLine, currentOffset, currentLength);\n\t\t\t\t\tif (c == null) {\n\t\t\t\t\t\twords.Add(new TextWord(document, currentLine, currentOffset, currentLength, this.DefaultTextColor, true));\n\t\t\t\t\t} else {\n\t\t\t\t\t\twords.Add(new TextWord(document, currentLine, currentOffset, currentLength, c, false));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (activeRuleSet != null) {\n\t\t\t\t\tNextMarker nextMarker = (NextMarker)activeRuleSet.NextMarkers[document, currentLine, currentOffset, currentLength];\n\t\t\t\t\tif (nextMarker != null) {\n\t\t\t\t\t\tif (nextMarker.MarkMarker && words.Count > 0) {\n\t\t\t\t\t\t\tTextWord prevword = ((TextWord)words[words.Count - 1]);\n\t\t\t\t\t\t\tprevword.SyntaxColor = nextMarker.Color;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmarkNext = nextMarker.Color;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmarkNext = null;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcurrentOffset += currentLength;\n\t\t\t\tcurrentLength = 0;\n\t\t\t}\n\t\t}\n\t\t\n\t\t#region Matching\n\t\t/// <summary>\n\t\t/// get the string, which matches the regular expression expr,\n\t\t/// in string s2 at index\n\t\t/// </summary>\n\t\tstatic string GetRegString(LineSegment lineSegment, char[] expr, int index, IDocument document)\n\t\t{\n\t\t\tint j = 0;\n\t\t\tStringBuilder regexpr = new StringBuilder();\n\t\t\t\n\t\t\tfor (int i = 0; i < expr.Length; ++i, ++j) {\n\t\t\t\tif (index + j >= lineSegment.Length)\n\t\t\t\t\tbreak;\n\t\t\t\t\n\t\t\t\tswitch (expr[i]) {\n\t\t\t\t\tcase '@': // \"special\" meaning\n\t\t\t\t\t\t++i;\n\t\t\t\t\t\tswitch (expr[i]) {\n\t\t\t\t\t\t\tcase '!': // don't match the following expression\n\t\t\t\t\t\t\t\tStringBuilder whatmatch = new StringBuilder();\n\t\t\t\t\t\t\t\t++i;\n\t\t\t\t\t\t\t\twhile (i < expr.Length && expr[i] != '@') {\n\t\t\t\t\t\t\t\t\twhatmatch.Append(expr[i++]);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase '@': // matches @\n\t\t\t\t\t\t\t\tregexpr.Append(document.GetCharAt(lineSegment.Offset + index + j));\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tif (expr[i] != document.GetCharAt(lineSegment.Offset + index + j)) {\n\t\t\t\t\t\t\treturn regexpr.ToString();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tregexpr.Append(document.GetCharAt(lineSegment.Offset + index + j));\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn regexpr.ToString();\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// returns true, if the get the string s2 at index matches the expression expr\n\t\t/// </summary>\n\t\tstatic bool MatchExpr(LineSegment lineSegment, char[] expr, int index, IDocument document, bool ignoreCase)\n\t\t{\n\t\t\tfor (int i = 0, j = 0; i < expr.Length; ++i, ++j) {\n\t\t\t\tswitch (expr[i]) {\n\t\t\t\t\tcase '@': // \"special\" meaning\n\t\t\t\t\t\t++i;\n\t\t\t\t\t\tif (i < expr.Length) {\n\t\t\t\t\t\t\tswitch (expr[i]) {\n\t\t\t\t\t\t\t\tcase 'C': // match whitespace or punctuation\n\t\t\t\t\t\t\t\t\tif (index + j == lineSegment.Offset || index + j >= lineSegment.Offset + lineSegment.Length) {\n\t\t\t\t\t\t\t\t\t\t// nothing (EOL or SOL)\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tchar ch = document.GetCharAt(lineSegment.Offset + index + j);\n\t\t\t\t\t\t\t\t\t\tif (!Char.IsWhiteSpace(ch) && !Char.IsPunctuation(ch)) {\n\t\t\t\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase '!': // don't match the following expression\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tStringBuilder whatmatch = new StringBuilder();\n\t\t\t\t\t\t\t\t\t\t++i;\n\t\t\t\t\t\t\t\t\t\twhile (i < expr.Length && expr[i] != '@') {\n\t\t\t\t\t\t\t\t\t\t\twhatmatch.Append(expr[i++]);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tif (lineSegment.Offset + index + j + whatmatch.Length < document.TextLength) {\n\t\t\t\t\t\t\t\t\t\t\tint k = 0;\n\t\t\t\t\t\t\t\t\t\t\tfor (; k < whatmatch.Length; ++k) {\n\t\t\t\t\t\t\t\t\t\t\t\tchar docChar = ignoreCase ? Char.ToUpperInvariant(document.GetCharAt(lineSegment.Offset + index + j + k)) : document.GetCharAt(lineSegment.Offset + index + j + k);\n\t\t\t\t\t\t\t\t\t\t\t\tchar spanChar = ignoreCase ? Char.ToUpperInvariant(whatmatch[k]) : whatmatch[k];\n\t\t\t\t\t\t\t\t\t\t\t\tif (docChar != spanChar) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tif (k >= whatmatch.Length) {\n\t\t\t\t\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n//\t\t\t\t\t\t\t\t\t--j;\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcase '-': // don't match the  expression before\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tStringBuilder whatmatch = new StringBuilder();\n\t\t\t\t\t\t\t\t\t\t++i;\n\t\t\t\t\t\t\t\t\t\twhile (i < expr.Length && expr[i] != '@') {\n\t\t\t\t\t\t\t\t\t\t\twhatmatch.Append(expr[i++]);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tif (index - whatmatch.Length >= 0) {\n\t\t\t\t\t\t\t\t\t\t\tint k = 0;\n\t\t\t\t\t\t\t\t\t\t\tfor (; k < whatmatch.Length; ++k) {\n\t\t\t\t\t\t\t\t\t\t\t\tchar docChar = ignoreCase ? Char.ToUpperInvariant(document.GetCharAt(lineSegment.Offset + index - whatmatch.Length + k)) : document.GetCharAt(lineSegment.Offset + index - whatmatch.Length + k);\n\t\t\t\t\t\t\t\t\t\t\t\tchar spanChar = ignoreCase ? Char.ToUpperInvariant(whatmatch[k]) : whatmatch[k];\n\t\t\t\t\t\t\t\t\t\t\t\tif (docChar != spanChar)\n\t\t\t\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tif (k >= whatmatch.Length) {\n\t\t\t\t\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n//\t\t\t\t\t\t\t\t\t--j;\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcase '@': // matches @\n\t\t\t\t\t\t\t\t\tif (index + j >= lineSegment.Length || '@' != document.GetCharAt(lineSegment.Offset + index + j)) {\n\t\t\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (index + j >= lineSegment.Length) {\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tchar docChar = ignoreCase ? Char.ToUpperInvariant(document.GetCharAt(lineSegment.Offset + index + j)) : document.GetCharAt(lineSegment.Offset + index + j);\n\t\t\t\t\t\t\tchar spanChar = ignoreCase ? Char.ToUpperInvariant(expr[i]) : expr[i];\n\t\t\t\t\t\t\tif (docChar != spanChar) {\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\t#endregion\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/FontContainer.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 3358 $</version>\n// </file>\n\nusing System;\nusing System.Drawing;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\t/// <summary>\n\t/// This class is used to generate bold, italic and bold/italic fonts out\n\t/// of a base font.\n\t/// </summary>\n\tpublic class FontContainer\n\t{\n\t\tFont defaultFont;\n\t\tFont regularfont, boldfont, italicfont, bolditalicfont;\n\t\t\n\t\t/// <value>\n\t\t/// The scaled, regular version of the base font\n\t\t/// </value>\n\t\tpublic Font RegularFont {\n\t\t\tget {\n\t\t\t\treturn regularfont;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// The scaled, bold version of the base font\n\t\t/// </value>\n\t\tpublic Font BoldFont {\n\t\t\tget {\n\t\t\t\treturn boldfont;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// The scaled, italic version of the base font\n\t\t/// </value>\n\t\tpublic Font ItalicFont {\n\t\t\tget {\n\t\t\t\treturn italicfont;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// The scaled, bold/italic version of the base font\n\t\t/// </value>\n\t\tpublic Font BoldItalicFont {\n\t\t\tget {\n\t\t\t\treturn bolditalicfont;\n\t\t\t}\n\t\t}\n\t\t\n\t\tstatic float twipsPerPixelY;\n\t\t\n\t\tpublic static float TwipsPerPixelY {\n\t\t\tget {\n\t\t\t\tif (twipsPerPixelY == 0) {\n\t\t\t\t\tusing (Bitmap bmp = new Bitmap(1,1)) {\n\t\t\t\t\t\tusing (Graphics g = Graphics.FromImage(bmp)) {\n\t\t\t\t\t\t\ttwipsPerPixelY = 1440 / g.DpiY;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn twipsPerPixelY;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// The base font\n\t\t/// </value>\n\t\tpublic Font DefaultFont {\n\t\t\tget {\n\t\t\t\treturn defaultFont;\n\t\t\t}\n\t\t\tset {\n\t\t\t\t// 1440 twips is one inch\n\t\t\t\tfloat pixelSize = (float)Math.Round(value.SizeInPoints * 20 / TwipsPerPixelY);\n\t\t\t\t\n\t\t\t\tdefaultFont    = value;\n\t\t\t\tregularfont    = new Font(value.FontFamily, pixelSize * TwipsPerPixelY / 20f, FontStyle.Regular);\n\t\t\t\tboldfont       = new Font(regularfont, FontStyle.Bold);\n\t\t\t\titalicfont     = new Font(regularfont, FontStyle.Italic);\n\t\t\t\tbolditalicfont = new Font(regularfont, FontStyle.Bold | FontStyle.Italic);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic static Font ParseFont(string font)\n\t\t{\n\t\t\tstring[] descr = font.Split(new char[]{',', '='});\n\t\t\treturn new Font(descr[1], Single.Parse(descr[3]));\n\t\t}\n\t\t\n\t\tpublic FontContainer(Font defaultFont)\n\t\t{\n\t\t\tthis.DefaultFont = defaultFont;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/HighlightBackground.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 1965 $</version>\n// </file>\n\nusing System;\nusing System.Drawing;\nusing System.Xml;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\t/// <summary>\n\t/// Extens the highlighting color with a background image.\n\t/// </summary>\n\tpublic class HighlightBackground : HighlightColor\n\t{\n\t\tImage backgroundImage;\n\t\t\n\t\t/// <value>\n\t\t/// The image used as background\n\t\t/// </value>\n\t\tpublic Image BackgroundImage {\n\t\t\tget {\n\t\t\t\treturn backgroundImage;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Creates a new instance of <see cref=\"HighlightBackground\"/>\n\t\t/// </summary>\n\t\tpublic HighlightBackground(XmlElement el) : base(el)\n\t\t{\n\t\t\tif (el.Attributes[\"image\"] != null) {\n\t\t\t\tbackgroundImage = new Bitmap(el.Attributes[\"image\"].InnerText);\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Creates a new instance of <see cref=\"HighlightBackground\"/>\n\t\t/// </summary>\n\t\tpublic HighlightBackground(Color color, Color backgroundcolor, bool bold, bool italic) : base(color, backgroundcolor, bold, italic)\n\t\t{\n\t\t}\n\t\t\n\t\tpublic HighlightBackground(string systemColor, string systemBackgroundColor, bool bold, bool italic) : base(systemColor, systemBackgroundColor, bold, italic)\n\t\t{\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/HighlightColor.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 1965 $</version>\n// </file>\n\nusing System;\nusing System.Diagnostics;\nusing System.Drawing;\nusing System.Globalization;\nusing System.Reflection;\nusing System.Xml;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\t/// <summary>\n\t/// A color used for highlighting\n\t/// </summary>\n\tpublic class HighlightColor\n\t{\n\t\tbool   systemColor     = false;\n\t\tstring systemColorName = null;\n\t\t\n\t\tbool   systemBgColor     = false;\n\t\tstring systemBgColorName = null;\n\t\t\n\t\tColor  color;\n\t\tColor  backgroundcolor = System.Drawing.Color.WhiteSmoke;\n\t\t\n\t\tbool   bold   = false;\n\t\tbool   italic = false;\n\t\tbool   hasForeground = false;\n\t\tbool   hasBackground = false;\n\t\t\n\t\tpublic bool HasForeground {\n\t\t\tget {\n\t\t\t\treturn hasForeground;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic bool HasBackground {\n\t\t\tget {\n\t\t\t\treturn hasBackground;\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\t/// <value>\n\t\t/// If true the font will be displayed bold style\n\t\t/// </value>\n\t\tpublic bool Bold {\n\t\t\tget {\n\t\t\t\treturn bold;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// If true the font will be displayed italic style\n\t\t/// </value>\n\t\tpublic bool Italic {\n\t\t\tget {\n\t\t\t\treturn italic;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// The background color used\n\t\t/// </value>\n\t\tpublic Color BackgroundColor {\n\t\t\tget {\n\t\t\t\tif (!systemBgColor) {\n\t\t\t\t\treturn backgroundcolor;\n\t\t\t\t}\n\t\t\t\treturn ParseColorString(systemBgColorName);\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// The foreground color used\n\t\t/// </value>\n\t\tpublic Color Color {\n\t\t\tget {\n\t\t\t\tif (!systemColor) {\n\t\t\t\t\treturn color;\n\t\t\t\t}\n\t\t\t\treturn ParseColorString(systemColorName);\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// The font used\n\t\t/// </value>\n\t\tpublic Font GetFont(FontContainer fontContainer)\n\t\t{\n\t\t\tif (Bold) {\n\t\t\t\treturn Italic ? fontContainer.BoldItalicFont : fontContainer.BoldFont;\n\t\t\t}\n\t\t\treturn Italic ? fontContainer.ItalicFont : fontContainer.RegularFont;\n\t\t}\n\t\t\n\t\tColor ParseColorString(string colorName)\n\t\t{\n\t\t\tstring[] cNames = colorName.Split('*');\n\t\t\tPropertyInfo myPropInfo = typeof(System.Drawing.SystemColors).GetProperty(cNames[0], BindingFlags.Public |\n\t\t\t                                                                          BindingFlags.Instance |\n\t\t\t                                                                          BindingFlags.Static);\n\t\t\tColor c = (Color)myPropInfo.GetValue(null, null);\n\t\t\t\n\t\t\tif (cNames.Length == 2) {\n\t\t\t\t// hack : can't figure out how to parse doubles with '.' (culture info might set the '.' to ',')\n\t\t\t\tdouble factor = Double.Parse(cNames[1]) / 100;\n\t\t\t\tc = Color.FromArgb((int)((double)c.R * factor), (int)((double)c.G * factor), (int)((double)c.B * factor));\n\t\t\t}\n\t\t\t\n\t\t\treturn c;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Creates a new instance of <see cref=\"HighlightColor\"/>\n\t\t/// </summary>\n\t\tpublic HighlightColor(XmlElement el)\n\t\t{\n\t\t\tDebug.Assert(el != null, \"ICSharpCode.TextEditor.Document.SyntaxColor(XmlElement el) : el == null\");\n\t\t\tif (el.Attributes[\"bold\"] != null) {\n\t\t\t\tbold = Boolean.Parse(el.Attributes[\"bold\"].InnerText);\n\t\t\t}\n\t\t\t\n\t\t\tif (el.Attributes[\"italic\"] != null) {\n\t\t\t\titalic = Boolean.Parse(el.Attributes[\"italic\"].InnerText);\n\t\t\t}\n\t\t\t\n\t\t\tif (el.Attributes[\"color\"] != null) {\n\t\t\t\tstring c = el.Attributes[\"color\"].InnerText;\n\t\t\t\tif (c[0] == '#') {\n\t\t\t\t\tcolor = ParseColor(c);\n\t\t\t\t} else if (c.StartsWith(\"SystemColors.\")) {\n\t\t\t\t\tsystemColor     = true;\n\t\t\t\t\tsystemColorName = c.Substring(\"SystemColors.\".Length);\n\t\t\t\t} else {\n\t\t\t\t\tcolor = (Color)(Color.GetType()).InvokeMember(c, BindingFlags.GetProperty, null, Color, new object[0]);\n\t\t\t\t}\n\t\t\t\thasForeground = true;\n\t\t\t} else {\n\t\t\t\tcolor = Color.Transparent; // to set it to the default value.\n\t\t\t}\n\t\t\t\n\t\t\tif (el.Attributes[\"bgcolor\"] != null) {\n\t\t\t\tstring c = el.Attributes[\"bgcolor\"].InnerText;\n\t\t\t\tif (c[0] == '#') {\n\t\t\t\t\tbackgroundcolor = ParseColor(c);\n\t\t\t\t} else if (c.StartsWith(\"SystemColors.\")) {\n\t\t\t\t\tsystemBgColor     = true;\n\t\t\t\t\tsystemBgColorName = c.Substring(\"SystemColors.\".Length);\n\t\t\t\t} else {\n\t\t\t\t\tbackgroundcolor = (Color)(Color.GetType()).InvokeMember(c, BindingFlags.GetProperty, null, Color, new object[0]);\n\t\t\t\t}\n\t\t\t\thasBackground = true;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Creates a new instance of <see cref=\"HighlightColor\"/>\n\t\t/// </summary>\n\t\tpublic HighlightColor(XmlElement el, HighlightColor defaultColor)\n\t\t{\n\t\t\tDebug.Assert(el != null, \"ICSharpCode.TextEditor.Document.SyntaxColor(XmlElement el) : el == null\");\n\t\t\tif (el.Attributes[\"bold\"] != null) {\n\t\t\t\tbold = Boolean.Parse(el.Attributes[\"bold\"].InnerText);\n\t\t\t} else {\n\t\t\t\tbold = defaultColor.Bold;\n\t\t\t}\n\t\t\t\n\t\t\tif (el.Attributes[\"italic\"] != null) {\n\t\t\t\titalic = Boolean.Parse(el.Attributes[\"italic\"].InnerText);\n\t\t\t} else {\n\t\t\t\titalic = defaultColor.Italic;\n\t\t\t}\n\t\t\t\n\t\t\tif (el.Attributes[\"color\"] != null) {\n\t\t\t\tstring c = el.Attributes[\"color\"].InnerText;\n\t\t\t\tif (c[0] == '#') {\n\t\t\t\t\tcolor = ParseColor(c);\n\t\t\t\t} else if (c.StartsWith(\"SystemColors.\")) {\n\t\t\t\t\tsystemColor     = true;\n\t\t\t\t\tsystemColorName = c.Substring(\"SystemColors.\".Length);\n\t\t\t\t} else {\n\t\t\t\t\tcolor = (Color)(Color.GetType()).InvokeMember(c, BindingFlags.GetProperty, null, Color, new object[0]);\n\t\t\t\t}\n\t\t\t\thasForeground = true;\n\t\t\t} else {\n\t\t\t\tcolor = defaultColor.color;\n\t\t\t}\n\t\t\t\n\t\t\tif (el.Attributes[\"bgcolor\"] != null) {\n\t\t\t\tstring c = el.Attributes[\"bgcolor\"].InnerText;\n\t\t\t\tif (c[0] == '#') {\n\t\t\t\t\tbackgroundcolor = ParseColor(c);\n\t\t\t\t} else if (c.StartsWith(\"SystemColors.\")) {\n\t\t\t\t\tsystemBgColor     = true;\n\t\t\t\t\tsystemBgColorName = c.Substring(\"SystemColors.\".Length);\n\t\t\t\t} else {\n\t\t\t\t\tbackgroundcolor = (Color)(Color.GetType()).InvokeMember(c, BindingFlags.GetProperty, null, Color, new object[0]);\n\t\t\t\t}\n\t\t\t\thasBackground = true;\n\t\t\t} else {\n\t\t\t\tbackgroundcolor = defaultColor.BackgroundColor;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Creates a new instance of <see cref=\"HighlightColor\"/>\n\t\t/// </summary>\n\t\tpublic HighlightColor(Color color, bool bold, bool italic)\n\t\t{\n\t\t\thasForeground = true;\n\t\t\tthis.color  = color;\n\t\t\tthis.bold   = bold;\n\t\t\tthis.italic = italic;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Creates a new instance of <see cref=\"HighlightColor\"/>\n\t\t/// </summary>\n\t\tpublic HighlightColor(Color color, Color backgroundcolor, bool bold, bool italic)\n\t\t{\n\t\t\thasForeground = true;\n\t\t\thasBackground  = true;\n\t\t\tthis.color            = color;\n\t\t\tthis.backgroundcolor  = backgroundcolor;\n\t\t\tthis.bold             = bold;\n\t\t\tthis.italic           = italic;\n\t\t}\n\t\t\n\t\t\n\t\t/// <summary>\n\t\t/// Creates a new instance of <see cref=\"HighlightColor\"/>\n\t\t/// </summary>\n\t\tpublic HighlightColor(string systemColor, string systemBackgroundColor, bool bold, bool italic)\n\t\t{\n\t\t\thasForeground = true;\n\t\t\thasBackground  = true;\n\t\t\t\n\t\t\tthis.systemColor  = true;\n\t\t\tsystemColorName   = systemColor;\n\t\t\t\n\t\t\tsystemBgColor     = true;\n\t\t\tsystemBgColorName = systemBackgroundColor;\n\t\t\t\n\t\t\tthis.bold         = bold;\n\t\t\tthis.italic       = italic;\n\t\t}\n\t\t\n\t\tstatic Color ParseColor(string c)\n\t\t{\n\t\t\tint a = 255;\n\t\t\tint offset = 0;\n\t\t\tif (c.Length > 7) {\n\t\t\t\toffset = 2;\n\t\t\t\ta = Int32.Parse(c.Substring(1,2), NumberStyles.HexNumber);\n\t\t\t}\n\t\t\t\n\t\t\tint r = Int32.Parse(c.Substring(1 + offset,2), NumberStyles.HexNumber);\n\t\t\tint g = Int32.Parse(c.Substring(3 + offset,2), NumberStyles.HexNumber);\n\t\t\tint b = Int32.Parse(c.Substring(5 + offset,2), NumberStyles.HexNumber);\n\t\t\treturn Color.FromArgb(a, r, g, b);\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Converts a <see cref=\"HighlightColor\"/> instance to string (for debug purposes)\n\t\t/// </summary>\n\t\tpublic override string ToString()\n\t\t{\n\t\t\treturn \"[HighlightColor: Bold = \" + Bold +\n\t\t\t\t\", Italic = \" + Italic +\n\t\t\t\t\", Color = \" + Color +\n\t\t\t\t\", BackgroundColor = \" + BackgroundColor + \"]\";\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/HighlightInfo.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 1965 $</version>\n// </file>\n\nusing System;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\tpublic class HighlightInfo\n\t{\n\t\tpublic bool BlockSpanOn = false;\n\t\tpublic bool Span        = false;\n\t\tpublic Span CurSpan     = null;\n\t\t\n\t\tpublic HighlightInfo(Span curSpan, bool span, bool blockSpanOn)\n\t\t{\n\t\t\tthis.CurSpan     = curSpan;\n\t\t\tthis.Span        = span;\n\t\t\tthis.BlockSpanOn = blockSpanOn;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/HighlightRuleSet.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 3036 $</version>\n// </file>\n\nusing System;\nusing System.Collections;\nusing System.Xml;\n\nusing ICSharpCode.TextEditor.Util;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\tpublic class HighlightRuleSet\n\t{\n\t\tLookupTable keyWords;\n\t\tArrayList   spans = new ArrayList();\n\t\tLookupTable prevMarkers;\n\t\tLookupTable nextMarkers;\n\t\tchar escapeCharacter;\n\t\t\n\t\tbool ignoreCase = false;\n\t\tstring name     = null;\n\t\t\n\t\tbool[] delimiters = new bool[256];\n\t\t\n\t\tstring      reference  = null;\n\t\t\n\t\tpublic ArrayList Spans {\n\t\t\tget {\n\t\t\t\treturn spans;\n\t\t\t}\n\t\t}\n\t\t\n\t\tinternal IHighlightingStrategyUsingRuleSets Highlighter;\n\t\t\n\t\tpublic LookupTable KeyWords {\n\t\t\tget {\n\t\t\t\treturn keyWords;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic LookupTable PrevMarkers {\n\t\t\tget {\n\t\t\t\treturn prevMarkers;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic LookupTable NextMarkers {\n\t\t\tget {\n\t\t\t\treturn nextMarkers;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic bool[] Delimiters {\n\t\t\tget {\n\t\t\t\treturn delimiters;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic char EscapeCharacter {\n\t\t\tget {\n\t\t\t\treturn escapeCharacter;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic bool IgnoreCase {\n\t\t\tget {\n\t\t\t\treturn ignoreCase;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic string Name {\n\t\t\tget {\n\t\t\t\treturn name;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tname = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic string Reference {\n\t\t\tget {\n\t\t\t\treturn reference;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic HighlightRuleSet()\n\t\t{\n\t\t\tkeyWords    = new LookupTable(false);\n\t\t\tprevMarkers = new LookupTable(false);\n\t\t\tnextMarkers = new LookupTable(false);\n\t\t}\n\t\t\n\t\tpublic HighlightRuleSet(XmlElement el)\n\t\t{\n\t\t\tXmlNodeList nodes;\n\t\t\t\n\t\t\tif (el.Attributes[\"name\"] != null) {\n\t\t\t\tName = el.Attributes[\"name\"].InnerText;\n\t\t\t}\n\t\t\t\n\t\t\tif (el.HasAttribute(\"escapecharacter\")) {\n\t\t\t\tescapeCharacter = el.GetAttribute(\"escapecharacter\")[0];\n\t\t\t}\n\t\t\t\n\t\t\tif (el.Attributes[\"reference\"] != null) {\n\t\t\t\treference = el.Attributes[\"reference\"].InnerText;\n\t\t\t}\n\t\t\t\n\t\t\tif (el.Attributes[\"ignorecase\"] != null) {\n\t\t\t\tignoreCase  = Boolean.Parse(el.Attributes[\"ignorecase\"].InnerText);\n\t\t\t}\n\t\t\t\n\t\t\tfor (int i  = 0; i < Delimiters.Length; ++i) {\n\t\t\t\tdelimiters[i] = false;\n\t\t\t}\n\t\t\t\n\t\t\tif (el[\"Delimiters\"] != null) {\n\t\t\t\tstring delimiterString = el[\"Delimiters\"].InnerText;\n\t\t\t\tforeach (char ch in delimiterString) {\n\t\t\t\t\tdelimiters[(int)ch] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n//\t\t\tSpans       = new LookupTable(!IgnoreCase);\n\n\t\t\tkeyWords    = new LookupTable(!IgnoreCase);\n\t\t\tprevMarkers = new LookupTable(!IgnoreCase);\n\t\t\tnextMarkers = new LookupTable(!IgnoreCase);\n\t\t\t\n\t\t\tnodes = el.GetElementsByTagName(\"KeyWords\");\n\t\t\tforeach (XmlElement el2 in nodes) {\n\t\t\t\tHighlightColor color = new HighlightColor(el2);\n\t\t\t\t\n\t\t\t\tXmlNodeList keys = el2.GetElementsByTagName(\"Key\");\n\t\t\t\tforeach (XmlElement node in keys) {\n\t\t\t\t\tkeyWords[node.Attributes[\"word\"].InnerText] = color;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tnodes = el.GetElementsByTagName(\"Span\");\n\t\t\tforeach (XmlElement el2 in nodes) {\n\t\t\t\tSpans.Add(new Span(el2));\n\t\t\t\t/*\n\t\t\t\tSpan span = new Span(el2);\n\t\t\t\tSpans[span.Begin] = span;*/\n\t\t\t}\n\t\t\t\n\t\t\tnodes = el.GetElementsByTagName(\"MarkPrevious\");\n\t\t\tforeach (XmlElement el2 in nodes) {\n\t\t\t\tPrevMarker prev = new PrevMarker(el2);\n\t\t\t\tprevMarkers[prev.What] = prev;\n\t\t\t}\n\t\t\t\n\t\t\tnodes = el.GetElementsByTagName(\"MarkFollowing\");\n\t\t\tforeach (XmlElement el2 in nodes) {\n\t\t\t\tNextMarker next = new NextMarker(el2);\n\t\t\t\tnextMarkers[next.What] = next;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Merges spans etc. from the other rule set into this rule set.\n\t\t/// </summary>\n\t\tpublic void MergeFrom(HighlightRuleSet ruleSet)\n\t\t{\n\t\t\tfor (int i = 0; i < delimiters.Length; i++) {\n\t\t\t\tdelimiters[i] |= ruleSet.delimiters[i];\n\t\t\t}\n\t\t\t// insert merged spans in front of old spans\n\t\t\tArrayList oldSpans = spans;\n\t\t\tspans = (ArrayList)ruleSet.spans.Clone();\n\t\t\tspans.AddRange(oldSpans);\n\t\t\t//keyWords.MergeFrom(ruleSet.keyWords);\n\t\t\t//prevMarkers.MergeFrom(ruleSet.prevMarkers);\n\t\t\t//nextMarkers.MergeFrom(ruleSet.nextMarkers);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/HighlightingColorNotFoundException.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 1624 $</version>\n// </file>\n\nusing System;\nusing System.Runtime.Serialization;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\t[Serializable()]\n\tpublic class HighlightingColorNotFoundException : Exception\n\t{\n\t\tpublic HighlightingColorNotFoundException() : base()\n\t\t{\n\t\t}\n\t\t\n\t\tpublic HighlightingColorNotFoundException(string message) : base(message)\n\t\t{\n\t\t}\n\t\t\n\t\tpublic HighlightingColorNotFoundException(string message, Exception innerException) : base(message, innerException)\n\t\t{\n\t\t}\n\t\t\n\t\tprotected HighlightingColorNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context)\n\t\t{\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/HighlightingDefinitionInvalidException.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 2533 $</version>\n// </file>\n\nusing System;\nusing System.Runtime.Serialization;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\t/// <summary>\n\t/// Indicates that the highlighting definition that was tried to load was invalid.\n\t/// You get this exception only once per highlighting definition, after that the definition\n\t/// is replaced with the default highlighter.\n\t/// </summary>\n\t[Serializable()]\n\tpublic class HighlightingDefinitionInvalidException : Exception\n\t{\n\t\tpublic HighlightingDefinitionInvalidException() : base()\n\t\t{\n\t\t}\n\t\t\n\t\tpublic HighlightingDefinitionInvalidException(string message) : base(message)\n\t\t{\n\t\t}\n\t\t\n\t\tpublic HighlightingDefinitionInvalidException(string message, Exception innerException) : base(message, innerException)\n\t\t{\n\t\t}\n\t\t\n\t\tprotected HighlightingDefinitionInvalidException(SerializationInfo info, StreamingContext context) : base(info, context)\n\t\t{\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/HighlightingDefinitionParser.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 2533 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Text;\nusing System.Windows.Forms;\nusing System.Xml;\nusing System.Xml.Schema;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\tpublic static class HighlightingDefinitionParser\n\t{\n\t\tpublic static DefaultHighlightingStrategy Parse(SyntaxMode syntaxMode, XmlReader xmlReader)\n\t\t{\n\t\t\treturn Parse(null, syntaxMode, xmlReader);\n\t\t}\n\n\t\tpublic static DefaultHighlightingStrategy Parse(DefaultHighlightingStrategy highlighter, SyntaxMode syntaxMode, XmlReader xmlReader)\n\t\t{\n\t\t\tif (syntaxMode == null)\n\t\t\t\tthrow new ArgumentNullException(\"syntaxMode\");\n\t\t\tif (xmlReader == null)\n\t\t\t\tthrow new ArgumentNullException(\"xmlTextReader\");\n\t\t\ttry {\n\t\t\t\tList<ValidationEventArgs> errors = null;\n\t\t\t\tXmlReaderSettings settings = new XmlReaderSettings();\n\t\t\t\tStream shemaStream = typeof(HighlightingDefinitionParser).Assembly.GetManifestResourceStream(\"ICSharpCode.TextEditor.Resources.Mode.xsd\");\n\t\t\t\tsettings.Schemas.Add(\"\", new XmlTextReader(shemaStream));\n\t\t\t\tsettings.Schemas.ValidationEventHandler += delegate(object sender, ValidationEventArgs args) {\n\t\t\t\t\tif (errors == null) {\n\t\t\t\t\t\terrors = new List<ValidationEventArgs>();\n\t\t\t\t\t}\n\t\t\t\t\terrors.Add(args);\n\t\t\t\t};\n\t\t\t\tsettings.ValidationType = ValidationType.Schema;\n\t\t\t\tXmlReader validatingReader = XmlReader.Create(xmlReader, settings);\n\n\t\t\t\tXmlDocument doc = new XmlDocument();\n\t\t\t\tdoc.Load(validatingReader);\n\t\t\t\t\n\t\t\t\tif (highlighter == null)\n\t\t\t\t\thighlighter = new DefaultHighlightingStrategy(doc.DocumentElement.Attributes[\"name\"].InnerText);\n\t\t\t\t\n\t\t\t\tif (doc.DocumentElement.HasAttribute(\"extends\")) {\n\t\t\t\t\tKeyValuePair<SyntaxMode, ISyntaxModeFileProvider> entry = HighlightingManager.Manager.FindHighlighterEntry(doc.DocumentElement.GetAttribute(\"extends\"));\n\t\t\t\t\tif (entry.Key == null) {\n\t\t\t\t\t\tthrow new HighlightingDefinitionInvalidException(\"Cannot find referenced highlighting source \" + doc.DocumentElement.GetAttribute(\"extends\"));\n\t\t\t\t\t} else {\n\t\t\t\t\t\thighlighter = Parse(highlighter, entry.Key, entry.Value.GetSyntaxModeFile(entry.Key));\n\t\t\t\t\t\tif (highlighter == null) return null;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (doc.DocumentElement.HasAttribute(\"extensions\")) {\n\t\t\t\t\thighlighter.Extensions = doc.DocumentElement.GetAttribute(\"extensions\").Split(new char[] { ';', '|' });\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tXmlElement environment = doc.DocumentElement[\"Environment\"];\n\t\t\t\tif (environment != null) {\n\t\t\t\t\tforeach (XmlNode node in environment.ChildNodes) {\n\t\t\t\t\t\tif (node is XmlElement) {\n\t\t\t\t\t\t\tXmlElement el = (XmlElement)node;\n\t\t\t\t\t\t\tif (el.Name == \"Custom\") {\n\t\t\t\t\t\t\t\thighlighter.SetColorFor(el.GetAttribute(\"name\"), el.HasAttribute(\"bgcolor\") ? new HighlightBackground(el) : new HighlightColor(el));\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\thighlighter.SetColorFor(el.Name, el.HasAttribute(\"bgcolor\") ? new HighlightBackground(el) : new HighlightColor(el));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// parse properties\n\t\t\t\tif (doc.DocumentElement[\"Properties\"]!= null) {\n\t\t\t\t\tforeach (XmlElement propertyElement in doc.DocumentElement[\"Properties\"].ChildNodes) {\n\t\t\t\t\t\thighlighter.Properties[propertyElement.Attributes[\"name\"].InnerText] =  propertyElement.Attributes[\"value\"].InnerText;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (doc.DocumentElement[\"Digits\"]!= null) {\n\t\t\t\t\thighlighter.DigitColor = new HighlightColor(doc.DocumentElement[\"Digits\"]);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tXmlNodeList nodes = doc.DocumentElement.GetElementsByTagName(\"RuleSet\");\n\t\t\t\tforeach (XmlElement element in nodes) {\n\t\t\t\t\thighlighter.AddRuleSet(new HighlightRuleSet(element));\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\txmlReader.Close();\n\t\t\t\t\n\t\t\t\tif (errors != null) {\n\t\t\t\t\tStringBuilder msg = new StringBuilder();\n\t\t\t\t\tforeach (ValidationEventArgs args in errors) {\n\t\t\t\t\t\tmsg.AppendLine(args.Message);\n\t\t\t\t\t}\n\t\t\t\t\tthrow new HighlightingDefinitionInvalidException(msg.ToString());\n\t\t\t\t} else {\n\t\t\t\t\treturn highlighter;\n\t\t\t\t}\n\t\t\t} catch (Exception e) {\n\t\t\t\tthrow new HighlightingDefinitionInvalidException(\"Could not load mode definition file '\" + syntaxMode.FileName + \"'.\\n\", e);\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/HighlightingManager.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 3209 $</version>\n// </file>\n\nusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Diagnostics;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\tpublic class HighlightingManager\n\t{\n\t\tArrayList syntaxModeFileProviders = new ArrayList();\n\t\tstatic HighlightingManager highlightingManager;\n\t\t\n\t\t// hash table from extension name to highlighting definition,\n\t\t// OR from extension name to Pair SyntaxMode,ISyntaxModeFileProvider\n\t\tHashtable highlightingDefs = new Hashtable();\n\t\t\n\t\tHashtable extensionsToName = new Hashtable();\n\t\t\n\t\tpublic Hashtable HighlightingDefinitions {\n\t\t\tget {\n\t\t\t\treturn highlightingDefs;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic static HighlightingManager Manager {\n\t\t\tget {\n\t\t\t\treturn highlightingManager;\n\t\t\t}\n\t\t}\n\t\t\n\t\tstatic HighlightingManager()\n\t\t{\n\t\t\thighlightingManager = new HighlightingManager();\n\t\t\thighlightingManager.AddSyntaxModeFileProvider(new ResourceSyntaxModeProvider());\n\t\t}\n\t\t\n\t\tpublic HighlightingManager()\n\t\t{\n\t\t\tCreateDefaultHighlightingStrategy();\n\t\t}\n\t\t\n\t\tpublic void AddSyntaxModeFileProvider(ISyntaxModeFileProvider syntaxModeFileProvider)\n\t\t{\n\t\t\tforeach (SyntaxMode syntaxMode in syntaxModeFileProvider.SyntaxModes) {\n\t\t\t\thighlightingDefs[syntaxMode.Name] = new DictionaryEntry(syntaxMode, syntaxModeFileProvider);\n\t\t\t\tforeach (string extension in syntaxMode.Extensions) {\n\t\t\t\t\textensionsToName[extension.ToUpperInvariant()] = syntaxMode.Name;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!syntaxModeFileProviders.Contains(syntaxModeFileProvider)) {\n\t\t\t\tsyntaxModeFileProviders.Add(syntaxModeFileProvider);\n\t\t\t}\n\t\t}\n\n\t\tpublic void AddHighlightingStrategy(IHighlightingStrategy highlightingStrategy)\n\t\t{\n\t\t\thighlightingDefs[highlightingStrategy.Name] = highlightingStrategy;\n\t\t\tforeach (string extension in highlightingStrategy.Extensions)\n\t\t\t{\n\t\t\t\textensionsToName[extension.ToUpperInvariant()] = highlightingStrategy.Name;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic void ReloadSyntaxModes()\n\t\t{\n\t\t\thighlightingDefs.Clear();\n\t\t\textensionsToName.Clear();\n\t\t\tCreateDefaultHighlightingStrategy();\n\t\t\tforeach (ISyntaxModeFileProvider provider in syntaxModeFileProviders) {\n\t\t\t\tprovider.UpdateSyntaxModeList();\n\t\t\t\tAddSyntaxModeFileProvider(provider);\n\t\t\t}\n\t\t\tOnReloadSyntaxHighlighting(EventArgs.Empty);\n\t\t}\n\t\t\n\t\tvoid CreateDefaultHighlightingStrategy()\n\t\t{\n\t\t\tDefaultHighlightingStrategy defaultHighlightingStrategy = new DefaultHighlightingStrategy();\n\t\t\tdefaultHighlightingStrategy.Extensions = new string[] {};\n\t\t\tdefaultHighlightingStrategy.Rules.Add(new HighlightRuleSet());\n\t\t\thighlightingDefs[\"Default\"] = defaultHighlightingStrategy;\n\t\t}\n\t\t\n\t\tIHighlightingStrategy LoadDefinition(DictionaryEntry entry)\n\t\t{\n\t\t\tSyntaxMode              syntaxMode             = (SyntaxMode)entry.Key;\n\t\t\tISyntaxModeFileProvider syntaxModeFileProvider = (ISyntaxModeFileProvider)entry.Value;\n\n\t\t\tDefaultHighlightingStrategy highlightingStrategy = null;\n\t\t\ttry {\n\t\t\t\tvar reader = syntaxModeFileProvider.GetSyntaxModeFile(syntaxMode);\n\t\t\t\tif (reader == null)\n\t\t\t\t\tthrow new HighlightingDefinitionInvalidException(\"Could not get syntax mode file for \" + syntaxMode.Name);\n\t\t\t\thighlightingStrategy = HighlightingDefinitionParser.Parse(syntaxMode, reader);\n\t\t\t\tif (highlightingStrategy.Name != syntaxMode.Name) {\n\t\t\t\t\tthrow new HighlightingDefinitionInvalidException(\"The name specified in the .xshd '\" + highlightingStrategy.Name + \"' must be equal the syntax mode name '\" + syntaxMode.Name + \"'\");\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tif (highlightingStrategy == null) {\n\t\t\t\t\thighlightingStrategy = DefaultHighlighting;\n\t\t\t\t}\n\t\t\t\thighlightingDefs[syntaxMode.Name] = highlightingStrategy;\n\t\t\t\thighlightingStrategy.ResolveReferences();\n\t\t\t}\n\t\t\treturn highlightingStrategy;\n\t\t}\n\t\t\n\t\tpublic DefaultHighlightingStrategy DefaultHighlighting {\n\t\t\tget {\n\t\t\t\treturn (DefaultHighlightingStrategy)highlightingDefs[\"Default\"];\n\t\t\t}\n\t\t}\n\t\t\n\t\tinternal KeyValuePair<SyntaxMode, ISyntaxModeFileProvider> FindHighlighterEntry(string name)\n\t\t{\n\t\t\tforeach (ISyntaxModeFileProvider provider in syntaxModeFileProviders) {\n\t\t\t\tforeach (SyntaxMode mode in provider.SyntaxModes) {\n\t\t\t\t\tif (mode.Name == name) {\n\t\t\t\t\t\treturn new KeyValuePair<SyntaxMode, ISyntaxModeFileProvider>(mode, provider);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn new KeyValuePair<SyntaxMode, ISyntaxModeFileProvider>(null, null);\n\t\t}\n\t\t\n\t\tpublic IHighlightingStrategy FindHighlighter(string name)\n\t\t{\n\t\t\tobject def = highlightingDefs[name];\n\t\t\tif (def is DictionaryEntry) {\n\t\t\t\treturn LoadDefinition((DictionaryEntry)def);\n\t\t\t}\n\t\t\treturn def == null ? DefaultHighlighting : (IHighlightingStrategy)def;\n\t\t}\n\t\t\n\t\tpublic IHighlightingStrategy FindHighlighterForFile(string fileName)\n\t\t{\n\t\t\tstring highlighterName = (string)extensionsToName[Path.GetExtension(fileName).ToUpperInvariant()];\n\t\t\tif (highlighterName != null) {\n\t\t\t\tobject def = highlightingDefs[highlighterName];\n\t\t\t\tif (def is DictionaryEntry) {\n\t\t\t\t\treturn LoadDefinition((DictionaryEntry)def);\n\t\t\t\t}\n\t\t\t\treturn def == null ? DefaultHighlighting : (IHighlightingStrategy)def;\n\t\t\t} else {\n\t\t\t\treturn DefaultHighlighting;\n\t\t\t}\n\t\t}\n\t\t\n\t\tprotected virtual void OnReloadSyntaxHighlighting(EventArgs e)\n\t\t{\n\t\t\tif (ReloadSyntaxHighlighting != null) {\n\t\t\t\tReloadSyntaxHighlighting(this, e);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic event EventHandler ReloadSyntaxHighlighting;\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/HighlightingStrategyFactory.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 1965 $</version>\n// </file>\n\nusing System;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\tpublic class HighlightingStrategyFactory\n\t{\n\t\tpublic static IHighlightingStrategy CreateHighlightingStrategy()\n\t\t{\n\t\t\treturn (IHighlightingStrategy)HighlightingManager.Manager.HighlightingDefinitions[\"Default\"];\n\t\t}\n\t\t\n\t\tpublic static IHighlightingStrategy CreateHighlightingStrategy(string name)\n\t\t{\n\t\t\tIHighlightingStrategy highlightingStrategy  = HighlightingManager.Manager.FindHighlighter(name);\n\t\t\t\n\t\t\tif (highlightingStrategy == null) {\n\t\t\t\treturn CreateHighlightingStrategy();\n\t\t\t}\n\t\t\treturn highlightingStrategy;\n\t\t}\n\t\t\n\t\tpublic static IHighlightingStrategy CreateHighlightingStrategyForFile(string fileName)\n\t\t{\n\t\t\tIHighlightingStrategy highlightingStrategy  = HighlightingManager.Manager.FindHighlighterForFile(fileName);\n\t\t\tif (highlightingStrategy == null) {\n\t\t\t\treturn CreateHighlightingStrategy();\n\t\t\t}\n\t\t\treturn highlightingStrategy;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/IHighlightingStrategy.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 3037 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\t/// <summary>\n\t/// A highlighting strategy for a buffer.\n\t/// </summary>\n\tpublic interface IHighlightingStrategy\n\t{\n\t\t/// <value>\n\t\t/// The name of the highlighting strategy, must be unique\n\t\t/// </value>\n\t\tstring Name {\n\t\t\tget;\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// The file extenstions on which this highlighting strategy gets\n\t\t/// used\n\t\t/// </value>\n\t\tstring[] Extensions {\n\t\t\tget;\n\t\t}\n\t\t\n\t\tDictionary<string, string> Properties {\n\t\t\tget;\n\t\t}\n\t\t\n\t\t// returns special color. (BackGround Color, Cursor Color and so on)\n\t\t\n\t\t/// <remarks>\n\t\t/// Gets the color of an Environment element.\n\t\t/// </remarks>\n\t\tHighlightColor GetColorFor(string name);\n\t\t\n\t\t/// <remarks>\n\t\t/// Used internally, do not call\n\t\t/// </remarks>\n\t\tvoid MarkTokens(IDocument document, List<LineSegment> lines);\n\t\t\n\t\t/// <remarks>\n\t\t/// Used internally, do not call\n\t\t/// </remarks>\n\t\tvoid MarkTokens(IDocument document);\n\t}\n\t\n\tpublic interface IHighlightingStrategyUsingRuleSets : IHighlightingStrategy\n\t{\n\t\t/// <remarks>\n\t\t/// Used internally, do not call\n\t\t/// </remarks>\n\t\tHighlightRuleSet GetRuleSet(Span span);\n\t\t\n\t\t/// <remarks>\n\t\t/// Used internally, do not call\n\t\t/// </remarks>\n\t\tHighlightColor GetColor(IDocument document, LineSegment keyWord, int index, int length);\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/NextMarker.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 1965 $</version>\n// </file>\n\nusing System;\nusing System.Xml;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\t/// <summary>\n\t/// Used for mark next token\n\t/// </summary>\n\tpublic class NextMarker\n\t{\n\t\tstring      what;\n\t\tHighlightColor color;\n\t\tbool        markMarker = false;\n\t\t\n\t\t/// <value>\n\t\t/// String value to indicate to mark next token\n\t\t/// </value>\n\t\tpublic string What {\n\t\t\tget {\n\t\t\t\treturn what;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// Color for marking next token\n\t\t/// </value>\n\t\tpublic HighlightColor Color {\n\t\t\tget {\n\t\t\t\treturn color;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// If true the indication text will be marked with the same color\n\t\t/// too\n\t\t/// </value>\n\t\tpublic bool MarkMarker {\n\t\t\tget {\n\t\t\t\treturn markMarker;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Creates a new instance of <see cref=\"NextMarker\"/>\n\t\t/// </summary>\n\t\tpublic NextMarker(XmlElement mark)\n\t\t{\n\t\t\tcolor = new HighlightColor(mark);\n\t\t\twhat  = mark.InnerText;\n\t\t\tif (mark.Attributes[\"markmarker\"] != null) {\n\t\t\t\tmarkMarker = Boolean.Parse(mark.Attributes[\"markmarker\"].InnerText);\n\t\t\t}\n\t\t}\n\t}\n\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/PrevMarker.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 1965 $</version>\n// </file>\n\nusing System;\nusing System.Xml;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\t/// <summary>\n\t/// Used for mark previous token\n\t/// </summary>\n\tpublic class PrevMarker\n\t{\n\t\tstring      what;\n\t\tHighlightColor color;\n\t\tbool        markMarker = false;\n\t\t\n\t\t/// <value>\n\t\t/// String value to indicate to mark previous token\n\t\t/// </value>\n\t\tpublic string What {\n\t\t\tget {\n\t\t\t\treturn what;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// Color for marking previous token\n\t\t/// </value>\n\t\tpublic HighlightColor Color {\n\t\t\tget {\n\t\t\t\treturn color;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// If true the indication text will be marked with the same color\n\t\t/// too\n\t\t/// </value>\n\t\tpublic bool MarkMarker {\n\t\t\tget {\n\t\t\t\treturn markMarker;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Creates a new instance of <see cref=\"PrevMarker\"/>\n\t\t/// </summary>\n\t\tpublic PrevMarker(XmlElement mark)\n\t\t{\n\t\t\tcolor = new HighlightColor(mark);\n\t\t\twhat  = mark.InnerText;\n\t\t\tif (mark.Attributes[\"markmarker\"] != null) {\n\t\t\t\tmarkMarker = Boolean.Parse(mark.Attributes[\"markmarker\"].InnerText);\n\t\t\t}\n\t\t}\n\t}\n\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/Span.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 2115 $</version>\n// </file>\n\nusing System;\nusing System.Xml;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\tpublic sealed class Span\n\t{\n\t\tbool        stopEOL;\n\t\tHighlightColor color;\n\t\tHighlightColor beginColor;\n\t\tHighlightColor endColor;\n\t\tchar[]      begin;\n\t\tchar[]      end;\n\t\tstring      name;\n\t\tstring      rule;\n\t\tHighlightRuleSet ruleSet;\n\t\tchar escapeCharacter;\n\t\tbool ignoreCase;\n\t\tbool isBeginSingleWord;\n\t\tbool? isBeginStartOfLine;\n\t\tbool isEndSingleWord;\n\t\t\n\t\tinternal HighlightRuleSet RuleSet {\n\t\t\tget {\n\t\t\t\treturn ruleSet;\n\t\t\t}\n\t\t\tset {\n\t\t\t\truleSet = value;\n\t\t\t}\n\t\t}\n\n\t\tpublic bool IgnoreCase\t{\n\t\t\tget\t{\n\t\t\t\treturn ignoreCase;\n\t\t\t}\n\t\t\tset\t{\n\t\t\t\tignoreCase = value;\n\t\t\t}\n\t\t}\n\n\t\tpublic bool StopEOL {\n\t\t\tget {\n\t\t\t\treturn stopEOL;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic bool? IsBeginStartOfLine {\n\t\t\tget {\n\t\t\t\treturn isBeginStartOfLine;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic bool IsBeginSingleWord {\n\t\t\tget {\n\t\t\t\treturn isBeginSingleWord;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic bool IsEndSingleWord {\n\t\t\tget {\n\t\t\t\treturn isEndSingleWord;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic HighlightColor Color {\n\t\t\tget {\n\t\t\t\treturn color;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic HighlightColor BeginColor {\n\t\t\tget {\n\t\t\t\tif(beginColor != null) {\n\t\t\t\t\treturn beginColor;\n\t\t\t\t} else {\n\t\t\t\t\treturn color;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic HighlightColor EndColor {\n\t\t\tget {\n\t\t\t\treturn endColor!=null ? endColor : color;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic char[] Begin {\n\t\t\tget { return begin; }\n\t\t}\n\t\t\n\t\tpublic char[] End {\n\t\t\tget { return end; }\n\t\t}\n\t\t\n\t\tpublic string Name {\n\t\t\tget { return name; }\n\t\t}\n\t\t\n\t\tpublic string Rule {\n\t\t\tget { return rule; }\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Gets the escape character of the span. The escape character is a character that can be used in front\n\t\t/// of the span end to make it not end the span. The escape character followed by another escape character\n\t\t/// means the escape character was escaped like in @\"a \"\" b\" literals in C#.\n\t\t/// The default value '\\0' means no escape character is allowed.\n\t\t/// </summary>\n\t\tpublic char EscapeCharacter {\n\t\t\tget { return escapeCharacter; }\n\t\t}\n\t\t\n\t\tpublic Span(XmlElement span)\n\t\t{\n\t\t\tcolor   = new HighlightColor(span);\n\t\t\t\n\t\t\tif (span.HasAttribute(\"rule\")) {\n\t\t\t\trule = span.GetAttribute(\"rule\");\n\t\t\t}\n\t\t\t\n\t\t\tif (span.HasAttribute(\"escapecharacter\")) {\n\t\t\t\tescapeCharacter = span.GetAttribute(\"escapecharacter\")[0];\n\t\t\t}\n\t\t\t\n\t\t\tname = span.GetAttribute(\"name\");\n\t\t\tif (span.HasAttribute(\"stopateol\")) {\n\t\t\t\tstopEOL = Boolean.Parse(span.GetAttribute(\"stopateol\"));\n\t\t\t}\n\t\t\t\n\t\t\tbegin   = span[\"Begin\"].InnerText.ToCharArray();\n\t\t\tbeginColor = new HighlightColor(span[\"Begin\"], color);\n\t\t\t\n\t\t\tif (span[\"Begin\"].HasAttribute(\"singleword\")) {\n\t\t\t\tthis.isBeginSingleWord = Boolean.Parse(span[\"Begin\"].GetAttribute(\"singleword\"));\n\t\t\t}\n\t\t\tif (span[\"Begin\"].HasAttribute(\"startofline\")) {\n\t\t\t\tthis.isBeginStartOfLine = Boolean.Parse(span[\"Begin\"].GetAttribute(\"startofline\"));\n\t\t\t}\n\t\t\t\n\t\t\tif (span[\"End\"] != null) {\n\t\t\t\tend  = span[\"End\"].InnerText.ToCharArray();\n\t\t\t\tendColor = new HighlightColor(span[\"End\"], color);\n\t\t\t\tif (span[\"End\"].HasAttribute(\"singleword\")) {\n\t\t\t\t\tthis.isEndSingleWord = Boolean.Parse(span[\"End\"].GetAttribute(\"singleword\"));\n\t\t\t\t}\n\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/SpanStack.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Daniel Grunwald\" email=\"daniel@danielgrunwald.de\"/>\n//     <version>$Revision: 1471 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\t/// <summary>\n\t/// A stack of Span instances. Works like Stack&lt;Span&gt;, but can be cloned quickly\n\t/// because it is implemented as linked list.\n\t/// </summary>\n\tpublic sealed class SpanStack : ICloneable, IEnumerable<Span>\n\t{\n\t\tinternal sealed class StackNode\n\t\t{\n\t\t\tpublic readonly StackNode Previous;\n\t\t\tpublic readonly Span Data;\n\t\t\t\n\t\t\tpublic StackNode(StackNode previous, Span data)\n\t\t\t{\n\t\t\t\tthis.Previous = previous;\n\t\t\t\tthis.Data = data;\n\t\t\t}\n\t\t}\n\t\t\n\t\tStackNode top = null;\n\t\t\n\t\tpublic Span Pop()\n\t\t{\n\t\t\tSpan s = top.Data;\n\t\t\ttop = top.Previous;\n\t\t\treturn s;\n\t\t}\n\t\t\n\t\tpublic Span Peek()\n\t\t{\n\t\t\treturn top.Data;\n\t\t}\n\t\t\n\t\tpublic void Push(Span s)\n\t\t{\n\t\t\ttop = new StackNode(top, s);\n\t\t}\n\t\t\n\t\tpublic bool IsEmpty {\n\t\t\tget {\n\t\t\t\treturn top == null;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic SpanStack Clone()\n\t\t{\n\t\t\tSpanStack n = new SpanStack();\n\t\t\tn.top = this.top;\n\t\t\treturn n;\n\t\t}\n\t\tobject ICloneable.Clone()\n\t\t{\n\t\t\treturn this.Clone();\n\t\t}\n\t\t\n\t\tpublic Enumerator GetEnumerator()\n\t\t{\n\t\t\treturn new Enumerator(new StackNode(top, null));\n\t\t}\n\t\tIEnumerator<Span> IEnumerable<Span>.GetEnumerator()\n\t\t{\n\t\t\treturn this.GetEnumerator();\n\t\t}\n\t\tSystem.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()\n\t\t{\n\t\t\treturn this.GetEnumerator();\n\t\t}\n\t\t\n\t\tpublic struct Enumerator : IEnumerator<Span>\n\t\t{\n\t\t\tStackNode c;\n\t\t\t\n\t\t\tinternal Enumerator(StackNode node)\n\t\t\t{\n\t\t\t\tc = node;\n\t\t\t}\n\t\t\t\n\t\t\tpublic Span Current {\n\t\t\t\tget {\n\t\t\t\t\treturn c.Data;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tobject System.Collections.IEnumerator.Current {\n\t\t\t\tget {\n\t\t\t\t\treturn c.Data;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tpublic void Dispose()\n\t\t\t{\n\t\t\t\tc = null;\n\t\t\t}\n\t\t\t\n\t\t\tpublic bool MoveNext()\n\t\t\t{\n\t\t\t\tc = c.Previous;\n\t\t\t\treturn c != null;\n\t\t\t}\n\t\t\t\n\t\t\tpublic void Reset()\n\t\t\t{\n\t\t\t\tthrow new NotSupportedException();\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/SyntaxModes/FileSyntaxModeProvider.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 2533 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Windows.Forms;\nusing System.Xml;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\tpublic class FileSyntaxModeProvider : ISyntaxModeFileProvider\n\t{\n\t\tstring    directory;\n\t\tList<SyntaxMode> syntaxModes = null;\n\t\t\n\t\tpublic ICollection<SyntaxMode> SyntaxModes {\n\t\t\tget {\n\t\t\t\treturn syntaxModes;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic FileSyntaxModeProvider(string directory)\n\t\t{\n\t\t\tthis.directory = directory;\n\t\t\tUpdateSyntaxModeList();\n\t\t}\n\t\t\n\t\tpublic void UpdateSyntaxModeList()\n\t\t{\n\t\t\tstring syntaxModeFile = Path.Combine(directory, \"SyntaxModes.xml\");\n\t\t\tif (File.Exists(syntaxModeFile)) {\n\t\t\t\tStream s = File.OpenRead(syntaxModeFile);\n\t\t\t\tsyntaxModes = SyntaxMode.GetSyntaxModes(s);\n\t\t\t\ts.Close();\n\t\t\t} else {\n\t\t\t\tsyntaxModes = ScanDirectory(directory);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic XmlTextReader GetSyntaxModeFile(SyntaxMode syntaxMode)\n\t\t{\n\t\t\tstring syntaxModeFile = Path.Combine(directory, syntaxMode.FileName);\n\t\t\tif (!File.Exists(syntaxModeFile)) {\n\t\t\t\tthrow new HighlightingDefinitionInvalidException(\"Can't load highlighting definition \" + syntaxModeFile + \" (file not found)!\");\n\t\t\t}\n\t\t\treturn new XmlTextReader(File.OpenRead(syntaxModeFile));\n\t\t}\n\t\t\n\t\tList<SyntaxMode> ScanDirectory(string directory)\n\t\t{\n\t\t\tstring[] files = Directory.GetFiles(directory);\n\t\t\tList<SyntaxMode> modes = new List<SyntaxMode>();\n\t\t\tforeach (string file in files) {\n\t\t\t\tif (Path.GetExtension(file).Equals(\".XSHD\", StringComparison.OrdinalIgnoreCase)) {\n\t\t\t\t\tXmlTextReader reader = new XmlTextReader(file);\n\t\t\t\t\twhile (reader.Read()) {\n\t\t\t\t\t\tif (reader.NodeType == XmlNodeType.Element) {\n\t\t\t\t\t\t\tswitch (reader.Name) {\n\t\t\t\t\t\t\t\tcase \"SyntaxDefinition\":\n\t\t\t\t\t\t\t\t\tstring name       = reader.GetAttribute(\"name\");\n\t\t\t\t\t\t\t\t\tstring extensions = reader.GetAttribute(\"extensions\");\n\t\t\t\t\t\t\t\t\tmodes.Add(new SyntaxMode(Path.GetFileName(file),\n\t\t\t\t\t\t\t\t\t                         name,\n\t\t\t\t\t\t\t\t\t                         extensions));\n\t\t\t\t\t\t\t\t\tgoto bailout;\n\t\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\t\tthrow new HighlightingDefinitionInvalidException(\"Unknown root node in syntax highlighting file :\" + reader.Name);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\tbailout:\n\t\t\t\t\treader.Close();\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn modes;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/SyntaxModes/ISyntaxModeFileProvider.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 1301 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\nusing System.Xml;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\tpublic interface ISyntaxModeFileProvider\n\t{\n\t\tICollection<SyntaxMode> SyntaxModes {\n\t\t\tget;\n\t\t}\n\t\t\n\t\tXmlTextReader GetSyntaxModeFile(SyntaxMode syntaxMode);\n\t\tvoid UpdateSyntaxModeList();\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/SyntaxModes/ResourceSyntaxModeProvider.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 1965 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Reflection;\nusing System.Xml;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\tpublic class ResourceSyntaxModeProvider : ISyntaxModeFileProvider\n\t{\n\t\tList<SyntaxMode> syntaxModes = null;\n\t\t\n\t\tpublic ICollection<SyntaxMode> SyntaxModes {\n\t\t\tget {\n\t\t\t\treturn syntaxModes;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic ResourceSyntaxModeProvider()\n\t\t{\n\t\t\tAssembly assembly = typeof(SyntaxMode).Assembly;\n\t\t\tStream syntaxModeStream = assembly.GetManifestResourceStream(\"ICSharpCode.TextEditor.Resources.SyntaxModes.xml\");\n\t\t\tif (syntaxModeStream != null) {\n\t\t\t\tsyntaxModes = SyntaxMode.GetSyntaxModes(syntaxModeStream);\n\t\t\t} else {\n\t\t\t\tsyntaxModes = new List<SyntaxMode>();\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic XmlTextReader GetSyntaxModeFile(SyntaxMode syntaxMode)\n\t\t{\n\t\t\tAssembly assembly = typeof(SyntaxMode).Assembly;\n\t\t\treturn new XmlTextReader(assembly.GetManifestResourceStream(\"ICSharpCode.TextEditor.Resources.\" + syntaxMode.FileName));\n\t\t}\n\t\t\n\t\tpublic void UpdateSyntaxModeList()\n\t\t{\n\t\t\t// resources don't change during runtime\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/SyntaxModes/SyntaxMode.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 2533 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Windows.Forms;\nusing System.Xml;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\tpublic class SyntaxMode\n\t{\n\t\tstring   fileName;\n\t\tstring   name;\n\t\tstring[] extensions;\n\t\t\n\t\tpublic string FileName {\n\t\t\tget {\n\t\t\t\treturn fileName;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tfileName = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic string Name {\n\t\t\tget {\n\t\t\t\treturn name;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tname = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic string[] Extensions {\n\t\t\tget {\n\t\t\t\treturn extensions;\n\t\t\t}\n\t\t\tset {\n\t\t\t\textensions = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic SyntaxMode(string fileName, string name, string extensions)\n\t\t{\n\t\t\tthis.fileName   = fileName;\n\t\t\tthis.name       = name;\n\t\t\tthis.extensions = extensions.Split(';', '|', ',');\n\t\t}\n\t\t\n\t\tpublic SyntaxMode(string fileName, string name, string[] extensions)\n\t\t{\n\t\t\tthis.fileName = fileName;\n\t\t\tthis.name = name;\n\t\t\tthis.extensions = extensions;\n\t\t}\n\t\t\n\t\tpublic static List<SyntaxMode> GetSyntaxModes(Stream xmlSyntaxModeStream)\n\t\t{\n\t\t\tXmlTextReader reader = new XmlTextReader(xmlSyntaxModeStream);\n\t\t\tList<SyntaxMode> syntaxModes = new List<SyntaxMode>();\n\t\t\twhile (reader.Read()) {\n\t\t\t\tswitch (reader.NodeType) {\n\t\t\t\t\tcase XmlNodeType.Element:\n\t\t\t\t\t\tswitch (reader.Name) {\n\t\t\t\t\t\t\tcase \"SyntaxModes\":\n\t\t\t\t\t\t\t\tstring version = reader.GetAttribute(\"version\");\n\t\t\t\t\t\t\t\tif (version != \"1.0\") {\n\t\t\t\t\t\t\t\t\tthrow new HighlightingDefinitionInvalidException(\"Unknown syntax mode file defininition with version \" + version);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase \"Mode\":\n\t\t\t\t\t\t\t\tsyntaxModes.Add(new SyntaxMode(reader.GetAttribute(\"file\"), \n\t\t\t\t\t\t\t\t                               reader.GetAttribute(\"name\"),\n\t\t\t\t\t\t\t\t                               reader.GetAttribute(\"extensions\")));\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\tthrow new HighlightingDefinitionInvalidException(\"Unknown node in syntax mode file :\" + reader.Name);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\treader.Close();\n\t\t\treturn syntaxModes;\n\t\t}\n\t\tpublic override string ToString() \n\t\t{\n\t\t\treturn String.Format(\"[SyntaxMode: FileName={0}, Name={1}, Extensions=({2})]\", fileName, name, String.Join(\",\", extensions));\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/TextWord.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 1965 $</version>\n// </file>\n\nusing System;\nusing System.Diagnostics;\nusing System.Drawing;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\tpublic enum TextWordType {\n\t\tWord,\n\t\tSpace,\n\t\tTab\n\t}\n\t\n\t/// <summary>\n\t/// This class represents single words with color information, two special versions of a word are\n\t/// spaces and tabs.\n\t/// </summary>\n\tpublic class TextWord\n\t{\n\t\tHighlightColor  color;\n\t\tLineSegment     line;\n\t\tIDocument       document;\n\t\t\n\t\tint          offset;\n\t\tint          length;\n\t\t\n\t\tpublic sealed class SpaceTextWord : TextWord\n\t\t{\n\t\t\tpublic SpaceTextWord()\n\t\t\t{\n\t\t\t\tlength = 1;\n\t\t\t}\n\t\t\t\n\t\t\tpublic SpaceTextWord(HighlightColor color)\n\t\t\t{\n\t\t\t\tlength = 1;\n\t\t\t\tbase.SyntaxColor = color;\n\t\t\t}\n\t\t\t\n\t\t\tpublic override Font GetFont(FontContainer fontContainer)\n\t\t\t{\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\t\n\t\t\tpublic override TextWordType Type {\n\t\t\t\tget {\n\t\t\t\t\treturn TextWordType.Space;\n\t\t\t\t}\n\t\t\t}\n\t\t\tpublic override bool IsWhiteSpace {\n\t\t\t\tget {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic sealed class TabTextWord : TextWord\n\t\t{\n\t\t\tpublic TabTextWord()\n\t\t\t{\n\t\t\t\tlength = 1;\n\t\t\t}\n\t\t\tpublic TabTextWord(HighlightColor color)\n\t\t\t{\n\t\t\t\tlength = 1;\n\t\t\t\tbase.SyntaxColor = color;\n\t\t\t}\n\t\t\t\n\t\t\tpublic override Font GetFont(FontContainer fontContainer)\n\t\t\t{\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\t\n\t\t\tpublic override TextWordType Type {\n\t\t\t\tget {\n\t\t\t\t\treturn TextWordType.Tab;\n\t\t\t\t}\n\t\t\t}\n\t\t\tpublic override bool IsWhiteSpace {\n\t\t\t\tget {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tstatic TextWord spaceWord = new SpaceTextWord();\n\t\tstatic TextWord tabWord   = new TabTextWord();\n\t\t\n\t\tbool hasDefaultColor;\n\t\t\n\t\tpublic static TextWord Space {\n\t\t\tget {\n\t\t\t\treturn spaceWord;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic static TextWord Tab {\n\t\t\tget {\n\t\t\t\treturn tabWord;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int Offset {\n\t\t\tget {\n\t\t\t\treturn offset;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int Length {\n\t\t\tget {\n\t\t\t\treturn length;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Splits the <paramref name=\"word\"/> into two parts: the part before <paramref name=\"pos\"/> is assigned to\n\t\t/// the reference parameter <paramref name=\"word\"/>, the part after <paramref name=\"pos\"/> is returned.\n\t\t/// </summary>\n\t\tpublic static TextWord Split(ref TextWord word, int pos)\n\t\t{\n\t\t\t#if DEBUG\n\t\t\tif (word.Type != TextWordType.Word)\n\t\t\t\tthrow new ArgumentException(\"word.Type must be Word\");\n\t\t\tif (pos <= 0)\n\t\t\t\tthrow new ArgumentOutOfRangeException(\"pos\", pos, \"pos must be > 0\");\n\t\t\tif (pos >= word.Length)\n\t\t\t\tthrow new ArgumentOutOfRangeException(\"pos\", pos, \"pos must be < word.Length\");\n\t\t\t#endif\n\t\t\tTextWord after = new TextWord(word.document, word.line, word.offset + pos, word.length - pos, word.color, word.hasDefaultColor);\n\t\t\tword = new TextWord(word.document, word.line, word.offset, pos, word.color, word.hasDefaultColor);\n\t\t\treturn after;\n\t\t}\n\t\t\n\t\tpublic bool HasDefaultColor {\n\t\t\tget {\n\t\t\t\treturn hasDefaultColor;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic virtual TextWordType Type {\n\t\t\tget {\n\t\t\t\treturn TextWordType.Word;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic string Word {\n\t\t\tget {\n\t\t\t\tif (document == null) {\n\t\t\t\t\treturn String.Empty;\n\t\t\t\t}\n\t\t\t\treturn document.GetText(line.Offset + offset, length);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic virtual Font GetFont(FontContainer fontContainer)\n\t\t{\n\t\t\treturn color.GetFont(fontContainer);\n\t\t}\n\t\t\n\t\tpublic Color Color {\n\t\t\tget {\n\t\t\t\tif (color == null)\n\t\t\t\t\treturn Color.Black;\n\t\t\t\telse\n\t\t\t\t\treturn color.Color;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic bool Bold {\n\t\t\tget {\n\t\t\t\tif (color == null)\n\t\t\t\t\treturn false;\n\t\t\t\telse\n\t\t\t\t\treturn color.Bold;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic bool Italic {\n\t\t\tget {\n\t\t\t\tif (color == null)\n\t\t\t\t\treturn false;\n\t\t\t\telse\n\t\t\t\t\treturn color.Italic;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic HighlightColor SyntaxColor {\n\t\t\tget {\n\t\t\t\treturn color;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tDebug.Assert(value != null);\n\t\t\t\tcolor = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic virtual bool IsWhiteSpace {\n\t\t\tget {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\t\n\t\tprotected TextWord()\n\t\t{\n\t\t}\n\t\t\n\t\t// TAB\n\t\tpublic TextWord(IDocument document, LineSegment line, int offset, int length, HighlightColor color, bool hasDefaultColor)\n\t\t{\n\t\t\tDebug.Assert(document != null);\n\t\t\tDebug.Assert(line != null);\n\t\t\tDebug.Assert(color != null);\n\t\t\t\n\t\t\tthis.document = document;\n\t\t\tthis.line  = line;\n\t\t\tthis.offset = offset;\n\t\t\tthis.length = length;\n\t\t\tthis.color = color;\n\t\t\tthis.hasDefaultColor = hasDefaultColor;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Converts a <see cref=\"TextWord\"/> instance to string (for debug purposes)\n\t\t/// </summary>\n\t\tpublic override string ToString()\n\t\t{\n\t\t\treturn \"[TextWord: Word = \" + Word + \", Color = \" + Color + \"]\";\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/IDocument.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 3205 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\nusing System.Drawing;\n\nusing ICSharpCode.TextEditor.Undo;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\t/// <summary>\n\t/// This interface represents a container which holds a text sequence and\n\t/// all necessary information about it. It is used as the base for a text editor.\n\t/// </summary>\n\tpublic interface IDocument\n\t{\n\t\tITextEditorProperties TextEditorProperties {\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\tUndoStack UndoStack {\n\t\t\tget;\n\t\t}\n\t\t/// <value>\n\t\t/// If true the document can't be altered\n\t\t/// </value>\n\t\tbool ReadOnly {\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// The <see cref=\"IFormattingStrategy\"/> attached to the <see cref=\"IDocument\"/> instance\n\t\t/// </summary>\n\t\tIFormattingStrategy FormattingStrategy {\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// The <see cref=\"ITextBufferStrategy\"/> attached to the <see cref=\"IDocument\"/> instance\n\t\t/// </summary>\n\t\tITextBufferStrategy TextBufferStrategy {\n\t\t\tget;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// The <see cref=\"FoldingManager\"/> attached to the <see cref=\"IDocument\"/> instance\n\t\t/// </summary>\n\t\tFoldingManager FoldingManager {\n\t\t\tget;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// The <see cref=\"IHighlightingStrategy\"/> attached to the <see cref=\"IDocument\"/> instance\n\t\t/// </summary>\n\t\tIHighlightingStrategy HighlightingStrategy {\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// The <see cref=\"IBookMarkManager\"/> attached to the <see cref=\"IDocument\"/> instance\n\t\t/// </summary>\n\t\tBookmarkManager BookmarkManager {\n\t\t\tget;\n\t\t}\n\t\t\n\t\tMarkerStrategy MarkerStrategy {\n\t\t\tget;\n\t\t}\n\t\t\n//\t\t/// <summary>\n//\t\t/// The <see cref=\"SelectionManager\"/> attached to the <see cref=\"IDocument\"/> instance\n//\t\t/// </summary>\n//\t\tSelectionManager SelectionManager {\n//\t\t\tget;\n//\t\t}\n\t\t\n\t\t#region ILineManager interface\n\t\t/// <value>\n\t\t/// A collection of all line segments\n\t\t/// </value>\n\t\t/// <remarks>\n\t\t/// The collection should only be used if you're aware\n\t\t/// of the 'last line ends with a delimiter problem'. Otherwise\n\t\t/// the <see cref=\"GetLineSegment\"/> method should be used.\n\t\t/// </remarks>\n\t\tIList<LineSegment> LineSegmentCollection {\n\t\t\tget;\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// The total number of lines in the document.\n\t\t/// </value>\n\t\tint TotalNumberOfLines {\n\t\t\tget;\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// Returns a valid line number for the given offset.\n\t\t/// </remarks>\n\t\t/// <param name=\"offset\">\n\t\t/// A offset which points to a character in the line which\n\t\t/// line number is returned.\n\t\t/// </param>\n\t\t/// <returns>\n\t\t/// An int which value is the line number.\n\t\t/// </returns>\n\t\t/// <exception cref=\"System.ArgumentException\">If offset points not to a valid position</exception>\n\t\tint GetLineNumberForOffset(int offset);\n\t\t\n\t\t/// <remarks>\n\t\t/// Returns a <see cref=\"LineSegment\"/> for the given offset.\n\t\t/// </remarks>\n\t\t/// <param name=\"offset\">\n\t\t/// A offset which points to a character in the line which\n\t\t/// is returned.\n\t\t/// </param>\n\t\t/// <returns>\n\t\t/// A <see cref=\"LineSegment\"/> object.\n\t\t/// </returns>\n\t\t/// <exception cref=\"System.ArgumentException\">If offset points not to a valid position</exception>\n\t\tLineSegment GetLineSegmentForOffset(int offset);\n\t\t\n\t\t/// <remarks>\n\t\t/// Returns a <see cref=\"LineSegment\"/> for the given line number.\n\t\t/// This function should be used to get a line instead of getting the\n\t\t/// line using the <see cref=\"ArrayList\"/>.\n\t\t/// </remarks>\n\t\t/// <param name=\"lineNumber\">\n\t\t/// The line number which is requested.\n\t\t/// </param>\n\t\t/// <returns>\n\t\t/// A <see cref=\"LineSegment\"/> object.\n\t\t/// </returns>\n\t\t/// <exception cref=\"System.ArgumentException\">If offset points not to a valid position</exception>\n\t\tLineSegment GetLineSegment(int lineNumber);\n\t\t\n\t\t/// <remarks>\n\t\t/// Get the first logical line for a given visible line.\n\t\t/// example : lineNumber == 100 foldings are in the linetracker\n\t\t/// between 0..1 (2 folded, invisible lines) this method returns 102\n\t\t/// the 'logical' line number\n\t\t/// </remarks>\n\t\tint GetFirstLogicalLine(int lineNumber);\n\t\t\n\t\t/// <remarks>\n\t\t/// Get the last logical line for a given visible line.\n\t\t/// example : lineNumber == 100 foldings are in the linetracker\n\t\t/// between 0..1 (2 folded, invisible lines) this method returns 102\n\t\t/// the 'logical' line number\n\t\t/// </remarks>\n\t\tint GetLastLogicalLine(int lineNumber);\n\t\t\n\t\t/// <remarks>\n\t\t/// Get the visible line for a given logical line.\n\t\t/// example : lineNumber == 100 foldings are in the linetracker\n\t\t/// between 0..1 (2 folded, invisible lines) this method returns 98\n\t\t/// the 'visible' line number\n\t\t/// </remarks>\n\t\tint GetVisibleLine(int lineNumber);\n\t\t\n//\t\t/// <remarks>\n//\t\t/// Get the visible column for a given logical line and logical column.\n//\t\t/// </remarks>\n//\t\tint GetVisibleColumn(int logicalLine, int logicalColumn);\n\t\t\n\t\t/// <remarks>\n\t\t/// Get the next visible line after lineNumber\n\t\t/// </remarks>\n\t\tint GetNextVisibleLineAbove(int lineNumber, int lineCount);\n\t\t\n\t\t/// <remarks>\n\t\t/// Get the next visible line below lineNumber\n\t\t/// </remarks>\n\t\tint GetNextVisibleLineBelow(int lineNumber, int lineCount);\n\t\t\n\t\tevent EventHandler<LineLengthChangeEventArgs> LineLengthChanged;\n\t\tevent EventHandler<LineCountChangeEventArgs> LineCountChanged;\n\t\tevent EventHandler<LineEventArgs> LineDeleted;\n\t\t#endregion\n\n\t\t#region ITextBufferStrategy interface\n\t\t/// <value>\n\t\t/// Get the whole text as string.\n\t\t/// When setting the text using the TextContent property, the undo stack is cleared.\n\t\t/// Set TextContent only for actions such as loading a file; if you want to change the current document\n\t\t/// use the Replace method instead.\n\t\t/// </value>\n\t\tstring TextContent {\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// The current length of the sequence of characters that can be edited.\n\t\t/// </value>\n\t\tint TextLength {\n\t\t\tget;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Inserts a string of characters into the sequence.\n\t\t/// </summary>\n\t\t/// <param name=\"offset\">\n\t\t/// offset where to insert the string.\n\t\t/// </param>\n\t\t/// <param name=\"text\">\n\t\t/// text to be inserted.\n\t\t/// </param>\n\t\tvoid Insert(int offset, string text);\n\t\t\n\t\t/// <summary>\n\t\t/// Removes some portion of the sequence.\n\t\t/// </summary>\n\t\t/// <param name=\"offset\">\n\t\t/// offset of the remove.\n\t\t/// </param>\n\t\t/// <param name=\"length\">\n\t\t/// number of characters to remove.\n\t\t/// </param>\n\t\tvoid Remove(int offset, int length);\n\t\t\n\t\t/// <summary>\n\t\t/// Replace some portion of the sequence.\n\t\t/// </summary>\n\t\t/// <param name=\"offset\">\n\t\t/// offset.\n\t\t/// </param>\n\t\t/// <param name=\"length\">\n\t\t/// number of characters to replace.\n\t\t/// </param>\n\t\t/// <param name=\"text\">\n\t\t/// text to be replaced with.\n\t\t/// </param>\n\t\tvoid Replace(int offset, int length, string text);\n\t\t\n\t\t/// <summary>\n\t\t/// Returns a specific char of the sequence.\n\t\t/// </summary>\n\t\t/// <param name=\"offset\">\n\t\t/// Offset of the char to get.\n\t\t/// </param>\n\t\tchar GetCharAt(int offset);\n\t\t\n\t\t/// <summary>\n\t\t/// Fetches a string of characters contained in the sequence.\n\t\t/// </summary>\n\t\t/// <param name=\"offset\">\n\t\t/// Offset into the sequence to fetch\n\t\t/// </param>\n\t\t/// <param name=\"length\">\n\t\t/// number of characters to copy.\n\t\t/// </param>\n\t\tstring GetText(int offset, int length);\n\t\t#endregion\n\t\tstring GetText(ISegment segment);\n\t\t\n\t\t#region ITextModel interface\n\t\t/// <summary>\n\t\t/// returns the logical line/column position from an offset\n\t\t/// </summary>\n\t\tTextLocation OffsetToPosition(int offset);\n\t\t\n\t\t/// <summary>\n\t\t/// returns the offset from a logical line/column position\n\t\t/// </summary>\n\t\tint PositionToOffset(TextLocation p);\n\t\t#endregion\n\t\t/// <value>\n\t\t/// A container where all TextAreaUpdate objects get stored\n\t\t/// </value>\n\t\tList<TextAreaUpdate> UpdateQueue {\n\t\t\tget;\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// Requests an update of the textarea\n\t\t/// </remarks>\n\t\tvoid RequestUpdate(TextAreaUpdate update);\n\t\t\n\t\t/// <remarks>\n\t\t/// Commits all updates in the queue to the textarea (the\n\t\t/// textarea will be painted)\n\t\t/// </remarks>\n\t\tvoid CommitUpdate();\n\t\t\n\t\t/// <summary>\n\t\t/// Moves, Resizes, Removes a list of segments on insert/remove/replace events.\n\t\t/// </summary>\n\t\tvoid UpdateSegmentListOnDocumentChange<T>(List<T> list, DocumentEventArgs e) where T : ISegment;\n\t\t\n\t\t/// <summary>\n\t\t/// Is fired when CommitUpdate is called\n\t\t/// </summary>\n\t\tevent EventHandler UpdateCommited;\n\t\t\n\t\t/// <summary>\n\t\t/// </summary>\n\t\tevent DocumentEventHandler DocumentAboutToBeChanged;\n\t\t\n\t\t/// <summary>\n\t\t/// </summary>\n\t\tevent DocumentEventHandler DocumentChanged;\n\t\t\n\t\tevent EventHandler TextContentChanged;\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/ISegment.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 1966 $</version>\n// </file>\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\t/// <summary>\n\t/// This interface is used to describe a span inside a text sequence\n\t/// </summary>\n\tpublic interface ISegment\n\t{\n\t\t/// <value>\n\t\t/// The offset where the span begins\n\t\t/// </value>\n\t\tint Offset {\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// The length of the span\n\t\t/// </value>\n\t\tint Length {\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t}\n\t\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/ITextEditorProperties.cs",
    "content": "// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"none\" email=\"\"/>\n//     <version>$Revision: 3205 $</version>\n// </file>\n\nusing System;\nusing System.Drawing;\nusing System.Text;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\tpublic interface ITextEditorProperties\n\t{\n\t\tbool AutoInsertCurlyBracket { // is wrapped in text editor control\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\tbool HideMouseCursor { // is wrapped in text editor control\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\tbool IsIconBarVisible { // is wrapped in text editor control\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\tbool AllowCaretBeyondEOL {\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\tbool ShowMatchingBracket { // is wrapped in text editor control\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\tbool CutCopyWholeLine {\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\n\t\tSystem.Drawing.Text.TextRenderingHint TextRenderingHint { // is wrapped in text editor control\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\tbool MouseWheelScrollDown {\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\tbool MouseWheelTextZoom {\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\tstring LineTerminator {\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\tLineViewerStyle LineViewerStyle { // is wrapped in text editor control\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\tbool ShowInvalidLines { // is wrapped in text editor control\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\tint VerticalRulerRow { // is wrapped in text editor control\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\tbool ShowSpaces { // is wrapped in text editor control\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\tbool ShowTabs { // is wrapped in text editor control\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\tbool ShowEOLMarker { // is wrapped in text editor control\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\tbool ConvertTabsToSpaces { // is wrapped in text editor control\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\tbool ShowHorizontalRuler { // is wrapped in text editor control\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\tbool ShowVerticalRuler { // is wrapped in text editor control\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\tEncoding Encoding {\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\tbool EnableFolding { // is wrapped in text editor control\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\tbool ShowLineNumbers { // is wrapped in text editor control\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// The width of a tab.\n\t\t/// </summary>\n\t\tint TabIndent { // is wrapped in text editor control\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// The amount of spaces a tab is converted to if ConvertTabsToSpaces is true.\n\t\t/// </summary>\n\t\tint IndentationSize {\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\tIndentStyle IndentStyle { // is wrapped in text editor control\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\tDocumentSelectionMode DocumentSelectionMode {\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\tFont Font { // is wrapped in text editor control\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\tFontContainer FontContainer {\n\t\t\tget;\n\t\t}\n\t\t\n\t\tBracketMatchingStyle  BracketMatchingStyle { // is wrapped in text editor control\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\tbool SupportReadOnlySegments {\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/LineManager/DeferredEventList.cs",
    "content": "// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Daniel Grunwald\"/>\n//     <version>$Revision$</version>\n// </file>\nusing System;\nusing System.Collections.Generic;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\t/// <summary>\n\t/// A list of events that are fired after the line manager has finished working.\n\t/// </summary>\n\tstruct DeferredEventList\n\t{\n\t\tinternal List<LineSegment> removedLines;\n\t\tinternal List<TextAnchor> textAnchor;\n\t\t\n\t\tpublic void AddRemovedLine(LineSegment line)\n\t\t{\n\t\t\tif (removedLines == null)\n\t\t\t\tremovedLines = new List<LineSegment>();\n\t\t\tremovedLines.Add(line);\n\t\t}\n\t\t\n\t\tpublic void AddDeletedAnchor(TextAnchor anchor)\n\t\t{\n\t\t\tif (textAnchor == null)\n\t\t\t\ttextAnchor = new List<TextAnchor>();\n\t\t\ttextAnchor.Add(anchor);\n\t\t}\n\t\t\n\t\tpublic void RaiseEvents()\n\t\t{\n\t\t\t// removedLines is raised by the LineManager\n\t\t\tif (textAnchor != null) {\n\t\t\t\tforeach (TextAnchor a in textAnchor) {\n\t\t\t\t\ta.RaiseDeleted();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/LineManager/LineManager.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 3274 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\tinternal sealed class LineManager\n\t{\n\t\tLineSegmentTree lineCollection = new LineSegmentTree();\n\t\t\n\t\tIDocument document;\n\t\tIHighlightingStrategy highlightingStrategy;\n\t\t\n\t\tpublic IList<LineSegment> LineSegmentCollection {\n\t\t\tget {\n\t\t\t\treturn lineCollection;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int TotalNumberOfLines {\n\t\t\tget {\n\t\t\t\treturn lineCollection.Count;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic IHighlightingStrategy HighlightingStrategy {\n\t\t\tget {\n\t\t\t\treturn highlightingStrategy;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tif (highlightingStrategy != value) {\n\t\t\t\t\thighlightingStrategy = value;\n\t\t\t\t\tif (highlightingStrategy != null) {\n\t\t\t\t\t\thighlightingStrategy.MarkTokens(document);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic LineManager(IDocument document, IHighlightingStrategy highlightingStrategy)\n\t\t{\n\t\t\tthis.document = document;\n\t\t\tthis.highlightingStrategy = highlightingStrategy;\n\t\t}\n\t\t\n\t\tpublic int GetLineNumberForOffset(int offset)\n\t\t{\n\t\t\treturn GetLineSegmentForOffset(offset).LineNumber;\n\t\t}\n\t\t\n\t\tpublic LineSegment GetLineSegmentForOffset(int offset)\n\t\t{\n\t\t\treturn lineCollection.GetByOffset(offset);\n\t\t}\n\t\t\n\t\tpublic LineSegment GetLineSegment(int lineNr)\n\t\t{\n\t\t\treturn lineCollection[lineNr];\n\t\t}\n\t\t\n\t\tpublic void Insert(int offset, string text)\n\t\t{\n\t\t\tReplace(offset, 0, text);\n\t\t}\n\t\t\n\t\tpublic void Remove(int offset, int length)\n\t\t{\n\t\t\tReplace(offset, length, String.Empty);\n\t\t}\n\t\t\n\t\tpublic void Replace(int offset, int length, string text)\n\t\t{\n\t\t\tDebug.WriteLine(\"Replace offset=\"+offset+\" length=\"+length+\" text.Length=\"+text.Length);\n\t\t\tint lineStart = GetLineNumberForOffset(offset);\n\t\t\tint oldNumberOfLines = this.TotalNumberOfLines;\n\t\t\tDeferredEventList deferredEventList = new DeferredEventList();\n\t\t\tRemoveInternal(ref deferredEventList, offset, length);\n\t\t\tint numberOfLinesAfterRemoving = this.TotalNumberOfLines;\n\t\t\tif (!string.IsNullOrEmpty(text)) {\n\t\t\t\tInsertInternal(offset, text);\n\t\t\t}\n//\t\t\t#if DEBUG\n//\t\t\tConsole.WriteLine(\"New line collection:\");\n//\t\t\tConsole.WriteLine(lineCollection.GetTreeAsString());\n//\t\t\tConsole.WriteLine(\"New text:\");\n//\t\t\tConsole.WriteLine(\"'\" + document.TextContent + \"'\");\n//\t\t\t#endif\n\t\t\t// Only fire events after RemoveInternal+InsertInternal finished completely:\n\t\t\t// Otherwise we would expose inconsistent state to the event handlers.\n\t\t\tRunHighlighter(lineStart, 1 + Math.Max(0, this.TotalNumberOfLines - numberOfLinesAfterRemoving));\n\t\t\t\n\t\t\tif (deferredEventList.removedLines != null) {\n\t\t\t\tforeach (LineSegment ls in deferredEventList.removedLines)\n\t\t\t\t\tOnLineDeleted(new LineEventArgs(document, ls));\n\t\t\t}\n\t\t\tdeferredEventList.RaiseEvents();\n\t\t\tif (this.TotalNumberOfLines != oldNumberOfLines) {\n\t\t\t\tOnLineCountChanged(new LineCountChangeEventArgs(document, lineStart, this.TotalNumberOfLines - oldNumberOfLines));\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid RemoveInternal(ref DeferredEventList deferredEventList, int offset, int length)\n\t\t{\n\t\t\tDebug.Assert(length >= 0);\n\t\t\tif (length == 0) return;\n\t\t\tLineSegmentTree.Enumerator it = lineCollection.GetEnumeratorForOffset(offset);\n\t\t\tLineSegment startSegment = it.Current;\n\t\t\tint startSegmentOffset = startSegment.Offset;\n\t\t\tif (offset + length < startSegmentOffset + startSegment.TotalLength) {\n\t\t\t\t// just removing a part of this line segment\n\t\t\t\tstartSegment.RemovedLinePart(ref deferredEventList, offset - startSegmentOffset, length);\n\t\t\t\tSetSegmentLength(startSegment, startSegment.TotalLength - length);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// merge startSegment with another line segment because startSegment's delimiter was deleted\n\t\t\t// possibly remove lines in between if multiple delimiters were deleted\n\t\t\tint charactersRemovedInStartLine = startSegmentOffset + startSegment.TotalLength - offset;\n\t\t\tDebug.Assert(charactersRemovedInStartLine > 0);\n\t\t\tstartSegment.RemovedLinePart(ref deferredEventList, offset - startSegmentOffset, charactersRemovedInStartLine);\n\t\t\t\n\t\t\t\n\t\t\tLineSegment endSegment = lineCollection.GetByOffset(offset + length);\n\t\t\tif (endSegment == startSegment) {\n\t\t\t\t// special case: we are removing a part of the last line up to the\n\t\t\t\t// end of the document\n\t\t\t\tSetSegmentLength(startSegment, startSegment.TotalLength - length);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tint endSegmentOffset = endSegment.Offset;\n\t\t\tint charactersLeftInEndLine = endSegmentOffset + endSegment.TotalLength - (offset + length);\n\t\t\tendSegment.RemovedLinePart(ref deferredEventList, 0, endSegment.TotalLength - charactersLeftInEndLine);\n\t\t\tstartSegment.MergedWith(endSegment, offset - startSegmentOffset);\n\t\t\tSetSegmentLength(startSegment, startSegment.TotalLength - charactersRemovedInStartLine + charactersLeftInEndLine);\n\t\t\tstartSegment.DelimiterLength = endSegment.DelimiterLength;\n\t\t\t// remove all segments between startSegment (excl.) and endSegment (incl.)\n\t\t\tit.MoveNext();\n\t\t\tLineSegment segmentToRemove;\n\t\t\tdo {\n\t\t\t\tsegmentToRemove = it.Current;\n\t\t\t\tit.MoveNext();\n\t\t\t\tlineCollection.RemoveSegment(segmentToRemove);\n\t\t\t\tsegmentToRemove.Deleted(ref deferredEventList);\n\t\t\t} while (segmentToRemove != endSegment);\n\t\t}\n\t\t\n\t\tvoid InsertInternal(int offset, string text)\n\t\t{\n\t\t\tLineSegment segment = lineCollection.GetByOffset(offset);\n\t\t\tDelimiterSegment ds = NextDelimiter(text, 0);\n\t\t\tif (ds == null) {\n\t\t\t\t// no newline is being inserted, all text is inserted in a single line\n\t\t\t\tsegment.InsertedLinePart(offset - segment.Offset, text.Length);\n\t\t\t\tSetSegmentLength(segment, segment.TotalLength + text.Length);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tLineSegment firstLine = segment;\n\t\t\tfirstLine.InsertedLinePart(offset - firstLine.Offset, ds.Offset);\n\t\t\tint lastDelimiterEnd = 0;\n\t\t\twhile (ds != null) {\n\t\t\t\t// split line segment at line delimiter\n\t\t\t\tint lineBreakOffset = offset + ds.Offset + ds.Length;\n\t\t\t\tint segmentOffset = segment.Offset;\n\t\t\t\tint lengthAfterInsertionPos = segmentOffset + segment.TotalLength - (offset + lastDelimiterEnd);\n\t\t\t\tlineCollection.SetSegmentLength(segment, lineBreakOffset - segmentOffset);\n\t\t\t\tLineSegment newSegment = lineCollection.InsertSegmentAfter(segment, lengthAfterInsertionPos);\n\t\t\t\tsegment.DelimiterLength = ds.Length;\n\t\t\t\t\n\t\t\t\tsegment = newSegment;\n\t\t\t\tlastDelimiterEnd = ds.Offset + ds.Length;\n\t\t\t\t\n\t\t\t\tds = NextDelimiter(text, lastDelimiterEnd);\n\t\t\t}\n\t\t\tfirstLine.SplitTo(segment);\n\t\t\t// insert rest after last delimiter\n\t\t\tif (lastDelimiterEnd != text.Length) {\n\t\t\t\tsegment.InsertedLinePart(0, text.Length - lastDelimiterEnd);\n\t\t\t\tSetSegmentLength(segment, segment.TotalLength + text.Length - lastDelimiterEnd);\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid SetSegmentLength(LineSegment segment, int newTotalLength)\n\t\t{\n\t\t\tint delta = newTotalLength - segment.TotalLength;\n\t\t\tif (delta != 0) {\n\t\t\t\tlineCollection.SetSegmentLength(segment, newTotalLength);\n\t\t\t\tOnLineLengthChanged(new LineLengthChangeEventArgs(document, segment, delta));\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid RunHighlighter(int firstLine, int lineCount)\n\t\t{\n\t\t\tif (highlightingStrategy != null) {\n\t\t\t\tList<LineSegment> markLines = new List<LineSegment>();\n\t\t\t\tLineSegmentTree.Enumerator it = lineCollection.GetEnumeratorForIndex(firstLine);\n\t\t\t\tfor (int i = 0; i < lineCount && it.IsValid; i++) {\n\t\t\t\t\tmarkLines.Add(it.Current);\n\t\t\t\t\tit.MoveNext();\n\t\t\t\t}\n\t\t\t\thighlightingStrategy.MarkTokens(document, markLines);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic void SetContent(string text)\n\t\t{\n\t\t\tlineCollection.Clear();\n\t\t\tif (text != null) {\n\t\t\t\tReplace(0, 0, text);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int GetVisibleLine(int logicalLineNumber)\n\t\t{\n\t\t\tif (!document.TextEditorProperties.EnableFolding) {\n\t\t\t\treturn logicalLineNumber;\n\t\t\t}\n\t\t\t\n\t\t\tint visibleLine = 0;\n\t\t\tint foldEnd = 0;\n\t\t\tList<FoldMarker> foldings = document.FoldingManager.GetTopLevelFoldedFoldings();\n\t\t\tforeach (FoldMarker fm in foldings) {\n\t\t\t\tif (fm.StartLine >= logicalLineNumber) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (fm.StartLine >= foldEnd) {\n\t\t\t\t\tvisibleLine += fm.StartLine - foldEnd;\n\t\t\t\t\tif (fm.EndLine > logicalLineNumber) {\n\t\t\t\t\t\treturn visibleLine;\n\t\t\t\t\t}\n\t\t\t\t\tfoldEnd = fm.EndLine;\n\t\t\t\t}\n\t\t\t}\n//\t\t\tDebug.Assert(logicalLineNumber >= foldEnd);\n\t\t\tvisibleLine += logicalLineNumber - foldEnd;\n\t\t\treturn visibleLine;\n\t\t}\n\t\t\n\t\tpublic int GetFirstLogicalLine(int visibleLineNumber)\n\t\t{\n\t\t\tif (!document.TextEditorProperties.EnableFolding) {\n\t\t\t\treturn visibleLineNumber;\n\t\t\t}\n\t\t\tint v = 0;\n\t\t\tint foldEnd = 0;\n\t\t\tList<FoldMarker> foldings = document.FoldingManager.GetTopLevelFoldedFoldings();\n\t\t\tforeach (FoldMarker fm in foldings) {\n\t\t\t\tif (fm.StartLine >= foldEnd) {\n\t\t\t\t\tif (v + fm.StartLine - foldEnd >= visibleLineNumber) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tv += fm.StartLine - foldEnd;\n\t\t\t\t\tfoldEnd = fm.EndLine;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// help GC\n\t\t\tfoldings.Clear();\n\t\t\tfoldings = null;\n\t\t\treturn foldEnd + visibleLineNumber - v;\n\t\t}\n\t\t\n\t\tpublic int GetLastLogicalLine(int visibleLineNumber)\n\t\t{\n\t\t\tif (!document.TextEditorProperties.EnableFolding) {\n\t\t\t\treturn visibleLineNumber;\n\t\t\t}\n\t\t\treturn GetFirstLogicalLine(visibleLineNumber + 1) - 1;\n\t\t}\n\t\t\n\t\t// TODO : speedup the next/prev visible line search\n\t\t// HOW? : save the foldings in a sorted list and lookup the\n\t\t//        line numbers in this list\n\t\tpublic int GetNextVisibleLineAbove(int lineNumber, int lineCount)\n\t\t{\n\t\t\tint curLineNumber = lineNumber;\n\t\t\tif (document.TextEditorProperties.EnableFolding) {\n\t\t\t\tfor (int i = 0; i < lineCount && curLineNumber < TotalNumberOfLines; ++i) {\n\t\t\t\t\t++curLineNumber;\n\t\t\t\t\twhile (curLineNumber < TotalNumberOfLines && (curLineNumber >= lineCollection.Count || !document.FoldingManager.IsLineVisible(curLineNumber))) {\n\t\t\t\t\t\t++curLineNumber;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcurLineNumber += lineCount;\n\t\t\t}\n\t\t\treturn Math.Min(TotalNumberOfLines - 1, curLineNumber);\n\t\t}\n\t\t\n\t\tpublic int GetNextVisibleLineBelow(int lineNumber, int lineCount)\n\t\t{\n\t\t\tint curLineNumber = lineNumber;\n\t\t\tif (document.TextEditorProperties.EnableFolding) {\n\t\t\t\tfor (int i = 0; i < lineCount; ++i) {\n\t\t\t\t\t--curLineNumber;\n\t\t\t\t\twhile (curLineNumber >= 0 && !document.FoldingManager.IsLineVisible(curLineNumber)) {\n\t\t\t\t\t\t--curLineNumber;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcurLineNumber -= lineCount;\n\t\t\t}\n\t\t\treturn Math.Max(0, curLineNumber);\n\t\t}\n\t\t\n\t\t// use always the same DelimiterSegment object for the NextDelimiter\n\t\tDelimiterSegment delimiterSegment = new DelimiterSegment();\n\t\t\n\t\tDelimiterSegment NextDelimiter(string text, int offset)\n\t\t{\n\t\t\tfor (int i = offset; i < text.Length; i++) {\n\t\t\t\tswitch (text[i]) {\n\t\t\t\t\tcase '\\r':\n\t\t\t\t\t\tif (i + 1 < text.Length) {\n\t\t\t\t\t\t\tif (text[i + 1] == '\\n') {\n\t\t\t\t\t\t\t\tdelimiterSegment.Offset = i;\n\t\t\t\t\t\t\t\tdelimiterSegment.Length = 2;\n\t\t\t\t\t\t\t\treturn delimiterSegment;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tgoto case '\\n';\n\t\t\t\t\tcase '\\n':\n\t\t\t\t\t\tdelimiterSegment.Offset = i;\n\t\t\t\t\t\tdelimiterSegment.Length = 1;\n\t\t\t\t\t\treturn delimiterSegment;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\t\n\t\tvoid OnLineCountChanged(LineCountChangeEventArgs e)\n\t\t{\n\t\t\tif (LineCountChanged != null) {\n\t\t\t\tLineCountChanged(this, e);\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid OnLineLengthChanged(LineLengthChangeEventArgs e)\n\t\t{\n\t\t\tif (LineLengthChanged != null) {\n\t\t\t\tLineLengthChanged(this, e);\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid OnLineDeleted(LineEventArgs e)\n\t\t{\n\t\t\tif (LineDeleted != null) {\n\t\t\t\tLineDeleted(this, e);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic event EventHandler<LineLengthChangeEventArgs> LineLengthChanged;\n\t\tpublic event EventHandler<LineCountChangeEventArgs> LineCountChanged;\n\t\tpublic event EventHandler<LineEventArgs> LineDeleted;\n\t\t\n\t\tsealed class DelimiterSegment\n\t\t{\n\t\t\tinternal int Offset;\n\t\t\tinternal int Length;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/LineManager/LineManagerEventArgs.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 2691 $</version>\n// </file>\n\nusing System;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\tpublic class LineCountChangeEventArgs : EventArgs\n\t{\n\t\tIDocument document;\n\t\tint       start;\n\t\tint       moved;\n\t\t\n\t\t/// <returns>\n\t\t/// always a valid Document which is related to the Event.\n\t\t/// </returns>\n\t\tpublic IDocument Document {\n\t\t\tget {\n\t\t\t\treturn document;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <returns>\n\t\t/// -1 if no offset was specified for this event\n\t\t/// </returns>\n\t\tpublic int LineStart {\n\t\t\tget {\n\t\t\t\treturn start;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <returns>\n\t\t/// -1 if no length was specified for this event\n\t\t/// </returns>\n\t\tpublic int LinesMoved {\n\t\t\tget {\n\t\t\t\treturn moved;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic LineCountChangeEventArgs(IDocument document, int lineStart, int linesMoved)\n\t\t{\n\t\t\tthis.document = document;\n\t\t\tthis.start    = lineStart;\n\t\t\tthis.moved    = linesMoved;\n\t\t}\n\t}\n\t\n\tpublic class LineEventArgs : EventArgs\n\t{\n\t\tIDocument document;\n\t\tLineSegment lineSegment;\n\t\t\n\t\tpublic IDocument Document {\n\t\t\tget { return document; }\n\t\t}\n\t\t\n\t\tpublic LineSegment LineSegment {\n\t\t\tget { return lineSegment; }\n\t\t}\n\t\t\n\t\tpublic LineEventArgs(IDocument document, LineSegment lineSegment)\n\t\t{\n\t\t\tthis.document = document;\n\t\t\tthis.lineSegment = lineSegment;\n\t\t}\n\t\t\n\t\tpublic override string ToString()\n\t\t{\n\t\t\treturn string.Format(\"[LineEventArgs Document={0} LineSegment={1}]\", this.document, this.lineSegment);\n\t\t}\n\t}\n\t\n\tpublic class LineLengthChangeEventArgs : LineEventArgs\n\t{\n\t\tint lengthDelta;\n\t\t\n\t\tpublic int LengthDelta {\n\t\t\tget { return lengthDelta; }\n\t\t}\n\t\t\n\t\tpublic LineLengthChangeEventArgs(IDocument document, LineSegment lineSegment, int moved)\n\t\t\t: base(document, lineSegment)\n\t\t{\n\t\t\tthis.lengthDelta = moved;\n\t\t}\n\t\t\n\t\tpublic override string ToString()\n\t\t{\n\t\t\treturn string.Format(\"[LineLengthEventArgs Document={0} LineSegment={1} LengthDelta={2}]\", this.Document, this.LineSegment, this.lengthDelta);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/LineManager/LineSegment.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 3272 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\nusing System.Drawing;\nusing System.Diagnostics;\nusing System.Text;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\tpublic sealed class LineSegment : ISegment\n\t{\n\t\tinternal LineSegmentTree.Enumerator treeEntry;\n\t\tint totalLength, delimiterLength;\n\t\t\n\t\tList<TextWord> words;\n\t\tSpanStack highlightSpanStack;\n\t\t\n\t\tpublic TextWord GetWord(int column)\n\t\t{\n\t\t\tint curColumn = 0;\n\t\t\tforeach (TextWord word in words) {\n\t\t\t\tif (column < curColumn + word.Length) {\n\t\t\t\t\treturn word;\n\t\t\t\t}\n\t\t\t\tcurColumn += word.Length;\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\t\n\t\tpublic bool IsDeleted {\n\t\t\tget { return !treeEntry.IsValid; }\n\t\t}\n\t\t\n\t\tpublic int LineNumber {\n\t\t\tget { return treeEntry.CurrentIndex; }\n\t\t}\n\t\t\n\t\tpublic int Offset {\n\t\t\tget { return treeEntry.CurrentOffset; }\n\t\t}\n\t\t\n\t\tpublic int Length {\n\t\t\tget\t{ return totalLength - delimiterLength; }\n\t\t}\n\t\t\n\t\tint ISegment.Offset {\n\t\t\tget { return this.Offset; }\n\t\t\tset { throw new NotSupportedException(); }\n\t\t}\n\t\tint ISegment.Length {\n\t\t\tget { return this.Length; }\n\t\t\tset { throw new NotSupportedException(); }\n\t\t}\n\t\t\n\t\tpublic int TotalLength {\n\t\t\tget { return totalLength; }\n\t\t\tinternal set { totalLength = value; }\n\t\t}\n\t\t\n\t\tpublic int DelimiterLength {\n\t\t\tget { return delimiterLength; }\n\t\t\tinternal set { delimiterLength = value; }\n\t\t}\n\t\t\n\t\t// highlighting information\n\t\tpublic List<TextWord> Words {\n\t\t\tget {\n\t\t\t\treturn words;\n\t\t\t}\n\t\t\tset {\n\t\t\t\twords = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic HighlightColor GetColorForPosition(int x)\n\t\t{\n\t\t\tif (Words != null) {\n\t\t\t\tint xPos = 0;\n\t\t\t\tforeach (TextWord word in Words) {\n\t\t\t\t\tif (x < xPos + word.Length) {\n\t\t\t\t\t\treturn word.SyntaxColor;\n\t\t\t\t\t}\n\t\t\t\t\txPos += word.Length;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn new HighlightColor(Color.Black, false, false);\n\t\t}\n\t\t\n\t\tpublic SpanStack HighlightSpanStack {\n\t\t\tget {\n\t\t\t\treturn highlightSpanStack;\n\t\t\t}\n\t\t\tset {\n\t\t\t\thighlightSpanStack = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Converts a <see cref=\"LineSegment\"/> instance to string (for debug purposes)\n\t\t/// </summary>\n\t\tpublic override string ToString()\n\t\t{\n\t\t\tif (IsDeleted)\n\t\t\t\treturn \"[LineSegment: (deleted) Length = \" + Length + \", TotalLength = \" + TotalLength + \", DelimiterLength = \" + delimiterLength + \"]\";\n\t\t\telse\n\t\t\t\treturn \"[LineSegment: LineNumber=\" + LineNumber + \", Offset = \"+ Offset +\", Length = \" + Length + \", TotalLength = \" + TotalLength + \", DelimiterLength = \" + delimiterLength + \"]\";\n\t\t}\n\t\t\n\t\t#region Anchor management\n\t\tUtil.WeakCollection<TextAnchor> anchors;\n\t\t\n\t\tpublic TextAnchor CreateAnchor(int column)\n\t\t{\n\t\t\tif (column < 0 || column > Length)\n\t\t\t\tthrow new ArgumentOutOfRangeException(\"column\");\n\t\t\tTextAnchor anchor = new TextAnchor(this, column);\n\t\t\tAddAnchor(anchor);\n\t\t\treturn anchor;\n\t\t}\n\t\t\n\t\tvoid AddAnchor(TextAnchor anchor)\n\t\t{\n\t\t\tDebug.Assert(anchor.Line == this);\n\t\t\t\n\t\t\tif (anchors == null)\n\t\t\t\tanchors = new Util.WeakCollection<TextAnchor>();\n\t\t\t\n\t\t\tanchors.Add(anchor);\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Is called when the LineSegment is deleted.\n\t\t/// </summary>\n\t\tinternal void Deleted(ref DeferredEventList deferredEventList)\n\t\t{\n\t\t\t//Console.WriteLine(\"Deleted\");\n\t\t\ttreeEntry = LineSegmentTree.Enumerator.Invalid;\n\t\t\tif (anchors != null) {\n\t\t\t\tforeach (TextAnchor a in anchors) {\n\t\t\t\t\ta.Delete(ref deferredEventList);\n\t\t\t\t}\n\t\t\t\tanchors = null;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Is called when a part of the line is removed.\n\t\t/// </summary>\n\t\tinternal void RemovedLinePart(ref DeferredEventList deferredEventList, int startColumn, int length)\n\t\t{\n\t\t\tif (length == 0)\n\t\t\t\treturn;\n\t\t\tDebug.Assert(length > 0);\n\t\t\t\n\t\t\t//Console.WriteLine(\"RemovedLinePart \" + startColumn + \", \" + length);\n\t\t\tif (anchors != null) {\n\t\t\t\tList<TextAnchor> deletedAnchors = null;\n\t\t\t\tforeach (TextAnchor a in anchors) {\n\t\t\t\t\tif (a.ColumnNumber > startColumn) {\n\t\t\t\t\t\tif (a.ColumnNumber >= startColumn + length) {\n\t\t\t\t\t\t\ta.ColumnNumber -= length;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (deletedAnchors == null)\n\t\t\t\t\t\t\t\tdeletedAnchors = new List<TextAnchor>();\n\t\t\t\t\t\t\ta.Delete(ref deferredEventList);\n\t\t\t\t\t\t\tdeletedAnchors.Add(a);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (deletedAnchors != null) {\n\t\t\t\t\tforeach (TextAnchor a in deletedAnchors) {\n\t\t\t\t\t\tanchors.Remove(a);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Is called when a part of the line is inserted.\n\t\t/// </summary>\n\t\tinternal void InsertedLinePart(int startColumn, int length)\n\t\t{\n\t\t\tif (length == 0)\n\t\t\t\treturn;\n\t\t\tDebug.Assert(length > 0);\n\t\t\t\n\t\t\t//Console.WriteLine(\"InsertedLinePart \" + startColumn + \", \" + length);\n\t\t\tif (anchors != null) {\n\t\t\t\tforeach (TextAnchor a in anchors) {\n\t\t\t\t\tif (a.MovementType == AnchorMovementType.BeforeInsertion\n\t\t\t\t\t    ? a.ColumnNumber > startColumn\n\t\t\t\t\t    : a.ColumnNumber >= startColumn)\n\t\t\t\t\t{\n\t\t\t\t\t\ta.ColumnNumber += length;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Is called after another line's content is appended to this line because the newline in between\n\t\t/// was deleted.\n\t\t/// The DefaultLineManager will call Deleted() on the deletedLine after the MergedWith call.\n\t\t/// \n\t\t/// firstLineLength: the length of the line before the merge.\n\t\t/// </summary>\n\t\tinternal void MergedWith(LineSegment deletedLine, int firstLineLength)\n\t\t{\n\t\t\t//Console.WriteLine(\"MergedWith\");\n\t\t\t\n\t\t\tif (deletedLine.anchors != null) {\n\t\t\t\tforeach (TextAnchor a in deletedLine.anchors) {\n\t\t\t\t\ta.Line = this;\n\t\t\t\t\tAddAnchor(a);\n\t\t\t\t\ta.ColumnNumber += firstLineLength;\n\t\t\t\t}\n\t\t\t\tdeletedLine.anchors = null;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Is called after a newline was inserted into this line, splitting it into this and followingLine.\n\t\t/// </summary>\n\t\tinternal void SplitTo(LineSegment followingLine)\n\t\t{\n\t\t\t//Console.WriteLine(\"SplitTo\");\n\t\t\t\n\t\t\tif (anchors != null) {\n\t\t\t\tList<TextAnchor> movedAnchors = null;\n\t\t\t\tforeach (TextAnchor a in anchors) {\n\t\t\t\t\tif (a.MovementType == AnchorMovementType.BeforeInsertion\n\t\t\t\t\t    ? a.ColumnNumber > this.Length\n\t\t\t\t\t    : a.ColumnNumber >= this.Length)\n\t\t\t\t\t{\n\t\t\t\t\t\ta.Line = followingLine;\n\t\t\t\t\t\tfollowingLine.AddAnchor(a);\n\t\t\t\t\t\ta.ColumnNumber -= this.Length;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (movedAnchors == null)\n\t\t\t\t\t\t\tmovedAnchors = new List<TextAnchor>();\n\t\t\t\t\t\tmovedAnchors.Add(a);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (movedAnchors != null) {\n\t\t\t\t\tforeach (TextAnchor a in movedAnchors) {\n\t\t\t\t\t\tanchors.Remove(a);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t#endregion\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/LineManager/LineSegmentTree.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Daniel Grunwald\" email=\"daniel@danielgrunwald.de\"/>\n//     <version>$Revision: 2683 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing ICSharpCode.TextEditor.Util;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\t/// <summary>\n\t/// Data structure for efficient management of the line segments (most operations are O(lg n)).\n\t/// This implements an augmented red-black tree where each node has fields for the number of\n\t/// nodes in its subtree (like an order statistics tree) for access by index(=line number).\n\t/// Additionally, each node knows the total length of all segments in its subtree.\n\t/// This means we can find nodes by offset in O(lg n) time. Since the offset itself is not stored in\n\t/// the line segment but computed from the lengths stored in the tree, we adjusting the offsets when\n\t/// text is inserted in one line means we just have to increment the totalLength of the affected line and\n\t/// its parent nodes - an O(lg n) operation.\n\t/// However this means getting the line number or offset from a LineSegment is not a constant time\n\t/// operation, but takes O(lg n).\n\t/// \n\t/// NOTE: The tree is never empty, Clear() causes it to contain an empty segment.\n\t/// </summary>\n\tsealed class LineSegmentTree : IList<LineSegment>\n\t{\n\t\tinternal struct RBNode\n\t\t{\n\t\t\tinternal LineSegment lineSegment;\n\t\t\tinternal int count;\n\t\t\tinternal int totalLength;\n\t\t\t\n\t\t\tpublic RBNode(LineSegment lineSegment)\n\t\t\t{\n\t\t\t\tthis.lineSegment = lineSegment;\n\t\t\t\tthis.count = 1;\n\t\t\t\tthis.totalLength = lineSegment.TotalLength;\n\t\t\t}\n\t\t\t\n\t\t\tpublic override string ToString()\n\t\t\t{\n\t\t\t\treturn \"[RBNode count=\" + count + \" totalLength=\"+totalLength\n\t\t\t\t\t+ \" lineSegment.LineNumber=\" + lineSegment.LineNumber\n\t\t\t\t\t+ \" lineSegment.Offset=\" + lineSegment.Offset\n\t\t\t\t\t+ \" lineSegment.TotalLength=\" + lineSegment.TotalLength\n\t\t\t\t\t+ \" lineSegment.DelimiterLength=\" + lineSegment.DelimiterLength + \"]\";\n\t\t\t}\n\t\t}\n\t\t\n\t\tstruct MyHost : IRedBlackTreeHost<RBNode>\n\t\t{\n\t\t\tpublic int Compare(RBNode x, RBNode y)\n\t\t\t{\n\t\t\t\tthrow new NotImplementedException();\n\t\t\t}\n\t\t\t\n\t\t\tpublic bool Equals(RBNode a, RBNode b)\n\t\t\t{\n\t\t\t\tthrow new NotImplementedException();\n\t\t\t}\n\t\t\t\n\t\t\tpublic void UpdateAfterChildrenChange(RedBlackTreeNode<RBNode> node)\n\t\t\t{\n\t\t\t\tint count = 1;\n\t\t\t\tint totalLength = node.val.lineSegment.TotalLength;\n\t\t\t\tif (node.left != null) {\n\t\t\t\t\tcount += node.left.val.count;\n\t\t\t\t\ttotalLength += node.left.val.totalLength;\n\t\t\t\t}\n\t\t\t\tif (node.right != null) {\n\t\t\t\t\tcount += node.right.val.count;\n\t\t\t\t\ttotalLength += node.right.val.totalLength;\n\t\t\t\t}\n\t\t\t\tif (count != node.val.count || totalLength != node.val.totalLength) {\n\t\t\t\t\tnode.val.count = count;\n\t\t\t\t\tnode.val.totalLength = totalLength;\n\t\t\t\t\tif (node.parent != null) UpdateAfterChildrenChange(node.parent);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tpublic void UpdateAfterRotateLeft(RedBlackTreeNode<RBNode> node)\n\t\t\t{\n\t\t\t\tUpdateAfterChildrenChange(node);\n\t\t\t\tUpdateAfterChildrenChange(node.parent);\n\t\t\t}\n\t\t\t\n\t\t\tpublic void UpdateAfterRotateRight(RedBlackTreeNode<RBNode> node)\n\t\t\t{\n\t\t\t\tUpdateAfterChildrenChange(node);\n\t\t\t\tUpdateAfterChildrenChange(node.parent);\n\t\t\t}\n\t\t}\n\t\t\n\t\treadonly AugmentableRedBlackTree<RBNode, MyHost> tree = new AugmentableRedBlackTree<RBNode, MyHost>(new MyHost());\n\t\t\n\t\tRedBlackTreeNode<RBNode> GetNode(int index)\n\t\t{\n\t\t\tif (index < 0 || index >= tree.Count)\n\t\t\t\tthrow new ArgumentOutOfRangeException(\"index\", index, \"index should be between 0 and \" + (tree.Count-1));\n\t\t\tRedBlackTreeNode<RBNode> node = tree.root;\n\t\t\twhile (true) {\n\t\t\t\tif (node.left != null && index < node.left.val.count) {\n\t\t\t\t\tnode = node.left;\n\t\t\t\t} else {\n\t\t\t\t\tif (node.left != null) {\n\t\t\t\t\t\tindex -= node.left.val.count;\n\t\t\t\t\t}\n\t\t\t\t\tif (index == 0)\n\t\t\t\t\t\treturn node;\n\t\t\t\t\tindex--;\n\t\t\t\t\tnode = node.right;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tstatic int GetIndexFromNode(RedBlackTreeNode<RBNode> node)\n\t\t{\n\t\t\tint index = (node.left != null) ? node.left.val.count : 0;\n\t\t\twhile (node.parent != null) {\n\t\t\t\tif (node == node.parent.right) {\n\t\t\t\t\tif (node.parent.left != null)\n\t\t\t\t\t\tindex += node.parent.left.val.count;\n\t\t\t\t\tindex++;\n\t\t\t\t}\n\t\t\t\tnode = node.parent;\n\t\t\t}\n\t\t\treturn index;\n\t\t}\n\t\t\n\t\tRedBlackTreeNode<RBNode> GetNodeByOffset(int offset)\n\t\t{\n\t\t\tif (offset < 0 || offset > this.TotalLength)\n\t\t\t\tthrow new ArgumentOutOfRangeException(\"offset\", offset, \"offset should be between 0 and \" + this.TotalLength);\n\t\t\tif (offset == this.TotalLength) {\n\t\t\t\tif (tree.root == null)\n\t\t\t\t\tthrow new InvalidOperationException(\"Cannot call GetNodeByOffset while tree is empty.\");\n\t\t\t\treturn tree.root.RightMost;\n\t\t\t}\n\t\t\tRedBlackTreeNode<RBNode> node = tree.root;\n\t\t\twhile (true) {\n\t\t\t\tif (node.left != null && offset < node.left.val.totalLength) {\n\t\t\t\t\tnode = node.left;\n\t\t\t\t} else {\n\t\t\t\t\tif (node.left != null) {\n\t\t\t\t\t\toffset -= node.left.val.totalLength;\n\t\t\t\t\t}\n\t\t\t\t\toffset -= node.val.lineSegment.TotalLength;\n\t\t\t\t\tif (offset < 0)\n\t\t\t\t\t\treturn node;\n\t\t\t\t\tnode = node.right;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tstatic int GetOffsetFromNode(RedBlackTreeNode<RBNode> node)\n\t\t{\n\t\t\tint offset = (node.left != null) ? node.left.val.totalLength : 0;\n\t\t\twhile (node.parent != null) {\n\t\t\t\tif (node == node.parent.right) {\n\t\t\t\t\tif (node.parent.left != null)\n\t\t\t\t\t\toffset += node.parent.left.val.totalLength;\n\t\t\t\t\toffset += node.parent.val.lineSegment.TotalLength;\n\t\t\t\t}\n\t\t\t\tnode = node.parent;\n\t\t\t}\n\t\t\treturn offset;\n\t\t}\n\t\t\n\t\tpublic LineSegment GetByOffset(int offset)\n\t\t{\n\t\t\treturn GetNodeByOffset(offset).val.lineSegment;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Gets the total length of all line segments. Runs in O(1).\n\t\t/// </summary>\n\t\tpublic int TotalLength {\n\t\t\tget {\n\t\t\t\tif (tree.root == null)\n\t\t\t\t\treturn 0;\n\t\t\t\telse\n\t\t\t\t\treturn tree.root.val.totalLength;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Updates the length of a line segment. Runs in O(lg n).\n\t\t/// </summary>\n\t\tpublic void SetSegmentLength(LineSegment segment, int newTotalLength)\n\t\t{\n\t\t\tif (segment == null)\n\t\t\t\tthrow new ArgumentNullException(\"segment\");\n\t\t\tRedBlackTreeNode<RBNode> node = segment.treeEntry.it.node;\n\t\t\tsegment.TotalLength = newTotalLength;\n\t\t\tdefault(MyHost).UpdateAfterChildrenChange(node);\n\t\t\t#if DEBUG\n\t\t\tCheckProperties();\n\t\t\t#endif\n\t\t}\n\t\t\n\t\tpublic void RemoveSegment(LineSegment segment)\n\t\t{\n\t\t\ttree.RemoveAt(segment.treeEntry.it);\n\t\t\t#if DEBUG\n\t\t\tCheckProperties();\n\t\t\t#endif\n\t\t}\n\t\t\n\t\tpublic LineSegment InsertSegmentAfter(LineSegment segment, int length)\n\t\t{\n\t\t\tLineSegment newSegment = new LineSegment();\n\t\t\tnewSegment.TotalLength = length;\n\t\t\tnewSegment.DelimiterLength = segment.DelimiterLength;\n\t\t\t\n\t\t\tnewSegment.treeEntry = InsertAfter(segment.treeEntry.it.node, newSegment);\n\t\t\treturn newSegment;\n\t\t}\n\t\t\n\t\tEnumerator InsertAfter(RedBlackTreeNode<RBNode> node, LineSegment newSegment)\n\t\t{\n\t\t\tRedBlackTreeNode<RBNode> newNode = new RedBlackTreeNode<RBNode>(new RBNode(newSegment));\n\t\t\tif (node.right == null) {\n\t\t\t\ttree.InsertAsRight(node, newNode);\n\t\t\t} else {\n\t\t\t\ttree.InsertAsLeft(node.right.LeftMost, newNode);\n\t\t\t}\n\t\t\t#if DEBUG\n\t\t\tCheckProperties();\n\t\t\t#endif\n\t\t\treturn new Enumerator(new RedBlackTreeIterator<RBNode>(newNode));\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Gets the number of items in the collections. Runs in O(1).\n\t\t/// </summary>\n\t\tpublic int Count {\n\t\t\tget { return tree.Count; }\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Gets or sets an item by index. Runs in O(lg n).\n\t\t/// </summary>\n\t\tpublic LineSegment this[int index] {\n\t\t\tget {\n\t\t\t\treturn GetNode(index).val.lineSegment;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tthrow new NotSupportedException();\n\t\t\t}\n\t\t}\n\t\t\n\t\tbool ICollection<LineSegment>.IsReadOnly {\n\t\t\tget { return true; }\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Gets the index of an item. Runs in O(lg n).\n\t\t/// </summary>\n\t\tpublic int IndexOf(LineSegment item)\n\t\t{\n\t\t\tint index = item.LineNumber;\n\t\t\tif (index < 0 || index >= this.Count)\n\t\t\t\treturn -1;\n\t\t\tif (item != this[index])\n\t\t\t\treturn -1;\n\t\t\treturn index;\n\t\t}\n\t\t\n\t\tvoid IList<LineSegment>.RemoveAt(int index)\n\t\t{\n\t\t\tthrow new NotSupportedException();\n\t\t}\n\t\t\n\t\t#if DEBUG\n\t\t[Conditional(\"DATACONSISTENCYTEST\")]\n\t\tvoid CheckProperties()\n\t\t{\n\t\t\tif (tree.root == null) {\n\t\t\t\tDebug.Assert(this.Count == 0);\n\t\t\t} else {\n\t\t\t\tDebug.Assert(tree.root.val.count == this.Count);\n\t\t\t\tCheckProperties(tree.root);\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid CheckProperties(RedBlackTreeNode<RBNode> node)\n\t\t{\n\t\t\tint count = 1;\n\t\t\tint totalLength = node.val.lineSegment.TotalLength;\n\t\t\tif (node.left != null) {\n\t\t\t\tCheckProperties(node.left);\n\t\t\t\tcount += node.left.val.count;\n\t\t\t\ttotalLength += node.left.val.totalLength;\n\t\t\t}\n\t\t\tif (node.right != null) {\n\t\t\t\tCheckProperties(node.right);\n\t\t\t\tcount += node.right.val.count;\n\t\t\t\ttotalLength += node.right.val.totalLength;\n\t\t\t}\n\t\t\tDebug.Assert(node.val.count == count);\n\t\t\tDebug.Assert(node.val.totalLength == totalLength);\n\t\t}\n\t\t\n\t\tpublic string GetTreeAsString()\n\t\t{\n\t\t\treturn tree.GetTreeAsString();\n\t\t}\n\t\t#endif\n\t\t\n\t\tpublic LineSegmentTree()\n\t\t{\n\t\t\tClear();\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Clears the list. Runs in O(1).\n\t\t/// </summary>\n\t\tpublic void Clear()\n\t\t{\n\t\t\ttree.Clear();\n\t\t\tLineSegment emptySegment = new LineSegment();\n\t\t\temptySegment.TotalLength = 0;\n\t\t\temptySegment.DelimiterLength = 0;\n\t\t\ttree.Add(new RBNode(emptySegment));\n\t\t\temptySegment.treeEntry = GetEnumeratorForIndex(0);\n\t\t\t#if DEBUG\n\t\t\tCheckProperties();\n\t\t\t#endif\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Tests whether an item is in the list. Runs in O(n).\n\t\t/// </summary>\n\t\tpublic bool Contains(LineSegment item)\n\t\t{\n\t\t\treturn IndexOf(item) >= 0;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Copies all elements from the list to the array.\n\t\t/// </summary>\n\t\tpublic void CopyTo(LineSegment[] array, int arrayIndex)\n\t\t{\n\t\t\tif (array == null) throw new ArgumentNullException(\"array\");\n\t\t\tforeach (LineSegment val in this)\n\t\t\t\tarray[arrayIndex++] = val;\n\t\t}\n\t\t\n\t\tIEnumerator<LineSegment> IEnumerable<LineSegment>.GetEnumerator()\n\t\t{\n\t\t\treturn this.GetEnumerator();\n\t\t}\n\t\t\n\t\tSystem.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()\n\t\t{\n\t\t\treturn this.GetEnumerator();\n\t\t}\n\t\t\n\t\tpublic Enumerator GetEnumerator()\n\t\t{\n\t\t\treturn new Enumerator(tree.GetEnumerator());\n\t\t}\n\t\t\n\t\tpublic Enumerator GetEnumeratorForIndex(int index)\n\t\t{\n\t\t\treturn new Enumerator(new RedBlackTreeIterator<RBNode>(GetNode(index)));\n\t\t}\n\t\t\n\t\tpublic Enumerator GetEnumeratorForOffset(int offset)\n\t\t{\n\t\t\treturn new Enumerator(new RedBlackTreeIterator<RBNode>(GetNodeByOffset(offset)));\n\t\t}\n\t\t\n\t\tpublic struct Enumerator : IEnumerator<LineSegment>\n\t\t{\n\t\t\t/// <summary>\n\t\t\t/// An invalid enumerator value. Calling MoveNext on the invalid enumerator\n\t\t\t/// will always return false, accessing Current will throw an exception.\n\t\t\t/// </summary>\n\t\t\tpublic static readonly Enumerator Invalid = default(Enumerator);\n\t\t\t\n\t\t\tinternal RedBlackTreeIterator<RBNode> it;\n\t\t\t\n\t\t\tinternal Enumerator(RedBlackTreeIterator<RBNode> it)\n\t\t\t{\n\t\t\t\tthis.it = it;\n\t\t\t}\n\t\t\t\n\t\t\t/// <summary>\n\t\t\t/// Gets the current value. Runs in O(1).\n\t\t\t/// </summary>\n\t\t\tpublic LineSegment Current {\n\t\t\t\tget {\n\t\t\t\t\treturn it.Current.lineSegment;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tpublic bool IsValid {\n\t\t\t\tget {\n\t\t\t\t\treturn it.IsValid;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t/// <summary>\n\t\t\t/// Gets the index of the current value. Runs in O(lg n).\n\t\t\t/// </summary>\n\t\t\tpublic int CurrentIndex {\n\t\t\t\tget {\n\t\t\t\t\tif (it.node == null)\n\t\t\t\t\t\tthrow new InvalidOperationException();\n\t\t\t\t\treturn GetIndexFromNode(it.node);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t/// <summary>\n\t\t\t/// Gets the offset of the current value. Runs in O(lg n).\n\t\t\t/// </summary>\n\t\t\tpublic int CurrentOffset {\n\t\t\t\tget {\n\t\t\t\t\tif (it.node == null)\n\t\t\t\t\t\tthrow new InvalidOperationException();\n\t\t\t\t\treturn GetOffsetFromNode(it.node);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tobject System.Collections.IEnumerator.Current {\n\t\t\t\tget {\n\t\t\t\t\treturn it.Current.lineSegment;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tpublic void Dispose()\n\t\t\t{\n\t\t\t}\n\t\t\t\n\t\t\t/// <summary>\n\t\t\t/// Moves to the next index. Runs in O(lg n), but for k calls, the combined time is only O(k+lg n).\n\t\t\t/// </summary>\n\t\t\tpublic bool MoveNext()\n\t\t\t{\n\t\t\t\treturn it.MoveNext();\n\t\t\t}\n\t\t\t\n\t\t\t/// <summary>\n\t\t\t/// Moves to the previous index. Runs in O(lg n), but for k calls, the combined time is only O(k+lg n).\n\t\t\t/// </summary>\n\t\t\tpublic bool MoveBack()\n\t\t\t{\n\t\t\t\treturn it.MoveBack();\n\t\t\t}\n\t\t\t\n\t\t\tvoid System.Collections.IEnumerator.Reset()\n\t\t\t{\n\t\t\t\tthrow new NotSupportedException();\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid IList<LineSegment>.Insert(int index, LineSegment item)\n\t\t{\n\t\t\tthrow new NotSupportedException();\n\t\t}\n\t\t\n\t\tvoid ICollection<LineSegment>.Add(LineSegment item)\n\t\t{\n\t\t\tthrow new NotSupportedException();\n\t\t}\n\t\t\n\t\tbool ICollection<LineSegment>.Remove(LineSegment item)\n\t\t{\n\t\t\tthrow new NotSupportedException();\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/MarkerStrategy/MarkerStrategy.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 2659 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\nusing System.Drawing;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\t/// <summary>\n\t/// Manages the list of markers and provides ways to retrieve markers for specific positions.\n\t/// </summary>\n\tpublic sealed class MarkerStrategy\n\t{\n\t\tList<TextMarker> textMarker = new List<TextMarker>();\n\t\tIDocument document;\n\t\t\n\t\tpublic IDocument Document {\n\t\t\tget {\n\t\t\t\treturn document;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic IEnumerable<TextMarker> TextMarker {\n\t\t\tget {\n\t\t\t\treturn textMarker.AsReadOnly();\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic void AddMarker(TextMarker item)\n\t\t{\n\t\t\tmarkersTable.Clear();\n\t\t\ttextMarker.Add(item);\n\t\t}\n\t\t\n\t\tpublic void InsertMarker(int index, TextMarker item)\n\t\t{\n\t\t\tmarkersTable.Clear();\n\t\t\ttextMarker.Insert(index, item);\n\t\t}\n\t\t\n\t\tpublic void RemoveMarker(TextMarker item)\n\t\t{\n\t\t\tmarkersTable.Clear();\n\t\t\ttextMarker.Remove(item);\n\t\t}\n\t\t\n\t\tpublic void RemoveAll(Predicate<TextMarker> match)\n\t\t{\n\t\t\tmarkersTable.Clear();\n\t\t\ttextMarker.RemoveAll(match);\n\t\t}\n\t\t\n\t\tpublic MarkerStrategy(IDocument document)\n\t\t{\n\t\t\tthis.document = document;\n\t\t\tdocument.DocumentChanged += new DocumentEventHandler(DocumentChanged);\n\t\t}\n\t\t\n\t\tDictionary<int, List<TextMarker>> markersTable = new Dictionary<int, List<TextMarker>>();\n\t\t\n\t\tpublic List<TextMarker> GetMarkers(int offset)\n\t\t{\n\t\t\tif (!markersTable.ContainsKey(offset)) {\n\t\t\t\tList<TextMarker> markers = new List<TextMarker>();\n\t\t\t\tfor (int i = 0; i < textMarker.Count; ++i) {\n\t\t\t\t\tTextMarker marker = (TextMarker)textMarker[i];\n\t\t\t\t\tif (marker.Offset <= offset && offset <= marker.EndOffset) {\n\t\t\t\t\t\tmarkers.Add(marker);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tmarkersTable[offset] = markers;\n\t\t\t}\n\t\t\treturn markersTable[offset];\n\t\t}\n\t\t\n\t\tpublic List<TextMarker> GetMarkers(int offset, int length)\n\t\t{\n\t\t\tint endOffset = offset + length - 1;\n\t\t\tList<TextMarker> markers = new List<TextMarker>();\n\t\t\tfor (int i = 0; i < textMarker.Count; ++i) {\n\t\t\t\tTextMarker marker = (TextMarker)textMarker[i];\n\t\t\t\tif (// start in marker region\n\t\t\t\t    marker.Offset <= offset && offset <= marker.EndOffset ||\n\t\t\t\t    // end in marker region\n\t\t\t\t    marker.Offset <= endOffset && endOffset <= marker.EndOffset ||\n\t\t\t\t    // marker start in region\n\t\t\t\t    offset <= marker.Offset && marker.Offset <= endOffset ||\n\t\t\t\t    // marker end in region\n\t\t\t\t    offset <= marker.EndOffset && marker.EndOffset <= endOffset\n\t\t\t\t   )\n\t\t\t\t{\n\t\t\t\t\tmarkers.Add(marker);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn markers;\n\t\t}\n\t\t\n\t\tpublic List<TextMarker> GetMarkers(TextLocation position)\n\t\t{\n\t\t\tif (position.Y >= document.TotalNumberOfLines || position.Y < 0) {\n\t\t\t\treturn new List<TextMarker>();\n\t\t\t}\n\t\t\tLineSegment segment = document.GetLineSegment(position.Y);\n\t\t\treturn GetMarkers(segment.Offset + position.X);\n\t\t}\n\t\t\n\t\tvoid DocumentChanged(object sender, DocumentEventArgs e)\n\t\t{\n\t\t\t// reset markers table\n\t\t\tmarkersTable.Clear();\n\t\t\tdocument.UpdateSegmentListOnDocumentChange(textMarker, e);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/MarkerStrategy/TextMarker.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Daniel Grunwald\" email=\"daniel@danielgrunwald.de\"/>\n//     <version>$Revision: 3206 $</version>\n// </file>\n\nusing System;\nusing System.Drawing;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\tpublic enum TextMarkerType\n\t{\n\t\tInvisible,\n\t\tSolidBlock,\n\t\tUnderlined,\n\t\tWaveLine\n\t}\n\t\n\t/// <summary>\n\t/// Marks a part of a document.\n\t/// </summary>\n\tpublic class TextMarker : AbstractSegment\n\t{\n\t\tTextMarkerType textMarkerType;\n\t\tColor          color;\n\t\tColor          foreColor;\n\t\tstring         toolTip = null;\n\t\tbool           overrideForeColor = false;\n\t\t\n\t\tpublic TextMarkerType TextMarkerType {\n\t\t\tget {\n\t\t\t\treturn textMarkerType;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic Color Color {\n\t\t\tget {\n\t\t\t\treturn color;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic Color ForeColor {\n\t\t\tget {\n\t\t\t\treturn foreColor;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic bool OverrideForeColor {\n\t\t\tget {\n\t\t\t\treturn overrideForeColor;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Marks the text segment as read-only.\n\t\t/// </summary>\n\t\tpublic bool IsReadOnly { get; set; }\n\t\t\n\t\tpublic string ToolTip {\n\t\t\tget {\n\t\t\t\treturn toolTip;\n\t\t\t}\n\t\t\tset {\n\t\t\t\ttoolTip = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Gets the last offset that is inside the marker region.\n\t\t/// </summary>\n\t\tpublic int EndOffset {\n\t\t\tget {\n\t\t\t\treturn Offset + Length - 1;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic TextMarker(int offset, int length, TextMarkerType textMarkerType) : this(offset, length, textMarkerType, Color.Red)\n\t\t{\n\t\t}\n\t\t\n\t\tpublic TextMarker(int offset, int length, TextMarkerType textMarkerType, Color color)\n\t\t{\n\t\t\tif (length < 1) length = 1;\n\t\t\tthis.offset          = offset;\n\t\t\tthis.length          = length;\n\t\t\tthis.textMarkerType  = textMarkerType;\n\t\t\tthis.color           = color;\n\t\t}\n\t\t\n\t\tpublic TextMarker(int offset, int length, TextMarkerType textMarkerType, Color color, Color foreColor)\n\t\t{\n\t\t\tif (length < 1) length = 1;\n\t\t\tthis.offset          = offset;\n\t\t\tthis.length          = length;\n\t\t\tthis.textMarkerType  = textMarkerType;\n\t\t\tthis.color           = color;\n\t\t\tthis.foreColor       = foreColor;\n\t\t\tthis.overrideForeColor = true;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/Selection/ColumnRange.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 1965 $</version>\n// </file>\n\nusing System;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\tpublic class ColumnRange \n\t{\n\t\tpublic static readonly ColumnRange NoColumn    = new ColumnRange(-2, -2);\n\t\tpublic static readonly ColumnRange WholeColumn = new ColumnRange(-1, -1);\n\t\t\n\t\tint startColumn;\n\t\tint endColumn;\n\t\t\n\t\tpublic int StartColumn {\n\t\t\tget {\n\t\t\t\treturn startColumn;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tstartColumn = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int EndColumn {\n\t\t\tget {\n\t\t\t\treturn endColumn;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tendColumn = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic ColumnRange(int startColumn, int endColumn)\n\t\t{\n\t\t\tthis.startColumn = startColumn;\n\t\t\tthis.endColumn = endColumn;\n\t\t\t\n\t\t}\n\t\t\n\t\tpublic override int GetHashCode()\n\t\t{\n\t\t\treturn startColumn + (endColumn << 16);\n\t\t}\n\t\t\n\t\tpublic override bool Equals(object obj)\n\t\t{\n\t\t\tif (obj is ColumnRange) {\n\t\t\t\treturn ((ColumnRange)obj).startColumn == startColumn &&\n\t\t\t\t       ((ColumnRange)obj).endColumn == endColumn;\n\t\t\t\t\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\tpublic override string ToString()\n\t\t{\n\t\t\treturn String.Format(\"[ColumnRange: StartColumn={0}, EndColumn={1}]\", startColumn, endColumn);\n\t\t}\n\t\t\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/Selection/DefaultSelection.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 2679 $</version>\n// </file>\n\nusing System;\nusing System.Diagnostics;\nusing System.Drawing;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\t/// <summary>\n\t/// Default implementation of the <see cref=\"ICSharpCode.TextEditor.Document.ISelection\"/> interface.\n\t/// </summary>\n\tpublic class DefaultSelection : ISelection\n\t{\n\t\tIDocument document;\n\t\tbool      isRectangularSelection;\n\t\tTextLocation     startPosition;\n\t\tTextLocation     endPosition;\n\t\t\n\t\tpublic TextLocation StartPosition {\n\t\t\tget {\n\t\t\t\treturn startPosition;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tDefaultDocument.ValidatePosition(document, value);\n\t\t\t\tstartPosition = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic TextLocation EndPosition {\n\t\t\tget {\n\t\t\t\treturn endPosition;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tDefaultDocument.ValidatePosition(document, value);\n\t\t\t\tendPosition = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int Offset {\n\t\t\tget {\n\t\t\t\treturn document.PositionToOffset(startPosition);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int EndOffset {\n\t\t\tget {\n\t\t\t\treturn document.PositionToOffset(endPosition);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int Length {\n\t\t\tget {\n\t\t\t\treturn EndOffset - Offset;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// Returns true, if the selection is empty\n\t\t/// </value>\n\t\tpublic bool IsEmpty {\n\t\t\tget {\n\t\t\t\treturn startPosition == endPosition;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// Returns true, if the selection is rectangular\n\t\t/// </value>\n\t\t// TODO : make this unused property used.\n\t\tpublic bool IsRectangularSelection {\n\t\t\tget {\n\t\t\t\treturn isRectangularSelection;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tisRectangularSelection = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// The text which is selected by this selection.\n\t\t/// </value>\n\t\tpublic string SelectedText {\n\t\t\tget {\n\t\t\t\tif (document != null) {\n\t\t\t\t\tif (Length < 0) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\treturn document.GetText(Offset, Length);\n\t\t\t\t}\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Creates a new instance of <see cref=\"DefaultSelection\"/>\n\t\t/// </summary>\n\t\tpublic DefaultSelection(IDocument document, TextLocation startPosition, TextLocation endPosition)\n\t\t{\n\t\t\tDefaultDocument.ValidatePosition(document, startPosition);\n\t\t\tDefaultDocument.ValidatePosition(document, endPosition);\n\t\t\tDebug.Assert(startPosition <= endPosition);\n\t\t\tthis.document      = document;\n\t\t\tthis.startPosition = startPosition;\n\t\t\tthis.endPosition   = endPosition;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Converts a <see cref=\"DefaultSelection\"/> instance to string (for debug purposes)\n\t\t/// </summary>\n\t\tpublic override string ToString()\n\t\t{\n\t\t\treturn String.Format(\"[DefaultSelection : StartPosition={0}, EndPosition={1}]\", startPosition, endPosition);\n\t\t}\n\t\tpublic bool ContainsPosition(TextLocation position)\n\t\t{\n\t\t\tif (this.IsEmpty)\n\t\t\t\treturn false;\n\t\t\treturn startPosition.Y < position.Y && position.Y  < endPosition.Y ||\n\t\t\t\tstartPosition.Y == position.Y && startPosition.X <= position.X && (startPosition.Y != endPosition.Y || position.X <= endPosition.X) ||\n\t\t\t\tendPosition.Y == position.Y && startPosition.Y != endPosition.Y && position.X <= endPosition.X;\n\t\t}\n\t\t\n\t\tpublic bool ContainsOffset(int offset)\n\t\t{\n\t\t\treturn Offset <= offset && offset <= EndOffset;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/Selection/ISelection.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 2659 $</version>\n// </file>\n\nusing System.Drawing;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\t/// <summary>\n\t/// An interface representing a portion of the current selection.\n\t/// </summary>\n\tpublic interface ISelection\n\t{\n\t\tTextLocation StartPosition {\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\tTextLocation EndPosition {\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\tint Offset {\n\t\t\tget;\n\t\t}\n\t\t\n\t\tint EndOffset {\n\t\t\tget;\n\t\t}\n\t\t\n\t\tint Length {\n\t\t\tget;\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// Returns true, if the selection is rectangular\n\t\t/// </value>\n\t\tbool IsRectangularSelection {\n\t\t\tget;\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// Returns true, if the selection is empty\n\t\t/// </value>\n\t\tbool IsEmpty {\n\t\t\tget;\n\t\t}\n\n\t\t/// <value>\n\t\t/// The text which is selected by this selection.\n\t\t/// </value>\n\t\tstring SelectedText {\n\t\t\tget;\n\t\t}\n\t\t\n\t\tbool ContainsOffset(int offset);\n\t\t\n\t\tbool ContainsPosition(TextLocation position);\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/Selection/SelectionManager.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 3205 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\nusing System.Drawing;\nusing System.Text;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\t/// <summary>\n\t/// This class manages the selections in a document.\n\t/// </summary>\n\tpublic class SelectionManager : IDisposable\n\t{\n\t\tTextLocation selectionStart;\n\t\t\n\t\tinternal TextLocation SelectionStart {\n\t\t\tget { return selectionStart; }\n\t\t\tset {\n\t\t\t\tDefaultDocument.ValidatePosition(document, value);\n\t\t\t\tselectionStart = value;\n\t\t\t}\n\t\t}\n\t\tIDocument document;\n\t\tTextArea textArea;\n\t\tinternal SelectFrom selectFrom = new SelectFrom();\n\n\t\tinternal List<ISelection> selectionCollection = new List<ISelection>();\n\t\t\n\t\t/// <value>\n\t\t/// A collection containing all selections.\n\t\t/// </value>\n\t\tpublic List<ISelection> SelectionCollection {\n\t\t\tget {\n\t\t\t\treturn selectionCollection;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// true if the <see cref=\"SelectionCollection\"/> is not empty, false otherwise.\n\t\t/// </value>\n\t\tpublic bool HasSomethingSelected {\n\t\t\tget {\n\t\t\t\treturn selectionCollection.Count > 0;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic bool SelectionIsReadonly {\n\t\t\tget {\n\t\t\t\tif (document.ReadOnly)\n\t\t\t\t\treturn true;\n\t\t\t\tforeach (ISelection sel in selectionCollection) {\n\t\t\t\t\tif (SelectionIsReadOnly(document, sel))\n\t\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\t\n\t\tinternal static bool SelectionIsReadOnly(IDocument document, ISelection sel)\n\t\t{\n\t\t\tif (document.TextEditorProperties.SupportReadOnlySegments)\n\t\t\t\treturn document.MarkerStrategy.GetMarkers(sel.Offset, sel.Length).Exists(m=>m.IsReadOnly);\n\t\t\telse\n\t\t\t\treturn false;\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// The text that is currently selected.\n\t\t/// </value>\n\t\tpublic string SelectedText {\n\t\t\tget {\n\t\t\t\tStringBuilder builder = new StringBuilder();\n\t\t\t\t\n//\t\t\t\tPriorityQueue queue = new PriorityQueue();\n\t\t\t\t\n\t\t\t\tforeach (ISelection s in selectionCollection) {\n\t\t\t\t\tbuilder.Append(s.SelectedText);\n//\t\t\t\t\tqueue.Insert(-s.Offset, s);\n\t\t\t\t}\n\t\t\t\t\n//\t\t\t\twhile (queue.Count > 0) {\n//\t\t\t\t\tISelection s = ((ISelection)queue.Remove());\n//\t\t\t\t\tbuilder.Append(s.SelectedText);\n//\t\t\t\t}\n\t\t\t\t\n\t\t\t\treturn builder.ToString();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Creates a new instance of <see cref=\"SelectionManager\"/>\n\t\t/// </summary>\n\t\tpublic SelectionManager(IDocument document)\n\t\t{\n\t\t\tthis.document = document;\n\t\t\tdocument.DocumentChanged += new DocumentEventHandler(DocumentChanged);\n\t\t}\n\n\t\t/// <summary>\n\t\t/// Creates a new instance of <see cref=\"SelectionManager\"/>\n\t\t/// </summary>\n\t\tpublic SelectionManager(IDocument document, TextArea textArea)\n\t\t{\n\t\t\tthis.document = document;\n\t\t\tthis.textArea = textArea;\n\t\t\tdocument.DocumentChanged += new DocumentEventHandler(DocumentChanged);\n\t\t}\n\n\t\tpublic void Dispose()\n\t\t{\n\t\t\tif (this.document != null) {\n\t\t\t\tdocument.DocumentChanged -= new DocumentEventHandler(DocumentChanged);\n\t\t\t\tthis.document = null;\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid DocumentChanged(object sender, DocumentEventArgs e)\n\t\t{\n\t\t\tif (e.Text == null) {\n\t\t\t\tRemove(e.Offset, e.Length);\n\t\t\t} else {\n\t\t\t\tif (e.Length < 0) {\n\t\t\t\t\tInsert(e.Offset, e.Text);\n\t\t\t\t} else {\n\t\t\t\t\tReplace(e.Offset, e.Length, e.Text);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// Clears the selection and sets a new selection\n\t\t/// using the given <see cref=\"ISelection\"/> object.\n\t\t/// </remarks>\n\t\tpublic void SetSelection(ISelection selection)\n\t\t{\n//\t\t\tautoClearSelection = false;\n\t\t\tif (selection != null) {\n\t\t\t\tif (SelectionCollection.Count == 1 &&\n\t\t\t\t    selection.StartPosition == SelectionCollection[0].StartPosition &&\n\t\t\t\t    selection.EndPosition == SelectionCollection[0].EndPosition ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tClearWithoutUpdate();\n\t\t\t\tselectionCollection.Add(selection);\n\t\t\t\tdocument.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.LinesBetween, selection.StartPosition.Y, selection.EndPosition.Y));\n\t\t\t\tdocument.CommitUpdate();\n\t\t\t\tOnSelectionChanged(EventArgs.Empty);\n\t\t\t} else {\n\t\t\t\tClearSelection();\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic void SetSelection(TextLocation startPosition, TextLocation endPosition)\n\t\t{\n\t\t\tSetSelection(new DefaultSelection(document, startPosition, endPosition));\n\t\t}\n\t\t\n\t\tpublic bool GreaterEqPos(TextLocation p1, TextLocation p2)\n\t\t{\n\t\t\treturn p1.Y > p2.Y || p1.Y == p2.Y && p1.X >= p2.X;\n\t\t}\n\t\t\n\t\tpublic void ExtendSelection(TextLocation oldPosition, TextLocation newPosition)\n\t\t{\n\t\t\t// where oldposition is where the cursor was,\n\t\t\t// and newposition is where it has ended up from a click (both zero based)\n\n\t\t\tif (oldPosition == newPosition)\n\t\t\t{\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tTextLocation min;\n\t\t\tTextLocation max;\n\t\t\tint oldnewX = newPosition.X;\n\t\t\tbool  oldIsGreater = GreaterEqPos(oldPosition, newPosition);\n\t\t\tif (oldIsGreater) {\n\t\t\t\tmin = newPosition;\n\t\t\t\tmax = oldPosition;\n\t\t\t} else {\n\t\t\t\tmin = oldPosition;\n\t\t\t\tmax = newPosition;\n\t\t\t}\n\n\t\t\tif (min == max) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!HasSomethingSelected)\n\t\t\t{\n\t\t\t\tSetSelection(new DefaultSelection(document, min, max));\n\t\t\t\t// initialise selectFrom for a cursor selection\n\t\t\t\tif (selectFrom.where == WhereFrom.None)\n\t\t\t\t\tSelectionStart = oldPosition; //textArea.Caret.Position;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tISelection selection = this.selectionCollection[0];\n\n\t\t\tif (min == max) {\n\t\t\t\t//selection.StartPosition = newPosition;\n\t\t\t\treturn;\n\t\t\t} else {\n\t\t\t\t// changed selection via gutter\n\t\t\t\tif (selectFrom.where == WhereFrom.Gutter)\n\t\t\t\t{\n\t\t\t\t\t// selection new position is always at the left edge for gutter selections\n\t\t\t\t\tnewPosition.X = 0;\n\t\t\t\t}\n\n\t\t\t\tif (GreaterEqPos(newPosition, SelectionStart)) // selecting forward\n\t\t\t\t{\n\t\t\t\t\tselection.StartPosition = SelectionStart;\n\t\t\t\t\t// this handles last line selection\n\t\t\t\t\tif (selectFrom.where == WhereFrom.Gutter ) //&& newPosition.Y != oldPosition.Y)\n\t\t\t\t\t\tselection.EndPosition = new TextLocation(textArea.Caret.Column, textArea.Caret.Line);\n\t\t\t\t\telse {\n\t\t\t\t\t\tnewPosition.X = oldnewX;\n\t\t\t\t\t\tselection.EndPosition = newPosition;\n\t\t\t\t\t}\n\t\t\t\t} else { // selecting back\n\t\t\t\t\tif (selectFrom.where == WhereFrom.Gutter && selectFrom.first == WhereFrom.Gutter)\n\t\t\t\t\t{ // gutter selection\n\t\t\t\t\t\tselection.EndPosition = NextValidPosition(SelectionStart.Y);\n\t\t\t\t\t} else { // internal text selection\n\t\t\t\t\t\tselection.EndPosition = SelectionStart; //selection.StartPosition;\n\t\t\t\t\t}\n\t\t\t\t\tselection.StartPosition = newPosition;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tdocument.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.LinesBetween, min.Y, max.Y));\n\t\t\tdocument.CommitUpdate();\n\t\t\tOnSelectionChanged(EventArgs.Empty);\n\t\t}\n\n\t\t// retrieve the next available line\n\t\t// - checks that there are more lines available after the current one\n\t\t// - if there are then the next line is returned\n\t\t// - if there are NOT then the last position on the given line is returned\n\t\tpublic TextLocation NextValidPosition(int line)\n\t\t{\n\t\t\tif (line < document.TotalNumberOfLines - 1)\n\t\t\t\treturn new TextLocation(0, line + 1);\n\t\t\telse\n\t\t\t\treturn new TextLocation(document.GetLineSegment(document.TotalNumberOfLines - 1).Length + 1, line);\n\t\t}\n\n\t\tvoid ClearWithoutUpdate()\n\t\t{\n\t\t\twhile (selectionCollection.Count > 0) {\n\t\t\t\tISelection selection = selectionCollection[selectionCollection.Count - 1];\n\t\t\t\tselectionCollection.RemoveAt(selectionCollection.Count - 1);\n\t\t\t\tdocument.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.LinesBetween, selection.StartPosition.Y, selection.EndPosition.Y));\n\t\t\t\tOnSelectionChanged(EventArgs.Empty);\n\t\t\t}\n\t\t}\n\t\t/// <remarks>\n\t\t/// Clears the selection.\n\t\t/// </remarks>\n\t\tpublic void ClearSelection()\n\t\t{\n\t\t\tPoint mousepos;\n\t\t\tmousepos = textArea.mousepos;\n\t\t\t// this is the most logical place to reset selection starting\n\t\t\t// positions because it is always called before a new selection\n\t\t\tselectFrom.first = selectFrom.where;\n\t\t\tTextLocation newSelectionStart = textArea.TextView.GetLogicalPosition(mousepos.X - textArea.TextView.DrawingPosition.X, mousepos.Y - textArea.TextView.DrawingPosition.Y);\n\t\t\tif (selectFrom.where == WhereFrom.Gutter) {\n\t\t\t\tnewSelectionStart.X = 0;\n//\t\t\t\tselectionStart.Y = -1;\n\t\t\t}\n\t\t\tif (newSelectionStart.Line >= document.TotalNumberOfLines) {\n\t\t\t\tnewSelectionStart.Line = document.TotalNumberOfLines-1;\n\t\t\t\tnewSelectionStart.Column = document.GetLineSegment(document.TotalNumberOfLines-1).Length;\n\t\t\t}\n\t\t\tthis.SelectionStart = newSelectionStart;\n\n\t\t\tClearWithoutUpdate();\n\t\t\tdocument.CommitUpdate();\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// Removes the selected text from the buffer and clears\n\t\t/// the selection.\n\t\t/// </remarks>\n\t\tpublic void RemoveSelectedText()\n\t\t{\n\t\t\tif (SelectionIsReadonly) {\n\t\t\t\tClearSelection();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tList<int> lines = new List<int>();\n\t\t\tint offset = -1;\n\t\t\tbool oneLine = true;\n//\t\t\tPriorityQueue queue = new PriorityQueue();\n\t\t\tforeach (ISelection s in selectionCollection) {\n//\t\t\t\tISelection s = ((ISelection)queue.Remove());\n\t\t\t\tif (oneLine) {\n\t\t\t\t\tint lineBegin = s.StartPosition.Y;\n\t\t\t\t\tif (lineBegin != s.EndPosition.Y) {\n\t\t\t\t\t\toneLine = false;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlines.Add(lineBegin);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\toffset = s.Offset;\n\t\t\t\tdocument.Remove(s.Offset, s.Length);\n\n//\t\t\t\tqueue.Insert(-s.Offset, s);\n\t\t\t}\n\t\t\tClearSelection();\n\t\t\tif (offset >= 0) {\n\t\t\t\t//             TODO:\n//\t\t\t\tdocument.Caret.Offset = offset;\n\t\t\t}\n\t\t\tif (offset != -1) {\n\t\t\t\tif (oneLine) {\n\t\t\t\t\tforeach (int i in lines) {\n\t\t\t\t\t\tdocument.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, i));\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tdocument.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea));\n\t\t\t\t}\n\t\t\t\tdocument.CommitUpdate();\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\tbool SelectionsOverlap(ISelection s1, ISelection s2)\n\t\t{\n\t\t\treturn (s1.Offset <= s2.Offset && s2.Offset <= s1.Offset + s1.Length)                         ||\n\t\t\t\t(s1.Offset <= s2.Offset + s2.Length && s2.Offset + s2.Length <= s1.Offset + s1.Length) ||\n\t\t\t\t(s1.Offset >= s2.Offset && s1.Offset + s1.Length <= s2.Offset + s2.Length);\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// Returns true if the given offset points to a section which is\n\t\t/// selected.\n\t\t/// </remarks>\n\t\tpublic bool IsSelected(int offset)\n\t\t{\n\t\t\treturn GetSelectionAt(offset) != null;\n\t\t}\n\n\t\t/// <remarks>\n\t\t/// Returns a <see cref=\"ISelection\"/> object giving the selection in which\n\t\t/// the offset points to.\n\t\t/// </remarks>\n\t\t/// <returns>\n\t\t/// <code>null</code> if the offset doesn't point to a selection\n\t\t/// </returns>\n\t\tpublic ISelection GetSelectionAt(int offset)\n\t\t{\n\t\t\tforeach (ISelection s in selectionCollection) {\n\t\t\t\tif (s.ContainsOffset(offset)) {\n\t\t\t\t\treturn s;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// Used internally, do not call.\n\t\t/// </remarks>\n\t\tinternal void Insert(int offset, string text)\n\t\t{\n//\t\t\tforeach (ISelection selection in SelectionCollection) {\n//\t\t\t\tif (selection.Offset > offset) {\n//\t\t\t\t\tselection.Offset += text.Length;\n//\t\t\t\t} else if (selection.Offset + selection.Length > offset) {\n//\t\t\t\t\tselection.Length += text.Length;\n//\t\t\t\t}\n//\t\t\t}\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// Used internally, do not call.\n\t\t/// </remarks>\n\t\tinternal void Remove(int offset, int length)\n\t\t{\n//\t\t\tforeach (ISelection selection in selectionCollection) {\n//\t\t\t\tif (selection.Offset > offset) {\n//\t\t\t\t\tselection.Offset -= length;\n//\t\t\t\t} else if (selection.Offset + selection.Length > offset) {\n//\t\t\t\t\tselection.Length -= length;\n//\t\t\t\t}\n//\t\t\t}\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// Used internally, do not call.\n\t\t/// </remarks>\n\t\tinternal void Replace(int offset, int length, string text)\n\t\t{\n//\t\t\tforeach (ISelection selection in selectionCollection) {\n//\t\t\t\tif (selection.Offset > offset) {\n//\t\t\t\t\tselection.Offset = selection.Offset - length + text.Length;\n//\t\t\t\t} else if (selection.Offset + selection.Length > offset) {\n//\t\t\t\t\tselection.Length = selection.Length - length + text.Length;\n//\t\t\t\t}\n//\t\t\t}\n\t\t}\n\t\t\n\t\tpublic ColumnRange GetSelectionAtLine(int lineNumber)\n\t\t{\n\t\t\tforeach (ISelection selection in selectionCollection) {\n\t\t\t\tint startLine = selection.StartPosition.Y;\n\t\t\t\tint endLine   = selection.EndPosition.Y;\n\t\t\t\tif (startLine < lineNumber && lineNumber < endLine) {\n\t\t\t\t\treturn ColumnRange.WholeColumn;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (startLine == lineNumber) {\n\t\t\t\t\tLineSegment line = document.GetLineSegment(startLine);\n\t\t\t\t\tint startColumn = selection.StartPosition.X;\n\t\t\t\t\tint endColumn   = endLine == lineNumber ? selection.EndPosition.X : line.Length + 1;\n\t\t\t\t\treturn new ColumnRange(startColumn, endColumn);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (endLine == lineNumber) {\n\t\t\t\t\tint endColumn   = selection.EndPosition.X;\n\t\t\t\t\treturn new ColumnRange(0, endColumn);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\treturn ColumnRange.NoColumn;\n\t\t}\n\t\t\n\t\tpublic void FireSelectionChanged()\n\t\t{\n\t\t\tOnSelectionChanged(EventArgs.Empty);\n\t\t}\n\t\tprotected virtual void OnSelectionChanged(EventArgs e)\n\t\t{\n\t\t\tif (SelectionChanged != null) {\n\t\t\t\tSelectionChanged(this, e);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic event EventHandler SelectionChanged;\n\t}\n\n\t// selection initiated from...\n\tinternal class SelectFrom {\n\t\tpublic int where = WhereFrom.None; // last selection initiator\n\t\tpublic int first = WhereFrom.None; // first selection initiator\n\n\t\tpublic SelectFrom()\n\t\t{\n\t\t}\n\t}\n\n\t// selection initiated from type...\n\tinternal class WhereFrom {\n\t\tpublic const int None = 0;\n\t\tpublic const int Gutter = 1;\n\t\tpublic const int TArea = 2;\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/TextAnchor.cs",
    "content": "// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Daniel Grunwald\" email=\"daniel@danielgrunwald.de\"/>\n//     <version>$Revision: 3272 $</version>\n// </file>\n\nusing System;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\tpublic enum AnchorMovementType\n\t{\n\t\t/// <summary>\n\t\t/// Behaves like a start marker - when text is inserted at the anchor position, the anchor will stay\n\t\t/// before the inserted text.\n\t\t/// </summary>\n\t\tBeforeInsertion,\n\t\t/// <summary>\n\t\t/// Behave like an end marker - when text is insered at the anchor position, the anchor will move\n\t\t/// after the inserted text.\n\t\t/// </summary>\n\t\tAfterInsertion\n\t}\n\t\n\t/// <summary>\n\t/// An anchor that can be put into a document and moves around when the document is changed.\n\t/// </summary>\n\tpublic sealed class TextAnchor\n\t{\n\t\tstatic Exception AnchorDeletedError()\n\t\t{\n\t\t\treturn new InvalidOperationException(\"The text containing the anchor was deleted\");\n\t\t}\n\t\t\n\t\tLineSegment lineSegment;\n\t\tint columnNumber;\n\t\t\n\t\tpublic LineSegment Line {\n\t\t\tget {\n\t\t\t\tif (lineSegment == null) throw AnchorDeletedError();\n\t\t\t\treturn lineSegment;\n\t\t\t}\n\t\t\tinternal set {\n\t\t\t\tlineSegment = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic bool IsDeleted {\n\t\t\tget {\n\t\t\t\treturn lineSegment == null;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int LineNumber {\n\t\t\tget {\n\t\t\t\treturn this.Line.LineNumber;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int ColumnNumber {\n\t\t\tget {\n\t\t\t\tif (lineSegment == null) throw AnchorDeletedError();\n\t\t\t\treturn columnNumber;\n\t\t\t}\n\t\t\tinternal set {\n\t\t\t\tcolumnNumber = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic TextLocation Location {\n\t\t\tget {\n\t\t\t\treturn new TextLocation(this.ColumnNumber, this.LineNumber);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int Offset {\n\t\t\tget {\n\t\t\t\treturn this.Line.Offset + columnNumber;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Controls how the anchor moves.\n\t\t/// </summary>\n\t\tpublic AnchorMovementType MovementType { get; set; }\n\t\t\n\t\tpublic event EventHandler Deleted;\n\t\t\n\t\tinternal void Delete(ref DeferredEventList deferredEventList)\n\t\t{\n\t\t\t// we cannot fire an event here because this method is called while the LineManager adjusts the\n\t\t\t// lineCollection, so an event handler could see inconsistent state\n\t\t\tlineSegment = null;\n\t\t\tdeferredEventList.AddDeletedAnchor(this);\n\t\t}\n\t\t\n\t\tinternal void RaiseDeleted()\n\t\t{\n\t\t\tif (Deleted != null)\n\t\t\t\tDeleted(this, EventArgs.Empty);\n\t\t}\n\t\t\n\t\tinternal TextAnchor(LineSegment lineSegment, int columnNumber)\n\t\t{\n\t\t\tthis.lineSegment = lineSegment;\n\t\t\tthis.columnNumber = columnNumber;\n\t\t}\n\t\t\n\t\tpublic override string ToString()\n\t\t{\n\t\t\tif (this.IsDeleted)\n\t\t\t\treturn \"[TextAnchor (deleted)]\";\n\t\t\telse\n\t\t\t\treturn \"[TextAnchor \" + this.Location.ToString() + \"]\";\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/TextBufferStrategy/GapTextBufferStrategy.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 2667 $</version>\n// </file>\n\nusing System;\nusing System.Text;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\tpublic class GapTextBufferStrategy : ITextBufferStrategy\n\t{\n\t\t#if DEBUG\n\t\tint creatorThread = System.Threading.Thread.CurrentThread.ManagedThreadId;\n\t\t\n\t\tvoid CheckThread()\n\t\t{\n\t\t\tif (System.Threading.Thread.CurrentThread.ManagedThreadId != creatorThread)\n\t\t\t\tthrow new InvalidOperationException(\"GapTextBufferStategy is not thread-safe!\");\n\t\t}\n\t\t#endif\n\t\t\n\t\tchar[] buffer = new char[0];\n\t\t\n\t\tint gapBeginOffset = 0;\n\t\tint gapEndOffset = 0;\n\t\tint gapLength = 0; // gapLength == gapEndOffset - gapBeginOffset\n\t\t\n\t\tconst int minGapLength = 128;\n\t\tconst int maxGapLength = 2048;\n\t\t\n\t\tpublic int Length {\n\t\t\tget {\n\t\t\t\treturn buffer.Length - gapLength;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic void SetContent(string text)\n\t\t{\n\t\t\tif (text == null) {\n\t\t\t\ttext = String.Empty;\n\t\t\t}\n\t\t\tbuffer = text.ToCharArray();\n\t\t\tgapBeginOffset = gapEndOffset = gapLength = 0;\n\t\t}\n\t\t\n\t\tpublic char GetCharAt(int offset)\n\t\t{\n\t\t\t#if DEBUG\n\t\t\tCheckThread();\n\t\t\t#endif\n\t\t\t\n\t\t\tif (offset < 0 || offset >= Length) {\n\t\t\t\tthrow new ArgumentOutOfRangeException(\"offset\", offset, \"0 <= offset < \" + Length.ToString());\n\t\t\t}\n\t\t\t\n\t\t\treturn offset < gapBeginOffset ? buffer[offset] : buffer[offset + gapLength];\n\t\t}\n\t\t\n\t\tpublic string GetText(int offset, int length)\n\t\t{\n\t\t\t#if DEBUG\n\t\t\tCheckThread();\n\t\t\t#endif\n\t\t\t\n\t\t\tif (offset < 0 || offset > Length) {\n\t\t\t\tthrow new ArgumentOutOfRangeException(\"offset\", offset, \"0 <= offset <= \" + Length.ToString());\n\t\t\t}\n\t\t\tif (length < 0 || offset + length > Length) {\n\t\t\t\tthrow new ArgumentOutOfRangeException(\"length\", length, \"0 <= length, offset(\" + offset + \")+length <= \" + Length.ToString());\n\t\t\t}\n\t\t\t\n\t\t\tint end = offset + length;\n\t\t\t\n\t\t\tif (end < gapBeginOffset) {\n\t\t\t\treturn new string(buffer, offset, length);\n\t\t\t}\n\t\t\t\n\t\t\tif (offset > gapBeginOffset) {\n\t\t\t\treturn new string(buffer, offset + gapLength, length);\n\t\t\t}\n\t\t\t\n\t\t\tint block1Size = gapBeginOffset - offset;\n\t\t\tint block2Size = end - gapBeginOffset;\n\t\t\t\n\t\t\tStringBuilder buf = new StringBuilder(block1Size + block2Size);\n\t\t\tbuf.Append(buffer, offset,       block1Size);\n\t\t\tbuf.Append(buffer, gapEndOffset, block2Size);\n\t\t\treturn buf.ToString();\n\t\t}\n\t\t\n\t\tpublic void Insert(int offset, string text)\n\t\t{\n\t\t\tReplace(offset, 0, text);\n\t\t}\n\t\t\n\t\tpublic void Remove(int offset, int length)\n\t\t{\n\t\t\tReplace(offset, length, String.Empty);\n\t\t}\n\t\t\n\t\tpublic void Replace(int offset, int length, string text)\n\t\t{\n\t\t\tif (text == null) {\n\t\t\t\ttext = String.Empty;\n\t\t\t}\n\t\t\t\n\t\t\t#if DEBUG\n\t\t\tCheckThread();\n\t\t\t#endif\n\t\t\t\n\t\t\tif (offset < 0 || offset > Length) {\n\t\t\t\tthrow new ArgumentOutOfRangeException(\"offset\", offset, \"0 <= offset <= \" + Length.ToString());\n\t\t\t}\n\t\t\tif (length < 0 || offset + length > Length) {\n\t\t\t\tthrow new ArgumentOutOfRangeException(\"length\", length, \"0 <= length, offset+length <= \" + Length.ToString());\n\t\t\t}\n\t\t\t\n\t\t\t// Math.Max is used so that if we need to resize the array\n\t\t\t// the new array has enough space for all old chars\n\t\t\tPlaceGap(offset, text.Length - length);\n\t\t\tgapEndOffset += length; // delete removed text\n\t\t\ttext.CopyTo(0, buffer, gapBeginOffset, text.Length);\n\t\t\tgapBeginOffset += text.Length;\n\t\t\tgapLength = gapEndOffset - gapBeginOffset;\n\t\t\tif (gapLength > maxGapLength) {\n\t\t\t\tMakeNewBuffer(gapBeginOffset, minGapLength);\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid PlaceGap(int newGapOffset, int minRequiredGapLength)\n\t\t{\n\t\t\tif (gapLength < minRequiredGapLength) {\n\t\t\t\t// enlarge gap\n\t\t\t\tMakeNewBuffer(newGapOffset, minRequiredGapLength);\n\t\t\t} else {\n\t\t\t\twhile (newGapOffset < gapBeginOffset) {\n\t\t\t\t\tbuffer[--gapEndOffset] = buffer[--gapBeginOffset];\n\t\t\t\t}\n\t\t\t\twhile (newGapOffset > gapBeginOffset) {\n\t\t\t\t\tbuffer[gapBeginOffset++] = buffer[gapEndOffset++];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid MakeNewBuffer(int newGapOffset, int newGapLength)\n\t\t{\n\t\t\tif (newGapLength < minGapLength) newGapLength = minGapLength;\n\t\t\t\n\t\t\tchar[] newBuffer = new char[Length + newGapLength];\n\t\t\tif (newGapOffset < gapBeginOffset) {\n\t\t\t\t// gap is moving backwards\n\t\t\t\t\n\t\t\t\t// first part:\n\t\t\t\tArray.Copy(buffer, 0, newBuffer, 0, newGapOffset);\n\t\t\t\t// moving middle part:\n\t\t\t\tArray.Copy(buffer, newGapOffset, newBuffer, newGapOffset + newGapLength, gapBeginOffset - newGapOffset);\n\t\t\t\t// last part:\n\t\t\t\tArray.Copy(buffer, gapEndOffset, newBuffer, newBuffer.Length - (buffer.Length - gapEndOffset), buffer.Length - gapEndOffset);\n\t\t\t} else {\n\t\t\t\t// gap is moving forwards\n\t\t\t\t// first part:\n\t\t\t\tArray.Copy(buffer, 0, newBuffer, 0, gapBeginOffset);\n\t\t\t\t// moving middle part:\n\t\t\t\tArray.Copy(buffer, gapEndOffset, newBuffer, gapBeginOffset, newGapOffset - gapBeginOffset);\n\t\t\t\t// last part:\n\t\t\t\tint lastPartLength = newBuffer.Length - (newGapOffset + newGapLength);\n\t\t\t\tArray.Copy(buffer, buffer.Length - lastPartLength, newBuffer, newGapOffset + newGapLength, lastPartLength);\n\t\t\t}\n\t\t\t\n\t\t\tgapBeginOffset = newGapOffset;\n\t\t\tgapEndOffset = newGapOffset + newGapLength;\n\t\t\tgapLength = newGapLength;\n\t\t\tbuffer = newBuffer;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/TextBufferStrategy/ITextBufferStrategy.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 1966 $</version>\n// </file>\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\t/// <summary>\n\t/// Interface to describe a sequence of characters that can be edited. \t\n\t/// </summary>\n\tpublic interface ITextBufferStrategy\n\t{\n\t\t/// <value>\n\t\t/// The current length of the sequence of characters that can be edited.\n\t\t/// </value>\n\t\tint Length {\n\t\t\tget;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Inserts a string of characters into the sequence.\n\t\t/// </summary>\n\t\t/// <param name=\"offset\">\n\t\t/// offset where to insert the string.\n\t\t/// </param>\n\t\t/// <param name=\"text\">\n\t\t/// text to be inserted.\n\t\t/// </param>\n\t\tvoid Insert(int offset, string text);\n\t\t\n\t\t/// <summary>\n\t\t/// Removes some portion of the sequence.\n\t\t/// </summary>\n\t\t/// <param name=\"offset\">\n\t\t/// offset of the remove.\n\t\t/// </param>\n\t\t/// <param name=\"length\">\n\t\t/// number of characters to remove.\n\t\t/// </param>\n\t\tvoid Remove(int offset, int length);\n\t\t\n\t\t/// <summary>\n\t\t/// Replace some portion of the sequence.\n\t\t/// </summary>\n\t\t/// <param name=\"offset\">\n\t\t/// offset.\n\t\t/// </param>\n\t\t/// <param name=\"length\">\n\t\t/// number of characters to replace.\n\t\t/// </param>\n\t\t/// <param name=\"text\">\n\t\t/// text to be replaced with.\n\t\t/// </param>\n\t\tvoid Replace(int offset, int length, string text);\n\t\t\n\t\t/// <summary>\n\t\t/// Fetches a string of characters contained in the sequence.\n\t\t/// </summary>\n\t\t/// <param name=\"offset\">\n\t\t/// Offset into the sequence to fetch\n\t\t/// </param>\n\t\t/// <param name=\"length\">\n\t\t/// number of characters to copy.\n\t\t/// </param>\n\t\tstring GetText(int offset, int length);\n\t\t\n\t\t/// <summary>\n\t\t/// Returns a specific char of the sequence.\n\t\t/// </summary>\n\t\t/// <param name=\"offset\">\n\t\t/// Offset of the char to get.\n\t\t/// </param>\n\t\tchar GetCharAt(int offset);\n\t\t\n\t\t/// <summary>\n\t\t/// This method sets the stored content.\n\t\t/// </summary>\n\t\t/// <param name=\"text\">\n\t\t/// The string that represents the character sequence.\n\t\t/// </param>\n\t\tvoid SetContent(string text);\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/TextBufferStrategy/StringTextBufferStrategy.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 2682 $</version>\n// </file>\n\nusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\t/// <summary>\n\t/// Simple implementation of the ITextBuffer interface implemented using a\n\t/// string.\n\t/// Only for fall-back purposes.\n\t/// </summary>\n\tpublic class StringTextBufferStrategy : ITextBufferStrategy\n\t{\n\t\tstring storedText = \"\";\n\t\t\n\t\tpublic int Length {\n\t\t\tget {\n\t\t\t\treturn storedText.Length;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic void Insert(int offset, string text)\n\t\t{\n\t\t\tif (text != null) {\n\t\t\t\tstoredText = storedText.Insert(offset, text);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic void Remove(int offset, int length)\n\t\t{\n\t\t\tstoredText = storedText.Remove(offset, length);\n\t\t}\n\t\t\n\t\tpublic void Replace(int offset, int length, string text)\n\t\t{\n\t\t\tRemove(offset, length);\n\t\t\tInsert(offset, text);\n\t\t}\n\t\t\n\t\tpublic string GetText(int offset, int length)\n\t\t{\n\t\t\tif (length == 0) {\n\t\t\t\treturn \"\";\n\t\t\t}\n\t\t\tif (offset == 0 && length >= storedText.Length) {\n\t\t\t\treturn storedText;\n\t\t\t}\n\t\t\treturn storedText.Substring(offset, Math.Min(length, storedText.Length - offset));\n\t\t}\n\t\t\n\t\tpublic char GetCharAt(int offset)\n\t\t{\n\t\t\tif (offset == Length) {\n\t\t\t\treturn '\\0';\n\t\t\t}\n\t\t\treturn storedText[offset];\n\t\t}\n\t\t\n\t\tpublic void SetContent(string text)\n\t\t{\n\t\t\tstoredText = text;\n\t\t}\n\t\t\n\t\tpublic StringTextBufferStrategy()\n\t\t{\n\t\t}\n\t\t\n\t\tpublic static ITextBufferStrategy CreateTextBufferFromFile(string fileName)\n\t\t{\n\t\t\tif (!File.Exists(fileName)) {\n\t\t\t\tthrow new System.IO.FileNotFoundException(fileName);\n\t\t\t}\n\t\t\tStringTextBufferStrategy s = new StringTextBufferStrategy();\n\t\t\ts.SetContent(Util.FileReader.ReadFileContent(fileName, Encoding.Default));\n\t\t\treturn s;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/TextLocation.cs",
    "content": "// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Daniel Grunwald\" email=\"daniel@danielgrunwald.de\"/>\n//     <version>$Revision: 2658$</version>\n// </file>\n\nusing System;\n\nnamespace ICSharpCode.TextEditor\n{\n\t/// <summary>\n\t/// A line/column position.\n\t/// Text editor lines/columns are counting from zero.\n\t/// </summary>\n\tpublic struct TextLocation : IComparable<TextLocation>, IEquatable<TextLocation>\n\t{\n\t\t/// <summary>\n\t\t/// Represents no text location (-1, -1).\n\t\t/// </summary>\n\t\tpublic static readonly TextLocation Empty = new TextLocation(-1, -1);\n\t\t\n\t\tpublic TextLocation(int column, int line)\n\t\t{\n\t\t\tx = column;\n\t\t\ty = line;\n\t\t}\n\t\t\n\t\tint x, y;\n\t\t\n\t\tpublic int X {\n\t\t\tget { return x; }\n\t\t\tset { x = value; }\n\t\t}\n\t\t\n\t\tpublic int Y {\n\t\t\tget { return y; }\n\t\t\tset { y = value; }\n\t\t}\n\t\t\n\t\tpublic int Line {\n\t\t\tget { return y; }\n\t\t\tset { y = value; }\n\t\t}\n\t\t\n\t\tpublic int Column {\n\t\t\tget { return x; }\n\t\t\tset { x = value; }\n\t\t}\n\t\t\n\t\tpublic bool IsEmpty {\n\t\t\tget {\n\t\t\t\treturn x <= 0 && y <= 0;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic override string ToString()\n\t\t{\n\t\t\treturn string.Format(\"(Line {1}, Col {0})\", this.x, this.y);\n\t\t}\n\t\t\n\t\tpublic override int GetHashCode()\n\t\t{\n\t\t\treturn unchecked (87 * x.GetHashCode() ^ y.GetHashCode());\n\t\t}\n\t\t\n\t\tpublic override bool Equals(object obj)\n\t\t{\n\t\t\tif (!(obj is TextLocation)) return false;\n\t\t\treturn (TextLocation)obj == this;\n\t\t}\n\t\t\n\t\tpublic bool Equals(TextLocation other)\n\t\t{\n\t\t\treturn this == other;\n\t\t}\n\t\t\n\t\tpublic static bool operator ==(TextLocation a, TextLocation b)\n\t\t{\n\t\t\treturn a.x == b.x && a.y == b.y;\n\t\t}\n\t\t\n\t\tpublic static bool operator !=(TextLocation a, TextLocation b)\n\t\t{\n\t\t\treturn a.x != b.x || a.y != b.y;\n\t\t}\n\t\t\n\t\tpublic static bool operator <(TextLocation a, TextLocation b)\n\t\t{\n\t\t\tif (a.y < b.y)\n\t\t\t\treturn true;\n\t\t\telse if (a.y == b.y)\n\t\t\t\treturn a.x < b.x;\n\t\t\telse\n\t\t\t\treturn false;\n\t\t}\n\t\t\n\t\tpublic static bool operator >(TextLocation a, TextLocation b)\n\t\t{\n\t\t\tif (a.y > b.y)\n\t\t\t\treturn true;\n\t\t\telse if (a.y == b.y)\n\t\t\t\treturn a.x > b.x;\n\t\t\telse\n\t\t\t\treturn false;\n\t\t}\n\t\t\n\t\tpublic static bool operator <=(TextLocation a, TextLocation b)\n\t\t{\n\t\t\treturn !(a > b);\n\t\t}\n\t\t\n\t\tpublic static bool operator >=(TextLocation a, TextLocation b)\n\t\t{\n\t\t\treturn !(a < b);\n\t\t}\n\t\t\n\t\tpublic int CompareTo(TextLocation other)\n\t\t{\n\t\t\tif (this == other)\n\t\t\t\treturn 0;\n\t\t\tif (this < other)\n\t\t\t\treturn -1;\n\t\t\telse\n\t\t\t\treturn 1;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Document/TextUtilities.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 3020 $</version>\n// </file>\n\nusing System;\nusing System.Diagnostics;\nusing System.Text;\n\nnamespace ICSharpCode.TextEditor.Document\n{\n\t\n\tpublic sealed class TextUtilities\n\t{\n\t\t/// <remarks>\n\t\t/// This function takes a string and converts the whitespace in front of\n\t\t/// it to tabs. If the length of the whitespace at the start of the string\n\t\t/// was not a whole number of tabs then there will still be some spaces just\n\t\t/// before the text starts.\n\t\t/// the output string will be of the form:\n\t\t/// 1. zero or more tabs\n\t\t/// 2. zero or more spaces (less than tabIndent)\n\t\t/// 3. the rest of the line\n\t\t/// </remarks>\n\t\tpublic static string LeadingWhiteSpaceToTabs(string line, int tabIndent) {\n\t\t\tStringBuilder sb = new StringBuilder(line.Length);\n\t\t\tint consecutiveSpaces = 0;\n\t\t\tint i = 0;\n\t\t\tfor(i = 0; i < line.Length; i++) {\n\t\t\t\tif(line[i] == ' ') {\n\t\t\t\t\tconsecutiveSpaces++;\n\t\t\t\t\tif(consecutiveSpaces == tabIndent) {\n\t\t\t\t\t\tsb.Append('\\t');\n\t\t\t\t\t\tconsecutiveSpaces = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if(line[i] == '\\t') {\n\t\t\t\t\tsb.Append('\\t');\n\t\t\t\t\t// if we had say 3 spaces then a tab and tabIndent was 4 then\n\t\t\t\t\t// we would want to simply replace all of that with 1 tab\n\t\t\t\t\tconsecutiveSpaces = 0;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif(i < line.Length) {\n\t\t\t\tsb.Append(line.Substring(i-consecutiveSpaces));\n\t\t\t}\n\t\t\treturn sb.ToString();\n\t\t}\n\t\t\n\t\tpublic static bool IsLetterDigitOrUnderscore(char c)\n\t\t{\n\t\t\tif(!Char.IsLetterOrDigit(c)) {\n\t\t\t\treturn c == '_';\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\t\n\t\tpublic enum CharacterType {\n\t\t\tLetterDigitOrUnderscore,\n\t\t\tWhiteSpace,\n\t\t\tOther\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// This method returns the expression before a specified offset.\n\t\t/// That method is used in code completion to determine the expression given\n\t\t/// to the parser for type resolve.\n\t\t/// </remarks>\n\t\tpublic static string GetExpressionBeforeOffset(TextArea textArea, int initialOffset)\n\t\t{\n\t\t\tIDocument document = textArea.Document;\n\t\t\tint offset = initialOffset;\n\t\t\twhile (offset - 1 > 0) {\n\t\t\t\tswitch (document.GetCharAt(offset - 1)) {\n\t\t\t\t\tcase '\\n':\n\t\t\t\t\tcase '\\r':\n\t\t\t\t\tcase '}':\n\t\t\t\t\t\tgoto done;\n//\t\t\t\t\t\toffset = SearchBracketBackward(document, offset - 2, '{','}');\n//\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase ']':\n\t\t\t\t\t\toffset = SearchBracketBackward(document, offset - 2, '[',']');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase ')':\n\t\t\t\t\t\toffset = SearchBracketBackward(document, offset - 2, '(',')');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '.':\n\t\t\t\t\t\t--offset;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '\"':\n\t\t\t\t\t\tif (offset < initialOffset - 1) {\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn \"\\\"\\\"\";\n\t\t\t\t\tcase '\\'':\n\t\t\t\t\t\tif (offset < initialOffset - 1) {\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn \"'a'\";\n\t\t\t\t\tcase '>':\n\t\t\t\t\t\tif (document.GetCharAt(offset - 2) == '-') {\n\t\t\t\t\t\t\toffset -= 2;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tgoto done;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tif (Char.IsWhiteSpace(document.GetCharAt(offset - 1))) {\n\t\t\t\t\t\t\t--offset;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tint start = offset - 1;\n\t\t\t\t\t\tif (!IsLetterDigitOrUnderscore(document.GetCharAt(start))) {\n\t\t\t\t\t\t\tgoto done;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\twhile (start > 0 && IsLetterDigitOrUnderscore(document.GetCharAt(start - 1))) {\n\t\t\t\t\t\t\t--start;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstring word = document.GetText(start, offset - start).Trim();\n\t\t\t\t\t\tswitch (word) {\n\t\t\t\t\t\t\tcase \"ref\":\n\t\t\t\t\t\t\tcase \"out\":\n\t\t\t\t\t\t\tcase \"in\":\n\t\t\t\t\t\t\tcase \"return\":\n\t\t\t\t\t\t\tcase \"throw\":\n\t\t\t\t\t\t\tcase \"case\":\n\t\t\t\t\t\t\t\tgoto done;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (word.Length > 0 && !IsLetterDigitOrUnderscore(word[0])) {\n\t\t\t\t\t\t\tgoto done;\n\t\t\t\t\t\t}\n\t\t\t\t\t\toffset = start;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\tdone:\n\t\t\t//// simple exit fails when : is inside comment line or any other character\n\t\t\t//// we have to check if we got several ids in resulting line, which usually happens when\n\t\t\t//// id. is typed on next line after comment one\n\t\t\t//// Would be better if lexer would parse properly such expressions. However this will cause\n\t\t\t//// modifications in this area too - to get full comment line and remove it afterwards\n\t\t\tif (offset < 0)\n\t\t\t\treturn string.Empty;\n\t\t\t\n\t\t\tstring resText=document.GetText(offset, textArea.Caret.Offset - offset ).Trim();\n\t\t\tint pos=resText.LastIndexOf('\\n');\n\t\t\tif (pos>=0) {\n\t\t\t\toffset+=pos+1;\n\t\t\t\t//// whitespaces and tabs, which might be inside, will be skipped by trim below\n\t\t\t}\n\t\t\tstring expression = document.GetText(offset, textArea.Caret.Offset - offset ).Trim();\n\t\t\treturn expression;\n\t\t}\n\t\t\n\t\t\n\t\tpublic static CharacterType GetCharacterType(char c)\n\t\t{\n\t\t\tif(IsLetterDigitOrUnderscore(c))\n\t\t\t\treturn CharacterType.LetterDigitOrUnderscore;\n\t\t\tif(Char.IsWhiteSpace(c))\n\t\t\t\treturn CharacterType.WhiteSpace;\n\t\t\treturn CharacterType.Other;\n\t\t}\n\t\t\n\t\tpublic static int GetFirstNonWSChar(IDocument document, int offset)\n\t\t{\n\t\t\twhile (offset < document.TextLength && Char.IsWhiteSpace(document.GetCharAt(offset))) {\n\t\t\t\t++offset;\n\t\t\t}\n\t\t\treturn offset;\n\t\t}\n\t\t\n\t\tpublic static int FindWordEnd(IDocument document, int offset)\n\t\t{\n\t\t\tLineSegment line   = document.GetLineSegmentForOffset(offset);\n\t\t\tint     endPos = line.Offset + line.Length;\n\t\t\twhile (offset < endPos && IsLetterDigitOrUnderscore(document.GetCharAt(offset))) {\n\t\t\t\t++offset;\n\t\t\t}\n\t\t\t\n\t\t\treturn offset;\n\t\t}\n\t\t\n\t\tpublic static int FindWordStart(IDocument document, int offset)\n\t\t{\n\t\t\tLineSegment line = document.GetLineSegmentForOffset(offset);\n\t\t\tint lineOffset = line.Offset;\n\t\t\twhile (offset > lineOffset && IsLetterDigitOrUnderscore(document.GetCharAt(offset - 1))) {\n\t\t\t\t--offset;\n\t\t\t}\n\t\t\t\n\t\t\treturn offset;\n\t\t}\n\t\t\n\t\t// go forward to the start of the next word\n\t\t// if the cursor is at the start or in the middle of a word we move to the end of the word\n\t\t// and then past any whitespace that follows it\n\t\t// if the cursor is at the start or in the middle of some whitespace we move to the start of the\n\t\t// next word\n\t\tpublic static int FindNextWordStart(IDocument document, int offset)\n\t\t{\n\t\t\tint originalOffset = offset;\n\t\t\tLineSegment line   = document.GetLineSegmentForOffset(offset);\n\t\t\tint     endPos = line.Offset + line.Length;\n\t\t\t// lets go to the end of the word, whitespace or operator\n\t\t\tCharacterType t = GetCharacterType(document.GetCharAt(offset));\n\t\t\twhile (offset < endPos && GetCharacterType(document.GetCharAt(offset)) == t) {\n\t\t\t\t++offset;\n\t\t\t}\n\t\t\t\n\t\t\t// now we're at the end of the word, lets find the start of the next one by skipping whitespace\n\t\t\twhile (offset < endPos && GetCharacterType(document.GetCharAt(offset)) == CharacterType.WhiteSpace) {\n\t\t\t\t++offset;\n\t\t\t}\n\n\t\t\treturn offset;\n\t\t}\n\t\t\n\t\t// go back to the start of the word we are on\n\t\t// if we are already at the start of a word or if we are in whitespace, then go back\n\t\t// to the start of the previous word\n\t\tpublic static int FindPrevWordStart(IDocument document, int offset)\n\t\t{\n\t\t\tint originalOffset = offset;\n\t\t\tif (offset > 0) {\n\t\t\t\tLineSegment line = document.GetLineSegmentForOffset(offset);\n\t\t\t\tCharacterType t = GetCharacterType(document.GetCharAt(offset - 1));\n\t\t\t\twhile (offset > line.Offset && GetCharacterType(document.GetCharAt(offset - 1)) == t) {\n\t\t\t\t\t--offset;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// if we were in whitespace, and now we're at the end of a word or operator, go back to the beginning of it\n\t\t\t\tif(t == CharacterType.WhiteSpace && offset > line.Offset) {\n\t\t\t\t\tt = GetCharacterType(document.GetCharAt(offset - 1));\n\t\t\t\t\twhile (offset > line.Offset && GetCharacterType(document.GetCharAt(offset - 1)) == t) {\n\t\t\t\t\t\t--offset;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\treturn offset;\n\t\t}\n\t\t\n\t\tpublic static string GetLineAsString(IDocument document, int lineNumber)\n\t\t{\n\t\t\tLineSegment line = document.GetLineSegment(lineNumber);\n\t\t\treturn document.GetText(line.Offset, line.Length);\n\t\t}\n\t\t\n\t\tpublic static int SearchBracketBackward(IDocument document, int offset, char openBracket, char closingBracket)\n\t\t{\n\t\t\treturn document.FormattingStrategy.SearchBracketBackward(document, offset, openBracket, closingBracket);\n\t\t}\n\t\t\n\t\tpublic static int SearchBracketForward(IDocument document, int offset, char openBracket, char closingBracket)\n\t\t{\n\t\t\treturn document.FormattingStrategy.SearchBracketForward(document, offset, openBracket, closingBracket);\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// Returns true, if the line lineNumber is empty or filled with whitespaces.\n\t\t/// </remarks>\n\t\tpublic static bool IsEmptyLine(IDocument document, int lineNumber)\n\t\t{\n\t\t\treturn IsEmptyLine(document, document.GetLineSegment(lineNumber));\n\t\t}\n\n\t\t/// <remarks>\n\t\t/// Returns true, if the line lineNumber is empty or filled with whitespaces.\n\t\t/// </remarks>\n\t\tpublic static bool IsEmptyLine(IDocument document, LineSegment line)\n\t\t{\n\t\t\tfor (int i = line.Offset; i < line.Offset + line.Length; ++i) {\n\t\t\t\tchar ch = document.GetCharAt(i);\n\t\t\t\tif (!Char.IsWhiteSpace(ch)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\t\n\t\tstatic bool IsWordPart(char ch)\n\t\t{\n\t\t\treturn IsLetterDigitOrUnderscore(ch) || ch == '.';\n\t\t}\n\t\t\n\t\tpublic static string GetWordAt(IDocument document, int offset)\n\t\t{\n\t\t\tif (offset < 0 || offset >= document.TextLength - 1 || !IsWordPart(document.GetCharAt(offset))) {\n\t\t\t\treturn String.Empty;\n\t\t\t}\n\t\t\tint startOffset = offset;\n\t\t\tint endOffset   = offset;\n\t\t\twhile (startOffset > 0 && IsWordPart(document.GetCharAt(startOffset - 1))) {\n\t\t\t\t--startOffset;\n\t\t\t}\n\t\t\t\n\t\t\twhile (endOffset < document.TextLength - 1 && IsWordPart(document.GetCharAt(endOffset + 1))) {\n\t\t\t\t++endOffset;\n\t\t\t}\n\t\t\t\n\t\t\tDebug.Assert(endOffset >= startOffset);\n\t\t\treturn document.GetText(startOffset, endOffset - startOffset + 1);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Gui/AbstractMargin.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 1965 $</version>\n// </file>\n\nusing System;\nusing System.Drawing;\nusing System.Windows.Forms;\n\nusing ICSharpCode.TextEditor.Document;\n\nnamespace ICSharpCode.TextEditor\n{\n\tpublic delegate void MarginMouseEventHandler(AbstractMargin sender, Point mousepos, MouseButtons mouseButtons);\n\tpublic delegate void MarginPaintEventHandler(AbstractMargin sender, Graphics g, Rectangle rect);\n\t\n\t/// <summary>\n\t/// This class views the line numbers and folding markers.\n\t/// </summary>\n\tpublic abstract class AbstractMargin\n\t{\n\t\tCursor cursor = Cursors.Default;\n\t\t\n\t\t[CLSCompliant(false)]\n\t\tprotected Rectangle drawingPosition = new Rectangle(0, 0, 0, 0);\n\t\t[CLSCompliant(false)]\n\t\tprotected TextArea textArea;\n\t\t\n\t\tpublic Rectangle DrawingPosition {\n\t\t\tget {\n\t\t\t\treturn drawingPosition;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tdrawingPosition = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic TextArea TextArea {\n\t\t\tget {\n\t\t\t\treturn textArea;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic IDocument Document {\n\t\t\tget {\n\t\t\t\treturn textArea.Document;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic ITextEditorProperties TextEditorProperties {\n\t\t\tget {\n\t\t\t\treturn textArea.Document.TextEditorProperties;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic virtual Cursor Cursor {\n\t\t\tget {\n\t\t\t\treturn cursor;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tcursor = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic virtual Size Size {\n\t\t\tget {\n\t\t\t\treturn new Size(-1, -1);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic virtual bool IsVisible {\n\t\t\tget {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\t\n\t\tprotected AbstractMargin(TextArea textArea)\n\t\t{\n\t\t\tthis.textArea = textArea;\n\t\t}\n\t\t\n\t\tpublic virtual void HandleMouseDown(Point mousepos, MouseButtons mouseButtons)\n\t\t{\n\t\t\tif (MouseDown != null) {\n\t\t\t\tMouseDown(this, mousepos, mouseButtons);\n\t\t\t}\n\t\t}\n\t\tpublic virtual void HandleMouseMove(Point mousepos, MouseButtons mouseButtons)\n\t\t{\n\t\t\tif (MouseMove != null) {\n\t\t\t\tMouseMove(this, mousepos, mouseButtons);\n\t\t\t}\n\t\t}\n\t\tpublic virtual void HandleMouseLeave(EventArgs e)\n\t\t{\n\t\t\tif (MouseLeave != null) {\n\t\t\t\tMouseLeave(this, e);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic virtual void Paint(Graphics g, Rectangle rect)\n\t\t{\n\t\t\tif (Painted != null) {\n\t\t\t\tPainted(this, g, rect);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic event MarginPaintEventHandler Painted;\n\t\tpublic event MarginMouseEventHandler MouseDown;\n\t\tpublic event MarginMouseEventHandler MouseMove;\n\t\tpublic event EventHandler            MouseLeave;\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Gui/BracketHighlighter.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 2659 $</version>\n// </file>\n\nusing System;\nusing System.Drawing;\nusing ICSharpCode.TextEditor.Document;\n\nnamespace ICSharpCode.TextEditor\n{\n\tpublic class BracketHighlight\n\t{\n\t\tpublic TextLocation OpenBrace { get; set; }\n\t\tpublic TextLocation CloseBrace { get; set; }\n\t\t\n\t\tpublic BracketHighlight(TextLocation openBrace, TextLocation closeBrace)\n\t\t{\n\t\t\tthis.OpenBrace = openBrace;\n\t\t\tthis.CloseBrace = closeBrace;\n\t\t}\n\t}\n\t\n\tpublic class BracketHighlightingSheme\n\t{\n\t\tchar opentag;\n\t\tchar closingtag;\n\t\t\n\t\tpublic char OpenTag {\n\t\t\tget {\n\t\t\t\treturn opentag;\n\t\t\t}\n\t\t\tset {\n\t\t\t\topentag = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic char ClosingTag {\n\t\t\tget {\n\t\t\t\treturn closingtag;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tclosingtag = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic BracketHighlightingSheme(char opentag, char closingtag)\n\t\t{\n\t\t\tthis.opentag    = opentag;\n\t\t\tthis.closingtag = closingtag;\n\t\t}\n\t\t\n\t\tpublic BracketHighlight GetHighlight(IDocument document, int offset)\n\t\t{\n\t\t\tint searchOffset;\n\t\t\tif (document.TextEditorProperties.BracketMatchingStyle == BracketMatchingStyle.After) {\n\t\t\t\tsearchOffset = offset;\n\t\t\t} else {\n\t\t\t\tsearchOffset = offset + 1;\n\t\t\t}\n\t\t\tchar word = document.GetCharAt(Math.Max(0, Math.Min(document.TextLength - 1, searchOffset)));\n\t\t\t\n\t\t\tTextLocation endP = document.OffsetToPosition(searchOffset);\n\t\t\tif (word == opentag) {\n\t\t\t\tif (searchOffset < document.TextLength) {\n\t\t\t\t\tint bracketOffset = TextUtilities.SearchBracketForward(document, searchOffset + 1, opentag, closingtag);\n\t\t\t\t\tif (bracketOffset >= 0) {\n\t\t\t\t\t\tTextLocation p = document.OffsetToPosition(bracketOffset);\n\t\t\t\t\t\treturn new BracketHighlight(p, endP);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (word == closingtag) {\n\t\t\t\tif (searchOffset > 0) {\n\t\t\t\t\tint bracketOffset = TextUtilities.SearchBracketBackward(document, searchOffset - 1, opentag, closingtag);\n\t\t\t\t\tif (bracketOffset >= 0) {\n\t\t\t\t\t\tTextLocation p = document.OffsetToPosition(bracketOffset);\n\t\t\t\t\t\treturn new BracketHighlight(p, endP);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Gui/BrushRegistry.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 1965 $</version>\n// </file>\n\nusing System;\nusing System.Collections;\nusing System.Drawing;\nusing System.Drawing.Drawing2D;\n\nnamespace ICSharpCode.TextEditor\n{\n\t/// <summary>\n\t/// Contains brushes/pens for the text editor to speed up drawing. Re-Creation of brushes and pens\n\t/// seems too costly.\n\t/// </summary>\n\tpublic class BrushRegistry\n\t{\n\t\tstatic Hashtable brushes = new Hashtable();\n\t\tstatic Hashtable pens    = new Hashtable();\n\t\tstatic Hashtable dotPens = new Hashtable();\n\t\t\n\t\tpublic static Brush GetBrush(Color color)\n\t\t{\n\t\t\tif (!brushes.Contains(color)) {\n\t\t\t\tBrush newBrush = new SolidBrush(color);\n\t\t\t\tbrushes.Add(color, newBrush);\n\t\t\t\treturn newBrush;\n\t\t\t}\n\t\t\treturn brushes[color] as Brush;\n\t\t}\n\t\t\n\t\tpublic static Pen GetPen(Color color)\n\t\t{\n\t\t\tif (!pens.Contains(color)) {\n\t\t\t\tPen newPen = new Pen(color);\n\t\t\t\tpens.Add(color, newPen);\n\t\t\t\treturn newPen;\n\t\t\t}\n\t\t\treturn pens[color] as Pen;\n\t\t}\n\t\t\n\t\tpublic static Pen GetDotPen(Color bgColor, Color fgColor)\n\t\t{\n\t\t\tbool containsBgColor = dotPens.Contains(bgColor);\n\t\t\tif (!containsBgColor || !((Hashtable)dotPens[bgColor]).Contains(fgColor)) {\n\t\t\t\tif (!containsBgColor) {\n\t\t\t\t\tdotPens[bgColor] = new Hashtable();\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tHatchBrush hb = new HatchBrush(HatchStyle.Percent50, bgColor, fgColor);\n\t\t\t\tPen newPen = new Pen(hb);\n\t\t\t\t((Hashtable)dotPens[bgColor])[fgColor] = newPen;\n\t\t\t\treturn newPen;\n\t\t\t}\n\t\t\treturn ((Hashtable)dotPens[bgColor])[fgColor] as Pen;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Gui/Caret.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 3279 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\nusing System.Drawing;\nusing System.Diagnostics;\nusing System.Runtime.InteropServices;\n\nusing ICSharpCode.TextEditor.Document;\n\nnamespace ICSharpCode.TextEditor\n{\n\t/// <summary>\n\t/// In this enumeration are all caret modes listed.\n\t/// </summary>\n\tpublic enum CaretMode {\n\t\t/// <summary>\n\t\t/// If the caret is in insert mode typed characters will be\n\t\t/// inserted at the caret position\n\t\t/// </summary>\n\t\tInsertMode,\n\t\t\n\t\t/// <summary>\n\t\t/// If the caret is in overwirte mode typed characters will\n\t\t/// overwrite the character at the caret position\n\t\t/// </summary>\n\t\tOverwriteMode\n\t}\n\t\n\t\n\tpublic class Caret : System.IDisposable\n\t{\n\t\tint       line          = 0;\n\t\tint       column        = 0;\n\t\tint       desiredXPos   = 0;\n\t\tCaretMode caretMode;\n\t\t\n\t\tstatic bool     caretCreated = false;\n\t\tbool     hidden       = true;\n\t\tTextArea textArea;\n\t\tPoint    currentPos   = new Point(-1, -1);\n\t\tIme      ime          = null;\n\t\tCaretImplementation caretImplementation;\n\t\t\n\t\t/// <value>\n\t\t/// The 'prefered' xPos in which the caret moves, when it is moved\n\t\t/// up/down. Measured in pixels, not in characters!\n\t\t/// </value>\n\t\tpublic int DesiredColumn {\n\t\t\tget {\n\t\t\t\treturn desiredXPos;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tdesiredXPos = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// The current caret mode.\n\t\t/// </value>\n\t\tpublic CaretMode CaretMode {\n\t\t\tget {\n\t\t\t\treturn caretMode;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tcaretMode = value;\n\t\t\t\tOnCaretModeChanged(EventArgs.Empty);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int Line {\n\t\t\tget {\n\t\t\t\treturn line;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tline = value;\n\t\t\t\tValidateCaretPos();\n\t\t\t\tUpdateCaretPosition();\n\t\t\t\tOnPositionChanged(EventArgs.Empty);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int Column {\n\t\t\tget {\n\t\t\t\treturn column;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tcolumn = value;\n\t\t\t\tValidateCaretPos();\n\t\t\t\tUpdateCaretPosition();\n\t\t\t\tOnPositionChanged(EventArgs.Empty);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic TextLocation Position {\n\t\t\tget {\n\t\t\t\treturn new TextLocation(column, line);\n\t\t\t}\n\t\t\tset {\n\t\t\t\tline   = value.Y;\n\t\t\t\tcolumn = value.X;\n\t\t\t\tValidateCaretPos();\n\t\t\t\tUpdateCaretPosition();\n\t\t\t\tOnPositionChanged(EventArgs.Empty);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int Offset {\n\t\t\tget {\n\t\t\t\treturn textArea.Document.PositionToOffset(Position);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic Caret(TextArea textArea)\n\t\t{\n\t\t\tthis.textArea = textArea;\n\t\t\ttextArea.GotFocus  += new EventHandler(GotFocus);\n\t\t\ttextArea.LostFocus += new EventHandler(LostFocus);\n\t\t\tif (Environment.OSVersion.Platform == PlatformID.Unix)\n\t\t\t\tcaretImplementation = new ManagedCaret(this);\n\t\t\telse\n\t\t\t\tcaretImplementation = new Win32Caret(this);\n\t\t}\n\t\t\n\t\tpublic void Dispose()\n\t\t{\n\t\t\ttextArea.GotFocus  -= new EventHandler(GotFocus);\n\t\t\ttextArea.LostFocus -= new EventHandler(LostFocus);\n\t\t\ttextArea = null;\n\t\t\tcaretImplementation.Dispose();\n\t\t}\n\t\t\n\t\tpublic TextLocation ValidatePosition(TextLocation pos)\n\t\t{\n\t\t\tint line   = Math.Max(0, Math.Min(textArea.Document.TotalNumberOfLines - 1, pos.Y));\n\t\t\tint column = Math.Max(0, pos.X);\n\t\t\t\n\t\t\tif (column == int.MaxValue || !textArea.TextEditorProperties.AllowCaretBeyondEOL) {\n\t\t\t\tLineSegment lineSegment = textArea.Document.GetLineSegment(line);\n\t\t\t\tcolumn = Math.Min(column, lineSegment.Length);\n\t\t\t}\n\t\t\treturn new TextLocation(column, line);\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// If the caret position is outside the document text bounds\n\t\t/// it is set to the correct position by calling ValidateCaretPos.\n\t\t/// </remarks>\n\t\tpublic void ValidateCaretPos()\n\t\t{\n\t\t\tline = Math.Max(0, Math.Min(textArea.Document.TotalNumberOfLines - 1, line));\n\t\t\tcolumn = Math.Max(0, column);\n\t\t\t\n\t\t\tif (column == int.MaxValue || !textArea.TextEditorProperties.AllowCaretBeyondEOL) {\n\t\t\t\tLineSegment lineSegment = textArea.Document.GetLineSegment(line);\n\t\t\t\tcolumn = Math.Min(column, lineSegment.Length);\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid CreateCaret()\n\t\t{\n\t\t\twhile (!caretCreated) {\n\t\t\t\tswitch (caretMode) {\n\t\t\t\t\tcase CaretMode.InsertMode:\n\t\t\t\t\t\tcaretCreated = caretImplementation.Create(2, textArea.TextView.FontHeight);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase CaretMode.OverwriteMode:\n\t\t\t\t\t\tcaretCreated = caretImplementation.Create((int)textArea.TextView.SpaceWidth, textArea.TextView.FontHeight);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (currentPos.X  < 0) {\n\t\t\t\tValidateCaretPos();\n\t\t\t\tcurrentPos = ScreenPosition;\n\t\t\t}\n\t\t\tcaretImplementation.SetPosition(currentPos.X, currentPos.Y);\n\t\t\tcaretImplementation.Show();\n\t\t}\n\t\t\n\t\tpublic void RecreateCaret()\n\t\t{\n\t\t\tLog(\"RecreateCaret\");\n\t\t\tDisposeCaret();\n\t\t\tif (!hidden) {\n\t\t\t\tCreateCaret();\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid DisposeCaret()\n\t\t{\n\t\t\tif (caretCreated) {\n\t\t\t\tcaretCreated = false;\n\t\t\t\tcaretImplementation.Hide();\n\t\t\t\tcaretImplementation.Destroy();\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid GotFocus(object sender, EventArgs e)\n\t\t{\n\t\t\tLog(\"GotFocus, IsInUpdate=\" + textArea.MotherTextEditorControl.IsInUpdate);\n\t\t\thidden = false;\n\t\t\tif (!textArea.MotherTextEditorControl.IsInUpdate) {\n\t\t\t\tCreateCaret();\n\t\t\t\tUpdateCaretPosition();\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid LostFocus(object sender, EventArgs e)\n\t\t{\n\t\t\tLog(\"LostFocus\");\n\t\t\thidden = true;\n\t\t\tDisposeCaret();\n\t\t}\n\t\t\n\t\tpublic Point ScreenPosition {\n\t\t\tget {\n\t\t\t\tint xpos = textArea.TextView.GetDrawingXPos(this.line, this.column);\n\t\t\t\treturn new Point(textArea.TextView.DrawingPosition.X + xpos,\n\t\t\t\t                 textArea.TextView.DrawingPosition.Y\n\t\t\t\t                 + (textArea.Document.GetVisibleLine(this.line)) * textArea.TextView.FontHeight\n\t\t\t\t                 - textArea.TextView.TextArea.VirtualTop.Y);\n\t\t\t}\n\t\t}\n\t\tint oldLine = -1;\n\t\tbool outstandingUpdate;\n\t\t\n\t\tinternal void OnEndUpdate()\n\t\t{\n\t\t\tif (outstandingUpdate)\n\t\t\t\tUpdateCaretPosition();\n\t\t}\n\t\t\n\t\tpublic void UpdateCaretPosition()\n\t\t{\n\t\t\tLog(\"UpdateCaretPosition\");\n\t\t\t\n\t\t\tif (caretImplementation.RequireRedrawOnPositionChange) {\n\t\t\t\ttextArea.UpdateLine(oldLine);\n\t\t\t\tif (line != oldLine)\n\t\t\t\t\ttextArea.UpdateLine(line);\n\t\t\t} else {\n\t\t\t\tif (textArea.MotherTextAreaControl.TextEditorProperties.LineViewerStyle == LineViewerStyle.FullRow && oldLine != line) {\n\t\t\t\t\ttextArea.UpdateLine(oldLine);\n\t\t\t\t\ttextArea.UpdateLine(line);\n\t\t\t\t}\n\t\t\t}\n\t\t\toldLine = line;\n\t\t\t\n\t\t\t\n\t\t\tif (hidden || textArea.MotherTextEditorControl.IsInUpdate) {\n\t\t\t\toutstandingUpdate = true;\n\t\t\t\treturn;\n\t\t\t} else {\n\t\t\t\toutstandingUpdate = false;\n\t\t\t}\n\t\t\tValidateCaretPos();\n\t\t\tint lineNr = this.line;\n\t\t\tint xpos = textArea.TextView.GetDrawingXPos(lineNr, this.column);\n\t\t\t//LineSegment lineSegment = textArea.Document.GetLineSegment(lineNr);\n\t\t\tPoint pos = ScreenPosition;\n\t\t\tif (xpos >= 0) {\n\t\t\t\tCreateCaret();\n\t\t\t\tbool success = caretImplementation.SetPosition(pos.X, pos.Y);\n\t\t\t\tif (!success) {\n\t\t\t\t\tcaretImplementation.Destroy();\n\t\t\t\t\tcaretCreated = false;\n\t\t\t\t\tUpdateCaretPosition();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcaretImplementation.Destroy();\n\t\t\t}\n\t\t\t\n\t\t\t// set the input method editor location\n\t\t\tif (ime == null) {\n\t\t\t\time = new Ime(textArea.Handle, textArea.Document.TextEditorProperties.Font);\n\t\t\t} else {\n\t\t\t\time.HWnd = textArea.Handle;\n\t\t\t\time.Font = textArea.Document.TextEditorProperties.Font;\n\t\t\t}\n\t\t\time.SetIMEWindowLocation(pos.X, pos.Y);\n\t\t\t\n\t\t\tcurrentPos = pos;\n\t\t}\n\t\t\n\t\t[Conditional(\"DEBUG\")]\n\t\tstatic void Log(string text)\n\t\t{\n\t\t\t//Console.WriteLine(text);\n\t\t}\n\t\t\n\t\t#region Caret implementation\n\t\tinternal void PaintCaret(Graphics g)\n\t\t{\n\t\t\tcaretImplementation.PaintCaret(g);\n\t\t}\n\t\t\n\t\tabstract class CaretImplementation : IDisposable\n\t\t{\n\t\t\tpublic bool RequireRedrawOnPositionChange;\n\t\t\t\n\t\t\tpublic abstract bool Create(int width, int height);\n\t\t\tpublic abstract void Hide();\n\t\t\tpublic abstract void Show();\n\t\t\tpublic abstract bool SetPosition(int x, int y);\n\t\t\tpublic abstract void PaintCaret(Graphics g);\n\t\t\tpublic abstract void Destroy();\n\t\t\t\n\t\t\tpublic virtual void Dispose()\n\t\t\t{\n\t\t\t\tDestroy();\n\t\t\t}\n\t\t}\n\t\t\n\t\tclass ManagedCaret : CaretImplementation\n\t\t{\n\t\t\tSystem.Windows.Forms.Timer timer = new System.Windows.Forms.Timer { Interval = 300 };\n\t\t\tbool visible;\n\t\t\tbool blink = true;\n\t\t\tint x, y, width, height;\n\t\t\tTextArea textArea;\n\t\t\tCaret parentCaret;\n\t\t\t\n\t\t\tpublic ManagedCaret(Caret caret)\n\t\t\t{\n\t\t\t\tbase.RequireRedrawOnPositionChange = true;\n\t\t\t\tthis.textArea = caret.textArea;\n\t\t\t\tthis.parentCaret = caret;\n\t\t\t\ttimer.Tick += CaretTimerTick;\n\t\t\t}\n\t\t\t\n\t\t\tvoid CaretTimerTick(object sender, EventArgs e)\n\t\t\t{\n\t\t\t\tblink = !blink;\n\t\t\t\tif (visible)\n\t\t\t\t\ttextArea.UpdateLine(parentCaret.Line);\n\t\t\t}\n\t\t\t\n\t\t\tpublic override bool Create(int width, int height)\n\t\t\t{\n\t\t\t\tthis.visible = true;\n\t\t\t\tthis.width = width - 2;\n\t\t\t\tthis.height = height;\n\t\t\t\ttimer.Enabled = true;\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tpublic override void Hide()\n\t\t\t{\n\t\t\t\tvisible = false;\n\t\t\t}\n\t\t\tpublic override void Show()\n\t\t\t{\n\t\t\t\tvisible = true;\n\t\t\t}\n\t\t\tpublic override bool SetPosition(int x, int y)\n\t\t\t{\n\t\t\t\tthis.x = x - 1;\n\t\t\t\tthis.y = y;\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tpublic override void PaintCaret(Graphics g)\n\t\t\t{\n\t\t\t\tif (visible && blink)\n\t\t\t\t\tg.DrawRectangle(Pens.Gray, x, y, width, height);\n\t\t\t}\n\t\t\tpublic override void Destroy()\n\t\t\t{\n\t\t\t\tvisible = false;\n\t\t\t\ttimer.Enabled = false;\n\t\t\t}\n\t\t\tpublic override void Dispose()\n\t\t\t{\n\t\t\t\tbase.Dispose();\n\t\t\t\ttimer.Dispose();\n\t\t\t}\n\t\t}\n\t\t\n\t\tclass Win32Caret : CaretImplementation\n\t\t{\n\t\t\t[DllImport(\"User32.dll\")]\n\t\t\tstatic extern bool CreateCaret(IntPtr hWnd, int hBitmap, int nWidth, int nHeight);\n\t\t\t\n\t\t\t[DllImport(\"User32.dll\")]\n\t\t\tstatic extern bool SetCaretPos(int x, int y);\n\t\t\t\n\t\t\t[DllImport(\"User32.dll\")]\n\t\t\tstatic extern bool DestroyCaret();\n\t\t\t\n\t\t\t[DllImport(\"User32.dll\")]\n\t\t\tstatic extern bool ShowCaret(IntPtr hWnd);\n\t\t\t\n\t\t\t[DllImport(\"User32.dll\")]\n\t\t\tstatic extern bool HideCaret(IntPtr hWnd);\n\t\t\t\n\t\t\tTextArea textArea;\n\t\t\t\n\t\t\tpublic Win32Caret(Caret caret)\n\t\t\t{\n\t\t\t\tthis.textArea = caret.textArea;\n\t\t\t}\n\t\t\t\n\t\t\tpublic override bool Create(int width, int height)\n\t\t\t{\n\t\t\t\treturn CreateCaret(textArea.Handle, 0, width, height);\n\t\t\t}\n\t\t\tpublic override void Hide()\n\t\t\t{\n\t\t\t\tHideCaret(textArea.Handle);\n\t\t\t}\n\t\t\tpublic override void Show()\n\t\t\t{\n\t\t\t\tShowCaret(textArea.Handle);\n\t\t\t}\n\t\t\tpublic override bool SetPosition(int x, int y)\n\t\t\t{\n\t\t\t\treturn SetCaretPos(x, y);\n\t\t\t}\n\t\t\tpublic override void PaintCaret(Graphics g)\n\t\t\t{\n\t\t\t}\n\t\t\tpublic override void Destroy()\n\t\t\t{\n\t\t\t\tDestroyCaret();\n\t\t\t}\n\t\t}\n\t\t#endregion\n\t\t\n\t\tbool firePositionChangedAfterUpdateEnd;\n\t\t\n\t\tvoid FirePositionChangedAfterUpdateEnd(object sender, EventArgs e)\n\t\t{\n\t\t\tOnPositionChanged(EventArgs.Empty);\n\t\t}\n\t\t\n\t\tprotected virtual void OnPositionChanged(EventArgs e)\n\t\t{\n\t\t\tif (this.textArea.MotherTextEditorControl.IsInUpdate) {\n\t\t\t\tif (firePositionChangedAfterUpdateEnd == false) {\n\t\t\t\t\tfirePositionChangedAfterUpdateEnd = true;\n\t\t\t\t\tthis.textArea.Document.UpdateCommited += FirePositionChangedAfterUpdateEnd;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t} else if (firePositionChangedAfterUpdateEnd) {\n\t\t\t\tthis.textArea.Document.UpdateCommited -= FirePositionChangedAfterUpdateEnd;\n\t\t\t\tfirePositionChangedAfterUpdateEnd = false;\n\t\t\t}\n\t\t\t\n\t\t\tList<FoldMarker> foldings = textArea.Document.FoldingManager.GetFoldingsFromPosition(line, column);\n\t\t\tbool  shouldUpdate = false;\n\t\t\tforeach (FoldMarker foldMarker in foldings) {\n\t\t\t\tshouldUpdate |= foldMarker.IsFolded;\n\t\t\t\tfoldMarker.IsFolded = false;\n\t\t\t}\n\t\t\t\n\t\t\tif (shouldUpdate) {\n\t\t\t\ttextArea.Document.FoldingManager.NotifyFoldingsChanged(EventArgs.Empty);\n\t\t\t}\n\t\t\t\n\t\t\tif (PositionChanged != null) {\n\t\t\t\tPositionChanged(this, e);\n\t\t\t}\n\t\t\ttextArea.ScrollToCaret();\n\t\t}\n\t\t\n\t\tprotected virtual void OnCaretModeChanged(EventArgs e)\n\t\t{\n\t\t\tif (CaretModeChanged != null) {\n\t\t\t\tCaretModeChanged(this, e);\n\t\t\t}\n\t\t\tcaretImplementation.Hide();\n\t\t\tcaretImplementation.Destroy();\n\t\t\tcaretCreated = false;\n\t\t\tCreateCaret();\n\t\t\tcaretImplementation.Show();\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// Is called each time the caret is moved.\n\t\t/// </remarks>\n\t\tpublic event EventHandler PositionChanged;\n\t\t\n\t\t/// <remarks>\n\t\t/// Is called each time the CaretMode has changed.\n\t\t/// </remarks>\n\t\tpublic event EventHandler CaretModeChanged;\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Gui/CompletionWindow/AbstractCompletionWindow.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 2681 $</version>\n// </file>\n\nusing System;\nusing System.Drawing;\nusing System.Windows.Forms;\n\nnamespace ICSharpCode.TextEditor.Gui.CompletionWindow\n{\n\t/// <summary>\n\t/// Description of AbstractCompletionWindow.\n\t/// </summary>\n\tpublic abstract class AbstractCompletionWindow : System.Windows.Forms.Form\n\t{\n\t\tprotected TextEditorControl control;\n\t\tprotected Size              drawingSize;\n\t\tRectangle workingScreen;\n\t\tForm parentForm;\n\t\t\n\t\tprotected AbstractCompletionWindow(Form parentForm, TextEditorControl control)\n\t\t{\n\t\t\tworkingScreen = Screen.GetWorkingArea(parentForm);\n//\t\t\tSetStyle(ControlStyles.Selectable, false);\n\t\t\tthis.parentForm = parentForm;\n\t\t\tthis.control  = control;\n\t\t\t\n\t\t\tSetLocation();\n\t\t\tStartPosition   = FormStartPosition.Manual;\n\t\t\tFormBorderStyle = FormBorderStyle.None;\n\t\t\tShowInTaskbar   = false;\n\t\t\tMinimumSize     = new Size(1, 1);\n\t\t\tSize            = new Size(1, 1);\n\t\t}\n\t\t\n\t\tprotected virtual void SetLocation()\n\t\t{\n\t\t\tTextArea textArea = control.ActiveTextAreaControl.TextArea;\n\t\t\tTextLocation caretPos  = textArea.Caret.Position;\n\t\t\t\n\t\t\tint xpos = textArea.TextView.GetDrawingXPos(caretPos.Y, caretPos.X);\n\t\t\tint rulerHeight = textArea.TextEditorProperties.ShowHorizontalRuler ? textArea.TextView.FontHeight : 0;\n\t\t\tPoint pos = new Point(textArea.TextView.DrawingPosition.X + xpos,\n\t\t\t                      textArea.TextView.DrawingPosition.Y + (textArea.Document.GetVisibleLine(caretPos.Y)) * textArea.TextView.FontHeight \n\t\t\t                      - textArea.TextView.TextArea.VirtualTop.Y + textArea.TextView.FontHeight + rulerHeight);\n\t\t\t\n\t\t\tPoint location = control.ActiveTextAreaControl.PointToScreen(pos);\n\t\t\t\n\t\t\t// set bounds\n\t\t\tRectangle bounds = new Rectangle(location, drawingSize);\n\t\t\t\n\t\t\tif (!workingScreen.Contains(bounds)) {\n\t\t\t\tif (bounds.Right > workingScreen.Right) {\n\t\t\t\t\tbounds.X = workingScreen.Right - bounds.Width;\n\t\t\t\t}\n\t\t\t\tif (bounds.Left < workingScreen.Left) {\n\t\t\t\t\tbounds.X = workingScreen.Left;\n\t\t\t\t}\n\t\t\t\tif (bounds.Top < workingScreen.Top) {\n\t\t\t\t\tbounds.Y = workingScreen.Top;\n\t\t\t\t}\n\t\t\t\tif (bounds.Bottom > workingScreen.Bottom) {\n\t\t\t\t\tbounds.Y = bounds.Y - bounds.Height - control.ActiveTextAreaControl.TextArea.TextView.FontHeight;\n\t\t\t\t\tif (bounds.Bottom > workingScreen.Bottom) {\n\t\t\t\t\t\tbounds.Y = workingScreen.Bottom - bounds.Height;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tBounds = bounds;\n\t\t}\n\t\t\n\t\tprotected override CreateParams CreateParams {\n\t\t\tget {\n\t\t\t\tCreateParams p = base.CreateParams;\n\t\t\t\tAddShadowToWindow(p);\n\t\t\t\treturn p;\n\t\t\t}\n\t\t}\n\t\t\n\t\tstatic int shadowStatus;\n\t\t\n\t\t/// <summary>\n\t\t/// Adds a shadow to the create params if it is supported by the operating system.\n\t\t/// </summary>\n\t\tpublic static void AddShadowToWindow(CreateParams createParams)\n\t\t{\n\t\t\tif (shadowStatus == 0) {\n\t\t\t\t// Test OS version\n\t\t\t\tshadowStatus = -1; // shadow not supported\n\t\t\t\tif (Environment.OSVersion.Platform == PlatformID.Win32NT) {\n\t\t\t\t\tVersion ver = Environment.OSVersion.Version;\n\t\t\t\t\tif (ver.Major > 5 || ver.Major == 5 && ver.Minor >= 1) {\n\t\t\t\t\t\tshadowStatus = 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (shadowStatus == 1) {\n\t\t\t\tcreateParams.ClassStyle |= 0x00020000; // set CS_DROPSHADOW\n\t\t\t}\n\t\t}\n\t\t\n\t\tprotected override bool ShowWithoutActivation {\n\t\t\tget {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\t\n\t\tprotected void ShowCompletionWindow()\n\t\t{\n\t\t\tOwner = parentForm;\n\t\t\tEnabled = true;\n\t\t\tthis.Show();\n\t\t\t\n\t\t\tcontrol.Focus();\n\t\t\t\n\t\t\tif (parentForm != null) {\n\t\t\t\tparentForm.LocationChanged += new EventHandler(this.ParentFormLocationChanged);\n\t\t\t}\n\t\t\t\n\t\t\tcontrol.ActiveTextAreaControl.VScrollBar.ValueChanged     += new EventHandler(ParentFormLocationChanged);\n\t\t\tcontrol.ActiveTextAreaControl.HScrollBar.ValueChanged     += new EventHandler(ParentFormLocationChanged);\n\t\t\tcontrol.ActiveTextAreaControl.TextArea.DoProcessDialogKey += new DialogKeyProcessor(ProcessTextAreaKey);\n\t\t\tcontrol.ActiveTextAreaControl.Caret.PositionChanged       += new EventHandler(CaretOffsetChanged);\n\t\t\tcontrol.ActiveTextAreaControl.TextArea.LostFocus          += new EventHandler(this.TextEditorLostFocus);\n\t\t\tcontrol.Resize += new EventHandler(ParentFormLocationChanged);\n\t\t\t\n\t\t\tforeach (Control c in Controls) {\n\t\t\t\tc.MouseMove += ControlMouseMove;\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid ParentFormLocationChanged(object sender, EventArgs e)\n\t\t{\n\t\t\tSetLocation();\n\t\t}\n\t\t\n\t\tpublic virtual bool ProcessKeyEvent(char ch)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\tprotected virtual bool ProcessTextAreaKey(Keys keyData)\n\t\t{\n\t\t\tif (!Visible) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tswitch (keyData) {\n\t\t\t\tcase Keys.Escape:\n\t\t\t\t\tClose();\n\t\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\tprotected virtual void CaretOffsetChanged(object sender, EventArgs e)\n\t\t{\n\t\t}\n\t\t\n\t\tprotected void TextEditorLostFocus(object sender, EventArgs e)\n\t\t{\n\t\t\tif (!control.ActiveTextAreaControl.TextArea.Focused && !this.ContainsFocus) {\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\t\n\t\tprotected override void OnClosed(EventArgs e)\n\t\t{\n\t\t\tbase.OnClosed(e);\n\t\t\t\n\t\t\t// take out the inserted methods\n\t\t\tparentForm.LocationChanged -= new EventHandler(ParentFormLocationChanged);\n\t\t\t\n\t\t\tforeach (Control c in Controls) {\n\t\t\t\tc.MouseMove -= ControlMouseMove;\n\t\t\t}\n\t\t\t\n\t\t\tif (control.ActiveTextAreaControl.VScrollBar != null) {\n\t\t\t\tcontrol.ActiveTextAreaControl.VScrollBar.ValueChanged -= new EventHandler(ParentFormLocationChanged);\n\t\t\t}\n\t\t\tif (control.ActiveTextAreaControl.HScrollBar != null) {\n\t\t\t\tcontrol.ActiveTextAreaControl.HScrollBar.ValueChanged -= new EventHandler(ParentFormLocationChanged);\n\t\t\t}\n\t\t\t\n\t\t\tcontrol.ActiveTextAreaControl.TextArea.LostFocus          -= new EventHandler(this.TextEditorLostFocus);\n\t\t\tcontrol.ActiveTextAreaControl.Caret.PositionChanged       -= new EventHandler(CaretOffsetChanged);\n\t\t\tcontrol.ActiveTextAreaControl.TextArea.DoProcessDialogKey -= new DialogKeyProcessor(ProcessTextAreaKey);\n\t\t\tcontrol.Resize -= new EventHandler(ParentFormLocationChanged);\n\t\t\tDispose();\n\t\t}\n\t\t\n\t\tprotected override void OnMouseMove(MouseEventArgs e)\n\t\t{\n\t\t\tbase.OnMouseMove(e);\n\t\t\tControlMouseMove(this, e);\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Invoked when the mouse moves over this form or any child control.\n\t\t/// Shows the mouse cursor on the text area if it has been hidden.\n\t\t/// </summary>\n\t\t/// <remarks>\n\t\t/// Derived classes should attach this handler to the MouseMove event\n\t\t/// of all created controls which are not added to the Controls\n\t\t/// collection.\n\t\t/// </remarks>\n\t\tprotected void ControlMouseMove(object sender, MouseEventArgs e)\n\t\t{\n\t\t\tcontrol.ActiveTextAreaControl.TextArea.ShowHiddenCursor(false);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Gui/CompletionWindow/CodeCompletionListView.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 2932 $</version>\n// </file>\n\nusing System;\nusing System.Drawing;\nusing System.Windows.Forms;\n\nnamespace ICSharpCode.TextEditor.Gui.CompletionWindow\n{\n\t/// <summary>\n\t/// Description of CodeCompletionListView.\n\t/// </summary>\n\tpublic class CodeCompletionListView : System.Windows.Forms.UserControl\n\t{\n\t\tICompletionData[] completionData;\n\t\tint               firstItem    = 0;\n\t\tint               selectedItem = -1;\n\t\tImageList         imageList;\n\t\t\n\t\tpublic ImageList ImageList {\n\t\t\tget {\n\t\t\t\treturn imageList;\n\t\t\t}\n\t\t\tset {\n\t\t\t\timageList = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int FirstItem {\n\t\t\tget {\n\t\t\t\treturn firstItem;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tif (firstItem != value) {\n\t\t\t\t\tfirstItem = value;\n\t\t\t\t\tOnFirstItemChanged(EventArgs.Empty);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic ICompletionData SelectedCompletionData {\n\t\t\tget {\n\t\t\t\tif (selectedItem < 0) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t\treturn completionData[selectedItem];\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int ItemHeight {\n\t\t\tget {\n\t\t\t\treturn Math.Max(imageList.ImageSize.Height, (int)(Font.Height * 1.25));\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int MaxVisibleItem {\n\t\t\tget {\n\t\t\t\treturn Height / ItemHeight;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic CodeCompletionListView(ICompletionData[] completionData)\n\t\t{\n\t\t\tArray.Sort(completionData, DefaultCompletionData.Compare);\n\t\t\tthis.completionData = completionData;\n\t\t\t\n//\t\t\tthis.KeyDown += new System.Windows.Forms.KeyEventHandler(OnKey);\n//\t\t\tSetStyle(ControlStyles.Selectable, false);\n//\t\t\tSetStyle(ControlStyles.UserPaint, true);\n//\t\t\tSetStyle(ControlStyles.DoubleBuffer, false);\n\t\t}\n\t\t\n\t\tpublic void Close()\n\t\t{\n\t\t\tif (completionData != null) {\n\t\t\t\tArray.Clear(completionData, 0, completionData.Length);\n\t\t\t}\n\t\t\tbase.Dispose();\n\t\t}\n\t\t\n\t\tpublic void SelectIndex(int index)\n\t\t{\n\t\t\tint oldSelectedItem = selectedItem;\n\t\t\tint oldFirstItem    = firstItem;\n\t\t\t\n\t\t\tindex = Math.Max(0, index);\n\t\t\tselectedItem = Math.Max(0, Math.Min(completionData.Length - 1, index));\n\t\t\tif (selectedItem < firstItem) {\n\t\t\t\tFirstItem = selectedItem;\n\t\t\t}\n\t\t\tif (firstItem + MaxVisibleItem <= selectedItem) {\n\t\t\t\tFirstItem = selectedItem - MaxVisibleItem + 1;\n\t\t\t}\n\t\t\tif (oldSelectedItem != selectedItem) {\n\t\t\t\tif (firstItem != oldFirstItem) {\n\t\t\t\t\tInvalidate();\n\t\t\t\t} else {\n\t\t\t\t\tint min = Math.Min(selectedItem, oldSelectedItem) - firstItem;\n\t\t\t\t\tint max = Math.Max(selectedItem, oldSelectedItem) - firstItem;\n\t\t\t\t\tInvalidate(new Rectangle(0, 1 + min * ItemHeight, Width, (max - min + 1) * ItemHeight));\n\t\t\t\t}\n\t\t\t\tOnSelectedItemChanged(EventArgs.Empty);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic void CenterViewOn(int index)\n\t\t{\n\t\t\tint oldFirstItem = this.FirstItem;\n\t\t\tint firstItem = index - MaxVisibleItem / 2;\n\t\t\tif (firstItem < 0)\n\t\t\t\tthis.FirstItem = 0;\n\t\t\telse if (firstItem >= completionData.Length - MaxVisibleItem)\n\t\t\t\tthis.FirstItem = completionData.Length - MaxVisibleItem;\n\t\t\telse\n\t\t\t\tthis.FirstItem = firstItem;\n\t\t\tif (this.FirstItem != oldFirstItem) {\n\t\t\t\tInvalidate();\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic void ClearSelection()\n\t\t{\n\t\t\tif (selectedItem < 0)\n\t\t\t\treturn;\n\t\t\tint itemNum = selectedItem - firstItem;\n\t\t\tselectedItem = -1;\n\t\t\tInvalidate(new Rectangle(0, itemNum * ItemHeight, Width, (itemNum + 1) * ItemHeight + 1));\n\t\t\tUpdate();\n\t\t\tOnSelectedItemChanged(EventArgs.Empty);\n\t\t}\n\t\t\n\t\tpublic void PageDown()\n\t\t{\n\t\t\tSelectIndex(selectedItem + MaxVisibleItem);\n\t\t}\n\t\t\n\t\tpublic void PageUp()\n\t\t{\n\t\t\tSelectIndex(selectedItem - MaxVisibleItem);\n\t\t}\n\t\t\n\t\tpublic void SelectNextItem()\n\t\t{\n\t\t\tSelectIndex(selectedItem + 1);\n\t\t}\n\t\t\n\t\tpublic void SelectPrevItem()\n\t\t{\n\t\t\tSelectIndex(selectedItem - 1);\n\t\t}\n\t\t\n\t\tpublic void SelectItemWithStart(string startText)\n\t\t{\n\t\t\tif (startText == null || startText.Length == 0) return;\n\t\t\tstring originalStartText = startText;\n\t\t\tstartText = startText.ToLower();\n\t\t\tint bestIndex = -1;\n\t\t\tint bestQuality = -1;\n\t\t\t// Qualities: 0 = match start\n\t\t\t//            1 = match start case sensitive\n\t\t\t//            2 = full match\n\t\t\t//            3 = full match case sensitive\n\t\t\tdouble bestPriority = 0;\n\t\t\tfor (int i = 0; i < completionData.Length; ++i) {\n\t\t\t\tstring itemText = completionData[i].Text;\n\t\t\t\tstring lowerText = itemText.ToLower();\n\t\t\t\tif (lowerText.StartsWith(startText)) {\n\t\t\t\t\tdouble priority = completionData[i].Priority;\n\t\t\t\t\tint quality;\n\t\t\t\t\tif (lowerText == startText) {\n\t\t\t\t\t\tif (itemText == originalStartText)\n\t\t\t\t\t\t\tquality = 3;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tquality = 2;\n\t\t\t\t\t} else if (itemText.StartsWith(originalStartText)) {\n\t\t\t\t\t\tquality = 1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tquality = 0;\n\t\t\t\t\t}\n\t\t\t\t\tbool useThisItem;\n\t\t\t\t\tif (bestQuality < quality) {\n\t\t\t\t\t\tuseThisItem = true;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (bestIndex == selectedItem) {\n\t\t\t\t\t\t\tuseThisItem = false;\n\t\t\t\t\t\t} else if (i == selectedItem) {\n\t\t\t\t\t\t\tuseThisItem = bestQuality == quality;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tuseThisItem = bestQuality == quality && bestPriority < priority;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (useThisItem) {\n\t\t\t\t\t\tbestIndex = i;\n\t\t\t\t\t\tbestPriority = priority;\n\t\t\t\t\t\tbestQuality = quality;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (bestIndex < 0) {\n\t\t\t\tClearSelection();\n\t\t\t} else {\n\t\t\t\tif (bestIndex < firstItem || firstItem + MaxVisibleItem <= bestIndex) {\n\t\t\t\t\tSelectIndex(bestIndex);\n\t\t\t\t\tCenterViewOn(bestIndex);\n\t\t\t\t} else {\n\t\t\t\t\tSelectIndex(bestIndex);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tprotected override void OnPaint(PaintEventArgs pe)\n\t\t{\n\t\t\tfloat yPos       = 1;\n\t\t\tfloat itemHeight = ItemHeight;\n\t\t\t// Maintain aspect ratio\n\t\t\tint imageWidth = (int)(itemHeight * imageList.ImageSize.Width / imageList.ImageSize.Height);\n\t\t\t\n\t\t\tint curItem = firstItem;\n\t\t\tGraphics g  = pe.Graphics;\n\t\t\twhile (curItem < completionData.Length && yPos < Height) {\n\t\t\t\tRectangleF drawingBackground = new RectangleF(1, yPos, Width - 2, itemHeight);\n\t\t\t\tif (drawingBackground.IntersectsWith(pe.ClipRectangle)) {\n\t\t\t\t\t// draw Background\n\t\t\t\t\tif (curItem == selectedItem) {\n\t\t\t\t\t\tg.FillRectangle(SystemBrushes.Highlight, drawingBackground);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tg.FillRectangle(SystemBrushes.Window, drawingBackground);\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t// draw Icon\n\t\t\t\t\tint   xPos   = 0;\n\t\t\t\t\tif (imageList != null && completionData[curItem].ImageIndex < imageList.Images.Count) {\n\t\t\t\t\t\tg.DrawImage(imageList.Images[completionData[curItem].ImageIndex], new RectangleF(1, yPos, imageWidth, itemHeight));\n\t\t\t\t\t\txPos = imageWidth;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t// draw text\n\t\t\t\t\tif (curItem == selectedItem) {\n\t\t\t\t\t\tg.DrawString(completionData[curItem].Text, Font, SystemBrushes.HighlightText, xPos, yPos);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tg.DrawString(completionData[curItem].Text, Font, SystemBrushes.WindowText, xPos, yPos);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tyPos += itemHeight;\n\t\t\t\t++curItem;\n\t\t\t}\n\t\t\tg.DrawRectangle(SystemPens.Control, new Rectangle(0, 0, Width - 1, Height - 1));\n\t\t}\n\t\t\n\t\tprotected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)\n\t\t{\n\t\t\tfloat yPos       = 1;\n\t\t\tint curItem = firstItem;\n\t\t\tfloat itemHeight = ItemHeight;\n\t\t\t\n\t\t\twhile (curItem < completionData.Length && yPos < Height) {\n\t\t\t\tRectangleF drawingBackground = new RectangleF(1, yPos, Width - 2, itemHeight);\n\t\t\t\tif (drawingBackground.Contains(e.X, e.Y)) {\n\t\t\t\t\tSelectIndex(curItem);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tyPos += itemHeight;\n\t\t\t\t++curItem;\n\t\t\t}\n\t\t}\n\t\t\n\t\tprotected override void OnPaintBackground(PaintEventArgs pe)\n\t\t{\n\t\t}\n\t\t\n\t\tprotected virtual void OnSelectedItemChanged(EventArgs e)\n\t\t{\n\t\t\tif (SelectedItemChanged != null) {\n\t\t\t\tSelectedItemChanged(this, e);\n\t\t\t}\n\t\t}\n\t\t\n\t\tprotected virtual void OnFirstItemChanged(EventArgs e)\n\t\t{\n\t\t\tif (FirstItemChanged != null) {\n\t\t\t\tFirstItemChanged(this, e);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic event EventHandler SelectedItemChanged;\n\t\tpublic event EventHandler FirstItemChanged;\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Gui/CompletionWindow/CodeCompletionWindow.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 3244 $</version>\n// </file>\n\nusing System;\nusing System.Drawing;\nusing System.Diagnostics;\nusing System.Windows.Forms;\nusing ICSharpCode.TextEditor.Document;\n\nnamespace ICSharpCode.TextEditor.Gui.CompletionWindow\n{\n\tpublic class CodeCompletionWindow : AbstractCompletionWindow\n\t{\n\t\tICompletionData[] completionData;\n\t\tCodeCompletionListView codeCompletionListView;\n\t\tVScrollBar vScrollBar = new VScrollBar();\n\t\tICompletionDataProvider dataProvider;\n\t\tIDocument document;\n\t\tbool showDeclarationWindow = true;\n\t\tbool fixedListViewWidth = true;\n\t\tconst int ScrollbarWidth = 16;\n\t\tconst int MaxListLength = 10;\n\n\t\tint startOffset;\n\t\tint endOffset;\n\t\tDeclarationViewWindow declarationViewWindow = null;\n\t\tRectangle workingScreen;\n\t\t\n\t\tpublic static CodeCompletionWindow ShowCompletionWindow(Form parent, TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider, char firstChar)\n\t\t{\n\t\t\treturn ShowCompletionWindow(parent, control, fileName, completionDataProvider, firstChar, true, true);\n\t\t}\n\t\t\n\t\tpublic static CodeCompletionWindow ShowCompletionWindow(Form parent, TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider, char firstChar, bool showDeclarationWindow, bool fixedListViewWidth)\n\t\t{\n\t\t\tICompletionData[] completionData = completionDataProvider.GenerateCompletionData(fileName, control.ActiveTextAreaControl.TextArea, firstChar);\n\t\t\tif (completionData == null || completionData.Length == 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tCodeCompletionWindow codeCompletionWindow = new CodeCompletionWindow(completionDataProvider, completionData, parent, control, showDeclarationWindow, fixedListViewWidth);\n\t\t\tcodeCompletionWindow.CloseWhenCaretAtBeginning = firstChar == '\\0';\n\t\t\tcodeCompletionWindow.ShowCompletionWindow();\n\t\t\treturn codeCompletionWindow;\n\t\t}\n\t\t\n\t\tCodeCompletionWindow(ICompletionDataProvider completionDataProvider, ICompletionData[] completionData, Form parentForm, TextEditorControl control, bool showDeclarationWindow, bool fixedListViewWidth) : base(parentForm, control)\n\t\t{\n\t\t\tthis.dataProvider = completionDataProvider;\n\t\t\tthis.completionData = completionData;\n\t\t\tthis.document = control.Document;\n\t\t\tthis.showDeclarationWindow = showDeclarationWindow;\n\t\t\tthis.fixedListViewWidth = fixedListViewWidth;\n\n\t\t\tworkingScreen = Screen.GetWorkingArea(Location);\n\t\t\tstartOffset = control.ActiveTextAreaControl.Caret.Offset + 1;\n\t\t\tendOffset   = startOffset;\n\t\t\tif (completionDataProvider.PreSelection != null) {\n\t\t\t\tstartOffset -= completionDataProvider.PreSelection.Length + 1;\n\t\t\t\tendOffset--;\n\t\t\t}\n\t\t\t\n\t\t\tcodeCompletionListView = new CodeCompletionListView(completionData);\n\t\t\tcodeCompletionListView.ImageList = completionDataProvider.ImageList;\n\t\t\tcodeCompletionListView.Dock = DockStyle.Fill;\n\t\t\tcodeCompletionListView.SelectedItemChanged += new EventHandler(CodeCompletionListViewSelectedItemChanged);\n\t\t\tcodeCompletionListView.DoubleClick += new EventHandler(CodeCompletionListViewDoubleClick);\n\t\t\tcodeCompletionListView.Click  += new EventHandler(CodeCompletionListViewClick);\n\t\t\tControls.Add(codeCompletionListView);\n\t\t\t\n\t\t\tif (completionData.Length > MaxListLength) {\n\t\t\t\tvScrollBar.Dock = DockStyle.Right;\n\t\t\t\tvScrollBar.Minimum = 0;\n\t\t\t\tvScrollBar.Maximum = completionData.Length - 1;\n\t\t\t\tvScrollBar.SmallChange = 1;\n\t\t\t\tvScrollBar.LargeChange = MaxListLength;\n\t\t\t\tcodeCompletionListView.FirstItemChanged += new EventHandler(CodeCompletionListViewFirstItemChanged);\n\t\t\t\tControls.Add(vScrollBar);\n\t\t\t}\n\t\t\t\n\t\t\tthis.drawingSize = GetListViewSize();\n\t\t\tSetLocation();\n\t\t\t\n\t\t\tif (declarationViewWindow == null) {\n\t\t\t\tdeclarationViewWindow = new DeclarationViewWindow(parentForm);\n\t\t\t}\n\t\t\tSetDeclarationViewLocation();\n\t\t\tdeclarationViewWindow.ShowDeclarationViewWindow();\n\t\t\tdeclarationViewWindow.MouseMove += ControlMouseMove;\n\t\t\tcontrol.Focus();\n\t\t\tCodeCompletionListViewSelectedItemChanged(this, EventArgs.Empty);\n\t\t\t\n\t\t\tif (completionDataProvider.DefaultIndex >= 0) {\n\t\t\t\tcodeCompletionListView.SelectIndex(completionDataProvider.DefaultIndex);\n\t\t\t}\n\t\t\t\n\t\t\tif (completionDataProvider.PreSelection != null) {\n\t\t\t\tCaretOffsetChanged(this, EventArgs.Empty);\n\t\t\t}\n\t\t\t\n\t\t\tvScrollBar.ValueChanged += VScrollBarValueChanged;\n\t\t\tdocument.DocumentAboutToBeChanged += DocumentAboutToBeChanged;\n\t\t}\n\t\t\n\t\tbool inScrollUpdate;\n\t\t\n\t\tvoid CodeCompletionListViewFirstItemChanged(object sender, EventArgs e)\n\t\t{\n\t\t\tif (inScrollUpdate) return;\n\t\t\tinScrollUpdate = true;\n\t\t\tvScrollBar.Value = Math.Min(vScrollBar.Maximum, codeCompletionListView.FirstItem);\n\t\t\tinScrollUpdate = false;\n\t\t}\n\t\t\n\t\tvoid VScrollBarValueChanged(object sender, EventArgs e)\n\t\t{\n\t\t\tif (inScrollUpdate) return;\n\t\t\tinScrollUpdate = true;\n\t\t\tcodeCompletionListView.FirstItem = vScrollBar.Value;\n\t\t\tcodeCompletionListView.Refresh();\n\t\t\tcontrol.ActiveTextAreaControl.TextArea.Focus();\n\t\t\tinScrollUpdate = false;\n\t\t}\n\t\t\n\t\tvoid SetDeclarationViewLocation()\n\t\t{\n\t\t\t//  This method uses the side with more free space\n\t\t\tint leftSpace = Bounds.Left - workingScreen.Left;\n\t\t\tint rightSpace = workingScreen.Right - Bounds.Right;\n\t\t\tPoint pos;\n\t\t\t// The declaration view window has better line break when used on\n\t\t\t// the right side, so prefer the right side to the left.\n\t\t\tif (rightSpace * 2 > leftSpace)\n\t\t\t\tpos = new Point(Bounds.Right, Bounds.Top);\n\t\t\telse\n\t\t\t\tpos = new Point(Bounds.Left - declarationViewWindow.Width, Bounds.Top);\n\t\t\tif (declarationViewWindow.Location != pos) {\n\t\t\t\tdeclarationViewWindow.Location = pos;\n\t\t\t}\n\t\t}\n\t\t\n\t\tprotected override void SetLocation()\n\t\t{\n\t\t\tbase.SetLocation();\n\t\t\tif (declarationViewWindow != null) {\n\t\t\t\tSetDeclarationViewLocation();\n\t\t\t}\n\t\t}\n\t\t\n\t\tUtil.MouseWheelHandler mouseWheelHandler = new Util.MouseWheelHandler();\n\t\t\n\t\tpublic void HandleMouseWheel(MouseEventArgs e)\n\t\t{\n\t\t\tint scrollDistance = mouseWheelHandler.GetScrollAmount(e);\n\t\t\tif (scrollDistance == 0)\n\t\t\t\treturn;\n\t\t\tif (control.TextEditorProperties.MouseWheelScrollDown)\n\t\t\t\tscrollDistance = -scrollDistance;\n\t\t\tint newValue = vScrollBar.Value + vScrollBar.SmallChange * scrollDistance;\n\t\t\tvScrollBar.Value = Math.Max(vScrollBar.Minimum, Math.Min(vScrollBar.Maximum - vScrollBar.LargeChange + 1, newValue));\n\t\t}\n\n\t\tvoid CodeCompletionListViewSelectedItemChanged(object sender, EventArgs e)\n\t\t{\n\t\t\tICompletionData data = codeCompletionListView.SelectedCompletionData;\n\t\t\tif (showDeclarationWindow && data != null && data.Description != null && data.Description.Length > 0) {\n\t\t\t\tdeclarationViewWindow.Description = data.Description;\n\t\t\t\tSetDeclarationViewLocation();\n\t\t\t} else {\n\t\t\t\tdeclarationViewWindow.Description = null;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic override bool ProcessKeyEvent(char ch)\n\t\t{\n\t\t\tswitch (dataProvider.ProcessKey(ch)) {\n\t\t\t\tcase CompletionDataProviderKeyResult.BeforeStartKey:\n\t\t\t\t\t// increment start+end, then process as normal char\n\t\t\t\t\t++startOffset;\n\t\t\t\t\t++endOffset;\n\t\t\t\t\treturn base.ProcessKeyEvent(ch);\n\t\t\t\tcase CompletionDataProviderKeyResult.NormalKey:\n\t\t\t\t\t// just process normally\n\t\t\t\t\treturn base.ProcessKeyEvent(ch);\n\t\t\t\tcase CompletionDataProviderKeyResult.InsertionKey:\n\t\t\t\t\treturn InsertSelectedItem(ch);\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new InvalidOperationException(\"Invalid return value of dataProvider.ProcessKey\");\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid DocumentAboutToBeChanged(object sender, DocumentEventArgs e)\n\t\t{\n\t\t\t// => startOffset test required so that this startOffset/endOffset are not incremented again\n\t\t\t//    for BeforeStartKey characters\n\t\t\tif (e.Offset >= startOffset && e.Offset <= endOffset) {\n\t\t\t\tif (e.Length > 0) { // length of removed region\n\t\t\t\t\tendOffset -= e.Length;\n\t\t\t\t}\n\t\t\t\tif (!string.IsNullOrEmpty(e.Text)) {\n\t\t\t\t\tendOffset += e.Text.Length;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// When this flag is set, code completion closes if the caret moves to the\n\t\t/// beginning of the allowed range. This is useful in Ctrl+Space and \"complete when typing\",\n\t\t/// but not in dot-completion.\n\t\t/// </summary>\n\t\tpublic bool CloseWhenCaretAtBeginning { get; set; }\n\t\t\n\t\tprotected override void CaretOffsetChanged(object sender, EventArgs e)\n\t\t{\n\t\t\tint offset = control.ActiveTextAreaControl.Caret.Offset;\n\t\t\tif (offset == startOffset) {\n\t\t\t\tif (CloseWhenCaretAtBeginning)\n\t\t\t\t\tClose();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (offset < startOffset || offset > endOffset) {\n\t\t\t\tClose();\n\t\t\t} else {\n\t\t\t\tcodeCompletionListView.SelectItemWithStart(control.Document.GetText(startOffset, offset - startOffset));\n\t\t\t}\n\t\t}\n\t\t\n\t\tprotected override bool ProcessTextAreaKey(Keys keyData)\n\t\t{\n\t\t\tif (!Visible) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\t\n\t\t\tswitch (keyData) {\n\t\t\t\tcase Keys.Home:\n\t\t\t\t\tcodeCompletionListView.SelectIndex(0);\n\t\t\t\t\treturn true;\n\t\t\t\tcase Keys.End:\n\t\t\t\t\tcodeCompletionListView.SelectIndex(completionData.Length-1);\n\t\t\t\t\treturn true;\n\t\t\t\tcase Keys.PageDown:\n\t\t\t\t\tcodeCompletionListView.PageDown();\n\t\t\t\t\treturn true;\n\t\t\t\tcase Keys.PageUp:\n\t\t\t\t\tcodeCompletionListView.PageUp();\n\t\t\t\t\treturn true;\n\t\t\t\tcase Keys.Down:\n\t\t\t\t\tcodeCompletionListView.SelectNextItem();\n\t\t\t\t\treturn true;\n\t\t\t\tcase Keys.Up:\n\t\t\t\t\tcodeCompletionListView.SelectPrevItem();\n\t\t\t\t\treturn true;\n\t\t\t\tcase Keys.Tab:\n\t\t\t\t\tInsertSelectedItem('\\t');\n\t\t\t\t\treturn true;\n\t\t\t\tcase Keys.Return:\n\t\t\t\t\tInsertSelectedItem('\\n');\n\t\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn base.ProcessTextAreaKey(keyData);\n\t\t}\n\t\t\n\t\tvoid CodeCompletionListViewDoubleClick(object sender, EventArgs e)\n\t\t{\n\t\t\tInsertSelectedItem('\\0');\n\t\t}\n\t\t\n\t\tvoid CodeCompletionListViewClick(object sender, EventArgs e)\n\t\t{\n\t\t\tcontrol.ActiveTextAreaControl.TextArea.Focus();\n\t\t}\n\t\t\n\t\tprotected override void Dispose(bool disposing)\n\t\t{\n\t\t\tif (disposing) {\n\t\t\t\tdocument.DocumentAboutToBeChanged -= DocumentAboutToBeChanged;\n\t\t\t\tif (codeCompletionListView != null) {\n\t\t\t\t\tcodeCompletionListView.Dispose();\n\t\t\t\t\tcodeCompletionListView = null;\n\t\t\t\t}\n\t\t\t\tif (declarationViewWindow != null) {\n\t\t\t\t\tdeclarationViewWindow.Dispose();\n\t\t\t\t\tdeclarationViewWindow = null;\n\t\t\t\t}\n\t\t\t}\n\t\t\tbase.Dispose(disposing);\n\t\t}\n\t\t\n\t\tbool InsertSelectedItem(char ch)\n\t\t{\n\t\t\tdocument.DocumentAboutToBeChanged -= DocumentAboutToBeChanged;\n\t\t\tICompletionData data = codeCompletionListView.SelectedCompletionData;\n\t\t\tbool result = false;\n\t\t\tif (data != null) {\n\t\t\t\tcontrol.BeginUpdate();\n\t\t\t\t\n\t\t\t\ttry {\n\t\t\t\t\tif (endOffset - startOffset > 0) {\n\t\t\t\t\t\tcontrol.Document.Remove(startOffset, endOffset - startOffset);\n\t\t\t\t\t}\n\t\t\t\t\tDebug.Assert(startOffset <= document.TextLength);\n\t\t\t\t\tresult = dataProvider.InsertAction(data, control.ActiveTextAreaControl.TextArea, startOffset, ch);\n\t\t\t\t} finally {\n\t\t\t\t\tcontrol.EndUpdate();\n\t\t\t\t}\n\t\t\t}\n\t\t\tClose();\n\t\t\treturn result;\n\t\t}\n\t\t\n\t\tSize GetListViewSize()\n\t\t{\n\t\t\tint height = codeCompletionListView.ItemHeight * Math.Min(MaxListLength, completionData.Length);\n\t\t\tint width = codeCompletionListView.ItemHeight * 10;\n\t\t\tif (!fixedListViewWidth) {\n\t\t\t\twidth = GetListViewWidth(width, height);\n\t\t\t}\n\t\t\treturn new Size(width, height);\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Gets the list view width large enough to handle the longest completion data\n\t\t/// text string.\n\t\t/// </summary>\n\t\t/// <param name=\"defaultWidth\">The default width of the list view.</param>\n\t\t/// <param name=\"height\">The height of the list view.  This is\n\t\t/// used to determine if the scrollbar is visible.</param>\n\t\t/// <returns>The list view width to accommodate the longest completion\n\t\t/// data text string; otherwise the default width.</returns>\n\t\tint GetListViewWidth(int defaultWidth, int height)\n\t\t{\n\t\t\tfloat width = defaultWidth;\n\t\t\tusing (Graphics graphics = codeCompletionListView.CreateGraphics()) {\n\t\t\t\tfor (int i = 0; i < completionData.Length; ++i) {\n\t\t\t\t\tfloat itemWidth = graphics.MeasureString(completionData[i].Text.ToString(), codeCompletionListView.Font).Width;\n\t\t\t\t\tif(itemWidth > width) {\n\t\t\t\t\t\twidth = itemWidth;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tfloat totalItemsHeight = codeCompletionListView.ItemHeight * completionData.Length;\n\t\t\tif (totalItemsHeight > height) {\n\t\t\t\twidth += ScrollbarWidth; // Compensate for scroll bar.\n\t\t\t}\n\t\t\treturn (int)width;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Gui/CompletionWindow/DeclarationViewWindow.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 1965 $</version>\n// </file>\n\nusing System;\nusing System.Drawing;\nusing System.Windows.Forms;\n\nusing ICSharpCode.TextEditor.Util;\n\nnamespace ICSharpCode.TextEditor.Gui.CompletionWindow\n{\n\tpublic interface IDeclarationViewWindow\n\t{\n\t\tstring Description {\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\tvoid ShowDeclarationViewWindow();\n\t\tvoid CloseDeclarationViewWindow();\n\t}\n\t\n\tpublic class DeclarationViewWindow : Form, IDeclarationViewWindow\n\t{\n\t\tstring description = String.Empty;\n\t\t\n\t\tpublic string Description {\n\t\t\tget {\n\t\t\t\treturn description;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tdescription = value;\n\t\t\t\tif (value == null && Visible) {\n\t\t\t\t\tVisible = false;\n\t\t\t\t} else if (value != null) {\n\t\t\t\t\tif (!Visible) ShowDeclarationViewWindow();\n\t\t\t\t\tRefresh();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic bool HideOnClick;\n\t\t\n\t\tpublic DeclarationViewWindow(Form parent)\n\t\t{\n\t\t\tSetStyle(ControlStyles.Selectable, false);\n\t\t\tStartPosition   = FormStartPosition.Manual;\n\t\t\tFormBorderStyle = FormBorderStyle.None;\n\t\t\tOwner           = parent;\n\t\t\tShowInTaskbar   = false;\n\t\t\tSize            = new Size(0, 0);\n\t\t\tbase.CreateHandle();\n\t\t}\n\t\t\n\t\tprotected override CreateParams CreateParams {\n\t\t\tget {\n\t\t\t\tCreateParams p = base.CreateParams;\n\t\t\t\tAbstractCompletionWindow.AddShadowToWindow(p);\n\t\t\t\treturn p;\n\t\t\t}\n\t\t}\n\t\t\n\t\tprotected override bool ShowWithoutActivation {\n\t\t\tget {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\t\n\t\tprotected override void OnClick(EventArgs e)\n\t\t{\n\t\t\tbase.OnClick(e);\n\t\t\tif (HideOnClick) Hide();\n\t\t}\n\t\t\n\t\tpublic void ShowDeclarationViewWindow()\n\t\t{\n\t\t\tShow();\n\t\t}\n\t\t\n\t\tpublic void CloseDeclarationViewWindow()\n\t\t{\n\t\t\tClose();\n\t\t\tDispose();\n\t\t}\n\t\t\n\t\tprotected override void OnPaint(PaintEventArgs pe)\n\t\t{\n\t\t\tif (description != null && description.Length > 0) {\n\t\t\t\tTipPainterTools.DrawHelpTipFromCombinedDescription(this, pe.Graphics, Font, null, description);\n\t\t\t}\n\t\t}\n\t\t\n\t\tprotected override void OnPaintBackground(PaintEventArgs pe)\n\t\t{\n\t\t\tpe.Graphics.FillRectangle(SystemBrushes.Info, pe.ClipRectangle);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Gui/CompletionWindow/ICompletionData.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 2932 $</version>\n// </file>\n\nusing System;\n\nnamespace ICSharpCode.TextEditor.Gui.CompletionWindow\n{\n\tpublic interface ICompletionData\n\t{\n\t\tint ImageIndex {\n\t\t\tget;\n\t\t}\n\t\t\n\t\tstring Text {\n\t\t\tget;\n\t\t\tset;\n\t\t}\n\t\t\n\t\tstring Description {\n\t\t\tget;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Gets a priority value for the completion data item.\n\t\t/// When selecting items by their start characters, the item with the highest\n\t\t/// priority is selected first.\n\t\t/// </summary>\n\t\tdouble Priority {\n\t\t\tget;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Insert the element represented by the completion data into the text\n\t\t/// editor.\n\t\t/// </summary>\n\t\t/// <param name=\"textArea\">TextArea to insert the completion data in.</param>\n\t\t/// <param name=\"ch\">Character that should be inserted after the completion data.\n\t\t/// \\0 when no character should be inserted.</param>\n\t\t/// <returns>Returns true when the insert action has processed the character\n\t\t/// <paramref name=\"ch\"/>; false when the character was not processed.</returns>\n\t\tbool InsertAction(TextArea textArea, char ch);\n\t}\n\t\n\tpublic class DefaultCompletionData : ICompletionData\n\t{\n\t\tstring text;\n\t\tstring description;\n\t\tint imageIndex;\n\t\t\n\t\tpublic int ImageIndex {\n\t\t\tget {\n\t\t\t\treturn imageIndex;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic string Text {\n\t\t\tget {\n\t\t\t\treturn text;\n\t\t\t}\n\t\t\tset {\n\t\t\t\ttext = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic string Description {\n\t\t\tget {\n\t\t\t\treturn description;\n\t\t\t}\n\t\t}\n\t\t\n\t\tdouble priority;\n\t\t\n\t\tpublic double Priority {\n\t\t\tget {\n\t\t\t\treturn priority;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tpriority = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic virtual bool InsertAction(TextArea textArea, char ch)\n\t\t{\n\t\t\ttextArea.InsertString(text);\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\tpublic DefaultCompletionData(string text, string description, int imageIndex)\n\t\t{\n\t\t\tthis.text        = text;\n\t\t\tthis.description = description;\n\t\t\tthis.imageIndex  = imageIndex;\n\t\t}\n\t\t\n\t\tpublic static int Compare(ICompletionData a, ICompletionData b)\n\t\t{\n\t\t\tif (a == null)\n\t\t\t\tthrow new ArgumentNullException(\"a\");\n\t\t\tif (b == null)\n\t\t\t\tthrow new ArgumentNullException(\"b\");\n\t\t\treturn string.Compare(a.Text, b.Text, StringComparison.InvariantCultureIgnoreCase);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Gui/CompletionWindow/ICompletionDataProvider.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 2074 $</version>\n// </file>\n\nusing System;\nusing System.Windows.Forms;\n\nnamespace ICSharpCode.TextEditor.Gui.CompletionWindow\n{\n\tpublic interface ICompletionDataProvider\n\t{\n\t\tImageList ImageList {\n\t\t\tget;\n\t\t}\n\t\tstring PreSelection {\n\t\t\tget;\n\t\t}\n\t\t/// <summary>\n\t\t/// Gets the index of the element in the list that is chosen by default.\n\t\t/// </summary>\n\t\tint DefaultIndex {\n\t\t\tget;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Processes a keypress. Returns the action to be run with the key.\n\t\t/// </summary>\n\t\tCompletionDataProviderKeyResult ProcessKey(char key);\n\t\t\n\t\t/// <summary>\n\t\t/// Executes the insertion. The provider should set the caret position and then\n\t\t/// call data.InsertAction.\n\t\t/// </summary>\n\t\tbool InsertAction(ICompletionData data, TextArea textArea, int insertionOffset, char key);\n\t\t\n\t\t/// <summary>\n\t\t/// Generates the completion data. This method is called by the text editor control.\n\t\t/// </summary>\n\t\tICompletionData[] GenerateCompletionData(string fileName, TextArea textArea, char charTyped);\n\t}\n\t\n\tpublic enum CompletionDataProviderKeyResult\n\t{\n\t\t/// <summary>\n\t\t/// Normal key, used to choose an entry from the completion list\n\t\t/// </summary>\n\t\tNormalKey,\n\t\t/// <summary>\n\t\t/// This key triggers insertion of the completed expression\n\t\t/// </summary>\n\t\tInsertionKey,\n\t\t/// <summary>\n\t\t/// Increment both start and end offset of completion region when inserting this\n\t\t/// key. Can be used to insert whitespace (or other characters) in front of the expression\n\t\t/// while the completion window is open.\n\t\t/// </summary>\n\t\tBeforeStartKey\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Gui/DrawableLine.cs",
    "content": "// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Daniel Grunwald\" email=\"daniel@danielgrunwald.de\"/>\n//     <version>$Revision: 1965 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\nusing System.Drawing;\n\nusing ICSharpCode.TextEditor.Document;\n\nnamespace ICSharpCode.TextEditor\n{\n\t/// <summary>\n\t/// A class that is able to draw a line on any control (outside the text editor)\n\t/// </summary>\n\tpublic class DrawableLine\n\t{\n\t\tstatic StringFormat sf = (StringFormat)System.Drawing.StringFormat.GenericTypographic.Clone();\n\t\t\n\t\tList<SimpleTextWord> words = new List<SimpleTextWord>();\n\t\tSizeF spaceSize;\n\t\tFont monospacedFont;\n\t\tFont boldMonospacedFont;\n\t\t\n\t\tprivate class SimpleTextWord {\n\t\t\tinternal TextWordType Type;\n\t\t\tinternal string       Word;\n\t\t\tinternal bool         Bold;\n\t\t\tinternal Color        Color;\n\t\t\t\n\t\t\tpublic SimpleTextWord(TextWordType Type, string Word, bool Bold, Color Color)\n\t\t\t{\n\t\t\t\tthis.Type = Type;\n\t\t\t\tthis.Word = Word;\n\t\t\t\tthis.Bold = Bold;\n\t\t\t\tthis.Color = Color;\n\t\t\t}\n\t\t\t\n\t\t\tinternal readonly static SimpleTextWord Space = new SimpleTextWord(TextWordType.Space, \" \", false, Color.Black);\n\t\t\tinternal readonly static SimpleTextWord Tab = new SimpleTextWord(TextWordType.Tab, \"\\t\", false, Color.Black);\n\t\t}\n\t\t\n\t\tpublic DrawableLine(IDocument document, LineSegment line, Font monospacedFont, Font boldMonospacedFont)\n\t\t{\n\t\t\tthis.monospacedFont = monospacedFont;\n\t\t\tthis.boldMonospacedFont = boldMonospacedFont;\n\t\t\tif (line.Words != null) {\n\t\t\t\tforeach (TextWord word in line.Words) {\n\t\t\t\t\tif (word.Type == TextWordType.Space) {\n\t\t\t\t\t\twords.Add(SimpleTextWord.Space);\n\t\t\t\t\t} else if (word.Type == TextWordType.Tab) {\n\t\t\t\t\t\twords.Add(SimpleTextWord.Tab);\n\t\t\t\t\t} else {\n\t\t\t\t\t\twords.Add(new SimpleTextWord(TextWordType.Word, word.Word, word.Bold, word.Color));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\twords.Add(new SimpleTextWord(TextWordType.Word, document.GetText(line), false, Color.Black));\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int LineLength {\n\t\t\tget {\n\t\t\t\tint length = 0;\n\t\t\t\tforeach (SimpleTextWord word in words) {\n\t\t\t\t\tlength += word.Word.Length;\n\t\t\t\t}\n\t\t\t\treturn length;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic void SetBold(int startIndex, int endIndex, bool bold)\n\t\t{\n\t\t\tif (startIndex < 0)\n\t\t\t\tthrow new ArgumentException(\"startIndex must be >= 0\");\n\t\t\tif (startIndex > endIndex)\n\t\t\t\tthrow new ArgumentException(\"startIndex must be <= endIndex\");\n\t\t\tif (startIndex == endIndex) return;\n\t\t\tint pos = 0;\n\t\t\tfor (int i = 0; i < words.Count; i++) {\n\t\t\t\tSimpleTextWord word = words[i];\n\t\t\t\tif (pos >= endIndex)\n\t\t\t\t\tbreak;\n\t\t\t\tint wordEnd = pos + word.Word.Length;\n\t\t\t\t// 3 possibilities:\n\t\t\t\tif (startIndex <= pos && endIndex >= wordEnd) {\n\t\t\t\t\t// word is fully in region:\n\t\t\t\t\tword.Bold = bold;\n\t\t\t\t} else if (startIndex <= pos) {\n\t\t\t\t\t// beginning of word is in region\n\t\t\t\t\tint inRegionLength = endIndex - pos;\n\t\t\t\t\tSimpleTextWord newWord = new SimpleTextWord(word.Type, word.Word.Substring(inRegionLength), word.Bold, word.Color);\n\t\t\t\t\twords.Insert(i + 1, newWord);\n\t\t\t\t\t\n\t\t\t\t\tword.Bold = bold;\n\t\t\t\t\tword.Word = word.Word.Substring(0, inRegionLength);\n\t\t\t\t} else if (startIndex < wordEnd) {\n\t\t\t\t\t// end of word is in region (or middle of word is in region)\n\t\t\t\t\tint notInRegionLength = startIndex - pos;\n\t\t\t\t\t\n\t\t\t\t\tSimpleTextWord newWord = new SimpleTextWord(word.Type, word.Word.Substring(notInRegionLength), word.Bold, word.Color);\n\t\t\t\t\t// newWord.Bold will be set in the next iteration\n\t\t\t\t\twords.Insert(i + 1, newWord);\n\t\t\t\t\t\n\t\t\t\t\tword.Word = word.Word.Substring(0, notInRegionLength);\n\t\t\t\t}\n\t\t\t\tpos = wordEnd;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic static float DrawDocumentWord(Graphics g, string word, PointF position, Font font, Color foreColor)\n\t\t{\n\t\t\tif (word == null || word.Length == 0) {\n\t\t\t\treturn 0f;\n\t\t\t}\n\t\t\tSizeF wordSize = g.MeasureString(word, font, 32768, sf);\n\t\t\t\n\t\t\tg.DrawString(word,\n\t\t\t             font,\n\t\t\t             BrushRegistry.GetBrush(foreColor),\n\t\t\t             position,\n\t\t\t             sf);\n\t\t\treturn wordSize.Width;\n\t\t}\n\t\t\n\t\tpublic SizeF GetSpaceSize(Graphics g)\n\t\t{\n\t\t\tif (spaceSize.IsEmpty) {\n\t\t\t\tspaceSize = g.MeasureString(\"-\", boldMonospacedFont,  new PointF(0, 0), sf);\n\t\t\t}\n\t\t\treturn spaceSize;\n\t\t}\n\t\t\n\t\tpublic void DrawLine(Graphics g, ref float xPos, float xOffset, float yPos, Color c)\n\t\t{\n\t\t\tSizeF spaceSize = GetSpaceSize(g);\n\t\t\tforeach (SimpleTextWord word in words) {\n\t\t\t\tswitch (word.Type) {\n\t\t\t\t\tcase TextWordType.Space:\n\t\t\t\t\t\txPos += spaceSize.Width;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase TextWordType.Tab:\n\t\t\t\t\t\tfloat tabWidth = spaceSize.Width * 4;\n\t\t\t\t\t\txPos += tabWidth;\n\t\t\t\t\t\txPos = (int)((xPos + 2) / tabWidth) * tabWidth;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase TextWordType.Word:\n\t\t\t\t\t\txPos += DrawDocumentWord(g,\n\t\t\t\t\t\t                         word.Word,\n\t\t\t\t\t\t                         new PointF(xPos + xOffset, yPos),\n\t\t\t\t\t\t                         word.Bold ? boldMonospacedFont : monospacedFont,\n\t\t\t\t\t\t                         c == Color.Empty ? word.Color : c\n\t\t\t\t\t\t                        );\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic void DrawLine(Graphics g, ref float xPos, float xOffset, float yPos)\n\t\t{\n\t\t\tDrawLine(g, ref xPos, xOffset, yPos, Color.Empty);\n\t\t}\n\t\t\n\t\tpublic float MeasureWidth(Graphics g, float xPos)\n\t\t{\n\t\t\tSizeF spaceSize = GetSpaceSize(g);\n\t\t\tforeach (SimpleTextWord word in words) {\n\t\t\t\tswitch (word.Type) {\n\t\t\t\t\tcase TextWordType.Space:\n\t\t\t\t\t\txPos += spaceSize.Width;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase TextWordType.Tab:\n\t\t\t\t\t\tfloat tabWidth = spaceSize.Width * 4;\n\t\t\t\t\t\txPos += tabWidth;\n\t\t\t\t\t\txPos = (int)((xPos + 2) / tabWidth) * tabWidth;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase TextWordType.Word:\n\t\t\t\t\t\tif (word.Word != null && word.Word.Length > 0) {\n\t\t\t\t\t\t\txPos += g.MeasureString(word.Word, word.Bold ? boldMonospacedFont : monospacedFont, 32768, sf).Width;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn xPos;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Gui/FindReplaceForm/FindAndReplaceForm.Designer.cs",
    "content": "﻿namespace ICSharpCode.TextEditor\n{\n\tpartial class FindAndReplaceForm\n\t{\n\t\t/// <summary>\n\t\t/// Required designer variable.\n\t\t/// </summary>\n\t\tprivate System.ComponentModel.IContainer components = null;\n\n\t\t/// <summary>\n\t\t/// Clean up any resources being used.\n\t\t/// </summary>\n\t\t/// <param name=\"disposing\">true if managed resources should be disposed; otherwise, false.</param>\n\t\tprotected override void Dispose(bool disposing)\n\t\t{\n\t\t\tif (disposing && (components != null))\n\t\t\t{\n\t\t\t\tcomponents.Dispose();\n\t\t\t}\n\t\t\tbase.Dispose(disposing);\n\t\t}\n\n\t\t#region Windows Form Designer generated code\n\n\t\t/// <summary>\n\t\t/// Required method for Designer support - do not modify\n\t\t/// the contents of this method with the code editor.\n\t\t/// </summary>\n\t\tprivate void InitializeComponent()\n\t\t{\n            this.label1 = new System.Windows.Forms.Label();\n            this.lblReplaceWith = new System.Windows.Forms.Label();\n            this.txtLookFor = new System.Windows.Forms.TextBox();\n            this.txtReplaceWith = new System.Windows.Forms.TextBox();\n            this.btnFindNext = new System.Windows.Forms.Button();\n            this.btnReplace = new System.Windows.Forms.Button();\n            this.btnReplaceAll = new System.Windows.Forms.Button();\n            this.chkMatchWholeWord = new System.Windows.Forms.CheckBox();\n            this.chkMatchCase = new System.Windows.Forms.CheckBox();\n            this.btnHighlightAll = new System.Windows.Forms.Button();\n            this.btnCancel = new System.Windows.Forms.Button();\n            this.btnFindPrevious = new System.Windows.Forms.Button();\n            this.SuspendLayout();\n            // \n            // label1\n            // \n            this.label1.AutoSize = true;\n            this.label1.Location = new System.Drawing.Point(12, 9);\n            this.label1.Name = \"label1\";\n            this.label1.Size = new System.Drawing.Size(56, 13);\n            this.label1.TabIndex = 0;\n            this.label1.Text = \"Fi&nd what:\";\n            // \n            // lblReplaceWith\n            // \n            this.lblReplaceWith.AutoSize = true;\n            this.lblReplaceWith.Location = new System.Drawing.Point(12, 35);\n            this.lblReplaceWith.Name = \"lblReplaceWith\";\n            this.lblReplaceWith.Size = new System.Drawing.Size(72, 13);\n            this.lblReplaceWith.TabIndex = 2;\n            this.lblReplaceWith.Text = \"Re&place with:\";\n            // \n            // txtLookFor\n            // \n            this.txtLookFor.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) \n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.txtLookFor.Location = new System.Drawing.Point(90, 6);\n            this.txtLookFor.Name = \"txtLookFor\";\n            this.txtLookFor.Size = new System.Drawing.Size(232, 20);\n            this.txtLookFor.TabIndex = 1;\n            // \n            // txtReplaceWith\n            // \n            this.txtReplaceWith.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) \n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.txtReplaceWith.Location = new System.Drawing.Point(90, 32);\n            this.txtReplaceWith.Name = \"txtReplaceWith\";\n            this.txtReplaceWith.Size = new System.Drawing.Size(232, 20);\n            this.txtReplaceWith.TabIndex = 3;\n            // \n            // btnFindNext\n            // \n            this.btnFindNext.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));\n            this.btnFindNext.Location = new System.Drawing.Point(247, 81);\n            this.btnFindNext.Name = \"btnFindNext\";\n            this.btnFindNext.Size = new System.Drawing.Size(75, 23);\n            this.btnFindNext.TabIndex = 6;\n            this.btnFindNext.Text = \"&Find next\";\n            this.btnFindNext.UseVisualStyleBackColor = true;\n            this.btnFindNext.Click += new System.EventHandler(this.btnFindNext_Click);\n            // \n            // btnReplace\n            // \n            this.btnReplace.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));\n            this.btnReplace.Location = new System.Drawing.Point(85, 110);\n            this.btnReplace.Name = \"btnReplace\";\n            this.btnReplace.Size = new System.Drawing.Size(75, 23);\n            this.btnReplace.TabIndex = 7;\n            this.btnReplace.Text = \"&Replace\";\n            this.btnReplace.UseVisualStyleBackColor = true;\n            this.btnReplace.Click += new System.EventHandler(this.btnReplace_Click);\n            // \n            // btnReplaceAll\n            // \n            this.btnReplaceAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));\n            this.btnReplaceAll.Location = new System.Drawing.Point(166, 110);\n            this.btnReplaceAll.Name = \"btnReplaceAll\";\n            this.btnReplaceAll.Size = new System.Drawing.Size(75, 23);\n            this.btnReplaceAll.TabIndex = 9;\n            this.btnReplaceAll.Text = \"Replace &All\";\n            this.btnReplaceAll.UseVisualStyleBackColor = true;\n            this.btnReplaceAll.Click += new System.EventHandler(this.btnReplaceAll_Click);\n            // \n            // chkMatchWholeWord\n            // \n            this.chkMatchWholeWord.AutoSize = true;\n            this.chkMatchWholeWord.Location = new System.Drawing.Point(178, 58);\n            this.chkMatchWholeWord.Name = \"chkMatchWholeWord\";\n            this.chkMatchWholeWord.Size = new System.Drawing.Size(113, 17);\n            this.chkMatchWholeWord.TabIndex = 5;\n            this.chkMatchWholeWord.Text = \"Match &whole word\";\n            this.chkMatchWholeWord.UseVisualStyleBackColor = true;\n            // \n            // chkMatchCase\n            // \n            this.chkMatchCase.AutoSize = true;\n            this.chkMatchCase.Location = new System.Drawing.Point(90, 58);\n            this.chkMatchCase.Name = \"chkMatchCase\";\n            this.chkMatchCase.Size = new System.Drawing.Size(82, 17);\n            this.chkMatchCase.TabIndex = 4;\n            this.chkMatchCase.Text = \"Match &case\";\n            this.chkMatchCase.UseVisualStyleBackColor = true;\n            // \n            // btnHighlightAll\n            // \n            this.btnHighlightAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));\n            this.btnHighlightAll.Location = new System.Drawing.Point(105, 110);\n            this.btnHighlightAll.Name = \"btnHighlightAll\";\n            this.btnHighlightAll.Size = new System.Drawing.Size(136, 23);\n            this.btnHighlightAll.TabIndex = 8;\n            this.btnHighlightAll.Text = \"Find && highlight &all\";\n            this.btnHighlightAll.UseVisualStyleBackColor = true;\n            this.btnHighlightAll.Visible = false;\n            this.btnHighlightAll.Click += new System.EventHandler(this.btnHighlightAll_Click);\n            // \n            // btnCancel\n            // \n            this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));\n            this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;\n            this.btnCancel.Location = new System.Drawing.Point(247, 110);\n            this.btnCancel.Name = \"btnCancel\";\n            this.btnCancel.Size = new System.Drawing.Size(75, 23);\n            this.btnCancel.TabIndex = 6;\n            this.btnCancel.Text = \"Cancel\";\n            this.btnCancel.UseVisualStyleBackColor = true;\n            this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);\n            // \n            // btnFindPrevious\n            // \n            this.btnFindPrevious.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));\n            this.btnFindPrevious.Location = new System.Drawing.Point(157, 81);\n            this.btnFindPrevious.Name = \"btnFindPrevious\";\n            this.btnFindPrevious.Size = new System.Drawing.Size(84, 23);\n            this.btnFindPrevious.TabIndex = 6;\n            this.btnFindPrevious.Text = \"Find pre&vious\";\n            this.btnFindPrevious.UseVisualStyleBackColor = true;\n            this.btnFindPrevious.Click += new System.EventHandler(this.btnFindPrevious_Click);\n            // \n            // FindAndReplaceForm\n            // \n            this.AcceptButton = this.btnReplace;\n            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\n            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\n            this.CancelButton = this.btnCancel;\n            this.ClientSize = new System.Drawing.Size(334, 145);\n            this.Controls.Add(this.chkMatchCase);\n            this.Controls.Add(this.chkMatchWholeWord);\n            this.Controls.Add(this.btnReplaceAll);\n            this.Controls.Add(this.btnReplace);\n            this.Controls.Add(this.btnHighlightAll);\n            this.Controls.Add(this.btnCancel);\n            this.Controls.Add(this.btnFindPrevious);\n            this.Controls.Add(this.btnFindNext);\n            this.Controls.Add(this.txtReplaceWith);\n            this.Controls.Add(this.txtLookFor);\n            this.Controls.Add(this.lblReplaceWith);\n            this.Controls.Add(this.label1);\n            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;\n            this.MaximizeBox = false;\n            this.MinimizeBox = false;\n            this.Name = \"FindAndReplaceForm\";\n            this.ShowIcon = false;\n            this.Text = \"Find and replace\";\n            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FindAndReplaceForm_FormClosing);\n            this.ResumeLayout(false);\n            this.PerformLayout();\n\n\t\t}\n\n\t\t#endregion\n\n\t\tprivate System.Windows.Forms.Label label1;\n\t\tprivate System.Windows.Forms.Label lblReplaceWith;\n\t\tprivate System.Windows.Forms.TextBox txtLookFor;\n\t\tprivate System.Windows.Forms.TextBox txtReplaceWith;\n\t\tprivate System.Windows.Forms.Button btnFindNext;\n\t\tprivate System.Windows.Forms.Button btnReplace;\n\t\tprivate System.Windows.Forms.Button btnReplaceAll;\n\t\tprivate System.Windows.Forms.CheckBox chkMatchWholeWord;\n\t\tprivate System.Windows.Forms.CheckBox chkMatchCase;\n\t\tprivate System.Windows.Forms.Button btnHighlightAll;\n\t\tprivate System.Windows.Forms.Button btnCancel;\n\t\tprivate System.Windows.Forms.Button btnFindPrevious;\n\t}\n}"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Gui/FindReplaceForm/FindAndReplaceForm.cs",
    "content": "﻿\n// code stolen from https://www.codeproject.com/Articles/30936/Using-ICSharpCode-TextEditor\n// Merged into ICSharpCode by Josh Barczak for Pyramid\n\nusing System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Drawing;\nusing System.Text;\nusing System.Windows.Forms;\nusing ICSharpCode.TextEditor.Document;\nusing ICSharpCode.TextEditor;\nusing System.Diagnostics;\nusing System.IO;\n\nnamespace ICSharpCode.TextEditor\n{\n    \n\n\tpublic partial class FindAndReplaceForm : Form\n\t{\n        \n\t\tpublic FindAndReplaceForm()\n\t\t{\n\t\t\tInitializeComponent();\n\t\t\t_search = new TextEditorSearcher();\n\t\t}\n\n\t\tTextEditorSearcher _search;\n\t\tTextEditorControl _editor;\n\t\tTextEditorControl Editor { \n\t\t\tget { return _editor; } \n\t\t\tset { \n\t\t\t\t_editor = value;\n\t\t\t\t_search.Document = _editor.Document;\n\t\t\t\tUpdateTitleBar();\n\t\t\t}\n\t\t}\n\n\t\tprivate void UpdateTitleBar()\n\t\t{\n\t\t\tstring text = ReplaceMode ? \"Find & replace\" : \"Find\";\n\t\t\tif (_editor != null && _editor.FileName != null)\n\t\t\t\ttext += \" - \" + Path.GetFileName(_editor.FileName);\n\t\t\tif (_search.HasScanRegion)\n\t\t\t\ttext += \" (selection only)\";\n\t\t\tthis.Text = text;\n\t\t}\n\n\t\tpublic void ShowFor(TextEditorControl editor, bool replaceMode)\n\t\t{\n\t\t\tEditor = editor;\n\n\t\t\t_search.ClearScanRegion();\n\t\t\tvar sm = editor.ActiveTextAreaControl.SelectionManager;\n\t\t\tif (sm.HasSomethingSelected && sm.SelectionCollection.Count == 1) {\n\t\t\t\tvar sel = sm.SelectionCollection[0];\n\t\t\t\tif (sel.StartPosition.Line == sel.EndPosition.Line)\n\t\t\t\t\ttxtLookFor.Text = sm.SelectedText;\n\t\t\t\telse\n\t\t\t\t\t_search.SetScanRegion(sel);\n\t\t\t} else {\n\t\t\t\t// Get the current word that the caret is on\n\t\t\t\tCaret caret = editor.ActiveTextAreaControl.Caret;\n\t\t\t\tint start = TextUtilities.FindWordStart(editor.Document, caret.Offset);\n\t\t\t\tint endAt = TextUtilities.FindWordEnd(editor.Document, caret.Offset);\n\t\t\t\ttxtLookFor.Text = editor.Document.GetText(start, endAt - start);\n\t\t\t}\n\t\t\t\n\t\t\tReplaceMode = replaceMode;\n\n\t\t\tthis.Owner = (Form)editor.TopLevelControl;\n\t\t\tthis.Show();\n\t\t\t\n\t\t\ttxtLookFor.SelectAll();\n\t\t\ttxtLookFor.Focus();\n\t\t}\n\n\t\tpublic bool ReplaceMode\n\t\t{\n\t\t\tget { return txtReplaceWith.Visible; }\n\t\t\tset {\n\t\t\t\tbtnReplace.Visible = btnReplaceAll.Visible = value;\n\t\t\t\tlblReplaceWith.Visible = txtReplaceWith.Visible = value;\n\t\t\t\tbtnHighlightAll.Visible = !value;\n\t\t\t\tthis.AcceptButton = value ? btnReplace : btnFindNext;\n\t\t\t\tUpdateTitleBar();\n\t\t\t}\n\t\t}\n\n\t\tprivate void btnFindPrevious_Click(object sender, EventArgs e)\n\t\t{\n\t\t\tFindNext(false, true, \"Text not found\");\n\t\t}\n\t\tprivate void btnFindNext_Click(object sender, EventArgs e)\n\t\t{\n\t\t\tFindNext(false, false, \"Text not found\");\n\t\t}\n\n\t\tprivate bool _lastSearchWasBackward = false;\n        private bool _lastSearchLoopedAround;\n\n\t\tpublic TextRange FindNext(bool viaF3, bool searchBackward, string messageIfNotFound)\n\t\t{\n\t\t\tif (string.IsNullOrEmpty(txtLookFor.Text))\n\t\t\t{\n\t\t\t\tMessageBox.Show(\"No string specified to look for!\");\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\t_lastSearchWasBackward = searchBackward;\n\t\t\t_search.LookFor = txtLookFor.Text;\n\t\t\t_search.MatchCase = chkMatchCase.Checked;\n\t\t\t_search.MatchWholeWordOnly = chkMatchWholeWord.Checked;\n\n\t\t\tvar caret = _editor.ActiveTextAreaControl.Caret;\n\t\t\tif (viaF3 && _search.HasScanRegion && !caret.Offset.\n\t\t\t\tIsInRange(_search.BeginOffset, _search.EndOffset)) {\n\t\t\t\t// user moved outside of the originally selected region\n\t\t\t\t_search.ClearScanRegion();\n\t\t\t\tUpdateTitleBar();\n\t\t\t}\n\n\t\t\tint startFrom = caret.Offset - (searchBackward ? 1 : 0);\n\t\t\tTextRange range = _search.FindNext(startFrom, searchBackward, out _lastSearchLoopedAround);\n\t\t\tif (range != null)\n\t\t\t\tSelectResult(range);\n\t\t\telse if (messageIfNotFound != null)\n\t\t\t\tMessageBox.Show(messageIfNotFound);\n\t\t\treturn range;\n\t\t}\n\n\t\tprivate void SelectResult(TextRange range)\n\t\t{\n\t\t\tTextLocation p1 = _editor.Document.OffsetToPosition(range.Offset);\n\t\t\tTextLocation p2 = _editor.Document.OffsetToPosition(range.Offset + range.Length);\n\t\t\t_editor.ActiveTextAreaControl.SelectionManager.SetSelection(p1, p2);\n\t\t\t_editor.ActiveTextAreaControl.ScrollTo(p1.Line, p1.Column);\n\t\t\t// Also move the caret to the end of the selection, because when the user \n\t\t\t// presses F3, the caret is where we start searching next time.\n\t\t\t_editor.ActiveTextAreaControl.Caret.Position = \n\t\t\t\t_editor.Document.OffsetToPosition(range.Offset + range.Length);\n\t\t}\n\n\t\tDictionary<TextEditorControl, HighlightGroup> _highlightGroups = new Dictionary<TextEditorControl, HighlightGroup>();\n\n\t\tprivate void btnHighlightAll_Click(object sender, EventArgs e)\n\t\t{\n\t\t\tif (!_highlightGroups.ContainsKey(_editor))\n\t\t\t\t_highlightGroups[_editor] = new HighlightGroup(_editor);\n\t\t\tHighlightGroup group = _highlightGroups[_editor];\n            group.ClearMarkers();\n\t\t\t\n\t\t\tif (!string.IsNullOrEmpty(LookFor))\n\t\t\t{\n\t\t\t\t_search.LookFor = txtLookFor.Text;\n\t\t\t\t_search.MatchCase = chkMatchCase.Checked;\n\t\t\t\t_search.MatchWholeWordOnly = chkMatchWholeWord.Checked;\n\n\t\t\t\tbool looped = false;\n\t\t\t\tint offset = 0, count = 0;\n\t\t\t\tfor(;;) {\n\t\t\t\t\tTextRange range = _search.FindNext(offset, false, out looped);\n\t\t\t\t\tif (range == null || looped)\n\t\t\t\t\t\tbreak;\n\t\t\t\t\toffset = range.Offset + range.Length;\n\t\t\t\t\tcount++;\n\n\t\t\t\t\tvar m = new TextMarker(range.Offset, range.Length, \n\t\t\t\t\t\t\tTextMarkerType.SolidBlock, Color.Yellow, Color.Black);\n\t\t\t\t\tgroup.AddMarker(m);\n\t\t\t\t}\n\n                _editor.Refresh(); // must repaint manually\n\t\t\t\n                // JDB:  Closing and leaving all the highlights active is annoying\n                //if (count == 0)\n\t\t\t\t//\tMessageBox.Show(\"Search text not found.\");\n\t\t\t\t//else\n\t\t\t\t//\tClose();\n\t\t\t}\n\t\t}\n\t\t\n\t\tprivate void FindAndReplaceForm_FormClosing(object sender, FormClosingEventArgs e)\n\t\t{\t// Prevent dispose, as this form can be re-used\n\t\t\tif (e.CloseReason != CloseReason.FormOwnerClosing)\n\t\t\t{\n\t\t\t\tif (this.Owner != null)\n\t\t\t\t\tthis.Owner.Select(); // prevent another app from being activated instead\n\t\t\t\t\n\t\t\t\te.Cancel = true;\n\t\t\t\tHide();\n\t\t\t\t\n\t\t\t\t// Discard search region\n\t\t\t\t_search.ClearScanRegion();\n                if( _highlightGroups.ContainsKey(_editor))\n                    _highlightGroups[_editor].ClearMarkers();\n\t\t\t\t_editor.Refresh(); // must repaint manually\n\t\t\t}\n\t\t}\n\n\t\tprivate void btnCancel_Click(object sender, EventArgs e)\n\t\t{\n\t\t\tClose();\n\t\t}\n\n\t\tprivate void btnReplace_Click(object sender, EventArgs e)\n\t\t{\n\t\t\tvar sm = _editor.ActiveTextAreaControl.SelectionManager;\n\t\t\tif (string.Equals(sm.SelectedText, txtLookFor.Text, StringComparison.OrdinalIgnoreCase))\n\t\t\t\tInsertText(txtReplaceWith.Text);\n\t\t\tFindNext(false, _lastSearchWasBackward, \"Text not found.\");\n\t\t}\n\n\t\tprivate void btnReplaceAll_Click(object sender, EventArgs e)\n\t\t{\n\t\t\tint count = 0;\n\t\t\t// BUG FIX: if the replacement string contains the original search string\n\t\t\t// (e.g. replace \"red\" with \"very red\") we must avoid looping around and\n\t\t\t// replacing forever! To fix, start replacing at beginning of region (by \n\t\t\t// moving the caret) and stop as soon as we loop around.\n\t\t\t_editor.ActiveTextAreaControl.Caret.Position = \n\t\t\t\t_editor.Document.OffsetToPosition(_search.BeginOffset);\n\n\t\t\t_editor.Document.UndoStack.StartUndoGroup();\n\t\t\ttry {\n\t\t\t\twhile (FindNext(false, false, null) != null)\n\t\t\t\t{\n\t\t\t\t\tif (_lastSearchLoopedAround)\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t// Replace\n\t\t\t\t\tcount++;\n\t\t\t\t\tInsertText(txtReplaceWith.Text);\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\t_editor.Document.UndoStack.EndUndoGroup();\n\t\t\t}\n\t\t\tif (count == 0)\n\t\t\t\tMessageBox.Show(\"No occurrances found.\");\n\t\t\telse {\n\t\t\t\tMessageBox.Show(string.Format(\"Replaced {0} occurrances.\", count));\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\n\t\tprivate void InsertText(string text)\n\t\t{\n\t\t\tvar textArea = _editor.ActiveTextAreaControl.TextArea;\n\t\t\ttextArea.Document.UndoStack.StartUndoGroup();\n\t\t\ttry {\n\t\t\t\tif (textArea.SelectionManager.HasSomethingSelected) {\n\t\t\t\t\ttextArea.Caret.Position = textArea.SelectionManager.SelectionCollection[0].StartPosition;\n\t\t\t\t\ttextArea.SelectionManager.RemoveSelectedText();\n\t\t\t\t}\n\t\t\t\ttextArea.InsertString(text);\n\t\t\t} finally {\n\t\t\t\ttextArea.Document.UndoStack.EndUndoGroup();\n\t\t\t}\n\t\t}\n\n\t\tpublic string LookFor { get { return txtLookFor.Text; } }\n\t}\n\n\tpublic class TextRange : AbstractSegment\n\t{\n\t\tIDocument _document;\n\t\tpublic TextRange(IDocument document, int offset, int length)\n\t\t{\n\t\t\t_document = document;\n\t\t\tthis.offset = offset;\n\t\t\tthis.length = length;\n\t\t}\n\t}\n\n\t/// <summary>This class finds occurrances of a search string in a text \n\t/// editor's IDocument... it's like Find box without a GUI.</summary>\n\tpublic class TextEditorSearcher : IDisposable\n\t{\n\t\tIDocument _document;\n\t\tpublic IDocument Document\n\t\t{\n\t\t\tget { return _document; } \n\t\t\tset { \n\t\t\t\tif (_document != value) {\n\t\t\t\t\tClearScanRegion();\n\t\t\t\t\t_document = value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// I would have used the TextAnchor class to represent the beginning and \n\t\t// end of the region to scan while automatically adjusting to changes in \n\t\t// the document--but for some reason it is sealed and its constructor is \n\t\t// internal. Instead I use a TextMarker, which is perhaps even better as \n\t\t// it gives me the opportunity to highlight the region. Note that all the \n\t\t// markers and coloring information is associated with the text document, \n\t\t// not the editor control, so TextEditorSearcher doesn't need a reference \n\t\t// to the TextEditorControl. After adding the marker to the document, we\n\t\t// must remember to remove it when it is no longer needed.\n\t\tTextMarker _region = null;\n\t\t/// <summary>Sets the region to search. The region is updated \n\t\t/// automatically as the document changes.</summary>\n\t\tpublic void SetScanRegion(ISelection sel)\n\t\t{\n\t\t\tSetScanRegion(sel.Offset, sel.Length);\n\t\t}\n\t\t/// <summary>Sets the region to search. The region is updated \n\t\t/// automatically as the document changes.</summary>\n\t\tpublic void SetScanRegion(int offset, int length)\n\t\t{\n\t\t\tvar bkgColor = _document.HighlightingStrategy.GetColorFor(\"Default\").BackgroundColor;\n\t\t\t_region = new TextMarker(offset, length, TextMarkerType.SolidBlock, \n\t\t\t\tbkgColor.HalfMix(Color.FromArgb(160,160,160)));\n\t\t\t_document.MarkerStrategy.AddMarker(_region);\n\t\t}\n\t\tpublic bool HasScanRegion\n\t\t{\n\t\t\tget { return _region != null; }\n\t\t}\n\t\tpublic void ClearScanRegion()\n\t\t{\n\t\t\tif (_region != null)\n\t\t\t{\n\t\t\t\t_document.MarkerStrategy.RemoveMarker(_region);\n\t\t\t\t_region = null;\n\t\t\t}\n\t\t}\n\t\tpublic void Dispose() { ClearScanRegion(); GC.SuppressFinalize(this); }\n\t\t~TextEditorSearcher() { Dispose(); }\n\t\t\n\t\t/// <summary>Begins the start offset for searching</summary>\n\t\tpublic int BeginOffset\n\t\t{\n\t\t\tget {\n\t\t\t\tif (_region != null)\n\t\t\t\t\treturn _region.Offset;\n\t\t\t\telse\n\t\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t\t/// <summary>Begins the end offset for searching</summary>\n\t\tpublic int EndOffset\n\t\t{\n\t\t\tget {\n\t\t\t\tif (_region != null)\n\t\t\t\t\treturn _region.EndOffset;\n\t\t\t\telse\n\t\t\t\t\treturn _document.TextLength;\n\t\t\t}\n\t\t}\n\n\t\tpublic bool MatchCase;\n\n\t\tpublic bool MatchWholeWordOnly;\n\n\t\tstring _lookFor;\n\t\tstring _lookFor2; // uppercase in case-insensitive mode\n\t\tpublic string LookFor\n\t\t{\n\t\t\tget { return _lookFor; }\n\t\t\tset { _lookFor = value; }\n\t\t}\n\n\t\t/// <summary>Finds next instance of LookFor, according to the search rules \n\t\t/// (MatchCase, MatchWholeWordOnly).</summary>\n\t\t/// <param name=\"beginAtOffset\">Offset in Document at which to begin the search</param>\n\t\t/// <remarks>If there is a match at beginAtOffset precisely, it will be returned.</remarks>\n\t\t/// <returns>Region of document that matches the search string</returns>\n\t\tpublic TextRange FindNext(int beginAtOffset, bool searchBackward, out bool loopedAround)\n\t\t{\n\t\t\tDebug.Assert(!string.IsNullOrEmpty(_lookFor));\n\t\t\tloopedAround = false;\n\n\t\t\tint startAt = BeginOffset, endAt = EndOffset;\n\t\t\tint curOffs = beginAtOffset.InRange(startAt, endAt);\n\n\t\t\t_lookFor2 = MatchCase ? _lookFor : _lookFor.ToUpperInvariant();\n\t\t\t\n\t\t\tTextRange result;\n\t\t\tif (searchBackward) {\n\t\t\t\tresult = FindNextIn(startAt, curOffs, true);\n\t\t\t\tif (result == null) {\n\t\t\t\t\tloopedAround = true;\n\t\t\t\t\tresult = FindNextIn(curOffs, endAt, true);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tresult = FindNextIn(curOffs, endAt, false);\n\t\t\t\tif (result == null) {\n\t\t\t\t\tloopedAround = true;\n\t\t\t\t\tresult = FindNextIn(startAt, curOffs, false);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn result;\n\t\t}\n\n\t\tprivate TextRange FindNextIn(int offset1, int offset2, bool searchBackward)\n\t\t{\n\t\t\tDebug.Assert(offset2 >= offset1);\n\t\t\toffset2 -= _lookFor.Length;\n\n\t\t\t// Make behavior decisions before starting search loop\n\t\t\tFunc<char, char, bool> matchFirstCh;\n\t\t\tFunc<int, bool> matchWord;\n\t\t\tif (MatchCase)\n\t\t\t\tmatchFirstCh = (lookFor, c) => (lookFor == c);\n\t\t\telse\n\t\t\t\tmatchFirstCh = (lookFor, c) => (lookFor == Char.ToUpperInvariant(c));\n\t\t\tif (MatchWholeWordOnly)\n\t\t\t\tmatchWord = IsWholeWordMatch;\n\t\t\telse\n\t\t\t\tmatchWord = IsPartWordMatch;\n\n\t\t\t// Search\n\t\t\tchar lookForCh = _lookFor2[0];\n\t\t\tif (searchBackward)\n\t\t\t{\n\t\t\t\tfor (int offset = offset2; offset >= offset1; offset--) {\n\t\t\t\t\tif (matchFirstCh(lookForCh, _document.GetCharAt(offset))\n\t\t\t\t\t\t&& matchWord(offset))\n\t\t\t\t\t\treturn new TextRange(_document, offset, _lookFor.Length);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor (int offset = offset1; offset <= offset2; offset++) {\n\t\t\t\t\tif (matchFirstCh(lookForCh, _document.GetCharAt(offset))\n\t\t\t\t\t\t&& matchWord(offset))\n\t\t\t\t\t\treturn new TextRange(_document, offset, _lookFor.Length);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\tprivate bool IsWholeWordMatch(int offset)\n\t\t{\n\t\t\tif (IsWordBoundary(offset) && IsWordBoundary(offset + _lookFor.Length))\n\t\t\t\treturn IsPartWordMatch(offset);\n\t\t\telse\n\t\t\t\treturn false;\n\t\t}\n\t\tprivate bool IsWordBoundary(int offset)\n\t\t{\n\t\t\treturn offset <= 0 || offset >= _document.TextLength ||\n\t\t\t\t!IsAlphaNumeric(offset - 1) || !IsAlphaNumeric(offset);\n\t\t}\n\t\tprivate bool IsAlphaNumeric(int offset)\n\t\t{\n\t\t\tchar c = _document.GetCharAt(offset);\n\t\t\treturn Char.IsLetterOrDigit(c) || c == '_';\n\t\t}\n\t\tprivate bool IsPartWordMatch(int offset)\n\t\t{\n\t\t\tstring substr = _document.GetText(offset, _lookFor.Length);\n\t\t\tif (!MatchCase)\n\t\t\t\tsubstr = substr.ToUpperInvariant();\n\t\t\treturn substr == _lookFor2;\n\t\t}\n\t}\n\n\t/// <summary>Bundles a group of markers together so that they can be cleared \n\t/// together.</summary>\n\tpublic class HighlightGroup : IDisposable\n\t{\n\t\tList<TextMarker> _markers = new List<TextMarker>();\n\t\tTextEditorControl _editor;\n\t\tIDocument _document;\n\t\tpublic HighlightGroup(TextEditorControl editor)\n\t\t{\n\t\t\t_editor = editor;\n\t\t\t_document = editor.Document;\n\t\t}\n\t\tpublic void AddMarker(TextMarker marker)\n\t\t{\n\t\t\t_markers.Add(marker);\n\t\t\t_document.MarkerStrategy.AddMarker(marker);\n\t\t}\n\t\tpublic void ClearMarkers()\n\t\t{\n\t\t\tforeach (TextMarker m in _markers)\n\t\t\t\t_document.MarkerStrategy.RemoveMarker(m);\n\t\t\t_markers.Clear();\n\t\t\t_editor.Refresh();\n\t\t}\n\t\tpublic void Dispose() { ClearMarkers(); GC.SuppressFinalize(this); }\n\t\t~HighlightGroup() { Dispose(); }\n\n\t\tpublic IList<TextMarker> Markers { get { return _markers.AsReadOnly(); } }\n\t}\n\n\n    public static class FIndAndReplaceHelpers\n    {\n        public static int InRange(this int x, int lo, int hi)\n        {\n            Debug.Assert(lo <= hi);\n            return x < lo ? lo : (x > hi ? hi : x);\n        }\n        public static bool IsInRange(this int x, int lo, int hi)\n        {\n            return x >= lo && x <= hi;\n        }\n        public static Color HalfMix(this Color one, Color two)\n        {\n            return Color.FromArgb(\n                (one.A + two.A) >> 1,\n                (one.R + two.R) >> 1,\n                (one.G + two.G) >> 1,\n                (one.B + two.B) >> 1);\n        }\n    }\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Gui/FindReplaceForm/FindAndReplaceForm.resx",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n  <!-- \n    Microsoft ResX Schema \n    \n    Version 2.0\n    \n    The primary goals of this format is to allow a simple XML format \n    that is mostly human readable. The generation and parsing of the \n    various data types are done through the TypeConverter classes \n    associated with the data types.\n    \n    Example:\n    \n    ... ado.net/XML headers & schema ...\n    <resheader name=\"resmimetype\">text/microsoft-resx</resheader>\n    <resheader name=\"version\">2.0</resheader>\n    <resheader name=\"reader\">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\n    <resheader name=\"writer\">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\n    <data name=\"Name1\"><value>this is my long string</value><comment>this is a comment</comment></data>\n    <data name=\"Color1\" type=\"System.Drawing.Color, System.Drawing\">Blue</data>\n    <data name=\"Bitmap1\" mimetype=\"application/x-microsoft.net.object.binary.base64\">\n        <value>[base64 mime encoded serialized .NET Framework object]</value>\n    </data>\n    <data name=\"Icon1\" type=\"System.Drawing.Icon, System.Drawing\" mimetype=\"application/x-microsoft.net.object.bytearray.base64\">\n        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\n        <comment>This is a comment</comment>\n    </data>\n                \n    There are any number of \"resheader\" rows that contain simple \n    name/value pairs.\n    \n    Each data row contains a name, and value. The row also contains a \n    type or mimetype. Type corresponds to a .NET class that support \n    text/value conversion through the TypeConverter architecture. \n    Classes that don't support this are serialized and stored with the \n    mimetype set.\n    \n    The mimetype is used for serialized objects, and tells the \n    ResXResourceReader how to depersist the object. This is currently not \n    extensible. For a given mimetype the value must be set accordingly:\n    \n    Note - application/x-microsoft.net.object.binary.base64 is the format \n    that the ResXResourceWriter will generate, however the reader can \n    read any of the formats listed below.\n    \n    mimetype: application/x-microsoft.net.object.binary.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\n            : and then encoded with base64 encoding.\n    \n    mimetype: application/x-microsoft.net.object.soap.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\n            : and then encoded with base64 encoding.\n\n    mimetype: application/x-microsoft.net.object.bytearray.base64\n    value   : The object must be serialized into a byte array \n            : using a System.ComponentModel.TypeConverter\n            : and then encoded with base64 encoding.\n    -->\n  <xsd:schema id=\"root\" xmlns=\"\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">\n    <xsd:import namespace=\"http://www.w3.org/XML/1998/namespace\" />\n    <xsd:element name=\"root\" msdata:IsDataSet=\"true\">\n      <xsd:complexType>\n        <xsd:choice maxOccurs=\"unbounded\">\n          <xsd:element name=\"metadata\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" use=\"required\" type=\"xsd:string\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"assembly\">\n            <xsd:complexType>\n              <xsd:attribute name=\"alias\" type=\"xsd:string\" />\n              <xsd:attribute name=\"name\" type=\"xsd:string\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"data\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n                <xsd:element name=\"comment\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"2\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" msdata:Ordinal=\"1\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" msdata:Ordinal=\"3\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" msdata:Ordinal=\"4\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"resheader\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" />\n            </xsd:complexType>\n          </xsd:element>\n        </xsd:choice>\n      </xsd:complexType>\n    </xsd:element>\n  </xsd:schema>\n  <resheader name=\"resmimetype\">\n    <value>text/microsoft-resx</value>\n  </resheader>\n  <resheader name=\"version\">\n    <value>2.0</value>\n  </resheader>\n  <resheader name=\"reader\">\n    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n  <resheader name=\"writer\">\n    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n</root>"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Gui/FoldMargin.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 2063 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\nusing System.Drawing;\nusing System.Windows.Forms;\n\nusing ICSharpCode.TextEditor.Document;\n\nnamespace ICSharpCode.TextEditor\n{\n\t/// <summary>\n\t/// This class views the line numbers and folding markers.\n\t/// </summary>\n\tpublic class FoldMargin : AbstractMargin\n\t{\n\t\tint selectedFoldLine = -1;\n\t\t\n\t\tpublic override Size Size {\n\t\t\tget {\n\t\t\t\treturn new Size((int)(textArea.TextView.FontHeight),\n\t\t\t\t                -1);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic override bool IsVisible {\n\t\t\tget {\n\t\t\t\treturn textArea.TextEditorProperties.EnableFolding;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic FoldMargin(TextArea textArea) : base(textArea)\n\t\t{\n\t\t}\n\t\t\n\t\tpublic override void Paint(Graphics g, Rectangle rect)\n\t\t{\n\t\t\tif (rect.Width <= 0 || rect.Height <= 0) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tHighlightColor lineNumberPainterColor = textArea.Document.HighlightingStrategy.GetColorFor(\"LineNumbers\");\n\t\t\tHighlightColor foldLineColor          = textArea.Document.HighlightingStrategy.GetColorFor(\"FoldLine\");\n\t\t\t\n\t\t\t\n\t\t\tfor (int y = 0; y < (DrawingPosition.Height + textArea.TextView.VisibleLineDrawingRemainder) / textArea.TextView.FontHeight + 1; ++y) {\n\t\t\t\tRectangle markerRectangle = new Rectangle(DrawingPosition.X,\n\t\t\t\t                                          DrawingPosition.Top + y * textArea.TextView.FontHeight - textArea.TextView.VisibleLineDrawingRemainder,\n\t\t\t\t                                          DrawingPosition.Width,\n\t\t\t\t                                          textArea.TextView.FontHeight);\n\t\t\t\t\n\t\t\t\tif (rect.IntersectsWith(markerRectangle)) {\n\t\t\t\t\t// draw dotted separator line\n\t\t\t\t\tif (textArea.Document.TextEditorProperties.ShowLineNumbers) {\n\t\t\t\t\t\tg.FillRectangle(BrushRegistry.GetBrush(textArea.Enabled ? lineNumberPainterColor.BackgroundColor : SystemColors.InactiveBorder),\n\t\t\t\t\t\t                new Rectangle(markerRectangle.X + 1, markerRectangle.Y, markerRectangle.Width - 1, markerRectangle.Height));\n\t\t\t\t\t\t\n\t\t\t\t\t\tg.DrawLine(BrushRegistry.GetDotPen(lineNumberPainterColor.Color, lineNumberPainterColor.BackgroundColor),\n\t\t\t\t\t\t           base.drawingPosition.X,\n\t\t\t\t\t\t           markerRectangle.Y,\n\t\t\t\t\t\t           base.drawingPosition.X,\n\t\t\t\t\t\t           markerRectangle.Bottom);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tg.FillRectangle(BrushRegistry.GetBrush(textArea.Enabled ? lineNumberPainterColor.BackgroundColor : SystemColors.InactiveBorder), markerRectangle);\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tint currentLine = textArea.Document.GetFirstLogicalLine(textArea.TextView.FirstPhysicalLine + y);\n\t\t\t\t\tif (currentLine < textArea.Document.TotalNumberOfLines) {\n\t\t\t\t\t\tPaintFoldMarker(g, currentLine, markerRectangle);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tbool SelectedFoldingFrom(List<FoldMarker> list)\n\t\t{\n\t\t\tif (list != null) {\n\t\t\t\tfor (int i = 0; i < list.Count; ++i) {\n\t\t\t\t\tif (this.selectedFoldLine == list[i].StartLine) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\tvoid PaintFoldMarker(Graphics g, int lineNumber, Rectangle drawingRectangle)\n\t\t{\n\t\t\tHighlightColor foldLineColor    = textArea.Document.HighlightingStrategy.GetColorFor(\"FoldLine\");\n\t\t\tHighlightColor selectedFoldLine = textArea.Document.HighlightingStrategy.GetColorFor(\"SelectedFoldLine\");\n\t\t\t\n\t\t\tList<FoldMarker> foldingsWithStart = textArea.Document.FoldingManager.GetFoldingsWithStart(lineNumber);\n\t\t\tList<FoldMarker> foldingsBetween   = textArea.Document.FoldingManager.GetFoldingsContainsLineNumber(lineNumber);\n\t\t\tList<FoldMarker> foldingsWithEnd   = textArea.Document.FoldingManager.GetFoldingsWithEnd(lineNumber);\n\t\t\t\n\t\t\tbool isFoldStart = foldingsWithStart.Count > 0;\n\t\t\tbool isBetween   = foldingsBetween.Count > 0;\n\t\t\tbool isFoldEnd   = foldingsWithEnd.Count > 0;\n\t\t\t\n\t\t\tbool isStartSelected   = SelectedFoldingFrom(foldingsWithStart);\n\t\t\tbool isBetweenSelected = SelectedFoldingFrom(foldingsBetween);\n\t\t\tbool isEndSelected     = SelectedFoldingFrom(foldingsWithEnd);\n\t\t\t\n\t\t\tint foldMarkerSize = (int)Math.Round(textArea.TextView.FontHeight * 0.57f);\n\t\t\tfoldMarkerSize -= (foldMarkerSize) % 2;\n\t\t\tint foldMarkerYPos = drawingRectangle.Y + (int)((drawingRectangle.Height - foldMarkerSize) / 2);\n\t\t\tint xPos = drawingRectangle.X + (drawingRectangle.Width - foldMarkerSize) / 2 + foldMarkerSize / 2;\n\t\t\t\n\t\t\t\n\t\t\tif (isFoldStart) {\n\t\t\t\tbool isVisible         = true;\n\t\t\t\tbool moreLinedOpenFold = false;\n\t\t\t\tforeach (FoldMarker foldMarker in foldingsWithStart) {\n\t\t\t\t\tif (foldMarker.IsFolded) {\n\t\t\t\t\t\tisVisible = false;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmoreLinedOpenFold = foldMarker.EndLine > foldMarker.StartLine;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tbool isFoldEndFromUpperFold = false;\n\t\t\t\tforeach (FoldMarker foldMarker in foldingsWithEnd) {\n\t\t\t\t\tif (foldMarker.EndLine > foldMarker.StartLine && !foldMarker.IsFolded) {\n\t\t\t\t\t\tisFoldEndFromUpperFold = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tDrawFoldMarker(g, new RectangleF(drawingRectangle.X + (drawingRectangle.Width - foldMarkerSize) / 2,\n\t\t\t\t                                 foldMarkerYPos,\n\t\t\t\t                                 foldMarkerSize,\n\t\t\t\t                                 foldMarkerSize),\n\t\t\t\t               isVisible,\n\t\t\t\t               isStartSelected\n\t\t\t\t              );\n\t\t\t\t\n\t\t\t\t// draw line above fold marker\n\t\t\t\tif (isBetween || isFoldEndFromUpperFold) {\n\t\t\t\t\tg.DrawLine(BrushRegistry.GetPen(isBetweenSelected ? selectedFoldLine.Color : foldLineColor.Color),\n\t\t\t\t\t           xPos,\n\t\t\t\t\t           drawingRectangle.Top,\n\t\t\t\t\t           xPos,\n\t\t\t\t\t           foldMarkerYPos - 1);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// draw line below fold marker\n\t\t\t\tif (isBetween || moreLinedOpenFold) {\n\t\t\t\t\tg.DrawLine(BrushRegistry.GetPen(isEndSelected || (isStartSelected && isVisible) || isBetweenSelected ? selectedFoldLine.Color : foldLineColor.Color),\n\t\t\t\t\t           xPos,\n\t\t\t\t\t           foldMarkerYPos + foldMarkerSize + 1,\n\t\t\t\t\t           xPos,\n\t\t\t\t\t           drawingRectangle.Bottom);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (isFoldEnd) {\n\t\t\t\t\tint midy = drawingRectangle.Top + drawingRectangle.Height / 2;\n\t\t\t\t\t\n\t\t\t\t\t// draw fold end marker\n\t\t\t\t\tg.DrawLine(BrushRegistry.GetPen(isEndSelected ? selectedFoldLine.Color : foldLineColor.Color),\n\t\t\t\t\t           xPos,\n\t\t\t\t\t           midy,\n\t\t\t\t\t           xPos + foldMarkerSize / 2,\n\t\t\t\t\t           midy);\n\t\t\t\t\t\n\t\t\t\t\t// draw line above fold end marker\n\t\t\t\t\t// must be drawn after fold marker because it might have a different color than the fold marker\n\t\t\t\t\tg.DrawLine(BrushRegistry.GetPen(isBetweenSelected || isEndSelected ? selectedFoldLine.Color : foldLineColor.Color),\n\t\t\t\t\t           xPos,\n\t\t\t\t\t           drawingRectangle.Top,\n\t\t\t\t\t           xPos,\n\t\t\t\t\t           midy);\n\t\t\t\t\t\n\t\t\t\t\t// draw line below fold end marker\n\t\t\t\t\tif (isBetween) {\n\t\t\t\t\t\tg.DrawLine(BrushRegistry.GetPen(isBetweenSelected ? selectedFoldLine.Color : foldLineColor.Color),\n\t\t\t\t\t\t           xPos,\n\t\t\t\t\t\t           midy + 1,\n\t\t\t\t\t\t           xPos,\n\t\t\t\t\t\t           drawingRectangle.Bottom);\n\t\t\t\t\t}\n\t\t\t\t} else if (isBetween) {\n\t\t\t\t\t// just draw the line :)\n\t\t\t\t\tg.DrawLine(BrushRegistry.GetPen(isBetweenSelected ? selectedFoldLine.Color : foldLineColor.Color),\n\t\t\t\t\t           xPos,\n\t\t\t\t\t           drawingRectangle.Top,\n\t\t\t\t\t           xPos,\n\t\t\t\t\t           drawingRectangle.Bottom);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic override void HandleMouseMove(Point mousepos, MouseButtons mouseButtons)\n\t\t{\n\t\t\tbool  showFolding  = textArea.Document.TextEditorProperties.EnableFolding;\n\t\t\tint   physicalLine = + (int)((mousepos.Y + textArea.VirtualTop.Y) / textArea.TextView.FontHeight);\n\t\t\tint   realline     = textArea.Document.GetFirstLogicalLine(physicalLine);\n\t\t\t\n\t\t\tif (!showFolding || realline < 0 || realline + 1 >= textArea.Document.TotalNumberOfLines) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tList<FoldMarker> foldMarkers = textArea.Document.FoldingManager.GetFoldingsWithStart(realline);\n\t\t\tint oldSelection = selectedFoldLine;\n\t\t\tif (foldMarkers.Count > 0) {\n\t\t\t\tselectedFoldLine = realline;\n\t\t\t} else {\n\t\t\t\tselectedFoldLine = -1;\n\t\t\t}\n\t\t\tif (oldSelection != selectedFoldLine) {\n\t\t\t\ttextArea.Refresh(this);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic override void HandleMouseDown(Point mousepos, MouseButtons mouseButtons)\n\t\t{\n\t\t\tbool  showFolding  = textArea.Document.TextEditorProperties.EnableFolding;\n\t\t\tint   physicalLine = + (int)((mousepos.Y + textArea.VirtualTop.Y) / textArea.TextView.FontHeight);\n\t\t\tint   realline     = textArea.Document.GetFirstLogicalLine(physicalLine);\n\t\t\t\n\t\t\t// focus the textarea if the user clicks on the line number view\n\t\t\ttextArea.Focus();\n\t\t\t\n\t\t\tif (!showFolding || realline < 0 || realline + 1 >= textArea.Document.TotalNumberOfLines) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tList<FoldMarker> foldMarkers = textArea.Document.FoldingManager.GetFoldingsWithStart(realline);\n\t\t\tforeach (FoldMarker fm in foldMarkers) {\n\t\t\t\tfm.IsFolded = !fm.IsFolded;\n\t\t\t}\n\t\t\ttextArea.Document.FoldingManager.NotifyFoldingsChanged(EventArgs.Empty);\n\t\t}\n\t\t\n\t\tpublic override void HandleMouseLeave(EventArgs e)\n\t\t{\n\t\t\tif (selectedFoldLine != -1) {\n\t\t\t\tselectedFoldLine = -1;\n\t\t\t\ttextArea.Refresh(this);\n\t\t\t}\n\t\t}\n\t\t\n\t\t#region Drawing functions\n\t\tvoid DrawFoldMarker(Graphics g, RectangleF rectangle, bool isOpened, bool isSelected)\n\t\t{\n\t\t\tHighlightColor foldMarkerColor = textArea.Document.HighlightingStrategy.GetColorFor(\"FoldMarker\");\n\t\t\tHighlightColor foldLineColor   = textArea.Document.HighlightingStrategy.GetColorFor(\"FoldLine\");\n\t\t\tHighlightColor selectedFoldLine = textArea.Document.HighlightingStrategy.GetColorFor(\"SelectedFoldLine\");\n\t\t\t\n\t\t\tRectangle intRect = new Rectangle((int)rectangle.X, (int)rectangle.Y, (int)rectangle.Width, (int)rectangle.Height);\n\t\t\tg.FillRectangle(BrushRegistry.GetBrush(foldMarkerColor.BackgroundColor), intRect);\n\t\t\tg.DrawRectangle(BrushRegistry.GetPen(isSelected ? selectedFoldLine.Color : foldMarkerColor.Color), intRect);\n\t\t\t\n\t\t\tint space  = (int)Math.Round(((double)rectangle.Height) / 8d) + 1;\n\t\t\tint mid    = intRect.Height / 2 + intRect.Height % 2;\n\t\t\t\n\t\t\tg.DrawLine(BrushRegistry.GetPen(foldLineColor.BackgroundColor),\n\t\t\t           rectangle.X + space,\n\t\t\t           rectangle.Y + mid,\n\t\t\t           rectangle.X + rectangle.Width - space,\n\t\t\t           rectangle.Y + mid);\n\t\t\t\n\t\t\tif (!isOpened) {\n\t\t\t\tg.DrawLine(BrushRegistry.GetPen(foldLineColor.BackgroundColor),\n\t\t\t\t           rectangle.X + mid,\n\t\t\t\t           rectangle.Y + space,\n\t\t\t\t           rectangle.X + mid,\n\t\t\t\t           rectangle.Y + rectangle.Height - space);\n\t\t\t}\n\t\t}\n\t\t#endregion\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Gui/GutterMargin.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 3050 $</version>\n// </file>\n\nusing System;\nusing System.Drawing;\nusing System.IO;\nusing System.Reflection;\nusing System.Windows.Forms;\n\nusing ICSharpCode.TextEditor.Document;\n\nnamespace ICSharpCode.TextEditor\n{\n\t/// <summary>\n\t/// This class views the line numbers and folding markers.\n\t/// </summary>\n\tpublic class GutterMargin : AbstractMargin, IDisposable\n\t{\n\t\tStringFormat numberStringFormat = (StringFormat)StringFormat.GenericTypographic.Clone();\n\t\t\n\t\tpublic static Cursor RightLeftCursor;\n\t\t\n\t\tstatic GutterMargin()\n\t\t{\n\t\t\tStream cursorStream = Assembly.GetCallingAssembly().GetManifestResourceStream(\"ICSharpCode.TextEditor.Resources.RightArrow.cur\");\n\t\t\tif (cursorStream == null) throw new Exception(\"could not find cursor resource\");\n\t\t\tRightLeftCursor = new Cursor(cursorStream);\n\t\t\tcursorStream.Close();\n\t\t}\n\t\t\n\t\tpublic void Dispose()\n\t\t{\n\t\t\tnumberStringFormat.Dispose();\n\t\t}\n\t\t\n\t\tpublic override Cursor Cursor {\n\t\t\tget {\n\t\t\t\treturn RightLeftCursor;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic override Size Size {\n\t\t\tget {\n\t\t\t\treturn new Size((int)(textArea.TextView.WideSpaceWidth\n\t\t\t\t                      * Math.Max(3, (int)Math.Log10(textArea.Document.TotalNumberOfLines) + 1)),\n\t\t\t\t                -1);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic override bool IsVisible {\n\t\t\tget {\n\t\t\t\treturn textArea.TextEditorProperties.ShowLineNumbers;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic GutterMargin(TextArea textArea) : base(textArea)\n\t\t{\n\t\t\tnumberStringFormat.LineAlignment = StringAlignment.Far;\n\t\t\tnumberStringFormat.FormatFlags   = StringFormatFlags.MeasureTrailingSpaces | StringFormatFlags.FitBlackBox |\n\t\t\t\tStringFormatFlags.NoWrap | StringFormatFlags.NoClip;\n\t\t}\n\t\t\n\t\tpublic override void Paint(Graphics g, Rectangle rect)\n\t\t{\n\t\t\tif (rect.Width <= 0 || rect.Height <= 0) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tHighlightColor lineNumberPainterColor = textArea.Document.HighlightingStrategy.GetColorFor(\"LineNumbers\");\n\t\t\tint fontHeight = textArea.TextView.FontHeight;\n\t\t\tBrush fillBrush = textArea.Enabled ? BrushRegistry.GetBrush(lineNumberPainterColor.BackgroundColor) : SystemBrushes.InactiveBorder;\n\t\t\tBrush drawBrush = BrushRegistry.GetBrush(lineNumberPainterColor.Color);\n\t\t\tfor (int y = 0; y < (DrawingPosition.Height + textArea.TextView.VisibleLineDrawingRemainder) / fontHeight + 1; ++y) {\n\t\t\t\tint ypos = drawingPosition.Y + fontHeight * y  - textArea.TextView.VisibleLineDrawingRemainder;\n\t\t\t\tRectangle backgroundRectangle = new Rectangle(drawingPosition.X, ypos, drawingPosition.Width, fontHeight);\n\t\t\t\tif (rect.IntersectsWith(backgroundRectangle)) {\n\t\t\t\t\tg.FillRectangle(fillBrush, backgroundRectangle);\n\t\t\t\t\tint curLine = textArea.Document.GetFirstLogicalLine(textArea.Document.GetVisibleLine(textArea.TextView.FirstVisibleLine) + y);\n\t\t\t\t\t\n\t\t\t\t\tif (curLine < textArea.Document.TotalNumberOfLines) {\n\t\t\t\t\t\tg.DrawString((curLine + 1).ToString(),\n\t\t\t\t\t\t             lineNumberPainterColor.GetFont(TextEditorProperties.FontContainer),\n\t\t\t\t\t\t             drawBrush,\n\t\t\t\t\t\t             backgroundRectangle,\n\t\t\t\t\t\t             numberStringFormat);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tpublic override void HandleMouseDown(Point mousepos, MouseButtons mouseButtons)\n\t\t{\n\t\t\tTextLocation selectionStartPos;\n\n\t\t\ttextArea.SelectionManager.selectFrom.where = WhereFrom.Gutter;\n\t\t\tint realline = textArea.TextView.GetLogicalLine(mousepos.Y);\n\t\t\tif (realline >= 0 && realline < textArea.Document.TotalNumberOfLines) {\n\t\t\t\t// shift-select\n\t\t\t\tif((Control.ModifierKeys & Keys.Shift) != 0) {\n\t\t\t\t\tif(!textArea.SelectionManager.HasSomethingSelected && realline != textArea.Caret.Position.Y) {\n\t\t\t\t\t\tif (realline >= textArea.Caret.Position.Y)\n\t\t\t\t\t\t{ // at or below starting selection, place the cursor on the next line\n\t\t\t\t\t\t\t// nothing is selected so make a new selection from cursor\n\t\t\t\t\t\t\tselectionStartPos = textArea.Caret.Position;\n\t\t\t\t\t\t\t// whole line selection - start of line to start of next line\n\t\t\t\t\t\t\tif (realline < textArea.Document.TotalNumberOfLines - 1)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttextArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, selectionStartPos, new TextLocation(0, realline + 1)));\n\t\t\t\t\t\t\t\ttextArea.Caret.Position = new TextLocation(0, realline + 1);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttextArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, selectionStartPos, new TextLocation(textArea.Document.GetLineSegment(realline).Length + 1, realline)));\n\t\t\t\t\t\t\t\ttextArea.Caret.Position = new TextLocation(textArea.Document.GetLineSegment(realline).Length + 1, realline);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{ // prior lines to starting selection, place the cursor on the same line as the new selection\n\t\t\t\t\t\t\t// nothing is selected so make a new selection from cursor\n\t\t\t\t\t\t\tselectionStartPos = textArea.Caret.Position;\n\t\t\t\t\t\t\t// whole line selection - start of line to start of next line\n\t\t\t\t\t\t\ttextArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, selectionStartPos, new TextLocation(selectionStartPos.X, selectionStartPos.Y)));\n\t\t\t\t\t\t\ttextArea.SelectionManager.ExtendSelection(new TextLocation(selectionStartPos.X, selectionStartPos.Y), new TextLocation(0, realline));\n\t\t\t\t\t\t\ttextArea.Caret.Position = new TextLocation(0, realline);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\t// let MouseMove handle a shift-click in a gutter\n\t\t\t\t\t\tMouseEventArgs e = new MouseEventArgs(mouseButtons, 1, mousepos.X, mousepos.Y, 0);\n\t\t\t\t\t\ttextArea.RaiseMouseMove(e);\n\t\t\t\t\t}\n\t\t\t\t} else { // this is a new selection with no shift-key\n\t\t\t\t\t// sync the textareamousehandler mouse location\n\t\t\t\t\t// (fixes problem with clicking out into a menu then back to the gutter whilst\n\t\t\t\t\t// there is a selection)\n\t\t\t\t\ttextArea.mousepos = mousepos;\n\n\t\t\t\t\tselectionStartPos = new TextLocation(0, realline);\n\t\t\t\t\ttextArea.SelectionManager.ClearSelection();\n\t\t\t\t\t// whole line selection - start of line to start of next line\n\t\t\t\t\tif (realline < textArea.Document.TotalNumberOfLines - 1)\n\t\t\t\t\t{\n\t\t\t\t\t\ttextArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, selectionStartPos, new TextLocation(selectionStartPos.X, selectionStartPos.Y + 1)));\n\t\t\t\t\t\ttextArea.Caret.Position = new TextLocation(selectionStartPos.X, selectionStartPos.Y + 1);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\ttextArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, new TextLocation(0, realline), new TextLocation(textArea.Document.GetLineSegment(realline).Length + 1, selectionStartPos.Y)));\n\t\t\t\t\t\ttextArea.Caret.Position = new TextLocation(textArea.Document.GetLineSegment(realline).Length + 1, selectionStartPos.Y);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Gui/HRuler.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 1925 $</version>\n// </file>\n\nusing System;\nusing System.Drawing;\nusing System.Windows.Forms;\n\nnamespace ICSharpCode.TextEditor\n{\n\t/// <summary>\n\t/// Horizontal ruler - text column measuring ruler at the top of the text area.\n\t/// </summary>\n\tpublic class HRuler : Control\n\t{\n\t\tTextArea textArea;\n\t\t\n\t\tpublic HRuler(TextArea textArea)\n\t\t{\n\t\t\tthis.textArea = textArea;\n\t\t}\n\t\t\n\t\tprotected override void OnPaint(System.Windows.Forms.PaintEventArgs e)\n\t\t{\n\t\t\tGraphics g = e.Graphics;\n\t\t\tint num = 0;\n\t\t\tfor (float x = textArea.TextView.DrawingPosition.Left; x < textArea.TextView.DrawingPosition.Right; x += textArea.TextView.WideSpaceWidth) {\n\t\t\t\tint offset = (Height * 2) / 3;\n\t\t\t\tif (num % 5 == 0) {\n\t\t\t\t\toffset = (Height * 4) / 5;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (num % 10 == 0) {\n\t\t\t\t\toffset = 1;\n\t\t\t\t}\n\t\t\t\t++num;\n\t\t\t\tg.DrawLine(Pens.Black,\n\t\t\t\t           (int)x, offset, (int)x, Height - offset);\n\t\t\t}\n\t\t}\n\t\t\n\t\tprotected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs e)\n\t\t{\n\t\t\te.Graphics.FillRectangle(Brushes.White,\n\t\t\t                         new Rectangle(0,\n\t\t\t                                       0,\n\t\t\t                                       Width,\n\t\t\t                                       Height));\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Gui/IconBarMargin.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 3176 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\nusing System.Drawing;\nusing System.Drawing.Drawing2D;\nusing System.Windows.Forms;\n\nusing ICSharpCode.TextEditor.Document;\n\nnamespace ICSharpCode.TextEditor\n{\n\t/// <summary>\n\t/// This class views the line numbers and folding markers.\n\t/// </summary>\n\tpublic class IconBarMargin : AbstractMargin\n\t{\n\t\tconst int iconBarWidth = 18;\n\t\t\n\t\tstatic readonly Size iconBarSize = new Size(iconBarWidth, -1);\n\t\t\n\t\tpublic override Size Size {\n\t\t\tget {\n\t\t\t\treturn iconBarSize;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic override bool IsVisible {\n\t\t\tget {\n\t\t\t\treturn textArea.TextEditorProperties.IsIconBarVisible;\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\tpublic IconBarMargin(TextArea textArea) : base(textArea)\n\t\t{\n\t\t}\n\t\t\n\t\tpublic override void Paint(Graphics g, Rectangle rect)\n\t\t{\n\t\t\tif (rect.Width <= 0 || rect.Height <= 0) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// paint background\n\t\t\tg.FillRectangle(SystemBrushes.Control, new Rectangle(drawingPosition.X, rect.Top, drawingPosition.Width - 1, rect.Height));\n\t\t\tg.DrawLine(SystemPens.ControlDark, base.drawingPosition.Right - 1, rect.Top, base.drawingPosition.Right - 1, rect.Bottom);\n\t\t\t\n\t\t\t// paint icons\n\t\t\tforeach (Bookmark mark in textArea.Document.BookmarkManager.Marks) {\n\t\t\t\tint lineNumber = textArea.Document.GetVisibleLine(mark.LineNumber);\n\t\t\t\tint lineHeight = textArea.TextView.FontHeight;\n\t\t\t\tint yPos = (int)(lineNumber * lineHeight) - textArea.VirtualTop.Y;\n\t\t\t\tif (IsLineInsideRegion(yPos, yPos + lineHeight, rect.Y, rect.Bottom)) {\n\t\t\t\t\tif (lineNumber == textArea.Document.GetVisibleLine(mark.LineNumber - 1)) {\n\t\t\t\t\t\t// marker is inside folded region, do not draw it\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tmark.Draw(this, g, new Point(0, yPos));\n\t\t\t\t}\n\t\t\t}\n\t\t\tbase.Paint(g, rect);\n\t\t}\n\t\t\n\t\tpublic override void HandleMouseDown(Point mousePos, MouseButtons mouseButtons)\n\t\t{\n\t\t\tint clickedVisibleLine = (mousePos.Y + textArea.VirtualTop.Y) / textArea.TextView.FontHeight;\n\t\t\tint lineNumber = textArea.Document.GetFirstLogicalLine(clickedVisibleLine);\n\t\t\t\n\t\t\tif ((mouseButtons & MouseButtons.Right) == MouseButtons.Right) {\n\t\t\t\tif (textArea.Caret.Line != lineNumber) {\n\t\t\t\t\ttextArea.Caret.Line = lineNumber;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tIList<Bookmark> marks = textArea.Document.BookmarkManager.Marks;\n\t\t\tList<Bookmark> marksInLine = new List<Bookmark>();\n\t\t\tint oldCount = marks.Count;\n\t\t\tforeach (Bookmark mark in marks) {\n\t\t\t\tif (mark.LineNumber == lineNumber) {\n\t\t\t\t\tmarksInLine.Add(mark);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (int i = marksInLine.Count - 1; i >= 0; i--) {\n\t\t\t\tBookmark mark = marksInLine[i];\n\t\t\t\tif (mark.Click(textArea, new MouseEventArgs(mouseButtons, 1, mousePos.X, mousePos.Y, 0))) {\n\t\t\t\t\tif (oldCount != marks.Count) {\n\t\t\t\t\t\ttextArea.UpdateLine(lineNumber);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tbase.HandleMouseDown(mousePos, mouseButtons);\n\t\t}\n\t\t\n\t\t#region Drawing functions\n\t\tpublic void DrawBreakpoint(Graphics g, int y, bool isEnabled, bool isHealthy)\n\t\t{\n\t\t\tint diameter = Math.Min(iconBarWidth - 2, textArea.TextView.FontHeight);\n\t\t\tRectangle rect = new Rectangle(1,\n\t\t\t                               y + (textArea.TextView.FontHeight - diameter) / 2,\n\t\t\t                               diameter,\n\t\t\t                               diameter);\n\t\t\t\n\t\t\t\n\t\t\tusing (GraphicsPath path = new GraphicsPath()) {\n\t\t\t\tpath.AddEllipse(rect);\n\t\t\t\tusing (PathGradientBrush pthGrBrush = new PathGradientBrush(path)) {\n\t\t\t\t\tpthGrBrush.CenterPoint = new PointF(rect.Left + rect.Width / 3 , rect.Top + rect.Height / 3);\n\t\t\t\t\tpthGrBrush.CenterColor = Color.MistyRose;\n\t\t\t\t\tColor[] colors = {isHealthy ? Color.Firebrick : Color.Olive};\n\t\t\t\t\tpthGrBrush.SurroundColors = colors;\n\t\t\t\t\t\n\t\t\t\t\tif (isEnabled) {\n\t\t\t\t\t\tg.FillEllipse(pthGrBrush, rect);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tg.FillEllipse(SystemBrushes.Control, rect);\n\t\t\t\t\t\tusing (Pen pen = new Pen(pthGrBrush)) {\n\t\t\t\t\t\t\tg.DrawEllipse(pen, new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic void DrawBookmark(Graphics g, int y, bool isEnabled)\n\t\t{\n\t\t\tint delta = textArea.TextView.FontHeight / 8;\n\t\t\tRectangle rect = new Rectangle(1, y + delta, base.drawingPosition.Width - 4, textArea.TextView.FontHeight - delta * 2);\n\t\t\t\n\t\t\tif (isEnabled) {\n\t\t\t\tusing (Brush brush = new LinearGradientBrush(new Point(rect.Left, rect.Top),\n\t\t\t\t                                             new Point(rect.Right, rect.Bottom),\n\t\t\t\t                                             Color.SkyBlue,\n\t\t\t\t                                             Color.White)) {\n\t\t\t\t\tFillRoundRect(g, brush, rect);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tFillRoundRect(g, Brushes.White, rect);\n\t\t\t}\n\t\t\tusing (Brush brush = new LinearGradientBrush(new Point(rect.Left, rect.Top),\n\t\t\t                                             new Point(rect.Right, rect.Bottom),\n\t\t\t                                             Color.SkyBlue,\n\t\t\t                                             Color.Blue)) {\n\t\t\t\tusing (Pen pen = new Pen(brush)) {\n\t\t\t\t\tDrawRoundRect(g, pen, rect);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tpublic void DrawArrow(Graphics g, int y)\n\t\t{\n\t\t\tint delta = textArea.TextView.FontHeight / 8;\n\t\t\tRectangle rect = new Rectangle(1, y + delta, base.drawingPosition.Width - 4, textArea.TextView.FontHeight - delta * 2);\n\t\t\tusing (Brush brush = new LinearGradientBrush(new Point(rect.Left, rect.Top),\n\t\t\t                                             new Point(rect.Right, rect.Bottom),\n\t\t\t                                             Color.LightYellow,\n\t\t\t                                             Color.Yellow)) {\n\t\t\t\tFillArrow(g, brush, rect);\n\t\t\t}\n\t\t\t\n\t\t\tusing (Brush brush = new LinearGradientBrush(new Point(rect.Left, rect.Top),\n\t\t\t                                             new Point(rect.Right, rect.Bottom),\n\t\t\t                                             Color.Yellow,\n\t\t\t                                             Color.Brown)) {\n\t\t\t\tusing (Pen pen = new Pen(brush)) {\n\t\t\t\t\tDrawArrow(g, pen, rect);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tGraphicsPath CreateArrowGraphicsPath(Rectangle r)\n\t\t{\n\t\t\tGraphicsPath gp = new GraphicsPath();\n\t\t\tint halfX = r.Width / 2;\n\t\t\tint halfY = r.Height/ 2;\n\t\t\tgp.AddLine(r.X, r.Y + halfY/2, r.X + halfX, r.Y + halfY/2);\n\t\t\tgp.AddLine(r.X + halfX, r.Y + halfY/2, r.X + halfX, r.Y);\n\t\t\tgp.AddLine(r.X + halfX, r.Y, r.Right, r.Y + halfY);\n\t\t\tgp.AddLine(r.Right, r.Y + halfY, r.X + halfX, r.Bottom);\n\t\t\tgp.AddLine(r.X + halfX, r.Bottom, r.X + halfX, r.Bottom - halfY/2);\n\t\t\tgp.AddLine(r.X + halfX, r.Bottom - halfY/2, r.X, r.Bottom - halfY/2);\n\t\t\tgp.AddLine(r.X, r.Bottom - halfY/2, r.X, r.Y + halfY/2);\n\t\t\tgp.CloseFigure();\n\t\t\treturn gp;\n\t\t}\n\t\t\n\t\tGraphicsPath CreateRoundRectGraphicsPath(Rectangle r)\n\t\t{\n\t\t\tGraphicsPath gp = new GraphicsPath();\n\t\t\tint radius = r.Width / 2;\n\t\t\tgp.AddLine(r.X + radius, r.Y, r.Right - radius, r.Y);\n\t\t\tgp.AddArc(r.Right - radius, r.Y, radius, radius, 270, 90);\n\t\t\t\n\t\t\tgp.AddLine(r.Right, r.Y + radius, r.Right, r.Bottom - radius);\n\t\t\tgp.AddArc(r.Right - radius, r.Bottom - radius, radius, radius, 0, 90);\n\t\t\t\n\t\t\tgp.AddLine(r.Right - radius, r.Bottom, r.X + radius, r.Bottom);\n\t\t\tgp.AddArc(r.X, r.Bottom - radius, radius, radius, 90, 90);\n\t\t\t\n\t\t\tgp.AddLine(r.X, r.Bottom - radius, r.X, r.Y + radius);\n\t\t\tgp.AddArc(r.X, r.Y, radius, radius, 180, 90);\n\t\t\t\n\t\t\tgp.CloseFigure();\n\t\t\treturn gp;\n\t\t}\n\t\t\n\t\tvoid DrawRoundRect(Graphics g, Pen p , Rectangle r)\n\t\t{\n\t\t\tusing (GraphicsPath gp = CreateRoundRectGraphicsPath(r)) {\n\t\t\t\tg.DrawPath(p, gp);\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid FillRoundRect(Graphics g, Brush b , Rectangle r)\n\t\t{\n\t\t\tusing (GraphicsPath gp = CreateRoundRectGraphicsPath(r)) {\n\t\t\t\tg.FillPath(b, gp);\n\t\t\t}\n\t\t}\n\n\t\tvoid DrawArrow(Graphics g, Pen p , Rectangle r)\n\t\t{\n\t\t\tusing (GraphicsPath gp = CreateArrowGraphicsPath(r)) {\n\t\t\t\tg.DrawPath(p, gp);\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid FillArrow(Graphics g, Brush b , Rectangle r)\n\t\t{\n\t\t\tusing (GraphicsPath gp = CreateArrowGraphicsPath(r)) {\n\t\t\t\tg.FillPath(b, gp);\n\t\t\t}\n\t\t}\n\n\t\t#endregion\n\t\t\n\t\tstatic bool IsLineInsideRegion(int top, int bottom, int regionTop, int regionBottom)\n\t\t{\n\t\t\tif (top >= regionTop && top <= regionBottom) {\n\t\t\t\t// Region overlaps the line's top edge.\n\t\t\t\treturn true;\n\t\t\t} else if(regionTop > top && regionTop < bottom) {\n\t\t\t\t// Region's top edge inside line.\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Gui/Ime.cs",
    "content": "// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Shinsaku Nakagawa\" email=\"shinsaku@users.sourceforge.jp\"/>\n//     <version>$Revision: 3113 $</version>\n// </file>\n\nusing System;\nusing System.Drawing;\nusing System.Runtime.InteropServices;\nusing System.Windows.Forms;\n\nnamespace ICSharpCode.TextEditor\n{\n\t/// <summary>\n\t/// Used internally, not for own use.\n\t/// </summary>\n\tinternal class Ime\n\t{\n\t\tpublic Ime(IntPtr hWnd, Font font)\n\t\t{\n\t\t\tstring PROCESSOR_ARCHITEW6432 = Environment.GetEnvironmentVariable(\"PROCESSOR_ARCHITEW6432\");\n\t\t\tif (PROCESSOR_ARCHITEW6432 == \"IA64\" || PROCESSOR_ARCHITEW6432 == \"AMD64\" || Environment.OSVersion.Platform == PlatformID.Unix) {\n\t\t\t\tdisableIME = true;\n\t\t\t} else {\n\t\t\t\tthis.hIMEWnd = ImmGetDefaultIMEWnd(hWnd);\n\t\t\t}\n\t\t\tthis.hWnd = hWnd;\n\t\t\tthis.font = font;\n\t\t\tSetIMEWindowFont(font);\n\t\t}\n\n\t\tprivate Font font = null;\n\t\tpublic Font Font\n\t\t{\n\t\t\tget {\n\t\t\t\treturn font;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tif (!value.Equals(font)) {\n\t\t\t\t\tfont = value;\n\t\t\t\t\tlf = null;\n\t\t\t\t\tSetIMEWindowFont(value);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tpublic IntPtr HWnd\n\t\t{\n\t\t\tset {\n\t\t\t\tif (this.hWnd != value) {\n\t\t\t\t\tthis.hWnd = value;\n\t\t\t\t\tif (!disableIME)\n\t\t\t\t\t\tthis.hIMEWnd = ImmGetDefaultIMEWnd(value);\n\t\t\t\t\tSetIMEWindowFont(font);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t[ DllImport(\"imm32.dll\") ]\n\t\tprivate static extern IntPtr ImmGetDefaultIMEWnd(IntPtr hWnd);\n\n\t\t[ DllImport(\"user32.dll\") ]\n\t\tprivate static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, COMPOSITIONFORM lParam);\n\t\t[ DllImport(\"user32.dll\") ]\n\t\tprivate static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, [In, MarshalAs(UnmanagedType.LPStruct)] LOGFONT lParam);\n\n\t\t[ StructLayout(LayoutKind.Sequential) ]\n\t\tprivate class COMPOSITIONFORM\n\t\t{\n\t\t\tpublic int dwStyle = 0;\n\t\t\tpublic POINT ptCurrentPos = null;\n\t\t\tpublic RECT rcArea = null;\n\t\t}\n\n\t\t[ StructLayout(LayoutKind.Sequential) ]\n\t\tprivate class POINT\n\t\t{\n\t\t\tpublic int x = 0;\n\t\t\tpublic int y = 0;\n\t\t}\n\n\t\t[ StructLayout(LayoutKind.Sequential) ]\n\t\tprivate class RECT\n\t\t{\n\t\t\tpublic int left = 0;\n\t\t\tpublic int top = 0;\n\t\t\tpublic int right = 0;\n\t\t\tpublic int bottom = 0;\n\t\t}\n\n\t\tprivate const int WM_IME_CONTROL = 0x0283;\n\n\t\tprivate const int IMC_SETCOMPOSITIONWINDOW = 0x000c;\n\t\tprivate IntPtr hIMEWnd;\n\t\tprivate IntPtr hWnd;\n\t\tprivate const int CFS_POINT = 0x0002;\n\n\t\t[ StructLayout(LayoutKind.Sequential) ]\n\t\tprivate class LOGFONT\n\t\t{\n\t\t\tpublic int lfHeight = 0;\n\t\t\tpublic int lfWidth = 0;\n\t\t\tpublic int lfEscapement = 0;\n\t\t\tpublic int lfOrientation = 0;\n\t\t\tpublic int lfWeight = 0;\n\t\t\tpublic byte lfItalic = 0;\n\t\t\tpublic byte lfUnderline = 0;\n\t\t\tpublic byte lfStrikeOut = 0;\n\t\t\tpublic byte lfCharSet = 0;\n\t\t\tpublic byte lfOutPrecision = 0;\n\t\t\tpublic byte lfClipPrecision = 0;\n\t\t\tpublic byte lfQuality = 0;\n\t\t\tpublic byte lfPitchAndFamily = 0;\n\t\t\t[ MarshalAs(UnmanagedType.ByValTStr, SizeConst=32) ] public string lfFaceName = null;\n\t\t}\n\t\tprivate const int IMC_SETCOMPOSITIONFONT = 0x000a;\n\t\tLOGFONT lf = null;\n\t\tstatic bool disableIME;\n\t\t\n\t\tprivate void SetIMEWindowFont(Font f)\n\t\t{\n\t\t\tif (disableIME || hIMEWnd == IntPtr.Zero) return;\n\t\t\t\n\t\t\tif (lf == null) {\n\t\t\t\tlf = new LOGFONT();\n\t\t\t\tf.ToLogFont(lf);\n\t\t\t\tlf.lfFaceName = f.Name;  // This is very important! \"Font.ToLogFont\" Method sets invalid value to LOGFONT.lfFaceName\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tSendMessage(\n\t\t\t\t\thIMEWnd,\n\t\t\t\t\tWM_IME_CONTROL,\n\t\t\t\t\tnew IntPtr(IMC_SETCOMPOSITIONFONT),\n\t\t\t\t\tlf\n\t\t\t\t);\n\t\t\t} catch (AccessViolationException ex) {\n\t\t\t\tHandle(ex);\n\t\t\t}\n\t\t}\n\n\t\tpublic void SetIMEWindowLocation(int x, int y)\n\t\t{\n\t\t\tif (disableIME || hIMEWnd == IntPtr.Zero) return;\n\n\t\t\tPOINT p = new POINT();\n\t\t\tp.x = x;\n\t\t\tp.y = y;\n\n\t\t\tCOMPOSITIONFORM lParam = new COMPOSITIONFORM();\n\t\t\tlParam.dwStyle = CFS_POINT;\n\t\t\tlParam.ptCurrentPos = p;\n\t\t\tlParam.rcArea = new RECT();\n\n\t\t\ttry {\n\t\t\t\tSendMessage(\n\t\t\t\t\thIMEWnd,\n\t\t\t\t\tWM_IME_CONTROL,\n\t\t\t\t\tnew IntPtr(IMC_SETCOMPOSITIONWINDOW),\n\t\t\t\t\tlParam\n\t\t\t\t);\n\t\t\t} catch (AccessViolationException ex) {\n\t\t\t\tHandle(ex);\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid Handle(Exception ex)\n\t\t{\n\t\t\tConsole.WriteLine(ex);\n\t\t\tif (!disableIME) {\n\t\t\t\tdisableIME = true;\n\t\t\t\tMessageBox.Show(\"Error calling IME: \" + ex.Message + \"\\nIME is disabled.\", \"IME error\");\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Gui/InsightWindow/IInsightDataProvider.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 2318 $</version>\n// </file>\n\nusing System;\n\nnamespace ICSharpCode.TextEditor.Gui.InsightWindow\n{\n\tpublic interface IInsightDataProvider\n\t{\n\t\t/// <summary>\n\t\t/// Tells the insight provider to prepare its data.\n\t\t/// </summary>\n\t\t/// <param name=\"fileName\">The name of the edited file</param>\n\t\t/// <param name=\"textArea\">The text area in which the file is being edited</param>\n\t\tvoid SetupDataProvider(string fileName, TextArea textArea);\n\t\t\n\t\t/// <summary>\n\t\t/// Notifies the insight provider that the caret offset has changed.\n\t\t/// </summary>\n\t\t/// <returns>Return true to close the insight window (e.g. when the\n\t\t/// caret was moved outside the region where insight is displayed for).\n\t\t/// Return false to keep the window open.</returns>\n\t\tbool CaretOffsetChanged();\n\t\t\n\t\t/// <summary>\n\t\t/// Gets the text to display in the insight window.\n\t\t/// </summary>\n\t\t/// <param name=\"number\">The number of the active insight entry.\n\t\t/// Multiple insight entries might be multiple overloads of the same method.</param>\n\t\t/// <returns>The text to display, e.g. a multi-line string where\n\t\t/// the first line is the method definition, followed by a description.</returns>\n\t\tstring GetInsightData(int number);\n\t\t\n\t\t/// <summary>\n\t\t/// Gets the number of available insight entries, e.g. the number of available\n\t\t/// overloads to call.\n\t\t/// </summary>\n\t\tint InsightDataCount {\n\t\t\tget;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Gets the index of the entry to initially select.\n\t\t/// </summary>\n\t\tint DefaultIndex {\n\t\t\tget;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Gui/InsightWindow/InsightWindow.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 3064 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\nusing System.Drawing;\nusing System.Windows.Forms;\n\nusing ICSharpCode.TextEditor.Gui.CompletionWindow;\nusing ICSharpCode.TextEditor.Util;\n\nnamespace ICSharpCode.TextEditor.Gui.InsightWindow\n{\n\tpublic class InsightWindow : AbstractCompletionWindow\n\t{\n\t\tpublic InsightWindow(Form parentForm, TextEditorControl control) : base(parentForm, control)\n\t\t{\n\t\t\tSetStyle(ControlStyles.UserPaint, true);\n\t\t\tSetStyle(ControlStyles.OptimizedDoubleBuffer, true);\n\t\t}\n\t\t\n\t\tpublic void ShowInsightWindow()\n\t\t{\n\t\t\tif (!Visible) {\n\t\t\t\tif (insightDataProviderStack.Count > 0) {\n\t\t\t\t\tShowCompletionWindow();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tRefresh();\n\t\t\t}\n\t\t}\n\t\t\n\t\t#region Event handling routines\n\t\tprotected override bool ProcessTextAreaKey(Keys keyData)\n\t\t{\n\t\t\tif (!Visible) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tswitch (keyData) {\n\t\t\t\tcase Keys.Down:\n\t\t\t\t\tif (DataProvider != null && DataProvider.InsightDataCount > 0) {\n\t\t\t\t\t\tCurrentData = (CurrentData + 1) % DataProvider.InsightDataCount;\n\t\t\t\t\t\tRefresh();\n\t\t\t\t\t}\n\t\t\t\t\treturn true;\n\t\t\t\tcase Keys.Up:\n\t\t\t\t\tif (DataProvider != null && DataProvider.InsightDataCount > 0) {\n\t\t\t\t\t\tCurrentData = (CurrentData + DataProvider.InsightDataCount - 1) % DataProvider.InsightDataCount;\n\t\t\t\t\t\tRefresh();\n\t\t\t\t\t}\n\t\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn base.ProcessTextAreaKey(keyData);\n\t\t}\n\t\t\n\t\tprotected override void CaretOffsetChanged(object sender, EventArgs e)\n\t\t{\n\t\t\t// move the window under the caret (don't change the x position)\n\t\t\tTextLocation caretPos  = control.ActiveTextAreaControl.Caret.Position;\n\t\t\tint y = (int)((1 + caretPos.Y) * control.ActiveTextAreaControl.TextArea.TextView.FontHeight)\n\t\t\t\t- control.ActiveTextAreaControl.TextArea.VirtualTop.Y - 1\n\t\t\t\t+ control.ActiveTextAreaControl.TextArea.TextView.DrawingPosition.Y;\n\t\t\t\n\t\t\tint xpos = control.ActiveTextAreaControl.TextArea.TextView.GetDrawingXPos(caretPos.Y, caretPos.X);\n\t\t\tint ypos = (control.ActiveTextAreaControl.Document.GetVisibleLine(caretPos.Y) + 1) * control.ActiveTextAreaControl.TextArea.TextView.FontHeight\n\t\t\t\t- control.ActiveTextAreaControl.TextArea.VirtualTop.Y;\n\t\t\tint rulerHeight = control.TextEditorProperties.ShowHorizontalRuler ? control.ActiveTextAreaControl.TextArea.TextView.FontHeight : 0;\n\t\t\t\n\t\t\tPoint p = control.ActiveTextAreaControl.PointToScreen(new Point(xpos, ypos + rulerHeight));\n\t\t\tif (p.Y != Location.Y) {\n\t\t\t\tLocation = p;\n\t\t\t}\n\t\t\t\n\t\t\twhile (DataProvider != null && DataProvider.CaretOffsetChanged()) {\n\t\t\t\tCloseCurrentDataProvider();\n\t\t\t}\n\t\t}\n\t\t\n\t\tprotected override void OnMouseDown(MouseEventArgs e)\n\t\t{\n\t\t\tbase.OnMouseDown(e);\n\t\t\tcontrol.ActiveTextAreaControl.TextArea.Focus();\n\t\t\tif (TipPainterTools.DrawingRectangle1.Contains(e.X, e.Y)) {\n\t\t\t\tCurrentData = (CurrentData + DataProvider.InsightDataCount - 1) % DataProvider.InsightDataCount;\n\t\t\t\tRefresh();\n\t\t\t}\n\t\t\tif (TipPainterTools.DrawingRectangle2.Contains(e.X, e.Y)) {\n\t\t\t\tCurrentData = (CurrentData + 1) % DataProvider.InsightDataCount;\n\t\t\t\tRefresh();\n\t\t\t}\n\t\t}\n\t\t\n\t\t#endregion\n\t\t\n\t\tMouseWheelHandler mouseWheelHandler = new MouseWheelHandler();\n\t\t\n\t\tpublic void HandleMouseWheel(MouseEventArgs e)\n\t\t{\n\t\t\tif (DataProvider != null && DataProvider.InsightDataCount > 0) {\n\t\t\t\tint distance = mouseWheelHandler.GetScrollAmount(e);\n\t\t\t\tif (control.TextEditorProperties.MouseWheelScrollDown)\n\t\t\t\t\tdistance = -distance;\n\t\t\t\tif (distance > 0) {\n\t\t\t\t\tCurrentData = (CurrentData + 1) % DataProvider.InsightDataCount;\n\t\t\t\t} else if (distance < 0) {\n\t\t\t\t\tCurrentData = (CurrentData + DataProvider.InsightDataCount - 1) % DataProvider.InsightDataCount;\n\t\t\t\t}\n\t\t\t\tRefresh();\n\t\t\t}\n\t\t}\n\t\t\n\t\t#region Insight Window Drawing routines\n\t\tprotected override void OnPaint(PaintEventArgs pe)\n\t\t{\n\t\t\tstring methodCountMessage = null, description;\n\t\t\tif (DataProvider == null || DataProvider.InsightDataCount < 1) {\n\t\t\t\tdescription = \"Unknown Method\";\n\t\t\t} else {\n\t\t\t\tif (DataProvider.InsightDataCount > 1) {\n\t\t\t\t\tmethodCountMessage = control.GetRangeDescription(CurrentData + 1, DataProvider.InsightDataCount);\n\t\t\t\t}\n\t\t\t\tdescription = DataProvider.GetInsightData(CurrentData);\n\t\t\t}\n\t\t\t\n\t\t\tdrawingSize = TipPainterTools.GetDrawingSizeHelpTipFromCombinedDescription(this,\n\t\t\t                                                                           pe.Graphics,\n\t\t\t                                                                           Font,\n\t\t\t                                                                           methodCountMessage,\n\t\t\t                                                                           description);\n\t\t\tif (drawingSize != Size) {\n\t\t\t\tSetLocation();\n\t\t\t} else {\n\t\t\t\tTipPainterTools.DrawHelpTipFromCombinedDescription(this, pe.Graphics, Font, methodCountMessage, description);\n\t\t\t}\n\t\t}\n\t\t\n\t\tprotected override void OnPaintBackground(PaintEventArgs pe)\n\t\t{\n\t\t\tpe.Graphics.FillRectangle(SystemBrushes.Info, pe.ClipRectangle);\n\t\t}\n\t\t#endregion\n\t\t\n\t\t#region InsightDataProvider handling\n\t\tStack<InsightDataProviderStackElement> insightDataProviderStack = new Stack<InsightDataProviderStackElement>();\n\t\t\n\t\tint CurrentData {\n\t\t\tget {\n\t\t\t\treturn insightDataProviderStack.Peek().currentData;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tinsightDataProviderStack.Peek().currentData = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tIInsightDataProvider DataProvider {\n\t\t\tget {\n\t\t\t\tif (insightDataProviderStack.Count == 0) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t\treturn insightDataProviderStack.Peek().dataProvider;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic void AddInsightDataProvider(IInsightDataProvider provider, string fileName)\n\t\t{\n\t\t\tprovider.SetupDataProvider(fileName, control.ActiveTextAreaControl.TextArea);\n\t\t\tif (provider.InsightDataCount > 0) {\n\t\t\t\tinsightDataProviderStack.Push(new InsightDataProviderStackElement(provider));\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid CloseCurrentDataProvider()\n\t\t{\n\t\t\tinsightDataProviderStack.Pop();\n\t\t\tif (insightDataProviderStack.Count == 0) {\n\t\t\t\tClose();\n\t\t\t} else {\n\t\t\t\tRefresh();\n\t\t\t}\n\t\t}\n\t\t\n\t\tclass InsightDataProviderStackElement\n\t\t{\n\t\t\tpublic int                  currentData;\n\t\t\tpublic IInsightDataProvider dataProvider;\n\t\t\t\n\t\t\tpublic InsightDataProviderStackElement(IInsightDataProvider dataProvider)\n\t\t\t{\n\t\t\t\tthis.currentData  = Math.Max(dataProvider.DefaultIndex, 0);\n\t\t\t\tthis.dataProvider = dataProvider;\n\t\t\t}\n\t\t}\n\t\t#endregion\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Gui/TextArea.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 3323 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Diagnostics;\nusing System.Drawing;\nusing System.Drawing.Text;\nusing System.Text;\nusing System.Windows.Forms;\n\nusing ICSharpCode.TextEditor.Actions;\nusing ICSharpCode.TextEditor.Document;\nusing ICSharpCode.TextEditor.Gui.CompletionWindow;\n\nnamespace ICSharpCode.TextEditor\n{\n\tpublic delegate bool KeyEventHandler(char ch);\n\tpublic delegate bool DialogKeyProcessor(Keys keyData);\n\t\n\t/// <summary>\n\t/// This class paints the textarea.\n\t/// </summary>\n\t[ToolboxItem(false)]\n\tpublic class TextArea : Control\n\t{\n\t\tbool hiddenMouseCursor = false;\n\t\t/// <summary>\n\t\t/// The position where the mouse cursor was when it was hidden. Sometimes the text editor gets MouseMove\n\t\t/// events when typing text even if the mouse is not moved.\n\t\t/// </summary>\n\t\tPoint mouseCursorHidePosition;\n\t\t\n\t\tPoint virtualTop        = new Point(0, 0);\n\t\tTextAreaControl         motherTextAreaControl;\n\t\tTextEditorControl       motherTextEditorControl;\n\t\t\n\t\tList<BracketHighlightingSheme> bracketshemes  = new List<BracketHighlightingSheme>();\n\t\tTextAreaClipboardHandler  textAreaClipboardHandler;\n\t\tbool autoClearSelection = false;\n\t\t\n\t\tList<AbstractMargin> leftMargins = new List<AbstractMargin>();\n\t\t\n\t\tTextView      textView;\n\t\tGutterMargin  gutterMargin;\n\t\tFoldMargin    foldMargin;\n\t\tIconBarMargin iconBarMargin;\n\t\t\n\t\tSelectionManager selectionManager;\n\t\tCaret            caret;\n\n\t\tinternal Point mousepos = new Point(0, 0);\n\t\t//public Point selectionStartPos = new Point(0,0);\n\n\t\tbool disposed;\n\t\t\n\t\t[Browsable(false)]\n\t\tpublic IList<AbstractMargin> LeftMargins {\n\t\t\tget {\n\t\t\t\treturn leftMargins.AsReadOnly();\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic void InsertLeftMargin(int index, AbstractMargin margin)\n\t\t{\n\t\t\tleftMargins.Insert(index, margin);\n\t\t\tRefresh();\n\t\t}\n\t\t\n\t\tpublic TextEditorControl MotherTextEditorControl {\n\t\t\tget {\n\t\t\t\treturn motherTextEditorControl;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic TextAreaControl MotherTextAreaControl {\n\t\t\tget {\n\t\t\t\treturn motherTextAreaControl;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic SelectionManager SelectionManager {\n\t\t\tget {\n\t\t\t\treturn selectionManager;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic Caret Caret {\n\t\t\tget {\n\t\t\t\treturn caret;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic TextView TextView {\n\t\t\tget {\n\t\t\t\treturn textView;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic GutterMargin GutterMargin {\n\t\t\tget {\n\t\t\t\treturn gutterMargin;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic FoldMargin FoldMargin {\n\t\t\tget {\n\t\t\t\treturn foldMargin;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic IconBarMargin IconBarMargin {\n\t\t\tget {\n\t\t\t\treturn iconBarMargin;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic Encoding Encoding {\n\t\t\tget {\n\t\t\t\treturn motherTextEditorControl.Encoding;\n\t\t\t}\n\t\t}\n\t\tpublic int MaxVScrollValue {\n\t\t\tget {\n\t\t\t\treturn (Document.GetVisibleLine(Document.TotalNumberOfLines - 1) + 1 + TextView.VisibleLineCount * 2 / 3) * TextView.FontHeight;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic Point VirtualTop {\n\t\t\tget {\n\t\t\t\treturn virtualTop;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tPoint newVirtualTop = new Point(value.X, Math.Min(MaxVScrollValue, Math.Max(0, value.Y)));\n\t\t\t\tif (virtualTop != newVirtualTop) {\n\t\t\t\t\tvirtualTop = newVirtualTop;\n\t\t\t\t\tmotherTextAreaControl.VScrollBar.Value = virtualTop.Y;\n\t\t\t\t\tInvalidate();\n\t\t\t\t}\n\t\t\t\tcaret.UpdateCaretPosition();\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic bool AutoClearSelection {\n\t\t\tget {\n\t\t\t\treturn autoClearSelection;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tautoClearSelection = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\t[Browsable(false)]\n\t\tpublic IDocument Document {\n\t\t\tget {\n\t\t\t\treturn motherTextEditorControl.Document;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic TextAreaClipboardHandler ClipboardHandler {\n\t\t\tget {\n\t\t\t\treturn textAreaClipboardHandler;\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\tpublic ITextEditorProperties TextEditorProperties {\n\t\t\tget {\n\t\t\t\treturn motherTextEditorControl.TextEditorProperties;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic TextArea(TextEditorControl motherTextEditorControl, TextAreaControl motherTextAreaControl)\n\t\t{\n\t\t\tthis.motherTextAreaControl      = motherTextAreaControl;\n\t\t\tthis.motherTextEditorControl    = motherTextEditorControl;\n\t\t\t\n\t\t\tcaret            = new Caret(this);\n\t\t\tselectionManager = new SelectionManager(Document, this);\n\t\t\t\n\t\t\tthis.textAreaClipboardHandler = new TextAreaClipboardHandler(this);\n\t\t\t\n\t\t\tResizeRedraw = true;\n\t\t\t\n\t\t\tSetStyle(ControlStyles.OptimizedDoubleBuffer, true);\n//\t\t\tSetStyle(ControlStyles.AllPaintingInWmPaint, true);\n//\t\t\tSetStyle(ControlStyles.UserPaint, true);\n\t\t\tSetStyle(ControlStyles.Opaque, false);\n\t\t\tSetStyle(ControlStyles.ResizeRedraw, true);\n\t\t\tSetStyle(ControlStyles.Selectable, true);\n\t\t\t\n\t\t\ttextView = new TextView(this);\n\t\t\t\n\t\t\tgutterMargin = new GutterMargin(this);\n\t\t\tfoldMargin   = new FoldMargin(this);\n\t\t\ticonBarMargin = new IconBarMargin(this);\n\t\t\tleftMargins.AddRange(new AbstractMargin[] { iconBarMargin, gutterMargin, foldMargin });\n\t\t\tOptionsChanged();\n\t\t\t\n\t\t\t\n\t\t\tnew TextAreaMouseHandler(this).Attach();\n\t\t\tnew TextAreaDragDropHandler().Attach(this);\n\t\t\t\n\t\t\tbracketshemes.Add(new BracketHighlightingSheme('{', '}'));\n\t\t\tbracketshemes.Add(new BracketHighlightingSheme('(', ')'));\n\t\t\tbracketshemes.Add(new BracketHighlightingSheme('[', ']'));\n\t\t\t\n\t\t\tcaret.PositionChanged += new EventHandler(SearchMatchingBracket);\n\t\t\tDocument.TextContentChanged += new EventHandler(TextContentChanged);\n\t\t\tDocument.FoldingManager.FoldingsChanged += new EventHandler(DocumentFoldingsChanged);\n\t\t}\n\t\t\n\t\tpublic void UpdateMatchingBracket()\n\t\t{\n\t\t\tSearchMatchingBracket(null, null);\n\t\t}\n\t\t\n\t\tvoid TextContentChanged(object sender, EventArgs e)\n\t\t{\n\t\t\tCaret.Position = new TextLocation(0, 0);\n\t\t\tSelectionManager.SelectionCollection.Clear();\n\t\t}\n\t\tvoid SearchMatchingBracket(object sender, EventArgs e)\n\t\t{\n\t\t\tif (!TextEditorProperties.ShowMatchingBracket) {\n\t\t\t\ttextView.Highlight = null;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tint oldLine1 = -1, oldLine2 = -1;\n\t\t\tif (textView.Highlight != null && textView.Highlight.OpenBrace.Y >=0 && textView.Highlight.OpenBrace.Y < Document.TotalNumberOfLines) {\n\t\t\t\toldLine1 = textView.Highlight.OpenBrace.Y;\n\t\t\t}\n\t\t\tif (textView.Highlight != null && textView.Highlight.CloseBrace.Y >=0 && textView.Highlight.CloseBrace.Y < Document.TotalNumberOfLines) {\n\t\t\t\toldLine2 = textView.Highlight.CloseBrace.Y;\n\t\t\t}\n\t\t\ttextView.Highlight = FindMatchingBracketHighlight();\n\t\t\tif (oldLine1 >= 0)\n\t\t\t\tUpdateLine(oldLine1);\n\t\t\tif (oldLine2 >= 0 && oldLine2 != oldLine1)\n\t\t\t\tUpdateLine(oldLine2);\n\t\t\tif (textView.Highlight != null) {\n\t\t\t\tint newLine1 = textView.Highlight.OpenBrace.Y;\n\t\t\t\tint newLine2 = textView.Highlight.CloseBrace.Y;\n\t\t\t\tif (newLine1 != oldLine1 && newLine1 != oldLine2)\n\t\t\t\t\tUpdateLine(newLine1);\n\t\t\t\tif (newLine2 != oldLine1 && newLine2 != oldLine2 && newLine2 != newLine1)\n\t\t\t\t\tUpdateLine(newLine2);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic BracketHighlight FindMatchingBracketHighlight()\n\t\t{\n\t\t\tif (Caret.Offset == 0)\n\t\t\t\treturn null;\n\t\t\tforeach (BracketHighlightingSheme bracketsheme in bracketshemes) {\n\t\t\t\tBracketHighlight highlight = bracketsheme.GetHighlight(Document, Caret.Offset - 1);\n\t\t\t\tif (highlight != null) {\n\t\t\t\t\treturn highlight;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\t\n\t\tpublic void SetDesiredColumn()\n\t\t{\n\t\t\tCaret.DesiredColumn = TextView.GetDrawingXPos(Caret.Line, Caret.Column) + VirtualTop.X;\n\t\t}\n\t\t\n\t\tpublic void SetCaretToDesiredColumn()\n\t\t{\n\t\t\tFoldMarker dummy;\n\t\t\tCaret.Position = textView.GetLogicalColumn(Caret.Line, Caret.DesiredColumn + VirtualTop.X, out dummy);\n\t\t}\n\t\t\n\t\tpublic void OptionsChanged()\n\t\t{\n\t\t\tUpdateMatchingBracket();\n\t\t\ttextView.OptionsChanged();\n\t\t\tcaret.RecreateCaret();\n\t\t\tcaret.UpdateCaretPosition();\n\t\t\tRefresh();\n\t\t}\n\t\t\n\t\tAbstractMargin lastMouseInMargin;\n\t\t\n\t\tprotected override void OnMouseLeave(System.EventArgs e)\n\t\t{\n\t\t\tbase.OnMouseLeave(e);\n\t\t\tthis.Cursor = Cursors.Default;\n\t\t\tif (lastMouseInMargin != null) {\n\t\t\t\tlastMouseInMargin.HandleMouseLeave(EventArgs.Empty);\n\t\t\t\tlastMouseInMargin = null;\n\t\t\t}\n\t\t\tCloseToolTip();\n\t\t}\n\t\t\n\t\tprotected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)\n\t\t{\n\t\t\t// this corrects weird problems when text is selected,\n\t\t\t// then a menu item is selected, then the text is\n\t\t\t// clicked again - it correctly synchronises the\n\t\t\t// click position\n\t\t\tmousepos = new Point(e.X, e.Y);\n\n\t\t\tbase.OnMouseDown(e);\n\t\t\tCloseToolTip();\n\t\t\t\n\t\t\tforeach (AbstractMargin margin in leftMargins) {\n\t\t\t\tif (margin.DrawingPosition.Contains(e.X, e.Y)) {\n\t\t\t\t\tmargin.HandleMouseDown(new Point(e.X, e.Y), e.Button);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Shows the mouse cursor if it has been hidden.\n\t\t/// </summary>\n\t\t/// <param name=\"forceShow\"><c>true</c> to always show the cursor or <c>false</c> to show it only if it has been moved since it was hidden.</param>\n\t\tinternal void ShowHiddenCursor(bool forceShow)\n\t\t{\n\t\t\tif (hiddenMouseCursor) {\n\t\t\t\tif (mouseCursorHidePosition != Cursor.Position || forceShow) {\n\t\t\t\t\tCursor.Show();\n\t\t\t\t\thiddenMouseCursor = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\t// static because the mouse can only be in one text area and we don't want to have\n\t\t// tooltips of text areas from inactive tabs floating around.\n\t\tstatic DeclarationViewWindow toolTip;\n\t\tstatic string oldToolTip;\n\t\t\n\t\tvoid SetToolTip(string text, int lineNumber)\n\t\t{\n\t\t\tif (toolTip == null || toolTip.IsDisposed)\n\t\t\t\ttoolTip = new DeclarationViewWindow(this.FindForm());\n\t\t\tif (oldToolTip == text)\n\t\t\t\treturn;\n\t\t\tif (text == null) {\n\t\t\t\ttoolTip.Hide();\n\t\t\t} else {\n\t\t\t\tPoint p = Control.MousePosition;\n\t\t\t\tPoint cp = PointToClient(p);\n\t\t\t\tif (lineNumber >= 0) {\n\t\t\t\t\tlineNumber = this.Document.GetVisibleLine(lineNumber);\n\t\t\t\t\tp.Y = (p.Y - cp.Y) + (lineNumber * this.TextView.FontHeight) - this.virtualTop.Y;\n\t\t\t\t}\n\t\t\t\tp.Offset(3, 3);\n\t\t\t\ttoolTip.Location = p;\n\t\t\t\ttoolTip.Description = text;\n\t\t\t\ttoolTip.HideOnClick = true;\n\t\t\t\ttoolTip.Show();\n\t\t\t}\n\t\t\toldToolTip = text;\n\t\t}\n\t\t\n\t\tpublic event ToolTipRequestEventHandler ToolTipRequest;\n\t\t\n\t\tprotected virtual void OnToolTipRequest(ToolTipRequestEventArgs e)\n\t\t{\n\t\t\tif (ToolTipRequest != null) {\n\t\t\t\tToolTipRequest(this, e);\n\t\t\t}\n\t\t}\n\t\t\n\t\tbool toolTipActive;\n\t\t/// <summary>\n\t\t/// Rectangle in text area that caused the current tool tip.\n\t\t/// Prevents tooltip from re-showing when it was closed because of a click or keyboard\n\t\t/// input and the mouse was not used.\n\t\t/// </summary>\n\t\tRectangle toolTipRectangle;\n\t\t\n\t\tvoid CloseToolTip()\n\t\t{\n\t\t\tif (toolTipActive) {\n\t\t\t\t//Console.WriteLine(\"Closing tooltip\");\n\t\t\t\ttoolTipActive = false;\n\t\t\t\tSetToolTip(null, -1);\n\t\t\t}\n\t\t\tResetMouseEventArgs();\n\t\t}\n\t\t\n\t\tprotected override void OnMouseHover(EventArgs e)\n\t\t{\n\t\t\tbase.OnMouseHover(e);\n\t\t\t//Console.WriteLine(\"Hover raised at \" + PointToClient(Control.MousePosition));\n\t\t\tif (MouseButtons == MouseButtons.None) {\n\t\t\t\tRequestToolTip(PointToClient(Control.MousePosition));\n\t\t\t} else {\n\t\t\t\tCloseToolTip();\n\t\t\t}\n\t\t}\n\t\t\n\t\tprotected void RequestToolTip(Point mousePos)\n\t\t{\n\t\t\tif (toolTipRectangle.Contains(mousePos)) {\n\t\t\t\tif (!toolTipActive)\n\t\t\t\t\tResetMouseEventArgs();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\t//Console.WriteLine(\"Request tooltip for \" + mousePos);\n\t\t\t\n\t\t\ttoolTipRectangle = new Rectangle(mousePos.X - 4, mousePos.Y - 4, 8, 8);\n\t\t\t\n\t\t\tTextLocation logicPos = textView.GetLogicalPosition(mousePos.X - textView.DrawingPosition.Left,\n\t\t\t                                                    mousePos.Y - textView.DrawingPosition.Top);\n\t\t\tbool inDocument = textView.DrawingPosition.Contains(mousePos)\n\t\t\t\t&& logicPos.Y >= 0 && logicPos.Y < Document.TotalNumberOfLines;\n\t\t\tToolTipRequestEventArgs args = new ToolTipRequestEventArgs(mousePos, logicPos, inDocument);\n\t\t\tOnToolTipRequest(args);\n\t\t\tif (args.ToolTipShown) {\n\t\t\t\t//Console.WriteLine(\"Set tooltip to \" + args.toolTipText);\n\t\t\t\ttoolTipActive = true;\n\t\t\t\tSetToolTip(args.toolTipText, inDocument ? logicPos.Y + 1 : -1);\n\t\t\t} else {\n\t\t\t\tCloseToolTip();\n\t\t\t}\n\t\t}\n\t\t\n\t\t// external interface to the attached event\n\t\tinternal void RaiseMouseMove(MouseEventArgs e)\n\t\t{\n\t\t\tOnMouseMove(e);\n\t\t}\n\n\t\tprotected override void OnMouseMove(MouseEventArgs e)\n\t\t{\n\t\t\tbase.OnMouseMove(e);\n\t\t\tif (!toolTipRectangle.Contains(e.Location)) {\n\t\t\t\ttoolTipRectangle = Rectangle.Empty;\n\t\t\t\tif (toolTipActive)\n\t\t\t\t\tRequestToolTip(e.Location);\n\t\t\t}\n\t\t\tforeach (AbstractMargin margin in leftMargins) {\n\t\t\t\tif (margin.DrawingPosition.Contains(e.X, e.Y)) {\n\t\t\t\t\tthis.Cursor = margin.Cursor;\n\t\t\t\t\tmargin.HandleMouseMove(new Point(e.X, e.Y), e.Button);\n\t\t\t\t\tif (lastMouseInMargin != margin) {\n\t\t\t\t\t\tif (lastMouseInMargin != null) {\n\t\t\t\t\t\t\tlastMouseInMargin.HandleMouseLeave(EventArgs.Empty);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlastMouseInMargin = margin;\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (lastMouseInMargin != null) {\n\t\t\t\tlastMouseInMargin.HandleMouseLeave(EventArgs.Empty);\n\t\t\t\tlastMouseInMargin = null;\n\t\t\t}\n\t\t\tif (textView.DrawingPosition.Contains(e.X, e.Y)) {\n\t\t\t\tTextLocation realmousepos = TextView.GetLogicalPosition(e.X - TextView.DrawingPosition.X, e.Y - TextView.DrawingPosition.Y);\n\t\t\t\tif(SelectionManager.IsSelected(Document.PositionToOffset(realmousepos)) && MouseButtons == MouseButtons.None) {\n\t\t\t\t\t// mouse is hovering over a selection, so show default mouse\n\t\t\t\t\tthis.Cursor = Cursors.Default;\n\t\t\t\t} else {\n\t\t\t\t\t// mouse is hovering over text area, not a selection, so show the textView cursor\n\t\t\t\t\tthis.Cursor = textView.Cursor;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.Cursor = Cursors.Default;\n\t\t}\n\t\tAbstractMargin updateMargin = null;\n\t\t\n\t\tpublic void Refresh(AbstractMargin margin)\n\t\t{\n\t\t\tupdateMargin = margin;\n\t\t\tInvalidate(updateMargin.DrawingPosition);\n\t\t\tUpdate();\n\t\t\tupdateMargin = null;\n\t\t}\n\t\t\n\t\tprotected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs pevent)\n\t\t{\n\t\t}\n\t\t\n\t\tprotected override void OnPaint(System.Windows.Forms.PaintEventArgs e)\n\t\t{\n\t\t\tint currentXPos = 0;\n\t\t\tint currentYPos = 0;\n\t\t\tbool adjustScrollBars = false;\n\t\t\tGraphics  g             = e.Graphics;\n\t\t\tRectangle clipRectangle = e.ClipRectangle;\n\t\t\t\n\t\t\tbool isFullRepaint = clipRectangle.X == 0 && clipRectangle.Y == 0\n\t\t\t\t&& clipRectangle.Width == this.Width && clipRectangle.Height == this.Height;\n\t\t\t\n\t\t\tg.TextRenderingHint = this.TextEditorProperties.TextRenderingHint;\n\t\t\t\n\t\t\tif (updateMargin != null) {\n\t\t\t\tupdateMargin.Paint(g, updateMargin.DrawingPosition);\n//\t\t\t\tclipRectangle.Intersect(updateMargin.DrawingPosition);\n\t\t\t}\n\t\t\t\n\t\t\tif (clipRectangle.Width <= 0 || clipRectangle.Height <= 0) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tforeach (AbstractMargin margin in leftMargins) {\n\t\t\t\tif (margin.IsVisible) {\n\t\t\t\t\tRectangle marginRectangle = new Rectangle(currentXPos , currentYPos, margin.Size.Width, Height - currentYPos);\n\t\t\t\t\tif (marginRectangle != margin.DrawingPosition) {\n\t\t\t\t\t\t// margin changed size\n\t\t\t\t\t\tif (!isFullRepaint && !clipRectangle.Contains(marginRectangle)) {\n\t\t\t\t\t\t\tInvalidate(); // do a full repaint\n\t\t\t\t\t\t}\n\t\t\t\t\t\tadjustScrollBars = true;\n\t\t\t\t\t\tmargin.DrawingPosition = marginRectangle;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentXPos += margin.DrawingPosition.Width;\n\t\t\t\t\tif (clipRectangle.IntersectsWith(marginRectangle)) {\n\t\t\t\t\t\tmarginRectangle.Intersect(clipRectangle);\n\t\t\t\t\t\tif (!marginRectangle.IsEmpty) {\n\t\t\t\t\t\t\tmargin.Paint(g, marginRectangle);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tRectangle textViewArea = new Rectangle(currentXPos, currentYPos, Width - currentXPos, Height - currentYPos);\n\t\t\tif (textViewArea != textView.DrawingPosition) {\n\t\t\t\tadjustScrollBars = true;\n\t\t\t\ttextView.DrawingPosition = textViewArea;\n\t\t\t\t// update caret position (but outside of WM_PAINT!)\n\t\t\t\tBeginInvoke((MethodInvoker)caret.UpdateCaretPosition);\n\t\t\t}\n\t\t\tif (clipRectangle.IntersectsWith(textViewArea)) {\n\t\t\t\ttextViewArea.Intersect(clipRectangle);\n\t\t\t\tif (!textViewArea.IsEmpty) {\n\t\t\t\t\ttextView.Paint(g, textViewArea);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (adjustScrollBars) {\n\t\t\t\tthis.motherTextAreaControl.AdjustScrollBars();\n\t\t\t}\n\t\t\t\n\t\t\t// we cannot update the caret position here, it's not allowed to call the caret API inside WM_PAINT\n\t\t\t//Caret.UpdateCaretPosition();\n\t\t\t\n\t\t\tbase.OnPaint(e);\n\t\t}\n\t\tvoid DocumentFoldingsChanged(object sender, EventArgs e)\n\t\t{\n\t\t\tCaret.UpdateCaretPosition();\n\t\t\tInvalidate();\n\t\t\tthis.motherTextAreaControl.AdjustScrollBars();\n\t\t}\n\t\t\n\t\t#region keyboard handling methods\n\t\t\n\t\t/// <summary>\n\t\t/// This method is called on each Keypress\n\t\t/// </summary>\n\t\t/// <returns>\n\t\t/// True, if the key is handled by this method and should NOT be\n\t\t/// inserted in the textarea.\n\t\t/// </returns>\n\t\tprotected internal virtual bool HandleKeyPress(char ch)\n\t\t{\n\t\t\tif (KeyEventHandler != null) {\n\t\t\t\treturn KeyEventHandler(ch);\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\t// Fixes SD2-747: Form containing the text editor and a button with a shortcut\n\t\tprotected override bool IsInputChar(char charCode)\n\t\t{\n\t\t\treturn true;\n\t\t}\n\t\t\n\t\tinternal bool IsReadOnly(int offset)\n\t\t{\n\t\t\tif (Document.ReadOnly) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (TextEditorProperties.SupportReadOnlySegments) {\n\t\t\t\treturn Document.MarkerStrategy.GetMarkers(offset).Exists(m=>m.IsReadOnly);\n\t\t\t} else {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\t\n\t\tinternal bool IsReadOnly(int offset, int length)\n\t\t{\n\t\t\tif (Document.ReadOnly) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (TextEditorProperties.SupportReadOnlySegments) {\n\t\t\t\treturn Document.MarkerStrategy.GetMarkers(offset, length).Exists(m=>m.IsReadOnly);\n\t\t\t} else {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic void SimulateKeyPress(char ch)\n\t\t{\n\t\t\tif (SelectionManager.HasSomethingSelected) {\n\t\t\t\tif (SelectionManager.SelectionIsReadonly)\n\t\t\t\t\treturn;\n\t\t\t} else if (IsReadOnly(Caret.Offset)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\n            //////////////////////////////////////////////////////////////////////////\n            // JDB 4/19/2015 -- Fix for Pyramid\n            //    You guys do not break lines when the shift key is down, \n            //    which is unfortunate, because I use BSD style brace placement \n            //    and I am CONSTANTLY hitting enter while the shift key is down after \n            //    closing an if block or for loop.   Looking at your code, I can see why \n            //    this was never a problem for you, but it's driving me bloody crazy\n            //\n            //  It seems that 'ProcessDialogKey' never gets hit on a shift-enter\n            //   but this path does, and so I'm gonna fake it...\n            //\n            if ( ch == '\\r' ){\n                ProcessDialogKey(Keys.Enter);\n                return;\n            }\n            ///////////////////////////////////////////////////////////////\n\t\t\tif (ch < ' ') {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tif (!hiddenMouseCursor && TextEditorProperties.HideMouseCursor) {\n\t\t\t\tif (this.ClientRectangle.Contains(PointToClient(Cursor.Position))) {\n\t\t\t\t\tmouseCursorHidePosition = Cursor.Position;\n\t\t\t\t\thiddenMouseCursor = true;\n\t\t\t\t\tCursor.Hide();\n\t\t\t\t}\n\t\t\t}\n\t\t\tCloseToolTip();\n\t\t\t\n\t\t\tBeginUpdate();\n\t\t\tDocument.UndoStack.StartUndoGroup();\n\t\t\ttry {\n\t\t\t\t// INSERT char\n\t\t\t\tif (!HandleKeyPress(ch)) {\n\t\t\t\t\tswitch (Caret.CaretMode) {\n\t\t\t\t\t\tcase CaretMode.InsertMode:\n\t\t\t\t\t\t\tInsertChar(ch);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase CaretMode.OverwriteMode:\n\t\t\t\t\t\t\tReplaceChar(ch);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tDebug.Assert(false, \"Unknown caret mode \" + Caret.CaretMode);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tint currentLineNr = Caret.Line;\n\t\t\t\tDocument.FormattingStrategy.FormatLine(this, currentLineNr, Document.PositionToOffset(Caret.Position), ch);\n\t\t\t\t\n\t\t\t\tEndUpdate();\n\t\t\t} finally {\n\t\t\t\tDocument.UndoStack.EndUndoGroup();\n\t\t\t}\n\t\t}\n\t\t\n\t\tprotected override void OnKeyPress(KeyPressEventArgs e)\n\t\t{\n\t\t\tbase.OnKeyPress(e);\n\t\t\tSimulateKeyPress(e.KeyChar);\n\t\t\te.Handled = true;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// This method executes a dialog key\n\t\t/// </summary>\n\t\tpublic bool ExecuteDialogKey(Keys keyData)\n\t\t{\n\t\t\t// try, if a dialog key processor was set to use this\n\t\t\tif (DoProcessDialogKey != null && DoProcessDialogKey(keyData)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\t\n\t\t\t// if not (or the process was 'silent', use the standard edit actions\n\t\t\tIEditAction action =  motherTextEditorControl.GetEditAction(keyData);\n\t\t\tAutoClearSelection = true;\n\t\t\tif (action != null) {\n\t\t\t\tBeginUpdate();\n\t\t\t\ttry {\n\t\t\t\t\tlock (Document) {\n\t\t\t\t\t\taction.Execute(this);\n\t\t\t\t\t\tif (SelectionManager.HasSomethingSelected && AutoClearSelection /*&& caretchanged*/) {\n\t\t\t\t\t\t\tif (Document.TextEditorProperties.DocumentSelectionMode == DocumentSelectionMode.Normal) {\n\t\t\t\t\t\t\t\tSelectionManager.ClearSelection();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\tEndUpdate();\n\t\t\t\t\tCaret.UpdateCaretPosition();\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\tprotected override bool ProcessDialogKey(Keys keyData)\n\t\t{\n\t\t\treturn ExecuteDialogKey(keyData) || base.ProcessDialogKey(keyData);\n\t\t}\n\t\t#endregion\n\t\t\n\t\tpublic void ScrollToCaret()\n\t\t{\n\t\t\tmotherTextAreaControl.ScrollToCaret();\n\t\t}\n\t\t\n\t\tpublic void ScrollTo(int line)\n\t\t{\n\t\t\tmotherTextAreaControl.ScrollTo(line);\n\t\t}\n\t\t\n\t\tpublic void BeginUpdate()\n\t\t{\n\t\t\tmotherTextEditorControl.BeginUpdate();\n\t\t}\n\t\t\n\t\tpublic void EndUpdate()\n\t\t{\n\t\t\tmotherTextEditorControl.EndUpdate();\n\t\t}\n\t\t\n\t\tpublic bool EnableCutOrPaste {\n\t\t\tget {\n\t\t\t\tif (motherTextAreaControl == null)\n\t\t\t\t\treturn false;\n\t\t\t\tif (SelectionManager.HasSomethingSelected)\n\t\t\t\t\treturn !SelectionManager.SelectionIsReadonly;\n\t\t\t\telse\n\t\t\t\t\treturn !IsReadOnly(Caret.Offset);\n\t\t\t}\n\t\t}\n\t\t\n\t\tstring GenerateWhitespaceString(int length)\n\t\t{\n\t\t\treturn new String(' ', length);\n\t\t}\n\t\t/// <remarks>\n\t\t/// Inserts a single character at the caret position\n\t\t/// </remarks>\n\t\tpublic void InsertChar(char ch)\n\t\t{\n\t\t\tbool updating = motherTextEditorControl.IsInUpdate;\n\t\t\tif (!updating) {\n\t\t\t\tBeginUpdate();\n\t\t\t}\n\t\t\t\n\t\t\t// filter out forgein whitespace chars and replace them with standard space (ASCII 32)\n\t\t\tif (Char.IsWhiteSpace(ch) && ch != '\\t' && ch != '\\n') {\n\t\t\t\tch = ' ';\n\t\t\t}\n\t\t\t\n\t\t\tDocument.UndoStack.StartUndoGroup();\n\t\t\tif (Document.TextEditorProperties.DocumentSelectionMode == DocumentSelectionMode.Normal &&\n\t\t\t    SelectionManager.SelectionCollection.Count > 0) {\n\t\t\t\tCaret.Position = SelectionManager.SelectionCollection[0].StartPosition;\n\t\t\t\tSelectionManager.RemoveSelectedText();\n\t\t\t}\n\t\t\tLineSegment caretLine = Document.GetLineSegment(Caret.Line);\n\t\t\tint offset = Caret.Offset;\n\t\t\t// use desired column for generated whitespaces\n\t\t\tint dc = Caret.Column;\n\t\t\tif (caretLine.Length < dc && ch != '\\n') {\n\t\t\t\tDocument.Insert(offset, GenerateWhitespaceString(dc - caretLine.Length) + ch);\n\t\t\t} else {\n\t\t\t\tDocument.Insert(offset, ch.ToString());\n\t\t\t}\n\t\t\tDocument.UndoStack.EndUndoGroup();\n\t\t\t++Caret.Column;\n\t\t\t\n\t\t\tif (!updating) {\n\t\t\t\tEndUpdate();\n\t\t\t\tUpdateLineToEnd(Caret.Line, Caret.Column);\n\t\t\t}\n\t\t\t\n\t\t\t// I prefer to set NOT the standard column, if you type something\n//\t\t\t++Caret.DesiredColumn;\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// Inserts a whole string at the caret position\n\t\t/// </remarks>\n\t\tpublic void InsertString(string str)\n\t\t{\n\t\t\tbool updating = motherTextEditorControl.IsInUpdate;\n\t\t\tif (!updating) {\n\t\t\t\tBeginUpdate();\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tDocument.UndoStack.StartUndoGroup();\n\t\t\t\tif (Document.TextEditorProperties.DocumentSelectionMode == DocumentSelectionMode.Normal &&\n\t\t\t\t    SelectionManager.SelectionCollection.Count > 0) {\n\t\t\t\t\tCaret.Position = SelectionManager.SelectionCollection[0].StartPosition;\n\t\t\t\t\tSelectionManager.RemoveSelectedText();\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tint oldOffset = Document.PositionToOffset(Caret.Position);\n\t\t\t\tint oldLine   = Caret.Line;\n\t\t\t\tLineSegment caretLine = Document.GetLineSegment(Caret.Line);\n\t\t\t\tif (caretLine.Length < Caret.Column) {\n\t\t\t\t\tint whiteSpaceLength = Caret.Column - caretLine.Length;\n\t\t\t\t\tDocument.Insert(oldOffset, GenerateWhitespaceString(whiteSpaceLength) + str);\n\t\t\t\t\tCaret.Position = Document.OffsetToPosition(oldOffset + str.Length + whiteSpaceLength);\n\t\t\t\t} else {\n\t\t\t\t\tDocument.Insert(oldOffset, str);\n\t\t\t\t\tCaret.Position = Document.OffsetToPosition(oldOffset + str.Length);\n\t\t\t\t}\n\t\t\t\tDocument.UndoStack.EndUndoGroup();\n\t\t\t\tif (oldLine != Caret.Line) {\n\t\t\t\t\tUpdateToEnd(oldLine);\n\t\t\t\t} else {\n\t\t\t\t\tUpdateLineToEnd(Caret.Line, Caret.Column);\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tif (!updating) {\n\t\t\t\t\tEndUpdate();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// Replaces a char at the caret position\n\t\t/// </remarks>\n\t\tpublic void ReplaceChar(char ch)\n\t\t{\n\t\t\tbool updating = motherTextEditorControl.IsInUpdate;\n\t\t\tif (!updating) {\n\t\t\t\tBeginUpdate();\n\t\t\t}\n\t\t\tif (Document.TextEditorProperties.DocumentSelectionMode == DocumentSelectionMode.Normal && SelectionManager.SelectionCollection.Count > 0) {\n\t\t\t\tCaret.Position = SelectionManager.SelectionCollection[0].StartPosition;\n\t\t\t\tSelectionManager.RemoveSelectedText();\n\t\t\t}\n\t\t\t\n\t\t\tint lineNr   = Caret.Line;\n\t\t\tLineSegment  line = Document.GetLineSegment(lineNr);\n\t\t\tint offset = Document.PositionToOffset(Caret.Position);\n\t\t\tif (offset < line.Offset + line.Length) {\n\t\t\t\tDocument.Replace(offset, 1, ch.ToString());\n\t\t\t} else {\n\t\t\t\tDocument.Insert(offset, ch.ToString());\n\t\t\t}\n\t\t\tif (!updating) {\n\t\t\t\tEndUpdate();\n\t\t\t\tUpdateLineToEnd(lineNr, Caret.Column);\n\t\t\t}\n\t\t\t++Caret.Column;\n//\t\t\t++Caret.DesiredColumn;\n\t\t}\n\t\t\n\t\tprotected override void Dispose(bool disposing)\n\t\t{\n\t\t\tbase.Dispose(disposing);\n\t\t\tif (disposing) {\n\t\t\t\tif (!disposed) {\n\t\t\t\t\tdisposed = true;\n\t\t\t\t\tif (caret != null) {\n\t\t\t\t\t\tcaret.PositionChanged -= new EventHandler(SearchMatchingBracket);\n\t\t\t\t\t\tcaret.Dispose();\n\t\t\t\t\t}\n\t\t\t\t\tif (selectionManager != null) {\n\t\t\t\t\t\tselectionManager.Dispose();\n\t\t\t\t\t}\n\t\t\t\t\tDocument.TextContentChanged -= new EventHandler(TextContentChanged);\n\t\t\t\t\tDocument.FoldingManager.FoldingsChanged -= new EventHandler(DocumentFoldingsChanged);\n\t\t\t\t\tmotherTextAreaControl = null;\n\t\t\t\t\tmotherTextEditorControl = null;\n\t\t\t\t\tforeach (AbstractMargin margin in leftMargins) {\n\t\t\t\t\t\tif (margin is IDisposable)\n\t\t\t\t\t\t\t(margin as IDisposable).Dispose();\n\t\t\t\t\t}\n\t\t\t\t\ttextView.Dispose();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t#region UPDATE Commands\n\t\tinternal void UpdateLine(int line)\n\t\t{\n\t\t\tUpdateLines(0, line, line);\n\t\t}\n\t\t\n\t\tinternal void UpdateLines(int lineBegin, int lineEnd)\n\t\t{\n\t\t\tUpdateLines(0, lineBegin, lineEnd);\n\t\t}\n\t\t\n\t\tinternal void UpdateToEnd(int lineBegin)\n\t\t{\n//\t\t\tif (lineBegin > FirstPhysicalLine + textView.VisibleLineCount) {\n//\t\t\t\treturn;\n//\t\t\t}\n\t\t\t\n\t\t\tlineBegin = Document.GetVisibleLine(lineBegin);\n\t\t\tint y         = Math.Max(    0, (int)(lineBegin * textView.FontHeight));\n\t\t\ty = Math.Max(0, y - this.virtualTop.Y);\n\t\t\tRectangle r = new Rectangle(0,\n\t\t\t                            y,\n\t\t\t                            Width,\n\t\t\t                            Height - y);\n\t\t\tInvalidate(r);\n\t\t}\n\t\t\n\t\tinternal void UpdateLineToEnd(int lineNr, int xStart)\n\t\t{\n\t\t\tUpdateLines(xStart, lineNr, lineNr);\n\t\t}\n\t\t\n\t\tinternal void UpdateLine(int line, int begin, int end)\n\t\t{\n\t\t\tUpdateLines(line, line);\n\t\t}\n\t\tint FirstPhysicalLine {\n\t\t\tget {\n\t\t\t\treturn VirtualTop.Y / textView.FontHeight;\n\t\t\t}\n\t\t}\n\t\tinternal void UpdateLines(int xPos, int lineBegin, int lineEnd)\n\t\t{\n//\t\t\tif (lineEnd < FirstPhysicalLine || lineBegin > FirstPhysicalLine + textView.VisibleLineCount) {\n//\t\t\t\treturn;\n//\t\t\t}\n\t\t\t\n\t\t\tInvalidateLines((int)(xPos * this.TextView.WideSpaceWidth), lineBegin, lineEnd);\n\t\t}\n\t\t\n\t\tvoid InvalidateLines(int xPos, int lineBegin, int lineEnd)\n\t\t{\n\t\t\tlineBegin     = Math.Max(Document.GetVisibleLine(lineBegin), FirstPhysicalLine);\n\t\t\tlineEnd       = Math.Min(Document.GetVisibleLine(lineEnd),   FirstPhysicalLine + textView.VisibleLineCount);\n\t\t\tint y         = Math.Max(    0, (int)(lineBegin  * textView.FontHeight));\n\t\t\tint height    = Math.Min(textView.DrawingPosition.Height, (int)((1 + lineEnd - lineBegin) * (textView.FontHeight + 1)));\n\t\t\t\n\t\t\tRectangle r = new Rectangle(0,\n\t\t\t                            y - 1 - this.virtualTop.Y,\n\t\t\t                            Width,\n\t\t\t                            height + 3);\n\t\t\t\n\t\t\tInvalidate(r);\n\t\t}\n\t\t#endregion\n\t\tpublic event KeyEventHandler    KeyEventHandler;\n\t\tpublic event DialogKeyProcessor DoProcessDialogKey;\n\t\t\n\t\t//internal void\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaClipboardHandler.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 3359 $</version>\n// </file>\n\nusing System;\nusing System.Drawing;\nusing System.IO;\nusing System.Runtime.InteropServices;\nusing System.Windows.Forms;\n\nusing ICSharpCode.TextEditor.Document;\nusing ICSharpCode.TextEditor.Util;\n\nnamespace ICSharpCode.TextEditor\n{\n\tpublic class TextAreaClipboardHandler\n\t{\n\t\tTextArea textArea;\n\t\t\n\t\tpublic bool EnableCut {\n\t\t\tget {\n\t\t\t\treturn textArea.EnableCutOrPaste; //textArea.SelectionManager.HasSomethingSelected;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic bool EnableCopy {\n\t\t\tget {\n\t\t\t\treturn true; //textArea.SelectionManager.HasSomethingSelected;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic bool EnablePaste {\n\t\t\tget {\n\t\t\t\tif (!textArea.EnableCutOrPaste)\n\t\t\t\t\treturn false;\n\t\t\t\ttry {\n\t\t\t\t\treturn Clipboard.ContainsText();\n\t\t\t\t} catch (ExternalException) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic bool EnableDelete {\n\t\t\tget {\n\t\t\t\treturn textArea.SelectionManager.HasSomethingSelected && !textArea.SelectionManager.SelectionIsReadonly;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic bool EnableSelectAll {\n\t\t\tget {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic TextAreaClipboardHandler(TextArea textArea)\n\t\t{\n\t\t\tthis.textArea = textArea;\n\t\t\ttextArea.SelectionManager.SelectionChanged += new EventHandler(DocumentSelectionChanged);\n\t\t}\n\t\t\n\t\tvoid DocumentSelectionChanged(object sender, EventArgs e)\n\t\t{\n//\t\t\t((DefaultWorkbench)WorkbenchSingleton.Workbench).UpdateToolbars();\n\t\t}\n\n\t\tconst string LineSelectedType = \"MSDEVLineSelect\";  // This is the type VS 2003 and 2005 use for flagging a whole line copy\n\t\t\n\t\tbool CopyTextToClipboard(string stringToCopy, bool asLine)\n\t\t{\n\t\t\tif (stringToCopy.Length > 0) {\n\t\t\t\tDataObject dataObject = new DataObject();\n\t\t\t\tdataObject.SetData(DataFormats.UnicodeText, true, stringToCopy);\n\t\t\t\tif (asLine) {\n\t\t\t\t\tMemoryStream lineSelected = new MemoryStream(1);\n\t\t\t\t\tlineSelected.WriteByte(1);\n\t\t\t\t\tdataObject.SetData(LineSelectedType, false, lineSelected);\n\t\t\t\t}\n\t\t\t\t// Default has no highlighting, therefore we don't need RTF output\n\t\t\t\tif (textArea.Document.HighlightingStrategy.Name != \"Default\") {\n\t\t\t\t\tdataObject.SetData(DataFormats.Rtf, RtfWriter.GenerateRtf(textArea));\n\t\t\t\t}\n\t\t\t\tOnCopyText(new CopyTextEventArgs(stringToCopy));\n\t\t\t\t\n\t\t\t\tSafeSetClipboard(dataObject);\n\t\t\t\treturn true;\n\t\t\t} else {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\t\n\t\t// Code duplication: TextAreaClipboardHandler.cs also has SafeSetClipboard\n\t\t[ThreadStatic] static int SafeSetClipboardDataVersion;\n\t\t\n\t\tstatic void SafeSetClipboard(object dataObject)\n\t\t{\n\t\t\t// Work around ExternalException bug. (SD2-426)\n\t\t\t// Best reproducable inside Virtual PC.\n\t\t\tint version = unchecked(++SafeSetClipboardDataVersion);\n\t\t\ttry {\n\t\t\t\tClipboard.SetDataObject(dataObject, true);\n\t\t\t} catch (ExternalException) {\n\t\t\t\tTimer timer = new Timer();\n\t\t\t\ttimer.Interval = 100;\n\t\t\t\ttimer.Tick += delegate {\n\t\t\t\t\ttimer.Stop();\n\t\t\t\t\ttimer.Dispose();\n\t\t\t\t\tif (SafeSetClipboardDataVersion == version) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tClipboard.SetDataObject(dataObject, true, 10, 50);\n\t\t\t\t\t\t} catch (ExternalException) { }\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\ttimer.Start();\n\t\t\t}\n\t\t}\n\n\t\tbool CopyTextToClipboard(string stringToCopy)\n\t\t{\n\t\t\treturn CopyTextToClipboard(stringToCopy, false);\n\t\t}\n\t\t\n\t\tpublic void Cut(object sender, EventArgs e)\n\t\t{\n\t\t\tif (textArea.SelectionManager.HasSomethingSelected) {\n\t\t\t\tif (CopyTextToClipboard(textArea.SelectionManager.SelectedText)) {\n\t\t\t\t\tif (textArea.SelectionManager.SelectionIsReadonly)\n\t\t\t\t\t\treturn;\n\t\t\t\t\t// Remove text\n\t\t\t\t\ttextArea.BeginUpdate();\n\t\t\t\t\ttextArea.Caret.Position = textArea.SelectionManager.SelectionCollection[0].StartPosition;\n\t\t\t\t\ttextArea.SelectionManager.RemoveSelectedText();\n\t\t\t\t\ttextArea.EndUpdate();\n\t\t\t\t}\n\t\t\t} else if (textArea.Document.TextEditorProperties.CutCopyWholeLine) {\n\t\t\t\t// No text was selected, select and cut the entire line\n\t\t\t\tint curLineNr = textArea.Document.GetLineNumberForOffset(textArea.Caret.Offset);\n\t\t\t\tLineSegment lineWhereCaretIs = textArea.Document.GetLineSegment(curLineNr);\n\t\t\t\tstring caretLineText = textArea.Document.GetText(lineWhereCaretIs.Offset, lineWhereCaretIs.TotalLength);\n\t\t\t\ttextArea.SelectionManager.SetSelection(textArea.Document.OffsetToPosition(lineWhereCaretIs.Offset), textArea.Document.OffsetToPosition(lineWhereCaretIs.Offset + lineWhereCaretIs.TotalLength));\n\t\t\t\tif (CopyTextToClipboard(caretLineText, true)) {\n\t\t\t\t\tif (textArea.SelectionManager.SelectionIsReadonly)\n\t\t\t\t\t\treturn;\n\t\t\t\t\t// remove line\n\t\t\t\t\ttextArea.BeginUpdate();\n\t\t\t\t\ttextArea.Caret.Position = textArea.Document.OffsetToPosition(lineWhereCaretIs.Offset);\n\t\t\t\t\ttextArea.SelectionManager.RemoveSelectedText();\n\t\t\t\t\ttextArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.PositionToEnd, new TextLocation(0, curLineNr)));\n\t\t\t\t\ttextArea.EndUpdate();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic void Copy(object sender, EventArgs e)\n\t\t{\n\t\t\tif (!CopyTextToClipboard(textArea.SelectionManager.SelectedText) && textArea.Document.TextEditorProperties.CutCopyWholeLine) {\n\t\t\t\t// No text was selected, select the entire line, copy it, and then deselect\n\t\t\t\tint curLineNr = textArea.Document.GetLineNumberForOffset(textArea.Caret.Offset);\n\t\t\t\tLineSegment lineWhereCaretIs = textArea.Document.GetLineSegment(curLineNr);\n\t\t\t\tstring caretLineText = textArea.Document.GetText(lineWhereCaretIs.Offset, lineWhereCaretIs.TotalLength);\n\t\t\t\tCopyTextToClipboard(caretLineText, true);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic void Paste(object sender, EventArgs e)\n\t\t{\n\t\t\tif (!textArea.EnableCutOrPaste) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Clipboard.GetDataObject may throw an exception...\n\t\t\tfor (int i = 0;; i++) {\n\t\t\t\ttry {\n\t\t\t\t\tIDataObject data = Clipboard.GetDataObject();\n\t\t\t\t\tif (data == null)\n\t\t\t\t\t\treturn;\n\t\t\t\t\tbool fullLine = data.GetDataPresent(LineSelectedType);\n\t\t\t\t\tif (data.GetDataPresent(DataFormats.UnicodeText)) {\n\t\t\t\t\t\tstring text = (string)data.GetData(DataFormats.UnicodeText);\n\t\t\t\t\t\tif (text.Length > 0) {\n\t\t\t\t\t\t\ttextArea.Document.UndoStack.StartUndoGroup();\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tif (textArea.SelectionManager.HasSomethingSelected) {\n\t\t\t\t\t\t\t\t\ttextArea.Caret.Position = textArea.SelectionManager.SelectionCollection[0].StartPosition;\n\t\t\t\t\t\t\t\t\ttextArea.SelectionManager.RemoveSelectedText();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (fullLine) {\n\t\t\t\t\t\t\t\t\tint col = textArea.Caret.Column;\n\t\t\t\t\t\t\t\t\ttextArea.Caret.Column = 0;\n\t\t\t\t\t\t\t\t\tif (!textArea.IsReadOnly(textArea.Caret.Offset))\n\t\t\t\t\t\t\t\t\t\ttextArea.InsertString(text);\n\t\t\t\t\t\t\t\t\ttextArea.Caret.Column = col;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t// textArea.EnableCutOrPaste already checked readonly for this case\n\t\t\t\t\t\t\t\t\ttextArea.InsertString(text);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} finally {\n\t\t\t\t\t\t\t\ttextArea.Document.UndoStack.EndUndoGroup();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t} catch (ExternalException) {\n\t\t\t\t\t// GetDataObject does not provide RetryTimes parameter\n\t\t\t\t\tif (i > 5) throw;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic void Delete(object sender, EventArgs e)\n\t\t{\n\t\t\tnew ICSharpCode.TextEditor.Actions.Delete().Execute(textArea);\n\t\t}\n\t\t\n\t\tpublic void SelectAll(object sender, EventArgs e)\n\t\t{\n\t\t\tnew ICSharpCode.TextEditor.Actions.SelectWholeDocument().Execute(textArea);\n\t\t}\n\t\t\n\t\tprotected virtual void OnCopyText(CopyTextEventArgs e)\n\t\t{\n\t\t\tif (CopyText != null) {\n\t\t\t\tCopyText(this, e);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic event CopyTextEventHandler CopyText;\n\t}\n\t\n\tpublic delegate void CopyTextEventHandler(object sender, CopyTextEventArgs e);\n\tpublic class CopyTextEventArgs : EventArgs\n\t{\n\t\tstring text;\n\t\t\n\t\tpublic string Text {\n\t\t\tget {\n\t\t\t\treturn text;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic CopyTextEventArgs(string text)\n\t\t{\n\t\t\tthis.text = text;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaControl.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 3078 $</version>\n// </file>\n\nusing System;\nusing System.ComponentModel;\nusing System.Drawing;\nusing System.Windows.Forms;\n\nusing ICSharpCode.TextEditor.Document;\n\nnamespace ICSharpCode.TextEditor\n{\n\t/// <summary>\n\t/// This class paints the textarea.\n\t/// </summary>\n\t[ToolboxItem(false)]\n\tpublic class TextAreaControl : Panel\n\t{\n\t\tTextEditorControl motherTextEditorControl;\n\t\t\n\t\tHRuler     hRuler     = null;\n\t\t\n\t\tVScrollBar vScrollBar = new VScrollBar();\n\t\tHScrollBar hScrollBar = new HScrollBar();\n\t\tTextArea   textArea;\n\t\tbool       doHandleMousewheel = true;\n\t\tbool       disposed;\n\t\t\n\t\tpublic TextArea TextArea {\n\t\t\tget {\n\t\t\t\treturn textArea;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic SelectionManager SelectionManager {\n\t\t\tget {\n\t\t\t\treturn textArea.SelectionManager;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic Caret Caret {\n\t\t\tget {\n\t\t\t\treturn textArea.Caret;\n\t\t\t}\n\t\t}\n\t\t\n\t\t[Browsable(false)]\n\t\tpublic IDocument Document {\n\t\t\tget {\n\t\t\t\tif (motherTextEditorControl != null)\n\t\t\t\t\treturn motherTextEditorControl.Document;\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic ITextEditorProperties TextEditorProperties {\n\t\t\tget {\n\t\t\t\tif (motherTextEditorControl != null)\n\t\t\t\t\treturn motherTextEditorControl.TextEditorProperties;\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic VScrollBar VScrollBar {\n\t\t\tget {\n\t\t\t\treturn vScrollBar;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic HScrollBar HScrollBar {\n\t\t\tget {\n\t\t\t\treturn hScrollBar;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic bool DoHandleMousewheel {\n\t\t\tget {\n\t\t\t\treturn doHandleMousewheel;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tdoHandleMousewheel = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic TextAreaControl(TextEditorControl motherTextEditorControl)\n\t\t{\n\t\t\tthis.motherTextEditorControl = motherTextEditorControl;\n\t\t\t\n\t\t\tthis.textArea                = new TextArea(motherTextEditorControl, this);\n\t\t\tControls.Add(textArea);\n\t\t\t\n\t\t\tvScrollBar.ValueChanged += new EventHandler(VScrollBarValueChanged);\n\t\t\tControls.Add(this.vScrollBar);\n\t\t\t\n\t\t\thScrollBar.ValueChanged += new EventHandler(HScrollBarValueChanged);\n\t\t\tControls.Add(this.hScrollBar);\n\t\t\tResizeRedraw = true;\n\t\t\t\n\t\t\tDocument.TextContentChanged += DocumentTextContentChanged;\n\t\t\tDocument.DocumentChanged += AdjustScrollBarsOnDocumentChange;\n\t\t\tDocument.UpdateCommited  += DocumentUpdateCommitted;\n\t\t}\n\t\t\n\t\tprotected override void Dispose(bool disposing)\n\t\t{\n\t\t\tif (disposing) {\n\t\t\t\tif (!disposed) {\n\t\t\t\t\tdisposed = true;\n\t\t\t\t\tDocument.TextContentChanged -= DocumentTextContentChanged;\n\t\t\t\t\tDocument.DocumentChanged -= AdjustScrollBarsOnDocumentChange;\n\t\t\t\t\tDocument.UpdateCommited  -= DocumentUpdateCommitted;\n\t\t\t\t\tmotherTextEditorControl = null;\n\t\t\t\t\tif (vScrollBar != null) {\n\t\t\t\t\t\tvScrollBar.Dispose();\n\t\t\t\t\t\tvScrollBar = null;\n\t\t\t\t\t}\n\t\t\t\t\tif (hScrollBar != null) {\n\t\t\t\t\t\thScrollBar.Dispose();\n\t\t\t\t\t\thScrollBar = null;\n\t\t\t\t\t}\n\t\t\t\t\tif (hRuler != null) {\n\t\t\t\t\t\thRuler.Dispose();\n\t\t\t\t\t\thRuler = null;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbase.Dispose(disposing);\n\t\t}\n\t\t\n\t\tvoid DocumentTextContentChanged(object sender, EventArgs e)\n\t\t{\n\t\t\t// after the text content is changed abruptly, we need to validate the\n\t\t\t// caret position - otherwise the caret position is invalid for a short amount\n\t\t\t// of time, which can break client code that expects that the caret position is always valid\n\t\t\tCaret.ValidateCaretPos();\n\t\t}\n\t\t\n\t\tprotected override void OnResize(System.EventArgs e)\n\t\t{\n\t\t\tbase.OnResize(e);\n\t\t\tResizeTextArea();\n\t\t}\n\t\t\n\t\tpublic void ResizeTextArea()\n\t\t{\n\t\t\tint y = 0;\n\t\t\tint h = 0;\n\t\t\tif (hRuler != null) {\n\t\t\t\thRuler.Bounds = new Rectangle(0,\n\t\t\t\t                              0,\n\t\t\t\t                              Width - SystemInformation.HorizontalScrollBarArrowWidth,\n\t\t\t\t                              textArea.TextView.FontHeight);\n\t\t\t\t\n\t\t\t\ty = hRuler.Bounds.Bottom;\n\t\t\t\th = hRuler.Bounds.Height;\n\t\t\t}\n\t\t\t\n\t\t\ttextArea.Bounds = new Rectangle(0, y,\n\t\t\t                                Width - SystemInformation.HorizontalScrollBarArrowWidth,\n\t\t\t                                Height - SystemInformation.VerticalScrollBarArrowHeight - h);\n\t\t\tSetScrollBarBounds();\n\t\t}\n\t\t\n\t\tpublic void SetScrollBarBounds()\n\t\t{\n\t\t\tvScrollBar.Bounds = new Rectangle(textArea.Bounds.Right, 0, SystemInformation.HorizontalScrollBarArrowWidth, Height - SystemInformation.VerticalScrollBarArrowHeight);\n\t\t\thScrollBar.Bounds = new Rectangle(0,\n\t\t\t                                  textArea.Bounds.Bottom,\n\t\t\t                                  Width - SystemInformation.HorizontalScrollBarArrowWidth,\n\t\t\t                                  SystemInformation.VerticalScrollBarArrowHeight);\n\t\t}\n\t\t\n\t\tbool adjustScrollBarsOnNextUpdate;\n\t\tPoint scrollToPosOnNextUpdate;\n\t\t\n\t\tvoid AdjustScrollBarsOnDocumentChange(object sender, DocumentEventArgs e)\n\t\t{\n\t\t\tif (motherTextEditorControl.IsInUpdate == false) {\n\t\t\t\tAdjustScrollBarsClearCache();\n\t\t\t\tAdjustScrollBars();\n\t\t\t} else {\n\t\t\t\tadjustScrollBarsOnNextUpdate = true;\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid DocumentUpdateCommitted(object sender, EventArgs e)\n\t\t{\n\t\t\tif (motherTextEditorControl.IsInUpdate == false) {\n\t\t\t\tCaret.ValidateCaretPos();\n\t\t\t\t\n\t\t\t\t// AdjustScrollBarsOnCommittedUpdate\n\t\t\t\tif (!scrollToPosOnNextUpdate.IsEmpty) {\n\t\t\t\t\tScrollTo(scrollToPosOnNextUpdate.Y, scrollToPosOnNextUpdate.X);\n\t\t\t\t}\n\t\t\t\tif (adjustScrollBarsOnNextUpdate) {\n\t\t\t\t\tAdjustScrollBarsClearCache();\n\t\t\t\t\tAdjustScrollBars();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tint[] lineLengthCache;\n\t\tconst int LineLengthCacheAdditionalSize = 100;\n\t\t\n\t\tvoid AdjustScrollBarsClearCache()\n\t\t{\n\t\t\tif (lineLengthCache != null) {\n\t\t\t\tif (lineLengthCache.Length < this.Document.TotalNumberOfLines + 2 * LineLengthCacheAdditionalSize) {\n\t\t\t\t\tlineLengthCache = null;\n\t\t\t\t} else {\n\t\t\t\t\tArray.Clear(lineLengthCache, 0, lineLengthCache.Length);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic void AdjustScrollBars()\n\t\t{\n\t\t\tadjustScrollBarsOnNextUpdate = false;\n\t\t\tvScrollBar.Minimum = 0;\n\t\t\t// number of visible lines in document (folding!)\n\t\t\tvScrollBar.Maximum = textArea.MaxVScrollValue;\n\t\t\tint max = 0;\n\t\t\t\n\t\t\tint firstLine = textArea.TextView.FirstVisibleLine;\n\t\t\tint lastLine = this.Document.GetFirstLogicalLine(textArea.TextView.FirstPhysicalLine + textArea.TextView.VisibleLineCount);\n\t\t\tif (lastLine >= this.Document.TotalNumberOfLines)\n\t\t\t\tlastLine = this.Document.TotalNumberOfLines - 1;\n\t\t\t\n\t\t\tif (lineLengthCache == null || lineLengthCache.Length <= lastLine) {\n\t\t\t\tlineLengthCache = new int[lastLine + LineLengthCacheAdditionalSize];\n\t\t\t}\n\t\t\t\n\t\t\tfor (int lineNumber = firstLine; lineNumber <= lastLine; lineNumber++) {\n\t\t\t\tLineSegment lineSegment = this.Document.GetLineSegment(lineNumber);\n\t\t\t\tif (Document.FoldingManager.IsLineVisible(lineNumber)) {\n\t\t\t\t\tif (lineLengthCache[lineNumber] > 0) {\n\t\t\t\t\t\tmax = Math.Max(max, lineLengthCache[lineNumber]);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tint visualLength = textArea.TextView.GetVisualColumnFast(lineSegment, lineSegment.Length);\n\t\t\t\t\t\tlineLengthCache[lineNumber] = Math.Max(1, visualLength);\n\t\t\t\t\t\tmax = Math.Max(max, visualLength);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\thScrollBar.Minimum = 0;\n\t\t\thScrollBar.Maximum = (Math.Max(max + 20, textArea.TextView.VisibleColumnCount - 1));\n\t\t\t\n\t\t\tvScrollBar.LargeChange = Math.Max(0, textArea.TextView.DrawingPosition.Height);\n\t\t\tvScrollBar.SmallChange = Math.Max(0, textArea.TextView.FontHeight);\n\t\t\t\n\t\t\thScrollBar.LargeChange = Math.Max(0, textArea.TextView.VisibleColumnCount - 1);\n\t\t\thScrollBar.SmallChange = Math.Max(0, (int)textArea.TextView.SpaceWidth);\n\t\t}\n\t\t\n\t\tpublic void OptionsChanged()\n\t\t{\n\t\t\ttextArea.OptionsChanged();\n\t\t\t\n\t\t\tif (textArea.TextEditorProperties.ShowHorizontalRuler) {\n\t\t\t\tif (hRuler == null) {\n\t\t\t\t\thRuler = new HRuler(textArea);\n\t\t\t\t\tControls.Add(hRuler);\n\t\t\t\t\tResizeTextArea();\n\t\t\t\t} else {\n\t\t\t\t\thRuler.Invalidate();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (hRuler != null) {\n\t\t\t\t\tControls.Remove(hRuler);\n\t\t\t\t\thRuler.Dispose();\n\t\t\t\t\thRuler = null;\n\t\t\t\t\tResizeTextArea();\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tAdjustScrollBars();\n\t\t}\n\t\t\n\t\tvoid VScrollBarValueChanged(object sender, EventArgs e)\n\t\t{\n\t\t\ttextArea.VirtualTop = new Point(textArea.VirtualTop.X, vScrollBar.Value);\n\t\t\ttextArea.Invalidate();\n\t\t\tAdjustScrollBars();\n\t\t}\n\t\t\n\t\tvoid HScrollBarValueChanged(object sender, EventArgs e)\n\t\t{\n\t\t\ttextArea.VirtualTop = new Point(hScrollBar.Value * textArea.TextView.WideSpaceWidth, textArea.VirtualTop.Y);\n\t\t\ttextArea.Invalidate();\n\t\t}\n\t\t\n\t\tUtil.MouseWheelHandler mouseWheelHandler = new Util.MouseWheelHandler();\n\t\t\n\t\tpublic void HandleMouseWheel(MouseEventArgs e)\n\t\t{\n\t\t\tint scrollDistance = mouseWheelHandler.GetScrollAmount(e);\n\t\t\tif (scrollDistance == 0)\n\t\t\t\treturn;\n\t\t\tif ((Control.ModifierKeys & Keys.Control) != 0 && TextEditorProperties.MouseWheelTextZoom) {\n\t\t\t\tif (scrollDistance > 0) {\n\t\t\t\t\tmotherTextEditorControl.Font = new Font(motherTextEditorControl.Font.Name,\n\t\t\t\t\t                                        motherTextEditorControl.Font.Size + 1);\n\t\t\t\t} else {\n\t\t\t\t\tmotherTextEditorControl.Font = new Font(motherTextEditorControl.Font.Name,\n\t\t\t\t\t                                        Math.Max(6, motherTextEditorControl.Font.Size - 1));\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (TextEditorProperties.MouseWheelScrollDown)\n\t\t\t\t\tscrollDistance = -scrollDistance;\n\t\t\t\tint newValue = vScrollBar.Value + vScrollBar.SmallChange * scrollDistance;\n\t\t\t\tvScrollBar.Value = Math.Max(vScrollBar.Minimum, Math.Min(vScrollBar.Maximum - vScrollBar.LargeChange + 1, newValue));\n\t\t\t}\n\t\t}\n\t\t\n\t\tprotected override void OnMouseWheel(MouseEventArgs e)\n\t\t{\n\t\t\tbase.OnMouseWheel(e);\n\t\t\tif (DoHandleMousewheel) {\n\t\t\t\tHandleMouseWheel(e);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic void ScrollToCaret()\n\t\t{\n\t\t\tScrollTo(textArea.Caret.Line, textArea.Caret.Column);\n\t\t}\n\t\t\n\t\tpublic void ScrollTo(int line, int column)\n\t\t{\n\t\t\tif (motherTextEditorControl.IsInUpdate) {\n\t\t\t\tscrollToPosOnNextUpdate = new Point(column, line);\n\t\t\t\treturn;\n\t\t\t} else {\n\t\t\t\tscrollToPosOnNextUpdate = Point.Empty;\n\t\t\t}\n\t\t\t\n\t\t\tScrollTo(line);\n\t\t\t\n\t\t\tint curCharMin  = (int)(this.hScrollBar.Value - this.hScrollBar.Minimum);\n\t\t\tint curCharMax  = curCharMin + textArea.TextView.VisibleColumnCount;\n\t\t\t\n\t\t\tint pos = textArea.TextView.GetVisualColumn(line, column);\n\t\t\t\n\t\t\tif (textArea.TextView.VisibleColumnCount < 0) {\n\t\t\t\thScrollBar.Value = 0;\n\t\t\t} else {\n\t\t\t\tif (pos < curCharMin) {\n\t\t\t\t\thScrollBar.Value = (int)(Math.Max(0, pos - scrollMarginHeight));\n\t\t\t\t} else {\n\t\t\t\t\tif (pos > curCharMax) {\n\t\t\t\t\t\thScrollBar.Value = (int)Math.Max(0, Math.Min(hScrollBar.Maximum, (pos - textArea.TextView.VisibleColumnCount + scrollMarginHeight)));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tint scrollMarginHeight  = 3;\n\t\t\n\t\t/// <summary>\n\t\t/// Ensure that <paramref name=\"line\"/> is visible.\n\t\t/// </summary>\n\t\tpublic void ScrollTo(int line)\n\t\t{\n\t\t\tline = Math.Max(0, Math.Min(Document.TotalNumberOfLines - 1, line));\n\t\t\tline = Document.GetVisibleLine(line);\n\t\t\tint curLineMin = textArea.TextView.FirstPhysicalLine;\n\t\t\tif (textArea.TextView.LineHeightRemainder > 0) {\n\t\t\t\tcurLineMin ++;\n\t\t\t}\n\t\t\t\n\t\t\tif (line - scrollMarginHeight + 3 < curLineMin) {\n\t\t\t\tthis.vScrollBar.Value =  Math.Max(0, Math.Min(this.vScrollBar.Maximum, (line - scrollMarginHeight + 3) * textArea.TextView.FontHeight)) ;\n\t\t\t\tVScrollBarValueChanged(this, EventArgs.Empty);\n\t\t\t} else {\n\t\t\t\tint curLineMax = curLineMin + this.textArea.TextView.VisibleLineCount;\n\t\t\t\tif (line + scrollMarginHeight - 1 > curLineMax) {\n\t\t\t\t\tif (this.textArea.TextView.VisibleLineCount == 1) {\n\t\t\t\t\t\tthis.vScrollBar.Value =  Math.Max(0, Math.Min(this.vScrollBar.Maximum, (line - scrollMarginHeight - 1) * textArea.TextView.FontHeight)) ;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.vScrollBar.Value = Math.Min(this.vScrollBar.Maximum,\n\t\t\t\t\t\t                                 (line - this.textArea.TextView.VisibleLineCount + scrollMarginHeight - 1)* textArea.TextView.FontHeight) ;\n\t\t\t\t\t}\n\t\t\t\t\tVScrollBarValueChanged(this, EventArgs.Empty);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Scroll so that the specified line is centered.\n\t\t/// </summary>\n\t\t/// <param name=\"line\">Line to center view on</param>\n\t\t/// <param name=\"treshold\">If this action would cause scrolling by less than or equal to\n\t\t/// <paramref name=\"treshold\"/> lines in any direction, don't scroll.\n\t\t/// Use -1 to always center the view.</param>\n\t\tpublic void CenterViewOn(int line, int treshold)\n\t\t{\n\t\t\tline = Math.Max(0, Math.Min(Document.TotalNumberOfLines - 1, line));\n\t\t\t// convert line to visible line:\n\t\t\tline = Document.GetVisibleLine(line);\n\t\t\t// subtract half the visible line count\n\t\t\tline -= textArea.TextView.VisibleLineCount / 2;\n\t\t\t\n\t\t\tint curLineMin = textArea.TextView.FirstPhysicalLine;\n\t\t\tif (textArea.TextView.LineHeightRemainder > 0) {\n\t\t\t\tcurLineMin ++;\n\t\t\t}\n\t\t\tif (Math.Abs(curLineMin - line) > treshold) {\n\t\t\t\t// scroll:\n\t\t\t\tthis.vScrollBar.Value =  Math.Max(0, Math.Min(this.vScrollBar.Maximum, (line - scrollMarginHeight + 3) * textArea.TextView.FontHeight)) ;\n\t\t\t\tVScrollBarValueChanged(this, EventArgs.Empty);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic void JumpTo(int line)\n\t\t{\n\t\t\tline = Math.Min(line, Document.TotalNumberOfLines - 1);\n\t\t\tstring text = Document.GetText(Document.GetLineSegment(line));\n\t\t\tJumpTo(line, text.Length - text.TrimStart().Length);\n\t\t}\n\t\t\n\t\tpublic void JumpTo(int line, int column)\n\t\t{\n\t\t\ttextArea.Focus();\n\t\t\ttextArea.SelectionManager.ClearSelection();\n\t\t\ttextArea.Caret.Position = new TextLocation(column, line);\n\t\t\ttextArea.SetDesiredColumn();\n\t\t\tScrollToCaret();\n\t\t}\n\t\t\n\t\tpublic event MouseEventHandler ShowContextMenu;\n\t\t\n\t\tprotected override void WndProc(ref Message m)\n\t\t{\n\t\t\tif (m.Msg == 0x007B) { // handle WM_CONTEXTMENU\n\t\t\t\tif (ShowContextMenu != null) {\n\t\t\t\t\tlong lParam = m.LParam.ToInt64();\n\t\t\t\t\tint x = unchecked((short)(lParam & 0xffff));\n\t\t\t\t\tint y = unchecked((short)((lParam & 0xffff0000) >> 16));\n\t\t\t\t\tif (x == -1 && y == -1) {\n\t\t\t\t\t\tPoint pos = Caret.ScreenPosition;\n\t\t\t\t\t\tShowContextMenu(this, new MouseEventArgs(MouseButtons.None, 0, pos.X, pos.Y + textArea.TextView.FontHeight, 0));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tPoint pos = PointToClient(new Point(x, y));\n\t\t\t\t\t\tShowContextMenu(this, new MouseEventArgs(MouseButtons.Right, 1, pos.X, pos.Y, 0));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbase.WndProc(ref m);\n\t\t}\n\t\t\n\t\tprotected override void OnEnter(EventArgs e)\n\t\t{\n\t\t\t// SD2-1072 - Make sure the caret line is valid if anyone\n\t\t\t// has handlers for the Enter event.\n\t\t\tCaret.ValidateCaretPos();\n\t\t\tbase.OnEnter(e);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaDragDropHandler.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 3205 $</version>\n// </file>\n\nusing System;\nusing System.Drawing;\nusing System.Windows.Forms;\n\nusing ICSharpCode.TextEditor.Document;\n\nnamespace ICSharpCode.TextEditor\n{\n\tpublic class TextAreaDragDropHandler\n\t{\n\t\tpublic static Action<Exception> OnDragDropException = ex => MessageBox.Show(ex.ToString());\n\t\t\n\t\tTextArea textArea;\n\t\t\n\t\tpublic void Attach(TextArea textArea)\n\t\t{\n\t\t\tthis.textArea = textArea;\n\t\t\ttextArea.AllowDrop = true;\n\t\t\t\n\t\t    textArea.DragEnter += MakeDragEventHandler(OnDragEnter);\n\t\t    textArea.DragDrop  += MakeDragEventHandler(OnDragDrop);\n\t\t    textArea.DragOver  += MakeDragEventHandler(OnDragOver);\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Create a drag'n'drop event handler.\n\t\t/// Windows Forms swallows unhandled exceptions during drag'n'drop, so we report them here.\n\t\t/// </summary>\n\t\tstatic DragEventHandler MakeDragEventHandler(DragEventHandler h)\n\t\t{\n\t\t\treturn (sender, e) => {\n\t\t\t\ttry {\n\t\t\t\t\th(sender, e);\n\t\t\t\t} catch (Exception ex) {\n\t\t\t\t\tOnDragDropException(ex);\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t\t\n\t\tstatic DragDropEffects GetDragDropEffect(DragEventArgs e)\n\t\t{\n\t\t\tif ((e.AllowedEffect & DragDropEffects.Move) > 0 &&\n\t\t\t    (e.AllowedEffect & DragDropEffects.Copy) > 0) {\n\t\t\t\treturn (e.KeyState & 8) > 0 ? DragDropEffects.Copy : DragDropEffects.Move;\n\t\t\t} else if ((e.AllowedEffect & DragDropEffects.Move) > 0) {\n\t\t\t\treturn DragDropEffects.Move;\n\t\t\t} else if ((e.AllowedEffect & DragDropEffects.Copy) > 0) {\n\t\t\t\treturn DragDropEffects.Copy;\n\t\t\t}\n\t\t\treturn DragDropEffects.None;\n\t\t}\n\t\t\n\t\tprotected void OnDragEnter(object sender, DragEventArgs e)\n\t\t{\n            // JDB:  Change for pyramid.  Pass the event up to the parent control\n            //  so that external handlers will fire\n            textArea.MotherTextEditorControl.DispatchDragEnter(e);\n\n        //    textArea.Parent.OnDragEnter(sender, e);\n\t\t//\tif (e.Data.GetDataPresent(typeof(string))) {\n\t\t//\t\te.Effect = GetDragDropEffect(e);\n\t\t//\t}\n\t\t}\n\t\t\n\t\t\n\t\tvoid InsertString(int offset, string str)\n\t\t{\n\t\t\ttextArea.Document.Insert(offset, str);\n\t\t\t\n\t\t\ttextArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document,\n\t\t\t                                                            textArea.Document.OffsetToPosition(offset),\n\t\t\t                                                            textArea.Document.OffsetToPosition(offset + str.Length)));\n\t\t\ttextArea.Caret.Position = textArea.Document.OffsetToPosition(offset + str.Length);\n\t\t\ttextArea.Refresh();\n\t\t}\n\t\t\n\t\tprotected void OnDragDrop(object sender, DragEventArgs e)\n\t\t{\n            // JDB:  Change for pyramid.  Pass the event up to the parent control\n            //  so that external handlers will fire\n            textArea.MotherTextEditorControl.DispatchDragDrop(e);\n            /*\n\t\t\tPoint p = textArea.PointToClient(new Point(e.X, e.Y));\n\t\t\t\n\t\t\tif (e.Data.GetDataPresent(typeof(string))) {\n\t\t\t\ttextArea.BeginUpdate();\n\t\t\t\ttextArea.Document.UndoStack.StartUndoGroup();\n\t\t\t\ttry {\n\t\t\t\t\tint offset = textArea.Caret.Offset;\n\t\t\t\t\tif (textArea.IsReadOnly(offset)) {\n\t\t\t\t\t\t// prevent dragging text into readonly section\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif (e.Data.GetDataPresent(typeof(DefaultSelection))) {\n\t\t\t\t\t\tISelection sel = (ISelection)e.Data.GetData(typeof(DefaultSelection));\n\t\t\t\t\t\tif (sel.ContainsPosition(textArea.Caret.Position)) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (GetDragDropEffect(e) == DragDropEffects.Move) {\n\t\t\t\t\t\t\tif (SelectionManager.SelectionIsReadOnly(textArea.Document, sel)) {\n\t\t\t\t\t\t\t\t// prevent dragging text out of readonly section\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tint len = sel.Length;\n\t\t\t\t\t\t\ttextArea.Document.Remove(sel.Offset, len);\n\t\t\t\t\t\t\tif (sel.Offset < offset) {\n\t\t\t\t\t\t\t\toffset -= len;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\ttextArea.SelectionManager.ClearSelection();\n\t\t\t\t\tInsertString(offset, (string)e.Data.GetData(typeof(string)));\n\t\t\t\t\ttextArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea));\n\t\t\t\t} finally {\n\t\t\t\t\ttextArea.Document.UndoStack.EndUndoGroup();\n\t\t\t\t\ttextArea.EndUpdate();\n\t\t\t\t}\n\t\t\t}\n            */\n\t\t}\n\t\t\n\t\tprotected void OnDragOver(object sender, DragEventArgs e)\n\t\t{\n            // JDB:  Change for pyramid.  Pass the event up to the parent control\n            //  so that external handlers will fire\n            textArea.MotherTextEditorControl.DispatchDragOver(e);\n            /*\n\t\t\tif (!textArea.Focused) {\n\t\t\t\ttextArea.Focus();\n\t\t\t}\n\t\t\t\n\t\t\tPoint p = textArea.PointToClient(new Point(e.X, e.Y));\n\t\t\t\n\t\t\tif (textArea.TextView.DrawingPosition.Contains(p.X, p.Y)) {\n\t\t\t\tTextLocation realmousepos= textArea.TextView.GetLogicalPosition(p.X - textArea.TextView.DrawingPosition.X,\n\t\t\t\t                                                                p.Y - textArea.TextView.DrawingPosition.Y);\n\t\t\t\tint lineNr = Math.Min(textArea.Document.TotalNumberOfLines - 1, Math.Max(0, realmousepos.Y));\n\t\t\t\t\n\t\t\t\ttextArea.Caret.Position = new TextLocation(realmousepos.X, lineNr);\n\t\t\t\ttextArea.SetDesiredColumn();\n\t\t\t\tif (e.Data.GetDataPresent(typeof(string)) && !textArea.IsReadOnly(textArea.Caret.Offset)) {\n\t\t\t\t\te.Effect = GetDragDropEffect(e);\n\t\t\t\t} else {\n\t\t\t\t\te.Effect = DragDropEffects.None;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\te.Effect = DragDropEffects.None;\n\t\t\t}*/\n             \n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaMouseHandler.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 3205 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\nusing System.Drawing;\nusing System.Text;\nusing System.Windows.Forms;\n\nusing ICSharpCode.TextEditor.Document;\n\nnamespace ICSharpCode.TextEditor\n{\n\t/// <summary>\n\t/// This class handles all mouse stuff for a textArea.\n\t/// </summary>\n\tpublic class TextAreaMouseHandler\n\t{\n\t\tTextArea  textArea;\n\t\tbool      doubleclick = false;\n\t\tbool      clickedOnSelectedText = false;\n\t\t\n\t\tMouseButtons button;\n\t\t\n\t\tstatic readonly Point nilPoint = new Point(-1, -1);\n\t\tPoint mousedownpos       = nilPoint;\n\t\tPoint lastmousedownpos   = nilPoint;\n\t\t\n\t\tbool gotmousedown = false;\n\t\tbool dodragdrop = false;\n\t\t\n\t\tpublic TextAreaMouseHandler(TextArea ttextArea)\n\t\t{\n\t\t\ttextArea = ttextArea;\n\t\t}\n\t\t\n\t\tpublic void Attach()\n\t\t{\n\t\t\ttextArea.Click       += new EventHandler(TextAreaClick);\n\t\t\ttextArea.MouseMove   += new MouseEventHandler(TextAreaMouseMove);\n\t\t\t\n\t\t\ttextArea.MouseDown   += new MouseEventHandler(OnMouseDown);\n\t\t\ttextArea.DoubleClick += new EventHandler(OnDoubleClick);\n\t\t\ttextArea.MouseLeave  += new EventHandler(OnMouseLeave);\n\t\t\ttextArea.MouseUp     += new MouseEventHandler(OnMouseUp);\n\t\t\ttextArea.LostFocus   += new EventHandler(TextAreaLostFocus);\n\t\t\ttextArea.ToolTipRequest += new ToolTipRequestEventHandler(OnToolTipRequest);\n\t\t}\n\t\t\n\t\tvoid OnToolTipRequest(object sender, ToolTipRequestEventArgs e)\n\t\t{\n\t\t\tif (e.ToolTipShown)\n\t\t\t\treturn;\n\t\t\tPoint mousepos = e.MousePosition;\n\t\t\tFoldMarker marker = textArea.TextView.GetFoldMarkerFromPosition(mousepos.X - textArea.TextView.DrawingPosition.X,\n\t\t\t                                                                mousepos.Y - textArea.TextView.DrawingPosition.Y);\n\t\t\tif (marker != null && marker.IsFolded) {\n\t\t\t\tStringBuilder sb = new StringBuilder(marker.InnerText);\n\t\t\t\t\n\t\t\t\t// max 10 lines\n\t\t\t\tint endLines = 0;\n\t\t\t\tfor (int i = 0; i < sb.Length; ++i) {\n\t\t\t\t\tif (sb[i] == '\\n') {\n\t\t\t\t\t\t++endLines;\n\t\t\t\t\t\tif (endLines >= 10) {\n\t\t\t\t\t\t\tsb.Remove(i + 1, sb.Length - i - 1);\n\t\t\t\t\t\t\tsb.Append(Environment.NewLine);\n\t\t\t\t\t\t\tsb.Append(\"...\");\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tsb.Replace(\"\\t\", \"    \");\n\t\t\t\te.ShowToolTip(sb.ToString());\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tList<TextMarker> markers = textArea.Document.MarkerStrategy.GetMarkers(e.LogicalPosition);\n\t\t\tforeach (TextMarker tm in markers) {\n\t\t\t\tif (tm.ToolTip != null) {\n\t\t\t\t\te.ShowToolTip(tm.ToolTip.Replace(\"\\t\", \"    \"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid ShowHiddenCursorIfMovedOrLeft()\n\t\t{\n\t\t\ttextArea.ShowHiddenCursor(!textArea.Focused ||\n\t\t\t                          !textArea.ClientRectangle.Contains(textArea.PointToClient(Cursor.Position)));\n\t\t}\n\t\t\n\t\tvoid TextAreaLostFocus(object sender, EventArgs e)\n\t\t{\n\t\t\t// The call to ShowHiddenCursorIfMovedOrLeft is delayed\n\t\t\t// until pending messages have been processed\n\t\t\t// so that it can properly detect whether the TextArea\n\t\t\t// has really lost focus.\n\t\t\t// For example, the CodeCompletionWindow gets focus when it is shown,\n\t\t\t// but immediately gives back focus to the TextArea.\n\t\t\ttextArea.BeginInvoke(new MethodInvoker(ShowHiddenCursorIfMovedOrLeft));\n\t\t}\n\t\t\n\t\tvoid OnMouseLeave(object sender, EventArgs e)\n\t\t{\n\t\t\tShowHiddenCursorIfMovedOrLeft();\n\t\t\tgotmousedown = false;\n\t\t\tmousedownpos = nilPoint;\n\t\t}\n\t\t\n\t\tvoid OnMouseUp(object sender, MouseEventArgs e)\n\t\t{\n\t\t\ttextArea.SelectionManager.selectFrom.where = WhereFrom.None;\n\t\t\tgotmousedown = false;\n\t\t\tmousedownpos = nilPoint;\n\t\t}\n\t\t\n\t\tvoid TextAreaClick(object sender, EventArgs e)\n\t\t{\n\t\t\tPoint mousepos;\n\t\t\tmousepos = textArea.mousepos;\n\t\t\t\n\t\t\tif (dodragdrop)\n\t\t\t{\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (clickedOnSelectedText && textArea.TextView.DrawingPosition.Contains(mousepos.X, mousepos.Y))\n\t\t\t{\n\t\t\t\ttextArea.SelectionManager.ClearSelection();\n\n\t\t\t\tTextLocation clickPosition = textArea.TextView.GetLogicalPosition(\n\t\t\t\t\tmousepos.X - textArea.TextView.DrawingPosition.X,\n\t\t\t\t\tmousepos.Y - textArea.TextView.DrawingPosition.Y);\n\t\t\t\ttextArea.Caret.Position = clickPosition;\n\t\t\t\ttextArea.SetDesiredColumn();\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\tvoid TextAreaMouseMove(object sender, MouseEventArgs e)\n\t\t{\n\t\t\ttextArea.mousepos = e.Location;\n\n\t\t\t// honour the starting selection strategy\n\t\t\tswitch (textArea.SelectionManager.selectFrom.where)\n\t\t\t{\n\t\t\t\tcase WhereFrom.Gutter:\n\t\t\t\t\tExtendSelectionToMouse();\n\t\t\t\t\treturn;\n\n\t\t\t\tcase WhereFrom.TArea:\n\t\t\t\t\tbreak;\n\n\t\t\t}\n\t\t\ttextArea.ShowHiddenCursor(false);\n\t\t\tif (dodragdrop) {\n\t\t\t\tdodragdrop = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tdoubleclick = false;\n\t\t\ttextArea.mousepos = new Point(e.X, e.Y);\n\t\t\t\n\t\t\tif (clickedOnSelectedText) {\n\t\t\t\tif (Math.Abs(mousedownpos.X - e.X) >= SystemInformation.DragSize.Width / 2 ||\n\t\t\t\t    Math.Abs(mousedownpos.Y - e.Y) >= SystemInformation.DragSize.Height / 2)\n\t\t\t\t{\n\t\t\t\t\tclickedOnSelectedText = false;\n\t\t\t\t\tISelection selection = textArea.SelectionManager.GetSelectionAt(textArea.Caret.Offset);\n\t\t\t\t\tif (selection != null) {\n\t\t\t\t\t\tstring text = selection.SelectedText;\n\t\t\t\t\t\tbool isReadOnly = SelectionManager.SelectionIsReadOnly(textArea.Document, selection);\n\t\t\t\t\t\tif (text != null && text.Length > 0) {\n\t\t\t\t\t\t\tDataObject dataObject = new DataObject ();\n\t\t\t\t\t\t\tdataObject.SetData(DataFormats.UnicodeText, true, text);\n\t\t\t\t\t\t\tdataObject.SetData(selection);\n\t\t\t\t\t\t\tdodragdrop = true;\n\t\t\t\t\t\t\ttextArea.DoDragDrop(dataObject, isReadOnly ? DragDropEffects.All & ~DragDropEffects.Move : DragDropEffects.All);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tif (e.Button == MouseButtons.Left) {\n\t\t\t\tif (gotmousedown && textArea.SelectionManager.selectFrom.where == WhereFrom.TArea)\n\t\t\t\t{\n\t\t\t\t\tExtendSelectionToMouse();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid ExtendSelectionToMouse()\n\t\t{\n\t\t\tPoint mousepos;\n\t\t\tmousepos = textArea.mousepos;\n\t\t\tTextLocation realmousepos = textArea.TextView.GetLogicalPosition(\n\t\t\t\tMath.Max(0, mousepos.X - textArea.TextView.DrawingPosition.X),\n\t\t\t\tmousepos.Y - textArea.TextView.DrawingPosition.Y);\n\t\t\tint y = realmousepos.Y;\n\t\t\trealmousepos = textArea.Caret.ValidatePosition(realmousepos);\n\t\t\tTextLocation oldPos = textArea.Caret.Position;\n\t\t\tif (oldPos == realmousepos && textArea.SelectionManager.selectFrom.where != WhereFrom.Gutter)\n\t\t\t{\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// the selection is from the gutter\n\t\t\tif (textArea.SelectionManager.selectFrom.where == WhereFrom.Gutter) {\n\t\t\t\tif(realmousepos.Y < textArea.SelectionManager.SelectionStart.Y) {\n\t\t\t\t\t// the selection has moved above the startpoint\n\t\t\t\t\ttextArea.Caret.Position = new TextLocation(0, realmousepos.Y);\n\t\t\t\t} else {\n\t\t\t\t\t// the selection has moved below the startpoint\n\t\t\t\t\ttextArea.Caret.Position = textArea.SelectionManager.NextValidPosition(realmousepos.Y);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttextArea.Caret.Position = realmousepos;\n\t\t\t}\n\n\t\t\t// moves selection across whole words for double-click initiated selection\n\t\t\tif (!minSelection.IsEmpty && textArea.SelectionManager.SelectionCollection.Count > 0 && textArea.SelectionManager.selectFrom.where == WhereFrom.TArea) {\n\t\t\t\t// Extend selection when selection was started with double-click\n\t\t\t\tISelection selection = textArea.SelectionManager.SelectionCollection[0];\n\t\t\t\tTextLocation min = textArea.SelectionManager.GreaterEqPos(minSelection, maxSelection) ? maxSelection : minSelection;\n\t\t\t\tTextLocation max = textArea.SelectionManager.GreaterEqPos(minSelection, maxSelection) ? minSelection : maxSelection;\n\t\t\t\tif (textArea.SelectionManager.GreaterEqPos(max, realmousepos) && textArea.SelectionManager.GreaterEqPos(realmousepos, min)) {\n\t\t\t\t\ttextArea.SelectionManager.SetSelection(min, max);\n\t\t\t\t} else if (textArea.SelectionManager.GreaterEqPos(max, realmousepos)) {\n\t\t\t\t\tint moff = textArea.Document.PositionToOffset(realmousepos);\n\t\t\t\t\tmin = textArea.Document.OffsetToPosition(FindWordStart(textArea.Document, moff));\n\t\t\t\t\ttextArea.SelectionManager.SetSelection(min, max);\n\t\t\t\t} else {\n\t\t\t\t\tint moff = textArea.Document.PositionToOffset(realmousepos);\n\t\t\t\t\tmax = textArea.Document.OffsetToPosition(FindWordEnd(textArea.Document, moff));\n\t\t\t\t\ttextArea.SelectionManager.SetSelection(min, max);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttextArea.SelectionManager.ExtendSelection(oldPos, textArea.Caret.Position);\n\t\t\t}\n\t\t\ttextArea.SetDesiredColumn();\n\t\t}\n\t\t\n\t\tvoid DoubleClickSelectionExtend()\n\t\t{\n\t\t\tPoint mousepos;\n\t\t\tmousepos = textArea.mousepos;\n\t\t\t\n\t\t\ttextArea.SelectionManager.ClearSelection();\n\t\t\tif (textArea.TextView.DrawingPosition.Contains(mousepos.X, mousepos.Y))\n\t\t\t{\n\t\t\t\tFoldMarker marker = textArea.TextView.GetFoldMarkerFromPosition(mousepos.X - textArea.TextView.DrawingPosition.X,\n\t\t\t\t                                                                mousepos.Y - textArea.TextView.DrawingPosition.Y);\n\t\t\t\tif (marker != null && marker.IsFolded) {\n\t\t\t\t\tmarker.IsFolded = false;\n\t\t\t\t\ttextArea.MotherTextAreaControl.AdjustScrollBars();\n\t\t\t\t}\n\t\t\t\tif (textArea.Caret.Offset < textArea.Document.TextLength) {\n\t\t\t\t\tswitch (textArea.Document.GetCharAt(textArea.Caret.Offset)) {\n\t\t\t\t\t\tcase '\"':\n\t\t\t\t\t\t\tif (textArea.Caret.Offset < textArea.Document.TextLength) {\n\t\t\t\t\t\t\t\tint next = FindNext(textArea.Document, textArea.Caret.Offset + 1, '\"');\n\t\t\t\t\t\t\t\tminSelection = textArea.Caret.Position;\n\t\t\t\t\t\t\t\tif (next > textArea.Caret.Offset && next < textArea.Document.TextLength)\n\t\t\t\t\t\t\t\t\tnext += 1;\n\t\t\t\t\t\t\t\tmaxSelection = textArea.Document.OffsetToPosition(next);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tminSelection = textArea.Document.OffsetToPosition(FindWordStart(textArea.Document, textArea.Caret.Offset));\n\t\t\t\t\t\t\tmaxSelection = textArea.Document.OffsetToPosition(FindWordEnd(textArea.Document, textArea.Caret.Offset));\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t\ttextArea.Caret.Position = maxSelection;\n\t\t\t\t\ttextArea.SelectionManager.ExtendSelection(minSelection, maxSelection);\n\t\t\t\t}\n\n\t\t\t\tif (textArea.SelectionManager.selectionCollection.Count > 0) {\n\t\t\t\t\tISelection selection = textArea.SelectionManager.selectionCollection[0];\n\t\t\t\t\t\n\t\t\t\t\tselection.StartPosition = minSelection;\n\t\t\t\t\tselection.EndPosition = maxSelection;\n\t\t\t\t\ttextArea.SelectionManager.SelectionStart = minSelection;\n\t\t\t\t}\n\n\t\t\t\t// after a double-click selection, the caret is placed correctly,\n\t\t\t\t// but it is not positioned internally.  The effect is when the cursor\n\t\t\t\t// is moved up or down a line, the caret will take on the column first\n\t\t\t\t// clicked on for the double-click\n\t\t\t\ttextArea.SetDesiredColumn();\n\n\t\t\t\t// HACK WARNING !!!\n\t\t\t\t// must refresh here, because when a error tooltip is showed and the underlined\n\t\t\t\t// code is double clicked the textArea don't update corrctly, updateline doesn't\n\t\t\t\t// work ... but the refresh does.\n\t\t\t\t// Mike\n\t\t\t\ttextArea.Refresh();\n\t\t\t}\n\t\t}\n\n\t\tvoid OnMouseDown(object sender, MouseEventArgs e)\n\t\t{\n\t\t\tPoint mousepos;\n\t\t\ttextArea.mousepos = e.Location;\n\t\t\tmousepos = e.Location;\n\n\t\t\tif (dodragdrop)\n\t\t\t{\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tif (doubleclick) {\n\t\t\t\tdoubleclick = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tif (textArea.TextView.DrawingPosition.Contains(mousepos.X, mousepos.Y)) {\n\t\t\t\tgotmousedown = true;\n\t\t\t\ttextArea.SelectionManager.selectFrom.where = WhereFrom.TArea;\n\t\t\t\tbutton = e.Button;\n\t\t\t\t\n\t\t\t\t// double-click\n\t\t\t\tif (button == MouseButtons.Left && e.Clicks == 2) {\n\t\t\t\t\tint deltaX   = Math.Abs(lastmousedownpos.X - e.X);\n\t\t\t\t\tint deltaY   = Math.Abs(lastmousedownpos.Y - e.Y);\n\t\t\t\t\tif (deltaX <= SystemInformation.DoubleClickSize.Width &&\n\t\t\t\t\t    deltaY <= SystemInformation.DoubleClickSize.Height) {\n\t\t\t\t\t\tDoubleClickSelectionExtend();\n\t\t\t\t\t\tlastmousedownpos = new Point(e.X, e.Y);\n\n\t\t\t\t\t\tif (textArea.SelectionManager.selectFrom.where == WhereFrom.Gutter) {\n\t\t\t\t\t\t\tif (!minSelection.IsEmpty && !maxSelection.IsEmpty && textArea.SelectionManager.SelectionCollection.Count > 0) {\n\t\t\t\t\t\t\t\ttextArea.SelectionManager.SelectionCollection[0].StartPosition = minSelection;\n\t\t\t\t\t\t\t\ttextArea.SelectionManager.SelectionCollection[0].EndPosition = maxSelection;\n\t\t\t\t\t\t\t\ttextArea.SelectionManager.SelectionStart = minSelection;\n\n\t\t\t\t\t\t\t\tminSelection = TextLocation.Empty;\n\t\t\t\t\t\t\t\tmaxSelection = TextLocation.Empty;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tminSelection = TextLocation.Empty;\n\t\t\t\tmaxSelection = TextLocation.Empty;\n\t\t\t\t\n\t\t\t\tlastmousedownpos = mousedownpos = new Point(e.X, e.Y);\n\t\t\t\t\n\t\t\t\tif (button == MouseButtons.Left) {\n\t\t\t\t\tFoldMarker marker = textArea.TextView.GetFoldMarkerFromPosition(mousepos.X - textArea.TextView.DrawingPosition.X,\n\t\t\t\t\t                                                                mousepos.Y - textArea.TextView.DrawingPosition.Y);\n\t\t\t\t\tif (marker != null && marker.IsFolded) {\n\t\t\t\t\t\tif (textArea.SelectionManager.HasSomethingSelected) {\n\t\t\t\t\t\t\tclickedOnSelectedText = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\ttextArea.SelectionManager.SetSelection(new DefaultSelection(textArea.TextView.Document, new TextLocation(marker.StartColumn, marker.StartLine), new TextLocation(marker.EndColumn, marker.EndLine)));\n\t\t\t\t\t\ttextArea.Focus();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ((Control.ModifierKeys & Keys.Shift) == Keys.Shift) {\n\t\t\t\t\t\tExtendSelectionToMouse();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tTextLocation realmousepos = textArea.TextView.GetLogicalPosition(mousepos.X - textArea.TextView.DrawingPosition.X, mousepos.Y - textArea.TextView.DrawingPosition.Y);\n\t\t\t\t\t\tclickedOnSelectedText = false;\n\t\t\t\t\t\t\n\t\t\t\t\t\tint offset = textArea.Document.PositionToOffset(realmousepos);\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (textArea.SelectionManager.HasSomethingSelected &&\n\t\t\t\t\t\t    textArea.SelectionManager.IsSelected(offset)) {\n\t\t\t\t\t\t\tclickedOnSelectedText = true;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ttextArea.SelectionManager.ClearSelection();\n\t\t\t\t\t\t\tif (mousepos.Y > 0 && mousepos.Y < textArea.TextView.DrawingPosition.Height) {\n\t\t\t\t\t\t\t\tTextLocation pos = new TextLocation();\n\t\t\t\t\t\t\t\tpos.Y = Math.Min(textArea.Document.TotalNumberOfLines - 1,  realmousepos.Y);\n\t\t\t\t\t\t\t\tpos.X = realmousepos.X;\n\t\t\t\t\t\t\t\ttextArea.Caret.Position = pos;\n\t\t\t\t\t\t\t\ttextArea.SetDesiredColumn();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (button == MouseButtons.Right) {\n\t\t\t\t\t// Rightclick sets the cursor to the click position unless\n\t\t\t\t\t// the previous selection was clicked\n\t\t\t\t\tTextLocation realmousepos = textArea.TextView.GetLogicalPosition(mousepos.X - textArea.TextView.DrawingPosition.X, mousepos.Y - textArea.TextView.DrawingPosition.Y);\n\t\t\t\t\tint offset = textArea.Document.PositionToOffset(realmousepos);\n\t\t\t\t\tif (!textArea.SelectionManager.HasSomethingSelected ||\n\t\t\t\t\t    !textArea.SelectionManager.IsSelected(offset))\n\t\t\t\t\t{\n\t\t\t\t\t\ttextArea.SelectionManager.ClearSelection();\n\t\t\t\t\t\tif (mousepos.Y > 0 && mousepos.Y < textArea.TextView.DrawingPosition.Height) {\n\t\t\t\t\t\t\tTextLocation pos = new TextLocation();\n\t\t\t\t\t\t\tpos.Y = Math.Min(textArea.Document.TotalNumberOfLines - 1,  realmousepos.Y);\n\t\t\t\t\t\t\tpos.X = realmousepos.X;\n\t\t\t\t\t\t\ttextArea.Caret.Position = pos;\n\t\t\t\t\t\t\ttextArea.SetDesiredColumn();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttextArea.Focus();\n\t\t}\n\t\t\n\t\tint FindNext(IDocument document, int offset, char ch)\n\t\t{\n\t\t\tLineSegment line = document.GetLineSegmentForOffset(offset);\n\t\t\tint         endPos = line.Offset + line.Length;\n\t\t\t\n\t\t\twhile (offset < endPos && document.GetCharAt(offset) != ch) {\n\t\t\t\t++offset;\n\t\t\t}\n\t\t\treturn offset;\n\t\t}\n\t\t\n\t\tbool IsSelectableChar(char ch)\n\t\t{\n\t\t\treturn Char.IsLetterOrDigit(ch) || ch=='_';\n\t\t}\n\t\t\n\t\tint FindWordStart(IDocument document, int offset)\n\t\t{\n\t\t\tLineSegment line = document.GetLineSegmentForOffset(offset);\n\t\t\t\n\t\t\tif (offset > 0 && Char.IsWhiteSpace(document.GetCharAt(offset - 1)) && Char.IsWhiteSpace(document.GetCharAt(offset))) {\n\t\t\t\twhile (offset > line.Offset && Char.IsWhiteSpace(document.GetCharAt(offset - 1))) {\n\t\t\t\t\t--offset;\n\t\t\t\t}\n\t\t\t} else  if (IsSelectableChar(document.GetCharAt(offset)) || (offset > 0 && Char.IsWhiteSpace(document.GetCharAt(offset)) && IsSelectableChar(document.GetCharAt(offset - 1))))  {\n\t\t\t\twhile (offset > line.Offset && IsSelectableChar(document.GetCharAt(offset - 1))) {\n\t\t\t\t\t--offset;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (offset > 0 && !Char.IsWhiteSpace(document.GetCharAt(offset - 1)) && !IsSelectableChar(document.GetCharAt(offset - 1)) ) {\n\t\t\t\t\treturn Math.Max(0, offset - 1);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn offset;\n\t\t}\n\t\t\n\t\tint FindWordEnd(IDocument document, int offset)\n\t\t{\n\t\t\tLineSegment line   = document.GetLineSegmentForOffset(offset);\n\t\t\tint         endPos = line.Offset + line.Length;\n\t\t\toffset = Math.Min(offset, endPos - 1);\n\t\t\t\n\t\t\tif (IsSelectableChar(document.GetCharAt(offset)))  {\n\t\t\t\twhile (offset < endPos && IsSelectableChar(document.GetCharAt(offset))) {\n\t\t\t\t\t++offset;\n\t\t\t\t}\n\t\t\t} else if (Char.IsWhiteSpace(document.GetCharAt(offset))) {\n\t\t\t\tif (offset > 0 && Char.IsWhiteSpace(document.GetCharAt(offset - 1))) {\n\t\t\t\t\twhile (offset < endPos && Char.IsWhiteSpace(document.GetCharAt(offset))) {\n\t\t\t\t\t\t++offset;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn Math.Max(0, offset + 1);\n\t\t\t}\n\t\t\t\n\t\t\treturn offset;\n\t\t}\n\t\tTextLocation minSelection = TextLocation.Empty;\n\t\tTextLocation maxSelection = TextLocation.Empty;\n\t\t\n\t\tvoid OnDoubleClick(object sender, System.EventArgs e)\n\t\t{\n\t\t\tif (dodragdrop) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\ttextArea.SelectionManager.selectFrom.where = WhereFrom.TArea;\n\t\t\tdoubleclick = true;\n\t\t\t\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaUpdate.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 2659 $</version>\n// </file>\n\nusing System;\nusing System.Drawing;\n\nnamespace ICSharpCode.TextEditor\n{\n\t/// <summary>\n\t/// This enum describes all implemented request types\n\t/// </summary>\n\tpublic enum TextAreaUpdateType {\n\t\tWholeTextArea,\n\t\tSingleLine,\n\t\tSinglePosition,\n\t\tPositionToLineEnd,\n\t\tPositionToEnd,\n\t\tLinesBetween\n\t}\n\t\n\t/// <summary>\n\t/// This class is used to request an update of the textarea\n\t/// </summary>\n\tpublic class TextAreaUpdate\n\t{\n\t\tTextLocation position;\n\t\tTextAreaUpdateType type;\n\t\t\n\t\tpublic TextAreaUpdateType TextAreaUpdateType {\n\t\t\tget {\n\t\t\t\treturn type;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic TextLocation Position {\n\t\t\tget {\n\t\t\t\treturn position;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Creates a new instance of <see cref=\"TextAreaUpdate\"/>\n\t\t/// </summary>\n\t\tpublic TextAreaUpdate(TextAreaUpdateType type)\n\t\t{\n\t\t\tthis.type = type;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Creates a new instance of <see cref=\"TextAreaUpdate\"/>\n\t\t/// </summary>\n\t\tpublic TextAreaUpdate(TextAreaUpdateType type, TextLocation position)\n\t\t{\n\t\t\tthis.type     = type;\n\t\t\tthis.position = position;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Creates a new instance of <see cref=\"TextAreaUpdate\"/>\n\t\t/// </summary>\n\t\tpublic TextAreaUpdate(TextAreaUpdateType type, int startLine, int endLine)\n\t\t{\n\t\t\tthis.type     = type;\n\t\t\tthis.position = new TextLocation(startLine, endLine);\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Creates a new instance of <see cref=\"TextAreaUpdate\"/>\n\t\t/// </summary>\n\t\tpublic TextAreaUpdate(TextAreaUpdateType type, int singleLine)\n\t\t{\n\t\t\tthis.type     = type;\n\t\t\tthis.position = new TextLocation(0, singleLine);\n\t\t}\n\t\t\n\t\tpublic override string ToString()\n\t\t{\n\t\t\treturn String.Format(\"[TextAreaUpdate: Type={0}, Position={1}]\", type, position);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Gui/TextEditorControl.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 3078 $</version>\n// </file>\n\nusing System;\nusing System.ComponentModel;\nusing System.Drawing;\nusing System.Drawing.Printing;\nusing System.Windows.Forms;\n\nusing ICSharpCode.TextEditor.Document;\n\nnamespace ICSharpCode.TextEditor\n{\n\t/// <summary>\n\t/// This class is used for a basic text area control\n\t/// </summary>\n\t[ToolboxBitmap(\"ICSharpCode.TextEditor.Resources.TextEditorControl.bmp\")]\n\t[ToolboxItem(true)]\n\tpublic class TextEditorControl : TextEditorControlBase\n\t{\n\t\tprotected Panel textAreaPanel     = new Panel();\n\t\tTextAreaControl primaryTextArea;\n\t\tSplitter        textAreaSplitter  = null;\n\t\tTextAreaControl secondaryTextArea = null;\n\t\t\n\t\tPrintDocument   printDocument = null;\n\t\t\n\t\t[Browsable(false)]\n\t\tpublic PrintDocument PrintDocument {\n\t\t\tget {\n\t\t\t\tif (printDocument == null) {\n\t\t\t\t\tprintDocument = new PrintDocument();\n\t\t\t\t\tprintDocument.BeginPrint += new PrintEventHandler(this.BeginPrint);\n\t\t\t\t\tprintDocument.PrintPage  += new PrintPageEventHandler(this.PrintPage);\n\t\t\t\t}\n\t\t\t\treturn printDocument;\n\t\t\t}\n\t\t}\n\t\t\n\t\tTextAreaControl activeTextAreaControl;\n\t\t\n\t\tpublic override TextAreaControl ActiveTextAreaControl {\n\t\t\tget {\n\t\t\t\treturn activeTextAreaControl;\n\t\t\t}\n\t\t}\n\t\t\n\t\tprotected void SetActiveTextAreaControl(TextAreaControl value)\n\t\t{\n\t\t\tif (activeTextAreaControl != value) {\n\t\t\t\tactiveTextAreaControl = value;\n\t\t\t\t\n\t\t\t\tif (ActiveTextAreaControlChanged != null) {\n\t\t\t\t\tActiveTextAreaControlChanged(this, EventArgs.Empty);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic event EventHandler ActiveTextAreaControlChanged;\n\t\t\n        // JDB -- Change for pyramid\n        //   The drag handler will pass events up to the TextEditor usercontrol\n        //    so that outside event delegates will fire on a drag\n        internal void DispatchDragDrop(DragEventArgs drgevent)\n        {\n            base.OnDragDrop(drgevent);\n        }\n        internal void DispatchDragEnter(DragEventArgs drgevent)\n        {\n            base.OnDragEnter(drgevent);\n        }\n        internal void DispatchDragOver(DragEventArgs drgevent)\n        {\n            base.OnDragLeave(drgevent);\n        }\n        // JDB\n\n\t\tpublic TextEditorControl()\n\t\t{\n\t\t\tSetStyle(ControlStyles.ContainerControl, true);\n\t\t\t\n\t\t\ttextAreaPanel.Dock = DockStyle.Fill;\n\t\t\t\n\t\t\tDocument = (new DocumentFactory()).CreateDocument();\n\t\t\tDocument.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy();\n\t\t\t\n\t\t\tprimaryTextArea  = new TextAreaControl(this);\n\t\t\tactiveTextAreaControl = primaryTextArea;\n\t\t\tprimaryTextArea.TextArea.GotFocus += delegate {\n\t\t\t\tSetActiveTextAreaControl(primaryTextArea);\n\t\t\t};\n\t\t\tprimaryTextArea.Dock = DockStyle.Fill;\n\t\t\ttextAreaPanel.Controls.Add(primaryTextArea);\n\t\t\tInitializeTextAreaControl(primaryTextArea);\n\t\t\tControls.Add(textAreaPanel);\n\t\t\tResizeRedraw = true;\n\t\t\tDocument.UpdateCommited += new EventHandler(CommitUpdateRequested);\n\t\t\tOptionsChanged();\n\t\t}\n\t\t\n\t\tprotected virtual void InitializeTextAreaControl(TextAreaControl newControl)\n\t\t{\n\t\t}\n\t\t\n\t\tpublic override void OptionsChanged()\n\t\t{\n\t\t\tprimaryTextArea.OptionsChanged();\n\t\t\tif (secondaryTextArea != null) {\n\t\t\t\tsecondaryTextArea.OptionsChanged();\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic void Split()\n\t\t{\n\t\t\tif (secondaryTextArea == null) {\n\t\t\t\tsecondaryTextArea = new TextAreaControl(this);\n\t\t\t\tsecondaryTextArea.Dock = DockStyle.Bottom;\n\t\t\t\tsecondaryTextArea.Height = Height / 2;\n\t\t\t\t\n\t\t\t\tsecondaryTextArea.TextArea.GotFocus += delegate {\n\t\t\t\t\tSetActiveTextAreaControl(secondaryTextArea);\n\t\t\t\t};\n\t\t\t\t\n\t\t\t\ttextAreaSplitter =  new Splitter();\n\t\t\t\ttextAreaSplitter.BorderStyle = BorderStyle.FixedSingle ;\n\t\t\t\ttextAreaSplitter.Height = 8;\n\t\t\t\ttextAreaSplitter.Dock = DockStyle.Bottom;\n\t\t\t\ttextAreaPanel.Controls.Add(textAreaSplitter);\n\t\t\t\ttextAreaPanel.Controls.Add(secondaryTextArea);\n\t\t\t\tInitializeTextAreaControl(secondaryTextArea);\n\t\t\t\tsecondaryTextArea.OptionsChanged();\n\t\t\t} else {\n\t\t\t\tSetActiveTextAreaControl(primaryTextArea);\n\t\t\t\t\n\t\t\t\ttextAreaPanel.Controls.Remove(secondaryTextArea);\n\t\t\t\ttextAreaPanel.Controls.Remove(textAreaSplitter);\n\t\t\t\t\n\t\t\t\tsecondaryTextArea.Dispose();\n\t\t\t\ttextAreaSplitter.Dispose();\n\t\t\t\tsecondaryTextArea = null;\n\t\t\t\ttextAreaSplitter  = null;\n\t\t\t}\n\t\t}\n\t\t\n\t\t[Browsable(false)]\n\t\tpublic bool EnableUndo {\n\t\t\tget {\n\t\t\t\treturn Document.UndoStack.CanUndo;\n\t\t\t}\n\t\t}\n\t\t\n\t\t[Browsable(false)]\n\t\tpublic bool EnableRedo {\n\t\t\tget {\n\t\t\t\treturn Document.UndoStack.CanRedo;\n\t\t\t}\n\t\t}\n\n\t\tpublic void Undo()\n\t\t{\n\t\t\tif (Document.ReadOnly) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (Document.UndoStack.CanUndo) {\n\t\t\t\tBeginUpdate();\n\t\t\t\tDocument.UndoStack.Undo();\n\t\t\t\t\n\t\t\t\tDocument.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea));\n\t\t\t\tthis.primaryTextArea.TextArea.UpdateMatchingBracket();\n\t\t\t\tif (secondaryTextArea != null) {\n\t\t\t\t\tthis.secondaryTextArea.TextArea.UpdateMatchingBracket();\n\t\t\t\t}\n\t\t\t\tEndUpdate();\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic void Redo()\n\t\t{\n\t\t\tif (Document.ReadOnly) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (Document.UndoStack.CanRedo) {\n\t\t\t\tBeginUpdate();\n\t\t\t\tDocument.UndoStack.Redo();\n\t\t\t\t\n\t\t\t\tDocument.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea));\n\t\t\t\tthis.primaryTextArea.TextArea.UpdateMatchingBracket();\n\t\t\t\tif (secondaryTextArea != null) {\n\t\t\t\t\tthis.secondaryTextArea.TextArea.UpdateMatchingBracket();\n\t\t\t\t}\n\t\t\t\tEndUpdate();\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic void SetHighlighting(string name)\n\t\t{\n\t\t\tDocument.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy(name);\n\t\t}\n\t\t\n\t\tprotected override void Dispose(bool disposing)\n\t\t{\n\t\t\tif (disposing) {\n\t\t\t\tif (printDocument != null) {\n\t\t\t\t\tprintDocument.BeginPrint -= new PrintEventHandler(this.BeginPrint);\n\t\t\t\t\tprintDocument.PrintPage  -= new PrintPageEventHandler(this.PrintPage);\n\t\t\t\t\tprintDocument = null;\n\t\t\t\t}\n\t\t\t\tDocument.UndoStack.ClearAll();\n\t\t\t\tDocument.UpdateCommited -= new EventHandler(CommitUpdateRequested);\n\t\t\t\tif (textAreaPanel != null) {\n\t\t\t\t\tif (secondaryTextArea != null) {\n\t\t\t\t\t\tsecondaryTextArea.Dispose();\n\t\t\t\t\t\ttextAreaSplitter.Dispose();\n\t\t\t\t\t\tsecondaryTextArea = null;\n\t\t\t\t\t\ttextAreaSplitter  = null;\n\t\t\t\t\t}\n\t\t\t\t\tif (primaryTextArea != null) {\n\t\t\t\t\t\tprimaryTextArea.Dispose();\n\t\t\t\t\t}\n\t\t\t\t\ttextAreaPanel.Dispose();\n\t\t\t\t\ttextAreaPanel = null;\n\t\t\t\t}\n\t\t\t}\n\t\t\tbase.Dispose(disposing);\n\t\t}\n\t\t\n\t\t#region Update Methods\n\t\tpublic override void EndUpdate()\n\t\t{\n\t\t\tbase.EndUpdate();\n\t\t\tDocument.CommitUpdate();\n\t\t\tif (!IsInUpdate) {\n\t\t\t\tActiveTextAreaControl.Caret.OnEndUpdate();\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid CommitUpdateRequested(object sender, EventArgs e)\n\t\t{\n\t\t\tif (IsInUpdate) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tforeach (TextAreaUpdate update in Document.UpdateQueue) {\n\t\t\t\tswitch (update.TextAreaUpdateType) {\n\t\t\t\t\tcase TextAreaUpdateType.PositionToEnd:\n\t\t\t\t\t\tthis.primaryTextArea.TextArea.UpdateToEnd(update.Position.Y);\n\t\t\t\t\t\tif (this.secondaryTextArea != null) {\n\t\t\t\t\t\t\tthis.secondaryTextArea.TextArea.UpdateToEnd(update.Position.Y);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase TextAreaUpdateType.PositionToLineEnd:\n\t\t\t\t\tcase TextAreaUpdateType.SingleLine:\n\t\t\t\t\t\tthis.primaryTextArea.TextArea.UpdateLine(update.Position.Y);\n\t\t\t\t\t\tif (this.secondaryTextArea != null) {\n\t\t\t\t\t\t\tthis.secondaryTextArea.TextArea.UpdateLine(update.Position.Y);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase TextAreaUpdateType.SinglePosition:\n\t\t\t\t\t\tthis.primaryTextArea.TextArea.UpdateLine(update.Position.Y, update.Position.X, update.Position.X);\n\t\t\t\t\t\tif (this.secondaryTextArea != null) {\n\t\t\t\t\t\t\tthis.secondaryTextArea.TextArea.UpdateLine(update.Position.Y, update.Position.X, update.Position.X);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase TextAreaUpdateType.LinesBetween:\n\t\t\t\t\t\tthis.primaryTextArea.TextArea.UpdateLines(update.Position.X, update.Position.Y);\n\t\t\t\t\t\tif (this.secondaryTextArea != null) {\n\t\t\t\t\t\t\tthis.secondaryTextArea.TextArea.UpdateLines(update.Position.X, update.Position.Y);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase TextAreaUpdateType.WholeTextArea:\n\t\t\t\t\t\tthis.primaryTextArea.TextArea.Invalidate();\n\t\t\t\t\t\tif (this.secondaryTextArea != null) {\n\t\t\t\t\t\t\tthis.secondaryTextArea.TextArea.Invalidate();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tDocument.UpdateQueue.Clear();\n//\t\t\tthis.primaryTextArea.TextArea.Update();\n//\t\t\tif (this.secondaryTextArea != null) {\n//\t\t\t\tthis.secondaryTextArea.TextArea.Update();\n//\t\t\t}\n\t\t}\n\t\t#endregion\n\t\t\n\t\t#region Printing routines\n\t\tint          curLineNr = 0;\n\t\tfloat        curTabIndent = 0;\n\t\tStringFormat printingStringFormat;\n\t\t\n\t\tvoid BeginPrint(object sender, PrintEventArgs ev)\n\t\t{\n\t\t\tcurLineNr = 0;\n\t\t\tprintingStringFormat = (StringFormat)System.Drawing.StringFormat.GenericTypographic.Clone();\n\t\t\t\n\t\t\t// 100 should be enough for everyone ...err ?\n\t\t\tfloat[] tabStops = new float[100];\n\t\t\tfor (int i = 0; i < tabStops.Length; ++i) {\n\t\t\t\ttabStops[i] = TabIndent * primaryTextArea.TextArea.TextView.WideSpaceWidth;\n\t\t\t}\n\t\t\t\n\t\t\tprintingStringFormat.SetTabStops(0, tabStops);\n\t\t}\n\t\t\n\t\tvoid Advance(ref float x, ref float y, float maxWidth, float size, float fontHeight)\n\t\t{\n\t\t\tif (x + size < maxWidth) {\n\t\t\t\tx += size;\n\t\t\t} else {\n\t\t\t\tx  = curTabIndent;\n\t\t\t\ty += fontHeight;\n\t\t\t}\n\t\t}\n\t\t\n\t\t// btw. I hate source code duplication ... but this time I don't care !!!!\n\t\tfloat MeasurePrintingHeight(Graphics g, LineSegment line, float maxWidth)\n\t\t{\n\t\t\tfloat xPos = 0;\n\t\t\tfloat yPos = 0;\n\t\t\tfloat fontHeight = Font.GetHeight(g);\n//\t\t\tbool  gotNonWhitespace = false;\n\t\t\tcurTabIndent = 0;\n\t\t\tFontContainer fontContainer = TextEditorProperties.FontContainer;\n\t\t\tforeach (TextWord word in line.Words) {\n\t\t\t\tswitch (word.Type) {\n\t\t\t\t\tcase TextWordType.Space:\n\t\t\t\t\t\tAdvance(ref xPos, ref yPos, maxWidth, primaryTextArea.TextArea.TextView.SpaceWidth, fontHeight);\n//\t\t\t\t\t\tif (!gotNonWhitespace) {\n//\t\t\t\t\t\t\tcurTabIndent = xPos;\n//\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase TextWordType.Tab:\n\t\t\t\t\t\tAdvance(ref xPos, ref yPos, maxWidth, TabIndent * primaryTextArea.TextArea.TextView.WideSpaceWidth, fontHeight);\n//\t\t\t\t\t\tif (!gotNonWhitespace) {\n//\t\t\t\t\t\t\tcurTabIndent = xPos;\n//\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase TextWordType.Word:\n//\t\t\t\t\t\tif (!gotNonWhitespace) {\n//\t\t\t\t\t\t\tgotNonWhitespace = true;\n//\t\t\t\t\t\t\tcurTabIndent    += TabIndent * primaryTextArea.TextArea.TextView.GetWidth(' ');\n//\t\t\t\t\t\t}\n\t\t\t\t\t\tSizeF drawingSize = g.MeasureString(word.Word, word.GetFont(fontContainer), new SizeF(maxWidth, fontHeight * 100), printingStringFormat);\n\t\t\t\t\t\tAdvance(ref xPos, ref yPos, maxWidth, drawingSize.Width, fontHeight);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn yPos + fontHeight;\n\t\t}\n\t\t\n\t\tvoid DrawLine(Graphics g, LineSegment line, float yPos, RectangleF margin)\n\t\t{\n\t\t\tfloat xPos = 0;\n\t\t\tfloat fontHeight = Font.GetHeight(g);\n//\t\t\tbool  gotNonWhitespace = false;\n\t\t\tcurTabIndent = 0 ;\n\t\t\t\n\t\t\tFontContainer fontContainer = TextEditorProperties.FontContainer;\n\t\t\tforeach (TextWord word in line.Words) {\n\t\t\t\tswitch (word.Type) {\n\t\t\t\t\tcase TextWordType.Space:\n\t\t\t\t\t\tAdvance(ref xPos, ref yPos, margin.Width, primaryTextArea.TextArea.TextView.SpaceWidth, fontHeight);\n//\t\t\t\t\t\tif (!gotNonWhitespace) {\n//\t\t\t\t\t\t\tcurTabIndent = xPos;\n//\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase TextWordType.Tab:\n\t\t\t\t\t\tAdvance(ref xPos, ref yPos, margin.Width, TabIndent * primaryTextArea.TextArea.TextView.WideSpaceWidth, fontHeight);\n//\t\t\t\t\t\tif (!gotNonWhitespace) {\n//\t\t\t\t\t\t\tcurTabIndent = xPos;\n//\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase TextWordType.Word:\n//\t\t\t\t\t\tif (!gotNonWhitespace) {\n//\t\t\t\t\t\t\tgotNonWhitespace = true;\n//\t\t\t\t\t\t\tcurTabIndent    += TabIndent * primaryTextArea.TextArea.TextView.GetWidth(' ');\n//\t\t\t\t\t\t}\n\t\t\t\t\t\tg.DrawString(word.Word, word.GetFont(fontContainer), BrushRegistry.GetBrush(word.Color), xPos + margin.X, yPos);\n\t\t\t\t\t\tSizeF drawingSize = g.MeasureString(word.Word, word.GetFont(fontContainer), new SizeF(margin.Width, fontHeight * 100), printingStringFormat);\n\t\t\t\t\t\tAdvance(ref xPos, ref yPos, margin.Width, drawingSize.Width, fontHeight);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid PrintPage(object sender, PrintPageEventArgs ev)\n\t\t{\n\t\t\tGraphics g = ev.Graphics;\n\t\t\tfloat yPos = ev.MarginBounds.Top;\n\t\t\t\n\t\t\twhile (curLineNr < Document.TotalNumberOfLines) {\n\t\t\t\tLineSegment curLine  = Document.GetLineSegment(curLineNr);\n\t\t\t\tif (curLine.Words != null) {\n\t\t\t\t\tfloat drawingHeight = MeasurePrintingHeight(g, curLine, ev.MarginBounds.Width);\n\t\t\t\t\tif (drawingHeight + yPos > ev.MarginBounds.Bottom) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tDrawLine(g, curLine, yPos, ev.MarginBounds);\n\t\t\t\t\tyPos += drawingHeight;\n\t\t\t\t}\n\t\t\t\t++curLineNr;\n\t\t\t}\n\t\t\t\n\t\t\t// If more lines exist, print another page.\n\t\t\tev.HasMorePages = curLineNr < Document.TotalNumberOfLines;\n\t\t}\n\t\t#endregion\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Gui/TextEditorControlBase.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 2932 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Diagnostics;\nusing System.Drawing;\nusing System.Drawing.Text;\nusing System.IO;\nusing System.Text;\nusing System.Windows.Forms;\n\nusing ICSharpCode.TextEditor.Actions;\nusing ICSharpCode.TextEditor.Document;\n\nnamespace ICSharpCode.TextEditor\n{\n\t/// <summary>\n\t/// This class is used for a basic text area control\n\t/// </summary>\n\t[ToolboxItem(false)]\n\tpublic abstract class TextEditorControlBase : UserControl\n\t{\n\t\tstring    currentFileName = null;\n\t\tint       updateLevel     = 0;\n\t\tIDocument document;\n\t\t\n\t\t/// <summary>\n\t\t/// This hashtable contains all editor keys, where\n\t\t/// the key is the key combination and the value the\n\t\t/// action.\n\t\t/// </summary>\n\t\tprotected Dictionary<Keys, IEditAction> editactions = new Dictionary<Keys, IEditAction>();\n\t\t\n\t\t[Browsable(false)]\n\t\t[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]\n\t\tpublic ITextEditorProperties TextEditorProperties {\n\t\t\tget {\n\t\t\t\treturn document.TextEditorProperties;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tdocument.TextEditorProperties = value;\n\t\t\t\tOptionsChanged();\n\t\t\t}\n\t\t}\n\t\t\n\t\tEncoding encoding;\n\t\t\n\t\t/// <value>\n\t\t/// Current file's character encoding\n\t\t/// </value>\n\t\t[Browsable(false)]\n\t\t[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]\n\t\tpublic Encoding Encoding {\n\t\t\tget {\n\t\t\t\tif (encoding == null)\n\t\t\t\t\treturn TextEditorProperties.Encoding;\n\t\t\t\treturn encoding;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tencoding = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// The current file name\n\t\t/// </value>\n\t\t[Browsable(false)]\n\t\t[ReadOnly(true)]\n\t\tpublic string FileName {\n\t\t\tget {\n\t\t\t\treturn currentFileName;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tif (currentFileName != value) {\n\t\t\t\t\tcurrentFileName = value;\n\t\t\t\t\tOnFileNameChanged(EventArgs.Empty);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// The current document\n\t\t/// </value>\n\t\t[Browsable(false)]\n\t\t[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]\n\t\tpublic IDocument Document {\n\t\t\tget {\n\t\t\t\treturn document;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tif (value == null)\n\t\t\t\t\tthrow new ArgumentNullException(\"value\");\n\t\t\t\tif (document != null) {\n\t\t\t\t\tdocument.DocumentChanged -= OnDocumentChanged;\n\t\t\t\t}\n\t\t\t\tdocument = value;\n\t\t\t\tdocument.UndoStack.TextEditorControl = this;\n\t\t\t\tdocument.DocumentChanged += OnDocumentChanged;\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid OnDocumentChanged(object sender, EventArgs e)\n\t\t{\n\t\t\tOnTextChanged(e);\n\t\t}\n\t\t\n\t\t[EditorBrowsable(EditorBrowsableState.Always), Browsable(true)]\n\t\t[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]\n\t\t[Editor(\"System.ComponentModel.Design.MultilineStringEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\", typeof(System.Drawing.Design.UITypeEditor))]\n\t\tpublic override string Text {\n\t\t\tget {\n\t\t\t\treturn Document.TextContent;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tDocument.TextContent = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\t[EditorBrowsable(EditorBrowsableState.Always), Browsable(true)]\n\t\tpublic new event EventHandler TextChanged\n\t\t{\n\t\t\tadd { base.TextChanged += value; }\n\t\t\tremove { base.TextChanged -= value; }\n\t\t}\n\t\t\n\t\tstatic Font ParseFont(string font)\n\t\t{\n\t\t\tstring[] descr = font.Split(new char[]{',', '='});\n\t\t\treturn new Font(descr[1], Single.Parse(descr[3]));\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// If set to true the contents can't be altered.\n\t\t/// </value>\n\t\t[Browsable(false)]\n\t\tpublic bool IsReadOnly {\n\t\t\tget {\n\t\t\t\treturn Document.ReadOnly;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tDocument.ReadOnly = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// true, if the textarea is updating it's status, while\n\t\t/// it updates it status no redraw operation occurs.\n\t\t/// </value>\n\t\t[Browsable(false)]\n\t\tpublic bool IsInUpdate {\n\t\t\tget {\n\t\t\t\treturn updateLevel > 0;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// supposedly this is the way to do it according to .NET docs,\n\t\t/// as opposed to setting the size in the constructor\n\t\t/// </value>\n\t\tprotected override Size DefaultSize {\n\t\t\tget {\n\t\t\t\treturn new Size(100, 100);\n\t\t\t}\n\t\t}\n\t\t\n\t\t#region Document Properties\n\t\t/// <value>\n\t\t/// If true spaces are shown in the textarea\n\t\t/// </value>\n\t\t[Category(\"Appearance\")]\n\t\t[DefaultValue(false)]\n\t\t[Description(\"If true spaces are shown in the textarea\")]\n\t\tpublic bool ShowSpaces {\n\t\t\tget {\n\t\t\t\treturn document.TextEditorProperties.ShowSpaces;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tdocument.TextEditorProperties.ShowSpaces = value;\n\t\t\t\tOptionsChanged();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// Specifies the quality of text rendering (whether to use hinting and/or anti-aliasing).\n\t\t/// </value>\n\t\t[Category(\"Appearance\")]\n\t\t[DefaultValue(TextRenderingHint.SystemDefault)]\n\t\t[Description(\"Specifies the quality of text rendering (whether to use hinting and/or anti-aliasing).\")]\n\t\tpublic TextRenderingHint TextRenderingHint {\n\t\t\tget {\n\t\t\t\treturn document.TextEditorProperties.TextRenderingHint;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tdocument.TextEditorProperties.TextRenderingHint = value;\n\t\t\t\tOptionsChanged();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// If true tabs are shown in the textarea\n\t\t/// </value>\n\t\t[Category(\"Appearance\")]\n\t\t[DefaultValue(false)]\n\t\t[Description(\"If true tabs are shown in the textarea\")]\n\t\tpublic bool ShowTabs {\n\t\t\tget {\n\t\t\t\treturn document.TextEditorProperties.ShowTabs;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tdocument.TextEditorProperties.ShowTabs = value;\n\t\t\t\tOptionsChanged();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// If true EOL markers are shown in the textarea\n\t\t/// </value>\n\t\t[Category(\"Appearance\")]\n\t\t[DefaultValue(false)]\n\t\t[Description(\"If true EOL markers are shown in the textarea\")]\n\t\tpublic bool ShowEOLMarkers {\n\t\t\tget {\n\t\t\t\treturn document.TextEditorProperties.ShowEOLMarker;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tdocument.TextEditorProperties.ShowEOLMarker = value;\n\t\t\t\tOptionsChanged();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// If true the horizontal ruler is shown in the textarea\n\t\t/// </value>\n\t\t[Category(\"Appearance\")]\n\t\t[DefaultValue(false)]\n\t\t[Description(\"If true the horizontal ruler is shown in the textarea\")]\n\t\tpublic bool ShowHRuler {\n\t\t\tget {\n\t\t\t\treturn document.TextEditorProperties.ShowHorizontalRuler;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tdocument.TextEditorProperties.ShowHorizontalRuler = value;\n\t\t\t\tOptionsChanged();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// If true the vertical ruler is shown in the textarea\n\t\t/// </value>\n\t\t[Category(\"Appearance\")]\n\t\t[DefaultValue(true)]\n\t\t[Description(\"If true the vertical ruler is shown in the textarea\")]\n\t\tpublic bool ShowVRuler {\n\t\t\tget {\n\t\t\t\treturn document.TextEditorProperties.ShowVerticalRuler;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tdocument.TextEditorProperties.ShowVerticalRuler = value;\n\t\t\t\tOptionsChanged();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// The row in which the vertical ruler is displayed\n\t\t/// </value>\n\t\t[Category(\"Appearance\")]\n\t\t[DefaultValue(80)]\n\t\t[Description(\"The row in which the vertical ruler is displayed\")]\n\t\tpublic int VRulerRow {\n\t\t\tget {\n\t\t\t\treturn document.TextEditorProperties.VerticalRulerRow;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tdocument.TextEditorProperties.VerticalRulerRow = value;\n\t\t\t\tOptionsChanged();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// If true line numbers are shown in the textarea\n\t\t/// </value>\n\t\t[Category(\"Appearance\")]\n\t\t[DefaultValue(true)]\n\t\t[Description(\"If true line numbers are shown in the textarea\")]\n\t\tpublic bool ShowLineNumbers {\n\t\t\tget {\n\t\t\t\treturn document.TextEditorProperties.ShowLineNumbers;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tdocument.TextEditorProperties.ShowLineNumbers = value;\n\t\t\t\tOptionsChanged();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// If true invalid lines are marked in the textarea\n\t\t/// </value>\n\t\t[Category(\"Appearance\")]\n\t\t[DefaultValue(false)]\n\t\t[Description(\"If true invalid lines are marked in the textarea\")]\n\t\tpublic bool ShowInvalidLines {\n\t\t\tget {\n\t\t\t\treturn document.TextEditorProperties.ShowInvalidLines;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tdocument.TextEditorProperties.ShowInvalidLines = value;\n\t\t\t\tOptionsChanged();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// If true folding is enabled in the textarea\n\t\t/// </value>\n\t\t[Category(\"Appearance\")]\n\t\t[DefaultValue(true)]\n\t\t[Description(\"If true folding is enabled in the textarea\")]\n\t\tpublic bool EnableFolding {\n\t\t\tget {\n\t\t\t\treturn document.TextEditorProperties.EnableFolding;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tdocument.TextEditorProperties.EnableFolding = value;\n\t\t\t\tOptionsChanged();\n\t\t\t}\n\t\t}\n\t\t\n\t\t[Category(\"Appearance\")]\n\t\t[DefaultValue(true)]\n\t\t[Description(\"If true matching brackets are highlighted\")]\n\t\tpublic bool ShowMatchingBracket {\n\t\t\tget {\n\t\t\t\treturn document.TextEditorProperties.ShowMatchingBracket;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tdocument.TextEditorProperties.ShowMatchingBracket = value;\n\t\t\t\tOptionsChanged();\n\t\t\t}\n\t\t}\n\t\t\n\t\t[Category(\"Appearance\")]\n\t\t[DefaultValue(false)]\n\t\t[Description(\"If true the icon bar is displayed\")]\n\t\tpublic bool IsIconBarVisible {\n\t\t\tget {\n\t\t\t\treturn document.TextEditorProperties.IsIconBarVisible;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tdocument.TextEditorProperties.IsIconBarVisible = value;\n\t\t\t\tOptionsChanged();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// The width in spaces of a tab character\n\t\t/// </value>\n\t\t[Category(\"Appearance\")]\n\t\t[DefaultValue(4)]\n\t\t[Description(\"The width in spaces of a tab character\")]\n\t\tpublic int TabIndent {\n\t\t\tget {\n\t\t\t\treturn document.TextEditorProperties.TabIndent;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tdocument.TextEditorProperties.TabIndent = value;\n\t\t\t\tOptionsChanged();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// The line viewer style\n\t\t/// </value>\n\t\t[Category(\"Appearance\")]\n\t\t[DefaultValue(LineViewerStyle.None)]\n\t\t[Description(\"The line viewer style\")]\n\t\tpublic LineViewerStyle LineViewerStyle {\n\t\t\tget {\n\t\t\t\treturn document.TextEditorProperties.LineViewerStyle;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tdocument.TextEditorProperties.LineViewerStyle = value;\n\t\t\t\tOptionsChanged();\n\t\t\t}\n\t\t}\n\n\t\t/// <value>\n\t\t/// The indent style\n\t\t/// </value>\n\t\t[Category(\"Behavior\")]\n\t\t[DefaultValue(IndentStyle.Smart)]\n\t\t[Description(\"The indent style\")]\n\t\tpublic IndentStyle IndentStyle {\n\t\t\tget {\n\t\t\t\treturn document.TextEditorProperties.IndentStyle;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tdocument.TextEditorProperties.IndentStyle = value;\n\t\t\t\tOptionsChanged();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// if true spaces are converted to tabs\n\t\t/// </value>\n\t\t[Category(\"Behavior\")]\n\t\t[DefaultValue(false)]\n\t\t[Description(\"Converts tabs to spaces while typing\")]\n\t\tpublic bool ConvertTabsToSpaces {\n\t\t\tget {\n\t\t\t\treturn document.TextEditorProperties.ConvertTabsToSpaces;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tdocument.TextEditorProperties.ConvertTabsToSpaces = value;\n\t\t\t\tOptionsChanged();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// if true spaces are converted to tabs\n\t\t/// </value>\n\t\t[Category(\"Behavior\")]\n\t\t[DefaultValue(false)]\n\t\t[Description(\"Hide the mouse cursor while typing\")]\n\t\tpublic bool HideMouseCursor {\n\t\t\tget {\n\t\t\t\treturn document.TextEditorProperties.HideMouseCursor;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tdocument.TextEditorProperties.HideMouseCursor = value;\n\t\t\t\tOptionsChanged();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// if true spaces are converted to tabs\n\t\t/// </value>\n\t\t[Category(\"Behavior\")]\n\t\t[DefaultValue(false)]\n\t\t[Description(\"Allows the caret to be placed beyond the end of line\")]\n\t\tpublic bool AllowCaretBeyondEOL {\n\t\t\tget {\n\t\t\t\treturn document.TextEditorProperties.AllowCaretBeyondEOL;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tdocument.TextEditorProperties.AllowCaretBeyondEOL = value;\n\t\t\t\tOptionsChanged();\n\t\t\t}\n\t\t}\n\t\t/// <value>\n\t\t/// if true spaces are converted to tabs\n\t\t/// </value>\n\t\t[Category(\"Behavior\")]\n\t\t[DefaultValue(BracketMatchingStyle.After)]\n\t\t[Description(\"Specifies if the bracket matching should match the bracket before or after the caret.\")]\n\t\tpublic BracketMatchingStyle BracketMatchingStyle {\n\t\t\tget {\n\t\t\t\treturn document.TextEditorProperties.BracketMatchingStyle;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tdocument.TextEditorProperties.BracketMatchingStyle = value;\n\t\t\t\tOptionsChanged();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <value>\n\t\t/// The base font of the text area. No bold or italic fonts\n\t\t/// can be used because bold/italic is reserved for highlighting\n\t\t/// purposes.\n\t\t/// </value>\n\t\t[Browsable(true)]\n\t\t[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]\n\t\t[Description(\"The base font of the text area. No bold or italic fonts can be used because bold/italic is reserved for highlighting purposes.\")]\n\t\tpublic override Font Font {\n\t\t\tget {\n\t\t\t\treturn document.TextEditorProperties.Font;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tdocument.TextEditorProperties.Font = value;\n\t\t\t\tOptionsChanged();\n\t\t\t}\n\t\t}\n\t\t\n\t\t#endregion\n\t\tpublic abstract TextAreaControl ActiveTextAreaControl {\n\t\t\tget;\n\t\t}\n\t\t\n\t\tprotected TextEditorControlBase()\n\t\t{\n\t\t\tGenerateDefaultActions();\n\t\t\tHighlightingManager.Manager.ReloadSyntaxHighlighting += new EventHandler(OnReloadHighlighting);\n\t\t}\n\t\t\n\t\tprotected virtual void OnReloadHighlighting(object sender, EventArgs e)\n\t\t{\n\t\t\tif (Document.HighlightingStrategy != null) {\n\t\t\t\ttry {\n\t\t\t\t\tDocument.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy(Document.HighlightingStrategy.Name);\n\t\t\t\t} catch (HighlightingDefinitionInvalidException ex) {\n\t\t\t\t\tMessageBox.Show(ex.ToString(), \"Error\", MessageBoxButtons.OK, MessageBoxIcon.Error);\n\t\t\t\t}\n\t\t\t\tOptionsChanged();\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic bool IsEditAction(Keys keyData)\n\t\t{\n\t\t\treturn editactions.ContainsKey(keyData);\n\t\t}\n\t\t\n\t\tinternal IEditAction GetEditAction(Keys keyData)\n\t\t{\n\t\t\tif (!IsEditAction(keyData)) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn (IEditAction)editactions[keyData];\n\t\t}\n\n\t\tvoid GenerateDefaultActions()\n\t\t{\n\t\t\teditactions[Keys.Left] = new CaretLeft();\n\t\t\teditactions[Keys.Left | Keys.Shift] = new ShiftCaretLeft();\n\t\t\teditactions[Keys.Left | Keys.Control] = new WordLeft();\n\t\t\teditactions[Keys.Left | Keys.Control | Keys.Shift] = new ShiftWordLeft();\n\t\t\teditactions[Keys.Right] = new CaretRight();\n\t\t\teditactions[Keys.Right | Keys.Shift] = new ShiftCaretRight();\n\t\t\teditactions[Keys.Right | Keys.Control] = new WordRight();\n\t\t\teditactions[Keys.Right | Keys.Control | Keys.Shift] = new ShiftWordRight();\n\t\t\teditactions[Keys.Up] = new CaretUp();\n\t\t\teditactions[Keys.Up | Keys.Shift] = new ShiftCaretUp();\n\t\t\teditactions[Keys.Up | Keys.Control] = new ScrollLineUp();\n\t\t\teditactions[Keys.Down] = new CaretDown();\n\t\t\teditactions[Keys.Down | Keys.Shift] = new ShiftCaretDown();\n\t\t\teditactions[Keys.Down | Keys.Control] = new ScrollLineDown();\n\t\t\t\n\t\t\teditactions[Keys.Insert] = new ToggleEditMode();\n\t\t\teditactions[Keys.Insert | Keys.Control] = new Copy();\n\t\t\teditactions[Keys.Insert | Keys.Shift] = new Paste();\n\t\t\teditactions[Keys.Delete] = new Delete();\n\t\t\teditactions[Keys.Delete | Keys.Shift] = new Cut();\n\t\t\teditactions[Keys.Home] = new Home();\n\t\t\teditactions[Keys.Home | Keys.Shift] = new ShiftHome();\n\t\t\teditactions[Keys.Home | Keys.Control] = new MoveToStart();\n\t\t\teditactions[Keys.Home | Keys.Control | Keys.Shift] = new ShiftMoveToStart();\n\t\t\teditactions[Keys.End] = new End();\n\t\t\teditactions[Keys.End | Keys.Shift] = new ShiftEnd();\n\t\t\teditactions[Keys.End | Keys.Control] = new MoveToEnd();\n\t\t\teditactions[Keys.End | Keys.Control | Keys.Shift] = new ShiftMoveToEnd();\n\t\t\teditactions[Keys.PageUp] = new MovePageUp();\n\t\t\teditactions[Keys.PageUp | Keys.Shift] = new ShiftMovePageUp();\n\t\t\teditactions[Keys.PageDown] = new MovePageDown();\n\t\t\teditactions[Keys.PageDown | Keys.Shift] = new ShiftMovePageDown();\n\t\t\t\n\t\t\teditactions[Keys.Return] = new Return();\n\t\t\teditactions[Keys.Tab] = new Tab();\n\t\t\teditactions[Keys.Tab | Keys.Shift] = new ShiftTab();\n\t\t\teditactions[Keys.Back] = new Backspace();\n\t\t\teditactions[Keys.Back | Keys.Shift] = new Backspace();\n\t\t\t\n\t\t\teditactions[Keys.X | Keys.Control] = new Cut();\n\t\t\teditactions[Keys.C | Keys.Control] = new Copy();\n\t\t\teditactions[Keys.V | Keys.Control] = new Paste();\n\t\t\t\n\t\t\teditactions[Keys.A | Keys.Control] = new SelectWholeDocument();\n\t\t\teditactions[Keys.Escape] = new ClearAllSelections();\n\t\t\t\n\t\t\teditactions[Keys.Divide | Keys.Control] = new ToggleComment();\n\t\t\teditactions[Keys.OemQuestion | Keys.Control] = new ToggleComment();\n\t\t\t\n\t\t\teditactions[Keys.Back | Keys.Alt]  = new Actions.Undo();\n\t\t\teditactions[Keys.Z | Keys.Control] = new Actions.Undo();\n\t\t\teditactions[Keys.Y | Keys.Control] = new Redo();\n\t\t\t\n\t\t\teditactions[Keys.Delete | Keys.Control] = new DeleteWord();\n\t\t\teditactions[Keys.Back | Keys.Control]   = new WordBackspace();\n\t\t\teditactions[Keys.D | Keys.Control]      = new DeleteLine();\n\t\t\teditactions[Keys.D | Keys.Shift | Keys.Control]      = new DeleteToLineEnd();\n\t\t\t\n\t\t\teditactions[Keys.B | Keys.Control]      = new GotoMatchingBrace();\n\n            editactions[Keys.F | Keys.Control] = new FindReplaceAction();\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// Call this method before a long update operation this\n\t\t/// 'locks' the text area so that no screen update occurs.\n\t\t/// </remarks>\n\t\tpublic virtual void BeginUpdate()\n\t\t{\n\t\t\t++updateLevel;\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// Call this method to 'unlock' the text area. After this call\n\t\t/// screen update can occur. But no automatical refresh occurs you\n\t\t/// have to commit the updates in the queue.\n\t\t/// </remarks>\n\t\tpublic virtual void EndUpdate()\n\t\t{\n\t\t\tDebug.Assert(updateLevel > 0);\n\t\t\tupdateLevel = Math.Max(0, updateLevel - 1);\n\t\t}\n\t\t\n\t\tpublic void LoadFile(string fileName)\n\t\t{\n\t\t\tLoadFile(fileName, true, true);\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// Loads a file given by fileName\n\t\t/// </remarks>\n\t\t/// <param name=\"fileName\">The name of the file to open</param>\n\t\t/// <param name=\"autoLoadHighlighting\">Automatically load the highlighting for the file</param>\n\t\t/// <param name=\"autodetectEncoding\">Automatically detect file encoding and set Encoding property to the detected encoding.</param>\n\t\tpublic void LoadFile(string fileName, bool autoLoadHighlighting, bool autodetectEncoding)\n\t\t{\n\t\t\tusing (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read)) {\n\t\t\t\tLoadFile(fileName, fs, autoLoadHighlighting, autodetectEncoding);\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// Loads a file from the specified stream.\n\t\t/// </remarks>\n\t\t/// <param name=\"fileName\">The name of the file to open. Used to find the correct highlighting strategy\n\t\t/// if autoLoadHighlighting is active, and sets the filename property to this value.</param>\n\t\t/// <param name=\"stream\">The stream to actually load the file content from.</param>\n\t\t/// <param name=\"autoLoadHighlighting\">Automatically load the highlighting for the file</param>\n\t\t/// <param name=\"autodetectEncoding\">Automatically detect file encoding and set Encoding property to the detected encoding.</param>\n\t\tpublic void LoadFile(string fileName, Stream stream, bool autoLoadHighlighting, bool autodetectEncoding)\n\t\t{\n\t\t\tif (stream == null)\n\t\t\t\tthrow new ArgumentNullException(\"stream\");\n\t\t\t\n\t\t\tBeginUpdate();\n\t\t\tdocument.TextContent = String.Empty;\n\t\t\tdocument.UndoStack.ClearAll();\n\t\t\tdocument.BookmarkManager.Clear();\n\t\t\tif (autoLoadHighlighting) {\n\t\t\t\ttry {\n\t\t\t\t\tdocument.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategyForFile(fileName);\n\t\t\t\t} catch (HighlightingDefinitionInvalidException ex) {\n\t\t\t\t\tMessageBox.Show(ex.ToString(), \"Error\", MessageBoxButtons.OK, MessageBoxIcon.Error);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (autodetectEncoding) {\n\t\t\t\tEncoding encoding = this.Encoding;\n\t\t\t\tDocument.TextContent = Util.FileReader.ReadFileContent(stream, ref encoding);\n\t\t\t\tthis.Encoding = encoding;\n\t\t\t} else {\n\t\t\t\tusing (StreamReader reader = new StreamReader(fileName, this.Encoding)) {\n\t\t\t\t\tDocument.TextContent = reader.ReadToEnd();\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tthis.FileName = fileName;\n\t\t\tOptionsChanged();\n\t\t\tDocument.UpdateQueue.Clear();\n\t\t\tEndUpdate();\n\t\t\t\n\t\t\tRefresh();\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Gets if the document can be saved with the current encoding without losing data.\n\t\t/// </summary>\n\t\tpublic bool CanSaveWithCurrentEncoding()\n\t\t{\n\t\t\tif (encoding == null || Util.FileReader.IsUnicode(encoding))\n\t\t\t\treturn true;\n\t\t\t// not a unicode codepage\n\t\t\tstring text = document.TextContent;\n\t\t\treturn encoding.GetString(encoding.GetBytes(text)) == text;\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// Saves the text editor content into the file.\n\t\t/// </remarks>\n\t\tpublic void SaveFile(string fileName)\n\t\t{\n\t\t\tusing (FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write)) {\n\t\t\t\tSaveFile(fs);\n\t\t\t}\n\t\t\tthis.FileName = fileName;\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// Saves the text editor content into the specified stream.\n\t\t/// Does not close the stream.\n\t\t/// </remarks>\n\t\tpublic void SaveFile(Stream stream)\n\t\t{\n\t\t\tStreamWriter streamWriter = new StreamWriter(stream, this.Encoding ?? Encoding.UTF8);\n\t\t\t\n\t\t\t// save line per line to apply the LineTerminator to all lines\n\t\t\t// (otherwise we might save files with mixed-up line endings)\n\t\t\tforeach (LineSegment line in Document.LineSegmentCollection) {\n\t\t\t\tstreamWriter.Write(Document.GetText(line.Offset, line.Length));\n\t\t\t\tif (line.DelimiterLength > 0) {\n\t\t\t\t\tchar charAfterLine = Document.GetCharAt(line.Offset + line.Length);\n\t\t\t\t\tif (charAfterLine != '\\n' && charAfterLine != '\\r')\n\t\t\t\t\t\tthrow new InvalidOperationException(\"The document cannot be saved because it is corrupted.\");\n\t\t\t\t\t// only save line terminator if the line has one\n\t\t\t\t\tstreamWriter.Write(document.TextEditorProperties.LineTerminator);\n\t\t\t\t}\n\t\t\t}\n\t\t\tstreamWriter.Flush();\n\t\t}\n\t\t\n\t\tpublic abstract void OptionsChanged();\n\t\t\n\t\t// Localization ISSUES\n\t\t\n\t\t// used in insight window\n\t\tpublic virtual string GetRangeDescription(int selectedItem, int itemCount)\n\t\t{\n\t\t\tStringBuilder sb=new StringBuilder(selectedItem.ToString());\n\t\t\tsb.Append(\" from \");\n\t\t\tsb.Append(itemCount.ToString());\n\t\t\treturn sb.ToString();\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// Overwritten refresh method that does nothing if the control is in\n\t\t/// an update cycle.\n\t\t/// </remarks>\n\t\tpublic override void Refresh()\n\t\t{\n\t\t\tif (IsInUpdate) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tbase.Refresh();\n\t\t}\n\t\t\n\t\tprotected override void Dispose(bool disposing)\n\t\t{\n\t\t\tif (disposing) {\n\t\t\t\tHighlightingManager.Manager.ReloadSyntaxHighlighting -= new EventHandler(OnReloadHighlighting);\n\t\t\t\tdocument.HighlightingStrategy = null;\n\t\t\t\tdocument.UndoStack.TextEditorControl = null;\n\t\t\t}\n\t\t\tbase.Dispose(disposing);\n\t\t}\n\t\t\n\t\tprotected virtual void OnFileNameChanged(EventArgs e)\n\t\t{\n\t\t\tif (FileNameChanged != null) {\n\t\t\t\tFileNameChanged(this, e);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic event EventHandler FileNameChanged;\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Gui/TextView.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Daniel Grunwald\" email=\"daniel@danielgrunwald.de\"/>\n//     <version>$Revision: 3205 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Drawing;\nusing System.Windows.Forms;\n\nusing ICSharpCode.TextEditor.Document;\n\nnamespace ICSharpCode.TextEditor\n{\n\t/// <summary>\n\t/// This class paints the textarea.\n\t/// </summary>\n\tpublic class TextView : AbstractMargin, IDisposable\n\t{\n\t\tint          fontHeight;\n\t\t//Hashtable    charWitdh           = new Hashtable();\n\t\t//StringFormat measureStringFormat = (StringFormat)StringFormat.GenericTypographic.Clone();\n\t\tBracketHighlight    highlight;\n\t\tint          physicalColumn = 0; // used for calculating physical column during paint\n\t\t\n\t\tpublic void Dispose()\n\t\t{\n\t\t\tmeasureCache.Clear();\n\t\t\t//measureStringFormat.Dispose();\n\t\t}\n\t\t\n\t\tpublic BracketHighlight Highlight {\n\t\t\tget {\n\t\t\t\treturn highlight;\n\t\t\t}\n\t\t\tset {\n\t\t\t\thighlight = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int FirstPhysicalLine {\n\t\t\tget {\n\t\t\t\treturn textArea.VirtualTop.Y / fontHeight;\n\t\t\t}\n\t\t}\n\t\tpublic int LineHeightRemainder {\n\t\t\tget {\n\t\t\t\treturn textArea.VirtualTop.Y % fontHeight;\n\t\t\t}\n\t\t}\n\t\t/// <summary>Gets the first visible <b>logical</b> line.</summary>\n\t\tpublic int FirstVisibleLine {\n\t\t\tget {\n\t\t\t\treturn textArea.Document.GetFirstLogicalLine(textArea.VirtualTop.Y / fontHeight);\n\t\t\t}\n\t\t\tset {\n\t\t\t\tif (FirstVisibleLine != value) {\n\t\t\t\t\ttextArea.VirtualTop = new Point(textArea.VirtualTop.X, textArea.Document.GetVisibleLine(value) * fontHeight);\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int VisibleLineDrawingRemainder {\n\t\t\tget {\n\t\t\t\treturn textArea.VirtualTop.Y % fontHeight;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int FontHeight {\n\t\t\tget {\n\t\t\t\treturn fontHeight;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int VisibleLineCount {\n\t\t\tget {\n\t\t\t\treturn 1 + DrawingPosition.Height / fontHeight;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int VisibleColumnCount {\n\t\t\tget {\n\t\t\t\treturn (int)(DrawingPosition.Width / WideSpaceWidth) - 1;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic TextView(TextArea textArea) : base(textArea)\n\t\t{\n\t\t\tbase.Cursor = Cursors.IBeam;\n\t\t\tOptionsChanged();\n\t\t}\n\t\t\n\t\tstatic int GetFontHeight(Font font)\n\t\t{\n\t\t\tint height1 = TextRenderer.MeasureText(\"_\", font).Height;\n\t\t\tint height2 = (int)Math.Ceiling(font.GetHeight());\n\t\t\treturn Math.Max(height1, height2) + 1;\n\t\t}\n\t\t\n\t\tint spaceWidth;\n\t\t\n\t\t/// <summary>\n\t\t/// Gets the width of a space character.\n\t\t/// This value can be quite small in some fonts - consider using WideSpaceWidth instead.\n\t\t/// </summary>\n\t\tpublic int SpaceWidth {\n\t\t\tget {\n\t\t\t\treturn spaceWidth;\n\t\t\t}\n\t\t}\n\t\t\n\t\tint wideSpaceWidth;\n\t\t\n\t\t/// <summary>\n\t\t/// Gets the width of a 'wide space' (=one quarter of a tab, if tab is set to 4 spaces).\n\t\t/// On monospaced fonts, this is the same value as spaceWidth.\n\t\t/// </summary>\n\t\tpublic int WideSpaceWidth {\n\t\t\tget {\n\t\t\t\treturn wideSpaceWidth;\n\t\t\t}\n\t\t}\n\t\t\n\t\tFont lastFont;\n\t\t\n\t\tpublic void OptionsChanged()\n\t\t{\n\t\t\tthis.lastFont = TextEditorProperties.FontContainer.RegularFont;\n\t\t\tthis.fontHeight = GetFontHeight(lastFont);\n\t\t\t// use minimum width - in some fonts, space has no width but kerning is used instead\n\t\t\t// -> DivideByZeroException\n\t\t\tthis.spaceWidth = Math.Max(GetWidth(' ', lastFont), 1);\n\t\t\t// tab should have the width of 4*'x'\n\t\t\tthis.wideSpaceWidth = Math.Max(spaceWidth, GetWidth('x', lastFont));\n\t\t}\n\t\t\n\t\t#region Paint functions\n\t\tpublic override void Paint(Graphics g, Rectangle rect)\n\t\t{\n\t\t\tif (rect.Width <= 0 || rect.Height <= 0) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\t// Just to ensure that fontHeight and char widths are always correct...\n\t\t\tif (lastFont != TextEditorProperties.FontContainer.RegularFont) {\n\t\t\t\tOptionsChanged();\n\t\t\t\ttextArea.Invalidate();\n\t\t\t}\n\t\t\t\n\t\t\tint horizontalDelta = textArea.VirtualTop.X;\n\t\t\tif (horizontalDelta > 0) {\n\t\t\t\tg.SetClip(this.DrawingPosition);\n\t\t\t}\n\t\t\t\n\t\t\tfor (int y = 0; y < (DrawingPosition.Height + VisibleLineDrawingRemainder) / fontHeight + 1; ++y) {\n\t\t\t\tRectangle lineRectangle = new Rectangle(DrawingPosition.X - horizontalDelta,\n\t\t\t\t                                        DrawingPosition.Top + y * fontHeight - VisibleLineDrawingRemainder,\n\t\t\t\t                                        DrawingPosition.Width + horizontalDelta,\n\t\t\t\t                                        fontHeight);\n\t\t\t\t\n\t\t\t\tif (rect.IntersectsWith(lineRectangle)) {\n\t\t\t\t\tint fvl = textArea.Document.GetVisibleLine(FirstVisibleLine);\n\t\t\t\t\tint currentLine = textArea.Document.GetFirstLogicalLine(textArea.Document.GetVisibleLine(FirstVisibleLine) + y);\n\t\t\t\t\tPaintDocumentLine(g, currentLine, lineRectangle);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tDrawMarkerDraw(g);\n\t\t\t\n\t\t\tif (horizontalDelta > 0) {\n\t\t\t\tg.ResetClip();\n\t\t\t}\n\t\t\ttextArea.Caret.PaintCaret(g);\n\t\t}\n\t\t\n\t\tvoid PaintDocumentLine(Graphics g, int lineNumber, Rectangle lineRectangle)\n\t\t{\n\t\t\tDebug.Assert(lineNumber >= 0);\n\t\t\tBrush bgColorBrush    = GetBgColorBrush(lineNumber);\n\t\t\tBrush backgroundBrush = textArea.Enabled ? bgColorBrush : SystemBrushes.InactiveBorder;\n\t\t\t\n\t\t\tif (lineNumber >= textArea.Document.TotalNumberOfLines) {\n\t\t\t\tg.FillRectangle(backgroundBrush, lineRectangle);\n\t\t\t\tif (TextEditorProperties.ShowInvalidLines) {\n\t\t\t\t\tDrawInvalidLineMarker(g, lineRectangle.Left, lineRectangle.Top);\n\t\t\t\t}\n\t\t\t\tif (TextEditorProperties.ShowVerticalRuler) {\n\t\t\t\t\tDrawVerticalRuler(g, lineRectangle);\n\t\t\t\t}\n//\t\t\t\tbgColorBrush.Dispose();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tint physicalXPos = lineRectangle.X;\n\t\t\t// there can't be a folding wich starts in an above line and ends here, because the line is a new one,\n\t\t\t// there must be a return before this line.\n\t\t\tint column = 0;\n\t\t\tphysicalColumn = 0;\n\t\t\tif (TextEditorProperties.EnableFolding) {\n\t\t\t\twhile (true) {\n\t\t\t\t\tList<FoldMarker> starts = textArea.Document.FoldingManager.GetFoldedFoldingsWithStartAfterColumn(lineNumber, column - 1);\n\t\t\t\t\tif (starts == null || starts.Count <= 0) {\n\t\t\t\t\t\tif (lineNumber < textArea.Document.TotalNumberOfLines) {\n\t\t\t\t\t\t\tphysicalXPos = PaintLinePart(g, lineNumber, column, textArea.Document.GetLineSegment(lineNumber).Length, lineRectangle, physicalXPos);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t// search the first starting folding\n\t\t\t\t\tFoldMarker firstFolding = (FoldMarker)starts[0];\n\t\t\t\t\tforeach (FoldMarker fm in starts) {\n\t\t\t\t\t\tif (fm.StartColumn < firstFolding.StartColumn) {\n\t\t\t\t\t\t\tfirstFolding = fm;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tstarts.Clear();\n\t\t\t\t\t\n\t\t\t\t\tphysicalXPos = PaintLinePart(g, lineNumber, column, firstFolding.StartColumn, lineRectangle, physicalXPos);\n\t\t\t\t\tcolumn     = firstFolding.EndColumn;\n\t\t\t\t\tlineNumber = firstFolding.EndLine;\n\t\t\t\t\tif (lineNumber >= textArea.Document.TotalNumberOfLines) {\n\t\t\t\t\t\tDebug.Assert(false, \"Folding ends after document end\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tColumnRange    selectionRange2 = textArea.SelectionManager.GetSelectionAtLine(lineNumber);\n\t\t\t\t\tbool drawSelected = ColumnRange.WholeColumn.Equals(selectionRange2) || firstFolding.StartColumn >= selectionRange2.StartColumn && firstFolding.EndColumn <= selectionRange2.EndColumn;\n\t\t\t\t\t\n\t\t\t\t\tphysicalXPos = PaintFoldingText(g, lineNumber, physicalXPos, lineRectangle, firstFolding.FoldText, drawSelected);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tphysicalXPos = PaintLinePart(g, lineNumber, 0, textArea.Document.GetLineSegment(lineNumber).Length, lineRectangle, physicalXPos);\n\t\t\t}\n\t\t\t\n\t\t\tif (lineNumber < textArea.Document.TotalNumberOfLines) {\n\t\t\t\t// Paint things after end of line\n\t\t\t\tColumnRange    selectionRange = textArea.SelectionManager.GetSelectionAtLine(lineNumber);\n\t\t\t\tLineSegment    currentLine    = textArea.Document.GetLineSegment(lineNumber);\n\t\t\t\tHighlightColor selectionColor = textArea.Document.HighlightingStrategy.GetColorFor(\"Selection\");\n\t\t\t\t\n\t\t\t\tbool  selectionBeyondEOL = selectionRange.EndColumn > currentLine.Length || ColumnRange.WholeColumn.Equals(selectionRange);\n\t\t\t\t\n\t\t\t\tif (TextEditorProperties.ShowEOLMarker) {\n\t\t\t\t\tHighlightColor eolMarkerColor = textArea.Document.HighlightingStrategy.GetColorFor(\"EOLMarkers\");\n\t\t\t\t\tphysicalXPos += DrawEOLMarker(g, eolMarkerColor.Color, selectionBeyondEOL ? bgColorBrush : backgroundBrush, physicalXPos, lineRectangle.Y);\n\t\t\t\t} else {\n\t\t\t\t\tif (selectionBeyondEOL) {\n\t\t\t\t\t\tg.FillRectangle(BrushRegistry.GetBrush(selectionColor.BackgroundColor), new RectangleF(physicalXPos, lineRectangle.Y, WideSpaceWidth, lineRectangle.Height));\n\t\t\t\t\t\tphysicalXPos += WideSpaceWidth;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tBrush fillBrush = selectionBeyondEOL && TextEditorProperties.AllowCaretBeyondEOL ? bgColorBrush : backgroundBrush;\n\t\t\t\tg.FillRectangle(fillBrush,\n\t\t\t\t                new RectangleF(physicalXPos, lineRectangle.Y, lineRectangle.Width - physicalXPos + lineRectangle.X, lineRectangle.Height));\n\t\t\t}\n\t\t\tif (TextEditorProperties.ShowVerticalRuler) {\n\t\t\t\tDrawVerticalRuler(g, lineRectangle);\n\t\t\t}\n//\t\t\tbgColorBrush.Dispose();\n\t\t}\n\t\t\n\t\tbool DrawLineMarkerAtLine(int lineNumber)\n\t\t{\n\t\t\treturn lineNumber == base.textArea.Caret.Line && textArea.MotherTextAreaControl.TextEditorProperties.LineViewerStyle == LineViewerStyle.FullRow;\n\t\t}\n\t\t\n\t\tBrush GetBgColorBrush(int lineNumber)\n\t\t{\n\t\t\tif (DrawLineMarkerAtLine(lineNumber)) {\n\t\t\t\tHighlightColor caretLine = textArea.Document.HighlightingStrategy.GetColorFor(\"CaretMarker\");\n\t\t\t\treturn BrushRegistry.GetBrush(caretLine.Color);\n\t\t\t}\n\t\t\tHighlightColor background = textArea.Document.HighlightingStrategy.GetColorFor(\"Default\");\n\t\t\tColor bgColor = background.BackgroundColor;\n\t\t\treturn BrushRegistry.GetBrush(bgColor);\n\t\t}\n\t\t\n\t\tconst int additionalFoldTextSize = 1;\n\t\t\n\t\tint PaintFoldingText(Graphics g, int lineNumber, int physicalXPos, Rectangle lineRectangle, string text, bool drawSelected)\n\t\t{\n\t\t\t// TODO: get font and color from the highlighting file\n\t\t\tHighlightColor      selectionColor  = textArea.Document.HighlightingStrategy.GetColorFor(\"Selection\");\n\t\t\tBrush               bgColorBrush    = drawSelected ? BrushRegistry.GetBrush(selectionColor.BackgroundColor) : GetBgColorBrush(lineNumber);\n\t\t\tBrush               backgroundBrush = textArea.Enabled ? bgColorBrush : SystemBrushes.InactiveBorder;\n\t\t\t\n\t\t\tFont font = textArea.TextEditorProperties.FontContainer.RegularFont;\n\t\t\t\n\t\t\tint wordWidth = MeasureStringWidth(g, text, font) + additionalFoldTextSize;\n\t\t\tRectangle rect = new Rectangle(physicalXPos, lineRectangle.Y, wordWidth, lineRectangle.Height - 1);\n\t\t\t\n\t\t\tg.FillRectangle(backgroundBrush, rect);\n\t\t\t\n\t\t\tphysicalColumn += text.Length;\n\t\t\tDrawString(g,\n\t\t\t           text,\n\t\t\t           font,\n\t\t\t           drawSelected ? selectionColor.Color : Color.Gray,\n\t\t\t           rect.X + 1, rect.Y);\n\t\t\tg.DrawRectangle(BrushRegistry.GetPen(drawSelected ? Color.DarkGray : Color.Gray), rect.X, rect.Y, rect.Width, rect.Height);\n\t\t\t\n\t\t\treturn physicalXPos + wordWidth + 1;\n\t\t}\n\t\t\n\t\tstruct MarkerToDraw {\n\t\t\tinternal TextMarker marker;\n\t\t\tinternal RectangleF drawingRect;\n\t\t\t\n\t\t\tpublic MarkerToDraw(TextMarker marker, RectangleF drawingRect)\n\t\t\t{\n\t\t\t\tthis.marker = marker;\n\t\t\t\tthis.drawingRect = drawingRect;\n\t\t\t}\n\t\t}\n\t\t\n\t\tList<MarkerToDraw> markersToDraw = new List<MarkerToDraw>();\n\t\t\n\t\tvoid DrawMarker(Graphics g, TextMarker marker, RectangleF drawingRect)\n\t\t{\n\t\t\t// draw markers later so they can overdraw the following text\n\t\t\tmarkersToDraw.Add(new MarkerToDraw(marker, drawingRect));\n\t\t}\n\t\t\n\t\tvoid DrawMarkerDraw(Graphics g)\n\t\t{\n\t\t\tforeach (MarkerToDraw m in markersToDraw) {\n\t\t\t\tTextMarker marker = m.marker;\n\t\t\t\tRectangleF drawingRect = m.drawingRect;\n\t\t\t\tfloat drawYPos = drawingRect.Bottom - 1;\n\t\t\t\tswitch (marker.TextMarkerType) {\n\t\t\t\t\tcase TextMarkerType.Underlined:\n\t\t\t\t\t\tg.DrawLine(BrushRegistry.GetPen(marker.Color), drawingRect.X, drawYPos, drawingRect.Right, drawYPos);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase TextMarkerType.WaveLine:\n\t\t\t\t\t\tint reminder = ((int)drawingRect.X) % 6;\n\t\t\t\t\t\tfor (float i = (int)drawingRect.X - reminder; i < drawingRect.Right; i += 6) {\n\t\t\t\t\t\t\tg.DrawLine(BrushRegistry.GetPen(marker.Color), i,     drawYPos + 3 - 4, i + 3, drawYPos + 1 - 4);\n\t\t\t\t\t\t\tif (i + 3 < drawingRect.Right) {\n\t\t\t\t\t\t\t\tg.DrawLine(BrushRegistry.GetPen(marker.Color), i + 3, drawYPos + 1 - 4, i + 6, drawYPos + 3 - 4);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase TextMarkerType.SolidBlock:\n\t\t\t\t\t\tg.FillRectangle(BrushRegistry.GetBrush(marker.Color), drawingRect);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tmarkersToDraw.Clear();\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Get the marker brush (for solid block markers) at a given position.\n\t\t/// </summary>\n\t\t/// <param name=\"offset\">The offset.</param>\n\t\t/// <param name=\"length\">The length.</param>\n\t\t/// <param name=\"markers\">All markers that have been found.</param>\n\t\t/// <returns>The Brush or null when no marker was found.</returns>\n\t\tBrush GetMarkerBrushAt(int offset, int length, ref Color foreColor, out IList<TextMarker> markers)\n\t\t{\n\t\t\tmarkers = Document.MarkerStrategy.GetMarkers(offset, length);\n\t\t\tforeach (TextMarker marker in markers) {\n\t\t\t\tif (marker.TextMarkerType == TextMarkerType.SolidBlock) {\n\t\t\t\t\tif (marker.OverrideForeColor) {\n\t\t\t\t\t\tforeColor = marker.ForeColor;\n\t\t\t\t\t}\n\t\t\t\t\treturn BrushRegistry.GetBrush(marker.Color);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\t\n\t\tint PaintLinePart(Graphics g, int lineNumber, int startColumn, int endColumn, Rectangle lineRectangle, int physicalXPos)\n\t\t{\n\t\t\tbool  drawLineMarker  = DrawLineMarkerAtLine(lineNumber);\n\t\t\tBrush backgroundBrush = textArea.Enabled ? GetBgColorBrush(lineNumber) : SystemBrushes.InactiveBorder;\n\t\t\t\n\t\t\tHighlightColor selectionColor = textArea.Document.HighlightingStrategy.GetColorFor(\"Selection\");\n\t\t\tColumnRange    selectionRange = textArea.SelectionManager.GetSelectionAtLine(lineNumber);\n\t\t\tHighlightColor tabMarkerColor   = textArea.Document.HighlightingStrategy.GetColorFor(\"TabMarkers\");\n\t\t\tHighlightColor spaceMarkerColor = textArea.Document.HighlightingStrategy.GetColorFor(\"SpaceMarkers\");\n\t\t\t\n\t\t\tLineSegment currentLine    = textArea.Document.GetLineSegment(lineNumber);\n\t\t\t\n\t\t\tBrush selectionBackgroundBrush  = BrushRegistry.GetBrush(selectionColor.BackgroundColor);\n\t\t\t\n\t\t\tif (currentLine.Words == null) {\n\t\t\t\treturn physicalXPos;\n\t\t\t}\n\t\t\t\n\t\t\tint currentWordOffset = 0; // we cannot use currentWord.Offset because it is not set on space words\n\t\t\t\n\t\t\tTextWord currentWord;\n\t\t\tTextWord nextCurrentWord = null;\n\t\t\tFontContainer fontContainer = TextEditorProperties.FontContainer;\n\t\t\tfor (int wordIdx = 0; wordIdx < currentLine.Words.Count; wordIdx++) {\n\t\t\t\tcurrentWord = currentLine.Words[wordIdx];\n\t\t\t\tif (currentWordOffset < startColumn) {\n\t\t\t\t\t// TODO: maybe we need to split at startColumn when we support fold markers\n\t\t\t\t\t// inside words\n\t\t\t\t\tcurrentWordOffset += currentWord.Length;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\trepeatDrawCurrentWord:\n\t\t\t\t//physicalXPos += 10; // leave room between drawn words - useful for debugging the drawing code\n\t\t\t\tif (currentWordOffset >= endColumn || physicalXPos >= lineRectangle.Right) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tint currentWordEndOffset = currentWordOffset + currentWord.Length - 1;\n\t\t\t\tTextWordType currentWordType = currentWord.Type;\n\t\t\t\t\n\t\t\t\tIList<TextMarker> markers;\n\t\t\t\tColor wordForeColor;\n\t\t\t\tif (currentWordType == TextWordType.Space)\n\t\t\t\t\twordForeColor = spaceMarkerColor.Color;\n\t\t\t\telse if (currentWordType == TextWordType.Tab)\n\t\t\t\t\twordForeColor = tabMarkerColor.Color;\n\t\t\t\telse\n\t\t\t\t\twordForeColor = currentWord.Color;\n\t\t\t\tBrush wordBackBrush = GetMarkerBrushAt(currentLine.Offset + currentWordOffset, currentWord.Length, ref wordForeColor, out markers);\n\t\t\t\t\n\t\t\t\t// It is possible that we have to split the current word because a marker/the selection begins/ends inside it\n\t\t\t\tif (currentWord.Length > 1) {\n\t\t\t\t\tint splitPos = int.MaxValue;\n\t\t\t\t\tif (highlight != null) {\n\t\t\t\t\t\t// split both before and after highlight\n\t\t\t\t\t\tif (highlight.OpenBrace.Y == lineNumber) {\n\t\t\t\t\t\t\tif (highlight.OpenBrace.X >= currentWordOffset && highlight.OpenBrace.X <= currentWordEndOffset) {\n\t\t\t\t\t\t\t\tsplitPos = Math.Min(splitPos, highlight.OpenBrace.X - currentWordOffset);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (highlight.CloseBrace.Y == lineNumber) {\n\t\t\t\t\t\t\tif (highlight.CloseBrace.X >= currentWordOffset && highlight.CloseBrace.X <= currentWordEndOffset) {\n\t\t\t\t\t\t\t\tsplitPos = Math.Min(splitPos, highlight.CloseBrace.X - currentWordOffset);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (splitPos == 0) {\n\t\t\t\t\t\t\tsplitPos = 1; // split after highlight\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (endColumn < currentWordEndOffset) { // split when endColumn is reached\n\t\t\t\t\t\tsplitPos = Math.Min(splitPos, endColumn - currentWordOffset);\n\t\t\t\t\t}\n\t\t\t\t\tif (selectionRange.StartColumn > currentWordOffset && selectionRange.StartColumn <= currentWordEndOffset) {\n\t\t\t\t\t\tsplitPos = Math.Min(splitPos, selectionRange.StartColumn - currentWordOffset);\n\t\t\t\t\t} else if (selectionRange.EndColumn > currentWordOffset && selectionRange.EndColumn <= currentWordEndOffset) {\n\t\t\t\t\t\tsplitPos = Math.Min(splitPos, selectionRange.EndColumn - currentWordOffset);\n\t\t\t\t\t}\n\t\t\t\t\tforeach (TextMarker marker in markers) {\n\t\t\t\t\t\tint markerColumn = marker.Offset - currentLine.Offset;\n\t\t\t\t\t\tint markerEndColumn = marker.EndOffset - currentLine.Offset + 1; // make end offset exclusive\n\t\t\t\t\t\tif (markerColumn > currentWordOffset && markerColumn <= currentWordEndOffset) {\n\t\t\t\t\t\t\tsplitPos = Math.Min(splitPos, markerColumn - currentWordOffset);\n\t\t\t\t\t\t} else if (markerEndColumn > currentWordOffset && markerEndColumn <= currentWordEndOffset) {\n\t\t\t\t\t\t\tsplitPos = Math.Min(splitPos, markerEndColumn - currentWordOffset);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (splitPos != int.MaxValue) {\n\t\t\t\t\t\tif (nextCurrentWord != null)\n\t\t\t\t\t\t\tthrow new ApplicationException(\"split part invalid: first part cannot be splitted further\");\n\t\t\t\t\t\tnextCurrentWord = TextWord.Split(ref currentWord, splitPos);\n\t\t\t\t\t\tgoto repeatDrawCurrentWord; // get markers for first word part\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// get colors from selection status:\n\t\t\t\tif (ColumnRange.WholeColumn.Equals(selectionRange) || (selectionRange.StartColumn <= currentWordOffset\n\t\t\t\t                                                       && selectionRange.EndColumn > currentWordEndOffset))\n\t\t\t\t{\n\t\t\t\t\t// word is completely selected\n\t\t\t\t\twordBackBrush = selectionBackgroundBrush;\n\t\t\t\t\tif (selectionColor.HasForeground) {\n\t\t\t\t\t\twordForeColor = selectionColor.Color;\n\t\t\t\t\t}\n\t\t\t\t} else if (drawLineMarker) {\n\t\t\t\t\twordBackBrush = backgroundBrush;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (wordBackBrush == null) { // use default background if no other background is set\n\t\t\t\t\tif (currentWord.SyntaxColor != null && currentWord.SyntaxColor.HasBackground)\n\t\t\t\t\t\twordBackBrush = BrushRegistry.GetBrush(currentWord.SyntaxColor.BackgroundColor);\n\t\t\t\t\telse\n\t\t\t\t\t\twordBackBrush = backgroundBrush;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tRectangleF wordRectangle;\n\t\t\t\t\n\t\t\t\tif (currentWord.Type == TextWordType.Space) {\n\t\t\t\t\t++physicalColumn;\n\t\t\t\t\t\n\t\t\t\t\twordRectangle = new RectangleF(physicalXPos, lineRectangle.Y, SpaceWidth, lineRectangle.Height);\n\t\t\t\t\tg.FillRectangle(wordBackBrush, wordRectangle);\n\t\t\t\t\t\n\t\t\t\t\tif (TextEditorProperties.ShowSpaces) {\n\t\t\t\t\t\tDrawSpaceMarker(g, wordForeColor, physicalXPos, lineRectangle.Y);\n\t\t\t\t\t}\n\t\t\t\t\tphysicalXPos += SpaceWidth;\n\t\t\t\t} else if (currentWord.Type == TextWordType.Tab) {\n\t\t\t\t\t\n\t\t\t\t\tphysicalColumn += TextEditorProperties.TabIndent;\n\t\t\t\t\tphysicalColumn = (physicalColumn / TextEditorProperties.TabIndent) * TextEditorProperties.TabIndent;\n\t\t\t\t\t// go to next tabstop\n\t\t\t\t\tint physicalTabEnd = ((physicalXPos + MinTabWidth - lineRectangle.X)\n\t\t\t\t\t                      / WideSpaceWidth / TextEditorProperties.TabIndent)\n\t\t\t\t\t\t* WideSpaceWidth * TextEditorProperties.TabIndent + lineRectangle.X;\n\t\t\t\t\tphysicalTabEnd += WideSpaceWidth * TextEditorProperties.TabIndent;\n\t\t\t\t\t\n\t\t\t\t\twordRectangle = new RectangleF(physicalXPos, lineRectangle.Y, physicalTabEnd - physicalXPos, lineRectangle.Height);\n\t\t\t\t\tg.FillRectangle(wordBackBrush, wordRectangle);\n\t\t\t\t\t\n\t\t\t\t\tif (TextEditorProperties.ShowTabs) {\n\t\t\t\t\t\tDrawTabMarker(g, wordForeColor, physicalXPos, lineRectangle.Y);\n\t\t\t\t\t}\n\t\t\t\t\tphysicalXPos = physicalTabEnd;\n\t\t\t\t} else {\n\t\t\t\t\tint wordWidth = DrawDocumentWord(g,\n\t\t\t\t\t                                 currentWord.Word,\n\t\t\t\t\t                                 new Point(physicalXPos, lineRectangle.Y),\n\t\t\t\t\t                                 currentWord.GetFont(fontContainer),\n\t\t\t\t\t                                 wordForeColor,\n\t\t\t\t\t                                 wordBackBrush);\n\t\t\t\t\twordRectangle = new RectangleF(physicalXPos, lineRectangle.Y, wordWidth, lineRectangle.Height);\n\t\t\t\t\tphysicalXPos += wordWidth;\n\t\t\t\t}\n\t\t\t\tforeach (TextMarker marker in markers) {\n\t\t\t\t\tif (marker.TextMarkerType != TextMarkerType.SolidBlock) {\n\t\t\t\t\t\tDrawMarker(g, marker, wordRectangle);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// draw bracket highlight\n\t\t\t\tif (highlight != null) {\n\t\t\t\t\tif (highlight.OpenBrace.Y == lineNumber && highlight.OpenBrace.X == currentWordOffset ||\n\t\t\t\t\t    highlight.CloseBrace.Y == lineNumber && highlight.CloseBrace.X == currentWordOffset) {\n\t\t\t\t\t\tDrawBracketHighlight(g, new Rectangle((int)wordRectangle.X, lineRectangle.Y, (int)wordRectangle.Width - 1, lineRectangle.Height - 1));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tcurrentWordOffset += currentWord.Length;\n\t\t\t\tif (nextCurrentWord != null) {\n\t\t\t\t\tcurrentWord = nextCurrentWord;\n\t\t\t\t\tnextCurrentWord = null;\n\t\t\t\t\tgoto repeatDrawCurrentWord;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (physicalXPos < lineRectangle.Right && endColumn >= currentLine.Length) {\n\t\t\t\t// draw markers at line end\n\t\t\t\tIList<TextMarker> markers = Document.MarkerStrategy.GetMarkers(currentLine.Offset + currentLine.Length);\n\t\t\t\tforeach (TextMarker marker in markers) {\n\t\t\t\t\tif (marker.TextMarkerType != TextMarkerType.SolidBlock) {\n\t\t\t\t\t\tDrawMarker(g, marker, new RectangleF(physicalXPos, lineRectangle.Y, WideSpaceWidth, lineRectangle.Height));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn physicalXPos;\n\t\t}\n\t\t\n\t\tint DrawDocumentWord(Graphics g, string word, Point position, Font font, Color foreColor, Brush backBrush)\n\t\t{\n\t\t\tif (word == null || word.Length == 0) {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\t\n\t\t\tif (word.Length > MaximumWordLength) {\n\t\t\t\tint width = 0;\n\t\t\t\tfor (int i = 0; i < word.Length; i += MaximumWordLength) {\n\t\t\t\t\tPoint pos = position;\n\t\t\t\t\tpos.X += width;\n\t\t\t\t\tif (i + MaximumWordLength < word.Length)\n\t\t\t\t\t\twidth += DrawDocumentWord(g, word.Substring(i, MaximumWordLength), pos, font, foreColor, backBrush);\n\t\t\t\t\telse\n\t\t\t\t\t\twidth += DrawDocumentWord(g, word.Substring(i, word.Length - i), pos, font, foreColor, backBrush);\n\t\t\t\t}\n\t\t\t\treturn width;\n\t\t\t}\n\t\t\t\n\t\t\tint wordWidth = MeasureStringWidth(g, word, font);\n\t\t\t\n\t\t\t//num = ++num % 3;\n\t\t\tg.FillRectangle(backBrush, //num == 0 ? Brushes.LightBlue : num == 1 ? Brushes.LightGreen : Brushes.Yellow,\n\t\t\t                new RectangleF(position.X, position.Y, wordWidth + 1, FontHeight));\n\t\t\t\n\t\t\tDrawString(g,\n\t\t\t           word,\n\t\t\t           font,\n\t\t\t           foreColor,\n\t\t\t           position.X,\n\t\t\t           position.Y);\n\t\t\treturn wordWidth;\n\t\t}\n\t\t\n\t\tstruct WordFontPair {\n\t\t\tstring word;\n\t\t\tFont font;\n\t\t\tpublic WordFontPair(string word, Font font) {\n\t\t\t\tthis.word = word;\n\t\t\t\tthis.font = font;\n\t\t\t}\n\t\t\tpublic override bool Equals(object obj) {\n\t\t\t\tWordFontPair myWordFontPair = (WordFontPair)obj;\n\t\t\t\tif (!word.Equals(myWordFontPair.word)) return false;\n\t\t\t\treturn font.Equals(myWordFontPair.font);\n\t\t\t}\n\t\t\t\n\t\t\tpublic override int GetHashCode() {\n\t\t\t\treturn word.GetHashCode() ^ font.GetHashCode();\n\t\t\t}\n\t\t}\n\t\t\n\t\tDictionary<WordFontPair, int> measureCache = new Dictionary<WordFontPair, int>();\n\t\t\n\t\t// split words after 1000 characters. Fixes GDI+ crash on very longs words, for example\n\t\t// a 100 KB Base64-file without any line breaks.\n\t\tconst int MaximumWordLength = 1000;\n\t\tconst int MaximumCacheSize = 2000;\n\t\t\n\t\tint MeasureStringWidth(Graphics g, string word, Font font)\n\t\t{\n\t\t\tint width;\n\t\t\t\n\t\t\tif (word == null || word.Length == 0)\n\t\t\t\treturn 0;\n\t\t\tif (word.Length > MaximumWordLength) {\n\t\t\t\twidth = 0;\n\t\t\t\tfor (int i = 0; i < word.Length; i += MaximumWordLength) {\n\t\t\t\t\tif (i + MaximumWordLength < word.Length)\n\t\t\t\t\t\twidth += MeasureStringWidth(g, word.Substring(i, MaximumWordLength), font);\n\t\t\t\t\telse\n\t\t\t\t\t\twidth += MeasureStringWidth(g, word.Substring(i, word.Length - i), font);\n\t\t\t\t}\n\t\t\t\treturn width;\n\t\t\t}\n\t\t\tif (measureCache.TryGetValue(new WordFontPair(word, font), out width)) {\n\t\t\t\treturn width;\n\t\t\t}\n\t\t\tif (measureCache.Count > MaximumCacheSize) {\n\t\t\t\tmeasureCache.Clear();\n\t\t\t}\n\t\t\t\n\t\t\t// This code here provides better results than MeasureString!\n\t\t\t// Example line that is measured wrong:\n\t\t\t// txt.GetPositionFromCharIndex(txt.SelectionStart)\n\t\t\t// (Verdana 10, highlighting makes GetP... bold) -> note the space between 'x' and '('\n\t\t\t// this also fixes \"jumping\" characters when selecting in non-monospace fonts\n\t\t\t// [...]\n\t\t\t// Replaced GDI+ measurement with GDI measurement: faster and even more exact\n\t\t\twidth = TextRenderer.MeasureText(g, word, font, new Size(short.MaxValue, short.MaxValue), textFormatFlags).Width;\n\t\t\tmeasureCache.Add(new WordFontPair(word, font), width);\n\t\t\treturn width;\n\t\t}\n\t\t\n\t\t// Important: Some flags combinations work on WinXP, but not on Win2000.\n\t\t// Make sure to test changes here on all operating systems.\n\t\tconst TextFormatFlags textFormatFlags =\n\t\t\tTextFormatFlags.NoPadding | TextFormatFlags.NoPrefix | TextFormatFlags.PreserveGraphicsClipping;\n\t\t#endregion\n\t\t\n\t\t#region Conversion Functions\n\t\tDictionary<Font, Dictionary<char, int>> fontBoundCharWidth = new Dictionary<Font, Dictionary<char, int>>();\n\t\t\n\t\tpublic int GetWidth(char ch, Font font)\n\t\t{\n\t\t\tif (!fontBoundCharWidth.ContainsKey(font)) {\n\t\t\t\tfontBoundCharWidth.Add(font, new Dictionary<char, int>());\n\t\t\t}\n\t\t\tif (!fontBoundCharWidth[font].ContainsKey(ch)) {\n\t\t\t\tusing (Graphics g = textArea.CreateGraphics()) {\n\t\t\t\t\treturn GetWidth(g, ch, font);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn fontBoundCharWidth[font][ch];\n\t\t}\n\t\t\n\t\tpublic int GetWidth(Graphics g, char ch, Font font)\n\t\t{\n\t\t\tif (!fontBoundCharWidth.ContainsKey(font)) {\n\t\t\t\tfontBoundCharWidth.Add(font, new Dictionary<char, int>());\n\t\t\t}\n\t\t\tif (!fontBoundCharWidth[font].ContainsKey(ch)) {\n\t\t\t\t//Console.WriteLine(\"Calculate character width: \" + ch);\n\t\t\t\tfontBoundCharWidth[font].Add(ch, MeasureStringWidth(g, ch.ToString(), font));\n\t\t\t}\n\t\t\treturn fontBoundCharWidth[font][ch];\n\t\t}\n\t\t\n\t\tpublic int GetVisualColumn(int logicalLine, int logicalColumn)\n\t\t{\n\t\t\tint column = 0;\n\t\t\tusing (Graphics g = textArea.CreateGraphics()) {\n\t\t\t\tCountColumns(ref column, 0, logicalColumn, logicalLine, g);\n\t\t\t}\n\t\t\treturn column;\n\t\t}\n\t\t\n\t\tpublic int GetVisualColumnFast(LineSegment line, int logicalColumn)\n\t\t{\n\t\t\tint lineOffset = line.Offset;\n\t\t\tint tabIndent = Document.TextEditorProperties.TabIndent;\n\t\t\tint guessedColumn = 0;\n\t\t\tfor (int i = 0; i < logicalColumn; ++i) {\n\t\t\t\tchar ch;\n\t\t\t\tif (i >= line.Length) {\n\t\t\t\t\tch = ' ';\n\t\t\t\t} else {\n\t\t\t\t\tch = Document.GetCharAt(lineOffset + i);\n\t\t\t\t}\n\t\t\t\tswitch (ch) {\n\t\t\t\t\tcase '\\t':\n\t\t\t\t\t\tguessedColumn += tabIndent;\n\t\t\t\t\t\tguessedColumn = (guessedColumn / tabIndent) * tabIndent;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t++guessedColumn;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn guessedColumn;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// returns line/column for a visual point position\n\t\t/// </summary>\n\t\tpublic TextLocation GetLogicalPosition(Point mousePosition)\n\t\t{\n\t\t\tFoldMarker dummy;\n\t\t\treturn GetLogicalColumn(GetLogicalLine(mousePosition.Y), mousePosition.X, out dummy);\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// returns line/column for a visual point position\n\t\t/// </summary>\n\t\tpublic TextLocation GetLogicalPosition(int visualPosX, int visualPosY)\n\t\t{\n\t\t\tFoldMarker dummy;\n\t\t\treturn GetLogicalColumn(GetLogicalLine(visualPosY), visualPosX, out dummy);\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// returns line/column for a visual point position\n\t\t/// </summary>\n\t\tpublic FoldMarker GetFoldMarkerFromPosition(int visualPosX, int visualPosY)\n\t\t{\n\t\t\tFoldMarker foldMarker;\n\t\t\tGetLogicalColumn(GetLogicalLine(visualPosY), visualPosX, out foldMarker);\n\t\t\treturn foldMarker;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// returns logical line number for a visual point\n\t\t/// </summary>\n\t\tpublic int GetLogicalLine(int visualPosY)\n\t\t{\n\t\t\tint clickedVisualLine = Math.Max(0, (visualPosY + this.textArea.VirtualTop.Y) / fontHeight);\n\t\t\treturn Document.GetFirstLogicalLine(clickedVisualLine);\n\t\t}\n\t\t\n\t\tinternal TextLocation GetLogicalColumn(int lineNumber, int visualPosX, out FoldMarker inFoldMarker)\n\t\t{\n\t\t\tvisualPosX += textArea.VirtualTop.X;\n\t\t\t\n\t\t\tinFoldMarker = null;\n\t\t\tif (lineNumber >= Document.TotalNumberOfLines) {\n\t\t\t\treturn new TextLocation((int)(visualPosX / WideSpaceWidth), lineNumber);\n\t\t\t}\n\t\t\tif (visualPosX <= 0) {\n\t\t\t\treturn new TextLocation(0, lineNumber);\n\t\t\t}\n\t\t\t\n\t\t\tint start = 0; // column\n\t\t\tint posX = 0; // visual position\n\t\t\t\n\t\t\tint result;\n\t\t\tusing (Graphics g = textArea.CreateGraphics()) {\n\t\t\t\tdo {\n\t\t\t\t\tLineSegment line = Document.GetLineSegment(lineNumber);\n\t\t\t\t\tFoldMarker nextFolding = FindNextFoldedFoldingOnLineAfterColumn(lineNumber, start-1);\n\t\t\t\t\tint end = nextFolding != null ? nextFolding.StartColumn : int.MaxValue;\n\t\t\t\t\tresult = GetLogicalColumnInternal(g, line, start, end, ref posX, visualPosX);\n\t\t\t\t\tif (result < 0) {\n\t\t\t\t\t\t// reached fold marker\n\t\t\t\t\t\tlineNumber = nextFolding.EndLine;\n\t\t\t\t\t\tstart = nextFolding.EndColumn;\n\t\t\t\t\t\tint newPosX = posX + 1 + MeasureStringWidth(g, nextFolding.FoldText, TextEditorProperties.FontContainer.RegularFont);\n\t\t\t\t\t\tif (newPosX >= visualPosX) {\n\t\t\t\t\t\t\tinFoldMarker = nextFolding;\n\t\t\t\t\t\t\tif (IsNearerToAThanB(visualPosX, posX, newPosX))\n\t\t\t\t\t\t\t\treturn new TextLocation(nextFolding.StartColumn, nextFolding.StartLine);\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\treturn new TextLocation(nextFolding.EndColumn, nextFolding.EndLine);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tposX = newPosX;\n\t\t\t\t\t}\n\t\t\t\t} while (result < 0);\n\t\t\t}\n\t\t\treturn new TextLocation(result, lineNumber);\n\t\t}\n\t\t\n\t\tint GetLogicalColumnInternal(Graphics g, LineSegment line, int start, int end, ref int drawingPos, int targetVisualPosX)\n\t\t{\n\t\t\tif (start == end)\n\t\t\t\treturn -1;\n\t\t\tDebug.Assert(start < end);\n\t\t\tDebug.Assert(drawingPos < targetVisualPosX);\n\t\t\t\n\t\t\tint tabIndent = Document.TextEditorProperties.TabIndent;\n\t\t\t\n\t\t\t/*float spaceWidth = SpaceWidth;\n\t\t\tfloat drawingPos = 0;\n\t\t\tLineSegment currentLine = Document.GetLineSegment(logicalLine);\n\t\t\tList<TextWord> words = currentLine.Words;\n\t\t\tif (words == null) return 0;\n\t\t\tint wordCount = words.Count;\n\t\t\tint wordOffset = 0;\n\t\t\tFontContainer fontContainer = TextEditorProperties.FontContainer;\n\t\t\t */\n\t\t\tFontContainer fontContainer = TextEditorProperties.FontContainer;\n\t\t\t\n\t\t\tList<TextWord> words = line.Words;\n\t\t\tif (words == null) return 0;\n\t\t\tint wordOffset = 0;\n\t\t\tfor (int i = 0; i < words.Count; i++) {\n\t\t\t\tTextWord word = words[i];\n\t\t\t\tif (wordOffset >= end) {\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t\tif (wordOffset + word.Length >= start) {\n\t\t\t\t\tint newDrawingPos;\n\t\t\t\t\tswitch (word.Type) {\n\t\t\t\t\t\tcase TextWordType.Space:\n\t\t\t\t\t\t\tnewDrawingPos = drawingPos + spaceWidth;\n\t\t\t\t\t\t\tif (newDrawingPos >= targetVisualPosX)\n\t\t\t\t\t\t\t\treturn IsNearerToAThanB(targetVisualPosX, drawingPos, newDrawingPos) ? wordOffset : wordOffset+1;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase TextWordType.Tab:\n\t\t\t\t\t\t\t// go to next tab position\n\t\t\t\t\t\t\tdrawingPos = (int)((drawingPos + MinTabWidth) / tabIndent / WideSpaceWidth) * tabIndent * WideSpaceWidth;\n\t\t\t\t\t\t\tnewDrawingPos = drawingPos + tabIndent * WideSpaceWidth;\n\t\t\t\t\t\t\tif (newDrawingPos >= targetVisualPosX)\n\t\t\t\t\t\t\t\treturn IsNearerToAThanB(targetVisualPosX, drawingPos, newDrawingPos) ? wordOffset : wordOffset+1;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase TextWordType.Word:\n\t\t\t\t\t\t\tint wordStart = Math.Max(wordOffset, start);\n\t\t\t\t\t\t\tint wordLength = Math.Min(wordOffset + word.Length, end) - wordStart;\n\t\t\t\t\t\t\tstring text = Document.GetText(line.Offset + wordStart, wordLength);\n\t\t\t\t\t\t\tFont font = word.GetFont(fontContainer) ?? fontContainer.RegularFont;\n\t\t\t\t\t\t\tnewDrawingPos = drawingPos + MeasureStringWidth(g, text, font);\n\t\t\t\t\t\t\tif (newDrawingPos >= targetVisualPosX) {\n\t\t\t\t\t\t\t\tfor (int j = 0; j < text.Length; j++) {\n\t\t\t\t\t\t\t\t\tnewDrawingPos = drawingPos + MeasureStringWidth(g, text[j].ToString(), font);\n\t\t\t\t\t\t\t\t\tif (newDrawingPos >= targetVisualPosX) {\n\t\t\t\t\t\t\t\t\t\tif (IsNearerToAThanB(targetVisualPosX, drawingPos, newDrawingPos))\n\t\t\t\t\t\t\t\t\t\t\treturn wordStart + j;\n\t\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\t\treturn wordStart + j + 1;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tdrawingPos = newDrawingPos;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn wordStart + text.Length;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tthrow new NotSupportedException();\n\t\t\t\t\t}\n\t\t\t\t\tdrawingPos = newDrawingPos;\n\t\t\t\t}\n\t\t\t\twordOffset += word.Length;\n\t\t\t}\n\t\t\treturn wordOffset;\n\t\t}\n\t\t\n\t\tstatic bool IsNearerToAThanB(int num, int a, int b)\n\t\t{\n\t\t\treturn Math.Abs(a - num) < Math.Abs(b - num);\n\t\t}\n\t\t\n\t\tFoldMarker FindNextFoldedFoldingOnLineAfterColumn(int lineNumber, int column)\n\t\t{\n\t\t\tList<FoldMarker> list = Document.FoldingManager.GetFoldedFoldingsWithStartAfterColumn(lineNumber, column);\n\t\t\tif (list.Count != 0)\n\t\t\t\treturn list[0];\n\t\t\telse\n\t\t\t\treturn null;\n\t\t}\n\t\t\n\t\tconst int MinTabWidth = 4;\n\t\t\n\t\tfloat CountColumns(ref int column, int start, int end, int logicalLine, Graphics g)\n\t\t{\n\t\t\tif (start > end) throw new ArgumentException(\"start > end\");\n\t\t\tif (start == end) return 0;\n\t\t\tfloat spaceWidth = SpaceWidth;\n\t\t\tfloat drawingPos = 0;\n\t\t\tint tabIndent  = Document.TextEditorProperties.TabIndent;\n\t\t\tLineSegment currentLine = Document.GetLineSegment(logicalLine);\n\t\t\tList<TextWord> words = currentLine.Words;\n\t\t\tif (words == null) return 0;\n\t\t\tint wordCount = words.Count;\n\t\t\tint wordOffset = 0;\n\t\t\tFontContainer fontContainer = TextEditorProperties.FontContainer;\n\t\t\tfor (int i = 0; i < wordCount; i++) {\n\t\t\t\tTextWord word = words[i];\n\t\t\t\tif (wordOffset >= end)\n\t\t\t\t\tbreak;\n\t\t\t\tif (wordOffset + word.Length >= start) {\n\t\t\t\t\tswitch (word.Type) {\n\t\t\t\t\t\tcase TextWordType.Space:\n\t\t\t\t\t\t\tdrawingPos += spaceWidth;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase TextWordType.Tab:\n\t\t\t\t\t\t\t// go to next tab position\n\t\t\t\t\t\t\tdrawingPos = (int)((drawingPos + MinTabWidth) / tabIndent / WideSpaceWidth) * tabIndent * WideSpaceWidth;\n\t\t\t\t\t\t\tdrawingPos += tabIndent * WideSpaceWidth;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase TextWordType.Word:\n\t\t\t\t\t\t\tint wordStart = Math.Max(wordOffset, start);\n\t\t\t\t\t\t\tint wordLength = Math.Min(wordOffset + word.Length, end) - wordStart;\n\t\t\t\t\t\t\tstring text = Document.GetText(currentLine.Offset + wordStart, wordLength);\n\t\t\t\t\t\t\tdrawingPos += MeasureStringWidth(g, text, word.GetFont(fontContainer) ?? fontContainer.RegularFont);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\twordOffset += word.Length;\n\t\t\t}\n\t\t\tfor (int j = currentLine.Length; j < end; j++) {\n\t\t\t\tdrawingPos += WideSpaceWidth;\n\t\t\t}\n\t\t\t// add one pixel in column calculation to account for floating point calculation errors\n\t\t\tcolumn += (int)((drawingPos + 1) / WideSpaceWidth);\n\t\t\t\n\t\t\t/* OLD Code (does not work for fonts like Verdana)\n\t\t\tfor (int j = start; j < end; ++j) {\n\t\t\t\tchar ch;\n\t\t\t\tif (j >= line.Length) {\n\t\t\t\t\tch = ' ';\n\t\t\t\t} else {\n\t\t\t\t\tch = Document.GetCharAt(line.Offset + j);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tswitch (ch) {\n\t\t\t\t\tcase '\\t':\n\t\t\t\t\t\tint oldColumn = column;\n\t\t\t\t\t\tcolumn += tabIndent;\n\t\t\t\t\t\tcolumn = (column / tabIndent) * tabIndent;\n\t\t\t\t\t\tdrawingPos += (column - oldColumn) * spaceWidth;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t++column;\n\t\t\t\t\t\tTextWord word = line.GetWord(j);\n\t\t\t\t\t\tif (word == null || word.Font == null) {\n\t\t\t\t\t\t\tdrawingPos += GetWidth(ch, TextEditorProperties.Font);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdrawingPos += GetWidth(ch, word.Font);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t//*/\n\t\t\treturn drawingPos;\n\t\t}\n\t\t\n\t\tpublic int GetDrawingXPos(int logicalLine, int logicalColumn)\n\t\t{\n\t\t\tList<FoldMarker> foldings = Document.FoldingManager.GetTopLevelFoldedFoldings();\n\t\t\tint i;\n\t\t\tFoldMarker f = null;\n\t\t\t// search the last folding that's interresting\n\t\t\tfor (i = foldings.Count - 1; i >= 0; --i) {\n\t\t\t\tf = foldings[i];\n\t\t\t\tif (f.StartLine < logicalLine || f.StartLine == logicalLine && f.StartColumn < logicalColumn) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tFoldMarker f2 = foldings[i / 2];\n\t\t\t\tif (f2.StartLine > logicalLine || f2.StartLine == logicalLine && f2.StartColumn >= logicalColumn) {\n\t\t\t\t\ti /= 2;\n\t\t\t\t}\n\t\t\t}\n\t\t\tint lastFolding  = 0;\n\t\t\tint firstFolding = 0;\n\t\t\tint column       = 0;\n\t\t\tint tabIndent    = Document.TextEditorProperties.TabIndent;\n\t\t\tfloat drawingPos;\n\t\t\tGraphics g = textArea.CreateGraphics();\n\t\t\t// if no folding is interresting\n\t\t\tif (f == null || !(f.StartLine < logicalLine || f.StartLine == logicalLine && f.StartColumn < logicalColumn)) {\n\t\t\t\tdrawingPos = CountColumns(ref column, 0, logicalColumn, logicalLine, g);\n\t\t\t\treturn (int)(drawingPos - textArea.VirtualTop.X);\n\t\t\t}\n\t\t\t\n\t\t\t// if logicalLine/logicalColumn is in folding\n\t\t\tif (f.EndLine > logicalLine || f.EndLine == logicalLine && f.EndColumn > logicalColumn) {\n\t\t\t\tlogicalColumn = f.StartColumn;\n\t\t\t\tlogicalLine = f.StartLine;\n\t\t\t\t--i;\n\t\t\t}\n\t\t\tlastFolding = i;\n\t\t\t\n\t\t\t// search backwards until a new visible line is reched\n\t\t\tfor (; i >= 0; --i) {\n\t\t\t\tf = (FoldMarker)foldings[i];\n\t\t\t\tif (f.EndLine < logicalLine) { // reached the begin of a new visible line\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfirstFolding = i + 1;\n\t\t\t\n\t\t\tif (lastFolding < firstFolding) {\n\t\t\t\tdrawingPos = CountColumns(ref column, 0, logicalColumn, logicalLine, g);\n\t\t\t\treturn (int)(drawingPos - textArea.VirtualTop.X);\n\t\t\t}\n\t\t\t\n\t\t\tint foldEnd      = 0;\n\t\t\tdrawingPos = 0;\n\t\t\tfor (i = firstFolding; i <= lastFolding; ++i) {\n\t\t\t\tf = foldings[i];\n\t\t\t\tdrawingPos += CountColumns(ref column, foldEnd, f.StartColumn, f.StartLine, g);\n\t\t\t\tfoldEnd = f.EndColumn;\n\t\t\t\tcolumn += f.FoldText.Length;\n\t\t\t\tdrawingPos += additionalFoldTextSize;\n\t\t\t\tdrawingPos += MeasureStringWidth(g, f.FoldText, TextEditorProperties.FontContainer.RegularFont);\n\t\t\t}\n\t\t\tdrawingPos += CountColumns(ref column, foldEnd, logicalColumn, logicalLine, g);\n\t\t\tg.Dispose();\n\t\t\treturn (int)(drawingPos - textArea.VirtualTop.X);\n\t\t}\n\t\t#endregion\n\t\t\n\t\t#region DrawHelper functions\n\t\tvoid DrawBracketHighlight(Graphics g, Rectangle rect)\n\t\t{\n\t\t\tg.FillRectangle(BrushRegistry.GetBrush(Color.FromArgb(50, 0, 0, 255)), rect);\n\t\t\tg.DrawRectangle(Pens.Blue, rect);\n\t\t}\n\t\t\n\t\tvoid DrawString(Graphics g, string text, Font font, Color color, int x, int y)\n\t\t{\n\t\t\tTextRenderer.DrawText(g, text, font, new Point(x, y), color, textFormatFlags);\n\t\t}\n\t\t\n\t\tvoid DrawInvalidLineMarker(Graphics g, int x, int y)\n\t\t{\n\t\t\tHighlightColor invalidLinesColor = textArea.Document.HighlightingStrategy.GetColorFor(\"InvalidLines\");\n\t\t\tDrawString(g, \"~\", invalidLinesColor.GetFont(TextEditorProperties.FontContainer), invalidLinesColor.Color, x, y);\n\t\t}\n\t\t\n\t\tvoid DrawSpaceMarker(Graphics g, Color color, int x, int y)\n\t\t{\n\t\t\tHighlightColor spaceMarkerColor = textArea.Document.HighlightingStrategy.GetColorFor(\"SpaceMarkers\");\n\t\t\tDrawString(g, \"\\u00B7\", spaceMarkerColor.GetFont(TextEditorProperties.FontContainer), color, x, y);\n\t\t}\n\t\t\n\t\tvoid DrawTabMarker(Graphics g, Color color, int x, int y)\n\t\t{\n\t\t\tHighlightColor tabMarkerColor   = textArea.Document.HighlightingStrategy.GetColorFor(\"TabMarkers\");\n\t\t\tDrawString(g, \"\\u00BB\", tabMarkerColor.GetFont(TextEditorProperties.FontContainer), color, x, y);\n\t\t}\n\t\t\n\t\tint DrawEOLMarker(Graphics g, Color color, Brush backBrush, int x, int y)\n\t\t{\n\t\t\tHighlightColor eolMarkerColor = textArea.Document.HighlightingStrategy.GetColorFor(\"EOLMarkers\");\n\t\t\t\n\t\t\tint width = GetWidth('\\u00B6', eolMarkerColor.GetFont(TextEditorProperties.FontContainer));\n\t\t\tg.FillRectangle(backBrush,\n\t\t\t                new RectangleF(x, y, width, fontHeight));\n\t\t\t\n\t\t\tDrawString(g, \"\\u00B6\", eolMarkerColor.GetFont(TextEditorProperties.FontContainer), color, x, y);\n\t\t\treturn width;\n\t\t}\n\t\t\n\t\tvoid DrawVerticalRuler(Graphics g, Rectangle lineRectangle)\n\t\t{\n\t\t\tint xpos = WideSpaceWidth * TextEditorProperties.VerticalRulerRow - textArea.VirtualTop.X;\n\t\t\tif (xpos <= 0) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tHighlightColor vRulerColor = textArea.Document.HighlightingStrategy.GetColorFor(\"VRuler\");\n\t\t\t\n\t\t\tg.DrawLine(BrushRegistry.GetPen(vRulerColor.Color),\n\t\t\t           drawingPosition.Left + xpos,\n\t\t\t           lineRectangle.Top,\n\t\t\t           drawingPosition.Left + xpos,\n\t\t\t           lineRectangle.Bottom);\n\t\t}\n\t\t#endregion\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Gui/ToolTipRequestEventArgs.cs",
    "content": "// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Daniel Grunwald\" email=\"daniel@danielgrunwald.de\"/>\n//     <version>$Revision: 2659 $</version>\n// </file>\n\nusing System;\nusing System.Drawing;\n\nnamespace ICSharpCode.TextEditor\n{\n\tpublic delegate void ToolTipRequestEventHandler(object sender, ToolTipRequestEventArgs e);\n\t\n\tpublic class ToolTipRequestEventArgs\n\t{\n\t\tPoint mousePosition;\n\t\tTextLocation logicalPosition;\n\t\tbool inDocument;\n\t\t\n\t\tpublic Point MousePosition {\n\t\t\tget {\n\t\t\t\treturn mousePosition;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic TextLocation LogicalPosition {\n\t\t\tget {\n\t\t\t\treturn logicalPosition;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic bool InDocument {\n\t\t\tget {\n\t\t\t\treturn inDocument;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Gets if some client handling the event has already shown a tool tip.\n\t\t/// </summary>\n\t\tpublic bool ToolTipShown {\n\t\t\tget {\n\t\t\t\treturn toolTipText != null;\n\t\t\t}\n\t\t}\n\t\t\n\t\tinternal string toolTipText;\n\t\t\n\t\tpublic void ShowToolTip(string text)\n\t\t{\n\t\t\ttoolTipText = text;\n\t\t}\n\t\t\n\t\tpublic ToolTipRequestEventArgs(Point mousePosition, TextLocation logicalPosition, bool inDocument)\n\t\t{\n\t\t\tthis.mousePosition = mousePosition;\n\t\t\tthis.logicalPosition = logicalPosition;\n\t\t\tthis.inDocument = inDocument;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Undo/IUndoableOperation.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 915 $</version>\n// </file>\n\nnamespace ICSharpCode.TextEditor.Undo\n{\n\t/// <summary>\n\t/// This Interface describes a the basic Undo/Redo operation\n\t/// all Undo Operations must implement this interface.\n\t/// </summary>\n\tpublic interface IUndoableOperation\n\t{\n\t\t/// <summary>\n\t\t/// Undo the last operation\n\t\t/// </summary>\n\t\tvoid Undo();\n\t\t\n\t\t/// <summary>\n\t\t/// Redo the last operation\n\t\t/// </summary>\n\t\tvoid Redo();\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Undo/UndoQueue.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 2161 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\n\nnamespace ICSharpCode.TextEditor.Undo\n{\n\t/// <summary>\n\t/// This class stacks the last x operations from the undostack and makes\n\t/// one undo/redo operation from it.\n\t/// </summary>\n\tinternal sealed class UndoQueue : IUndoableOperation\n\t{\n\t\tList<IUndoableOperation> undolist = new List<IUndoableOperation>();\n\t\t\n\t\t/// <summary>\n\t\t/// </summary>\n\t\tpublic UndoQueue(Stack<IUndoableOperation> stack, int numops)\n\t\t{\n\t\t\tif (stack == null)  {\n\t\t\t\tthrow new ArgumentNullException(\"stack\");\n\t\t\t}\n\t\t\t\n\t\t\tDebug.Assert(numops > 0 , \"ICSharpCode.TextEditor.Undo.UndoQueue : numops should be > 0\");\n\t\t\tif (numops > stack.Count) {\n\t\t\t\tnumops = stack.Count;\n\t\t\t}\n\t\t\t\n\t\t\tfor (int i = 0; i < numops; ++i) {\n\t\t\t\tundolist.Add(stack.Pop());\n\t\t\t}\n\t\t}\n\t\tpublic void Undo()\n\t\t{\n\t\t\tfor (int i = 0; i < undolist.Count; ++i) {\n\t\t\t\tundolist[i].Undo();\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic void Redo()\n\t\t{\n\t\t\tfor (int i = undolist.Count - 1 ; i >= 0 ; --i) {\n\t\t\t\tundolist[i].Redo();\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Undo/UndoStack.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 2827 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\nusing System.Drawing;\n\nnamespace ICSharpCode.TextEditor.Undo\n{\n\t/// <summary>\n\t/// This class implements an undo stack\n\t/// </summary>\n\tpublic class UndoStack\n\t{\n\t\tStack<IUndoableOperation> undostack = new Stack<IUndoableOperation>();\n\t\tStack<IUndoableOperation> redostack = new Stack<IUndoableOperation>();\n\t\t\n\t\tpublic TextEditorControlBase TextEditorControl = null;\n\t\t\n\t\t/// <summary>\n\t\t/// </summary>\n\t\tpublic event EventHandler ActionUndone;\n\t\t/// <summary>\n\t\t/// </summary>\n\t\tpublic event EventHandler ActionRedone;\n\t\t\n\t\t/// <summary>\n\t\t/// Gets/Sets if changes to the document are protocolled by the undo stack.\n\t\t/// Used internally to disable the undo stack temporarily while undoing an action.\n\t\t/// </summary>\n\t\tinternal bool AcceptChanges = true;\n\t\t\n\t\t/// <summary>\n\t\t/// Gets if there are actions on the undo stack.\n\t\t/// </summary>\n\t\tpublic bool CanUndo {\n\t\t\tget {\n\t\t\t\treturn undostack.Count > 0;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Gets if there are actions on the redo stack.\n\t\t/// </summary>\n\t\tpublic bool CanRedo {\n\t\t\tget {\n\t\t\t\treturn redostack.Count > 0;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Gets the number of actions on the undo stack.\n\t\t/// </summary>\n\t\tpublic int UndoItemCount {\n\t\t\tget {\n\t\t\t\treturn undostack.Count;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Gets the number of actions on the redo stack.\n\t\t/// </summary>\n\t\tpublic int RedoItemCount {\n\t\t\tget {\n\t\t\t\treturn redostack.Count;\n\t\t\t}\n\t\t}\n\t\t\n\t\tint undoGroupDepth;\n\t\tint actionCountInUndoGroup;\n\t\t\n\t\tpublic void StartUndoGroup()\n\t\t{\n\t\t\tif (undoGroupDepth == 0) {\n\t\t\t\tactionCountInUndoGroup = 0;\n\t\t\t}\n\t\t\tundoGroupDepth++;\n\t\t\t//Util.LoggingService.Debug(\"Open undo group (new depth=\" + undoGroupDepth + \")\");\n\t\t}\n\t\t\n\t\tpublic void EndUndoGroup()\n\t\t{\n\t\t\tif (undoGroupDepth == 0)\n\t\t\t\tthrow new InvalidOperationException(\"There are no open undo groups\");\n\t\t\tundoGroupDepth--;\n\t\t\t//Util.LoggingService.Debug(\"Close undo group (new depth=\" + undoGroupDepth + \")\");\n\t\t\tif (undoGroupDepth == 0 && actionCountInUndoGroup > 1) {\n\t\t\t\tundostack.Push(new UndoQueue(undostack, actionCountInUndoGroup));\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic void AssertNoUndoGroupOpen()\n\t\t{\n\t\t\tif (undoGroupDepth != 0) {\n\t\t\t\tundoGroupDepth = 0;\n\t\t\t\tthrow new InvalidOperationException(\"No undo group should be open at this point\");\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Call this method to undo the last operation on the stack\n\t\t/// </summary>\n\t\tpublic void Undo()\n\t\t{\n\t\t\tAssertNoUndoGroupOpen();\n\t\t\tif (undostack.Count > 0) {\n\t\t\t\tIUndoableOperation uedit = (IUndoableOperation)undostack.Pop();\n\t\t\t\tredostack.Push(uedit);\n\t\t\t\tuedit.Undo();\n\t\t\t\tOnActionUndone();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Call this method to redo the last undone operation\n\t\t/// </summary>\n\t\tpublic void Redo()\n\t\t{\n\t\t\tAssertNoUndoGroupOpen();\n\t\t\tif (redostack.Count > 0) {\n\t\t\t\tIUndoableOperation uedit = (IUndoableOperation)redostack.Pop();\n\t\t\t\tundostack.Push(uedit);\n\t\t\t\tuedit.Redo();\n\t\t\t\tOnActionRedone();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Call this method to push an UndoableOperation on the undostack, the redostack\n\t\t/// will be cleared, if you use this method.\n\t\t/// </summary>\n\t\tpublic void Push(IUndoableOperation operation)\n\t\t{\n\t\t\tif (operation == null) {\n\t\t\t\tthrow new ArgumentNullException(\"operation\");\n\t\t\t}\n\t\t\t\n\t\t\tif (AcceptChanges) {\n\t\t\t\tStartUndoGroup();\n\t\t\t\tundostack.Push(operation);\n\t\t\t\tactionCountInUndoGroup++;\n\t\t\t\tif (TextEditorControl != null) {\n\t\t\t\t\tundostack.Push(new UndoableSetCaretPosition(this, TextEditorControl.ActiveTextAreaControl.Caret.Position));\n\t\t\t\t\tactionCountInUndoGroup++;\n\t\t\t\t}\n\t\t\t\tEndUndoGroup();\n\t\t\t\tClearRedoStack();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Call this method, if you want to clear the redo stack\n\t\t/// </summary>\n\t\tpublic void ClearRedoStack()\n\t\t{\n\t\t\tredostack.Clear();\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Clears both the undo and redo stack.\n\t\t/// </summary>\n\t\tpublic void ClearAll()\n\t\t{\n\t\t\tAssertNoUndoGroupOpen();\n\t\t\tundostack.Clear();\n\t\t\tredostack.Clear();\n\t\t\tactionCountInUndoGroup = 0;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// </summary>\n\t\tprotected void OnActionUndone()\n\t\t{\n\t\t\tif (ActionUndone != null) {\n\t\t\t\tActionUndone(null, null);\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// </summary>\n\t\tprotected void OnActionRedone()\n\t\t{\n\t\t\tif (ActionRedone != null) {\n\t\t\t\tActionRedone(null, null);\n\t\t\t}\n\t\t}\n\t\t\n\t\tclass UndoableSetCaretPosition : IUndoableOperation\n\t\t{\n\t\t\tUndoStack stack;\n\t\t\tTextLocation pos;\n\t\t\tTextLocation redoPos;\n\t\t\t\n\t\t\tpublic UndoableSetCaretPosition(UndoStack stack, TextLocation pos)\n\t\t\t{\n\t\t\t\tthis.stack = stack;\n\t\t\t\tthis.pos = pos;\n\t\t\t}\n\t\t\t\n\t\t\tpublic void Undo()\n\t\t\t{\n\t\t\t\tredoPos = stack.TextEditorControl.ActiveTextAreaControl.Caret.Position;\n\t\t\t\tstack.TextEditorControl.ActiveTextAreaControl.Caret.Position = pos;\n\t\t\t}\n\t\t\t\n\t\t\tpublic void Redo()\n\t\t\t{\n\t\t\t\tstack.TextEditorControl.ActiveTextAreaControl.Caret.Position = redoPos;\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Undo/UndoableDelete.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 1965 $</version>\n// </file>\n\nusing System;\nusing System.Diagnostics;\nusing ICSharpCode.TextEditor.Document;\n\nnamespace ICSharpCode.TextEditor.Undo\n{\n\t/// <summary>\n\t/// This class is for the undo of Document insert operations\n\t/// </summary>\n\tpublic class UndoableDelete : IUndoableOperation\n\t{\n\t\tIDocument document;\n//\t\tint      oldCaretPos;\n\t\tint      offset;\n\t\tstring   text;\n\t\t\n\t\t/// <summary>\n\t\t/// Creates a new instance of <see cref=\"UndoableDelete\"/>\n\t\t/// </summary>\t\n\t\tpublic UndoableDelete(IDocument document, int offset, string text)\n\t\t{\n\t\t\tif (document == null) {\n\t\t\t\tthrow new ArgumentNullException(\"document\");\n\t\t\t}\n\t\t\tif (offset < 0 || offset > document.TextLength) {\n\t\t\t\tthrow new ArgumentOutOfRangeException(\"offset\");\n\t\t\t}\n\t\t\t\n\t\t\tDebug.Assert(text != null, \"text can't be null\");\n//\t\t\toldCaretPos   = document.Caret.Offset;\n\t\t\tthis.document = document;\n\t\t\tthis.offset   = offset;\n\t\t\tthis.text     = text;\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// Undo last operation\n\t\t/// </remarks>\n\t\tpublic void Undo()\n\t\t{\n\t\t\t// we clear all selection direct, because the redraw\n\t\t\t// is done per refresh at the end of the action\n//\t\t\ttextArea.SelectionManager.SelectionCollection.Clear();\n\t\t\tdocument.UndoStack.AcceptChanges = false;\n\t\t\tdocument.Insert(offset, text);\n//\t\t\tdocument.Caret.Offset = Math.Min(document.TextLength, Math.Max(0, oldCaretPos));\n\t\t\tdocument.UndoStack.AcceptChanges = true;\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// Redo last undone operation\n\t\t/// </remarks>\n\t\tpublic void Redo()\n\t\t{\n\t\t\t// we clear all selection direct, because the redraw\n\t\t\t// is done per refresh at the end of the action\n//\t\t\ttextArea.SelectionManager.SelectionCollection.Clear();\n\n\t\t\tdocument.UndoStack.AcceptChanges = false;\n\t\t\tdocument.Remove(offset, text.Length);\n//\t\t\tdocument.Caret.Offset = Math.Min(document.TextLength, Math.Max(0, document.Caret.Offset));\n\t\t\tdocument.UndoStack.AcceptChanges = true;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Undo/UndoableInsert.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 1965 $</version>\n// </file>\n\nusing System;\nusing System.Diagnostics;\nusing ICSharpCode.TextEditor.Document;\n\nnamespace ICSharpCode.TextEditor.Undo\n{\n\t/// <summary>\n\t/// This class is for the undo of Document insert operations\n\t/// </summary>\n\tpublic class UndoableInsert : IUndoableOperation\n\t{\n\t\tIDocument document;\n//\t\tint      oldCaretPos;\n\t\tint      offset;\n\t\tstring   text;\n\t\t\n\t\t/// <summary>\n\t\t/// Creates a new instance of <see cref=\"UndoableInsert\"/>\n\t\t/// </summary>\t\n\t\tpublic UndoableInsert(IDocument document, int offset, string text)\n\t\t{\n\t\t\tif (document == null) {\n\t\t\t\tthrow new ArgumentNullException(\"document\");\n\t\t\t}\n\t\t\tif (offset < 0 || offset > document.TextLength) {\n\t\t\t\tthrow new ArgumentOutOfRangeException(\"offset\");\n\t\t\t}\n\t\t\t\n\t\t\tDebug.Assert(text != null, \"text can't be null\");\n//\t\t\toldCaretPos   = document.Caret.Offset;\n\t\t\tthis.document = document;\n\t\t\tthis.offset   = offset;\n\t\t\tthis.text     = text;\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// Undo last operation\n\t\t/// </remarks>\n\t\tpublic void Undo()\n\t\t{\n\t\t\t// we clear all selection direct, because the redraw\n\t\t\t// is done per refresh at the end of the action\n//\t\t\tdocument.SelectionCollection.Clear();\n\n\t\t\tdocument.UndoStack.AcceptChanges = false;\n\t\t\tdocument.Remove(offset, text.Length);\n//\t\t\tdocument.Caret.Offset = Math.Min(document.TextLength, Math.Max(0, oldCaretPos));\n\t\t\tdocument.UndoStack.AcceptChanges = true;\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// Redo last undone operation\n\t\t/// </remarks>\n\t\tpublic void Redo()\n\t\t{\n\t\t\t// we clear all selection direct, because the redraw\n\t\t\t// is done per refresh at the end of the action\n//\t\t\tdocument.SelectionCollection.Clear();\n\n\t\t\tdocument.UndoStack.AcceptChanges = false;\n\t\t\tdocument.Insert(offset, text);\n//\t\t\tdocument.Caret.Offset = Math.Min(document.TextLength, Math.Max(0, document.Caret.Offset));\n\t\t\tdocument.UndoStack.AcceptChanges = true;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Undo/UndoableReplace.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 1965 $</version>\n// </file>\n\nusing System;\nusing System.Diagnostics;\nusing ICSharpCode.TextEditor.Document;\n\nnamespace ICSharpCode.TextEditor.Undo\n{\n\t/// <summary>\n\t/// This class is for the undo of Document insert operations\n\t/// </summary>\n\tpublic class UndoableReplace : IUndoableOperation\n\t{\n\t\tIDocument document;\n//\t\tint       oldCaretPos;\n\t\tint       offset;\n\t\tstring    text;\n\t\tstring    origText;\n\t\t\n\t\t/// <summary>\n\t\t/// Creates a new instance of <see cref=\"UndoableReplace\"/>\n\t\t/// </summary>\t\n\t\tpublic UndoableReplace(IDocument document, int offset, string origText, string text)\n\t\t{\n\t\t\tif (document == null) {\n\t\t\t\tthrow new ArgumentNullException(\"document\");\n\t\t\t}\n\t\t\tif (offset < 0 || offset > document.TextLength) {\n\t\t\t\tthrow new ArgumentOutOfRangeException(\"offset\");\n\t\t\t}\n\t\t\t\n\t\t\tDebug.Assert(text != null, \"text can't be null\");\n//\t\t\toldCaretPos   = document.Caret.Offset;\n\t\t\tthis.document = document;\n\t\t\tthis.offset   = offset;\n\t\t\tthis.text     = text;\n\t\t\tthis.origText = origText;\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// Undo last operation\n\t\t/// </remarks>\n\t\tpublic void Undo()\n\t\t{\n\t\t\t// we clear all selection direct, because the redraw\n\t\t\t// is done per refresh at the end of the action\n//\t\t\tdocument.SelectionCollection.Clear();\n\n\t\t\tdocument.UndoStack.AcceptChanges = false;\n\t\t\tdocument.Replace(offset, text.Length, origText);\n//\t\t\tdocument.Caret.Offset = Math.Min(document.TextLength, Math.Max(0, oldCaretPos));\n\t\t\tdocument.UndoStack.AcceptChanges = true;\n\t\t}\n\t\t\n\t\t/// <remarks>\n\t\t/// Redo last undone operation\n\t\t/// </remarks>\n\t\tpublic void Redo()\n\t\t{\n\t\t\t// we clear all selection direct, because the redraw\n\t\t\t// is done per refresh at the end of the action\n//\t\t\tdocument.SelectionCollection.Clear();\n\n\t\t\tdocument.UndoStack.AcceptChanges = false;\n\t\t\tdocument.Replace(offset, origText.Length, text);\n//\t\t\tdocument.Caret.Offset = Math.Min(document.TextLength, Math.Max(0, document.Caret.Offset));\n\t\t\tdocument.UndoStack.AcceptChanges = true;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Util/AugmentableRedBlackTree.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Daniel Grunwald\" email=\"daniel@danielgrunwald.de\"/>\n//     <version>$Revision: 2497 $</version>\n// </file>\n\nusing System;\nusing System.Text;\nusing System.Diagnostics;\nusing System.Collections.Generic;\n\nnamespace ICSharpCode.TextEditor.Util\n{\n\tinternal sealed class RedBlackTreeNode<T>\n\t{\n\t\tinternal RedBlackTreeNode<T> left, right, parent;\n\t\tinternal T val;\n\t\tinternal bool color;\n\t\t\n\t\tinternal RedBlackTreeNode(T val)\n\t\t{\n\t\t\tthis.val = val;\n\t\t}\n\t\t\n\t\tinternal RedBlackTreeNode<T> LeftMost {\n\t\t\tget {\n\t\t\t\tRedBlackTreeNode<T> node = this;\n\t\t\t\twhile (node.left != null)\n\t\t\t\t\tnode = node.left;\n\t\t\t\treturn node;\n\t\t\t}\n\t\t}\n\t\t\n\t\tinternal RedBlackTreeNode<T> RightMost {\n\t\t\tget {\n\t\t\t\tRedBlackTreeNode<T> node = this;\n\t\t\t\twhile (node.right != null)\n\t\t\t\t\tnode = node.right;\n\t\t\t\treturn node;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tinternal interface IRedBlackTreeHost<T> : IComparer<T>\n\t{\n\t\tbool Equals(T a, T b);\n\t\t\n\t\tvoid UpdateAfterChildrenChange(RedBlackTreeNode<T> node);\n\t\tvoid UpdateAfterRotateLeft(RedBlackTreeNode<T> node);\n\t\tvoid UpdateAfterRotateRight(RedBlackTreeNode<T> node);\n\t}\n\t\n\t/// <summary>\n\t/// Description of RedBlackTree.\n\t/// </summary>\n\tinternal sealed class AugmentableRedBlackTree<T, Host> : ICollection<T> where Host : IRedBlackTreeHost<T>\n\t{\n\t\treadonly Host host;\n\t\tint count;\n\t\tinternal RedBlackTreeNode<T> root;\n\t\t\n\t\tpublic AugmentableRedBlackTree(Host host)\n\t\t{\n\t\t\tif (host == null) throw new ArgumentNullException(\"host\");\n\t\t\tthis.host = host;\n\t\t}\n\t\t\n\t\tpublic int Count {\n\t\t\tget { return count; }\n\t\t}\n\t\t\n\t\tpublic void Clear()\n\t\t{\n\t\t\troot = null;\n\t\t\tcount = 0;\n\t\t}\n\t\t\n\t\t#region Debugging code\n\t\t#if DEBUG\n\t\t/// <summary>\n\t\t/// Check tree for consistency and being balanced.\n\t\t/// </summary>\n\t\t[Conditional(\"DATACONSISTENCYTEST\")]\n\t\tvoid CheckProperties()\n\t\t{\n\t\t\tint blackCount = -1;\n\t\t\tCheckNodeProperties(root, null, RED, 0, ref blackCount);\n\t\t\t\n\t\t\tint nodeCount = 0;\n\t\t\tforeach (T val in this) {\n\t\t\t\tnodeCount++;\n\t\t\t}\n\t\t\tDebug.Assert(count == nodeCount);\n\t\t}\n\t\t\n\t\t/*\n\t\t1. A node is either red or black.\n\t\t2. The root is black.\n\t\t3. All leaves are black. (The leaves are the NIL children.)\n\t\t4. Both children of every red node are black. (So every red node must have a black parent.)\n\t\t5. Every simple path from a node to a descendant leaf contains the same number of black nodes. (Not counting the leaf node.)\n\t\t */\n\t\tvoid CheckNodeProperties(RedBlackTreeNode<T> node, RedBlackTreeNode<T> parentNode, bool parentColor, int blackCount, ref int expectedBlackCount)\n\t\t{\n\t\t\tif (node == null) return;\n\t\t\t\n\t\t\tDebug.Assert(node.parent == parentNode);\n\t\t\t\n\t\t\tif (parentColor == RED) {\n\t\t\t\tDebug.Assert(node.color == BLACK);\n\t\t\t}\n\t\t\tif (node.color == BLACK) {\n\t\t\t\tblackCount++;\n\t\t\t}\n\t\t\tif (node.left == null && node.right == null) {\n\t\t\t\t// node is a leaf node:\n\t\t\t\tif (expectedBlackCount == -1)\n\t\t\t\t\texpectedBlackCount = blackCount;\n\t\t\t\telse\n\t\t\t\t\tDebug.Assert(expectedBlackCount == blackCount);\n\t\t\t}\n\t\t\tCheckNodeProperties(node.left, node, node.color, blackCount, ref expectedBlackCount);\n\t\t\tCheckNodeProperties(node.right, node, node.color, blackCount, ref expectedBlackCount);\n\t\t}\n\t\t\n\t\tpublic string GetTreeAsString()\n\t\t{\n\t\t\tStringBuilder b = new StringBuilder();\n\t\t\tAppendTreeToString(root, b, 0);\n\t\t\treturn b.ToString();\n\t\t}\n\t\t\n\t\tstatic void AppendTreeToString(RedBlackTreeNode<T> node, StringBuilder b, int indent)\n\t\t{\n\t\t\tif (node.color == RED)\n\t\t\t\tb.Append(\"RED   \");\n\t\t\telse\n\t\t\t\tb.Append(\"BLACK \");\n\t\t\tb.AppendLine(node.val.ToString());\n\t\t\tindent += 2;\n\t\t\tif (node.left != null) {\n\t\t\t\tb.Append(' ', indent);\n\t\t\t\tb.Append(\"L: \");\n\t\t\t\tAppendTreeToString(node.left, b, indent);\n\t\t\t}\n\t\t\tif (node.right != null) {\n\t\t\t\tb.Append(' ', indent);\n\t\t\t\tb.Append(\"R: \");\n\t\t\t\tAppendTreeToString(node.right, b, indent);\n\t\t\t}\n\t\t}\n\t\t#endif\n\t\t#endregion\n\t\t\n\t\t#region Add\n\t\tpublic void Add(T item)\n\t\t{\n\t\t\tAddInternal(new RedBlackTreeNode<T>(item));\n\t\t\t#if DEBUG\n\t\t\tCheckProperties();\n\t\t\t#endif\n\t\t}\n\t\t\n\t\tvoid AddInternal(RedBlackTreeNode<T> newNode)\n\t\t{\n\t\t\tDebug.Assert(newNode.color == BLACK);\n\t\t\tif (root == null) {\n\t\t\t\tcount = 1;\n\t\t\t\troot = newNode;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Insert into the tree\n\t\t\tRedBlackTreeNode<T> parentNode = root;\n\t\t\twhile (true) {\n\t\t\t\tif (host.Compare(newNode.val, parentNode.val) <= 0) {\n\t\t\t\t\tif (parentNode.left == null) {\n\t\t\t\t\t\tInsertAsLeft(parentNode, newNode);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tparentNode = parentNode.left;\n\t\t\t\t} else {\n\t\t\t\t\tif (parentNode.right == null) {\n\t\t\t\t\t\tInsertAsRight(parentNode, newNode);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tparentNode = parentNode.right;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tinternal void InsertAsLeft(RedBlackTreeNode<T> parentNode, RedBlackTreeNode<T> newNode)\n\t\t{\n\t\t\tDebug.Assert(parentNode.left == null);\n\t\t\tparentNode.left = newNode;\n\t\t\tnewNode.parent = parentNode;\n\t\t\tnewNode.color = RED;\n\t\t\thost.UpdateAfterChildrenChange(parentNode);\n\t\t\tFixTreeOnInsert(newNode);\n\t\t\tcount++;\n\t\t}\n\t\t\n\t\tinternal void InsertAsRight(RedBlackTreeNode<T> parentNode, RedBlackTreeNode<T> newNode)\n\t\t{\n\t\t\tDebug.Assert(parentNode.right == null);\n\t\t\tparentNode.right = newNode;\n\t\t\tnewNode.parent = parentNode;\n\t\t\tnewNode.color = RED;\n\t\t\thost.UpdateAfterChildrenChange(parentNode);\n\t\t\tFixTreeOnInsert(newNode);\n\t\t\tcount++;\n\t\t}\n\t\t\n\t\tvoid FixTreeOnInsert(RedBlackTreeNode<T> node)\n\t\t{\n\t\t\tDebug.Assert(node != null);\n\t\t\tDebug.Assert(node.color == RED);\n\t\t\tDebug.Assert(node.left == null || node.left.color == BLACK);\n\t\t\tDebug.Assert(node.right == null || node.right.color == BLACK);\n\t\t\t\n\t\t\tRedBlackTreeNode<T> parentNode = node.parent;\n\t\t\tif (parentNode == null) {\n\t\t\t\t// we inserted in the root -> the node must be black\n\t\t\t\t// since this is a root node, making the node black increments the number of black nodes\n\t\t\t\t// on all paths by one, so it is still the same for all paths.\n\t\t\t\tnode.color = BLACK;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (parentNode.color == BLACK) {\n\t\t\t\t// if the parent node where we inserted was black, our red node is placed correctly.\n\t\t\t\t// since we inserted a red node, the number of black nodes on each path is unchanged\n\t\t\t\t// -> the tree is still balanced\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// parentNode is red, so there is a conflict here!\n\t\t\t\n\t\t\t// because the root is black, parentNode is not the root -> there is a grandparent node\n\t\t\tRedBlackTreeNode<T> grandparentNode = parentNode.parent;\n\t\t\tRedBlackTreeNode<T> uncleNode = Sibling(parentNode);\n\t\t\tif (uncleNode != null && uncleNode.color == RED) {\n\t\t\t\tparentNode.color = BLACK;\n\t\t\t\tuncleNode.color = BLACK;\n\t\t\t\tgrandparentNode.color = RED;\n\t\t\t\tFixTreeOnInsert(grandparentNode);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// now we know: parent is red but uncle is black\n\t\t\t// First rotation:\n\t\t\tif (node == parentNode.right && parentNode == grandparentNode.left) {\n\t\t\t\tRotateLeft(parentNode);\n\t\t\t\tnode = node.left;\n\t\t\t} else if (node == parentNode.left && parentNode == grandparentNode.right) {\n\t\t\t\tRotateRight(parentNode);\n\t\t\t\tnode = node.right;\n\t\t\t}\n\t\t\t// because node might have changed, reassign variables:\n\t\t\tparentNode = node.parent;\n\t\t\tgrandparentNode = parentNode.parent;\n\t\t\t\n\t\t\t// Now recolor a bit:\n\t\t\tparentNode.color = BLACK;\n\t\t\tgrandparentNode.color = RED;\n\t\t\t// Second rotation:\n\t\t\tif (node == parentNode.left && parentNode == grandparentNode.left) {\n\t\t\t\tRotateRight(grandparentNode);\n\t\t\t} else {\n\t\t\t\t// because of the first rotation, this is guaranteed:\n\t\t\t\tDebug.Assert(node == parentNode.right && parentNode == grandparentNode.right);\n\t\t\t\tRotateLeft(grandparentNode);\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid ReplaceNode(RedBlackTreeNode<T> replacedNode, RedBlackTreeNode<T> newNode)\n\t\t{\n\t\t\tif (replacedNode.parent == null) {\n\t\t\t\tDebug.Assert(replacedNode == root);\n\t\t\t\troot = newNode;\n\t\t\t} else {\n\t\t\t\tif (replacedNode.parent.left == replacedNode)\n\t\t\t\t\treplacedNode.parent.left = newNode;\n\t\t\t\telse\n\t\t\t\t\treplacedNode.parent.right = newNode;\n\t\t\t}\n\t\t\tif (newNode != null) {\n\t\t\t\tnewNode.parent = replacedNode.parent;\n\t\t\t}\n\t\t\treplacedNode.parent = null;\n\t\t}\n\t\t\n\t\tvoid RotateLeft(RedBlackTreeNode<T> p)\n\t\t{\n\t\t\t// let q be p's right child\n\t\t\tRedBlackTreeNode<T> q = p.right;\n\t\t\tDebug.Assert(q != null);\n\t\t\tDebug.Assert(q.parent == p);\n\t\t\t// set q to be the new root\n\t\t\tReplaceNode(p, q);\n\t\t\t\n\t\t\t// set p's right child to be q's left child\n\t\t\tp.right = q.left;\n\t\t\tif (p.right != null) p.right.parent = p;\n\t\t\t// set q's left child to be p\n\t\t\tq.left = p;\n\t\t\tp.parent = q;\n\t\t\thost.UpdateAfterRotateLeft(p);\n\t\t}\n\t\t\n\t\tvoid RotateRight(RedBlackTreeNode<T> p)\n\t\t{\n\t\t\t// let q be p's left child\n\t\t\tRedBlackTreeNode<T> q = p.left;\n\t\t\tDebug.Assert(q != null);\n\t\t\tDebug.Assert(q.parent == p);\n\t\t\t// set q to be the new root\n\t\t\tReplaceNode(p, q);\n\t\t\t\n\t\t\t// set p's left child to be q's right child\n\t\t\tp.left = q.right;\n\t\t\tif (p.left != null) p.left.parent = p;\n\t\t\t// set q's right child to be p\n\t\t\tq.right = p;\n\t\t\tp.parent = q;\n\t\t\thost.UpdateAfterRotateRight(p);\n\t\t}\n\t\t\n\t\tRedBlackTreeNode<T> Sibling(RedBlackTreeNode<T> node)\n\t\t{\n\t\t\tif (node == node.parent.left)\n\t\t\t\treturn node.parent.right;\n\t\t\telse\n\t\t\t\treturn node.parent.left;\n\t\t}\n\t\t#endregion\n\t\t\n\t\t#region Remove\n\t\tpublic void RemoveAt(RedBlackTreeIterator<T> iterator)\n\t\t{\n\t\t\tRedBlackTreeNode<T> node = iterator.node;\n\t\t\tif (node == null)\n\t\t\t\tthrow new ArgumentException(\"Invalid iterator\");\n\t\t\twhile (node.parent != null)\n\t\t\t\tnode = node.parent;\n\t\t\tif (node != root)\n\t\t\t\tthrow new ArgumentException(\"Iterator does not belong to this tree\");\n\t\t\tRemoveNode(iterator.node);\n\t\t\t#if DEBUG\n\t\t\tCheckProperties();\n\t\t\t#endif\n\t\t}\n\t\t\n\t\tinternal void RemoveNode(RedBlackTreeNode<T> removedNode)\n\t\t{\n\t\t\tif (removedNode.left != null && removedNode.right != null) {\n\t\t\t\t// replace removedNode with it's in-order successor\n\t\t\t\t\n\t\t\t\tRedBlackTreeNode<T> leftMost = removedNode.right.LeftMost;\n\t\t\t\tRemoveNode(leftMost); // remove leftMost from its current location\n\t\t\t\t\n\t\t\t\t// and overwrite the removedNode with it\n\t\t\t\tReplaceNode(removedNode, leftMost);\n\t\t\t\tleftMost.left = removedNode.left;\n\t\t\t\tif (leftMost.left != null) leftMost.left.parent = leftMost;\n\t\t\t\tleftMost.right = removedNode.right;\n\t\t\t\tif (leftMost.right != null) leftMost.right.parent = leftMost;\n\t\t\t\tleftMost.color = removedNode.color;\n\t\t\t\t\n\t\t\t\thost.UpdateAfterChildrenChange(leftMost);\n\t\t\t\tif (leftMost.parent != null) host.UpdateAfterChildrenChange(leftMost.parent);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tcount--;\n\t\t\t\n\t\t\t// now either removedNode.left or removedNode.right is null\n\t\t\t// get the remaining child\n\t\t\tRedBlackTreeNode<T> parentNode = removedNode.parent;\n\t\t\tRedBlackTreeNode<T> childNode = removedNode.left ?? removedNode.right;\n\t\t\tReplaceNode(removedNode, childNode);\n\t\t\tif (parentNode != null) host.UpdateAfterChildrenChange(parentNode);\n\t\t\tif (removedNode.color == BLACK) {\n\t\t\t\tif (childNode != null && childNode.color == RED) {\n\t\t\t\t\tchildNode.color = BLACK;\n\t\t\t\t} else {\n\t\t\t\t\tFixTreeOnDelete(childNode, parentNode);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tstatic RedBlackTreeNode<T> Sibling(RedBlackTreeNode<T> node, RedBlackTreeNode<T> parentNode)\n\t\t{\n\t\t\tDebug.Assert(node == null || node.parent == parentNode);\n\t\t\tif (node == parentNode.left)\n\t\t\t\treturn parentNode.right;\n\t\t\telse\n\t\t\t\treturn parentNode.left;\n\t\t}\n\t\t\n\t\tconst bool RED = true;\n\t\tconst bool BLACK = false;\n\t\t\n\t\tstatic bool GetColor(RedBlackTreeNode<T> node)\n\t\t{\n\t\t\treturn node != null ? node.color : BLACK;\n\t\t}\n\t\t\n\t\tvoid FixTreeOnDelete(RedBlackTreeNode<T> node, RedBlackTreeNode<T> parentNode)\n\t\t{\n\t\t\tDebug.Assert(node == null || node.parent == parentNode);\n\t\t\tif (parentNode == null)\n\t\t\t\treturn;\n\t\t\t\n\t\t\t// warning: node may be null\n\t\t\tRedBlackTreeNode<T> sibling = Sibling(node, parentNode);\n\t\t\tif (sibling.color == RED) {\n\t\t\t\tparentNode.color = RED;\n\t\t\t\tsibling.color = BLACK;\n\t\t\t\tif (node == parentNode.left) {\n\t\t\t\t\tRotateLeft(parentNode);\n\t\t\t\t} else {\n\t\t\t\t\tRotateRight(parentNode);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tsibling = Sibling(node, parentNode); // update value of sibling after rotation\n\t\t\t}\n\t\t\t\n\t\t\tif (parentNode.color == BLACK\n\t\t\t    && sibling.color == BLACK\n\t\t\t    && GetColor(sibling.left) == BLACK\n\t\t\t    && GetColor(sibling.right) == BLACK)\n\t\t\t{\n\t\t\t\tsibling.color = RED;\n\t\t\t\tFixTreeOnDelete(parentNode, parentNode.parent);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tif (parentNode.color == RED\n\t\t\t    && sibling.color == BLACK\n\t\t\t    && GetColor(sibling.left) == BLACK\n\t\t\t    && GetColor(sibling.right) == BLACK)\n\t\t\t{\n\t\t\t\tsibling.color = RED;\n\t\t\t\tparentNode.color = BLACK;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tif (node == parentNode.left &&\n\t\t\t    sibling.color == BLACK &&\n\t\t\t    GetColor(sibling.left) == RED &&\n\t\t\t    GetColor(sibling.right) == BLACK)\n\t\t\t{\n\t\t\t\tsibling.color = RED;\n\t\t\t\tsibling.left.color = BLACK;\n\t\t\t\tRotateRight(sibling);\n\t\t\t}\n\t\t\telse if (node == parentNode.right &&\n\t\t\t         sibling.color == BLACK &&\n\t\t\t         GetColor(sibling.right) == RED &&\n\t\t\t         GetColor(sibling.left) == BLACK)\n\t\t\t{\n\t\t\t\tsibling.color = RED;\n\t\t\t\tsibling.right.color = BLACK;\n\t\t\t\tRotateLeft(sibling);\n\t\t\t}\n\t\t\tsibling = Sibling(node, parentNode); // update value of sibling after rotation\n\t\t\t\n\t\t\tsibling.color = parentNode.color;\n\t\t\tparentNode.color = BLACK;\n\t\t\tif (node == parentNode.left) {\n\t\t\t\tif (sibling.right != null) {\n\t\t\t\t\tDebug.Assert(sibling.right.color == RED);\n\t\t\t\t\tsibling.right.color = BLACK;\n\t\t\t\t}\n\t\t\t\tRotateLeft(parentNode);\n\t\t\t} else {\n\t\t\t\tif (sibling.left != null) {\n\t\t\t\t\tDebug.Assert(sibling.left.color == RED);\n\t\t\t\t\tsibling.left.color = BLACK;\n\t\t\t\t}\n\t\t\t\tRotateRight(parentNode);\n\t\t\t}\n\t\t}\n\t\t#endregion\n\t\t\n\t\t#region Find/LowerBound/UpperBound/GetEnumerator\n\t\t/// <summary>\n\t\t/// Returns the iterator pointing to the specified item, or an iterator in End state if the item is not found.\n\t\t/// </summary>\n\t\tpublic RedBlackTreeIterator<T> Find(T item)\n\t\t{\n\t\t\tRedBlackTreeIterator<T> it = LowerBound(item);\n\t\t\twhile (it.IsValid && host.Compare(it.Current, item) == 0) {\n\t\t\t\tif (host.Equals(it.Current, item))\n\t\t\t\t\treturn it;\n\t\t\t\tit.MoveNext();\n\t\t\t}\n\t\t\treturn default(RedBlackTreeIterator<T>);\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Returns the iterator pointing to the first item greater or equal to <paramref name=\"item\"/>.\n\t\t/// </summary>\n\t\tpublic RedBlackTreeIterator<T> LowerBound(T item)\n\t\t{\n\t\t\tRedBlackTreeNode<T> node = root;\n\t\t\tRedBlackTreeNode<T> resultNode = null;\n\t\t\twhile (node != null) {\n\t\t\t\tif (host.Compare(node.val, item) < 0) {\n\t\t\t\t\tnode = node.right;\n\t\t\t\t} else {\n\t\t\t\t\tresultNode = node;\n\t\t\t\t\tnode = node.left;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn new RedBlackTreeIterator<T>(resultNode);\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Returns the iterator pointing to the first item greater than <paramref name=\"item\"/>.\n\t\t/// </summary>\n\t\tpublic RedBlackTreeIterator<T> UpperBound(T item)\n\t\t{\n\t\t\tRedBlackTreeIterator<T> it = LowerBound(item);\n\t\t\twhile (it.IsValid && host.Compare(it.Current, item) == 0) {\n\t\t\t\tit.MoveNext();\n\t\t\t}\n\t\t\treturn it;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Gets a tree iterator that starts on the first node.\n\t\t/// </summary>\n\t\tpublic RedBlackTreeIterator<T> Begin()\n\t\t{\n\t\t\tif (root == null) return default(RedBlackTreeIterator<T>);\n\t\t\treturn new RedBlackTreeIterator<T>(root.LeftMost);\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Gets a tree iterator that starts one node before the first node.\n\t\t/// </summary>\n\t\tpublic RedBlackTreeIterator<T> GetEnumerator()\n\t\t{\n\t\t\tif (root == null) return default(RedBlackTreeIterator<T>);\n\t\t\tRedBlackTreeNode<T> dummyNode = new RedBlackTreeNode<T>(default(T));\n\t\t\tdummyNode.right = root;\n\t\t\treturn new RedBlackTreeIterator<T>(dummyNode);\n\t\t}\n\t\t#endregion\n\t\t\n\t\t#region ICollection members\n\t\tpublic bool Contains(T item)\n\t\t{\n\t\t\treturn Find(item).IsValid;\n\t\t}\n\t\t\n\t\tpublic bool Remove(T item)\n\t\t{\n\t\t\tRedBlackTreeIterator<T> it = Find(item);\n\t\t\tif (!it.IsValid) {\n\t\t\t\treturn false;\n\t\t\t} else {\n\t\t\t\tRemoveAt(it);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\t\n\t\tIEnumerator<T> IEnumerable<T>.GetEnumerator()\n\t\t{\n\t\t\treturn GetEnumerator();\n\t\t}\n\t\t\n\t\tSystem.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()\n\t\t{\n\t\t\treturn GetEnumerator();\n\t\t}\n\t\t\n\t\tbool ICollection<T>.IsReadOnly {\n\t\t\tget { return false; }\n\t\t}\n\t\t\n\t\tpublic void CopyTo(T[] array, int arrayIndex)\n\t\t{\n\t\t\tif (array == null) throw new ArgumentNullException(\"array\");\n\t\t\tforeach (T val in this) {\n\t\t\t\tarray[arrayIndex++] = val;\n\t\t\t}\n\t\t}\n\t\t#endregion\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Util/CheckedList.cs",
    "content": "// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <author name=\"Daniel Grunwald\"/>\n//     <version>$Revision: 3090 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\nusing System.Threading;\n\nnamespace ICSharpCode.TextEditor.Util\n{\n\t/// <summary>\n\t/// A IList{T} that checks that it is only accessed on the thread that created it, and that\n\t/// it is not modified while an enumerator is running.\n\t/// </summary>\n\tsealed class CheckedList<T> : IList<T>\n\t{\n\t\treadonly int threadID;\n\t\treadonly IList<T> baseList;\n\t\tint enumeratorCount;\n\t\t\n\t\tpublic CheckedList() : this(new List<T>()) {}\n\t\t\n\t\tpublic CheckedList(IList<T> baseList)\n\t\t{\n\t\t\tif (baseList == null)\n\t\t\t\tthrow new ArgumentNullException(\"baseList\");\n\t\t\tthis.baseList = baseList;\n\t\t\tthis.threadID = Thread.CurrentThread.ManagedThreadId;\n\t\t}\n\t\t\n\t\tvoid CheckRead()\n\t\t{\n\t\t\tif (Thread.CurrentThread.ManagedThreadId != threadID)\n\t\t\t\tthrow new InvalidOperationException(\"CheckList cannot be accessed from this thread!\");\n\t\t}\n\t\t\n\t\tvoid CheckWrite()\n\t\t{\n\t\t\tif (Thread.CurrentThread.ManagedThreadId != threadID)\n\t\t\t\tthrow new InvalidOperationException(\"CheckList cannot be accessed from this thread!\");\n\t\t\tif (enumeratorCount != 0)\n\t\t\t\tthrow new InvalidOperationException(\"CheckList cannot be written to while enumerators are active!\");\n\t\t}\n\t\t\n\t\tpublic T this[int index] {\n\t\t\tget {\n\t\t\t\tCheckRead();\n\t\t\t\treturn baseList[index];\n\t\t\t}\n\t\t\tset {\n\t\t\t\tCheckWrite();\n\t\t\t\tbaseList[index] = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int Count {\n\t\t\tget {\n\t\t\t\tCheckRead();\n\t\t\t\treturn baseList.Count;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic bool IsReadOnly {\n\t\t\tget {\n\t\t\t\tCheckRead();\n\t\t\t\treturn baseList.IsReadOnly;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic int IndexOf(T item)\n\t\t{\n\t\t\tCheckRead();\n\t\t\treturn baseList.IndexOf(item);\n\t\t}\n\t\t\n\t\tpublic void Insert(int index, T item)\n\t\t{\n\t\t\tCheckWrite();\n\t\t\tbaseList.Insert(index, item);\n\t\t}\n\t\t\n\t\tpublic void RemoveAt(int index)\n\t\t{\n\t\t\tCheckWrite();\n\t\t\tbaseList.RemoveAt(index);\n\t\t}\n\t\t\n\t\tpublic void Add(T item)\n\t\t{\n\t\t\tCheckWrite();\n\t\t\tbaseList.Add(item);\n\t\t}\n\t\t\n\t\tpublic void Clear()\n\t\t{\n\t\t\tCheckWrite();\n\t\t\tbaseList.Clear();\n\t\t}\n\t\t\n\t\tpublic bool Contains(T item)\n\t\t{\n\t\t\tCheckRead();\n\t\t\treturn baseList.Contains(item);\n\t\t}\n\t\t\n\t\tpublic void CopyTo(T[] array, int arrayIndex)\n\t\t{\n\t\t\tCheckRead();\n\t\t\tbaseList.CopyTo(array, arrayIndex);\n\t\t}\n\t\t\n\t\tpublic bool Remove(T item)\n\t\t{\n\t\t\tCheckWrite();\n\t\t\treturn baseList.Remove(item);\n\t\t}\n\t\t\n\t\tpublic IEnumerator<T> GetEnumerator()\n\t\t{\n\t\t\tCheckRead();\n\t\t\treturn Enumerate();\n\t\t}\n\t\t\n\t\tSystem.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()\n\t\t{\n\t\t\tCheckRead();\n\t\t\treturn Enumerate();\n\t\t}\n\t\t\n\t\tIEnumerator<T> Enumerate()\n\t\t{\n\t\t\tCheckRead();\n\t\t\ttry {\n\t\t\t\tenumeratorCount++;\n\t\t\t\tforeach (T val in baseList) {\n\t\t\t\t\tyield return val;\n\t\t\t\t\tCheckRead();\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tenumeratorCount--;\n\t\t\t\tCheckRead();\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Util/FileReader.cs",
    "content": "// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Daniel Grunwald\" email=\"daniel@danielgrunwald.de\"/>\n//     <version>$Revision: 2682 $</version>\n// </file>\n\nusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace ICSharpCode.TextEditor.Util\n{\n\t/// <summary>\n\t/// Class that can open text files with auto-detection of the encoding.\n\t/// </summary>\n\tpublic static class FileReader\n\t{\n\t\tpublic static bool IsUnicode(Encoding encoding)\n\t\t{\n\t\t\tint codepage = encoding.CodePage;\n\t\t\t// return true if codepage is any UTF codepage\n\t\t\treturn codepage == 65001 || codepage == 65000 || codepage == 1200 || codepage == 1201;\n\t\t}\n\t\t\n\t\tpublic static string ReadFileContent(Stream fs, ref Encoding encoding)\n\t\t{\n\t\t\tusing (StreamReader reader = OpenStream(fs, encoding)) {\n\t\t\t\treader.Peek();\n\t\t\t\tencoding = reader.CurrentEncoding;\n\t\t\t\treturn reader.ReadToEnd();\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic static string ReadFileContent(string fileName, Encoding encoding)\n\t\t{\n\t\t\tusing (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) {\n\t\t\t\treturn ReadFileContent(fs, ref encoding);\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic static StreamReader OpenStream(Stream fs, Encoding defaultEncoding)\n\t\t{\n\t\t\tif (fs == null)\n\t\t\t\tthrow new ArgumentNullException(\"fs\");\n\t\t\t\n\t\t\tif (fs.Length >= 2) {\n\t\t\t\t// the autodetection of StreamReader is not capable of detecting the difference\n\t\t\t\t// between ISO-8859-1 and UTF-8 without BOM.\n\t\t\t\tint firstByte = fs.ReadByte();\n\t\t\t\tint secondByte = fs.ReadByte();\n\t\t\t\tswitch ((firstByte << 8) | secondByte) {\n\t\t\t\t\tcase 0x0000: // either UTF-32 Big Endian or a binary file; use StreamReader\n\t\t\t\t\tcase 0xfffe: // Unicode BOM (UTF-16 LE or UTF-32 LE)\n\t\t\t\t\tcase 0xfeff: // UTF-16 BE BOM\n\t\t\t\t\tcase 0xefbb: // start of UTF-8 BOM\n\t\t\t\t\t\t// StreamReader autodetection works\n\t\t\t\t\t\tfs.Position = 0;\n\t\t\t\t\t\treturn new StreamReader(fs);\n\t\t\t\t\tdefault:\n\t\t\t\t\t\treturn AutoDetect(fs, (byte)firstByte, (byte)secondByte, defaultEncoding);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (defaultEncoding != null) {\n\t\t\t\t\treturn new StreamReader(fs, defaultEncoding);\n\t\t\t\t} else {\n\t\t\t\t\treturn new StreamReader(fs);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tstatic StreamReader AutoDetect(Stream fs, byte firstByte, byte secondByte, Encoding defaultEncoding)\n\t\t{\n\t\t\tint max = (int)Math.Min(fs.Length, 500000); // look at max. 500 KB\n\t\t\tconst int ASCII = 0;\n\t\t\tconst int Error = 1;\n\t\t\tconst int UTF8  = 2;\n\t\t\tconst int UTF8Sequence = 3;\n\t\t\tint state = ASCII;\n\t\t\tint sequenceLength = 0;\n\t\t\tbyte b;\n\t\t\tfor (int i = 0; i < max; i++) {\n\t\t\t\tif (i == 0) {\n\t\t\t\t\tb = firstByte;\n\t\t\t\t} else if (i == 1) {\n\t\t\t\t\tb = secondByte;\n\t\t\t\t} else {\n\t\t\t\t\tb = (byte)fs.ReadByte();\n\t\t\t\t}\n\t\t\t\tif (b < 0x80) {\n\t\t\t\t\t// normal ASCII character\n\t\t\t\t\tif (state == UTF8Sequence) {\n\t\t\t\t\t\tstate = Error;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t} else if (b < 0xc0) {\n\t\t\t\t\t// 10xxxxxx : continues UTF8 byte sequence\n\t\t\t\t\tif (state == UTF8Sequence) {\n\t\t\t\t\t\t--sequenceLength;\n\t\t\t\t\t\tif (sequenceLength < 0) {\n\t\t\t\t\t\t\tstate = Error;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t} else if (sequenceLength == 0) {\n\t\t\t\t\t\t\tstate = UTF8;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstate = Error;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t} else if (b >= 0xc2 && b < 0xf5) {\n\t\t\t\t\t// beginning of byte sequence\n\t\t\t\t\tif (state == UTF8 || state == ASCII) {\n\t\t\t\t\t\tstate = UTF8Sequence;\n\t\t\t\t\t\tif (b < 0xe0) {\n\t\t\t\t\t\t\tsequenceLength = 1; // one more byte following\n\t\t\t\t\t\t} else if (b < 0xf0) {\n\t\t\t\t\t\t\tsequenceLength = 2; // two more bytes following\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tsequenceLength = 3; // three more bytes following\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstate = Error;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// 0xc0, 0xc1, 0xf5 to 0xff are invalid in UTF-8 (see RFC 3629)\n\t\t\t\t\tstate = Error;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfs.Position = 0;\n\t\t\tswitch (state) {\n\t\t\t\tcase ASCII:\n\t\t\t\tcase Error:\n\t\t\t\t\t// when the file seems to be ASCII or non-UTF8,\n\t\t\t\t\t// we read it using the user-specified encoding so it is saved again\n\t\t\t\t\t// using that encoding.\n\t\t\t\t\tif (IsUnicode(defaultEncoding)) {\n\t\t\t\t\t\t// the file is not Unicode, so don't read it using Unicode even if the\n\t\t\t\t\t\t// user has choosen Unicode as the default encoding.\n\t\t\t\t\t\t\n\t\t\t\t\t\t// If we don't do this, SD will end up always adding a Byte Order Mark\n\t\t\t\t\t\t// to ASCII files.\n\t\t\t\t\t\tdefaultEncoding = Encoding.Default; // use system encoding instead\n\t\t\t\t\t}\n\t\t\t\t\treturn new StreamReader(fs, defaultEncoding);\n\t\t\t\tdefault:\n\t\t\t\t\treturn new StreamReader(fs);\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Util/LoggingService.cs",
    "content": "// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <author name=\"Daniel Grunwald\"/>\n//     <version>$Revision: 2719 $</version>\n// </file>\n\nusing System;\n\nnamespace ICSharpCode.TextEditor.Util\n{\n\t/// <summary>\n\t/// Central location for logging calls in the text editor.\n\t/// </summary>\n\tstatic class LoggingService\n\t{\n\t\tpublic static void Debug(string text)\n\t\t{\n\t\t\t#if DEBUG\n\t\t\tConsole.WriteLine(text);\n\t\t\t#endif\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Util/LookupTable.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 1965 $</version>\n// </file>\n\nusing System;\nusing ICSharpCode.TextEditor.Document;\n\nnamespace ICSharpCode.TextEditor.Util\n{\n\t/// <summary>\n\t/// This class implements a keyword map. It implements a digital search trees (tries) to find\n\t/// a word.\n\t/// </summary>\n\tpublic class LookupTable\n\t{\n\t\tNode root = new Node(null, null);\n\t\tbool casesensitive;\n\t\tint  length;\n\t\t\n\t\t/// <value>\n\t\t/// The number of elements in the table\n\t\t/// </value>\n\t\tpublic int Count {\n\t\t\tget {\n\t\t\t\treturn length;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Get the object, which was inserted under the keyword (line, at offset, with length length),\n\t\t/// returns null, if no such keyword was inserted.\n\t\t/// </summary>\n\t\tpublic object this[IDocument document, LineSegment line, int offset, int length] {\n\t\t\tget {\n\t\t\t\tif(length == 0) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t\tNode next = root;\n\t\t\t\t\n\t\t\t\tint wordOffset = line.Offset + offset;\n\t\t\t\tif (casesensitive) {\n\t\t\t\t\tfor (int i = 0; i < length; ++i) {\n\t\t\t\t\t\tint index = ((int)document.GetCharAt(wordOffset + i)) % 256;\n\t\t\t\t\t\tnext = next.leaf[index];\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (next == null) {\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (next.color != null && TextUtility.RegionMatches(document, wordOffset, length, next.word)) {\n\t\t\t\t\t\t\treturn next.color;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfor (int i = 0; i < length; ++i) {\n\t\t\t\t\t\tint index = ((int)Char.ToUpper(document.GetCharAt(wordOffset + i))) % 256;\n\t\t\t\t\t\t\n\t\t\t\t\t\tnext = next.leaf[index];\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (next == null) {\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (next.color != null && TextUtility.RegionMatches(document, casesensitive, wordOffset, length, next.word)) {\n\t\t\t\t\t\t\treturn next.color;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Inserts an object in the tree, under keyword\n\t\t/// </summary>\n\t\tpublic object this[string keyword] {\n\t\t\tset {\n\t\t\t\tNode node = root;\n\t\t\t\tNode next = root;\n\t\t\t\tif (!casesensitive) {\n\t\t\t\t\tkeyword = keyword.ToUpper();\n\t\t\t\t}\n\t\t\t\t++length;\n\t\t\t\t\n\t\t\t\t// insert word into the tree\n\t\t\t\tfor (int i = 0; i < keyword.Length; ++i) {\n\t\t\t\t\tint index = ((int)keyword[i]) % 256; // index of curchar\n\t\t\t\t\tbool d = keyword[i] == '\\\\';\n\t\t\t\t\t\n\t\t\t\t\tnext = next.leaf[index];             // get node to this index\n\t\t\t\t\t\n\t\t\t\t\tif (next == null) { // no node created -> insert word here\n\t\t\t\t\t\tnode.leaf[index] = new Node(value, keyword);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif (next.word != null && next.word.Length != i) { // node there, take node content and insert them again\n\t\t\t\t\t\tstring tmpword  = next.word;                  // this word will be inserted 1 level deeper (better, don't need too much \n\t\t\t\t\t\tobject tmpcolor = next.color;                 // string comparisons for finding.)\n\t\t\t\t\t\tnext.color = next.word = null;\n\t\t\t\t\t\tthis[tmpword] = tmpcolor;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif (i == keyword.Length - 1) { // end of keyword reached, insert node there, if a node was here it was\n\t\t\t\t\t\tnext.word = keyword;       // reinserted, if it has the same length (keyword EQUALS this word) it will be overwritten\n\t\t\t\t\t\tnext.color = value;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tnode = next;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Creates a new instance of <see cref=\"LookupTable\"/>\n\t\t/// </summary>\n\t\tpublic LookupTable(bool casesensitive)\n\t\t{\n\t\t\tthis.casesensitive = casesensitive;\n\t\t}\n\t\t\n\t\tclass Node\n\t\t{\n\t\t\tpublic Node(object color, string word)\n\t\t\t{\n\t\t\t\tthis.word  = word;\n\t\t\t\tthis.color = color;\n\t\t\t}\n\t\t\t\n\t\t\tpublic string word;\n\t\t\tpublic object color;\n\n\t\t\tpublic Node[] leaf {\n\t\t\t\tget { return _leaf ?? (_leaf = new Node[256]); }\n\t\t\t}\n\t\t\tprivate Node[] _leaf;\n\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Util/MouseWheelHandler.cs",
    "content": "// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <author name=\"Daniel Grunwald\"/>\n//     <version>$Revision: 3064 $</version>\n// </file>\n\nusing System;\nusing System.Windows.Forms;\n\nnamespace ICSharpCode.TextEditor.Util\n{\n\t/// <summary>\n\t/// Accumulates mouse wheel deltas and reports the actual number of lines to scroll.\n\t/// </summary>\n\tclass MouseWheelHandler\n\t{\n\t\t// CODE DUPLICATION: See ICSharpCode.SharpDevelop.Widgets.MouseWheelHandler\n\t\t\n\t\tconst int WHEEL_DELTA = 120;\n\t\t\n\t\tint mouseWheelDelta;\n\t\t\n\t\tpublic int GetScrollAmount(MouseEventArgs e)\n\t\t{\n\t\t\t// accumulate the delta to support high-resolution mice\n\t\t\tmouseWheelDelta += e.Delta;\n\t\t\t\n\t\t\tint linesPerClick = Math.Max(SystemInformation.MouseWheelScrollLines, 1);\n\t\t\t\n\t\t\tint scrollDistance = mouseWheelDelta * linesPerClick / WHEEL_DELTA;\n\t\t\tmouseWheelDelta %= Math.Max(1, WHEEL_DELTA / linesPerClick);\n\t\t\treturn scrollDistance;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Util/RedBlackTreeIterator.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Daniel Grunwald\" email=\"daniel@danielgrunwald.de\"/>\n//     <version>$Revision: 2497 $</version>\n// </file>\n\nusing System;\nusing System.Diagnostics;\nusing System.Collections.Generic;\n\nnamespace ICSharpCode.TextEditor.Util\n{\n\tinternal struct RedBlackTreeIterator<T> : IEnumerator<T>\n\t{\n\t\tinternal RedBlackTreeNode<T> node;\n\t\t\n\t\tinternal RedBlackTreeIterator(RedBlackTreeNode<T> node)\n\t\t{\n\t\t\tthis.node = node;\n\t\t}\n\t\t\n\t\tpublic bool IsValid {\n\t\t\tget { return node != null; }\n\t\t}\n\t\t\n\t\tpublic T Current {\n\t\t\tget {\n\t\t\t\tif (node != null)\n\t\t\t\t\treturn node.val;\n\t\t\t\telse\n\t\t\t\t\tthrow new InvalidOperationException();\n\t\t\t}\n\t\t}\n\t\t\n\t\tobject System.Collections.IEnumerator.Current {\n\t\t\tget {\n\t\t\t\treturn this.Current;\n\t\t\t}\n\t\t}\n\t\t\n\t\tvoid IDisposable.Dispose()\n\t\t{\n\t\t}\n\t\t\n\t\tvoid System.Collections.IEnumerator.Reset()\n\t\t{\n\t\t\tthrow new NotSupportedException();\n\t\t}\n\t\t\n\t\tpublic bool MoveNext()\n\t\t{\n\t\t\tif (node == null)\n\t\t\t\treturn false;\n\t\t\tif (node.right != null) {\n\t\t\t\tnode = node.right.LeftMost;\n\t\t\t} else {\n\t\t\t\tRedBlackTreeNode<T> oldNode;\n\t\t\t\tdo {\n\t\t\t\t\toldNode = node;\n\t\t\t\t\tnode = node.parent;\n\t\t\t\t\t// we are on the way up from the right part, don't output node again\n\t\t\t\t} while (node != null && node.right == oldNode);\n\t\t\t}\n\t\t\treturn node != null;\n\t\t}\n\t\t\n\t\tpublic bool MoveBack()\n\t\t{\n\t\t\tif (node == null)\n\t\t\t\treturn false;\n\t\t\tif (node.left != null) {\n\t\t\t\tnode = node.left.RightMost;\n\t\t\t} else {\n\t\t\t\tRedBlackTreeNode<T> oldNode;\n\t\t\t\tdo {\n\t\t\t\t\toldNode = node;\n\t\t\t\t\tnode = node.parent;\n\t\t\t\t\t// we are on the way up from the left part, don't output node again\n\t\t\t\t} while (node != null && node.left == oldNode);\n\t\t\t}\n\t\t\treturn node != null;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Util/RtfWriter.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 1965 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\nusing System.Drawing;\nusing System.Text;\n\nusing ICSharpCode.TextEditor.Document;\n\nnamespace ICSharpCode.TextEditor.Util\n{\n\tpublic class RtfWriter\n\t{\n\t\tstatic Dictionary<string, int> colors;\n\t\tstatic int           colorNum;\n\t\tstatic StringBuilder colorString;\n\t\t\n\t\tpublic static string GenerateRtf(TextArea textArea)\n\t\t{\n\t\t\tcolors = new Dictionary<string, int>();\n\t\t\tcolorNum = 0;\n\t\t\tcolorString = new StringBuilder();\n\t\t\t\n\t\t\t\n\t\t\tStringBuilder rtf = new StringBuilder();\n\t\t\t\n\t\t\trtf.Append(@\"{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1031\");\n\t\t\tBuildFontTable(textArea.Document, rtf);\n\t\t\trtf.Append('\\n');\n\t\t\t\n\t\t\tstring fileContent = BuildFileContent(textArea);\n\t\t\tBuildColorTable(textArea.Document, rtf);\n\t\t\trtf.Append('\\n');\n\t\t\trtf.Append(@\"\\viewkind4\\uc1\\pard\");\n\t\t\trtf.Append(fileContent);\n\t\t\trtf.Append(\"}\");\n\t\t\treturn rtf.ToString();\n\t\t}\n\t\t\n\t\tstatic void BuildColorTable(IDocument doc, StringBuilder rtf)\n\t\t{\n\t\t\trtf.Append(@\"{\\colortbl ;\");\n\t\t\trtf.Append(colorString.ToString());\n\t\t\trtf.Append(\"}\");\n\t\t}\n\t\t\n\t\tstatic void BuildFontTable(IDocument doc, StringBuilder rtf)\n\t\t{\n\t\t\trtf.Append(@\"{\\fonttbl\");\n\t\t\trtf.Append(@\"{\\f0\\fmodern\\fprq1\\fcharset0 \" + doc.TextEditorProperties.Font.Name + \";}\");\n\t\t\trtf.Append(\"}\");\n\t\t}\n\t\t\n\t\tstatic string BuildFileContent(TextArea textArea)\n\t\t{\n\t\t\tStringBuilder rtf = new StringBuilder();\n\t\t\tbool firstLine = true;\n\t\t\tColor curColor = Color.Black;\n\t\t\tbool  oldItalic = false;\n\t\t\tbool  oldBold   = false;\n\t\t\tbool  escapeSequence = false;\n\t\t\t\n\t\t\tforeach (ISelection selection in textArea.SelectionManager.SelectionCollection) {\n\t\t\t\tint selectionOffset    = textArea.Document.PositionToOffset(selection.StartPosition);\n\t\t\t\tint selectionEndOffset = textArea.Document.PositionToOffset(selection.EndPosition);\n\t\t\t\tfor (int i = selection.StartPosition.Y; i <= selection.EndPosition.Y; ++i) {\n\t\t\t\t\tLineSegment line = textArea.Document.GetLineSegment(i);\n\t\t\t\t\tint offset = line.Offset;\n\t\t\t\t\tif (line.Words == null) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tforeach (TextWord word in line.Words) {\n\t\t\t\t\t\tswitch (word.Type) {\n\t\t\t\t\t\t\tcase TextWordType.Space:\n\t\t\t\t\t\t\t\tif (selection.ContainsOffset(offset)) {\n\t\t\t\t\t\t\t\t\trtf.Append(' ');\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t++offset;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tcase TextWordType.Tab:\n\t\t\t\t\t\t\t\tif (selection.ContainsOffset(offset)) {\n\t\t\t\t\t\t\t\t\trtf.Append(@\"\\tab\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t++offset;\n\t\t\t\t\t\t\t\tescapeSequence = true;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tcase TextWordType.Word:\n\t\t\t\t\t\t\t\tColor c = word.Color;\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tif (offset + word.Word.Length > selectionOffset && offset < selectionEndOffset) {\n\t\t\t\t\t\t\t\t\tstring colorstr = c.R + \", \" + c.G + \", \" + c.B;\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tif (!colors.ContainsKey(colorstr)) {\n\t\t\t\t\t\t\t\t\t\tcolors[colorstr] = ++colorNum;\n\t\t\t\t\t\t\t\t\t\tcolorString.Append(@\"\\red\" + c.R + @\"\\green\" + c.G + @\"\\blue\" + c.B + \";\");\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (c != curColor || firstLine) {\n\t\t\t\t\t\t\t\t\t\trtf.Append(@\"\\cf\" + colors[colorstr].ToString());\n\t\t\t\t\t\t\t\t\t\tcurColor = c;\n\t\t\t\t\t\t\t\t\t\tescapeSequence = true;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tif (oldItalic != word.Italic) {\n\t\t\t\t\t\t\t\t\t\tif (word.Italic) {\n\t\t\t\t\t\t\t\t\t\t\trtf.Append(@\"\\i\");\n\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\trtf.Append(@\"\\i0\");\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\toldItalic = word.Italic;\n\t\t\t\t\t\t\t\t\t\tescapeSequence = true;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tif (oldBold != word.Bold) {\n\t\t\t\t\t\t\t\t\t\tif (word.Bold) {\n\t\t\t\t\t\t\t\t\t\t\trtf.Append(@\"\\b\");\n\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\trtf.Append(@\"\\b0\");\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\toldBold = word.Bold;\n\t\t\t\t\t\t\t\t\t\tescapeSequence = true;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tif (firstLine) {\n\t\t\t\t\t\t\t\t\t\trtf.Append(@\"\\f0\\fs\" + (textArea.TextEditorProperties.Font.Size * 2));\n\t\t\t\t\t\t\t\t\t\tfirstLine = false;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (escapeSequence) {\n\t\t\t\t\t\t\t\t\t\trtf.Append(' ');\n\t\t\t\t\t\t\t\t\t\tescapeSequence = false;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tstring printWord;\n\t\t\t\t\t\t\t\t\tif (offset < selectionOffset) {\n\t\t\t\t\t\t\t\t\t\tprintWord = word.Word.Substring(selectionOffset - offset);\n\t\t\t\t\t\t\t\t\t} else if (offset + word.Word.Length > selectionEndOffset) {\n\t\t\t\t\t\t\t\t\t\tprintWord = word.Word.Substring(0, (offset + word.Word.Length) - selectionEndOffset);\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tprintWord = word.Word;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\trtf.Append(printWord.Replace(@\"\\\", @\"\\\\\").Replace(\"{\", \"\\\\{\").Replace(\"}\", \"\\\\}\"));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\toffset += word.Length;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (offset < selectionEndOffset) {\n\t\t\t\t\t\trtf.Append(@\"\\par\");\n\t\t\t\t\t}\n\t\t\t\t\trtf.Append('\\n');\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\treturn rtf.ToString();\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Util/TextUtility.cs",
    "content": "﻿// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Mike Krüger\" email=\"mike@icsharpcode.net\"/>\n//     <version>$Revision: 915 $</version>\n// </file>\n\nusing System;\n\nusing ICSharpCode.TextEditor.Document;\n\nnamespace ICSharpCode.TextEditor.Util\n{\n\tpublic class TextUtility\n\t{\n\t\t\n\t\tpublic static bool RegionMatches(IDocument document, int offset, int length, string word)\n\t\t{\n\t\t\tif (length != word.Length || document.TextLength < offset + length) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\t\n\t\t\tfor (int i = 0; i < length; ++i) {\n\t\t\t\tif (document.GetCharAt(offset + i) != word[i]) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\t\n\t\tpublic static bool RegionMatches(IDocument document, bool casesensitive, int offset, int length, string word)\n\t\t{\n\t\t\tif (casesensitive) {\n\t\t\t\treturn RegionMatches(document, offset, length, word);\n\t\t\t}\n\t\t\t\n\t\t\tif (length != word.Length || document.TextLength < offset + length) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\t\n\t\t\tfor (int i = 0; i < length; ++i) {\n\t\t\t\tif (Char.ToUpper(document.GetCharAt(offset + i)) != Char.ToUpper(word[i])) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\t\n\t\tpublic static bool RegionMatches(IDocument document, int offset, int length, char[] word)\n\t\t{\n\t\t\tif (length != word.Length || document.TextLength < offset + length) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\t\n\t\t\tfor (int i = 0; i < length; ++i) {\n\t\t\t\tif (document.GetCharAt(offset + i) != word[i]) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\t\n\t\tpublic static bool RegionMatches(IDocument document, bool casesensitive, int offset, int length, char[] word)\n\t\t{\n\t\t\tif (casesensitive) {\n\t\t\t\treturn RegionMatches(document, offset, length, word);\n\t\t\t}\n\t\t\t\n\t\t\tif (length != word.Length || document.TextLength < offset + length) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\t\n\t\t\tfor (int i = 0; i < length; ++i) {\n\t\t\t\tif (Char.ToUpper(document.GetCharAt(offset + i)) != Char.ToUpper(word[i])) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Util/TipPainter.cs",
    "content": "// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"none\" email=\"\"/>\n//     <version>$Revision: 2487 $</version>\n// </file>\n\nusing System.Drawing;\nusing System.Drawing.Text;\nusing System.Windows.Forms;\n\nnamespace ICSharpCode.TextEditor.Util\n{\n\tstatic class TipPainter\n\t{\n\t\tconst float HorizontalBorder = 2;\n\t\tconst float VerticalBorder   = 1;\n\t\tstatic RectangleF workingArea = RectangleF.Empty;\n\t\t\n\t\t//static StringFormat centerTipFormat = CreateTipStringFormat();\n\t\t\n\t\tpublic static Size GetTipSize(Control control, Graphics graphics, Font font, string description)\n\t\t{\n\t\t\treturn GetTipSize(control, graphics, new TipText (graphics, font, description));\n\t\t}\n\t\t\n\t\tpublic static Size GetTipSize(Control control, Graphics graphics, TipSection tipData)\n\t\t{\n\t\t\tSize tipSize = Size.Empty;\n\t\t\tSizeF tipSizeF = SizeF.Empty;\n\t\t\t\n\t\t\tif (workingArea == RectangleF.Empty) {\n\t\t\t\tForm ownerForm = control.FindForm();\n\t\t\t\tif (ownerForm.Owner != null) {\n\t\t\t\t\townerForm = ownerForm.Owner;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tworkingArea = Screen.GetWorkingArea(ownerForm);\n\t\t\t}\n\t\t\t\n\t\t\tPointF screenLocation = control.PointToScreen(Point.Empty);\n\t\t\t\n\t\t\tSizeF maxLayoutSize = new SizeF(workingArea.Right - screenLocation.X - HorizontalBorder * 2,\n\t\t\t                                workingArea.Bottom - screenLocation.Y - VerticalBorder * 2);\n\t\t\t\n\t\t\tif (maxLayoutSize.Width > 0 && maxLayoutSize.Height > 0) {\n\t\t\t\tgraphics.TextRenderingHint =\n\t\t\t\tTextRenderingHint.AntiAliasGridFit;\n\t\t\t\t\n\t\t\t\ttipData.SetMaximumSize(maxLayoutSize);\n\t\t\t\ttipSizeF = tipData.GetRequiredSize();\n\t\t\t\ttipData.SetAllocatedSize(tipSizeF);\n\t\t\t\t\n\t\t\t\ttipSizeF += new SizeF(HorizontalBorder * 2,\n\t\t\t\t                      VerticalBorder   * 2);\n\t\t\t\ttipSize = Size.Ceiling(tipSizeF);\n\t\t\t}\n\t\t\t\n\t\t\tif (control.ClientSize != tipSize) {\n\t\t\t\tcontrol.ClientSize = tipSize;\n\t\t\t}\n\t\t\t\n\t\t\treturn tipSize;\n\t\t}\n\t\t\n\t\tpublic static Size DrawTip(Control control, Graphics graphics, Font font, string description)\n\t\t{\n\t\t\treturn DrawTip(control, graphics, new TipText (graphics, font, description));\n\t\t}\n\t\t\n\t\tpublic static Size DrawTip(Control control, Graphics graphics, TipSection tipData)\n\t\t{\n\t\t\tSize tipSize = Size.Empty;\n\t\t\tSizeF tipSizeF = SizeF.Empty;\n\t\t\t\n\t\t\tPointF screenLocation = control.PointToScreen(Point.Empty);\n\t\t\t\n\t\t\tif (workingArea == RectangleF.Empty) {\n\t\t\t\tForm ownerForm = control.FindForm();\n\t\t\t\tif (ownerForm.Owner != null) {\n\t\t\t\t\townerForm = ownerForm.Owner;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tworkingArea = Screen.GetWorkingArea(ownerForm);\n\t\t\t}\n\t\n\t\t\tSizeF maxLayoutSize = new SizeF(workingArea.Right - screenLocation.X - HorizontalBorder * 2,\n\t\t\t                                workingArea.Bottom - screenLocation.Y - VerticalBorder * 2);\n\t\t\t\n\t\t\tif (maxLayoutSize.Width > 0 && maxLayoutSize.Height > 0) {\n\t\t\t\tgraphics.TextRenderingHint =\n\t\t\t\tTextRenderingHint.AntiAliasGridFit;\n\t\t\t\t\n\t\t\t\ttipData.SetMaximumSize(maxLayoutSize);\n\t\t\t\ttipSizeF = tipData.GetRequiredSize();\n\t\t\t\ttipData.SetAllocatedSize(tipSizeF);\n\t\t\t\t\n\t\t\t\ttipSizeF += new SizeF(HorizontalBorder * 2,\n\t\t\t\t                      VerticalBorder   * 2);\n\t\t\t\ttipSize = Size.Ceiling(tipSizeF);\n\t\t\t}\n\t\t\t\n\t\t\tif (control.ClientSize != tipSize) {\n\t\t\t\tcontrol.ClientSize = tipSize;\n\t\t\t}\n\t\t\t\n\t\t\tif (tipSize != Size.Empty) {\n\t\t\t\tRectangle borderRectangle = new Rectangle\n\t\t\t\t(Point.Empty, tipSize - new Size(1, 1));\n\t\t\t\t\n\t\t\t\tRectangleF displayRectangle = new RectangleF\n\t\t\t\t(HorizontalBorder, VerticalBorder,\n\t\t\t\t tipSizeF.Width - HorizontalBorder * 2,\n\t\t\t\t tipSizeF.Height - VerticalBorder * 2);\n\t\t\t\t\n\t\t\t\t// DrawRectangle draws from Left to Left + Width. A bug? :-/\n\t\t\t\tgraphics.DrawRectangle(SystemPens.WindowFrame,\n\t\t\t\t                       borderRectangle);\n\t\t\t\ttipData.Draw(new PointF(HorizontalBorder, VerticalBorder));\n\t\t\t}\n\t\t\treturn tipSize;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Util/TipPainterTools.cs",
    "content": "// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"none\" email=\"\"/>\n//     <version>$Revision: 915 $</version>\n// </file>\n\nusing System;\nusing System.Drawing;\nusing System.Windows.Forms;\n\nnamespace ICSharpCode.TextEditor.Util\n{\n\tclass TipPainterTools\n\t{\n\t\tconst int SpacerSize = 4;\n\t\t\n\t\tprivate TipPainterTools()\n\t\t{\n\t\t\t\n\t\t}\n\t\tpublic static Size GetDrawingSizeHelpTipFromCombinedDescription(Control control,\n\t\t                                                      Graphics graphics,\n\t\t                                                      Font font,\n\t\t                                                      string countMessage,\n\t\t                                                      string description)\n\t\t{\n\t\t\tstring basicDescription = null;\n\t\t\tstring documentation = null;\n\n\t\t\tif (IsVisibleText(description)) {\n\t     \t\tstring[] splitDescription = description.Split(new char[] { '\\n' }, 2);\n\t\t\t\t\t\t\n\t\t\t\tif (splitDescription.Length > 0) {\n\t\t\t\t\tbasicDescription = splitDescription[0];\n\t\t\t\t\t\n\t\t\t\t\tif (splitDescription.Length > 1) {\n\t\t\t\t\t\tdocumentation = splitDescription[1].Trim();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\treturn GetDrawingSizeDrawHelpTip(control, graphics, font, countMessage, basicDescription, documentation);\n\t\t}\n\t\t\n\t\tpublic static Size DrawHelpTipFromCombinedDescription(Control control,\n\t\t                                                      Graphics graphics,\n\t\t                                                      Font font,\n\t\t                                                      string countMessage,\n\t\t                                                      string description)\n\t\t{\n\t\t\tstring basicDescription = null;\n\t\t\tstring documentation = null;\n\n\t\t\tif (IsVisibleText(description)) {\n\t     \t\tstring[] splitDescription = description.Split\n\t     \t\t\t(new char[] { '\\n' }, 2);\n\t\t\t\t\t\t\n\t\t\t\tif (splitDescription.Length > 0) {\n\t\t\t\t\tbasicDescription = splitDescription[0];\n\t\t\t\t\t\n\t\t\t\t\tif (splitDescription.Length > 1) {\n\t\t\t\t\t\tdocumentation = splitDescription[1].Trim();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\treturn DrawHelpTip(control, graphics, font, countMessage,\n\t\t\t            basicDescription, documentation);\n \t\t}\n\t\t\n\t\t// btw. I know it's ugly.\n\t\tpublic static Rectangle DrawingRectangle1;\n\t\tpublic static Rectangle DrawingRectangle2;\n\t\t\n\t\tpublic static Size GetDrawingSizeDrawHelpTip(Control control,\n\t\t                               Graphics graphics, Font font,\n\t\t                               string countMessage,\n\t\t                               string basicDescription,\n\t\t                               string documentation)\n\t\t{\n\t\t\tif (IsVisibleText(countMessage)     ||\n\t\t\t    IsVisibleText(basicDescription) ||\n\t\t\t    IsVisibleText(documentation)) {\n\t\t\t\t// Create all the TipSection objects.\n\t\t\t\tCountTipText countMessageTip = new CountTipText(graphics, font, countMessage);\n\t\t\t\t\n\t\t\t\tTipSpacer countSpacer = new TipSpacer(graphics, new SizeF(IsVisibleText(countMessage) ? 4 : 0, 0));\n\t\t\t\t\n\t\t\t\tTipText descriptionTip = new TipText(graphics, font, basicDescription);\n\t\t\t\t\n\t\t\t\tTipSpacer docSpacer = new TipSpacer(graphics, new SizeF(0, IsVisibleText(documentation) ? 4 : 0));\n\t\t\t\t\n\t\t\t\tTipText docTip = new TipText(graphics, font, documentation);\n\t\t\t\t\n\t\t\t\t// Now put them together.\n\t\t\t\tTipSplitter descSplitter = new TipSplitter(graphics, false,\n\t\t\t\t                                           descriptionTip,\n\t\t\t\t                                           docSpacer\n\t\t\t\t                                           );\n\t\t\t\t\n\t\t\t\tTipSplitter mainSplitter = new TipSplitter(graphics, true,\n\t\t\t\t                                           countMessageTip,\n\t\t\t\t                                           countSpacer,\n\t\t\t\t                                           descSplitter);\n\t\t\t\t\n\t\t\t\tTipSplitter mainSplitter2 = new TipSplitter(graphics, false,\n\t\t\t\t                                           mainSplitter,\n\t\t\t\t                                           docTip);\n\t\t\t\t\n\t\t\t\t// Show it.\n\t\t\t\tSize size = TipPainter.GetTipSize(control, graphics, mainSplitter2);\n\t\t\t\tDrawingRectangle1 = countMessageTip.DrawingRectangle1;\n\t\t\t\tDrawingRectangle2 = countMessageTip.DrawingRectangle2;\n\t\t\t\treturn size;\n\t\t\t}\n\t\t\treturn Size.Empty;\n\t\t}\n\t\tpublic static Size DrawHelpTip(Control control,\n\t\t                               Graphics graphics, Font font,\n\t\t                               string countMessage,\n\t\t                               string basicDescription,\n\t\t                               string documentation)\n\t\t{\n\t\t\tif (IsVisibleText(countMessage)     ||\n\t\t\t    IsVisibleText(basicDescription) ||\n\t\t\t    IsVisibleText(documentation)) {\n\t\t\t\t// Create all the TipSection objects.\n\t\t\t\tCountTipText countMessageTip = new CountTipText(graphics, font, countMessage);\n\t\t\t\t\n\t\t\t\tTipSpacer countSpacer = new TipSpacer(graphics, new SizeF(IsVisibleText(countMessage) ? 4 : 0, 0));\n\t\t\t\t\n\t\t\t\tTipText descriptionTip = new TipText(graphics, font, basicDescription);\n\t\t\t\t\n\t\t\t\tTipSpacer docSpacer = new TipSpacer(graphics, new SizeF(0, IsVisibleText(documentation) ? 4 : 0));\n\t\t\t\t\n\t\t\t\tTipText docTip = new TipText(graphics, font, documentation);\n\t\t\t\t\n\t\t\t\t// Now put them together.\n\t\t\t\tTipSplitter descSplitter = new TipSplitter(graphics, false,\n\t\t\t\t                                           descriptionTip,\n\t\t\t\t                                           docSpacer\n\t\t\t\t                                           );\n\t\t\t\t\n\t\t\t\tTipSplitter mainSplitter = new TipSplitter(graphics, true,\n\t\t\t\t                                           countMessageTip,\n\t\t\t\t                                           countSpacer,\n\t\t\t\t                                           descSplitter);\n\t\t\t\t\n\t\t\t\tTipSplitter mainSplitter2 = new TipSplitter(graphics, false,\n\t\t\t\t                                           mainSplitter,\n\t\t\t\t                                           docTip);\n\t\t\t\t\n\t\t\t\t// Show it.\n\t\t\t\tSize size = TipPainter.DrawTip(control, graphics, mainSplitter2);\n\t\t\t\tDrawingRectangle1 = countMessageTip.DrawingRectangle1;\n\t\t\t\tDrawingRectangle2 = countMessageTip.DrawingRectangle2;\n\t\t\t\treturn size;\n\t\t\t}\n\t\t\treturn Size.Empty;\n\t\t}\n\t\t\n\t\tstatic bool IsVisibleText(string text)\n\t\t{\n\t\t\treturn text != null && text.Length > 0;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Util/TipSection.cs",
    "content": "// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"none\" email=\"\"/>\n//     <version>$Revision: 915 $</version>\n// </file>\n\nusing System;\nusing System.Diagnostics;\nusing System.Drawing;\n\nnamespace ICSharpCode.TextEditor.Util\n{\n\tabstract class TipSection\n\t{\n\t\tSizeF    tipAllocatedSize;\n\t\tGraphics tipGraphics;\n\t\tSizeF    tipMaxSize;\n\t\tSizeF    tipRequiredSize;\n\t\t\n\t\tprotected TipSection(Graphics graphics)\n\t\t{\n\t\t\ttipGraphics = graphics;\n\t\t}\n\t\t\n\t\tpublic abstract void Draw(PointF location);\n\t\t\n\t\tpublic SizeF GetRequiredSize()\n\t\t{\n\t\t\treturn tipRequiredSize;\n\t\t}\n\t\t\n\t\tpublic void SetAllocatedSize(SizeF allocatedSize)\n\t\t{\n\t\t\tDebug.Assert(allocatedSize.Width >= tipRequiredSize.Width &&\n\t\t\t             allocatedSize.Height >= tipRequiredSize.Height);\n\t\t\t\n\t\t\ttipAllocatedSize = allocatedSize; OnAllocatedSizeChanged();\n\t\t}\n\t\t\n\t\tpublic void SetMaximumSize(SizeF maximumSize)\n\t\t{\n\t\t\ttipMaxSize = maximumSize; OnMaximumSizeChanged();\n\t\t}\n\t\t\n\t\tprotected virtual void OnAllocatedSizeChanged()\n\t\t{\n\t\t\t\n\t\t}\n\t\t\n\t\tprotected virtual void OnMaximumSizeChanged()\n\t\t{\n\t\t\t\n\t\t}\n\t\t\n\t\tprotected void SetRequiredSize(SizeF requiredSize)\n\t\t{\n\t\t\trequiredSize.Width  = Math.Max(0, requiredSize.Width);\n\t\t\trequiredSize.Height = Math.Max(0, requiredSize.Height);\n\t\t\trequiredSize.Width  = Math.Min(tipMaxSize.Width, requiredSize.Width);\n\t\t\trequiredSize.Height = Math.Min(tipMaxSize.Height, requiredSize.Height);\n\t\t\t\n\t\t\ttipRequiredSize = requiredSize;\n\t\t}\n\t\t\n\t\tprotected Graphics Graphics\t{\n\t\t\tget {\n\t\t\t\treturn tipGraphics;\n\t\t\t}\n\t\t}\n\t\t\n\t\tprotected SizeF AllocatedSize {\n\t\t\tget {\n\t\t\t\treturn tipAllocatedSize;\n\t\t\t}\n\t\t}\n\t\t\n\t\tprotected SizeF MaximumSize {\n\t\t\tget {\n\t\t\t\treturn tipMaxSize;\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Util/TipSpacer.cs",
    "content": "// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"none\" email=\"\"/>\n//     <version>$Revision: 915 $</version>\n// </file>\n\nusing System;\nusing System.Drawing;\n\nnamespace ICSharpCode.TextEditor.Util\n{\n\tclass TipSpacer: TipSection\n\t{\n\t\tSizeF spacerSize;\n\t\t\n\t\tpublic TipSpacer(Graphics graphics, SizeF size): base(graphics)\n\t\t{\n\t\t\tspacerSize = size;\n\t\t}\n\t\t\n\t\tpublic override void Draw(PointF location)\n\t\t{\n\t\t\t\n\t\t}\n\t\t\n\t\tprotected override void OnMaximumSizeChanged()\n\t\t{\n\t\t\tbase.OnMaximumSizeChanged();\n\t\t\t\n\t\t\tSetRequiredSize(new SizeF\n\t\t\t                (Math.Min(MaximumSize.Width, spacerSize.Width),\n\t\t\t                Math.Min(MaximumSize.Height, spacerSize.Height)));\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Util/TipSplitter.cs",
    "content": "// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"none\" email=\"\"/>\n//     <version>$Revision: 915 $</version>\n// </file>\n\nusing System;\nusing System.Diagnostics;\nusing System.Drawing;\n\nnamespace ICSharpCode.TextEditor.Util\n{\n\tclass TipSplitter: TipSection\n\t{\n\t\tbool         isHorizontal;\n\t\tfloat     [] offsets;\n\t\tTipSection[] tipSections;\n\t\t\n\t\tpublic TipSplitter(Graphics graphics, bool horizontal, params TipSection[] sections): base(graphics)\n\t\t{\n\t\t\tDebug.Assert(sections != null);\n\t\t\t\n\t\t\tisHorizontal = horizontal;\n\t\t\toffsets = new float[sections.Length];\n\t\t\ttipSections = (TipSection[])sections.Clone();\t\n\t\t}\n\t\t\n\t\tpublic override void Draw(PointF location)\n\t\t{\n\t\t\tif (isHorizontal) {\n\t\t\t\tfor (int i = 0; i < tipSections.Length; i ++) {\n\t\t\t\t\ttipSections[i].Draw\n\t\t\t\t\t\t(new PointF(location.X + offsets[i], location.Y));\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor (int i = 0; i < tipSections.Length; i ++) {\n\t\t\t\t\ttipSections[i].Draw\n\t\t\t\t\t\t(new PointF(location.X, location.Y + offsets[i]));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tprotected override void OnMaximumSizeChanged()\n\t\t{\n\t\t\tbase.OnMaximumSizeChanged();\n\t\t\t\n\t\t\tfloat currentDim = 0;\n\t\t\tfloat otherDim = 0;\n\t\t\tSizeF availableArea = MaximumSize;\n\t\t\t\n\t\t\tfor (int i = 0; i < tipSections.Length; i ++) {\n\t\t\t\tTipSection section = (TipSection)tipSections[i];\n\t\t\t\n\t\t\t\tsection.SetMaximumSize(availableArea);\n\t\t\t\t\n\t\t\t\tSizeF requiredArea = section.GetRequiredSize();\n\t\t\t\toffsets[i] = currentDim;\n\n\t\t\t\t// It's best to start on pixel borders, so this will\n\t\t\t\t// round up to the nearest pixel. Otherwise there are\n\t\t\t\t// weird cutoff artifacts.\n\t\t\t\tfloat pixelsUsed;\n\t\t\t\t\n\t\t\t\tif (isHorizontal) {\n\t\t\t\t\tpixelsUsed  = (float)Math.Ceiling(requiredArea.Width);\n\t\t\t\t\tcurrentDim += pixelsUsed;\n\t\t\t\t\t\n\t\t\t\t\tavailableArea.Width = Math.Max\n\t\t\t\t\t\t(0, availableArea.Width - pixelsUsed);\n\t\t\t\t\t\n\t\t\t\t\totherDim = Math.Max(otherDim, requiredArea.Height);\n\t\t\t\t} else {\n\t\t\t\t\tpixelsUsed  = (float)Math.Ceiling(requiredArea.Height);\n\t\t\t\t\tcurrentDim += pixelsUsed;\n\t\t\t\t\t\n\t\t\t\t\tavailableArea.Height = Math.Max\n\t\t\t\t\t\t(0, availableArea.Height - pixelsUsed);\n\t\t\t\t\t\n\t\t\t\t\totherDim = Math.Max(otherDim, requiredArea.Width);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tforeach (TipSection section in tipSections) {\n\t\t\t\tif (isHorizontal) {\n\t\t\t\t\tsection.SetAllocatedSize(new SizeF(section.GetRequiredSize().Width, otherDim));\n\t\t\t\t} else {\n\t\t\t\t\tsection.SetAllocatedSize(new SizeF(otherDim, section.GetRequiredSize().Height));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (isHorizontal) {\n\t\t\t\tSetRequiredSize(new SizeF(currentDim, otherDim));\n\t\t\t} else {\n\t\t\t\tSetRequiredSize(new SizeF(otherDim, currentDim));\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Util/TipText.cs",
    "content": "// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"none\" email=\"\"/>\n//     <version>$Revision: 2561 $</version>\n// </file>\n\nusing System;\nusing System.Drawing;\n\nnamespace ICSharpCode.TextEditor.Util\n{\n\tclass CountTipText: TipText\n\t{\n\t\tfloat triHeight = 10;\n\t\tfloat triWidth  = 10;\n\t\t\n\t\tpublic CountTipText(Graphics graphics, Font font, string text) : base(graphics, font, text)\n\t\t{\n\t\t}\n\t\t\n\t\tvoid DrawTriangle(float x, float y, bool flipped)\n\t\t{\n\t\t\tBrush brush = BrushRegistry.GetBrush(Color.FromArgb(192, 192, 192));\n\t\t\tbase.Graphics.FillRectangle(brush, new RectangleF(x, y, triHeight, triHeight));\n\t\t\tfloat triHeight2 = triHeight / 2;\n\t\t\tfloat triHeight4 = triHeight / 4;\n\t\t\tbrush = Brushes.Black;\n\t\t\tif (flipped) {\n\t\t\t\tbase.Graphics.FillPolygon(brush, new PointF[] {\n\t\t\t\t                          \tnew PointF(x,                y + triHeight2 - triHeight4),\n\t\t\t\t                          \tnew PointF(x + triWidth / 2, y + triHeight2 + triHeight4),\n\t\t\t\t                          \tnew PointF(x + triWidth,     y + triHeight2 - triHeight4),\n\t\t\t\t                          });\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\tbase.Graphics.FillPolygon(brush, new PointF[] {\n\t\t\t\t                          \tnew PointF(x,                y +  triHeight2 + triHeight4),\n\t\t\t\t                          \tnew PointF(x + triWidth / 2, y +  triHeight2 - triHeight4),\n\t\t\t\t                          \tnew PointF(x + triWidth,     y +  triHeight2 + triHeight4),\n\t\t\t\t                          });\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic Rectangle DrawingRectangle1;\n\t\tpublic Rectangle DrawingRectangle2;\n\t\t\n\t\tpublic override void Draw(PointF location)\n\t\t{\n\t\t\tif (tipText != null && tipText.Length > 0) {\n\t\t\t\tbase.Draw(new PointF(location.X + triWidth + 4, location.Y));\n\t\t\t\tDrawingRectangle1 = new Rectangle((int)location.X + 2,\n\t\t\t\t                                  (int)location.Y + 2,\n\t\t\t\t                                  (int)(triWidth),\n\t\t\t\t                                  (int)(triHeight));\n\t\t\t\tDrawingRectangle2 = new Rectangle((int)(location.X + base.AllocatedSize.Width - triWidth  - 2),\n\t\t\t\t                                  (int)location.Y + 2,\n\t\t\t\t                                  (int)(triWidth),\n\t\t\t\t                                  (int)(triHeight));\n\t\t\t\tDrawTriangle(location.X + 2, location.Y + 2, false);\n\t\t\t\tDrawTriangle(location.X + base.AllocatedSize.Width - triWidth  - 2, location.Y + 2, true);\n\t\t\t}\n\t\t}\n\t\t\n\t\tprotected override void OnMaximumSizeChanged()\n\t\t{\n\t\t\tif (IsTextVisible()) {\n\t\t\t\tSizeF tipSize = Graphics.MeasureString\n\t\t\t\t\t(tipText, tipFont, MaximumSize,\n\t\t\t\t\t GetInternalStringFormat());\n\t\t\t\ttipSize.Width += triWidth * 2 + 8;\n\t\t\t\tSetRequiredSize(tipSize);\n\t\t\t} else {\n\t\t\t\tSetRequiredSize(SizeF.Empty);\n\t\t\t}\n\t\t}\n\t\t\n\t}\n\t\n\tclass TipText: TipSection\n\t{\n\t\tprotected StringAlignment horzAlign;\n\t\tprotected StringAlignment vertAlign;\n\t\tprotected Color           tipColor;\n\t\tprotected Font            tipFont;\n\t\tprotected StringFormat    tipFormat;\n\t\tprotected string          tipText;\n\t\t\n\t\tpublic TipText(Graphics graphics, Font font, string text):\n\t\t\tbase(graphics)\n\t\t{\n\t\t\ttipFont = font; tipText = text;\n\t\t\tif (text != null && text.Length > short.MaxValue)\n\t\t\t\tthrow new ArgumentException(\"TipText: text too long (max. is \" + short.MaxValue + \" characters)\", \"text\");\n\t\t\t\n\t\t\tColor               = SystemColors.InfoText;\n\t\t\tHorizontalAlignment = StringAlignment.Near;\n\t\t\tVerticalAlignment   = StringAlignment.Near;\n\t\t}\n\t\t\n\t\tpublic override void Draw(PointF location)\n\t\t{\n\t\t\tif (IsTextVisible()) {\n\t\t\t\tRectangleF drawRectangle = new RectangleF(location, AllocatedSize);\n\t\t\t\t\n\t\t\t\tGraphics.DrawString(tipText, tipFont,\n\t\t\t\t                    BrushRegistry.GetBrush(Color),\n\t\t\t\t                    drawRectangle,\n\t\t\t\t                    GetInternalStringFormat());\n\t\t\t}\n\t\t}\n\t\t\n\t\tprotected StringFormat GetInternalStringFormat()\n\t\t{\n\t\t\tif (tipFormat == null) {\n\t\t\t\ttipFormat = CreateTipStringFormat(horzAlign, vertAlign);\n\t\t\t}\n\t\t\t\n\t\t\treturn tipFormat;\n\t\t}\n\t\t\n\t\tprotected override void OnMaximumSizeChanged()\n\t\t{\n\t\t\tbase.OnMaximumSizeChanged();\n\t\t\t\n\t\t\tif (IsTextVisible()) {\n\t\t\t\tSizeF tipSize = Graphics.MeasureString\n\t\t\t\t\t(tipText, tipFont, MaximumSize,\n\t\t\t\t\t GetInternalStringFormat());\n\t\t\t\t\n\t\t\t\tSetRequiredSize(tipSize);\n\t\t\t} else {\n\t\t\t\tSetRequiredSize(SizeF.Empty);\n\t\t\t}\n\t\t}\n\t\t\n\t\tstatic StringFormat CreateTipStringFormat(StringAlignment horizontalAlignment, StringAlignment verticalAlignment)\n\t\t{\n\t\t\tStringFormat format = (StringFormat)StringFormat.GenericTypographic.Clone();\n\t\t\tformat.FormatFlags = StringFormatFlags.FitBlackBox | StringFormatFlags.MeasureTrailingSpaces;\n\t\t\t// note: Align Near, Line Center seemed to do something before\n\t\t\t\n\t\t\tformat.Alignment     = horizontalAlignment;\n\t\t\tformat.LineAlignment = verticalAlignment;\n\t\t\t\n\t\t\treturn format;\n\t\t}\n\t\t\n\t\tprotected bool IsTextVisible()\n\t\t{\n\t\t\treturn tipText != null && tipText.Length > 0;\n\t\t}\n\t\t\n\t\tpublic Color Color {\n\t\t\tget {\n\t\t\t\treturn tipColor;\n\t\t\t}\n\t\t\tset {\n\t\t\t\ttipColor = value;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic StringAlignment HorizontalAlignment {\n\t\t\tget {\n\t\t\t\treturn horzAlign;\n\t\t\t}\n\t\t\tset {\n\t\t\t\thorzAlign = value;\n\t\t\t\ttipFormat = null;\n\t\t\t}\n\t\t}\n\t\t\n\t\tpublic StringAlignment VerticalAlignment {\n\t\t\tget {\n\t\t\t\treturn vertAlign;\n\t\t\t}\n\t\t\tset {\n\t\t\t\tvertAlign = value;\n\t\t\t\ttipFormat = null;\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/ICSharpCode.TextEditor/Project/Src/Util/WeakCollection.cs",
    "content": "// <file>\n//     <copyright see=\"prj:///doc/copyright.txt\"/>\n//     <license see=\"prj:///doc/license.txt\"/>\n//     <owner name=\"Daniel Grunwald\" email=\"daniel@danielgrunwald.de\"/>\n//     <version>$Revision: 2683 $</version>\n// </file>\n\nusing System;\nusing System.Collections.Generic;\n\nnamespace ICSharpCode.TextEditor.Util\n{\n\t/// <summary>\n\t/// A collection that does not allows its elements to be garbage-collected (unless there are other\n\t/// references to the elements). Elements will disappear from the collection when they are\n\t/// garbage-collected.\n\t/// \n\t/// The WeakCollection is not thread-safe, not even for read-only access!\n\t/// No methods may be called on the WeakCollection while it is enumerated, not even a Contains or\n\t/// creating a second enumerator.\n\t/// The WeakCollection does not preserve any order among its contents; the ordering may be different each\n\t/// time the collection is enumerated.\n\t/// \n\t/// Since items may disappear at any time when they are garbage collected, this class\n\t/// cannot provide a useful implementation for Count and thus cannot implement the ICollection interface.\n\t/// </summary>\n\tpublic class WeakCollection<T> : IEnumerable<T> where T : class\n\t{\n\t\treadonly List<WeakReference> innerList = new List<WeakReference>();\n\t\t\n\t\t/// <summary>\n\t\t/// Adds an element to the collection. Runtime: O(n).\n\t\t/// </summary>\n\t\tpublic void Add(T item)\n\t\t{\n\t\t\tif (item == null)\n\t\t\t\tthrow new ArgumentNullException(\"item\");\n\t\t\tCheckNoEnumerator();\n\t\t\tif (innerList.Count == innerList.Capacity || (innerList.Count % 32) == 31)\n\t\t\t\tinnerList.RemoveAll(delegate(WeakReference r) { return !r.IsAlive; });\n\t\t\tinnerList.Add(new WeakReference(item));\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Removes all elements from the collection. Runtime: O(n).\n\t\t/// </summary>\n\t\tpublic void Clear()\n\t\t{\n\t\t\tinnerList.Clear();\n\t\t\tCheckNoEnumerator();\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Checks if the collection contains an item. Runtime: O(n).\n\t\t/// </summary>\n\t\tpublic bool Contains(T item)\n\t\t{\n\t\t\tif (item == null)\n\t\t\t\tthrow new ArgumentNullException(\"item\");\n\t\t\tCheckNoEnumerator();\n\t\t\tforeach (T element in this) {\n\t\t\t\tif (item.Equals(element))\n\t\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Removes an element from the collection. Returns true if the item is found and removed,\n\t\t/// false when the item is not found.\n\t\t/// Runtime: O(n).\n\t\t/// </summary>\n\t\tpublic bool Remove(T item)\n\t\t{\n\t\t\tif (item == null)\n\t\t\t\tthrow new ArgumentNullException(\"item\");\n\t\t\tCheckNoEnumerator();\n\t\t\tfor (int i = 0; i < innerList.Count;) {\n\t\t\t\tT element = (T)innerList[i].Target;\n\t\t\t\tif (element == null) {\n\t\t\t\t\tRemoveAt(i);\n\t\t\t\t} else if (element == item) {\n\t\t\t\t\tRemoveAt(i);\n\t\t\t\t\treturn true;\n\t\t\t\t} else {\n\t\t\t\t\ti++;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\tvoid RemoveAt(int i)\n\t\t{\n\t\t\tint lastIndex = innerList.Count - 1;\n\t\t\tinnerList[i] = innerList[lastIndex];\n\t\t\tinnerList.RemoveAt(lastIndex);\n\t\t}\n\t\t\n\t\tbool hasEnumerator;\n\t\t\n\t\tvoid CheckNoEnumerator()\n\t\t{\n\t\t\tif (hasEnumerator)\n\t\t\t\tthrow new InvalidOperationException(\"The WeakCollection is already being enumerated, it cannot be modified at the same time. Ensure you dispose the first enumerator before modifying the WeakCollection.\");\n\t\t}\n\t\t\n\t\t/// <summary>\n\t\t/// Enumerates the collection.\n\t\t/// Each MoveNext() call on the enumerator is O(1), thus the enumeration is O(n).\n\t\t/// </summary>\n\t\tpublic IEnumerator<T> GetEnumerator()\n\t\t{\n\t\t\tif (hasEnumerator)\n\t\t\t\tthrow new InvalidOperationException(\"The WeakCollection is already being enumerated, it cannot be enumerated twice at the same time. Ensure you dispose the first enumerator before using another enumerator.\");\n\t\t\ttry {\n\t\t\t\thasEnumerator = true;\n\t\t\t\tfor (int i = 0; i < innerList.Count;) {\n\t\t\t\t\tT element = (T)innerList[i].Target;\n\t\t\t\t\tif (element == null) {\n\t\t\t\t\t\tRemoveAt(i);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tyield return element;\n\t\t\t\t\t\ti++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\thasEnumerator = false;\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()\n\t\t{\n\t\t\treturn GetEnumerator();\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/IIncludeHandler.cs",
    "content": "﻿using System;\n\nnamespace Pyramid\n{\n    public interface IIncludeResult\n    {\n        byte[] Contents { get; }\n        string FullPath { get; }\n    }\n\n    public enum IncludeType\n    {\n        System,\n        User,\n    }\n\n    public interface IIncludeHandler\n    {\n        IIncludeResult OpenInclude(IncludeType eType, string targetPath, string includerPath );\n    }\n}\n"
  },
  {
    "path": "src/IWrapper.cs",
    "content": "﻿using System;\n\nnamespace Pyramid\n{\n  \n   \n    public interface IWrapper\n    {\n        /// <summary>\n        ///  Construct a D3DCompiler by dynamically loading a given D3DCompiler DLL\n        ///   Throws if the DLL could not be loaded properly\n        /// </summary>\n        /// <param name=\"DLLPath\"></param>\n        /// <returns></returns>\n        ID3DCompiler CreateD3DCompiler(string DLLPath, IIncludeHandler handler );\n\n        IDXILCompiler CreateDXILCompiler(string DLLPath, IIncludeHandler handler);\n\n        /// <summary>\n        ///  Construct an instance of the GLSL Optimizer\n        /// </summary>\n        /// <returns></returns>\n        GLSLOptimizer.IOptimizer CreateGLSLOptimizer( GLSLOptimizer.Target eTarget );\n\n        GLSlang.ICompiler CreateGLSlangCompiler( IIncludeHandler handler );\n\n        IAMDDriver CreateAMDDriver( string DLLPath );\n\n    }\n}\n"
  },
  {
    "path": "src/IncludeHandler.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.IO;\n\nnamespace Pyramid\n{\n    class IncludeResult : IIncludeResult\n    {\n        public IncludeResult( string path )\n        {\n            FullPath = path;\n            Contents = File.ReadAllBytes(path);\n        }\n        public byte[] Contents { get; private set; }\n        public string FullPath { get; private set; }\n    }\n\n    class IncludeHandler : IIncludeHandler\n    {\n        private List<string> m_SearchDirs = new List<string>();\n\n        public IncludeHandler( IEnumerable<string> IncludePaths )\n        {\n            if (IncludePaths != null)\n                m_SearchDirs.AddRange(IncludePaths);\n        }\n\n        IIncludeResult DoPath(string searchPath, string includePath )\n        {\n            string relPath = Path.GetFullPath(Path.Combine(searchPath, includePath));\n            if( File.Exists(relPath))\n            {\n                return new IncludeResult(relPath);\n            }\n            return null;\n        }\n\n        public IIncludeResult OpenInclude(IncludeType eType, string path, string includerPath)\n        {\n            if (!String.IsNullOrEmpty(includerPath))\n            {\n                string fileDir = Path.GetDirectoryName(includerPath);\n                IIncludeResult r = DoPath(fileDir, path);\n                if (r != null)\n                    return r;\n            }\n\n            foreach( string s in m_SearchDirs )\n            {\n                if( Directory.Exists(s))\n                {\n                    IIncludeResult r = DoPath(s, path);\n                    if (r != null)\n                        return r;\n                }\n            }\n\n            return null;\n        }\n    }\n}\n"
  },
  {
    "path": "src/LanguageTypes.cs",
    "content": "﻿namespace Pyramid\n{\n    public enum Languages\n    {\n        HLSL,\n        GLSL,\n    };\n\n    public interface ICompileOptions\n    {\n        Languages Language { get; }\n    }\n\n    public interface IShader\n    {\n        Languages Language { get; }\n        string Code { get; }\n\n        /// <summary>\n        ///  Full path to source file, if we have one. \n        ///  May be empty if text was typed into editor and not saved\n        /// </summary>\n        string SourceFilePath { get; }\n    };\n}\n"
  },
  {
    "path": "src/Languages/GLSLLanguage.cs",
    "content": "﻿\nnamespace Pyramid\n{\n   \n\n\n    public class GLSLLanguage : ILanguage\n    {\n        private GLSLOptionsPanel m_Options = new GLSLOptionsPanel();\n        public ICompileOptionsPanel OptionsPanel { get { return m_Options; } }\n        public string Name {  get {return \"GLSL\";} }\n    }\n\n\n}"
  },
  {
    "path": "src/Languages/GLSLOptionsPanel.Designer.cs",
    "content": "﻿namespace Pyramid\n{\n    partial class GLSLOptionsPanel\n    {\n        /// <summary> \n        /// Required designer variable.\n        /// </summary>\n        private System.ComponentModel.IContainer components = null;\n\n        /// <summary> \n        /// Clean up any resources being used.\n        /// </summary>\n        /// <param name=\"disposing\">true if managed resources should be disposed; otherwise, false.</param>\n        protected override void Dispose(bool disposing)\n        {\n            if (disposing && (components != null))\n            {\n                components.Dispose();\n            }\n            base.Dispose(disposing);\n        }\n\n        #region Component Designer generated code\n\n        /// <summary> \n        /// Required method for Designer support - do not modify \n        /// the contents of this method with the code editor.\n        /// </summary>\n        private void InitializeComponent()\n        {\n            this.label1 = new System.Windows.Forms.Label();\n            this.cmbShaderType = new System.Windows.Forms.ComboBox();\n            this.groupBox1 = new System.Windows.Forms.GroupBox();\n            this.label3 = new System.Windows.Forms.Label();\n            this.upUnrollIter = new System.Windows.Forms.NumericUpDown();\n            this.cmbGLSLOptTarget = new System.Windows.Forms.ComboBox();\n            this.label2 = new System.Windows.Forms.Label();\n            this.groupBox1.SuspendLayout();\n            ((System.ComponentModel.ISupportInitialize)(this.upUnrollIter)).BeginInit();\n            this.SuspendLayout();\n            // \n            // label1\n            // \n            this.label1.AutoSize = true;\n            this.label1.Location = new System.Drawing.Point(5, 12);\n            this.label1.Name = \"label1\";\n            this.label1.Size = new System.Drawing.Size(31, 13);\n            this.label1.TabIndex = 0;\n            this.label1.Text = \"Type\";\n            // \n            // cmbShaderType\n            // \n            this.cmbShaderType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\n            this.cmbShaderType.FormattingEnabled = true;\n            this.cmbShaderType.Location = new System.Drawing.Point(42, 9);\n            this.cmbShaderType.Name = \"cmbShaderType\";\n            this.cmbShaderType.Size = new System.Drawing.Size(135, 21);\n            this.cmbShaderType.TabIndex = 1;\n            // \n            // groupBox1\n            // \n            this.groupBox1.Controls.Add(this.label3);\n            this.groupBox1.Controls.Add(this.upUnrollIter);\n            this.groupBox1.Controls.Add(this.cmbGLSLOptTarget);\n            this.groupBox1.Controls.Add(this.label2);\n            this.groupBox1.Location = new System.Drawing.Point(3, 36);\n            this.groupBox1.Name = \"groupBox1\";\n            this.groupBox1.Size = new System.Drawing.Size(180, 81);\n            this.groupBox1.TabIndex = 4;\n            this.groupBox1.TabStop = false;\n            this.groupBox1.Text = \"GLSL Optimizer\";\n            // \n            // label3\n            // \n            this.label3.AutoSize = true;\n            this.label3.Location = new System.Drawing.Point(6, 52);\n            this.label3.Name = \"label3\";\n            this.label3.Size = new System.Drawing.Size(57, 13);\n            this.label3.TabIndex = 7;\n            this.label3.Text = \"Max Unroll\";\n            // \n            // upUnrollIter\n            // \n            this.upUnrollIter.Location = new System.Drawing.Point(69, 48);\n            this.upUnrollIter.Name = \"upUnrollIter\";\n            this.upUnrollIter.Size = new System.Drawing.Size(53, 20);\n            this.upUnrollIter.TabIndex = 6;\n            this.upUnrollIter.Value = new decimal(new int[] {\n            16,\n            0,\n            0,\n            0});\n            // \n            // cmbGLSLOptTarget\n            // \n            this.cmbGLSLOptTarget.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\n            this.cmbGLSLOptTarget.FormattingEnabled = true;\n            this.cmbGLSLOptTarget.Location = new System.Drawing.Point(61, 20);\n            this.cmbGLSLOptTarget.Name = \"cmbGLSLOptTarget\";\n            this.cmbGLSLOptTarget.Size = new System.Drawing.Size(113, 21);\n            this.cmbGLSLOptTarget.TabIndex = 5;\n            // \n            // label2\n            // \n            this.label2.AutoSize = true;\n            this.label2.Location = new System.Drawing.Point(6, 23);\n            this.label2.Name = \"label2\";\n            this.label2.Size = new System.Drawing.Size(38, 13);\n            this.label2.TabIndex = 4;\n            this.label2.Text = \"Target\";\n            // \n            // GLSLOptionsPanel\n            // \n            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\n            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\n            this.Controls.Add(this.groupBox1);\n            this.Controls.Add(this.cmbShaderType);\n            this.Controls.Add(this.label1);\n            this.Name = \"GLSLOptionsPanel\";\n            this.Size = new System.Drawing.Size(198, 132);\n            this.groupBox1.ResumeLayout(false);\n            this.groupBox1.PerformLayout();\n            ((System.ComponentModel.ISupportInitialize)(this.upUnrollIter)).EndInit();\n            this.ResumeLayout(false);\n            this.PerformLayout();\n\n        }\n\n        #endregion\n\n        private System.Windows.Forms.Label label1;\n        private System.Windows.Forms.ComboBox cmbShaderType;\n        private System.Windows.Forms.GroupBox groupBox1;\n        private System.Windows.Forms.Label label3;\n        private System.Windows.Forms.NumericUpDown upUnrollIter;\n        private System.Windows.Forms.ComboBox cmbGLSLOptTarget;\n        private System.Windows.Forms.Label label2;\n\n    }\n}\n"
  },
  {
    "path": "src/Languages/GLSLOptionsPanel.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Drawing;\nusing System.Data;\nusing System.Text;\nusing System.Windows.Forms;\n\nnamespace Pyramid\n{\n    \n    public partial class GLSLOptionsPanel : UserControl, ICompileOptionsPanel\n    {\n        class GLSLOptimizerOptions : GLSLOptimizer.IOptions\n        {\n            public GLSLOptimizer.ShaderType ShaderType { get; set; }\n            public uint MaxUnrollIterations { get; set; }\n        }\n\n        class GLSLOptions : IGLSLOptions\n        {\n            public Languages Language { get { return Languages.GLSL; } }\n            public GLSLOptimizer.IOptions OptimizerOptions { get; set; }\n            public GLSLShaderType ShaderType { get; set; }\n            public GLSLOptimizer.Target OptimizerTarget { get; set; }\n        }\n\n        public GLSLOptionsPanel()\n        {\n            InitializeComponent();\n\n            foreach (object e in Enum.GetValues(typeof(GLSLShaderType)))\n                cmbShaderType.Items.Add(e);\n            foreach (object e in Enum.GetValues(typeof(GLSLOptimizer.Target)))\n                cmbGLSLOptTarget.Items.Add(e);\n\n            cmbGLSLOptTarget.SelectedIndex = 0;\n            cmbShaderType.SelectedIndex = 0;\n        }\n\n        public Control Panel { get { return this; } }\n\n        public ICompileOptions ReadOptions()\n        {\n            GLSLOptions opts = new GLSLOptions();\n            opts.ShaderType = (GLSLShaderType)cmbShaderType.SelectedItem;\n            opts.OptimizerTarget = (GLSLOptimizer.Target)cmbGLSLOptTarget.SelectedItem;\n            \n            GLSLOptimizer.ShaderType eType;\n            switch (opts.ShaderType)\n            {\n                default:    return opts;\n                case GLSLShaderType.VERTEX:   eType = GLSLOptimizer.ShaderType.VERTEX;    break;\n                case GLSLShaderType.FRAGMENT: eType = GLSLOptimizer.ShaderType.FRAGMENT;  break;\n            }\n\n            GLSLOptimizerOptions optOptions = new GLSLOptimizerOptions();\n            optOptions.ShaderType = eType;\n            optOptions.MaxUnrollIterations = (uint)upUnrollIter.Value;\n            opts.OptimizerOptions = optOptions;\n            return opts;\n        }\n    }\n}\n"
  },
  {
    "path": "src/Languages/GLSLOptionsPanel.resx",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n  <!-- \n    Microsoft ResX Schema \n    \n    Version 2.0\n    \n    The primary goals of this format is to allow a simple XML format \n    that is mostly human readable. The generation and parsing of the \n    various data types are done through the TypeConverter classes \n    associated with the data types.\n    \n    Example:\n    \n    ... ado.net/XML headers & schema ...\n    <resheader name=\"resmimetype\">text/microsoft-resx</resheader>\n    <resheader name=\"version\">2.0</resheader>\n    <resheader name=\"reader\">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\n    <resheader name=\"writer\">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\n    <data name=\"Name1\"><value>this is my long string</value><comment>this is a comment</comment></data>\n    <data name=\"Color1\" type=\"System.Drawing.Color, System.Drawing\">Blue</data>\n    <data name=\"Bitmap1\" mimetype=\"application/x-microsoft.net.object.binary.base64\">\n        <value>[base64 mime encoded serialized .NET Framework object]</value>\n    </data>\n    <data name=\"Icon1\" type=\"System.Drawing.Icon, System.Drawing\" mimetype=\"application/x-microsoft.net.object.bytearray.base64\">\n        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\n        <comment>This is a comment</comment>\n    </data>\n                \n    There are any number of \"resheader\" rows that contain simple \n    name/value pairs.\n    \n    Each data row contains a name, and value. The row also contains a \n    type or mimetype. Type corresponds to a .NET class that support \n    text/value conversion through the TypeConverter architecture. \n    Classes that don't support this are serialized and stored with the \n    mimetype set.\n    \n    The mimetype is used for serialized objects, and tells the \n    ResXResourceReader how to depersist the object. This is currently not \n    extensible. For a given mimetype the value must be set accordingly:\n    \n    Note - application/x-microsoft.net.object.binary.base64 is the format \n    that the ResXResourceWriter will generate, however the reader can \n    read any of the formats listed below.\n    \n    mimetype: application/x-microsoft.net.object.binary.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\n            : and then encoded with base64 encoding.\n    \n    mimetype: application/x-microsoft.net.object.soap.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\n            : and then encoded with base64 encoding.\n\n    mimetype: application/x-microsoft.net.object.bytearray.base64\n    value   : The object must be serialized into a byte array \n            : using a System.ComponentModel.TypeConverter\n            : and then encoded with base64 encoding.\n    -->\n  <xsd:schema id=\"root\" xmlns=\"\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">\n    <xsd:import namespace=\"http://www.w3.org/XML/1998/namespace\" />\n    <xsd:element name=\"root\" msdata:IsDataSet=\"true\">\n      <xsd:complexType>\n        <xsd:choice maxOccurs=\"unbounded\">\n          <xsd:element name=\"metadata\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" use=\"required\" type=\"xsd:string\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"assembly\">\n            <xsd:complexType>\n              <xsd:attribute name=\"alias\" type=\"xsd:string\" />\n              <xsd:attribute name=\"name\" type=\"xsd:string\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"data\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n                <xsd:element name=\"comment\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"2\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" msdata:Ordinal=\"1\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" msdata:Ordinal=\"3\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" msdata:Ordinal=\"4\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"resheader\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" />\n            </xsd:complexType>\n          </xsd:element>\n        </xsd:choice>\n      </xsd:complexType>\n    </xsd:element>\n  </xsd:schema>\n  <resheader name=\"resmimetype\">\n    <value>text/microsoft-resx</value>\n  </resheader>\n  <resheader name=\"version\">\n    <value>2.0</value>\n  </resheader>\n  <resheader name=\"reader\">\n    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n  <resheader name=\"writer\">\n    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n</root>"
  },
  {
    "path": "src/Languages/HLSLLanguage.cs",
    "content": "﻿\n\nnamespace Pyramid\n{\n    public class HLSLLanguage : ILanguage\n    {\n        private HLSLOptionsPanel m_Options = new HLSLOptionsPanel();\n        public ICompileOptionsPanel OptionsPanel { get { return m_Options; } }\n        public string Name { get { return \"HLSL\"; } }\n    }\n\n   \n\n}"
  },
  {
    "path": "src/Languages/HLSLOptionsPanel.Designer.cs",
    "content": "﻿namespace Pyramid\n{\n    partial class HLSLOptionsPanel\n    {\n        /// <summary> \n        /// Required designer variable.\n        /// </summary>\n        private System.ComponentModel.IContainer components = null;\n\n        /// <summary> \n        /// Clean up any resources being used.\n        /// </summary>\n        /// <param name=\"disposing\">true if managed resources should be disposed; otherwise, false.</param>\n        protected override void Dispose(bool disposing)\n        {\n            if (disposing && (components != null))\n            {\n                components.Dispose();\n            }\n            base.Dispose(disposing);\n        }\n\n        #region Component Designer generated code\n\n        /// <summary> \n        /// Required method for Designer support - do not modify \n        /// the contents of this method with the code editor.\n        /// </summary>\n        private void InitializeComponent()\n        {\n            this.label1 = new System.Windows.Forms.Label();\n            this.cmbTarget = new System.Windows.Forms.ComboBox();\n            this.label2 = new System.Windows.Forms.Label();\n            this.label3 = new System.Windows.Forms.Label();\n            this.cmbOpt = new System.Windows.Forms.ComboBox();\n            this.txtEntryPoint = new System.Windows.Forms.TextBox();\n            this.label4 = new System.Windows.Forms.Label();\n            this.chkCompat = new System.Windows.Forms.CheckBox();\n            this.txtRootSig = new System.Windows.Forms.TextBox();\n            this.label5 = new System.Windows.Forms.Label();\n            this.cmbRootSignature = new System.Windows.Forms.ComboBox();\n            this.label6 = new System.Windows.Forms.Label();\n            this.SuspendLayout();\n            // \n            // label1\n            // \n            this.label1.AutoSize = true;\n            this.label1.Location = new System.Drawing.Point(17, 14);\n            this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);\n            this.label1.Name = \"label1\";\n            this.label1.Size = new System.Drawing.Size(43, 17);\n            this.label1.TabIndex = 0;\n            this.label1.Text = \"HLSL\";\n            // \n            // cmbTarget\n            // \n            this.cmbTarget.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\n            this.cmbTarget.FormattingEnabled = true;\n            this.cmbTarget.Location = new System.Drawing.Point(120, 46);\n            this.cmbTarget.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);\n            this.cmbTarget.Name = \"cmbTarget\";\n            this.cmbTarget.Size = new System.Drawing.Size(160, 24);\n            this.cmbTarget.TabIndex = 1;\n            // \n            // label2\n            // \n            this.label2.AutoSize = true;\n            this.label2.Location = new System.Drawing.Point(17, 49);\n            this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);\n            this.label2.Name = \"label2\";\n            this.label2.Size = new System.Drawing.Size(50, 17);\n            this.label2.TabIndex = 2;\n            this.label2.Text = \"Target\";\n            // \n            // label3\n            // \n            this.label3.AutoSize = true;\n            this.label3.Location = new System.Drawing.Point(17, 80);\n            this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);\n            this.label3.Name = \"label3\";\n            this.label3.Size = new System.Drawing.Size(31, 17);\n            this.label3.TabIndex = 3;\n            this.label3.Text = \"Opt\";\n            // \n            // cmbOpt\n            // \n            this.cmbOpt.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\n            this.cmbOpt.FormattingEnabled = true;\n            this.cmbOpt.Location = new System.Drawing.Point(120, 80);\n            this.cmbOpt.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);\n            this.cmbOpt.Name = \"cmbOpt\";\n            this.cmbOpt.Size = new System.Drawing.Size(160, 24);\n            this.cmbOpt.TabIndex = 4;\n            // \n            // txtEntryPoint\n            // \n            this.txtEntryPoint.Location = new System.Drawing.Point(120, 112);\n            this.txtEntryPoint.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);\n            this.txtEntryPoint.Name = \"txtEntryPoint\";\n            this.txtEntryPoint.Size = new System.Drawing.Size(159, 22);\n            this.txtEntryPoint.TabIndex = 5;\n            this.txtEntryPoint.Text = \"main\";\n            // \n            // label4\n            // \n            this.label4.AutoSize = true;\n            this.label4.Location = new System.Drawing.Point(9, 116);\n            this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);\n            this.label4.Name = \"label4\";\n            this.label4.Size = new System.Drawing.Size(73, 17);\n            this.label4.TabIndex = 6;\n            this.label4.Text = \"EntryPoint\";\n            // \n            // chkCompat\n            // \n            this.chkCompat.AutoSize = true;\n            this.chkCompat.Location = new System.Drawing.Point(120, 142);\n            this.chkCompat.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);\n            this.chkCompat.Name = \"chkCompat\";\n            this.chkCompat.Size = new System.Drawing.Size(78, 21);\n            this.chkCompat.TabIndex = 7;\n            this.chkCompat.Text = \"Compat\";\n            this.chkCompat.UseVisualStyleBackColor = true;\n            // \n            // txtRootSig\n            // \n            this.txtRootSig.Location = new System.Drawing.Point(120, 191);\n            this.txtRootSig.Margin = new System.Windows.Forms.Padding(4);\n            this.txtRootSig.Name = \"txtRootSig\";\n            this.txtRootSig.Size = new System.Drawing.Size(159, 22);\n            this.txtRootSig.TabIndex = 8;\n            this.txtRootSig.Text = \"RootSignature\";\n            // \n            // label5\n            // \n            this.label5.AutoSize = true;\n            this.label5.Location = new System.Drawing.Point(9, 194);\n            this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);\n            this.label5.Name = \"label5\";\n            this.label5.Size = new System.Drawing.Size(90, 17);\n            this.label5.TabIndex = 9;\n            this.label5.Text = \"RootSig #def\";\n            // \n            // cmbRootSignature\n            // \n            this.cmbRootSignature.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\n            this.cmbRootSignature.FormattingEnabled = true;\n            this.cmbRootSignature.Location = new System.Drawing.Point(119, 221);\n            this.cmbRootSignature.Margin = new System.Windows.Forms.Padding(4);\n            this.cmbRootSignature.Name = \"cmbRootSignature\";\n            this.cmbRootSignature.Size = new System.Drawing.Size(160, 24);\n            this.cmbRootSignature.TabIndex = 10;\n            // \n            // label6\n            // \n            this.label6.AutoSize = true;\n            this.label6.Location = new System.Drawing.Point(9, 221);\n            this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);\n            this.label6.Name = \"label6\";\n            this.label6.Size = new System.Drawing.Size(104, 17);\n            this.label6.TabIndex = 11;\n            this.label6.Text = \"RootSig Target\";\n            // \n            // HLSLOptionsPanel\n            // \n            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);\n            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\n            this.Controls.Add(this.label6);\n            this.Controls.Add(this.cmbRootSignature);\n            this.Controls.Add(this.label5);\n            this.Controls.Add(this.txtRootSig);\n            this.Controls.Add(this.chkCompat);\n            this.Controls.Add(this.label4);\n            this.Controls.Add(this.txtEntryPoint);\n            this.Controls.Add(this.cmbOpt);\n            this.Controls.Add(this.label3);\n            this.Controls.Add(this.label2);\n            this.Controls.Add(this.cmbTarget);\n            this.Controls.Add(this.label1);\n            this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);\n            this.Name = \"HLSLOptionsPanel\";\n            this.Size = new System.Drawing.Size(310, 267);\n            this.Load += new System.EventHandler(this.HLSLOptionsPanel_Load);\n            this.ResumeLayout(false);\n            this.PerformLayout();\n\n        }\n\n        #endregion\n\n        private System.Windows.Forms.Label label1;\n        private System.Windows.Forms.ComboBox cmbTarget;\n        private System.Windows.Forms.Label label2;\n        private System.Windows.Forms.Label label3;\n        private System.Windows.Forms.ComboBox cmbOpt;\n        private System.Windows.Forms.TextBox txtEntryPoint;\n        private System.Windows.Forms.Label label4;\n        private System.Windows.Forms.CheckBox chkCompat;\n        private System.Windows.Forms.TextBox txtRootSig;\n        private System.Windows.Forms.Label label5;\n        private System.Windows.Forms.ComboBox cmbRootSignature;\n        private System.Windows.Forms.Label label6;\n    }\n}\n"
  },
  {
    "path": "src/Languages/HLSLOptionsPanel.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Drawing;\nusing System.Text;\nusing System.Windows.Forms;\n\nnamespace Pyramid\n{\n\n    public partial class HLSLOptionsPanel : UserControl, ICompileOptionsPanel\n    {\n        private class HLSLOptions : IHLSLOptions\n        {\n            public Languages Language { get { return Languages.HLSL; } }\n            public HLSLTarget Target { get; set; }\n            public RootSignatureTarget RootSigTarget { get; set; }\n            public HLSLOptimizationLevel OptimizationLevel { get; set; }\n            public string EntryPoint { get; set; }\n            public string RootSigMacro { get; set; }\n            public bool Compatibility { get; set; }\n\n            public HLSLShaderType ShaderType\n            {\n                get\n                {\n                    switch (this.Target)\n                    {\n                        case HLSLTarget.vs_3_0:\n                        case HLSLTarget.vs_4_0:\n                        case HLSLTarget.vs_4_1:\n                        case HLSLTarget.vs_5_0:\n                        case HLSLTarget.vs_5_1:\n                        case HLSLTarget.vs_6_0:\n                        case HLSLTarget.vs_6_1:\n                        case HLSLTarget.vs_6_2:\n                            return HLSLShaderType.VERTEX;                       \n                        case HLSLTarget.ps_3_0:\n                        case HLSLTarget.ps_4_0:\n                        case HLSLTarget.ps_4_1:\n                        case HLSLTarget.ps_5_0:\n                        case HLSLTarget.ps_5_1:\n                        case HLSLTarget.ps_6_0:\n                        case HLSLTarget.ps_6_1:\n                        case HLSLTarget.ps_6_2:\n                            return HLSLShaderType.PIXEL;\n                        case HLSLTarget.gs_4_0:\n                        case HLSLTarget.gs_4_1:\n                        case HLSLTarget.gs_5_0:\n                        case HLSLTarget.gs_5_1:\n                        case HLSLTarget.gs_6_0:\n                        case HLSLTarget.gs_6_1:\n                        case HLSLTarget.gs_6_2:\n                            return HLSLShaderType.GEOMETRY;\n                        case HLSLTarget.hs_5_0:\n                        case HLSLTarget.hs_5_1:\n                        case HLSLTarget.hs_6_0:\n                        case HLSLTarget.hs_6_1:\n                        case HLSLTarget.hs_6_2:\n                            return HLSLShaderType.HULL;\n                        case HLSLTarget.ds_5_0:\n                        case HLSLTarget.ds_5_1:\n                        case HLSLTarget.ds_6_0:\n                        case HLSLTarget.ds_6_1:\n                        case HLSLTarget.ds_6_2:\n                            return HLSLShaderType.DOMAIN;\n                        case HLSLTarget.cs_4_0:\n                        case HLSLTarget.cs_4_1:\n                        case HLSLTarget.cs_5_0:\n                        case HLSLTarget.cs_5_1:\n                        case HLSLTarget.cs_6_0:\n                        case HLSLTarget.cs_6_1:\n                        case HLSLTarget.cs_6_2:\n                            return HLSLShaderType.COMPUTE;\n                    }\n                    throw new System.Exception(\"What is this?\");\n                }\n            }\n\n            public uint GetD3DCompileFlagBits()\n            {\n                uint flags=0;\n                switch (OptimizationLevel)\n                {\n                    case HLSLOptimizationLevel.SKIP: \n                        flags |= (1 << 2); \n                        break; //D3DCOMPILE_SKIP_OPTIMIZATION\n                    case HLSLOptimizationLevel.LEVEL0: \n                        flags |= (1 << 14); \n                        break; //D3DCOMPILE_OPTIMIZATION_LEVEL0\n                    case HLSLOptimizationLevel.LEVEL1: \n                        flags |= 0; \n                        break;//D3DCOMPILE_OPTIMIZATION_LEVEL1\n                    case HLSLOptimizationLevel.LEVEL2: \n                        flags |= (1<<14)|(1<<15) ; \n                        break; //D3DCOMPILE_OPTIMIZATION_LEVEL2\n                    case HLSLOptimizationLevel.LEVEL3: \n                        flags |= (1<<15);\n                        break; //D3DCOMPILE_OPTIMIZATION_LEVEL3\n                }\n\n                if (Compatibility)\n                    flags |= (1 << 12);// D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY\n                return flags;\n            }\n\n            public string GetFXCCommandLine(string shaderFile)\n            {\n                string switches = \"\";\n                switch (OptimizationLevel)\n                {\n                    case HLSLOptimizationLevel.SKIP:   switches += \"/Od \"; break;\n                    case HLSLOptimizationLevel.LEVEL0: switches += \"/O0 \"; break;\n                    case HLSLOptimizationLevel.LEVEL1: switches += \"/O1 \"; break;\n                    case HLSLOptimizationLevel.LEVEL2: switches += \"/O2 \"; break;\n                    case HLSLOptimizationLevel.LEVEL3: switches += \"/O3 \"; break;\n                }\n\n                if (Compatibility)\n                    switches += \"/Gec\";\n\n                return String.Format(\n                    \"/T{0} /E{1} {2} \\\"{3}\\\"\",\n                    Target.ToString(), \n                    EntryPoint, \n                    switches, \n                    shaderFile );\n            }\n        }\n\n        public HLSLOptionsPanel()\n        {\n            InitializeComponent();\n            \n            foreach( object e in Enum.GetValues(typeof(HLSLTarget)))\n            {\n                string n = Enum.GetName(typeof(HLSLTarget), e);\n                cmbTarget.Items.Add(n);\n            }\n            foreach( object e in Enum.GetValues(typeof(HLSLOptimizationLevel)))\n            {\n                string n = Enum.GetName(typeof(HLSLOptimizationLevel), e);\n                cmbOpt.Items.Add(n);\n            }\n            foreach( object e in Enum.GetValues(typeof(RootSignatureTarget) ) )\n            {\n                string n = Enum.GetName(typeof(RootSignatureTarget), e);\n                cmbRootSignature.Items.Add(n);\n            }\n            cmbTarget.SelectedIndex = cmbTarget.Items.IndexOf(\"ps_5_0\");\n            cmbOpt.SelectedIndex = cmbOpt.Items.IndexOf(\"LEVEL3\");\n            cmbRootSignature.SelectedIndex = cmbRootSignature.Items.IndexOf(\"rootsig_1_0\");\n        }\n        \n        public Control Panel { get { return this; } }\n\n        public ICompileOptions ReadOptions()\n        {\n            HLSLOptions opts = new HLSLOptions();\n            opts.Compatibility = chkCompat.Checked;\n            opts.EntryPoint = txtEntryPoint.Text;\n            opts.RootSigMacro = txtRootSig.Text;\n            opts.RootSigTarget = (RootSignatureTarget)Enum.Parse(typeof(RootSignatureTarget), (string) cmbRootSignature.Items[cmbRootSignature.SelectedIndex]);\n            opts.Target = (HLSLTarget) Enum.Parse(typeof(HLSLTarget), (string) cmbTarget.Items[cmbTarget.SelectedIndex]);\n            opts.OptimizationLevel = (HLSLOptimizationLevel)Enum.Parse(typeof(HLSLOptimizationLevel), (string)\n                                                               cmbOpt.Items[cmbOpt.SelectedIndex]);\n            return opts;\n        }\n\n        private void HLSLOptionsPanel_Load(object sender, EventArgs e)\n        {\n\n        }\n    }\n}\n"
  },
  {
    "path": "src/Languages/HLSLOptionsPanel.resx",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n  <!-- \n    Microsoft ResX Schema \n    \n    Version 2.0\n    \n    The primary goals of this format is to allow a simple XML format \n    that is mostly human readable. The generation and parsing of the \n    various data types are done through the TypeConverter classes \n    associated with the data types.\n    \n    Example:\n    \n    ... ado.net/XML headers & schema ...\n    <resheader name=\"resmimetype\">text/microsoft-resx</resheader>\n    <resheader name=\"version\">2.0</resheader>\n    <resheader name=\"reader\">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\n    <resheader name=\"writer\">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\n    <data name=\"Name1\"><value>this is my long string</value><comment>this is a comment</comment></data>\n    <data name=\"Color1\" type=\"System.Drawing.Color, System.Drawing\">Blue</data>\n    <data name=\"Bitmap1\" mimetype=\"application/x-microsoft.net.object.binary.base64\">\n        <value>[base64 mime encoded serialized .NET Framework object]</value>\n    </data>\n    <data name=\"Icon1\" type=\"System.Drawing.Icon, System.Drawing\" mimetype=\"application/x-microsoft.net.object.bytearray.base64\">\n        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\n        <comment>This is a comment</comment>\n    </data>\n                \n    There are any number of \"resheader\" rows that contain simple \n    name/value pairs.\n    \n    Each data row contains a name, and value. The row also contains a \n    type or mimetype. Type corresponds to a .NET class that support \n    text/value conversion through the TypeConverter architecture. \n    Classes that don't support this are serialized and stored with the \n    mimetype set.\n    \n    The mimetype is used for serialized objects, and tells the \n    ResXResourceReader how to depersist the object. This is currently not \n    extensible. For a given mimetype the value must be set accordingly:\n    \n    Note - application/x-microsoft.net.object.binary.base64 is the format \n    that the ResXResourceWriter will generate, however the reader can \n    read any of the formats listed below.\n    \n    mimetype: application/x-microsoft.net.object.binary.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\n            : and then encoded with base64 encoding.\n    \n    mimetype: application/x-microsoft.net.object.soap.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\n            : and then encoded with base64 encoding.\n\n    mimetype: application/x-microsoft.net.object.bytearray.base64\n    value   : The object must be serialized into a byte array \n            : using a System.ComponentModel.TypeConverter\n            : and then encoded with base64 encoding.\n    -->\n  <xsd:schema id=\"root\" xmlns=\"\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">\n    <xsd:import namespace=\"http://www.w3.org/XML/1998/namespace\" />\n    <xsd:element name=\"root\" msdata:IsDataSet=\"true\">\n      <xsd:complexType>\n        <xsd:choice maxOccurs=\"unbounded\">\n          <xsd:element name=\"metadata\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" use=\"required\" type=\"xsd:string\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"assembly\">\n            <xsd:complexType>\n              <xsd:attribute name=\"alias\" type=\"xsd:string\" />\n              <xsd:attribute name=\"name\" type=\"xsd:string\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"data\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n                <xsd:element name=\"comment\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"2\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" msdata:Ordinal=\"1\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" msdata:Ordinal=\"3\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" msdata:Ordinal=\"4\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"resheader\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" />\n            </xsd:complexType>\n          </xsd:element>\n        </xsd:choice>\n      </xsd:complexType>\n    </xsd:element>\n  </xsd:schema>\n  <resheader name=\"resmimetype\">\n    <value>text/microsoft-resx</value>\n  </resheader>\n  <resheader name=\"version\">\n    <value>2.0</value>\n  </resheader>\n  <resheader name=\"reader\">\n    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n  <resheader name=\"writer\">\n    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n</root>"
  },
  {
    "path": "src/Languages/ICompileOptionsPanel.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.Windows.Forms;\n\nnamespace Pyramid\n{\n\n\n    public interface ICompileOptionsPanel\n    {\n        Control Panel { get; }\n        ICompileOptions ReadOptions();\n    };\n\n\n\n   \n}\n"
  },
  {
    "path": "src/Languages/ILanguage.cs",
    "content": "﻿\nnamespace Pyramid\n{\n\n    public interface ILanguage\n    {\n        ICompileOptionsPanel OptionsPanel { get; }\n        string Name { get; }\n    };\n}\n"
  },
  {
    "path": "src/MainUI/AboutBox.Designer.cs",
    "content": "﻿namespace Pyramid\n{\n    partial class AboutBox\n    {\n        /// <summary>\n        /// Required designer variable.\n        /// </summary>\n        private System.ComponentModel.IContainer components = null;\n\n        /// <summary>\n        /// Clean up any resources being used.\n        /// </summary>\n        protected override void Dispose(bool disposing)\n        {\n            if (disposing && (components != null))\n            {\n                components.Dispose();\n            }\n            base.Dispose(disposing);\n        }\n\n        #region Windows Form Designer generated code\n\n        /// <summary>\n        /// Required method for Designer support - do not modify\n        /// the contents of this method with the code editor.\n        /// </summary>\n        private void InitializeComponent()\n        {\n            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AboutBox));\n            this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();\n            this.logoPictureBox = new System.Windows.Forms.PictureBox();\n            this.labelProductName = new System.Windows.Forms.Label();\n            this.labelVersion = new System.Windows.Forms.Label();\n            this.labelCopyright = new System.Windows.Forms.Label();\n            this.labelCompanyName = new System.Windows.Forms.Label();\n            this.textBoxDescription = new System.Windows.Forms.TextBox();\n            this.okButton = new System.Windows.Forms.Button();\n            this.tableLayoutPanel.SuspendLayout();\n            ((System.ComponentModel.ISupportInitialize)(this.logoPictureBox)).BeginInit();\n            this.SuspendLayout();\n            // \n            // tableLayoutPanel\n            // \n            this.tableLayoutPanel.ColumnCount = 2;\n            this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33F));\n            this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 67F));\n            this.tableLayoutPanel.Controls.Add(this.logoPictureBox, 0, 0);\n            this.tableLayoutPanel.Controls.Add(this.labelProductName, 1, 0);\n            this.tableLayoutPanel.Controls.Add(this.labelVersion, 1, 1);\n            this.tableLayoutPanel.Controls.Add(this.labelCopyright, 1, 2);\n            this.tableLayoutPanel.Controls.Add(this.labelCompanyName, 1, 3);\n            this.tableLayoutPanel.Controls.Add(this.textBoxDescription, 1, 4);\n            this.tableLayoutPanel.Controls.Add(this.okButton, 1, 5);\n            this.tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;\n            this.tableLayoutPanel.Location = new System.Drawing.Point(9, 9);\n            this.tableLayoutPanel.Name = \"tableLayoutPanel\";\n            this.tableLayoutPanel.RowCount = 6;\n            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F));\n            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F));\n            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F));\n            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F));\n            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));\n            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F));\n            this.tableLayoutPanel.Size = new System.Drawing.Size(417, 265);\n            this.tableLayoutPanel.TabIndex = 0;\n            // \n            // logoPictureBox\n            // \n            this.logoPictureBox.Dock = System.Windows.Forms.DockStyle.Fill;\n            this.logoPictureBox.Image = ((System.Drawing.Image)(resources.GetObject(\"logoPictureBox.Image\")));\n            this.logoPictureBox.Location = new System.Drawing.Point(3, 3);\n            this.logoPictureBox.Name = \"logoPictureBox\";\n            this.tableLayoutPanel.SetRowSpan(this.logoPictureBox, 6);\n            this.logoPictureBox.Size = new System.Drawing.Size(131, 259);\n            this.logoPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;\n            this.logoPictureBox.TabIndex = 12;\n            this.logoPictureBox.TabStop = false;\n            // \n            // labelProductName\n            // \n            this.labelProductName.Dock = System.Windows.Forms.DockStyle.Fill;\n            this.labelProductName.Location = new System.Drawing.Point(143, 0);\n            this.labelProductName.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0);\n            this.labelProductName.MaximumSize = new System.Drawing.Size(0, 17);\n            this.labelProductName.Name = \"labelProductName\";\n            this.labelProductName.Size = new System.Drawing.Size(271, 17);\n            this.labelProductName.TabIndex = 19;\n            this.labelProductName.Text = \"Pyramid ShaderAnalyzer\";\n            this.labelProductName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;\n            // \n            // labelVersion\n            // \n            this.labelVersion.Dock = System.Windows.Forms.DockStyle.Fill;\n            this.labelVersion.Location = new System.Drawing.Point(143, 26);\n            this.labelVersion.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0);\n            this.labelVersion.MaximumSize = new System.Drawing.Size(0, 17);\n            this.labelVersion.Name = \"labelVersion\";\n            this.labelVersion.Size = new System.Drawing.Size(271, 17);\n            this.labelVersion.TabIndex = 0;\n            this.labelVersion.Text = \"Version 1.4\";\n            this.labelVersion.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;\n            // \n            // labelCopyright\n            // \n            this.labelCopyright.Dock = System.Windows.Forms.DockStyle.Fill;\n            this.labelCopyright.Location = new System.Drawing.Point(143, 52);\n            this.labelCopyright.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0);\n            this.labelCopyright.MaximumSize = new System.Drawing.Size(0, 17);\n            this.labelCopyright.Name = \"labelCopyright\";\n            this.labelCopyright.Size = new System.Drawing.Size(271, 17);\n            this.labelCopyright.TabIndex = 21;\n            this.labelCopyright.Text = \"Copyright 2014-2015 Joshua Barczak\";\n            this.labelCopyright.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;\n            // \n            // labelCompanyName\n            // \n            this.labelCompanyName.Dock = System.Windows.Forms.DockStyle.Fill;\n            this.labelCompanyName.Location = new System.Drawing.Point(143, 78);\n            this.labelCompanyName.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0);\n            this.labelCompanyName.MaximumSize = new System.Drawing.Size(0, 17);\n            this.labelCompanyName.Name = \"labelCompanyName\";\n            this.labelCompanyName.Size = new System.Drawing.Size(271, 17);\n            this.labelCompanyName.TabIndex = 22;\n            this.labelCompanyName.Text = \"Me Myself and I, Ltd.\";\n            this.labelCompanyName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;\n            // \n            // textBoxDescription\n            // \n            this.textBoxDescription.Dock = System.Windows.Forms.DockStyle.Fill;\n            this.textBoxDescription.Location = new System.Drawing.Point(143, 107);\n            this.textBoxDescription.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3);\n            this.textBoxDescription.Multiline = true;\n            this.textBoxDescription.Name = \"textBoxDescription\";\n            this.textBoxDescription.ReadOnly = true;\n            this.textBoxDescription.ScrollBars = System.Windows.Forms.ScrollBars.Both;\n            this.textBoxDescription.Size = new System.Drawing.Size(271, 126);\n            this.textBoxDescription.TabIndex = 23;\n            this.textBoxDescription.TabStop = false;\n            this.textBoxDescription.Text = resources.GetString(\"textBoxDescription.Text\");\n            // \n            // okButton\n            // \n            this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));\n            this.okButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;\n            this.okButton.Location = new System.Drawing.Point(339, 239);\n            this.okButton.Name = \"okButton\";\n            this.okButton.Size = new System.Drawing.Size(75, 23);\n            this.okButton.TabIndex = 24;\n            this.okButton.Text = \"&OK\";\n            // \n            // AboutBox\n            // \n            this.AcceptButton = this.okButton;\n            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\n            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\n            this.ClientSize = new System.Drawing.Size(435, 283);\n            this.Controls.Add(this.tableLayoutPanel);\n            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;\n            this.MaximizeBox = false;\n            this.MinimizeBox = false;\n            this.Name = \"AboutBox\";\n            this.Padding = new System.Windows.Forms.Padding(9);\n            this.ShowIcon = false;\n            this.ShowInTaskbar = false;\n            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;\n            this.Text = \"About This Thing\";\n            this.tableLayoutPanel.ResumeLayout(false);\n            this.tableLayoutPanel.PerformLayout();\n            ((System.ComponentModel.ISupportInitialize)(this.logoPictureBox)).EndInit();\n            this.ResumeLayout(false);\n\n        }\n\n        #endregion\n\n        private System.Windows.Forms.TableLayoutPanel tableLayoutPanel;\n        private System.Windows.Forms.PictureBox logoPictureBox;\n        private System.Windows.Forms.Label labelProductName;\n        private System.Windows.Forms.Label labelVersion;\n        private System.Windows.Forms.Label labelCopyright;\n        private System.Windows.Forms.Label labelCompanyName;\n        private System.Windows.Forms.TextBox textBoxDescription;\n        private System.Windows.Forms.Button okButton;\n    }\n}\n"
  },
  {
    "path": "src/MainUI/AboutBox.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Drawing;\nusing System.Reflection;\nusing System.Windows.Forms;\n\nnamespace Pyramid\n{\n    partial class AboutBox : Form\n    {\n        public AboutBox()\n        {\n            InitializeComponent();\n        }\n\n    }\n}\n"
  },
  {
    "path": "src/MainUI/AboutBox.resx",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n  <!-- \n    Microsoft ResX Schema \n    \n    Version 2.0\n    \n    The primary goals of this format is to allow a simple XML format \n    that is mostly human readable. The generation and parsing of the \n    various data types are done through the TypeConverter classes \n    associated with the data types.\n    \n    Example:\n    \n    ... ado.net/XML headers & schema ...\n    <resheader name=\"resmimetype\">text/microsoft-resx</resheader>\n    <resheader name=\"version\">2.0</resheader>\n    <resheader name=\"reader\">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\n    <resheader name=\"writer\">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\n    <data name=\"Name1\"><value>this is my long string</value><comment>this is a comment</comment></data>\n    <data name=\"Color1\" type=\"System.Drawing.Color, System.Drawing\">Blue</data>\n    <data name=\"Bitmap1\" mimetype=\"application/x-microsoft.net.object.binary.base64\">\n        <value>[base64 mime encoded serialized .NET Framework object]</value>\n    </data>\n    <data name=\"Icon1\" type=\"System.Drawing.Icon, System.Drawing\" mimetype=\"application/x-microsoft.net.object.bytearray.base64\">\n        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\n        <comment>This is a comment</comment>\n    </data>\n                \n    There are any number of \"resheader\" rows that contain simple \n    name/value pairs.\n    \n    Each data row contains a name, and value. The row also contains a \n    type or mimetype. Type corresponds to a .NET class that support \n    text/value conversion through the TypeConverter architecture. \n    Classes that don't support this are serialized and stored with the \n    mimetype set.\n    \n    The mimetype is used for serialized objects, and tells the \n    ResXResourceReader how to depersist the object. This is currently not \n    extensible. For a given mimetype the value must be set accordingly:\n    \n    Note - application/x-microsoft.net.object.binary.base64 is the format \n    that the ResXResourceWriter will generate, however the reader can \n    read any of the formats listed below.\n    \n    mimetype: application/x-microsoft.net.object.binary.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\n            : and then encoded with base64 encoding.\n    \n    mimetype: application/x-microsoft.net.object.soap.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\n            : and then encoded with base64 encoding.\n\n    mimetype: application/x-microsoft.net.object.bytearray.base64\n    value   : The object must be serialized into a byte array \n            : using a System.ComponentModel.TypeConverter\n            : and then encoded with base64 encoding.\n    -->\n  <xsd:schema id=\"root\" xmlns=\"\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">\n    <xsd:import namespace=\"http://www.w3.org/XML/1998/namespace\" />\n    <xsd:element name=\"root\" msdata:IsDataSet=\"true\">\n      <xsd:complexType>\n        <xsd:choice maxOccurs=\"unbounded\">\n          <xsd:element name=\"metadata\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" use=\"required\" type=\"xsd:string\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"assembly\">\n            <xsd:complexType>\n              <xsd:attribute name=\"alias\" type=\"xsd:string\" />\n              <xsd:attribute name=\"name\" type=\"xsd:string\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"data\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n                <xsd:element name=\"comment\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"2\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" msdata:Ordinal=\"1\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" msdata:Ordinal=\"3\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" msdata:Ordinal=\"4\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"resheader\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" />\n            </xsd:complexType>\n          </xsd:element>\n        </xsd:choice>\n      </xsd:complexType>\n    </xsd:element>\n  </xsd:schema>\n  <resheader name=\"resmimetype\">\n    <value>text/microsoft-resx</value>\n  </resheader>\n  <resheader name=\"version\">\n    <value>2.0</value>\n  </resheader>\n  <resheader name=\"reader\">\n    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n  <resheader name=\"writer\">\n    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n  <assembly alias=\"System.Drawing\" name=\"System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\" />\n  <data name=\"logoPictureBox.Image\" type=\"System.Drawing.Bitmap, System.Drawing\" mimetype=\"application/x-microsoft.net.object.bytearray.base64\">\n    <value>\n        iVBORw0KGgoAAAANSUhEUgAAAHgAAAEGCAIAAAAhWcaAAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6\n        JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AABvkklEQVR4Xu29B1hUd9r+z3X939+7bzax\n        RQWmnZmhS++9i4KCXRRRsKGoiKKIKIJKlSrSpTdpioWmYm9gLzEao4kliTGmZ3ez6767yb7/+3u+M8fD\n        DBiTTVE33+u5cKSe85n73M/9nJk5oyEsE4rKRaIKkbhKLKmVMPUM08hIW6Ty3XL5PrlOl45Ot47uEV3d\n        47p6J/X0TrGFG8f09I7o6Xbr6u7X1W3X1d2nq7NbR2enjk6zjk6jjk69jk6djixDxsxhRJailJSUy5cv\n        f/vtt3/729/+/ve//+///u8//vGPf/7zn999993333//L3b936u+WNBlInG5WFIhkVRKmCpGWiOV1kpl\n        O2TyJrm8RS5vlevs1dHt1NU9oAuy4Esoo46yrA+xn8dX29RY1+joVOvI0mXMbEZkIUpPT7958+Zf/vKX\n        v/71r0+ePPlPw60BylA0Bc1UMgR0lVRWLZPVyuR1cnm9XKeBBdeio9OqA+US/Xbp6h7UJYi5UrLW3aOr\n        s6sPa3mVXF4pl6ZKJTMlQmNhYWHhhx9++B+Im4B+SrlSSblaJq+Rk6qVwwQIsh06hHiTkvheljjgwjoA\n        HQXWuAOojbSqsa6Qy8vl0o1SyWSJUEfY0NDwpz/96T8KtwYoiysUoEFZWk1AP6Vcq/O0OOIgCI4qxEEZ\n        hRucZeMbVFiXyeWlcmY1I/YRR0REHDlyhMP9ynu3hrhMLCmXMBWsnCtZOdcoQPehzBVwqxCHL+9mXQXW\n        Acq0uPaIgwDfybEulcu3y+WFcmYRI7IXbdmy5c6dO3zcYK2CW7GlL/nSEBeLxaWENaFcJUPJq+WkBgLN\n        lYqlgPguHXi0gjgKN2DZtD2qsC6Ry4vlsmSZZLpEqC9samr6+uuvgZtLJq+etDXEOWLJNglTxDAljLRM\n        KquQySoJa3DpUyqUuepX4LAUShzGwrVH3B+1PNbFcnkRK+0oRuwpXr9+/ZUrV4D7z3/+80DGrdjkl3Np\n        iNPF4gyxJEPC5DDSPKmsSCYrkREzLSdpAfnsuYir44ZBgy8sBaDhIVwUqevLulAuL5AjcUtmkUxSX1//\n        5ZdffvPNNxQ337hfdmlriFPFkjQJs4VhMhhplhQl2yqTb2MRwExBHFCApur5NK6CWylwUmDNtcdqnT6s\n        8+WyPBmzihF7iTds2HDjxo2vvvqKc5JXQ9oa4mSxJEXCpDFgLU2XSjOkskyZLJstEM9jD3Ae8efSOB83\n        tW/gpkV1ja/Csvms8+SybTJpmlQSKBEaCPfs2fPFF1/06yQvqbQ1JIkSJplhUhjMFNhP2RYZZjnCmsNN\n        ieezRMDl+QWujhuKpqy5KMJjDVHjD8lyZMwyRuQkysrK+vjjj+EkNJO87NJmQScx0mQpqRSpLE1GiuLO\n        YHFnKXHnyMBCxVJ+QOAq3k1x0+JYVypZw6y3KVhLN0jF/mKBUNDb2/v555+rS/ulCyQaoMyBlqXIFJXK\n        w60u8FwWN9D8NNwoyho3KGscIiqs2T/EzGaEo4QtLS2ffvrpyy5tAvqpnDnQfNwDCRx+UvBj/EQdN0RN\n        WdPYh7sNvw2NEaxx9FDWsBFH0bZt2x4/fsyXtnrWVuzQi7o0xIvFTDxhrUqZX8/G3de+f1jdYM3H3S/r\n        3Kespeuk4jEkaN+6deuzzz7jAsnLZSMazs7OAgOByE0kni5mljOqiPnF95OB1P08ZsKXNj01iI/qrJUG\n        QlinSCVTJAKJ4PTp05A2AgmytoqNvOCsNerq6vLz82NiYoKCghwdHUVWIom/hAljZBvVQNN6hrqpd2O8\n        Biy0OHXcHGsV3FzRcaY/1ihi2YbC9vb2Tz755KWzEY2dO3e2trbuZhfSa3Z29pIlS8aMGSMyF0nGSZhF\n        jCxRjTVKHTdHBMmERu/nNG7OSVC4MbCuUVCAyEKEARLJDx2S2ghNIy84a42Ojo7Ozs6urq79+/fjBhYk\n        09bWBpkvX76cELcWSSZLmEg1V+GchOIGaw53zg8ZtwprDjetZ7NeTk77FRcXP3z4EDZC00i/lq3YxRdj\n        aRw5cuTo0aPH2IUbhw8fPnTo0MGDByl3QIfGFyxYIJQJxR5iJlTNUp5h3NRJIG32tMkPS5uPm2Y+yhpD\n        o7Ix0sKwLnIR5eTkfPjhh8+2bMVevgBL4yy7zp07h4+YDs6cOXPq1KkTJ06AO+4DDjrC7IYNGyZOnEgE\n        Pl0iXaMWujnc/6a0KW58fCZr6Vop7vjU1NQPPviAb9kvbHvUeOutt65fv46P165du3r16uXLly9dunT+\n        /HlwB3R0eUCH0kG8u7sbxHNzc0NDQ4UmQskECROl9JNnJ26+tNVdm8+aj5vPuogd0Pmss2TSOKnYW5yY\n        mPjgwYNHjx4h+am3xxeHtcadO3feU6533333nXfeuXnzJtCD+5UrVy5evAjoUDqInzx5EjKHt4B4RUUF\n        eiYyAIkoK1ncYP08rg1qz2kj6qwxyHCgUWAdLxX7iDdu3Hj//n2uPapHkReBtcZHygW/w2GILb537x6g\n        3759m4MOpUPmFy5cgMw54tA4un9kZCTBHSCRrpI+ZT2QtGkgeR4b4XDjBjejq7DGr82USRPIOJOQkIAt\n        p+2RiyIvFGsNqAAHHTwON7CV8DtIA9wp9Lt373JKf/vttzniVONwFfj4jh07IiIihKZCyVSJdL3ytJQK\n        a07anI30G/74oLliv6Q491TIDo3qrH3EmzZtgkSw5VwUeaFYa8DX0LKxWfiI29hEQAd6DjqUDhOkMqfE\n        OY2jhfb09KB5QuBVVVVhYWEiWxEzh3USPmsVG6FjJOaa57FsWvh8NY81F/hY0IQ1PMRbnJycDGXwWSP2\n        vSCsNXC3cwsJCQanAp0qncqcTxyughYKH+cEfvz48YKCghkzZoi9xMxS5lmsn23ZKpRpUdY4DnA09Msa\n        vdFDnJGRAdZc7HtxWGvQjcBCKsJtxH4kJEDH9nHQ4XrYaCpzSpy6Chop31IgcOonSUlJxLgnS6Qb2EcS\n        ONZ9LZs8fPOc7ZGCpmYN1jgaMMhwIYRjHSMVOYvy8vLef//9F421Bv4wXdgIrH6hQ+l84pzGqY9D4Ldu\n        3bpx4waCCsWNXIixfunSpSInETltMjBrNLc+7ZEPGvUM1jRc01+CYkGjkDhFdqLy8vJnsP5NZhkNevfS\n        hS3A6he6OnG4CnYDAZYKHDvG+QmHG6FbqCuUTJLAQ38G1spPEtbw92JeCFGKmrBeyojMRc3NzSqssf2/\n        IWsNxb/KRYljUeIUugpxzlXg41TgaJuIVnBw+IkK7q6uLkRAsQvr2j8Xa5g1WNNwzYUQjnWGjFnACA2E\n        Bw4c4Fir55BfmbUqaP7iiFPofOJwFb7AsRvUwVVwUzNB+s7OzhaOEjJBjAK0OmvEvudhrfwMAa0eQiho\n        yjqIEUgEuKdfENbPAs2tfomrCJzvJ3zc8G60SkyYLS0tmN3F48Qka3Ogfyxr3mcIa3wnQkiBsjHyRI0/\n        IZkoiYqKQrvGltDMhy2kcyM2HruAffnVWD8XaG5xxPsVOPUT7AynburdaJVIJpcvX0YKjI2NRTBgIlhp\n        q7PmPEQlh3CK7pc1QgjXGDnW6TJpolQ8WpySkqLOGvr4lVn/ONB0cbixgJsTOB83NRN4N22VNAhS487J\n        yRGaC5m5DAE9EGv4L0DzZ/T+QCvMWqUx0l/Iilq6RiqyJyEEdzYmANz36Cj03BNljY0Ha7pHit37ZdZP\n        Ac0tDjffTzjc1LuxY0gmCILYT+okmHHq6upIGgmUPAXNZ50nU+Tr5xC1gjXfrHmiRjHhjNBI2NHRgb+O\n        uxypFAoAazQYbCq2GVuOXXihQdPFqqGPn1Dc1LtpMsExiz2EcSN0U2l3dnbOmzdPMkGCA/wpawqam2XY\n        GV0BlA+6L2sCul+zZkVNWKMxCgTwLsoadzx6CXSALfzVWP8MoOlSx821Ss644SQIAJD27du3IW0E7RUr\n        VojHiskASUFzoqYzOsyXa4wqoFHqrPlmTX8hCxqxEk04Pj4erQImhvsbW6ISrn9ps/7ZQNNFWWNR1hQ3\n        30lUpI38t379erGXWBqrxnqr8jwf9+xhFdAojrV6su4ravx+kYOorKwMdzD+NKwMW8IFvl+hMf7MoOlS\n        kTbnJNgrOAkOW07aOJahssTERLGrmIlmFKwpaI41/HcgUaOUrAloLllTA6G/TSlqZjEj1BceOnQIAZ8L\n        1/wQgq3FNr9MoLGwuSq4qZOgBUHa1LVp/sOxjD1PT08nsW81y5oTNQohhG/W3KMBaqAVrKmB5PMMhIqa\n        Pd8imSbBmIpcj4OJH0J+hcb4S4Gmi8OtLm3q2jSQUBvB9EhOQoE1QKuYNVhXsAYCsj/ImqY9voEoRS3d\n        LBW7i5Ev0Y25EMI1xl/UrH9Z0HRR1nxpU9fm2wgGCkRdwhq6hofwRa1iIBS0Cm6ONcxa3UB4omaWkbTX\n        1tZ2/fp19GSVxsiZ9UsJGosIu6+0qY1g92iHpHMNVJaZmSl2E0vXSZ+CRvGnGGB9JmuFgaCL8hOIUtSy\n        NPJSsCVLlmB0oo2xX7P+2UX9K4Gmi7LmpA0bgYiojcArcRSDNVSWmppKckg8jzUMhCZrGAhogi997kd/\n        oBWsYSBIIHSEAWjKmhW1dJMUvXfr1q0YnWBZOJhg1r/0FPOrgsZSYc23EewqTX5ojxs3bhT7ismTiTnW\n        XNqjBsI9p6lf1pyBYIShP04NhAUNUZNxUU948OBB5Ev+FPPLGcivDRoLW09x822Es2yuPUZHR0smSp6C\n        huEqDYR0RSrqgVkrDIQ7B8J1RRY0MZAJktWrV1+8eJFOMVyy/oUM5DcATRdlDdVwrGnyo+0Ruw2thYeH\n        S2byWEPUynGR0ARi+gRUvocoQStYw9ZVuqJS1GSEsRZVVlZiNKfJGn3il0t7vxloLI419gesueRHUzZY\n        nz59WqgrZBYwCtBU1DAQ2hUBl3uyb3+sFaKG29BYrSZqZjYze/bsc+fOIVkj83Bp75cwkN8SNBafNfZK\n        nTVymNBCSJ51RllTUXNdEZTpqwWeYSAqXZGKmj4VIlmGWI1ZCQaCtPeLGshvDBrrB1lXVFSIXEWKEMKJ\n        msZq8KUvzlBhrQT9tCvyZ0VO1KnsXC4jcznSnoqB/LwjzG8PGgv7gMWxxu6psE5OThb7ixWg1UXNveKo\n        P9YKA0FX7FfUqTLEm/Xr1/MNBA2ZP8Jgq/59A3khQGNR1hBOv6yx80uXLoWlElLgxT1ZkoqagqasBzIQ\n        Oiv2K+pI8tKY1tZWlQRCR5ifqyu+KKCxnsEaOeTkyZNCYyGzgiGgqXtw8QOIm9iCjTxb1PQESF/QshSZ\n        JECycuXKnp4eJBB6vok7BwJRcwbyioDGUmHN+TXN17W1tWQ6xxSTy7oHN5RDyPTFz882EBr1+KKm7pEi\n        k66SCk3IlZ7Onz9PzzfRcyBcV/z3Rf1igcbqlzXN11BZQkKCZJqEgMZETgfFSjbnATH/Zc9qoElXhKhL\n        lPOLuqgnSZYtW3bmzJlnd8VXBzQWZc31RrDGBEFn9Bs3bpBkHcEoQLOnqglHmAYotyhZ/6CoaabmgZZG\n        E1HX19efPXv2GV3xJ4v6RQSNxWeNPeRmdEisubkZaQ9oFKC5lgjEO1nW9LoJHGiONSdqdadmX4mDiR+i\n        xpREuyJ3Yo/Oiv+mqF9Q0FjYH8hHhTWSAPY8Pj6emcEQ0LBpuAfXEvnXXunPQFRFzeU8FjRxaiNhY2Nj\n        b28vPbGnPiv+ZFG/uKCxONaQEnYSu4odRoNCNgARHOwENLIH3KOaJQvEu5Ss+00gVNT8TE1bIuseRNT+\n        5Flkp06dunDhAn9WpKKmUe+nifqFBo3FZ42Dl7KGxDAuiseIiagBmjv1QUG3sqxVDERF1PT0KUD3FTWz\n        nBHqCPfu3ase9f5NUb/ooLEoa+yeSmMMDw9nwhkCGjaN7AGa1D12s6y5C2X9oKh5oFHi0eK4uDjEdhr1\n        fi5RvwSgsfisObPu7OwUOYlAioCmNg27YEE/vdjeQKLGj9CzH1xLVLoHE8aMGzfu6NGjiHo/o6hfDtBY\n        2CuuMVIDQfCC9JgQhlgBQMOmafag1++kF5F8hqiL2PPUai0RhfsvMzPz5xX1ywSab9Z0ikHmFVmKMCsS\n        cJxN08sv04ujPkPU2/sOLzzQTBAza9asn1fULw1oLMpaxaxTU1MlMyVPQbM2TUCzF0d9KmoKWsmagC5X\n        5jw195CuI8NLVVUVFbV6/PgJmfplAo3FsYamYNbQFw5tobFQmiQloMGRgqYXW0bBQAYSdSU7vAzQEiXj\n        Sc6DqBE/uEzNDYr8sx+KLfuh9ZKBxgJrFQOBn0pmSBSg2VkcfAnljh8SNcyd3xL57hFOnunb3d1NMzU3\n        KPLPfvwo93gpQfMNBAkEhzaOdGAiEOnYgn4I0F0s64FEzbVEgEZL7OseKJEDuZrksWPH6KBIz36onNJ7\n        fvd4+UBj8Q2EJhA4NTObISg50PBoepH2NqWoOdBK1kTUaIncqY++oCXTJHPnzj106BA9+3Hjxg16Sg8R\n        np6n/lEt8aUEjYV94xvIpUuXED/kW9m3fgBoBA8Kmr7LAxV1vzkPLZGbElXcI4o8nNja2nr8+HHEG/pU\n        mwcPHqAl8h98eU5Rv8SgOQOhIwzJ1IsYolwKGsEDoOm7PLSzosZ9oC5qtERMiZx78ECjxC7kigmHDx+G\n        qOl56oFynmKzBl4vK2gsFVEfOXJE5CwiLZEPupt99xLcgKibBmiJpbxA3dc9mBlMcHDwwYMHT5w4oT68\n        /KiW+HKD5kRNu2JYWBgTw6iCPszqGk7dMnBL5AJ135BHTpzKhDt37lTPeT+2Jb7EoLE41rQrNjQ0SAIk\n        xCUoaLjzIfJWSIR1F/vuMAO1ROoeajaNwjgO90BLRM7jWiJ99umPco+XGzQW9pAaCESN/RfqCuG2itMd\n        FPRR8oZTRNrI1LQlqoOGe9DJhZ734IFG9ggNDT1w4AC/JVL3QEt8/inxpQetImqojwljyMBCrQOgj+np\n        nWDf1quTbYl896CsqXtwk4uKTS8nk0tHRwdaIn3ott8p8dUHjYU95EQN3Yldxbot7LkODvQpwpo4NVpi\n        v+6B7EEnl37dw0qUm5uLKfHkyZPclNhvoFZsUH/rFQHNF/WsWbNkybKnoI/r6Z1mC6JGzhvIPTC50LOm\n        aqAl4yTLly/fv38/nRKvXr3KD9Sce2AbniHqVwE0Fl/U+fn5TAhDhu/9CtD6p/UNTxsSUe9XugcHmrKG\n        e5SxF4vsz6aZuUxAQEBnZycXqLkTp8/vHuRSP4qbL/PiixpHt8hBRIIHRhWAPqFncNrA+IwxcOO/A7qH\n        Ssjj2bQ0ViqUk0fH/x33eEVAY2FHsKtQFvSFKQOHPzHlwwQ05GzWYwbWUPez3IMLeX1Bo3DPpaWlUfeg\n        z7D5se6h8Yw74eVaVNTYW+wzehezgCFyPkI6IRBb9lpa9FgQUVP34INmWStC3kA2HSAJDw+n7qGePZ5n\n        ciGgXxlRY1+oe8BJxW5i8satCNEsaKteK9uztiZnTBTu0e95j3KeTfcFzcwnj9i2tbXx3aPfyWVA0D8Y\n        AF+ihR3hWuL48eMRJGjkgG+AsuM5R+AmLRHj+EAhj2/TPNDSGKmAEbS0tNDJ5dy5c2+99dbt27f55z2e\n        bdMaz7bwl2sBNCfquLg40KGd0LzH3OGcg+t5V7CGX5NxXMWmWdaqNs0DjUKazs7OhnscOXIE7qH+UADu\n        3WfYtMazLfylW5yooT5Mz/ANkIVBO5138rzo6XHBA9DhHuRZH2qgSchDmh6gH4pHi1etWtXe3k4fClA/\n        a/psmyagXzH3gG6wUziuRZYivQPEoK17rSHn0ZdG+1zygbRJ9tjL2rQKaIgaaXpr//2QCWSCgoJg09xZ\n        0+vXr/cb8voHzTnLK8Oac4+pU6fql+jDoO3O2kHL4y6NC7gcgBskeyDkDZSm6Uv11UGHM56ennv37uVC\n        3rVr11Rsmjs9rdgU3tKgzvJKtsT4+Hi9dXrUNyDniVcmTr061feSL9CTkAeb5oNmWRObpv1QLXhI15N+\n        2NTUxIU8+tya57Rpcv3oZ7fLl25hJ7Ev2GFAkQfJkTfgG+ALyjPfmjn5ymS4B7HpgdL0M/qhOXl7tJ9m\n        0xrPeU7k5VrYF0gHwYBxYoAVdjH+8vjAa4Eh10PAGv+FTZMnjP1gP+wLGtkcYYZv0/xZ/NlpWoO7H/r9\n        8ku6sCOQFQ5kgUjgsMfB+6I3fGP29dkLbyyc+/ZcmDUyH3kcQP3sEu2HmA/7A435MCwsbN++fZxNP3+a\n        1kC75H/51WBNQUM9oaGhdoV2IDv92vT5N+Yve2fZkneWTLs6jYS8TrYf8kGzrNEPSfAAaPTDvgmPmc1M\n        mTJlz549NE3TRxHVT3r0D5rv4q9SS6TusXnzZus4a8g5+Hpw+Dvhq99djQp9O5TY9IEB+iHmQwQPmvBU\n        QC9h3N3dd+/e3dHRwdm0ysO1A/VDDfUTfa+MqLE7dXV15nPNIed5b89bcWvF+jvr496Lg6i9LnrpHdEj\n        j4s/I3ioJTzpWqmZmdmuXbtg09zDteiHd+/e/cF+qEE1/+qJGnuBfQELo7FGkPOim4tibsckvp+YfDc5\n        +t1oBGpM52Q+7Bc0fVhLLeHJkmVCXWFlZeVAYwvXD/sB/fDhw3/n+dUv7MIuYEfQpuTm8rnX5i5/Zzm0\n        nH4vPft+dsJ7CUgg6If9Bw+wpglPHTSb8HJyclT64Z07d/hPNKUYVUH3+2QybKLi6y/zwl5ghx0dHUMO\n        h0DF0PK2B9uKPihKv5++4MYCMrYgeKiAZlk/TXjqoJ1EGzduRD/s6uqiz6qhDwJwwWOgfqjBXYzslRQ1\n        9mXy5MkhLSHx78VDy2UflVV9XFX4QWHkO5GYy8kgrpLwKOjSgaO0tzgqKgr9kD8fcqfxqF65uUSxHezS\n        4NIJv2m+Gqyx/Tg6lyxZMqt4Vtq9tOIPi3c82rHz8c7qj6vj7sRhbCGDeL8JD1F6ANA0Sre2tvLnQ5VH\n        W7jgodgOdmnQpklFTTM1vUNega5IQeNID0wNzH2QC767H+/u/Kxz1+Nd4I6hXLd74Cg90MwSKJk5cyYN\n        HvTRlucMHhrcFfZ+3stTvCALu1BYWDhpzaTSj0qbP2k+8PmBo18e7fqsK+9B3pSrU0jCQ5TuFzSdWdRA\n        MyHkqQc7d+7kggf/YS0uVvQDGsrnnsv+M16e4gVZAN3U1DQ+bHztx7Xtn7Uf/+r42W/O4mPlw0pM5OSM\n        R7+gq9gn8vYLOowZPXo0QCN4cA9rPc+JafKes7/E5SlekIWNh+68Z3jDLg5/cRiUaUHdYTfC9E6xM4sK\n        aPY9nMmjtP2CjmCcnZ1bWlr4J6afJ+FpZGdn08tTcE+x5ke9l501thyKcxnnArvo+bqHAw11I3gYnjYk\n        J0v7A02e84gpXA20NEpqbW3d3NzMJTz6JLF+Ty31Ac0w5rh/+K8PfZW6IrYc+2XraktNgys4deztWJMz\n        JmQ4VANNTpYOBHqt1NTUlILmP1D7g6eWNMzMloSGhuJugf7pd9OuSLvni2Yg2IwfXIpvZRf+C6GZWZvx\n        KaOg7s3vb7bosSDPTlehjALoQuV5JRXQcVIDAwOA7jdKPwu0q2u9kVFgbGws7Yowdf71bX5RA8GhgzaC\n        bW1sbMzPz9+0adOKFStwr2PEQMNxcnKysLAwNDSUyWQSiUTILtzAf/FJfAnf4O3tPWnSJPxIZGQkYty2\n        bdt27NiBeIsohV3ANmPhrxiMMuj9updfYI1x3KrXikzhKpRR6IcDgJZtlMnlcjTYfs/hqT+mpdhVFvQO\n        R8c8Pb3RGOFxCHAGgqSiYiD4sZ/MGr8HbQCRKC8vb/Xq1YGBgcBkbjxqrIdryNSJq8Pmpq1ZuT1lY0t+\n        dnd1ydld9Tf2775/vOvx2aN/unz6ydvn//HOpe/fvYzCDfwXn8SX8A032prO1pV0F6S3JK/bHr0kNSx4\n        VWDAHB+3sbaW5ga6GL7xh5YvX/7m8DczdmTUnak78uGRni97SH3Vk3Mvx67HjiiaPb9B6nlAJ8oYhgHo\n        gWaWZ4FG2dhslkqt6+rq6EMG1EBUEsiPMmv8FP489JWQkICEr6cjH+PuGh48Y0tMVMPW9FNNVcD0j3cu\n        /uv2lX+3bvT+6/Kx73u7vj/e+v2hhu87Kr9vLfy+IevvFZvvpq84GRNaP39ilLPxPDdzD1M5I9bynuw9\n        d83cjds3xrTF2B2zk+9krz+B4nCjYB0FA4BOlolEIoBWP1kKgT5jOAToBrZ2WFquEov14Tt8A6EJ5DlH\n        GNyZyJXQ7KJFi3Tl8gAf7zWL5pelbj7RUPXxmUOqgH7GunXxX9dO/evCoe9Pt31/uPn7rqrvdxPW31Ul\n        fVca911B9KN1M55smfckefa9NRO753sVTrKLdBvlbSIaqvWHQT6DhgcPF6wVMAUMCRts6VSxoGm8S2aL\n        xxoOBq9THw77fZRWgYYF3eTq2khxm5qGzZs3D+5ODYTO5c82a9zGn9m+fXt4eLiJkeGsiQHQbHtZwb1j\n        Xao4ftF699K/rvf869KR73s6ibQP1H6/t+T75q3f1aZ9V77x0aa5T3LCWdbBTzZO/9uGSX+L9f/zau/z\n        c83K/WVRjlrehoNHav73IM9BI0JHCBOE9NmO0gypNFUqS1KyVhYFTYdD7jmPUGe/U7gCE0C7uTXzWY8a\n        FYyOxM3lOBa4sZJv1qCPv5GcnIy/OsHHe/PKZftKtj04cUB1/3/NeufCv946rWS9i7BuK/1+V/73OzIf\n        pUc8KV79JHfZk4yFT1LnPNk042/xU/4cM/bxSodHS60eLTJ7tND47Az9ojHixTYj7HRe/6+h/9+w8cO0\n        FmhJNpD3TCOVRIpATyLWAUtEJqZT+LNBc6IkoHmsG52cyg0Np6xfv54bYbi0B9YQOH57XFyckYH+3OmT\n        ixI3XNjToLrDv34BMeR89SQo/+vcwe/PdCj8urPq+7bt3+3M+yQ35kll/JPtMU/yVjzJXkyknTTr2/hJ\n        j6PdH0XaP1rCsl4w6sP5RvfnGb0fatjkL13rqOmjP3jY8P8e4j5Ec7amZJ1Eii4G4hulaIb19fUAzU3h\n        9HkH/NMd/YJu4bEmuB0dCw0M/BMTE+E71KzBGlEGbc1AX2/e9KllqZve7tr93S2SBFT3+WcvNEyi06MK\n        gif3ErUeaf7+UCOp7h3fd9d/f7CO6Be1v+b7rmqWb/n3+7Z/v7vo+10F/2zKebwt5knN5ifl65+URD/J\n        X0FsJH3+t0lBn8aNeQTWK5weLbV5tMgcuias5xrdCTF8d47hO8EGe/xl6x21xugNHjbsv4d6DdWap4Uc\n        jXxZW1uLfoiZhZvC6emOZ5xX0nB3363Gusnefque3pj09HRMmUlJSVpaWlN8x2Stj0bw+utbZ/9+A3nr\n        4j+VkUsVzU+oqydJHwM10GnK/q46mTSxwujvtkZ+l7Xku/Sw71Lnf5cc+l1SyHeJs0ltDmZvzPkuOeS7\n        lLnfpc0n35Ox+LvsZeRHtq38Ln8V+fGitd+VrPtHUezjlEUEcdHqJwVRT/Iin+QufZK16Nu0kE83BXyy\n        Hqw9CesIu0fhlo8WmjycPwq6fi/E8FawwY1ZBteD9K/O1G/wY1bajnSSv/Ffb/x/mpqaW7ZsaWhoQMKj\n        wyEd97jTHfS8kipoT8+Oflmbm6doatrpSqWRc2c3b8t8eKr707NHv7p44s9Xz/zt+rn//TdYkygG0dWn\n        f1cU8136ou82Bf1z3aR/Ro39Z6T3/y7z+HaJ+5/C3b5c7Pr5YtfHi1wfh7k8Wujy8UKXhwtdPlpACjfw\n        X9QnYS746meLXL9Y7Pp1uBt+6q9L3f++zP2fER7/XOFNfuEaf/zmJ2snfxrh82RT4JPEoCcpc56khTxJ\n        C0V9mzLr8Sb/T+J8P4n1eRTt8Wil86Pl9oT1ItOPF4x6EGp0d46C9VtB+ldm6l+coX8hUD/fUzhHb7iV\n        WDMgIACHOBeluSkcRz93uqMPaG/vQyzrPZS1i0ujrW21qWmJqUmRqXGCTOKSFbvq1sE9SBFg/dm5Y19f\n        OvmXaz0ca2ogz2ZN1Lozj+grZS7L1Ac4wAWMwOuDBc735zm/P9fpTqjTu6FO74Q63QxxuhHi9HaI4/U5\n        jm/NcbzWX+Hz+Cq+B4Vvxk+h8OPvzXW6O8/p/nxn/Fr8ctwTn8xzuBto/M0Sx78uc/pbhOvfVnr9LXrM\n        39aO/3PsuE/Wejxa40kUvdr9UZQr0TVYE8s2fzTf+MO5hPWd2YZU12AN0Oem6p3z1z800SzJWW+8gdDL\n        yysmJgZ9i5/w6MxCswMX0gD6KMu608Vll41NtZFRgYV5qb1tpatjHcrOKkVX6p4ZE/Vu9977x/d/fJqw\n        /ubSqR9gjc8caviuctN3aQsI2eVef1niTrECAZhSoADER3l19s9Q3D1B7wbcZ9dmWp+baPROqO2deXZ3\n        59t9sMD+UZjDZ4scvwi3e7TIGPolKoZHwzpo4TbRNWH9Ueio+yFGYA2/VrCepndhgsH1mVbXZlhemWFV\n        5GUUYs7oCTTXrFmDxgj3+Oijj2DTcA/0Q+6MB1gD9HEPj257+z2mpjU2VjWOdrVuTjuUVY+ys0rTl3ul\n        rlp+u3vfgxP7H5059Pn545Q1pmE+6+9O7CH2mjofx+w/lnngcMZRzyeLPf95sT5PnZtmcWKC4aVga9SV\n        2TbX5ti8HWJzM9T2Zqjl5Tn61+cYvDPH8L1QQ/gyHAP98FGYKaEcZv5ogemjecYfzyWs359NbOTtWQZX\n        p+tfnWx0c6bV24S11dWZ1pdnWNX5miy10bWUCmNjY48ePYpBD/MhHT64oVrD0XG/lWWrg91ed5cOT9d9\n        Hi673JwaVFg72GQa6PgmRCy6c6gNrD/pOcxn/fe9pX/PXfG/66f8Y7kn4MI6AReH8C3WBDi4Kvv/q1XP\n        ZLMTE0ddmGVN62IwKUA/F2x2fKbuqUDdnhl652bqXZqlfy3Y4Ca8IsTw3lwj+MbDuaNAGUV1fXe24buw\n        kUCDG1OMb8+yfifI+u0gaxwuV2aAtfWlmTY7/c2jHPTtdMTwbrRHbtADa3iIhqN9p6fbodGeh709ur3c\n        93u5tXm4tLo7N/bFvcPRLs9Qb2L0gpCrbc2U9Wf12V+lhH2zatyfwl0J3HmA60jg8pSrss+/SZ2eaHJq\n        sgkHmqszQaaHZ+gcmqZzZJrO0Wk6J6brnmahXwjSvxSkf32W/s1gA5gG+IIy6t4cwvr2DMM7gab3Z1u/\n        F2zzbrDNjSCb60HWV2faXJ5pc3Gm7YWZtq0TLKMcDe11Jampqch8MGskEODWGO15jK2joz2PeHsc8nI/\n        4OXW7um6x925SYW1s0OZscHMReO9T6wIvLd0zAfznO7MdbgZYv/2bPtrsx2ukb1yuELKEaWyt79hnQwY\n        dWaqqQpl1KmZJoem6xyaqqxpOodZ4sen6Z6crntmmt65QD0kDWQ7OAZ8A9BJBRren2n2YYjN/Tk278+2\n        BetbwTZvz7K5FmR7JciWsA6yOxdk1xJgudzBwEIuLigoQOaDtDnQlPVRsPb2OOjlBhsB6xaWNYvbsc7N\n        psLNcrspM104aHjl6FGnA23OBNr2zLDtnWl7Nsjuwiz7C7McLgU7XCb1ArE+Nt6wZ7q5CmXUyZnGfUDz\n        6vBUnaNTdI5N0T05RfcMYsZ0PeQNEEc/vDHV4P5M84chNh+F2H4QYndvju17c2zfnW17M9juerDdlVl2\n        F4PszgfZnZ1p1xtkVzPOYoGNgT4jQujmg+Zww0YOerl3sZbd6u5Q52Zd7mZR7Gpe5GJe5GxWZCqbLxoq\n        S3TSOTjF+uh0mxOBNqcJbvwBsLZXZ001zhX7VVL4zouzSJ2f5XAuyP5skH3PTFKnUTPsUKdm2J0MtDvB\n        K/wXhc/Tb8B34vt72Z/Fb8A9jd+GX6vcBnJ4HfbVOzvD8vwsaxQf9ImZRv2DnqLTPZnUock6hycT4sf5\n        xCfqvTvD/P5smwdzbD8MsfsgxPZ+iN3dELs7c+xvzWYP7mD7S7PsLpBNsqP7kudjNs1cF6CPs3zpR441\n        bKTby2mfp22jh1WNq0W5s3mJs1mxk1kRLQu9KOkIqwgLSeckq8NTbY5Ptzk1A+q2OzeTsKbSvhTseFmJ\n        lTLF54GD/nnAOh5odyTQ9tB02wPTbDqn2HSw1T7Fml9tk1VL5RvoT+HH90+16Z5GftvRQFvcJbgbyN02\n        w6ZzjE7PTKveIKuzQVbn2KLQj84w7J6mRnmqTjcFPUlRwM0RPzFF99R4navTzNEJbwdbwzruz7F9EGL3\n        INT+Xqj9+6EO74Y43Jjj8NZse+wyOODuP8OKBrtJQfctj2OjnfePtm/ztm31tNnpbtXgalnjYlHhbL7d\n        0azE0ayYrSJbo0Q97dEzDLQrfIy7p9ocg7Rn2J6ZYdcL3MSniMTOBjlAbhTrsUA7PlMwouD2KWvvJOs9\n        bO1+jqLfiR9Bcb+Bf09Q+vsCzJu8dQ5Oszg03eJooMWJGZanZlr2BBHuhwP1Dk6VH5wi7wZctvoFzRXF\n        fcRXfn6q+ZVAy7dmWN2cBdy278+xvRdifz/U4f5ch7tzHe+EON4Kcbg+x+EKYe1AWWP3+4IGYqcDo+3b\n        ve3avGwh572etrvdbXa5WTe5WtW5WFY7mZc59cU9igkSDhYlOunCRo5MswbuY9NQtvh4eBrB2jXVun2y\n        TRu78xQrBUp5tU602jXRaievWiYoqlmtuC+h+D+C34DCr+LuA45+s69xnbfO7klmqL2TzNummHdNteie\n        ZnEk0KJtqk77ZFnnZPn+KfIDU3jEp+gc7A80qQk6h311z06zOD/N4mIgGVjeCrK+Ocv29mzb90Ls7811\n        uDfX8d5cTKdIX45vk9BFjmOwhtSUHq2KmFabh80+D5s97ta73K13ulrtcLGsdbao5OEmxM11V0pH2Cww\n        EdX5me2baLl7kiUiDtlt3CY7jxso61YWK0Wj4Bjws1bfO4Cirx1tUOOj3zLRbOckUrtY4qhdk0zqJjCN\n        /szOAOnuCdK2SbL2SbKuySzxyfKDk1A6tPqADtA54qffO9UCrM9Nt7ww3fLSDKtrSHizbN8JtrsTAvcg\n        oO/Nc8KMdpuMESTjwjbBmgVNjcJuH4fYA2VDQNPicLPSroe0n+I2J7htjdP1hBNGvvHmWjt53Tizen/z\n        hvEWDf4Wjf4WDQGWTQGW5KO/VVMAKVVAv1Cx92WZu071WMOGCaZNqIlmqGYW+o4JhhXjJZV+kio/SfU4\n        yY7xTLM/Ib5voqx9oqxronz/RPlBWnzi/jrHxhkQ0IS15blplucDrS7OsL4SZPPWLLsbwXa35jjcCXV8\n        f67jXbBG/GXnYYwUYK0x2qFtNEEMlyBFEXNFKCvL3Wavu81uNyLtJhfLOmeLakfzSkfzcgezMnuzUpSJ\n        PEI83DLQQJDpYVTua1bpZ17jZ143zqJ+vMWO8ZYN/paN/grcqlB+mcIfyrMXVfuNqvM3rQ8w3RFgCuKN\n        LPRqf73tfpLSsZIyX0m5b1/i46W7/aV7A2TtAbKuCfIDfNzjdI77G/UBPd3qfKD1RQwsQbbXSMKzvzkH\n        LdHxDjEQha7B+vocRw0v292etntQHqBsQ6sPayXodrYIbjebVlfrFmerRifLOkfgtqhyMK9wAHHzchvj\n        bF3hlJFvaIebM2VjzSp8zar9zGv9LOoJbsIa9atJu97PrNCZAWV+UeJl4+VFvuLiMeKSsZLtYxXEK0Dc\n        V1w5VlLjK2nwY3aOk+7xl7UFyDonKAR+wFd+YoJxz1QL1j0s4R4AfSHQ+sIMMhZenmV3dZYdIgeCxzsh\n        ju+GOkLRwE1Za3jY7PSwbYUzsNWHtTtbStBt7qTa3WxQ+1yt97hY7XKxanGybHC0qHcwr3EwB25Fmemt\n        lWq6+khHxNrrQtpVvpC2Rb/S/kVxV/uMKnGXq4CmVeQrLRgrLvQRF40hxREvGysuHyOuYKtqjKTel2ny\n        Y3aPl+71JwLvHCM7OdHkzBRzgO6dZnl2utU5FvTFGTaXZtpeCrK7Emx/NZjMyUgdN+Y4srjJCTWUhpt1\n        ozsynM0uD5vdHGvWJRSgSdm2Aa6bDT6CcoerotpcrPc4W+1yJrgbHS12OFrUOZjXstBr7M0qjaSLhMNM\n        p+hpJ7sYVPqaq0sbuBv8rQrGmKd4msQ4G4XbGQZb6k001RltJHPSZ6x0GGOpWE8ikoqEYqFQKBCgcAP/\n        xSfxJXwDvg3fjB/BD+LH8UvwqwrHmDeyoMs99cu89FQQo2r9TQp8Jfk+4vzRpAp8nhIvQfmIS33EZT7i\n        CtQYceUYSa2vpNGP2eUn3eslPTbR9NRk8zNTFazPBRLrgKIp6Muz7K/MskfYAOu3ZjvQ87SQ8y2ARmdD\n        nHCzbkGvA2t3ND0FaFJEvDZ7Xa1JsbfbXG3aQdnNthPF4XaxbmVxN7ECB/F6WrYm+friWdpD5EFGwgx3\n        I0g7y9NkrZPRQhuDiaZyF33GiBGbmJg4OTn5+fkFBgYuWLAgMjJy3bp1SUlJWVlZeXl527dvr6ioqK6u\n        rmNXbW1tVVVVWVlZYWFhdnZ2SkpKXFxcVFTUokWLZs6cOX78eBcXF1NT01GM2NVA6iEeNsdcstZFP3u0\n        ER905XjD/LFiDjRXwE1qtKh4tKhktHj7aIK7XIm7erSk2Ut+IMD0yESzE5PNT0+x6KGiBmj2jBIHGgn6\n        ajBhjcjBnRbXQHJwtqhClnCzakajc7dpZVnvcVPw3UMpu7DlSlijONZdbFHi+1ysdysFDuJw8AbC3bLR\n        3CiDEUwd9EeBePhQzZEj3N3dp06dunjx4vXr1+fk5FRWVoJdTU0NIALlDnY1sKuxsbFJuZr7Wy3sUvyH\n        t0pKSqKjo0dqj/Se7G3vZT9Se4SFXNvPWLLARp7gZrBtjE6/oEl5iwu8RWBd6C0q9u6L21Nc56nTOs64\n        3d/k4ASzo5PNTxLWVmcDrc/PsAFrgL40y56wZkFD11fZByKQOkgzxNCBfOZsUYGM7GrVCGm7Wu9ytd7N\n        IibFClYBegDW+9mixKnAdztY7rS1aLYybzI3a7Kw2Glt3WpqmiOTBY8caTBt2rTNmzeXlpaWl5cDMdQK\n        xPX19RxZkAK+nTt37mJXa2vrbnbtUa69AyzFl/fswTfHxsY6jXZKrU1FpVSnrExbOXvF7LGBYy2dLcWi\n        1+303phmNmy1g2aeGuh8LxGqgC3gLlLiLnUX13nptfiN2uVnsme8SWeA2aFJ5senWJ4mrG3OzySn7gjo\n        YAKasGZBU9YoChqFMa/MyaLKyXKHs1UzGp2rdSt4sUVZP8WtZA0boaz3u9sdQLnZHnCy2W9n1WFl0WZl\n        1WZj02Fn1+no2OXsvN/JiZSz8wFr6+36+gu0tEwnTZoUHx8PIUPFVL/gC7jAClKgtm/fvra2tnZ2dXR0\n        dLKrS7n2qy3FF7q66HfOmjUrcHFgVnNWVlNWZmNmRkNGxo6M9Pr0LXVbZLGyodOGvu78+v/o/Y+e+DUf\n        w8HhtiMyPYUsaEKZlCcpylqhbhdx3WiDJt9RmDZ3jjNuHW+6L8D0wCTzo1MsT06z7p1hew6siajREgno\n        K0rQtDQcTAsczAodTIvsUWYlDuaVThb1zpaNcAD4wECslbgJa1fbTkfrTnvr/dZWB2xsjjg4HHd2PuHm\n        dtLV9TjKxeWoi8thlLMz+YhydT1ib7/DyGilWOzs4+OzatUquAcQU82CL8V64MCBgwcPdrPr0KFDhw8f\n        PsKuo+w6prbo5+n34JsdHBxicmLy9uZt27Mtd3dubmvu1l1bs3dmR9VGCdOFWrFaWlFaWiu0hgcNH+w9\n        +DWT1xjh/3gbDA63HpHt8RT0U9woR1Gdj9GOsaMafI2b/cDaBKz3+Jt1TrQ4NMXqxDTrHsKanC6GexBd\n        s6fmcRtB8GTAKA170wI7kwJ700I7RRWzibgG9joA66e4naz32VnutbLYZw3Q9t0s3zNubr3u7mfZ6nVz\n        63FzO+3mdsrNDV8iRenjhrv7CReXAxYWKTo6U0aOZObOnUsvdgZtgizFCnwnTpw4efLkqVOnTp8+febM\n        mZ6enl7lOstbik/19uIb8G3on9ZO1iX7S1DFXcVFnUWowo7CgraCaVXTBOkCQZxAe4229mq2orQJ8eDh\n        gz0Gv2bwmr7gtQDDodH2mnzW+e5QtLR2jFHdGMrapNnPpGW8aau/2Z4A87YJlgenWB2bRk4XnwXrIPtL\n        wfYIJKcnmXaP1T3mP+rMZAsNO5N8lK1JAcoO0AnrIjvTUsRh5Ae0NeBGqODjdrbeY2+5x9pij7nZbviD\n        o+NBF5cjLi7HWIigeRqI3d3PeXhcYOs8W4Q7ysPjjLJ62Or19Dzn4FBrbLyKYdypwOmbVIEXwAHi+fPn\n        L168eIldV65cuXr16rVr195SW/gkFr6K70Fumb5wevWJ6urj1VXHqiqPVlYcrag4UlF2qMy50lmUKRIm\n        CIXrhYJ1AkGsQBAj0I5mcS/V0lyg+ab/m2/YvDFo2P+zl74x1/zNTHchQOe5iLa76VT7GNX4jKobO6re\n        17jRz6R5nOlOf7PWAPO9Eyz2TbTsmmJ1ZJoNnOTIRJPucYbdfvonJpj0TEX4c0ABdJ4tKbAmpWRNpG1v\n        hnmvli9tJ6vdtpa7Lc13w4Lhv05OUPEhFPUE1iWAG2olrMHX0/Oip+dlL68r7EfUJRQ+6eXVp7y9L48e\n        fcXL65yd3fZRo5ZKJE4IauhmsG9QA77r16+//fbbN2/efOedd26x6za77vAW/cy77Jo8eXJ8QXzT+abG\n        c42NZxsbzjbU99TXnakrP1luWG0ozhGLkkSijSJRgkgYT4gL1wkF0QLtZdpaYVpa87S0QrVGBo0c6jH0\n        NaPX9IWvTRk1LN5aq8xDr2q0Uc2YUbVjCOh6XxPCerzZLn/z1gkWcJKmMYY7vHSbPOVtvkaHJlicnmbb\n        G2h/bob9+Rn2BLS+eLqtyTa21HE/lba9RZONebO5WYuNTZuDA/obENMioClrmC9bxBlgF2Dt6XkeZL29\n        r3p7v+XtfX30aK7e8vG55uODj09rzJjrY8a8PXbsO6NHX3J0rDI2DpPJ3Dw9PSMiIpCajx8//t57791l\n        17179+6z68GDBx+oLRi6jbMN+O55a8/ua7tbr7W2Xm3ddWVXy6WWtUfXSuukkq0S8RaxOEUsThaLE8Wi\n        zazAY4WC5QLBMoF2mLb2Am2t+Qrib45/8w3TN4Sv//d0I2Gykx6mTbCuG0tAQ9o1ow2qvPTK3WSVbrI6\n        L/3msca7/a3aJ1p3T7Y5NtX21HS7nkD7syxrjWH/85qOwM/KaEt/uIm0rU2KLUzKTIyrrKxaHBzanJxI\n        inB2PsgWAe3iwikadcTN7aib2zHWhU/BHOAMlPXo0W/7+NwcM+bWmDHv0ho7ltYttnDjtq/vHT8/1Ht+\n        fnd9fC6gXFx2WFltNDAIkkis/P39YSzIhbDvDz/88OHDhx+z69GjR5988gn9iJWZmRkSGdJ5u7Pjdkf7\n        u+2kbrXvu7lv3419k7snM7WMJF8iyZJIMiWSDIlki0SSJhEniUVxIuEqoXC5ULBEIFgsECxiiS/U1p6v\n        rTlGE1OVl5eXrtbwyfqCBFtmu5u82JkpdJRsd5VVeurX+Rg3jbNsGWe509+q1d9qT4DVvgDr/ZNsj0yx\n        PTnN7kygPaStkeJqMF5HkxnpbKYXq2StwG1lnG82Kt/IMN/MrMzGptbOrtnBodXREaxhGoS1i0s3S5nK\n        mVP0UXf3Y2wdd3c/6el52sur19v7AswBsoVgKVBf3/dBEzVu3D227rP1gK0Pxo37cOzYG2PH3vTzu+Xn\n        d3vcuPd8fa+5u++0t081M5uvq+umrS1EgIMXY3RE/4SxfM6uL774AiNiRn1G973u7vvd+Hjw7kHU/vf2\n        d93pst1vK62RMkUMk8cwuQyzlSHEsyTiNLFog0i0RiSKEokiRcAtXCYULhFqL9IeOX/kEKshBgYGGDhf\n        f/31YcOGCwa9PkFHM8lBp3q0ce0Y03pfs3pf80Y/C8J6vNUuBWvrvRNsOifaHp5iewKsp9tp5HmZ5HiO\n        mmkoFAwdNUq2mIK2Nt5mZpRrZJhralpsZVVua1vNVo2dXYODQ4uj414npw5n5y4XF7A+5OqKIpTd3Kic\n        FaA9PI6jPD0p6x5v73PwhDFjroKgr++7fn7vs2Q/HD/+o/HjH44f/8jf/1FAAOqTgIDHKEp//PgPAgI+\n        mDDhg0mTPpoy5aPAwIdBQQ+Dgz+eNq3H37/J23uLo+MSc3N/XV0LOzu7gICAiRMnWmPKurGn672u/Xf3\n        H7x3kOBGPejOuJ4h65IBtLREKi2UMvmMJE8izhULs4SCFIHmOs2Rq0YOXz58WPiwIWFD3pj3xushr/9x\n        9h9fn/3G/4j+aGnpNG7czFmzli1ZEh8aGuXpGWAk0JpjKsvzgIeY7fAz3+Fn0TjOonm8FVjvBO4A6z0T\n        COv2iTbdk21hIxpFo03zvAnrxeaM5iCBnmi6mdHWUYZbTU0LLC2329hAy+U2NpUoJe46e/tmR8dWJ6c2\n        lvUBV9duN7fDbAExLQVlCtrLC3XKy+uMt3evj8/5MWMujx37lq/vO7AI0Bw//kMW8eMJEz6bMOGLiRO/\n        mDTpi8mT8fHjyZMfTZ36ybRpnwQGPp458/GsWZ/OmfPp3Lmfzp//aVjYZ0uXfhYZ+fnq1Z/Hxn4eF/d4\n        zZprkZEH7e2D5kaHtd/uarvdue9W+9532nbf2NP6duuu67vGdI15o+KN17Nefz3t9deTSb2R9MagpEGD\n        Ng0avG7I4KjBgyOHDl325rBlw99cPnJEhObICG2t5cKRMwXDho2IiEhYtmxTRMTmyMjkqKjU1avTw8LW\n        entPsJOKIqz1a30J6IZxYG0J1s3+Vjv9rcF6N4u7bYLNgUm2GmVjTYt9COutnsazTZk//Nd/aWqOHjUq\n        ydq6FKUETVjb2lbZ2VXb2UHXtfb29Y6OLU5Oe1xcOlxdD7i5dbu7H3Z3P+LhcdTDA5SPeXoC8QlaLOiT\n        3t6nvL1Pe3v3jB59dsyYC8Dt6/uWn987sAV///v+/g9Z1gTx1KlfBgZ+OWPGpzNnfhocDLifhYR8Nm/e\n        5wsXfrFo0RdLl34REfHFihVfRkd/uW7dlwkJXyYmfrVly9fZ2V9nZn4oYnSL91ceeXj6yEenjjw8dfTj\n        U0cfnTrGlvVxO6ZFLqmQS0rlkhJS4iKZuFAmypWKUqXCjYwwTiJcKxHESARrJILVYpT2KvFIH21XVz/A\n        XbkybdWqtDVrstauzV63buuGDQWbNhUvXrze3X28r4F0k/OohnGWKMLa3xrFsW7xs2oaba1R4WsG1uke\n        xtPN5HpCLRjchAkTBAI7Q8OV1tZltADa1halYG1vX2NvX+vgANaNzs6tLi5tbm5d7u4HwRqgPT0p5eNe\n        XkDMp0xq9OjTbPX4+JxVqvuan9/NcePujB9/PyDg4YQJn06a9CVYz5jx+ezZn4eEfDl//pdhYV8tXvxV\n        RMRXUVHfREd/Exv7TVzcN5s2/Skl5U8ZGX/euvXPhYV/KSv7duXKxolzAo89OnPskzPHH5858bjn5Kc9\n        J/HxcU/SrTTpIR2mQQkatZ1lXSgT58pEKVLRZkYYzwjXM8J1jDCW4YgPt9QKDFy8Zk1GTExWbOzW9evz\n        4uMLN20qSU4uT0urycioz85unD8/Wl8oDLHQK/Exaxxv2QQD8bfe4WtV621V42lV7WFZ62GhUe1nvtrR\n        0E1PguwZFxeXlpaWnJw8b9684cOlOjozLS23saJWsLazq7Szq7K3J6xZ0KgdTk7Nrq573Nw63N0PeHgc\n        8vQ84uV1zMuLgPb2BmJafUD7+Jxhi+AeM+bc2LEXx4694uf39rhx744ff9ff/8MJEz6BgUyf/uWsWV+F\n        hn4dFvZ1ePg3K1b8KTr6T+vW/Sk+/k+JiX/esuXPOTl/KSj4trT026qqvzY2/s3PLzy5MuPkp70nP+s9\n        9fnZ02ydwu3PeidemCpt12HqdZgqHaacrTI5iog6h4KWijYoK05BXLBYMlyoBTmvW7ctLi4/IQEqLklM\n        rEhLq87M3JGT07xtW2t+/t6iorbU1Mrp0xe660qjbUdVeVlWuJMqd7eocDOvckeZacy21NUTC1esWJGb\n        m7t161Zko4yMjC1btqCh+/r6isUexsZrbW3LWEUDdAVY29tXOThUY5xzdKxzcgLoBmfnRheXXW5u+9zd\n        Oz08Dnp5HfbyOurtfdzbm7IGX1pUzk9LSRzeDeLnx4695Ot7lRL3978bEPARBD55MtT9VUgIwR0R8c2q\n        VYQ15JyaSkAXFX1bXv7Xurq/pqaedBnjvf/9I4TyZwrKtNo/6TI5ZSFt1WFqWdAVbBHWOpIiuThTJk6R\n        ihOlogS24tliiWtPFHt4+G/YkA8Vb9xYvHlzWWpqVXp6XXZ2U15ea2FhGyJPWdnBlJQDS5d2Tp3aaWWV\n        POIN7ck68kwHkzJXs3I3RVUCdFBQUFZWVlFREYaC/Pz8vLw8EMfKzs7G5+fPn6+pqaenN9vaOs/ODqDL\n        7e0ButLBocrRscbRsdbJibBmQaOaXF13ubu3eXh0eXp2e3kd8fY+Nnr0idGjT7I1IG5UX40T4kqN34LG\n        AwKg8cewlMBAIvBFi75ZvvybNWuItIF769a/FBd/O2VK/Mq02BOPe0/0VTQq8sYq6SFdpkmHqdZhKtli\n        WRMDyZeLtwC0TJwoE2+k9ZS4pp1w9uxIVsWlyckQck1mZn1OTkt29p74+PYlS7oCAw/4+cEzD8A/nZx2\n        4fgGKIaZaactWm1mUOZqWu5mWuZGPmqUsQtTAAIpVgm7itkF+lhJSUnITAzjYWoaY29f4eAAyqQcHavB\n        2tm51tm5ztkZrBvYF9CBdbObG8Xd6eXVzb6iQB23Kmh+KYn3wlWUMoeP3+DJ/DGVOaAvXkwsZdGiy6Ms\n        7Wp7Wo9+3HvsUe+xT3qPc8Q/O+vS6yFt02F2qIFGS8yVi9NZ0Jtl4k282igTLmVGigToe/HxpdHRFUuX\n        Vs2ZUz1lSr2fX4uHx26kAGfnvc7OuIEAhlzQAMpwVPagL9XXjxQP0QrWl4MyLY0KdtGHOaqrq+nHmpoa\n        7iMWPrl69WptbR19/Rk2NpmYj1FOTtVsEdYuLnUuLvUuLg3QtZJ1i7v7Lg+PfZ6enZ6exExY4seVrFXh\n        9ls8mT+FrlT6O+PHk7gSEPAx7MXMLDVk1fIDD3oPPujt/qC3+8PeQx/1Hn7Ye+Rhb9LNLNFBPcEOHUGF\n        XFgmF5aSEuFjiUyYLxNskQlSZILNMkGCVDuelNYGqWacdOR66dAxIgODSe7uBc7ORXZ2SLq0iIXCPMEU\n        LYrappOTovAZOCq+ikPf1DRJIPAbyzBpdqMIaAqUPozU0NBAHzfiP8CBhdtY5eXlCxYsYBh7E5Mljo7l\n        Tk5Vzs6gzBXB7epaz76Kn7w2lL7My81tp7v7Hk/Pdi+vA97eh/rifl7itPjclQ6DLnrZw+OAVM+0sLOu\n        697prntn9pPqUdT9Ho9jE99skr9ZKnuzQPZmnuzNfNnwPFJv5siGpcmGJkiHxkmHxkiHrpEOiWZ4JXlN\n        X0tHJ9zcPNXcPI2tDEvLLGvrbba2Rba2pax5AjT4tjg773R23sV+RDVB2g4OmDYQ0rZLpbNttYQx5gYa\n        QLxjx47Gxsbm5mb66EZbW1tHR0cX+ygGPfuOj1j4b2dnJxrmtGnTdHXHWlrGOjtXs1Xj4gLKtIi0WdYK\n        J1HipgJvg8C9vA56e/8UgasXRW9ktHrmsrCuuye77p5S1D1F5d2oEnUYDatihhYyQ7cxQ3OZoVtJDcmR\n        DEmXDN4kHhwnHrxWPHg1LRFXbwQK/vCHEcbGG0xM4k1NN5qZJVpYpFlaZlpZ5draltjZlTk41Dg5NYEv\n        rMPVda+r6z5kAfYG8u5OfIlVN8aOcn39ZTpDtTQ4xHv37m1vbwfNQ4cOHT169AS7zpw5c/r06Z6eHnrq\n        HZ85fvw4vpqYmCgS6RgaTrWxSaK4XVyAeyDi5IWLPOK7WeJdrIOThvnvEMd+MromeW1VLGjV8jseOLRZ\n        MnS7eGieeOg28dBc8dCtpIZkiYakiAbHCQfHCgevEQ5erVp/dNASCscbG69Xgk42N99iZZVtY5MPC2Z9\n        Y4eLSwuba9sxRrCTRCebcTvc3PYig7HSxrRRgSNg1KjVGvAEqmJo9vDhw8eOHQPQs2fPXrhw4dKlS5cv\n        X77GnmXHxytXruC/58+f7+3txR0Aya9du1YiMRk1KtjOLl2pbg66Cm7qJxxuSpxYCo/4T9G4gcHK4MjF\n        fLhcVd7aKe00GVojGVrEglZSHpojHpIuGrKJBb1WFTFq0CLBHwQjdHXDjY3jTEwSTE03m5mlWFhAzvCN\n        YogUudbZucXFZTcou7sDMQaIg2wdYEFD3dA1LBtWXmJjk2ttnaGxb98+GEJ3dzd0CtkCMfgC640bN27d\n        uvXuu+/euXPnPXbhBj6Dz4M7oFPicHBkcIaxMDaeY2eX4ewM46b1o4i38lyF83EElR/wcchKz9Sq+EC9\n        CmJaU06GDNvJDC0TD81Xk3OqaPAGVs4xqpRRr4/VHjHC1dh4HawDcjY1TYScWYPOg+2i16EH8uaGA8iy\n        +MhWp7s7DASujVGuwtER3wxDz7OxydGAMOEV8AT4w8WLF69evQqU4Pv+++8/ePCAnvbF+uijj3D7gw8+\n        uH//PiX+9ttvQ+AQPn4QXXTZsmUMYzlq1Bxb2y083D9MnO8q6JweHnt5MlexclXourqLF65bqcKXVs27\n        rfIus6G1kqHF/cl584ByRv2PwUipNFjpG5uUvpFjY1PAujNGB2x2KyIsTbEs37301ccuLki60Du8BSEY\n        JoPEAtDZGrCLkydPUiGDHRDfvXsXiAH3k08++eyzz+h5XroeP3788ccfgzhwQ+McbqgbZlJfX8/iNjUy\n        QgpM7IubloqVD9Q51aGrKJ1wx1Fs7eZe27NbBTEtIuddA8g5TTQ4Xjh4Xf9yfmOKYOhQaypnExPIGb6R\n        amGRwbZBUCN5A3MDpjN2QINNNyt3ATLH5+uxm4hkjo64S0rs7QsB2s4uVwOODEywgps3b0KqIEgRA+tX\n        X331zTff/OlPf/ozu3Dj66+//vLLL0Ef3wCNU3W/8847MBPcT7i38NvQXaOiosRifUPDiZaWa9VYczWQ\n        zNWhE+6svSCVP+UukUxfnbVRhS+tsneaiDv3K+cM0ZBEpZyjVSmjXrPSFIkmsXKOMzWFogE6CZHDyirT\n        xmarrS2aYREIgiPMgc21ZOOVO4L/wlgqnJzw1VKUknW+Bo59ODJgQaFwhkePHoEjEAPrX/7yl7/+9a9/\n        U64nT57gv5Q4cH/66af4ZvzIvXv3cBzgfoLtwHxg3PB6ZJi4uLhx48bp6nqZmS1xcMjtS1mlVKCrKl2d\n        +6hR0WOmT26/fbTz7gmuuhSFsDF92E7JkNIfL+dZ2n8YMhyBDDkBf2LUqBhj41gTk/VmZvEWFpssLdNs\n        bLKgUBgCyxpdsdLJqZK3I7hNimWNrxLcDg7bHRyKNSBGOADsAoZAhQzZgiaY/v3vf6cvr8XCDbo43Pi2\n        L774gpoJrAaeTp0EBwc1bjgSGmxmZuasWbNg30ZGgVZWcbxtGqj6sRcVvWM/RTL9tB3bOu8eV6+st4pE\n        7QZDq0VDioVDtgmHbFXU4Gzh4HTh4EThoDjBoFjBoGjBoNW0tAetUtQfHUdoaXkYGCwxMFhmaLjcyGgl\n        cJuYrDUz22BuvtnSMgX5wdY2x94erAtZ1qUQL7CyfLld4FgrpA3W5ELdcAD4AJDRS/pAyNAvmIIvfXE+\n        1nfswn8pdHzDt99+i2+G9nHfcE6CwwIHx/Xr1znjprgxxMNPBAKhjo67icl8W9tU3mY9u1R6KUEvkwWF\n        rl7SefdYv+V22Hdoo3BIqWBIvmBIrmDIVsGQHFKDswSDUwSDNmgPWqc9aM1TuFy9Ear1h5HD8Mv19ReD\n        taEhWK8YNSrKxGSNmdl6c/ONFhZJ1tZb0Nns7LaxoLezoCllPmgU/cxTaWuADiQJH6B2AbVCsxQxyNJL\n        IPyf8lqV+C/HGnqn0oaPc05C+yRn3Cq4ESKzsrLmzp2LYUdPz8fUdLFaRPnhMjGJcfTxrjvb2vn+MfVa\n        c2HjiH3M0CrhkELBkG18ytqDt2gP3qw9aL3WoLVag1ZrDVqlWq+5DB850klPb6G+fhhlbWQUwYKOMTUl\n        oKFoGxsoeqvSPQBaXc78UrC2sUnVAGWYMt8u1Clzi7LmS7tfJ6HGrYKbjpfHjh1DmsQgmpycHBwcDOK6\n        ut7QuI3NZrWt7KewhyMF0oTSLSp8uTI74DB0h2BIiWBIXl85Z2gPTtYeFKc1KFZr0BpVxKg35mn+QXso\n        w0zT01ugpwfQ4VC0kVGksfEqU1NYBzw60cqKejTkXADbZeVc/gzQ2CnsGroUdlODM2UVu2AV3IcyXfTz\n        fNy4bzgnwa/iUiAfN8yEejdaJZIJ5njEyoMHD2IuBfHQ0FC4ikzmCB+3sFhlb5+jssVc4bieHbVIBS5X\n        M0/PH7ZbOLSCNQ2+nDNZOW96ppxdh48Y4airC8oL9PUXsdYBOa+Eb5iarmPlnGxtnQ6DZuVMfYOT81PQ\n        2HjsAnYEu4OdCgwMjImJKSwsJO+VxTflfoWsvlRYU9yQNn7VM3DTVolkQoMgpiT4CQSO6b+joyM3N3f5\n        8uUBAQFisR6sfNSoWZaWq+3ts7l9gLjcxvkOZBrbrpcyHUZD6wRDivvKOVswOF17cJKScr9yDlWR82JW\n        zstZOcegE1pYbGblnIlEbGfHyVkBGhuJTcUGY7Ox8WPHjl2wYMHmzZu5c861tbUaUCIOf1AeyC4GWkTY\n        ak7yDNy0VdIhHoESuZvzEypwODg9QYgknpaWFh4ejnQoEjEymQMiuYHBTKmeQWpdjgpfrlwOjxnaLBhS\n        ptYDIedU7UEJWoPWaQ2KUUVM6zUnuLMzT87wDch5hbFxNCvnBFbOW2xtFW3Q1jbTwmKticlCQ8MJ2Dxs\n        pI+PD45LJNqioiL+mWcMcfTkqOIdOn8sZW71i5satwpurlUiCNLcTc+ZUIHThgkH5xNva2traWnJzs5e\n        uXKlsbHxssRlbbfb2u50tN/pan/vQMd73R3vHep4/0jn+0cX9EYM2ysaWikYUsSaBkBzPRBy5npgtCpi\n        1OvBI/8wYqhMNoOTs4HBUipn2gZNTVeNGhU+alSInt5kudxLIrEQChlXV9epU6cuWbIkKSmpvLxchSyF\n        y3/1Anlz359MmVvPgxutEsmEBkHkbs5POIFzDs4nDlcBcUz2syNnH/vkGOrIx0cOfXTo4IOD++/v77zb\n        2f5ee961fFm7zqCaoYOKhg7KfXNQzvDBOSMGZ49EDUofOShZc9AGzUGxmoNiNPsixn9J/Y/N0BEj7KTS\n        iQwznmHGSCToXS5CoZ1AYKGtbaCpKdHT07OxsYFmZ86cGRERAU+AbKktAC5HlnvYhIPLvXoBiiHvCw46\n        lJQC209d9Jc8Gzed4Pl+QgVOHRyzJSXOaRyukpKS4jvNt+Viy4lPT5x4TOr44+NP65PjY3rGCNoEmrWa\n        I7aPGF44/M28N4fmDh26dejgzMGDUge9kfDG67Gv/3HNH/8Y9cc/ruhbK//42qTX/t8b/08ikejq6uKg\n        sbKycnR09PLyQqtAKIJ9rVu3Lj09HUdVfn5+cXExfd0N9EsfkKJn8zmyu3bt4l63ALjt7e1QCY5OtH0N\n        KmQsBa1/e9HfpoKbSyY0d9Mxh/rJw4cPOQdXJw7V2LrYFrYXnvz0JIqw5oqFvvjaYvFhsWinSFgjFFYI\n        hWVCYalQuF0oKBYICgSCbIF2irZ2orb2Rm3teFJa8VpPK05ruN1wPz+/xYsXg+nSpUvRjWFT0dHR4JuQ\n        kIBElJGRgS5dUFBQVlZWWVkJxBAvlS3VLJ8sFn1dCIWLPo/jEkcn2r4G5aKA9PMt+mv5uLEobggcuFUE\n        DuKcpXDEsZV6hnrJFcmnPj916jNSJz87SYqFjtp6Z6vxcWPxHrGoXiSqEonKRU9BFwkEuQLtNG0CerOC\n        skqNnDoSngCfhTUB8YoVK1atWoU0tn79+o0bN4JyZmYmKMMoIGTc5RQx+AIuyGJRzdKH/ShZLO5FIbBB\n        HJc4OtH2CWgFm19gqeDmBE79hAocxCFwODhnKZQ4vBsIojOjT39xmtTnpwluWiz0A58ccOlxkXRKxE1i\n        cbVYXCkGaFGZSFQqEpYIhflC8jTRVIEgSSDYJBAkqJZ2pPZwk+Gw3cjISKgYiNesWRMbGxsfH5+YmIjY\n        w72iFEKGEUPC0C+FC7JoHmghVLMIqZQsfcAPUYrCxUGJYQ0dCGOEhgLJL7k43HyBc37COTi1FI74hg0b\n        lsQtOfPlGVJfkFIQZ6GjplycIj0kZXYxkjqJpEoirhCLy8XiMrFou0hUJBJtFQnThMJkoXCzULhRKNgo\n        UJQStOYYTfqSGRgF1tq1a/EXN23ahJYAU+aEDC+Giili8IVsqRugeaCFUM1yZOlrbRClEKhggPS1ILdv\n        38Yx+muA5hZHXEXg6sShppDIkIP3Dire++DLHgVxJfSIGxE6J3Ske6RMA8NUM0wVI6mQSMolkjKJuEQs\n        zhOLMkSiNJEoSSTcJCS1sU9pz9MewYyAXUDCsGPkXzgygtqWLVtycnLQ9yBkeAXaHfobfcya8oVmKVb0\n        D4oVmkVHAVnIlpKF71G4sEH0HnQgHKO/Kmi6ONx8gfOJYycDwwL3vb2v96teVM9X5E0mSCmhp72fZnrK\n        VNYukzZJpXVSCpqpIAXQkkKJJEciTheLUxUvURFt6lPCdUItB61Zs2bBJcAXKgbi1NRU3Lvbtm1DtKio\n        qIBXwIvR3IAYngvxgi91A4qVEyxGMJBFVAXZu3fvgix8j8KFDSLO4ujEMfobgOYWRxy4OeLYw0lzJiHM\n        PX3bFBY3B732Ya3DWQd5l1y2UyarZ5/BXyWVVpJiyhimhGG2MeTFKWkSSbIEoElt7lPak7R9fX0BF+0O\n        fKFiIKZegWiBaAw7RvgFYpgvJHzu3DnwBVy0Dc4KkEopVqpZzGKULLo6yFK4SFbo9uj5OEZ/S9Dc4ojD\n        DQOCAnac2XH267Oop6yVdfiLw6MvjNY5rCNvlcsaZbJamaxGJqsiJa2QSkul0gIpk8Uw6YwkVSJJ7KdE\n        i0Ra+lpwDBgxQgWMgqY3HEYIyPAK2DEiGowCKgZiGC7EC77QLOBSrGCKVEqxUs1iFuPIotMALjwQC90e\n        PR+u+EKApgs68p/hX3eqjlJWKQp68pXJusd0dfbqyJvk8nq5vFYur5HLq+WEdZlMWiRlchgmk2G2MEwK\n        wySplmSDROAiCAsLA18sGEVhYWFJSQm8ggoZHQ9ChhfDKKiK4Qzgy7cCjikWWjfFyieLTkPhwgaRr+CH\n        cMUXBTRGLGi57nQd93ZWiuKxnnN9ju5JXZ12HXlLH8rkXfEqZLISmWybTJollaaTt/WQJvcpJpmAFk0S\n        TZkyBaENiyKGV0DICMjUkREqIGT0OhgxjAIWAcOFeKkVcFhhBRzWgchi0d7Ddv1/vhCgsauTQyYTx1Ch\n        zKvFNxcbnDbQ7dAlb4y3Q/l+3uwbAZH3pt8ul+XLZNnsm6ekqVKmJVkoEegKEJDhxRQxFTJNb5g7YBdw\n        ZMQJCBlGjMwAFUO/1BAAF0wBlDLlY+2XLBYaD9vyyez924PGbs9YNKPlUosKWX6tvLVy1JlRul0s5Ubl\n        m3lzlMvk5I2ABng7XlrSNVKhvXD16tVAXFpaCsRIb2i8oIwxj6OMxIaUBsoQMvwXlKFfqlmKlQLFokzp\n        4rByZLFo48Giu/lbgsYOoCOFrgxtu9mmQpZfMbdjyHt479clbyCmTrmcfWP6HJnira1SVRHTEvmK5s2b\n        B8T0lAWEDLtoYd9oE2MIAhzmDlBG30PTo08IgFFAxdAvRcwBpWsgrFiK3eu7fjPQaC+YFJYlLDv04JAK\n        WX6tu7NOlTJMg1Kukssr5ORd6bcS0+j3jelpSWZIBAIBcgV9yn1NTQ3SBVrfHvZdNkEZAx4cA5Q5LYMy\n        LBj+AFugiClWBUvlUuzMc6zfBjQaupGpUWxOrApWlQJl8x5z3QPPpLyNpQzTGIAys4gRGgkRlrkzyJQy\n        HAMx7hD79m2cL4My1TIoQ8iwCCCmfBWb/lPXbwAau+fk5ZRem66CVaUUjgHKu3V0mpSU6ZsNUsol7Fvw\n        PtuaV0lFdqK1a9fS147Qk5yUMgbr7u7uEydOICwjYyDGISMjwKH1US1TI4aQ/33KWL8qaKgDvWhC8ISy\n        g2UqWFUK3e+pY/SlTN5sEJS3y+V5P9QAE6Rib/HixYs5yrT77WLfIe/AgQM0L1++fBnDNMIyzRjofmh9\n        nCn/LHLG+vVAo8msX79+YczCfdf3qWBVqfCb4SRjqPgyR5kNc+TNdyll9fd2VJYkgLwrPaUM06irq0Na\n        R16m5+GoNXMNED0DYRkxDi365zUNun4l0Bi3bJxsEgoTMN2pYFWpkOshhqcNSZL79ygzMxiBRIDZmm/N\n        iBlogAhzsGYMJufPn7/W3xsK/rymQdcvDhpbj2EX88j2/dtVmKrUkS+PkLf5P6WnmEqeTbnf9ylVFhPK\n        CA0UDRCLhjm+NR8/fhzj3xX2PXbv3r2L2Q+D3y9kGnT9sqBxeCJdrExe2XWnSwWrStU/qve55KN3XE+3\n        vS9lNmP0T3mAyMyEMyIzUXx8PL8BqlgzUjOSDx2ykZphGpitfyHToEtje1HiL1HpqdHTpoz1muCRVpdy\n        9OPDz65NN+ItjpkJ27UEDVra1ZraZZrapZraJZraxaS0Ckdq5Y3U2jpSa8tIzaQRmptHaG4coblhhGZc\n        PzViwZvDjAf7+DiHzJ4UOmfS3NAp8+dODVswfdHCGUvDgyIj5kStmBezeuG6teEJG5YlblyRlrw6c8ua\n        7MzYbTlx+dviC/MSivI3FhdsKincrLJH/2b9IopubW01tzFflbrqB4WMQsCw6LHQPairu0dXp1ntPAZN\n        cs+nZRLmnETLly/ntMw1QEyA1JqRmmHNSM3UmmmeoxMgnU24wUSxMz/T6qPo0uIkWmUlycpKKd+OSkVV\n        lKLSKsrSKsu2oKrK0xVVkVFNKrOmMjM+LsLX121SyIRtu7cee3REtT7pU10POyac9ZccFglbBcJ6bWG1\n        trBcW1imLSzVFm4nJSjWEhRoCXK1BBla2ila2kla2pu1tBO0tOO1BLQSnpZ2pOYI++Hj/EZHrVy8Kip8\n        9aqlMdERsWsjN8RFbUxYk5y4Lj0tPic7qSA/vbQkp7oyv2HH9p3NFXt313a0NR7o2nmoe/eRw3uPH207\n        cbzz1InOM6f2nzl1oOf0wZ4zB3vPdPf2HDrbe/gc6uyR82ePXjh37ML5YxfPH7944cSliycvXzx1+dKp\n        K5dPX7185uqVnmtXet662vvWtbPXr527/ta5t6+ff/v6hZ9N0Qj8qampPpN8UqpSznxxRkW26lX0QZHX\n        Ra9+TFlFy5j9uKlk4O4nXScVe4kXLFjAhTluAkTM4Bpgb28vl5r7teafN2nw18+g6KyM9cFBE8xsTZYn\n        Ltt5pVlVxfxSannRlYVGRw2EbdrCJm1BjbagUilkTstFWoJ8LcFWLe10Te0UTYWW458WX9HaqzRHuAz3\n        9naLWrEoagXkvCR69bK1ayLi1q2M3xCduGltWmpcZsbmvG0pxYWZFWW5dTVFTQ2lu3dV79tT19XRdHD/\n        zsOcnI91nDzRefpk14ul6AcPHhQVFVnaWy7fvLz5QrOKZvut5k+aJ16ZqHdajyRlzNZqpkwCBrRcxp6T\n        o2eLBp79UNL1UvFocUhISEVFBadlGubQKlRiBp1N+Cc0uNNGv5A1c+snKjotOXrWzABDU/15q0PLDm1X\n        Ve4AFXktwuy4iahDIGzWFtRqCSq1BGXaglJtAatiUiXagkItQZ6WIEtLO5XVcqKm9iZNvpZpUUVrRxEt\n        e3k6r4gMW7liMdyZWPOaZetiYc2rNiXEpCSvz0jfmJuTVJifXrY9uwrWXF/SQqy5pn3fjv2dzd0HdkHO\n        Rw/vPXYMcm6HO5862fVCKPrcuXNJSUn2rvYrklY09jaqCHagQkyGkPVP62OwVqSLhgFMGQGDnsVHDXzm\n        EyWNIb4cGhpKtYzFaZlGZvpMAXoKlB8zfunZpN/1vIrOz01YtmS2l6ej02iHFSnL63trjz06rCxV5arU\n        /MtziSO3s46sELKWoFRLsF1LAAmjqCkjYGzVEqQjYMCUNbU3a2pvhJZpqSpae5nmCLs3fXzcVywPo3Je\n        HbVkTfTStTHLYc2bEDOSYrekxudkJeZtS91enFlZvq2+trCpoax1J7HmzvaGg/tbug/sPHKIyBnufPxY\n        28njHb+lopE6MzMz9Q31Zyyakbkj8+hHR1XU+ozacm8LiRYn+zpyXyH3MeVcXsAYICyjmOUM8nJ4eDg/\n        Y/DHv66uLvrQFDb+6tWrdM7+iH2JHz9m/ArWzK0BFb0pYTmGKycHS0cv+yXxi0oOFh19dJhfz1Z04Xv5\n        vj1jmENi4R5tYSOihZaggidkomVS2lxSVjVllXqqZa25I4ebDvP391kesRByZmPG4jWrl8TGLF+/bkVC\n        /OrEzYgZG7IyN27bipiRUV62tbamAKl5V0vFntaajrYGNmm0HDrYCjkfO7L32JF9cOcTx9t/VUVfvHgR\n        QQLG5+ztHL4uvGBfwcnHJ1V0+uza/Xj37OuzySMjh3R125QZmUYLdSGXk6SsOLOMqe+ZpoxiQsl5jOjo\n        aBUtc77MaZmezoeWucj8JftyVf6jU7+Olukiik5NXrU0PMh/vKe5maGDh+3cVSEZDVs6brcpzkX0FTJX\n        6opu+aAp+EIQ7JjkihZtQb2WoEpLUM53ZKWQizS1CzW1t2lpZ/cV8lNTVimiZc2JI95khs4InLA8YkHk\n        8oWw5qiVi6JXLVkbs4xoecOqpM0xqcnrMzM25m5NLirYUsZOgDvqiluaylt3VbfthTVjCGxGcD50cNfR\n        w3tQx4/uY+PzL6/owMBASwfLwIWBcXlxNSdqfvB8cb+179N9C28stDlro3eUPcnZytoxP1dwQuY9EKU4\n        fUFNeeCkjJImSCUBEoFEsGXLFv55DDr70byMjDGQltUfaf01tUyXxrbdW9tu7eVOpPVTalqmReVc+n7J\n        1HOTjY4YCDu0hTu1iIqr+6pYRcgFELKmdramFl/ICSr67VNaSzVHOL3p4my3aGEwq+UFKyPDVhEth69d\n        s2x9LLQclbiJajlhKyJzQVppSXZVxbZ6MgGWwZqVqZnIGUnjcDfnzsgbv5aiVbT5/JV9P3vylcnkkT14\n        cfsPqLiPIz+3kFHMIkZkJ+Ie96Narq+vb2xspA+X0Nnv6NGjyMtcxlDRMndmjjub8SvLGUtDVb/q1VfI\n        ux60hF9eZH/SVtQtEOzREjRqCWo1BVWaRMWchHkqJkKGHUPIuZraWRDySK3kkVqJmlo/JGTUSJiybOjk\n        Sb4RS+dFLJun0HLUoujVS9auiVgfG0m0vDEmNUWp5fy07cVZVRW5dTWFjQ3bdzaV724l1tzV0bC/E0lD\n        IWcU3PnFVXTG/YxpV6dZ9lrqHSO5mAx4LcpE0a+KqR1XKjMyfQIGosVzCJlMfb5igeCpKfPDMj2/3NHR\n        0d3dTc9jICzRZ35yeZlmjBdBy3T9sKIzb6VPPz/V/Jip8KA2kXCTlnatpnY1JKwpKNUUbGerBNVXxTRX\n        5Glq52hqZ2gSFSdByCO1No3UShiptUETpY1SUzFKc/aI4ebDvD2dwxeHRCydq9DyioVEy4qMEZkQv4r4\n        csq6zPQE9lRGamkJtLy1trqgkZxoLt+9q6ptT11H2w7I+UAXDc4kbMCd2WnwxVD0ia9OZN3PQhx2OudE\n        zrR181xYXcJ9VfzUjpErCthnxVE7xrD3zIyMIuliikSoL4yNjeWEzDfl3bt304BBH8bu7e2l5+ToeQz6\n        /FrMfioZ47fVMl19FF30XsGSK4u9T3sYHtEXHlDqt05Tu0pTu0L5UN529tE8ImG2ipU3IORi1o7zWTvO\n        5Ox4pNbmkVoboWJ+9aNozXkjhtu+6exsGxoyfemSkGVLQpcTLc9fuSJs9crFa6Ix+0VsWL9iY/yqpMS1\n        W1LXZ2Vg9ksszN9Suj2rkvgytIzIXAYt79tT276vrpPIGUmjqfsAOa1xuHsXzRu/jaKLPyyOuhWF/OBw\n        zoE8AfmwLvHffexEN5B+n6Hi7XJ5ofI8Mp30YMcDn7WgRYQ8TSI0EkZFRfHTBZeUMfXtU14IEabMBYyb\n        N2/S54o/Yq+5RZ9iq56Xf1st06UhPKAl2KslQARuUIq3nCdepX77FPvgNNEybhSNVHjxVtaLVVQcryJk\n        rp4qWjNkxHCbYY4O1rNnTVkSPgdahi8vj5i3MnIBO/iFx6xZuj52+Ya4lZs3Ricnrd2SFpeduSkvl539\n        tmdWlSu03NxY2rqTROa2vbWw5s72HQc6m9g5sJm682+s6H6Uqy5eWnwJ8xMFjcbUi59bxShEC8x7Qj3h\n        Kvad9tSFjHRBH/FDUj7CvgbtLHshxOvXr8OU7927x4Xlb/pe3uU3mf2evTQGlC2/WAkrisSJkdr5I7Vz\n        R2pnk+daEAmjIGGaKAZUMa/iNEdOGf7mqKFurvZzQ6YTIYfPYU157gqYciQJGGtWh8euXRbHBoykzWtS\n        kxEw4rdmb87fllxcmF62neTl+tqCxnr4cunuXdBy9b499IQGGQJRB4mc4c6KvPFbK1pFtvwaSMKIE5wR\n        c4nih6IxVxj2xO7igICAhIQElWihLuTDhw+fUF43lbsQIkz54+e4stkLtTRUxYvi65c+UahgpFY++1yh\n        rJFaaSO0ktn6YSNWLc2wEcPdhw3TGuLn67F4UXD44tnQ8jKY8rK5kcvmrVi+YNXKsOjVi2Njlq6LXR4P\n        U94UnZK4Np2YcgIbMDD4pVeUZVdXbSNaJhmjtJWcZa5ktQxrJnKmwZlk5xdU0er6RVXI5aVkriOnjDkX\n        5iT8HEZMS7qKtWNDYVhYWGFhIWfHdNhDRqbRAvOeupBpurijvG7qs035BdQyXRp99FukqRAvfa5b5kjN\n        LSM0k0eQZ7wljtDaPEJr0withBFa8SO04kaoqHWg0lw2YsTYN4fpDHFxsZ01a+LiMAg5eMni2UuXzIlg\n        kzJMOWrlwuhVi9ZGL1m3NiI+bsXmjUjKa7akrsvM2LA1exNrymmlJGBg8MvbUVfQ1FCysxkZA+NfJay5\n        bW8NtNzRVt/ZXs+e1iDZ+cVTtIp4ESHgv/SxO06/NEj80FynUkTFEyVCE2FwcHBaWhpVMT1lQe2YnrWg\n        wx4y8sGDB2m0UBcyPX3xed/rpr7gpqyyNLRyR2ohPGSM1ExjlcuKlzxjkz5pM2GEZrziiZpExfxSEy9X\n        IxcMH+41bJh0iJOjdeD08YsWBi0OmxW+KHgphBwesmwpmy4i56+CkFcvXrtmybpYCDlyU0JU8uaYtJTY\n        zPS4nOyNeblJRQUppcXp5WVZNZVba2vyGuoKqZZ3tZTDl6k1t+/FEFgLLbPuTAz6BVW0QrkoKJczX4j3\n        uf2XX0wYIx4tFuoI586dm5mZ2a+KW1paWvu+dwMd9mhGfuuttxAtBhIy0oXKo9cvvpbp0iCy5ZSrFG+/\n        9QxFa64YMWLim8MshhgZ6Xp7Os2ZNTls4UxOyHDkZXDkpaErls9duWLBqqiFayDkmKVxEPKGFZsSWEdO\n        WZuRFrc1a+O23M2F+SklRWnlMOWKnJoqhOX8xvqi5saSnU3QchkiM9UykfO+2o59cGeEjRdf0T9JuVwx\n        4YxkPDHiiRMnxsTEcBKmAx6XKODFnIq72HcVOHr0KLXjCxcu0Es10OsI0IxMo4W6kF/8dDHQ0lCR7TOK\n        L+eRi4cPHzdsmNmQIUMGubrYTp82buG8GWHzZ4QtCFoUFhS+aBaixdLw2cuWzomMmLsyct6qFQtXRy1a\n        uyZ83dqlG9ZHJGwg0SIlMXpLKufImwvykkuKtpRtz6gsz66u3FoPU64vbNpBtbydaHknsea9u2lqrkG9\n        VIpWE+kzCkGCmcGIXcRCGbmObFxcHH+0oxLmjBi5mD6m19HRQb2YqvjMmTPnz5+/fPky344//PBD+iJ3\n        7joCNFq87ELm1nMpeuSCN4l+LYYM1RxsbWXiO8ZtTvCkBfMCF8wPXDg/kNhx2EyoeGk4UXHEspDIiNAV\n        kfOiVixYHRUWE70oNmbJhnVsQE6IStq8OjU5Jj11XVbGhtychLxczHsQclrZ9i0VpVnVFTl1Ndsa6vIb\n        dxRAyy1NVMul0PLuXeV7iZyr9u1BvUKKlsZKmbmMZJxEZCUSCAT0OshF7DU5IV6qXwQJzoU5Ce9TXhmO\n        Xrns+PHjSBS9vb3Ui69fv05VfO/evQ8++IDaMc0V9CE+DHvqGfnlFTK3+ih6ZMTwETOHDfceCvMdqjXY\n        2FjPxdlmQoD3vNCp8+dOWzBv2oL50xcuCFyklPCSxUTFMOLlS6Fi1otXLohetTAmevG6tUviYpex6XhF\n        0uZVKUmY9GKz0tfnZMXn5mws2JZYVJBcWgwhp1eWZVVX5tRWs6bMarm5Ab5cvLOpBFpuhZx3le8hSaPi\n        5VY0YgMTSMIvUS4j+MHrIMN/aYrg9EvnOrhwd3c3lfAp9uJwMGLk4mvKd4N677334MXqKv4L+yYkfDt+\n        lYTMLQ19XamVpbGHu92EAK+Q4Enz2BfmKcRLCvqdAf0uDpu5ZHHQEjZLREDCy0IQiqNWQMLzWQmTRLE+\n        lk0U8cs3b1wJFacSFa/NSl+XnRnH2vHmovykksKU7cWp5SRaZLJCzq2vQVLOa6xHWC6ElluaiJZ3NpdA\n        y607kTQQnF8JRUOwfM1i0dhAlQvnpREY4kUKhnjhv9DvAfbKnNAvhjoECc6FOQlzRoxcjAGPXlyLRmNO\n        xfx0/EqqmL80FsyfBuWGLUAR8S5eSMQbvgjiZf13CfQ7m9Vv6MrIuatWzotetWDNKpolwuNil8SvXwYJ\n        w4gTN0WlJK1OS1mTnrY2M319dlZcbnZCfu6mwnzYcdL2otTSEuSKjKpyOHJ2bRUx5R2123bAlOvzmxqg\n        ZSJnquVdzUga2181RVO3hWZ3P991kCFeBOFz585R/V69ehVDHfT77rvvci788OFDhGJqxF+xb7iFXMwl\n        iv8cFfOXxtLwWcuWoIKXL5sdGYFBLmRlZGjUirmrqP+S8xJha9dAv4vj1i3ZsH5p/IaITfGRiRtXJpMs\n        sSotJXoLJLwlNjsDEt6wbWtC/raNBXmbiwqh4pRSYsdbKsvI62qrK7Ig5LrqrXU1udByQz3ryyRjFDY3\n        FrWQUrjzq6loCBZuSzX7PNdBvnnzJiLE7du332evH0ktmAYJ7hJ8cGEqYRUj/k9TMX9prI5CbJi/ZvWC\n        mOiFsWvC1q1dtH6tUrxxyzbGR27eGJm4aUXy5qhU6DcZ+o3J2EKyRA5x4bhtOfF5ucjFmwrzEoupikuI\n        iivIq2vhyBk1lVk1ldl11TlIFztqiZZ31G1jtZzfhPGPuvN/gqJhtRd/zHWQIV5ECL5+YcFckFBx4f9k\n        CassjY0blm1KiNicsDxxY2TSJkxxMF9WvDDf1DXpqTGZ6WuzMmJzMtdtzVrPuvCG/NyEgm0bi/I3Fxcg\n        FydtL04pK0GlkdfVlqZXlqdXwZErM2urkC6IllFUyw11qDylO/+HKRpW+6Oug8z3X75+qYSh398l3O/S\n        SE+NzkiLztiyJnPLmqz0tdkZyA+xrHjhv8SCqX4L8jYVF0DCiSXkFYlJpcXkRbVlxI5TWTveAjumV+1Q\n        aLlaoeX6mq2o3xVN3v0Ni7otNEsnNypb2C6nXIQHFfFy/vu7fp9naeQS2cblbd2Ays+NL9iWUMBeV4gt\n        ouKSQhTiBH2BeErZ9hTWixVX7SBa5l2BhmSMKuTl3xWtpmi+YKlmVWSLpaJcLMXd9Pt67qVRmLcRRSXM\n        ipcU73XhimscoJ7nmkq/K3pARbMxQSFYLIVi2aW4L35fP8fS4CSscnUDZfV/BZrfFf2jFa0A/vv6hdfP\n        cJWw3xX9u6JfoPW7on9X9Ku1flf074p+tdbviv5d0a/S+r//+/8BPTxUq6Ub7iwAAAAASUVORK5CYII=\n</value>\n  </data>\n  <data name=\"textBoxDescription.Text\" xml:space=\"preserve\">\n    <value>Pyramid is a simple, cheap, free shader analysis tool. It is distributed under the GNU GPL.  Third party components included with Pyramid (FXC, CodeXL, AMD DXX Driver,\n PowerVR compilers) are the property of their respective owners and are provided solely for convenience.   \nICSharpCode.TextEditor was originally written for SharpDevelop, and is distributed under the LGPL.</value>\n  </data>\n</root>"
  },
  {
    "path": "src/MainUI/MainForm.Designer.cs",
    "content": "﻿\nnamespace Pyramid\n{\n    partial class MainForm\n    {\n        /// <summary>\n        /// Required designer variable.\n        /// </summary>\n        private System.ComponentModel.IContainer components = null;\n\n        /// <summary>\n        /// Clean up any resources being used.\n        /// </summary>\n        /// <param name=\"disposing\">true if managed resources should be disposed; otherwise, false.</param>\n        protected override void Dispose(bool disposing)\n        {\n            if (disposing && (components != null))\n            {\n                components.Dispose();\n            }\n            base.Dispose(disposing);\n        }\n\n        #region Windows Form Designer generated code\n\n        /// <summary>\n        /// Required method for Designer support - do not modify\n        /// the contents of this method with the code editor.\n        /// </summary>\n        private void InitializeComponent()\n        {\n            this.menuStrip1 = new System.Windows.Forms.MenuStrip();\n            this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();\n            this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();\n            this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();\n            this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();\n            this.saveAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();\n            this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();\n            this.toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();\n            this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();\n            this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();\n            this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();\n            this.splitContainer1 = new System.Windows.Forms.SplitContainer();\n            this.txtCode = new ICSharpCode.TextEditor.TextEditorControl();\n            this.splitContainer2 = new System.Windows.Forms.SplitContainer();\n            this.splitContainer3 = new System.Windows.Forms.SplitContainer();\n            this.CompilePanel = new System.Windows.Forms.Panel();\n            this.cmbLanguage = new System.Windows.Forms.ComboBox();\n            this.btnCompile = new System.Windows.Forms.Button();\n            this.AnalysisPanel = new System.Windows.Forms.Panel();\n            this.BackendPanel = new System.Windows.Forms.Panel();\n            this.cmbBackend = new System.Windows.Forms.ComboBox();\n            this.menuStrip1.SuspendLayout();\n            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();\n            this.splitContainer1.Panel1.SuspendLayout();\n            this.splitContainer1.Panel2.SuspendLayout();\n            this.splitContainer1.SuspendLayout();\n            ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();\n            this.splitContainer2.Panel1.SuspendLayout();\n            this.splitContainer2.Panel2.SuspendLayout();\n            this.splitContainer2.SuspendLayout();\n            ((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).BeginInit();\n            this.splitContainer3.Panel1.SuspendLayout();\n            this.splitContainer3.Panel2.SuspendLayout();\n            this.splitContainer3.SuspendLayout();\n            this.SuspendLayout();\n            // \n            // menuStrip1\n            // \n            this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {\n            this.fileToolStripMenuItem,\n            this.toolsToolStripMenuItem,\n            this.helpToolStripMenuItem});\n            this.menuStrip1.Location = new System.Drawing.Point(0, 0);\n            this.menuStrip1.Name = \"menuStrip1\";\n            this.menuStrip1.Size = new System.Drawing.Size(784, 24);\n            this.menuStrip1.TabIndex = 0;\n            this.menuStrip1.Text = \"menuStrip1\";\n            // \n            // fileToolStripMenuItem\n            // \n            this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {\n            this.newToolStripMenuItem,\n            this.openToolStripMenuItem,\n            this.saveToolStripMenuItem,\n            this.saveAsToolStripMenuItem,\n            this.exitToolStripMenuItem});\n            this.fileToolStripMenuItem.Name = \"fileToolStripMenuItem\";\n            this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);\n            this.fileToolStripMenuItem.Text = \"File\";\n            // \n            // newToolStripMenuItem\n            // \n            this.newToolStripMenuItem.Name = \"newToolStripMenuItem\";\n            this.newToolStripMenuItem.Size = new System.Drawing.Size(152, 22);\n            this.newToolStripMenuItem.Text = \"New\";\n            this.newToolStripMenuItem.Click += new System.EventHandler(this.newToolStripMenuItem_Click);\n            // \n            // openToolStripMenuItem\n            // \n            this.openToolStripMenuItem.Name = \"openToolStripMenuItem\";\n            this.openToolStripMenuItem.Size = new System.Drawing.Size(152, 22);\n            this.openToolStripMenuItem.Text = \"Open\";\n            this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click);\n            // \n            // saveToolStripMenuItem\n            // \n            this.saveToolStripMenuItem.Name = \"saveToolStripMenuItem\";\n            this.saveToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));\n            this.saveToolStripMenuItem.Size = new System.Drawing.Size(152, 22);\n            this.saveToolStripMenuItem.Text = \"&Save\";\n            this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);\n            // \n            // saveAsToolStripMenuItem\n            // \n            this.saveAsToolStripMenuItem.Name = \"saveAsToolStripMenuItem\";\n            this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(152, 22);\n            this.saveAsToolStripMenuItem.Text = \"Save As\";\n            this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.saveAsToolStripMenuItem_Click);\n            // \n            // exitToolStripMenuItem\n            // \n            this.exitToolStripMenuItem.Name = \"exitToolStripMenuItem\";\n            this.exitToolStripMenuItem.Size = new System.Drawing.Size(152, 22);\n            this.exitToolStripMenuItem.Text = \"Exit\";\n            this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);\n            // \n            // toolsToolStripMenuItem\n            // \n            this.toolsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {\n            this.optionsToolStripMenuItem});\n            this.toolsToolStripMenuItem.Name = \"toolsToolStripMenuItem\";\n            this.toolsToolStripMenuItem.Size = new System.Drawing.Size(48, 20);\n            this.toolsToolStripMenuItem.Text = \"Tools\";\n            // \n            // optionsToolStripMenuItem\n            // \n            this.optionsToolStripMenuItem.Name = \"optionsToolStripMenuItem\";\n            this.optionsToolStripMenuItem.Size = new System.Drawing.Size(116, 22);\n            this.optionsToolStripMenuItem.Text = \"Options\";\n            this.optionsToolStripMenuItem.Click += new System.EventHandler(this.optionsToolStripMenuItem_Click);\n            // \n            // helpToolStripMenuItem\n            // \n            this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {\n            this.aboutToolStripMenuItem});\n            this.helpToolStripMenuItem.Name = \"helpToolStripMenuItem\";\n            this.helpToolStripMenuItem.Size = new System.Drawing.Size(44, 20);\n            this.helpToolStripMenuItem.Text = \"Help\";\n            // \n            // aboutToolStripMenuItem\n            // \n            this.aboutToolStripMenuItem.Name = \"aboutToolStripMenuItem\";\n            this.aboutToolStripMenuItem.Size = new System.Drawing.Size(107, 22);\n            this.aboutToolStripMenuItem.Text = \"About\";\n            this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click);\n            // \n            // splitContainer1\n            // \n            this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;\n            this.splitContainer1.Location = new System.Drawing.Point(0, 24);\n            this.splitContainer1.Name = \"splitContainer1\";\n            // \n            // splitContainer1.Panel1\n            // \n            this.splitContainer1.Panel1.Controls.Add(this.txtCode);\n            // \n            // splitContainer1.Panel2\n            // \n            this.splitContainer1.Panel2.Controls.Add(this.splitContainer2);\n            this.splitContainer1.Size = new System.Drawing.Size(784, 537);\n            this.splitContainer1.SplitterDistance = 254;\n            this.splitContainer1.TabIndex = 1;\n            // \n            // txtCode\n            // \n            this.txtCode.AllowDrop = true;\n            this.txtCode.Dock = System.Windows.Forms.DockStyle.Fill;\n            this.txtCode.EnableFolding = false;\n            this.txtCode.IsReadOnly = false;\n            this.txtCode.Location = new System.Drawing.Point(0, 0);\n            this.txtCode.Name = \"txtCode\";\n            this.txtCode.Size = new System.Drawing.Size(254, 537);\n            this.txtCode.TabIndex = 2;\n            this.txtCode.Text = \"float4 main() : SV_TARGET { return 0; }\\r\\n\";\n            // \n            // splitContainer2\n            // \n            this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;\n            this.splitContainer2.Location = new System.Drawing.Point(0, 0);\n            this.splitContainer2.Name = \"splitContainer2\";\n            // \n            // splitContainer2.Panel1\n            // \n            this.splitContainer2.Panel1.Controls.Add(this.splitContainer3);\n            // \n            // splitContainer2.Panel2\n            // \n            this.splitContainer2.Panel2.Controls.Add(this.BackendPanel);\n            this.splitContainer2.Panel2.Controls.Add(this.cmbBackend);\n            this.splitContainer2.Size = new System.Drawing.Size(526, 537);\n            this.splitContainer2.SplitterDistance = 201;\n            this.splitContainer2.TabIndex = 0;\n            // \n            // splitContainer3\n            // \n            this.splitContainer3.Dock = System.Windows.Forms.DockStyle.Fill;\n            this.splitContainer3.Location = new System.Drawing.Point(0, 0);\n            this.splitContainer3.Name = \"splitContainer3\";\n            this.splitContainer3.Orientation = System.Windows.Forms.Orientation.Horizontal;\n            // \n            // splitContainer3.Panel1\n            // \n            this.splitContainer3.Panel1.Controls.Add(this.CompilePanel);\n            this.splitContainer3.Panel1.Controls.Add(this.cmbLanguage);\n            this.splitContainer3.Panel1.Controls.Add(this.btnCompile);\n            // \n            // splitContainer3.Panel2\n            // \n            this.splitContainer3.Panel2.Controls.Add(this.AnalysisPanel);\n            this.splitContainer3.Size = new System.Drawing.Size(201, 537);\n            this.splitContainer3.SplitterDistance = 288;\n            this.splitContainer3.TabIndex = 0;\n            // \n            // CompilePanel\n            // \n            this.CompilePanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)\n            | System.Windows.Forms.AnchorStyles.Left)\n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.CompilePanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;\n            this.CompilePanel.Location = new System.Drawing.Point(4, 68);\n            this.CompilePanel.Name = \"CompilePanel\";\n            this.CompilePanel.Size = new System.Drawing.Size(194, 217);\n            this.CompilePanel.TabIndex = 2;\n            // \n            // cmbLanguage\n            // \n            this.cmbLanguage.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)\n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.cmbLanguage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\n            this.cmbLanguage.FormattingEnabled = true;\n            this.cmbLanguage.Location = new System.Drawing.Point(3, 45);\n            this.cmbLanguage.Name = \"cmbLanguage\";\n            this.cmbLanguage.Size = new System.Drawing.Size(195, 21);\n            this.cmbLanguage.TabIndex = 1;\n            this.cmbLanguage.SelectedIndexChanged += new System.EventHandler(this.cmbLanguage_SelectedIndexChanged);\n            // \n            // btnCompile\n            // \n            this.btnCompile.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)\n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.btnCompile.Location = new System.Drawing.Point(2, 3);\n            this.btnCompile.Name = \"btnCompile\";\n            this.btnCompile.Size = new System.Drawing.Size(196, 41);\n            this.btnCompile.TabIndex = 0;\n            this.btnCompile.Text = \"COMPILE\";\n            this.btnCompile.UseVisualStyleBackColor = true;\n            this.btnCompile.Click += new System.EventHandler(this.btnCompile_Click);\n            // \n            // AnalysisPanel\n            // \n            this.AnalysisPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;\n            this.AnalysisPanel.Dock = System.Windows.Forms.DockStyle.Fill;\n            this.AnalysisPanel.Location = new System.Drawing.Point(0, 0);\n            this.AnalysisPanel.Name = \"AnalysisPanel\";\n            this.AnalysisPanel.Size = new System.Drawing.Size(201, 245);\n            this.AnalysisPanel.TabIndex = 0;\n            // \n            // BackendPanel\n            // \n            this.BackendPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)\n            | System.Windows.Forms.AnchorStyles.Left)\n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.BackendPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;\n            this.BackendPanel.Location = new System.Drawing.Point(2, 30);\n            this.BackendPanel.Name = \"BackendPanel\";\n            this.BackendPanel.Size = new System.Drawing.Size(316, 504);\n            this.BackendPanel.TabIndex = 1;\n            // \n            // cmbBackend\n            // \n            this.cmbBackend.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)\n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.cmbBackend.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\n            this.cmbBackend.FormattingEnabled = true;\n            this.cmbBackend.Location = new System.Drawing.Point(2, 3);\n            this.cmbBackend.Name = \"cmbBackend\";\n            this.cmbBackend.Size = new System.Drawing.Size(316, 21);\n            this.cmbBackend.TabIndex = 0;\n            this.cmbBackend.SelectedIndexChanged += new System.EventHandler(this.cmbBackend_SelectedIndexChanged);\n            // \n            // MainForm\n            // \n            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\n            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\n            this.ClientSize = new System.Drawing.Size(784, 561);\n            this.Controls.Add(this.splitContainer1);\n            this.Controls.Add(this.menuStrip1);\n            this.Name = \"MainForm\";\n            this.Text = \"Pyramid\";\n            this.menuStrip1.ResumeLayout(false);\n            this.menuStrip1.PerformLayout();\n            this.splitContainer1.Panel1.ResumeLayout(false);\n            this.splitContainer1.Panel2.ResumeLayout(false);\n            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();\n            this.splitContainer1.ResumeLayout(false);\n            this.splitContainer2.Panel1.ResumeLayout(false);\n            this.splitContainer2.Panel2.ResumeLayout(false);\n            ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();\n            this.splitContainer2.ResumeLayout(false);\n            this.splitContainer3.Panel1.ResumeLayout(false);\n            this.splitContainer3.Panel2.ResumeLayout(false);\n            ((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).EndInit();\n            this.splitContainer3.ResumeLayout(false);\n            this.ResumeLayout(false);\n            this.PerformLayout();\n\n        }\n\n        #endregion\n\n        private System.Windows.Forms.MenuStrip menuStrip1;\n        private System.Windows.Forms.SplitContainer splitContainer1;\n        private System.Windows.Forms.SplitContainer splitContainer2;\n        private System.Windows.Forms.SplitContainer splitContainer3;\n        private System.Windows.Forms.Panel BackendPanel;\n        private System.Windows.Forms.ComboBox cmbBackend;\n        private System.Windows.Forms.Panel AnalysisPanel;\n        private System.Windows.Forms.ComboBox cmbLanguage;\n        private System.Windows.Forms.Button btnCompile;\n        private System.Windows.Forms.Panel CompilePanel;\n        private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;\n        private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem;\n        private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem;\n        private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem;\n        private System.Windows.Forms.ToolStripMenuItem saveAsToolStripMenuItem;\n        private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;\n        private System.Windows.Forms.ToolStripMenuItem toolsToolStripMenuItem;\n        private System.Windows.Forms.ToolStripMenuItem optionsToolStripMenuItem;\n        private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem;\n        private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;\n        private ICSharpCode.TextEditor.TextEditorControl txtCode;\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n    }\n}\n"
  },
  {
    "path": "src/MainUI/MainForm.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Data;\nusing System.Drawing;\nusing System.Text;\nusing System.Windows.Forms;\nusing System.IO;\n\nnamespace Pyramid\n{\n    public partial class MainForm : Form\n    {\n        private List<IBackend> m_Backends;\n        private List<ILanguage> m_Languages;\n        private ICompileOptionsPanel m_CompileOptionsPanel;\n        private Options m_Options;\n        private IWrapper m_Wrapper;\n        private string m_FileName = \"\";\n        private string m_LastBackend = \"\";\n\n        public Options Options { get { return m_Options; } }\n      \n        private void CreateBackends( Options opts )\n        {\n            List<IBackend> backends = new List<IBackend>();\n            IIncludeHandler handler = new IncludeHandler(opts.IncludePaths);\n\n            try\n            {\n                ID3DCompiler fxc = m_Wrapper.CreateD3DCompiler(opts.D3DCompilerPath, handler);\n                IDXILCompiler dxil = m_Wrapper.CreateDXILCompiler(opts.DXILCompilerPath, handler);\n\n                backends.Add(new D3DCompilerBackend(fxc,dxil));\n                try\n                {\n                    IAMDDriver driver = m_Wrapper.CreateAMDDriver(opts.DXXDriverPath);\n                    backends.Add(new AMDDriverBackend(driver, fxc));\n                }\n                catch( System.Exception ex )\n                {\n                    MessageBox.Show(ex.Message);\n                }\n            }\n            catch( System.Exception ex )\n            {\n                MessageBox.Show(ex.Message);\n            }\n            \n            backends.Add(new CodeXLBackend(opts.CodeXLPath, opts.D3DCompilerPath, opts.TempPath));\n            backends.Add(new GLSlangBackend(m_Wrapper,handler));\n            backends.Add(new GLSLOptimizerBackend(m_Wrapper));\n            backends.Add(new PowerVRBackend(opts.PowerVRCompilerPath, opts.TempPath));\n            backends.Add(new MaliSCBackend(opts.MaliSCRoot, opts.TempPath));\n            backends.Add(new RGABackend(opts.RGAPath, opts.TempPath,m_Wrapper,handler));\n            \n            if (File.Exists(opts.IntelShaderAnalyzerPath))\n            {\n                backends.Add(new IntelShaderAnalyzerBackend(opts));\n            }\n\n            m_Backends = backends;\n        }\n\n        public MainForm( Options options, IWrapper wrapper )\n        {\n            InitializeComponent();\n            m_Options   = options;\n            cmbBackend.DisplayMember  = \"Name\";\n            cmbLanguage.DisplayMember = \"Name\";\n\n            List<ILanguage> languages = new List<ILanguage>();\n            languages.Add(new HLSLLanguage());\n            languages.Add(new GLSLLanguage());\n            m_Languages = languages;\n\n            foreach (ILanguage l in m_Languages)\n                cmbLanguage.Items.Add(l);\n\n            cmbLanguage.SelectedIndex = 0;\n\n            m_Wrapper = wrapper;\n            CreateBackends(options);\n\n            txtCode.AllowDrop = true;\n            txtCode.DragEnter += \n                delegate( object sender, DragEventArgs args )\n                {\n                    if (args.Data.GetDataPresent(DataFormats.FileDrop))\n                        args.Effect = DragDropEffects.Move;\n                    else\n                        args.Effect = DragDropEffects.None;\n                };\n\n            txtCode.DragDrop +=\n                delegate(object sender, DragEventArgs args)\n                {\n                    if (args.Data.GetDataPresent(DataFormats.FileDrop))\n                    {\n                        string[] paths = args.Data.GetData(DataFormats.FileDrop) as string[];\n                        OpenFile(paths[0]);\n                    }\n                };\n        }\n\n        private void ClearResults()\n        {\n            cmbBackend.Items.Clear();\n            BackendPanel.Controls.Clear();\n            AnalysisPanel.Controls.Clear();\n        }\n\n        private void btnCompile_Click(object sender, EventArgs e)\n        {\n            if( m_CompileOptionsPanel == null )\n                return;\n\n            this.UseWaitCursor = true;\n\n            ClearResults();\n\n            IResultSet SelectedResultSet = null;\n\n            ICompileOptions opts = m_CompileOptionsPanel.ReadOptions();\n            \n            IShader shader = null;\n            switch (opts.Language)\n            {\n                case Languages.GLSL: \n                    shader = new GLSLShader(txtCode.Text, opts as IGLSLOptions, m_FileName ); break;\n                case Languages.HLSL: \n                    shader = new HLSLShader(txtCode.Text, opts as IHLSLOptions, m_FileName ); break;\n                default:\n                    throw new System.Exception(\"Unsupported language\");\n            }\n\n            foreach (IBackend backend in m_Backends)\n            {\n                if (m_Options.IsBackendDisabled(backend.Name))\n                    continue;\n\n                IBackendOptions options = null;\n\n                if (backend is AMDDriverBackend)\n                {\n                    AMDDriverBackend amdBackend = backend as AMDDriverBackend;\n                    List<string> requestedAsics = new List<string>();\n                    foreach (string asic in amdBackend.Asics)\n                    {\n                        if (!m_Options.IsAMDAsicDisabled(asic))\n                        {\n                            requestedAsics.Add(asic);\n                        }\n                    }\n                    AMDDriverBackendOptions backendOptions = new AMDDriverBackendOptions(requestedAsics);\n                    options = backendOptions;\n                }\n                else if (backend is CodeXLBackend)\n                {\n                    CodeXLBackend codeXLBackend = backend as CodeXLBackend;\n                    List<string> requestedAsics = new List<string>();\n                    foreach (string asic in codeXLBackend.Asics)\n                    {\n                        if (!m_Options.IsCodeXLAsicDisabled(asic))\n                        {\n                            requestedAsics.Add(asic);\n                        }\n                    }\n                    CodeXLBackendOptions backendOptions = new CodeXLBackendOptions(requestedAsics);\n                    options = backendOptions;\n                }\n                else if( backend is RGABackend )\n                {\n                    options = new RGABackendOptions(m_Options);\n                }\n\n                IResultSet r = backend.Compile(shader, options);\n                if (r != null)\n                {\n                    if (r.Name.Equals(m_LastBackend))\n                        SelectedResultSet = r;\n                    cmbBackend.Items.Add(r);\n                }\n            }\n\n            if (cmbBackend.Items.Count > 0)\n            {\n                if (SelectedResultSet != null)\n                    cmbBackend.SelectedIndex = cmbBackend.Items.IndexOf(SelectedResultSet);\n                else\n                    cmbBackend.SelectedIndex = 0;\n            }\n            else\n            {\n                m_LastBackend = \"\";\n            }\n\n            this.UseWaitCursor = false;\n        }\n\n        private void cmbLanguage_SelectedIndexChanged(object sender, EventArgs e)\n        {\n            CompilePanel.Controls.Clear();\n\n            ClearResults();\n\n            m_CompileOptionsPanel = null;\n            if (cmbLanguage.SelectedItem != null)\n            {\n                ILanguage l = (ILanguage)cmbLanguage.SelectedItem;\n                CompilePanel.Controls.Add(l.OptionsPanel.Panel);\n                m_CompileOptionsPanel = l.OptionsPanel;\n\n                try\n                {\n                    txtCode.SetHighlighting(l.Name);\n                }\n                catch( System.Exception ex )\n                {\n                    MessageBox.Show(ex.Message, \"Uh-oh\", MessageBoxButtons.OK, MessageBoxIcon.Error);\n                }\n            }\n\n        }\n\n        private void cmbBackend_SelectedIndexChanged(object sender, EventArgs e)\n        {\n            BackendPanel.Controls.Clear();\n            AnalysisPanel.Controls.Clear();\n            if (cmbBackend.SelectedItem != null )\n            {\n                IResultSet rs = (IResultSet) cmbBackend.SelectedItem;\n\n                if (rs.ResultsPanel != null)\n                {\n                    BackendPanel.Controls.Add(rs.ResultsPanel);\n                    rs.ResultsPanel.Dock = DockStyle.Fill;\n                }\n\n                if (rs.AnalysisPanel != null)\n                {\n                    AnalysisPanel.Controls.Add(rs.AnalysisPanel);\n                    rs.AnalysisPanel.Dock = DockStyle.Fill;\n                }\n                m_LastBackend = rs.Name;\n            }\n        }\n\n        private void optionsToolStripMenuItem_Click(object sender, EventArgs e)\n        {\n            OptionsScreen opts = new OptionsScreen(m_Options, m_Backends);\n            if (opts.ShowDialog() != DialogResult.Cancel)\n            {\n                m_Options = opts.SelectedOptions;\n                ClearResults();\n                CreateBackends(m_Options);\n            }\n        }\n\n        private void newToolStripMenuItem_Click(object sender, EventArgs e)\n        {\n            this.Text = \"Pyramid\";\n            txtCode.Text = \"\";\n            txtCode.Refresh();\n            m_FileName = \"\";\n            ClearResults();\n        }\n\n        private void OpenFile( string path )\n        {\n            try\n            {\n                string code = File.ReadAllText(path);\n                txtCode.Text = code;\n                ClearResults();\n                m_FileName = path;\n                this.Text = \"Pyramid : \" + m_FileName;\n            }\n            catch (Exception ex)\n            {\n                MessageBox.Show(ex.Message, \"uh-oh, couldn't Open\", MessageBoxButtons.OK, MessageBoxIcon.Error);\n            }\n        }\n\n        private void openToolStripMenuItem_Click(object sender, EventArgs e)\n        {\n            OpenFileDialog fd = new OpenFileDialog();\n            if( fd.ShowDialog() != DialogResult.Cancel)\n            {\n                OpenFile(fd.FileName);\n            }\n        }\n\n        private void saveToolStripMenuItem_Click(object sender, EventArgs e)\n        {\n            if (String.IsNullOrEmpty(m_FileName))\n                SaveAs();\n            else\n                Save(m_FileName);\n        }\n\n        private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)\n        {\n            SaveAs();\n        }\n\n        private void exitToolStripMenuItem_Click(object sender, EventArgs e)\n        {\n            this.Close();\n        }\n\n        private void SaveAs()\n        {\n            SaveFileDialog save = new SaveFileDialog();\n            if (save.ShowDialog() != DialogResult.Cancel)\n            {\n                Save(save.FileName);\n                m_FileName = save.FileName;\n                this.Text = \"Pyramid : \" + m_FileName;\n            }\n        }\n\n        private void Save( string As )\n        {\n            try\n            {\n                File.WriteAllText(As, txtCode.Text);\n            }\n            catch (Exception e)\n            {\n                MessageBox.Show(e.Message, \"uh-oh, couldn't save\", MessageBoxButtons.OK, MessageBoxIcon.Error);\n            }\n        }\n\n        private void aboutToolStripMenuItem_Click(object sender, EventArgs e)\n        {\n            AboutBox a = new AboutBox();\n            a.ShowDialog();\n        }\n\n\n        // Hackery to make .NET split containers behave themselves at arbitrary dpi  Courtesty of:\n        //   https://www.codeproject.com/Tips/786170/Proper-Resizing-of-SplitterContainer-Controls-at-a\n\n        // Save the current scale value\n        // ScaleControl() is called during the Form's constructor\n        private SizeF scale = new SizeF(1.0f, 1.0f);\n        protected override void ScaleControl(SizeF factor, BoundsSpecified specified)\n        {\n            scale = new SizeF(scale.Width * factor.Width, scale.Height * factor.Height);\n            base.ScaleControl(factor, specified);\n        }\n\n        // Recursively search for SplitContainer controls\n        private void FixSplitter(Control c)\n        {\n            foreach (Control child in c.Controls)\n            {\n                if (child is SplitContainer)\n                {\n                    SplitContainer sp = (SplitContainer)child;\n                    FixSplitter(sp);\n                    FixSplitter(sp.Panel1);\n                    FixSplitter(sp.Panel2);\n                }\n                else\n                {\n                    FixSplitter(child);\n                }\n            }\n        }\n\n        private void FixSplitter(SplitContainer sp)\n        {\n            // Scale factor depends on orientation\n            float sc = (sp.Orientation == Orientation.Vertical) ? scale.Width : scale.Height;\n            if (sp.FixedPanel == FixedPanel.Panel1)\n            {\n                sp.SplitterDistance = (int)Math.Round((float)sp.SplitterDistance * sc);\n            }\n            else if (sp.FixedPanel == FixedPanel.Panel2)\n            {\n                int cs = (sp.Orientation == Orientation.Vertical) ? sp.Panel2.ClientSize.Width : sp.Panel2.ClientSize.Height;\n                int newcs = (int)((float)cs * sc);\n                sp.SplitterDistance -= (newcs - cs);\n            }\n        }\n\n        private void MainForm_Shown(object sender, EventArgs e)\n        {\n            FixSplitter(this);\n        }\n    }\n}\n"
  },
  {
    "path": "src/MainUI/MainForm.resx",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n  <!-- \n    Microsoft ResX Schema \n    \n    Version 2.0\n    \n    The primary goals of this format is to allow a simple XML format \n    that is mostly human readable. The generation and parsing of the \n    various data types are done through the TypeConverter classes \n    associated with the data types.\n    \n    Example:\n    \n    ... ado.net/XML headers & schema ...\n    <resheader name=\"resmimetype\">text/microsoft-resx</resheader>\n    <resheader name=\"version\">2.0</resheader>\n    <resheader name=\"reader\">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\n    <resheader name=\"writer\">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\n    <data name=\"Name1\"><value>this is my long string</value><comment>this is a comment</comment></data>\n    <data name=\"Color1\" type=\"System.Drawing.Color, System.Drawing\">Blue</data>\n    <data name=\"Bitmap1\" mimetype=\"application/x-microsoft.net.object.binary.base64\">\n        <value>[base64 mime encoded serialized .NET Framework object]</value>\n    </data>\n    <data name=\"Icon1\" type=\"System.Drawing.Icon, System.Drawing\" mimetype=\"application/x-microsoft.net.object.bytearray.base64\">\n        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\n        <comment>This is a comment</comment>\n    </data>\n                \n    There are any number of \"resheader\" rows that contain simple \n    name/value pairs.\n    \n    Each data row contains a name, and value. The row also contains a \n    type or mimetype. Type corresponds to a .NET class that support \n    text/value conversion through the TypeConverter architecture. \n    Classes that don't support this are serialized and stored with the \n    mimetype set.\n    \n    The mimetype is used for serialized objects, and tells the \n    ResXResourceReader how to depersist the object. This is currently not \n    extensible. For a given mimetype the value must be set accordingly:\n    \n    Note - application/x-microsoft.net.object.binary.base64 is the format \n    that the ResXResourceWriter will generate, however the reader can \n    read any of the formats listed below.\n    \n    mimetype: application/x-microsoft.net.object.binary.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\n            : and then encoded with base64 encoding.\n    \n    mimetype: application/x-microsoft.net.object.soap.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\n            : and then encoded with base64 encoding.\n\n    mimetype: application/x-microsoft.net.object.bytearray.base64\n    value   : The object must be serialized into a byte array \n            : using a System.ComponentModel.TypeConverter\n            : and then encoded with base64 encoding.\n    -->\n  <xsd:schema id=\"root\" xmlns=\"\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">\n    <xsd:import namespace=\"http://www.w3.org/XML/1998/namespace\" />\n    <xsd:element name=\"root\" msdata:IsDataSet=\"true\">\n      <xsd:complexType>\n        <xsd:choice maxOccurs=\"unbounded\">\n          <xsd:element name=\"metadata\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" use=\"required\" type=\"xsd:string\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"assembly\">\n            <xsd:complexType>\n              <xsd:attribute name=\"alias\" type=\"xsd:string\" />\n              <xsd:attribute name=\"name\" type=\"xsd:string\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"data\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n                <xsd:element name=\"comment\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"2\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" msdata:Ordinal=\"1\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" msdata:Ordinal=\"3\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" msdata:Ordinal=\"4\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"resheader\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" />\n            </xsd:complexType>\n          </xsd:element>\n        </xsd:choice>\n      </xsd:complexType>\n    </xsd:element>\n  </xsd:schema>\n  <resheader name=\"resmimetype\">\n    <value>text/microsoft-resx</value>\n  </resheader>\n  <resheader name=\"version\">\n    <value>2.0</value>\n  </resheader>\n  <resheader name=\"reader\">\n    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n  <resheader name=\"writer\">\n    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n  <metadata name=\"menuStrip1.TrayLocation\" type=\"System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\">\n    <value>17, 17</value>\n  </metadata>\n</root>"
  },
  {
    "path": "src/MainUI/OptionsScreen.Designer.cs",
    "content": "﻿namespace Pyramid\n{\n    partial class OptionsScreen\n    {\n        /// <summary>\n        /// Required designer variable.\n        /// </summary>\n        private System.ComponentModel.IContainer components = null;\n\n        /// <summary>\n        /// Clean up any resources being used.\n        /// </summary>\n        /// <param name=\"disposing\">true if managed resources should be disposed; otherwise, false.</param>\n        protected override void Dispose(bool disposing)\n        {\n            if (disposing && (components != null))\n            {\n                components.Dispose();\n            }\n            base.Dispose(disposing);\n        }\n\n        #region Windows Form Designer generated code\n\n        /// <summary>\n        /// Required method for Designer support - do not modify\n        /// the contents of this method with the code editor.\n        /// </summary>\n        private void InitializeComponent()\n        {\n            this.components = new System.ComponentModel.Container();\n            this.txtCodeXL = new System.Windows.Forms.TextBox();\n            this.txtD3DCompiler = new System.Windows.Forms.TextBox();\n            this.txtTemp = new System.Windows.Forms.TextBox();\n            this.label2 = new System.Windows.Forms.Label();\n            this.label3 = new System.Windows.Forms.Label();\n            this.label4 = new System.Windows.Forms.Label();\n            this.btnTemp = new System.Windows.Forms.Button();\n            this.btnCodeXL = new System.Windows.Forms.Button();\n            this.btnD3DCompiler = new System.Windows.Forms.Button();\n            this.btnOk = new System.Windows.Forms.Button();\n            this.btnCancel = new System.Windows.Forms.Button();\n            this.label1 = new System.Windows.Forms.Label();\n            this.txtPowerVR = new System.Windows.Forms.TextBox();\n            this.btnPowerVR = new System.Windows.Forms.Button();\n            this.btnDefaults = new System.Windows.Forms.Button();\n            this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);\n            this.label5 = new System.Windows.Forms.Label();\n            this.label7 = new System.Windows.Forms.Label();\n            this.label12 = new System.Windows.Forms.Label();\n            this.btnAddInclude = new System.Windows.Forms.Button();\n            this.btnDeleteInclude = new System.Windows.Forms.Button();\n            this.label13 = new System.Windows.Forms.Label();\n            this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();\n            this.label14 = new System.Windows.Forms.Label();\n            this.label15 = new System.Windows.Forms.Label();\n            this.txtDXX = new System.Windows.Forms.TextBox();\n            this.btnDXX = new System.Windows.Forms.Button();\n            this.lstBackends = new System.Windows.Forms.CheckedListBox();\n            this.label6 = new System.Windows.Forms.Label();\n            this.btnMali = new System.Windows.Forms.Button();\n            this.txtMali = new System.Windows.Forms.TextBox();\n            this.lstAMDAsics = new System.Windows.Forms.CheckedListBox();\n            this.label8 = new System.Windows.Forms.Label();\n            this.label9 = new System.Windows.Forms.Label();\n            this.lstCodeXLAsics = new System.Windows.Forms.CheckedListBox();\n            this.txtRGA = new System.Windows.Forms.TextBox();\n            this.btnRGA = new System.Windows.Forms.Button();\n            this.lstRGAAsics = new System.Windows.Forms.CheckedListBox();\n            this.label11 = new System.Windows.Forms.Label();\n            this.lstIncludes = new System.Windows.Forms.ListBox();\n            this.btnDXIL = new System.Windows.Forms.Button();\n            this.txtDXIL = new System.Windows.Forms.TextBox();\n            this.btnIntelShaderAnalyzer = new System.Windows.Forms.Button();\n            this.txtIntelShaderAnalyzer = new System.Windows.Forms.TextBox();\n            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();\n            this.SuspendLayout();\n            // \n            // txtCodeXL\n            // \n            this.txtCodeXL.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) \n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.txtCodeXL.Enabled = false;\n            this.txtCodeXL.Location = new System.Drawing.Point(115, 314);\n            this.txtCodeXL.Margin = new System.Windows.Forms.Padding(4);\n            this.txtCodeXL.Name = \"txtCodeXL\";\n            this.txtCodeXL.Size = new System.Drawing.Size(705, 22);\n            this.txtCodeXL.TabIndex = 1;\n            // \n            // txtD3DCompiler\n            // \n            this.txtD3DCompiler.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) \n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.txtD3DCompiler.Enabled = false;\n            this.txtD3DCompiler.Location = new System.Drawing.Point(115, 346);\n            this.txtD3DCompiler.Margin = new System.Windows.Forms.Padding(4);\n            this.txtD3DCompiler.Name = \"txtD3DCompiler\";\n            this.txtD3DCompiler.Size = new System.Drawing.Size(705, 22);\n            this.txtD3DCompiler.TabIndex = 2;\n            // \n            // txtTemp\n            // \n            this.txtTemp.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) \n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.txtTemp.Enabled = false;\n            this.txtTemp.Location = new System.Drawing.Point(115, 282);\n            this.txtTemp.Margin = new System.Windows.Forms.Padding(4);\n            this.txtTemp.Name = \"txtTemp\";\n            this.txtTemp.Size = new System.Drawing.Size(705, 22);\n            this.txtTemp.TabIndex = 3;\n            // \n            // label2\n            // \n            this.label2.AutoSize = true;\n            this.label2.Location = new System.Drawing.Point(47, 317);\n            this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);\n            this.label2.Name = \"label2\";\n            this.label2.Size = new System.Drawing.Size(58, 17);\n            this.label2.TabIndex = 5;\n            this.label2.Text = \"CodeXL\";\n            this.toolTip1.SetToolTip(this.label2, \"Path to AMD CodeXL Analyzer\");\n            // \n            // label3\n            // \n            this.label3.AutoSize = true;\n            this.label3.Location = new System.Drawing.Point(19, 349);\n            this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);\n            this.label3.Name = \"label3\";\n            this.label3.Size = new System.Drawing.Size(91, 17);\n            this.label3.TabIndex = 6;\n            this.label3.Text = \"D3DCompiler\";\n            this.toolTip1.SetToolTip(this.label3, \"Path to the D3DCompiler DLL to use\");\n            // \n            // label4\n            // \n            this.label4.AutoSize = true;\n            this.label4.Location = new System.Drawing.Point(40, 287);\n            this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);\n            this.label4.Name = \"label4\";\n            this.label4.Size = new System.Drawing.Size(66, 17);\n            this.label4.TabIndex = 7;\n            this.label4.Text = \"Temp Dir\";\n            this.toolTip1.SetToolTip(this.label4, \"Path to a directory that will be polluted with temporary nonsense when the compil\" +\n        \"e button is pressed.\");\n            // \n            // btnTemp\n            // \n            this.btnTemp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\n            this.btnTemp.Location = new System.Drawing.Point(829, 282);\n            this.btnTemp.Margin = new System.Windows.Forms.Padding(4);\n            this.btnTemp.Name = \"btnTemp\";\n            this.btnTemp.Size = new System.Drawing.Size(43, 25);\n            this.btnTemp.TabIndex = 8;\n            this.btnTemp.Text = \"...\";\n            this.btnTemp.UseVisualStyleBackColor = true;\n            this.btnTemp.Click += new System.EventHandler(this.btnTemp_Click);\n            // \n            // btnCodeXL\n            // \n            this.btnCodeXL.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\n            this.btnCodeXL.Location = new System.Drawing.Point(829, 312);\n            this.btnCodeXL.Margin = new System.Windows.Forms.Padding(4);\n            this.btnCodeXL.Name = \"btnCodeXL\";\n            this.btnCodeXL.Size = new System.Drawing.Size(43, 25);\n            this.btnCodeXL.TabIndex = 10;\n            this.btnCodeXL.Text = \"...\";\n            this.btnCodeXL.UseVisualStyleBackColor = true;\n            this.btnCodeXL.Click += new System.EventHandler(this.btnCodeXL_Click);\n            // \n            // btnD3DCompiler\n            // \n            this.btnD3DCompiler.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\n            this.btnD3DCompiler.Location = new System.Drawing.Point(829, 344);\n            this.btnD3DCompiler.Margin = new System.Windows.Forms.Padding(4);\n            this.btnD3DCompiler.Name = \"btnD3DCompiler\";\n            this.btnD3DCompiler.Size = new System.Drawing.Size(43, 25);\n            this.btnD3DCompiler.TabIndex = 11;\n            this.btnD3DCompiler.Text = \"...\";\n            this.btnD3DCompiler.UseVisualStyleBackColor = true;\n            this.btnD3DCompiler.Click += new System.EventHandler(this.btnD3DCompiler_Click);\n            // \n            // btnOk\n            // \n            this.btnOk.DialogResult = System.Windows.Forms.DialogResult.OK;\n            this.btnOk.Location = new System.Drawing.Point(505, 609);\n            this.btnOk.Margin = new System.Windows.Forms.Padding(4);\n            this.btnOk.Name = \"btnOk\";\n            this.btnOk.Size = new System.Drawing.Size(92, 31);\n            this.btnOk.TabIndex = 12;\n            this.btnOk.Text = \"Ok\";\n            this.btnOk.UseVisualStyleBackColor = true;\n            // \n            // btnCancel\n            // \n            this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;\n            this.btnCancel.Location = new System.Drawing.Point(617, 608);\n            this.btnCancel.Margin = new System.Windows.Forms.Padding(4);\n            this.btnCancel.Name = \"btnCancel\";\n            this.btnCancel.Size = new System.Drawing.Size(92, 31);\n            this.btnCancel.TabIndex = 13;\n            this.btnCancel.Text = \"Cancel\";\n            this.btnCancel.UseVisualStyleBackColor = true;\n            // \n            // label1\n            // \n            this.label1.AutoSize = true;\n            this.label1.Location = new System.Drawing.Point(16, 383);\n            this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);\n            this.label1.Name = \"label1\";\n            this.label1.Size = new System.Drawing.Size(88, 17);\n            this.label1.TabIndex = 14;\n            this.label1.Text = \"PowerVR Dir\";\n            this.toolTip1.SetToolTip(this.label1, \"Directory where the PowerVR compilers can be found.  Default will be relative to \" +\n        \"working directory.\");\n            // \n            // txtPowerVR\n            // \n            this.txtPowerVR.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) \n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.txtPowerVR.Enabled = false;\n            this.txtPowerVR.Location = new System.Drawing.Point(115, 376);\n            this.txtPowerVR.Margin = new System.Windows.Forms.Padding(4);\n            this.txtPowerVR.Name = \"txtPowerVR\";\n            this.txtPowerVR.Size = new System.Drawing.Size(705, 22);\n            this.txtPowerVR.TabIndex = 15;\n            // \n            // btnPowerVR\n            // \n            this.btnPowerVR.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\n            this.btnPowerVR.Location = new System.Drawing.Point(829, 375);\n            this.btnPowerVR.Margin = new System.Windows.Forms.Padding(4);\n            this.btnPowerVR.Name = \"btnPowerVR\";\n            this.btnPowerVR.Size = new System.Drawing.Size(43, 23);\n            this.btnPowerVR.TabIndex = 16;\n            this.btnPowerVR.Text = \"...\";\n            this.btnPowerVR.UseVisualStyleBackColor = true;\n            this.btnPowerVR.Click += new System.EventHandler(this.btnPowerVR_Click);\n            // \n            // btnDefaults\n            // \n            this.btnDefaults.Location = new System.Drawing.Point(48, 609);\n            this.btnDefaults.Margin = new System.Windows.Forms.Padding(4);\n            this.btnDefaults.Name = \"btnDefaults\";\n            this.btnDefaults.Size = new System.Drawing.Size(87, 30);\n            this.btnDefaults.TabIndex = 17;\n            this.btnDefaults.Text = \"Defaults\";\n            this.btnDefaults.UseVisualStyleBackColor = true;\n            this.btnDefaults.Click += new System.EventHandler(this.btnDefaults_Click);\n            // \n            // toolTip1\n            // \n            this.toolTip1.ShowAlways = true;\n            // \n            // label5\n            // \n            this.label5.AutoSize = true;\n            this.label5.Location = new System.Drawing.Point(32, 412);\n            this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);\n            this.label5.Name = \"label5\";\n            this.label5.Size = new System.Drawing.Size(70, 17);\n            this.label5.TabIndex = 20;\n            this.label5.Text = \"AMD DXX\";\n            this.toolTip1.SetToolTip(this.label5, \"Directory where atidxx32.dll can be found.  Default will be relative to working d\" +\n        \"irectory.\");\n            // \n            // label7\n            // \n            this.label7.AutoSize = true;\n            this.label7.Location = new System.Drawing.Point(51, 444);\n            this.label7.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);\n            this.label7.Name = \"label7\";\n            this.label7.Size = new System.Drawing.Size(55, 17);\n            this.label7.TabIndex = 26;\n            this.label7.Text = \"Mali Dir\";\n            this.toolTip1.SetToolTip(this.label7, \"Directory where the mali shader compiler can be found.  Default will be relative \" +\n        \"to working directory.\");\n            // \n            // label12\n            // \n            this.label12.AutoSize = true;\n            this.label12.Location = new System.Drawing.Point(67, 479);\n            this.label12.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);\n            this.label12.Name = \"label12\";\n            this.label12.Size = new System.Drawing.Size(38, 17);\n            this.label12.TabIndex = 38;\n            this.label12.Text = \"RGA\";\n            this.toolTip1.SetToolTip(this.label12, \"Directory where the mali shader compiler can be found.  Default will be relative \" +\n        \"to working directory.\");\n            // \n            // btnAddInclude\n            // \n            this.btnAddInclude.Location = new System.Drawing.Point(768, 201);\n            this.btnAddInclude.Margin = new System.Windows.Forms.Padding(4);\n            this.btnAddInclude.Name = \"btnAddInclude\";\n            this.btnAddInclude.Size = new System.Drawing.Size(23, 25);\n            this.btnAddInclude.TabIndex = 44;\n            this.btnAddInclude.Text = \"+\";\n            this.toolTip1.SetToolTip(this.btnAddInclude, \"Add include path\");\n            this.btnAddInclude.UseVisualStyleBackColor = true;\n            this.btnAddInclude.Click += new System.EventHandler(this.btnAddInclude_Click);\n            // \n            // btnDeleteInclude\n            // \n            this.btnDeleteInclude.Location = new System.Drawing.Point(799, 201);\n            this.btnDeleteInclude.Margin = new System.Windows.Forms.Padding(4);\n            this.btnDeleteInclude.Name = \"btnDeleteInclude\";\n            this.btnDeleteInclude.Size = new System.Drawing.Size(23, 25);\n            this.btnDeleteInclude.TabIndex = 45;\n            this.btnDeleteInclude.Text = \"X\";\n            this.toolTip1.SetToolTip(this.btnDeleteInclude, \"Delete include path\");\n            this.btnDeleteInclude.UseVisualStyleBackColor = true;\n            this.btnDeleteInclude.Click += new System.EventHandler(this.btnDeleteInclude_Click);\n            // \n            // label13\n            // \n            this.label13.AutoSize = true;\n            this.label13.Location = new System.Drawing.Point(44, 201);\n            this.label13.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);\n            this.label13.Name = \"label13\";\n            this.label13.Size = new System.Drawing.Size(60, 17);\n            this.label13.TabIndex = 46;\n            this.label13.Text = \"Includes\";\n            this.toolTip1.SetToolTip(this.label13, \"Path to a directory that will be polluted with temporary nonsense when the compil\" +\n        \"e button is pressed.\");\n            // \n            // numericUpDown1\n            // \n            this.numericUpDown1.InterceptArrowKeys = false;\n            this.numericUpDown1.Location = new System.Drawing.Point(768, 246);\n            this.numericUpDown1.Margin = new System.Windows.Forms.Padding(4);\n            this.numericUpDown1.Minimum = new decimal(new int[] {\n            100,\n            0,\n            0,\n            -2147483648});\n            this.numericUpDown1.Name = \"numericUpDown1\";\n            this.numericUpDown1.Size = new System.Drawing.Size(23, 22);\n            this.numericUpDown1.TabIndex = 47;\n            this.toolTip1.SetToolTip(this.numericUpDown1, \"Adjust include order\");\n            this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);\n            // \n            // label14\n            // \n            this.label14.AutoSize = true;\n            this.label14.Location = new System.Drawing.Point(19, 509);\n            this.label14.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);\n            this.label14.Name = \"label14\";\n            this.label14.Size = new System.Drawing.Size(97, 17);\n            this.label14.TabIndex = 48;\n            this.label14.Text = \"DXIL Compiler\";\n            this.toolTip1.SetToolTip(this.label14, \"Path to the D3DCompiler DLL to use\");\n            // \n            // label15\n            // \n            this.label15.AutoSize = true;\n            this.label15.Location = new System.Drawing.Point(21, 539);\n            this.label15.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);\n            this.label15.Name = \"label15\";\n            this.label15.Size = new System.Drawing.Size(56, 17);\n            this.label15.TabIndex = 51;\n            this.label15.Text = \"Intel SA\";\n            this.toolTip1.SetToolTip(this.label15, \"Path to the D3DCompiler DLL to use\");\n            this.label15.Click += new System.EventHandler(this.label15_Click);\n            // \n            // txtDXX\n            // \n            this.txtDXX.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) \n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.txtDXX.Enabled = false;\n            this.txtDXX.Location = new System.Drawing.Point(115, 408);\n            this.txtDXX.Margin = new System.Windows.Forms.Padding(4);\n            this.txtDXX.Name = \"txtDXX\";\n            this.txtDXX.Size = new System.Drawing.Size(705, 22);\n            this.txtDXX.TabIndex = 18;\n            // \n            // btnDXX\n            // \n            this.btnDXX.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\n            this.btnDXX.Location = new System.Drawing.Point(829, 410);\n            this.btnDXX.Margin = new System.Windows.Forms.Padding(4);\n            this.btnDXX.Name = \"btnDXX\";\n            this.btnDXX.Size = new System.Drawing.Size(43, 23);\n            this.btnDXX.TabIndex = 19;\n            this.btnDXX.Text = \"...\";\n            this.btnDXX.UseVisualStyleBackColor = true;\n            this.btnDXX.Click += new System.EventHandler(this.btnDXX_Click);\n            // \n            // lstBackends\n            // \n            this.lstBackends.FormattingEnabled = true;\n            this.lstBackends.Location = new System.Drawing.Point(44, 57);\n            this.lstBackends.Margin = new System.Windows.Forms.Padding(4);\n            this.lstBackends.Name = \"lstBackends\";\n            this.lstBackends.ScrollAlwaysVisible = true;\n            this.lstBackends.Size = new System.Drawing.Size(203, 123);\n            this.lstBackends.TabIndex = 22;\n            // \n            // label6\n            // \n            this.label6.AutoSize = true;\n            this.label6.Location = new System.Drawing.Point(40, 22);\n            this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);\n            this.label6.Name = \"label6\";\n            this.label6.Size = new System.Drawing.Size(70, 17);\n            this.label6.TabIndex = 23;\n            this.label6.Text = \"Backends\";\n            // \n            // btnMali\n            // \n            this.btnMali.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\n            this.btnMali.Location = new System.Drawing.Point(829, 442);\n            this.btnMali.Margin = new System.Windows.Forms.Padding(4);\n            this.btnMali.Name = \"btnMali\";\n            this.btnMali.Size = new System.Drawing.Size(43, 23);\n            this.btnMali.TabIndex = 25;\n            this.btnMali.Text = \"...\";\n            this.btnMali.UseVisualStyleBackColor = true;\n            this.btnMali.Click += new System.EventHandler(this.btnMali_Click);\n            // \n            // txtMali\n            // \n            this.txtMali.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) \n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.txtMali.Enabled = false;\n            this.txtMali.Location = new System.Drawing.Point(115, 440);\n            this.txtMali.Margin = new System.Windows.Forms.Padding(4);\n            this.txtMali.Name = \"txtMali\";\n            this.txtMali.Size = new System.Drawing.Size(705, 22);\n            this.txtMali.TabIndex = 24;\n            // \n            // lstAMDAsics\n            // \n            this.lstAMDAsics.FormattingEnabled = true;\n            this.lstAMDAsics.Location = new System.Drawing.Point(273, 57);\n            this.lstAMDAsics.Margin = new System.Windows.Forms.Padding(4);\n            this.lstAMDAsics.Name = \"lstAMDAsics\";\n            this.lstAMDAsics.ScrollAlwaysVisible = true;\n            this.lstAMDAsics.Size = new System.Drawing.Size(203, 123);\n            this.lstAMDAsics.TabIndex = 27;\n            // \n            // label8\n            // \n            this.label8.AutoSize = true;\n            this.label8.Location = new System.Drawing.Point(269, 22);\n            this.label8.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);\n            this.label8.Name = \"label8\";\n            this.label8.Size = new System.Drawing.Size(75, 17);\n            this.label8.TabIndex = 28;\n            this.label8.Text = \"AMD Asics\";\n            // \n            // label9\n            // \n            this.label9.AutoSize = true;\n            this.label9.Location = new System.Drawing.Point(497, 22);\n            this.label9.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);\n            this.label9.Name = \"label9\";\n            this.label9.Size = new System.Drawing.Size(95, 17);\n            this.label9.TabIndex = 30;\n            this.label9.Text = \"CodeXL Asics\";\n            // \n            // lstCodeXLAsics\n            // \n            this.lstCodeXLAsics.FormattingEnabled = true;\n            this.lstCodeXLAsics.Location = new System.Drawing.Point(501, 57);\n            this.lstCodeXLAsics.Margin = new System.Windows.Forms.Padding(4);\n            this.lstCodeXLAsics.Name = \"lstCodeXLAsics\";\n            this.lstCodeXLAsics.ScrollAlwaysVisible = true;\n            this.lstCodeXLAsics.Size = new System.Drawing.Size(171, 123);\n            this.lstCodeXLAsics.TabIndex = 29;\n            // \n            // txtRGA\n            // \n            this.txtRGA.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) \n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.txtRGA.Enabled = false;\n            this.txtRGA.Location = new System.Drawing.Point(115, 474);\n            this.txtRGA.Margin = new System.Windows.Forms.Padding(4);\n            this.txtRGA.Name = \"txtRGA\";\n            this.txtRGA.Size = new System.Drawing.Size(705, 22);\n            this.txtRGA.TabIndex = 34;\n            // \n            // btnRGA\n            // \n            this.btnRGA.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\n            this.btnRGA.Location = new System.Drawing.Point(828, 476);\n            this.btnRGA.Margin = new System.Windows.Forms.Padding(4);\n            this.btnRGA.Name = \"btnRGA\";\n            this.btnRGA.Size = new System.Drawing.Size(43, 23);\n            this.btnRGA.TabIndex = 35;\n            this.btnRGA.Text = \"...\";\n            this.btnRGA.UseVisualStyleBackColor = true;\n            this.btnRGA.Click += new System.EventHandler(this.btnRGA_Click);\n            // \n            // lstRGAAsics\n            // \n            this.lstRGAAsics.FormattingEnabled = true;\n            this.lstRGAAsics.Location = new System.Drawing.Point(700, 57);\n            this.lstRGAAsics.Margin = new System.Windows.Forms.Padding(4);\n            this.lstRGAAsics.Name = \"lstRGAAsics\";\n            this.lstRGAAsics.ScrollAlwaysVisible = true;\n            this.lstRGAAsics.Size = new System.Drawing.Size(171, 123);\n            this.lstRGAAsics.TabIndex = 36;\n            // \n            // label11\n            // \n            this.label11.AutoSize = true;\n            this.label11.Location = new System.Drawing.Point(696, 22);\n            this.label11.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);\n            this.label11.Name = \"label11\";\n            this.label11.Size = new System.Drawing.Size(75, 17);\n            this.label11.TabIndex = 37;\n            this.label11.Text = \"RGA Asics\";\n            // \n            // lstIncludes\n            // \n            this.lstIncludes.FormattingEnabled = true;\n            this.lstIncludes.ItemHeight = 16;\n            this.lstIncludes.Location = new System.Drawing.Point(115, 201);\n            this.lstIncludes.Margin = new System.Windows.Forms.Padding(4);\n            this.lstIncludes.Name = \"lstIncludes\";\n            this.lstIncludes.Size = new System.Drawing.Size(643, 68);\n            this.lstIncludes.TabIndex = 39;\n            // \n            // btnDXIL\n            // \n            this.btnDXIL.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\n            this.btnDXIL.Location = new System.Drawing.Point(828, 505);\n            this.btnDXIL.Margin = new System.Windows.Forms.Padding(4);\n            this.btnDXIL.Name = \"btnDXIL\";\n            this.btnDXIL.Size = new System.Drawing.Size(43, 25);\n            this.btnDXIL.TabIndex = 50;\n            this.btnDXIL.Text = \"...\";\n            this.btnDXIL.UseVisualStyleBackColor = true;\n            this.btnDXIL.Click += new System.EventHandler(this.btnDXIL_Click);\n            // \n            // txtDXIL\n            // \n            this.txtDXIL.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) \n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.txtDXIL.Enabled = false;\n            this.txtDXIL.Location = new System.Drawing.Point(115, 506);\n            this.txtDXIL.Margin = new System.Windows.Forms.Padding(4);\n            this.txtDXIL.Name = \"txtDXIL\";\n            this.txtDXIL.Size = new System.Drawing.Size(705, 22);\n            this.txtDXIL.TabIndex = 49;\n            // \n            // btnIntelShaderAnalyzer\n            // \n            this.btnIntelShaderAnalyzer.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\n            this.btnIntelShaderAnalyzer.Location = new System.Drawing.Point(830, 535);\n            this.btnIntelShaderAnalyzer.Margin = new System.Windows.Forms.Padding(4);\n            this.btnIntelShaderAnalyzer.Name = \"btnIntelShaderAnalyzer\";\n            this.btnIntelShaderAnalyzer.Size = new System.Drawing.Size(43, 25);\n            this.btnIntelShaderAnalyzer.TabIndex = 53;\n            this.btnIntelShaderAnalyzer.Text = \"...\";\n            this.btnIntelShaderAnalyzer.UseVisualStyleBackColor = true;\n            this.btnIntelShaderAnalyzer.Click += new System.EventHandler(this.btnIntelShaderAnalyzer_Click);\n            // \n            // txtIntelShaderAnalyzer\n            // \n            this.txtIntelShaderAnalyzer.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) \n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.txtIntelShaderAnalyzer.Enabled = false;\n            this.txtIntelShaderAnalyzer.Location = new System.Drawing.Point(117, 536);\n            this.txtIntelShaderAnalyzer.Margin = new System.Windows.Forms.Padding(4);\n            this.txtIntelShaderAnalyzer.Name = \"txtIntelShaderAnalyzer\";\n            this.txtIntelShaderAnalyzer.Size = new System.Drawing.Size(705, 22);\n            this.txtIntelShaderAnalyzer.TabIndex = 52;\n            // \n            // OptionsScreen\n            // \n            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);\n            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\n            this.ClientSize = new System.Drawing.Size(897, 654);\n            this.Controls.Add(this.btnIntelShaderAnalyzer);\n            this.Controls.Add(this.txtIntelShaderAnalyzer);\n            this.Controls.Add(this.label15);\n            this.Controls.Add(this.btnDXIL);\n            this.Controls.Add(this.txtDXIL);\n            this.Controls.Add(this.label14);\n            this.Controls.Add(this.numericUpDown1);\n            this.Controls.Add(this.label13);\n            this.Controls.Add(this.btnDeleteInclude);\n            this.Controls.Add(this.btnAddInclude);\n            this.Controls.Add(this.lstIncludes);\n            this.Controls.Add(this.label12);\n            this.Controls.Add(this.label11);\n            this.Controls.Add(this.lstRGAAsics);\n            this.Controls.Add(this.btnRGA);\n            this.Controls.Add(this.txtRGA);\n            this.Controls.Add(this.label9);\n            this.Controls.Add(this.lstCodeXLAsics);\n            this.Controls.Add(this.label8);\n            this.Controls.Add(this.lstAMDAsics);\n            this.Controls.Add(this.label7);\n            this.Controls.Add(this.btnMali);\n            this.Controls.Add(this.txtMali);\n            this.Controls.Add(this.label6);\n            this.Controls.Add(this.lstBackends);\n            this.Controls.Add(this.label5);\n            this.Controls.Add(this.btnDXX);\n            this.Controls.Add(this.txtDXX);\n            this.Controls.Add(this.btnDefaults);\n            this.Controls.Add(this.btnPowerVR);\n            this.Controls.Add(this.txtPowerVR);\n            this.Controls.Add(this.label1);\n            this.Controls.Add(this.btnCancel);\n            this.Controls.Add(this.btnOk);\n            this.Controls.Add(this.btnD3DCompiler);\n            this.Controls.Add(this.btnCodeXL);\n            this.Controls.Add(this.btnTemp);\n            this.Controls.Add(this.label4);\n            this.Controls.Add(this.label3);\n            this.Controls.Add(this.label2);\n            this.Controls.Add(this.txtTemp);\n            this.Controls.Add(this.txtD3DCompiler);\n            this.Controls.Add(this.txtCodeXL);\n            this.Margin = new System.Windows.Forms.Padding(4);\n            this.Name = \"OptionsScreen\";\n            this.Text = \"OptionsScreen\";\n            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OptionsScreen_FormClosing);\n            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();\n            this.ResumeLayout(false);\n            this.PerformLayout();\n\n        }\n\n        #endregion\n\n        private System.Windows.Forms.TextBox txtCodeXL;\n        private System.Windows.Forms.TextBox txtD3DCompiler;\n        private System.Windows.Forms.TextBox txtTemp;\n        private System.Windows.Forms.Label label2;\n        private System.Windows.Forms.Label label3;\n        private System.Windows.Forms.Label label4;\n        private System.Windows.Forms.Button btnTemp;\n        private System.Windows.Forms.Button btnCodeXL;\n        private System.Windows.Forms.Button btnD3DCompiler;\n        private System.Windows.Forms.Button btnOk;\n        private System.Windows.Forms.Button btnCancel;\n        private System.Windows.Forms.Label label1;\n        private System.Windows.Forms.TextBox txtPowerVR;\n        private System.Windows.Forms.Button btnPowerVR;\n        private System.Windows.Forms.Button btnDefaults;\n        private System.Windows.Forms.ToolTip toolTip1;\n        private System.Windows.Forms.TextBox txtDXX;\n        private System.Windows.Forms.Button btnDXX;\n        private System.Windows.Forms.Label label5;\n        private System.Windows.Forms.CheckedListBox lstBackends;\n        private System.Windows.Forms.Label label6;\n        private System.Windows.Forms.Label label7;\n        private System.Windows.Forms.Button btnMali;\n        private System.Windows.Forms.TextBox txtMali;\n        private System.Windows.Forms.CheckedListBox lstAMDAsics;\n        private System.Windows.Forms.Label label8;\n        private System.Windows.Forms.Label label9;\n        private System.Windows.Forms.CheckedListBox lstCodeXLAsics;\n        private System.Windows.Forms.TextBox txtRGA;\n        private System.Windows.Forms.Button btnRGA;\n        private System.Windows.Forms.CheckedListBox lstRGAAsics;\n        private System.Windows.Forms.Label label11;\n        private System.Windows.Forms.Label label12;\n        private System.Windows.Forms.ListBox lstIncludes;\n        private System.Windows.Forms.Button btnAddInclude;\n        private System.Windows.Forms.Button btnDeleteInclude;\n        private System.Windows.Forms.Label label13;\n        private System.Windows.Forms.NumericUpDown numericUpDown1;\n        private System.Windows.Forms.Label label14;\n        private System.Windows.Forms.Button btnDXIL;\n        private System.Windows.Forms.TextBox txtDXIL;\n        private System.Windows.Forms.Button btnIntelShaderAnalyzer;\n        private System.Windows.Forms.TextBox txtIntelShaderAnalyzer;\n        private System.Windows.Forms.Label label15;\n    }\n}"
  },
  {
    "path": "src/MainUI/OptionsScreen.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Data;\nusing System.Drawing;\nusing System.Text;\nusing System.Windows.Forms;\n\nnamespace Pyramid\n{\n    public partial class OptionsScreen : Form\n    {\n        private Options m_InitialOpts;\n        private string m_IncludeBrowseStart = \"\";\n\n        public Options SelectedOptions { get; private set; }\n\n        public OptionsScreen( Options opts, List<IBackend> backends )\n        {\n            InitializeComponent();\n            m_InitialOpts       = opts;\n            PopulateGUIFromOptions(opts);\n\n            foreach (IBackend backend in backends)\n            {\n                int index = lstBackends.Items.Add(backend.Name);\n                lstBackends.SetItemChecked(index,!opts.IsBackendDisabled(backend.Name));\n            }\n\n            // #mivance refactor\n            IBackend amdBackend = backends.Find(backend => backend.Name == \"AMDDXX\");\n\n            if (amdBackend is AMDDriverBackend)\n            {\n                AMDDriverBackend driver = amdBackend as AMDDriverBackend;\n\n                foreach (string asic in driver.Asics)\n                {\n                    int index = lstAMDAsics.Items.Add(asic);\n                    lstAMDAsics.SetItemChecked(index, !opts.IsAMDAsicDisabled(asic));\n                }\n            }\n\n            IBackend codeXLBackend = backends.Find(backend => backend.Name == \"CodeXL\");\n\n            if (codeXLBackend is CodeXLBackend)\n            {\n                CodeXLBackend driver = codeXLBackend as CodeXLBackend;\n                foreach (string asic in driver.Asics)\n                {\n                    int index = lstCodeXLAsics.Items.Add(asic);\n                    lstCodeXLAsics.SetItemChecked(index, !opts.IsCodeXLAsicDisabled(asic));\n                }\n            }\n\n            if (System.IO.File.Exists(opts.RGAPath))\n            {\n                List<string> rgaAsics = RGABackend.GetAsicList(opts.RGAPath);\n                foreach (string asic in rgaAsics)\n                {\n                    int index = lstRGAAsics.Items.Add(asic);\n                    lstRGAAsics.SetItemChecked(index, !opts.IsRGAAsicDisabled(asic));\n                }\n            }\n\n        }\n\n        private void PopulateGUIFromOptions(Options opts)\n        {\n            txtD3DCompiler.Text = opts.D3DCompilerPath;\n            txtCodeXL.Text = opts.CodeXLPath;\n            txtTemp.Text = opts.TempPath;\n            txtPowerVR.Text = opts.PowerVRCompilerPath;\n            txtDXX.Text = opts.DXXDriverPath;\n            txtMali.Text = opts.MaliSCRoot;\n            txtRGA.Text = opts.RGAPath;\n            txtDXIL.Text = opts.DXILCompilerPath;\n            txtIntelShaderAnalyzer.Text = opts.IntelShaderAnalyzerPath;\n\n            foreach (string s in opts.IncludePaths)\n                lstIncludes.Items.Add(s);\n\n            // start include browsing at last include directory\n            if (lstIncludes.Items.Count > 0)\n                m_IncludeBrowseStart = (string) lstIncludes.Items[lstIncludes.Items.Count - 1];\n        }\n\n        private string BrowseFile( string initial )\n        {\n            OpenFileDialog fd = new OpenFileDialog();\n            fd.FileName = initial;\n            if (fd.ShowDialog() != DialogResult.Cancel)\n                return fd.FileName;\n            else\n                return initial;\n        }\n\n        private string BrowseFolder(string initial)\n        {\n            FolderBrowserDialog fd = new FolderBrowserDialog();\n            if( !string.IsNullOrEmpty(initial) && System.IO.Directory.Exists(initial))\n                fd.SelectedPath = initial;\n\n            if (fd.ShowDialog() != DialogResult.Cancel)\n                return fd.SelectedPath;\n            else\n                return initial;\n        }\n\n        private void btnD3DCompiler_Click(object sender, EventArgs e)\n        {\n            txtD3DCompiler.Text = BrowseFile(txtD3DCompiler.Text);\n        }\n\n        private void btnCodeXL_Click(object sender, EventArgs e)\n        {\n            txtCodeXL.Text = BrowseFile(txtCodeXL.Text);\n        }\n\n        private void btnTemp_Click(object sender, EventArgs e)\n        {\n            txtTemp.Text = BrowseFolder(txtTemp.Text);\n        }\n\n        private void OptionsScreen_FormClosing(object sender, FormClosingEventArgs e)\n        {\n            if (this.DialogResult == DialogResult.Cancel)\n            {\n                SelectedOptions = m_InitialOpts;\n            }\n            else\n            {\n                SelectedOptions = new Options();\n                SelectedOptions.CodeXLPath = txtCodeXL.Text;\n                SelectedOptions.D3DCompilerPath = txtD3DCompiler.Text;\n                SelectedOptions.TempPath = txtTemp.Text;\n                SelectedOptions.PowerVRCompilerPath = txtPowerVR.Text;\n                SelectedOptions.DXXDriverPath = txtDXX.Text;\n                SelectedOptions.MaliSCRoot = txtMali.Text ;\n                SelectedOptions.RGAPath = txtRGA.Text;\n                SelectedOptions.DXILCompilerPath = txtDXIL.Text;\n                SelectedOptions.IntelShaderAnalyzerPath = txtIntelShaderAnalyzer.Text;\n\n                for (int backendIndex = 0; backendIndex < lstBackends.Items.Count; backendIndex++)\n                {\n                    if (!lstBackends.GetItemChecked(backendIndex))\n                        SelectedOptions.DisableBackend(lstBackends.Items[backendIndex].ToString());\n                }\n\n                for (int amdAsicIndex = 0; amdAsicIndex < lstAMDAsics.Items.Count; amdAsicIndex++)\n                {\n                    if (!lstAMDAsics.GetItemChecked(amdAsicIndex))\n                    {\n                        SelectedOptions.DisableAMDAsic(lstAMDAsics.Items[amdAsicIndex].ToString());\n                    }\n                }\n\n                for (int codeXLAsicIndex = 0; codeXLAsicIndex < lstCodeXLAsics.Items.Count; codeXLAsicIndex++)\n                {\n                    if (!lstCodeXLAsics.GetItemChecked(codeXLAsicIndex))\n                    {\n                        SelectedOptions.DisableCodeXLAsic(lstCodeXLAsics.Items[codeXLAsicIndex].ToString());\n                    }\n                }\n\n                for (int i = 0; i < lstRGAAsics.Items.Count; i++)\n                {\n                    if (!lstRGAAsics.GetItemChecked(i))\n                    {\n                        SelectedOptions.DisableRGAAsic(lstRGAAsics.Items[i].ToString());\n                    }\n                }\n\n                foreach( string s in lstIncludes.Items )\n                    SelectedOptions.AddInclude(s);\n            }\n        }\n\n        private void btnPowerVR_Click(object sender, EventArgs e)\n        {\n            txtPowerVR.Text = BrowseFolder(txtPowerVR.Text);\n        }\n\n        private void btnDefaults_Click(object sender, EventArgs e)\n        {\n            Options opts = Options.GetDefaults();\n            PopulateGUIFromOptions(opts);\n\n            for (int i = 0; i < lstBackends.Items.Count; i++)\n                lstBackends.SetItemChecked(i, true);\n        }\n\n        private void btnDXX_Click(object sender, EventArgs e)\n        {\n            txtDXX.Text = BrowseFile(txtDXX.Text);\n        }\n\n        private void btnMali_Click(object sender, EventArgs e)\n        {\n            txtMali.Text = BrowseFolder(txtMali.Text);\n        }\n        \n\n        private void btnRGA_Click(object sender, EventArgs e)\n        {\n            txtRGA.Text = BrowseFile(txtRGA.Text);\n        }\n\n        private void btnAddInclude_Click(object sender, EventArgs e)\n        {\n            FolderBrowserDialog fd = new FolderBrowserDialog();\n            if( System.IO.Directory.Exists(m_IncludeBrowseStart) )\n                fd.SelectedPath = m_IncludeBrowseStart;\n\n            if (fd.ShowDialog() != DialogResult.Cancel)\n            {\n                string path = fd.SelectedPath;\n                if (!lstIncludes.Items.Contains(path))\n                {\n                    lstIncludes.Items.Add(path);\n                    m_IncludeBrowseStart = path; // remember last place user browsed to\n                }\n            }\n        }\n\n        private void btnDeleteInclude_Click(object sender, EventArgs e)\n        {\n            if( lstIncludes.SelectedItem != null )\n            {\n                lstIncludes.Items.Remove(lstIncludes.SelectedItem);\n            }\n        }\n\n        private void numericUpDown1_ValueChanged(object sender, EventArgs e)\n        {\n            if (lstIncludes.SelectedItem != null)\n            {\n                // figure out which direction user wamts it moved in\n                int direction = (int)numericUpDown1.Value;\n                int oldPlace = lstIncludes.SelectedIndex;\n                int newPlace = lstIncludes.SelectedIndex;\n                if (direction == 1)\n                {\n                    // user clicked the up arrow, move it up\n                    if( lstIncludes.SelectedIndex > 0 )\n                        newPlace = oldPlace - 1;\n                }\n                else if (direction == -1)\n                {\n                    // user clicked the down arrow, move it down\n                    if (lstIncludes.SelectedIndex < lstIncludes.Items.Count - 1)\n                        newPlace = oldPlace + 1;                    \n                }\n\n                if( oldPlace != newPlace )\n                {\n                    string a = (string) lstIncludes.Items[oldPlace];\n                    string b = (string) lstIncludes.Items[newPlace];\n                    lstIncludes.Items[oldPlace] = b;\n                    lstIncludes.Items[newPlace] = a;\n                    lstIncludes.SelectedIndex = newPlace;\n                }\n            }\n\n            // clear the updown for next time\n            numericUpDown1.Value = 0;\n        }\n\n        private void btnDXIL_Click(object sender, EventArgs e)\n        {\n            txtDXIL.Text = BrowseFile(txtDXIL.Text);\n        }\n\n        private void btnIntelShaderAnalyzer_Click(object sender, EventArgs e)\n        {\n            txtIntelShaderAnalyzer.Text = BrowseFile(txtIntelShaderAnalyzer.Text);\n        }\n\n        private void label15_Click(object sender, EventArgs e)\n        {\n\n        }\n    }\n}\n"
  },
  {
    "path": "src/MainUI/OptionsScreen.resx",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n  <!-- \n    Microsoft ResX Schema \n    \n    Version 2.0\n    \n    The primary goals of this format is to allow a simple XML format \n    that is mostly human readable. The generation and parsing of the \n    various data types are done through the TypeConverter classes \n    associated with the data types.\n    \n    Example:\n    \n    ... ado.net/XML headers & schema ...\n    <resheader name=\"resmimetype\">text/microsoft-resx</resheader>\n    <resheader name=\"version\">2.0</resheader>\n    <resheader name=\"reader\">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\n    <resheader name=\"writer\">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\n    <data name=\"Name1\"><value>this is my long string</value><comment>this is a comment</comment></data>\n    <data name=\"Color1\" type=\"System.Drawing.Color, System.Drawing\">Blue</data>\n    <data name=\"Bitmap1\" mimetype=\"application/x-microsoft.net.object.binary.base64\">\n        <value>[base64 mime encoded serialized .NET Framework object]</value>\n    </data>\n    <data name=\"Icon1\" type=\"System.Drawing.Icon, System.Drawing\" mimetype=\"application/x-microsoft.net.object.bytearray.base64\">\n        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\n        <comment>This is a comment</comment>\n    </data>\n                \n    There are any number of \"resheader\" rows that contain simple \n    name/value pairs.\n    \n    Each data row contains a name, and value. The row also contains a \n    type or mimetype. Type corresponds to a .NET class that support \n    text/value conversion through the TypeConverter architecture. \n    Classes that don't support this are serialized and stored with the \n    mimetype set.\n    \n    The mimetype is used for serialized objects, and tells the \n    ResXResourceReader how to depersist the object. This is currently not \n    extensible. For a given mimetype the value must be set accordingly:\n    \n    Note - application/x-microsoft.net.object.binary.base64 is the format \n    that the ResXResourceWriter will generate, however the reader can \n    read any of the formats listed below.\n    \n    mimetype: application/x-microsoft.net.object.binary.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\n            : and then encoded with base64 encoding.\n    \n    mimetype: application/x-microsoft.net.object.soap.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\n            : and then encoded with base64 encoding.\n\n    mimetype: application/x-microsoft.net.object.bytearray.base64\n    value   : The object must be serialized into a byte array \n            : using a System.ComponentModel.TypeConverter\n            : and then encoded with base64 encoding.\n    -->\n  <xsd:schema id=\"root\" xmlns=\"\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">\n    <xsd:import namespace=\"http://www.w3.org/XML/1998/namespace\" />\n    <xsd:element name=\"root\" msdata:IsDataSet=\"true\">\n      <xsd:complexType>\n        <xsd:choice maxOccurs=\"unbounded\">\n          <xsd:element name=\"metadata\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" use=\"required\" type=\"xsd:string\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"assembly\">\n            <xsd:complexType>\n              <xsd:attribute name=\"alias\" type=\"xsd:string\" />\n              <xsd:attribute name=\"name\" type=\"xsd:string\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"data\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n                <xsd:element name=\"comment\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"2\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" msdata:Ordinal=\"1\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" msdata:Ordinal=\"3\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" msdata:Ordinal=\"4\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"resheader\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" />\n            </xsd:complexType>\n          </xsd:element>\n        </xsd:choice>\n      </xsd:complexType>\n    </xsd:element>\n  </xsd:schema>\n  <resheader name=\"resmimetype\">\n    <value>text/microsoft-resx</value>\n  </resheader>\n  <resheader name=\"version\">\n    <value>2.0</value>\n  </resheader>\n  <resheader name=\"reader\">\n    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n  <resheader name=\"writer\">\n    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n  <metadata name=\"toolTip1.TrayLocation\" type=\"System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\">\n    <value>17, 17</value>\n  </metadata>\n  <metadata name=\"toolTip1.TrayLocation\" type=\"System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\">\n    <value>17, 17</value>\n  </metadata>\n</root>"
  },
  {
    "path": "src/Options.cs",
    "content": "﻿using System;\nusing System.IO;\nusing System.Collections.Generic;\nusing System.Windows.Forms;\n\nnamespace Pyramid\n{\n    public class Options\n    {\n        private List<string> m_DisabledBackends = new List<string>();\n        private List<string> m_DisabledAMDAsics = new List<string>();\n        private List<string> m_DisabledCodeXLAsics = new List<string>();\n        private List<string> m_DisabledRGAAsics = new List<string>();\n        private List<string> m_IncludePaths = new List<string>();\n        \n        public string RGAPath { get; set; }\n        public string D3DCompilerPath { get; set; }\n        public string DXILCompilerPath { get; set; }\n        public string CodeXLPath { get; set; }\n        public string TempPath { get; set; }\n        public string PowerVRCompilerPath { get; set; }\n        public string DXXDriverPath { get; set; }\n        public string MaliSCRoot { get; set; }\n        public string IntelShaderAnalyzerPath { get; set; }\n        public IEnumerable<string> DisabledBackends { get { return m_DisabledBackends; } }\n        public IEnumerable<string> DisabledAMDAsics { get { return m_DisabledAMDAsics; } }\n        public IEnumerable<string> DisabledCodeXLAsics { get { return m_DisabledCodeXLAsics; } }\n        public IEnumerable<string> DisabledRGAAsics { get { return m_DisabledRGAAsics; } }\n        public IEnumerable<string> IncludePaths { get { return m_IncludePaths; } }\n\n        public void DisableBackend(string name)\n        {\n            m_DisabledBackends.Add(name);\n        }\n        public bool IsBackendDisabled(string name)\n        {\n            return m_DisabledBackends.Contains(name);\n        }\n\n        public void DisableRGAAsic(string name)\n        {\n            m_DisabledRGAAsics.Add(name);\n        }\n        public bool IsRGAAsicDisabled(string name)\n        {\n            return m_DisabledRGAAsics.Contains(name);\n        }\n\n       \n        public void DisableAMDAsic(string name)\n        {\n            m_DisabledAMDAsics.Add(name);\n        }\n        public bool IsAMDAsicDisabled(string name)\n        {\n            return m_DisabledAMDAsics.Contains(name);\n        }\n\n        public void DisableCodeXLAsic(string name)\n        {\n            m_DisabledCodeXLAsics.Add(name);\n        }\n        public bool IsCodeXLAsicDisabled(string name)\n        {\n            return m_DisabledCodeXLAsics.Contains(name);\n        }\n\n        public void AddInclude(string include)\n        {\n            if( !m_IncludePaths.Contains(include))\n                m_IncludePaths.Add(include);\n        }\n        public void RemoveInclude( string include )\n        {\n            m_IncludePaths.Remove(include);\n        }\n\n        public static Options GetDefaults()\n        {\n            Options opts = new Options();\n            opts.D3DCompilerPath     = \"d3dcompiler_47.dll\";\n            opts.DXILCompilerPath    = \"dxcompiler.dll\";\n            opts.CodeXLPath          = \"CodeXLAnalyzer.exe\";\n            opts.PowerVRCompilerPath = \"PowerVR\";\n            opts.DXXDriverPath = \"atidxx32.dll\";\n            opts.MaliSCRoot = \"MaliSC\";\n            opts.RGAPath = \"rga\\\\rga.exe\";\n            opts.IntelShaderAnalyzerPath = \"IntelShaderAnalyzer\\\\IntelShaderAnalyzer.exe\";\n            opts.TempPath = Path.Combine(\n                Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),\n                \"Pyramid\" );\n\n            return opts;\n        }\n\n        public static Options Get()\n        {\n            string OptionsFile = Path.Combine(\n                Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),\n                \"Pyramid\\\\options\" );\n\n            Options defaults = GetDefaults();\n            if (!System.IO.File.Exists(OptionsFile))\n                return defaults;\n\n            Options opts = new Options();\n            try\n            {\n                string[] lines = File.ReadAllLines(OptionsFile);\n                Dictionary<string,string> map = new Dictionary<string,string>();\n                foreach( string s in lines )\n                {\n                    int idx = s.IndexOf('=');\n                    string key   = s.Substring(0, idx);\n                    string value = s.Substring(idx+1);\n                    map.Add(key, value);\n                }\n                \n                string d3dCompiler;\n                if (!map.TryGetValue(\"D3DCompiler\", out d3dCompiler))\n                    d3dCompiler = defaults.D3DCompilerPath;\n\n                string dxilCompiler;\n                if (!map.TryGetValue(\"DXILCompiler\", out dxilCompiler))\n                    dxilCompiler = defaults.DXILCompilerPath;\n\n\n                string codeXL;\n                if (!map.TryGetValue(\"CodeXL\", out codeXL))\n                    codeXL = defaults.CodeXLPath;\n\n                string temp;\n                if (!map.TryGetValue(\"temp\", out temp))\n                    temp = defaults.TempPath;\n\n                string pvr;\n                if (!map.TryGetValue(\"PowerVR\", out pvr))\n                    pvr = defaults.PowerVRCompilerPath;\n\n                string dxx;\n                if (!map.TryGetValue(\"DXX\", out dxx))\n                    dxx = defaults.DXXDriverPath;\n\n                string mali;\n                if (!map.TryGetValue(\"Mali\", out mali))\n                    mali = defaults.MaliSCRoot;\n                \n                string disabledBackends;\n                if( map.TryGetValue(\"DisabledBackends\", out disabledBackends))\n                    opts.m_DisabledBackends.AddRange(disabledBackends.Split(','));\n\n                string disabledAMDAsics;\n                if (map.TryGetValue(\"DisabledAMDAsics\", out disabledAMDAsics))\n                    opts.m_DisabledAMDAsics.AddRange(disabledAMDAsics.Split(','));\n\n                string disabledCodeXLAsics;\n                if (map.TryGetValue(\"DisabledCodeXLAsics\", out disabledCodeXLAsics))\n                    opts.m_DisabledCodeXLAsics.AddRange(disabledCodeXLAsics.Split(','));\n\n                string disabledRGAAsics;\n                if (map.TryGetValue(\"DisabledRGAAsics\", out disabledRGAAsics))\n                    opts.m_DisabledRGAAsics.AddRange(disabledRGAAsics.Split(','));\n\n                string rga;\n                if (!map.TryGetValue(\"RGAPath\", out rga))\n                    rga = defaults.RGAPath;\n                \n                string intelAnalyzer;\n                if (!map.TryGetValue(\"IntelShaderAnalyzerPath\", out intelAnalyzer))\n                    intelAnalyzer = defaults.IntelShaderAnalyzerPath;\n\n\n                string includePaths;\n                if (map.TryGetValue(\"IncludePaths\", out includePaths))\n                    opts.m_IncludePaths.AddRange(includePaths.Split('?'));\n\n                opts.D3DCompilerPath = d3dCompiler;\n                opts.DXILCompilerPath = dxilCompiler;\n                opts.CodeXLPath = codeXL;\n                opts.TempPath = temp;\n                opts.PowerVRCompilerPath = pvr;\n                opts.DXXDriverPath = dxx;\n                opts.MaliSCRoot = mali;\n                opts.RGAPath = rga;\n                opts.IntelShaderAnalyzerPath = intelAnalyzer;\n\n                return opts;\n            }\n            catch (Exception e)\n            {\n                // not found\n                MessageBox.Show(e.Message, \"uh-oh, couldn't read options file\", MessageBoxButtons.OK, MessageBoxIcon.Error);\n                return GetDefaults();\n            }\n        }\n\n        public void Write()\n        {\n            string OptionsFile = Path.Combine(\n               Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),\n               \"Pyramid\\\\options\");\n\n            try\n            {\n                string DisabledBackends = String.Join(\",\",m_DisabledBackends.ToArray());\n                string DisabledAMDAsics = String.Join(\",\",m_DisabledAMDAsics.ToArray());\n                string DisabledCodeXLAsics = String.Join(\",\", m_DisabledCodeXLAsics.ToArray());\n                string DisabledRGAAsics = String.Join(\",\", m_DisabledRGAAsics.ToArray());\n                \n                // NOTE: remember, must join include paths with a non-path character\n                string IncludePaths = String.Join(\"?\", m_IncludePaths);\n\n                File.WriteAllText(OptionsFile,\n                                   String.Format(\"D3DCompiler={0}\\nCodeXL={1}\\ntemp={2}\\nPowerVR={3}\\nMali={4}\\nDisabledBackends={5}\\nDisabledAMDAsics={6}\\nDisabledCodeXLAsics={7}\\nRGAPath={8}\\nDisabledRGAAsics={9}\\nIncludePaths={10}\\nDXILCompiler={11}\\nIntelShaderAnalyzerPath={12}\\n\",\n                                                             D3DCompilerPath,\n                                                             CodeXLPath,\n                                                             TempPath,\n                                                             PowerVRCompilerPath,\n                                                             MaliSCRoot,\n                                                             DisabledBackends,\n                                                             DisabledAMDAsics,\n                                                             DisabledCodeXLAsics,\n                                                             RGAPath,\n                                                             DisabledRGAAsics,\n                                                             IncludePaths,\n                                                             DXILCompilerPath,\n                                                             IntelShaderAnalyzerPath ));\n            }\n            catch(Exception e)\n            {\n                MessageBox.Show(e.Message, \"uh-oh, couldn't write options file\", MessageBoxButtons.OK, MessageBoxIcon.Error);\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "src/Program.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.Windows.Forms;\nusing System.Reflection;\n\nnamespace Pyramid\n{\n    static class Program\n    {\n        /// <summary>\n        /// The main entry point for the application.\n        /// </summary>\n        [STAThread]\n        static void Main()\n        {\n            \n            Application.EnableVisualStyles();\n            Application.SetCompatibleTextRenderingDefault(false);\n\n            Options opts = Options.Get();\n            System.IO.Directory.CreateDirectory(opts.TempPath);\n\n\n            IWrapper wrapper = new Wrapper();\n            MainForm main = new MainForm( opts, wrapper );\n            Application.Run(main);\n\n            \n\n            main.Options.Write();\n        }\n    }\n}\n"
  },
  {
    "path": "src/Properties/AssemblyInfo.cs",
    "content": "﻿using System.Reflection;\nusing System.Runtime.CompilerServices;\nusing System.Runtime.InteropServices;\n\n// General Information about an assembly is controlled through the following \n// set of attributes. Change these attribute values to modify the information\n// associated with an assembly.\n[assembly: AssemblyTitle(\"Pyramid\")]\n[assembly: AssemblyDescription(\"\")]\n[assembly: AssemblyConfiguration(\"\")]\n[assembly: AssemblyCompany(\"\")]\n[assembly: AssemblyProduct(\"Pyramid\")]\n[assembly: AssemblyCopyright(\"Copyright ©  2014\")]\n[assembly: AssemblyTrademark(\"\")]\n[assembly: AssemblyCulture(\"\")]\n\n// Setting ComVisible to false makes the types in this assembly not visible \n// to COM components.  If you need to access a type in this assembly from \n// COM, set the ComVisible attribute to true on that type.\n[assembly: ComVisible(false)]\n\n// The following GUID is for the ID of the typelib if this project is exposed to COM\n[assembly: Guid(\"20c36372-9723-4568-8ed4-853d62821d0e\")]\n\n// Version information for an assembly consists of the following four values:\n//\n//      Major Version\n//      Minor Version \n//      Build Number\n//      Revision\n//\n// You can specify all the values or you can default the Build and Revision Numbers \n// by using the '*' as shown below:\n// [assembly: AssemblyVersion(\"1.0.*\")]\n[assembly: AssemblyVersion(\"1.0.0.0\")]\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]\n"
  },
  {
    "path": "src/Properties/Resources.Designer.cs",
    "content": "﻿//------------------------------------------------------------------------------\n// <auto-generated>\n//     This code was generated by a tool.\n//     Runtime Version:4.0.30319.34014\n//\n//     Changes to this file may cause incorrect behavior and will be lost if\n//     the code is regenerated.\n// </auto-generated>\n//------------------------------------------------------------------------------\n\nnamespace Pyramid.Properties {\n    using System;\n    \n    \n    /// <summary>\n    ///   A strongly-typed resource class, for looking up localized strings, etc.\n    /// </summary>\n    // This class was auto-generated by the StronglyTypedResourceBuilder\n    // class via a tool like ResGen or Visual Studio.\n    // To add or remove a member, edit your .ResX file then rerun ResGen\n    // with the /str option, or rebuild your VS project.\n    [global::System.CodeDom.Compiler.GeneratedCodeAttribute(\"System.Resources.Tools.StronglyTypedResourceBuilder\", \"4.0.0.0\")]\n    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\n    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]\n    internal class Resources {\n        \n        private static global::System.Resources.ResourceManager resourceMan;\n        \n        private static global::System.Globalization.CultureInfo resourceCulture;\n        \n        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute(\"Microsoft.Performance\", \"CA1811:AvoidUncalledPrivateCode\")]\n        internal Resources() {\n        }\n        \n        /// <summary>\n        ///   Returns the cached ResourceManager instance used by this class.\n        /// </summary>\n        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]\n        internal static global::System.Resources.ResourceManager ResourceManager {\n            get {\n                if (object.ReferenceEquals(resourceMan, null)) {\n                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager(\"Pyramid.Properties.Resources\", typeof(Resources).Assembly);\n                    resourceMan = temp;\n                }\n                return resourceMan;\n            }\n        }\n        \n        /// <summary>\n        ///   Overrides the current thread's CurrentUICulture property for all\n        ///   resource lookups using this strongly typed resource class.\n        /// </summary>\n        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]\n        internal static global::System.Globalization.CultureInfo Culture {\n            get {\n                return resourceCulture;\n            }\n            set {\n                resourceCulture = value;\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "src/Properties/Resources.resx",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n  <!-- \n    Microsoft ResX Schema \n    \n    Version 2.0\n    \n    The primary goals of this format is to allow a simple XML format \n    that is mostly human readable. The generation and parsing of the \n    various data types are done through the TypeConverter classes \n    associated with the data types.\n    \n    Example:\n    \n    ... ado.net/XML headers & schema ...\n    <resheader name=\"resmimetype\">text/microsoft-resx</resheader>\n    <resheader name=\"version\">2.0</resheader>\n    <resheader name=\"reader\">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\n    <resheader name=\"writer\">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\n    <data name=\"Name1\"><value>this is my long string</value><comment>this is a comment</comment></data>\n    <data name=\"Color1\" type=\"System.Drawing.Color, System.Drawing\">Blue</data>\n    <data name=\"Bitmap1\" mimetype=\"application/x-microsoft.net.object.binary.base64\">\n        <value>[base64 mime encoded serialized .NET Framework object]</value>\n    </data>\n    <data name=\"Icon1\" type=\"System.Drawing.Icon, System.Drawing\" mimetype=\"application/x-microsoft.net.object.bytearray.base64\">\n        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\n        <comment>This is a comment</comment>\n    </data>\n                \n    There are any number of \"resheader\" rows that contain simple \n    name/value pairs.\n    \n    Each data row contains a name, and value. The row also contains a \n    type or mimetype. Type corresponds to a .NET class that support \n    text/value conversion through the TypeConverter architecture. \n    Classes that don't support this are serialized and stored with the \n    mimetype set.\n    \n    The mimetype is used for serialized objects, and tells the \n    ResXResourceReader how to depersist the object. This is currently not \n    extensible. For a given mimetype the value must be set accordingly:\n    \n    Note - application/x-microsoft.net.object.binary.base64 is the format \n    that the ResXResourceWriter will generate, however the reader can \n    read any of the formats listed below.\n    \n    mimetype: application/x-microsoft.net.object.binary.base64\n    value   : The object must be serialized with \n            : System.Serialization.Formatters.Binary.BinaryFormatter\n            : and then encoded with base64 encoding.\n    \n    mimetype: application/x-microsoft.net.object.soap.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\n            : and then encoded with base64 encoding.\n\n    mimetype: application/x-microsoft.net.object.bytearray.base64\n    value   : The object must be serialized into a byte array \n            : using a System.ComponentModel.TypeConverter\n            : and then encoded with base64 encoding.\n    -->\n  <xsd:schema id=\"root\" xmlns=\"\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">\n    <xsd:element name=\"root\" msdata:IsDataSet=\"true\">\n      <xsd:complexType>\n        <xsd:choice maxOccurs=\"unbounded\">\n          <xsd:element name=\"metadata\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"assembly\">\n            <xsd:complexType>\n              <xsd:attribute name=\"alias\" type=\"xsd:string\" />\n              <xsd:attribute name=\"name\" type=\"xsd:string\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"data\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n                <xsd:element name=\"comment\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"2\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" msdata:Ordinal=\"1\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" msdata:Ordinal=\"3\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" msdata:Ordinal=\"4\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"resheader\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" />\n            </xsd:complexType>\n          </xsd:element>\n        </xsd:choice>\n      </xsd:complexType>\n    </xsd:element>\n  </xsd:schema>\n  <resheader name=\"resmimetype\">\n    <value>text/microsoft-resx</value>\n  </resheader>\n  <resheader name=\"version\">\n    <value>2.0</value>\n  </resheader>\n  <resheader name=\"reader\">\n    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n  <resheader name=\"writer\">\n    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n</root>"
  },
  {
    "path": "src/Properties/Settings.Designer.cs",
    "content": "﻿//------------------------------------------------------------------------------\n// <auto-generated>\n//     This code was generated by a tool.\n//     Runtime Version:4.0.30319.34014\n//\n//     Changes to this file may cause incorrect behavior and will be lost if\n//     the code is regenerated.\n// </auto-generated>\n//------------------------------------------------------------------------------\n\nnamespace Pyramid.Properties {\n    \n    \n    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]\n    [global::System.CodeDom.Compiler.GeneratedCodeAttribute(\"Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator\", \"12.0.0.0\")]\n    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {\n        \n        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));\n        \n        public static Settings Default {\n            get {\n                return defaultInstance;\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "src/Properties/Settings.settings",
    "content": "﻿<?xml version='1.0' encoding='utf-8'?>\n<SettingsFile xmlns=\"http://schemas.microsoft.com/VisualStudio/2004/01/settings\" CurrentProfile=\"(Default)\">\n  <Profiles>\n    <Profile Name=\"(Default)\" />\n  </Profiles>\n  <Settings />\n</SettingsFile>\n"
  },
  {
    "path": "src/Pyramid.csproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"12.0\" DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <Import Project=\"$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props\" Condition=\"Exists('$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props')\" />\n  <PropertyGroup>\n    <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>\n    <Platform Condition=\" '$(Platform)' == '' \">AnyCPU</Platform>\n    <ProjectGuid>{BFF31873-BEEA-4528-ACE9-27DDFD150BF1}</ProjectGuid>\n    <OutputType>WinExe</OutputType>\n    <AppDesignerFolder>Properties</AppDesignerFolder>\n    <RootNamespace>Pyramid</RootNamespace>\n    <AssemblyName>Pyramid</AssemblyName>\n    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>\n    <FileAlignment>512</FileAlignment>\n    <TargetFrameworkProfile />\n    <PublishUrl>publish\\</PublishUrl>\n    <Install>true</Install>\n    <InstallFrom>Disk</InstallFrom>\n    <UpdateEnabled>false</UpdateEnabled>\n    <UpdateMode>Foreground</UpdateMode>\n    <UpdateInterval>7</UpdateInterval>\n    <UpdateIntervalUnits>Days</UpdateIntervalUnits>\n    <UpdatePeriodically>false</UpdatePeriodically>\n    <UpdateRequired>false</UpdateRequired>\n    <MapFileExtensions>true</MapFileExtensions>\n    <ApplicationRevision>0</ApplicationRevision>\n    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>\n    <IsWebBootstrapper>false</IsWebBootstrapper>\n    <UseApplicationTrust>false</UseApplicationTrust>\n    <BootstrapperEnabled>true</BootstrapperEnabled>\n  </PropertyGroup>\n  <PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' \">\n    <PlatformTarget>x86</PlatformTarget>\n    <DebugSymbols>true</DebugSymbols>\n    <DebugType>full</DebugType>\n    <Optimize>false</Optimize>\n    <OutputPath>bin\\Debug\\</OutputPath>\n    <DefineConstants>DEBUG;TRACE</DefineConstants>\n    <ErrorReport>prompt</ErrorReport>\n    <WarningLevel>4</WarningLevel>\n    <Prefer32Bit>false</Prefer32Bit>\n  </PropertyGroup>\n  <PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' \">\n    <PlatformTarget>x86</PlatformTarget>\n    <DebugType>pdbonly</DebugType>\n    <Optimize>true</Optimize>\n    <OutputPath>bin\\Release\\</OutputPath>\n    <DefineConstants>TRACE</DefineConstants>\n    <ErrorReport>prompt</ErrorReport>\n    <WarningLevel>4</WarningLevel>\n    <Prefer32Bit>false</Prefer32Bit>\n  </PropertyGroup>\n  <ItemGroup>\n    <Reference Include=\"System\" />\n    <Reference Include=\"System.Data\" />\n    <Reference Include=\"System.Deployment\" />\n    <Reference Include=\"System.Design\" />\n    <Reference Include=\"System.Drawing\" />\n    <Reference Include=\"System.Windows.Forms\" />\n    <Reference Include=\"System.Xml\" />\n  </ItemGroup>\n  <ItemGroup>\n    <Compile Include=\"Backends\\AMDDriverBackend.cs\" />\n    <Compile Include=\"Backends\\AMDDriverResultsPanel.cs\">\n      <SubType>UserControl</SubType>\n    </Compile>\n    <Compile Include=\"Backends\\AMDDriverResultsPanel.Designer.cs\">\n      <DependentUpon>AMDDriverResultsPanel.cs</DependentUpon>\n    </Compile>\n    <Compile Include=\"Backends\\GLSlangResultsPanel.cs\">\n      <SubType>UserControl</SubType>\n    </Compile>\n    <Compile Include=\"Backends\\GLSlangResultsPanel.Designer.cs\">\n      <DependentUpon>GLSlangResultsPanel.cs</DependentUpon>\n    </Compile>\n    <Compile Include=\"Backends\\IntelShaderAnalyzerBackend.cs\" />\n    <Compile Include=\"Backends\\IntelShaderAnalyzerResultsPanel.cs\">\n      <SubType>UserControl</SubType>\n    </Compile>\n    <Compile Include=\"Backends\\IntelShaderAnalyzerResultsPanel.Designer.cs\">\n      <DependentUpon>IntelShaderAnalyzerResultsPanel.cs</DependentUpon>\n    </Compile>\n    <Compile Include=\"Backends\\MaliSCBackend.cs\" />\n    <Compile Include=\"Backends\\MaliSCResultsPanel.cs\">\n      <SubType>UserControl</SubType>\n    </Compile>\n    <Compile Include=\"Backends\\MaliSCResultsPanel.Designer.cs\">\n      <DependentUpon>MaliSCResultsPanel.cs</DependentUpon>\n    </Compile>\n    <Compile Include=\"Backends\\RGABackend.cs\" />\n    <Compile Include=\"IncludeHandler.cs\" />\n    <Compile Include=\"Languages\\ILanguage.cs\" />\n    <Compile Include=\"MainUI\\AboutBox.cs\">\n      <SubType>Form</SubType>\n    </Compile>\n    <Compile Include=\"MainUI\\AboutBox.Designer.cs\">\n      <DependentUpon>AboutBox.cs</DependentUpon>\n    </Compile>\n    <Compile Include=\"Backends\\CodeXLAnalysisPanel.cs\">\n      <SubType>UserControl</SubType>\n    </Compile>\n    <Compile Include=\"Backends\\CodeXLAnalysisPanel.Designer.cs\">\n      <DependentUpon>CodeXLAnalysisPanel.cs</DependentUpon>\n    </Compile>\n    <Compile Include=\"Backends\\CodeXLBackend.cs\" />\n    <Compile Include=\"Backends\\CodeXLResultsPanel.cs\">\n      <SubType>UserControl</SubType>\n    </Compile>\n    <Compile Include=\"Backends\\CodeXLResultsPanel.Designer.cs\">\n      <DependentUpon>CodeXLResultsPanel.cs</DependentUpon>\n    </Compile>\n    <Compile Include=\"Backends\\FXCBackend.cs\" />\n    <Compile Include=\"Backends\\FXCResultsPanel.cs\">\n      <SubType>UserControl</SubType>\n    </Compile>\n    <Compile Include=\"Backends\\FXCResultsPanel.Designer.cs\">\n      <DependentUpon>FXCResultsPanel.cs</DependentUpon>\n    </Compile>\n    <Compile Include=\"Backends\\GLSlangBackend.cs\" />\n    <Compile Include=\"Languages\\GLSLLanguage.cs\" />\n    <Compile Include=\"Backends\\GLSLOptimizerBackend.cs\" />\n    <Compile Include=\"Languages\\GLSLOptionsPanel.cs\">\n      <SubType>UserControl</SubType>\n    </Compile>\n    <Compile Include=\"Languages\\GLSLOptionsPanel.Designer.cs\">\n      <DependentUpon>GLSLOptionsPanel.cs</DependentUpon>\n    </Compile>\n    <Compile Include=\"Languages\\HLSLLanguage.cs\" />\n    <Compile Include=\"Languages\\HLSLOptionsPanel.cs\">\n      <SubType>UserControl</SubType>\n    </Compile>\n    <Compile Include=\"Languages\\HLSLOptionsPanel.Designer.cs\">\n      <DependentUpon>HLSLOptionsPanel.cs</DependentUpon>\n    </Compile>\n    <Compile Include=\"Backends\\IBackend.cs\" />\n    <Compile Include=\"Languages\\ICompileOptionsPanel.cs\" />\n    <Compile Include=\"MainUI\\MainForm.cs\">\n      <SubType>Form</SubType>\n    </Compile>\n    <Compile Include=\"MainUI\\MainForm.Designer.cs\">\n      <DependentUpon>MainForm.cs</DependentUpon>\n    </Compile>\n    <Compile Include=\"Options.cs\" />\n    <Compile Include=\"MainUI\\OptionsScreen.cs\">\n      <SubType>Form</SubType>\n    </Compile>\n    <Compile Include=\"MainUI\\OptionsScreen.Designer.cs\">\n      <DependentUpon>OptionsScreen.cs</DependentUpon>\n    </Compile>\n    <Compile Include=\"Backends\\PowerVRBackend.cs\" />\n    <Compile Include=\"Program.cs\" />\n    <Compile Include=\"Properties\\AssemblyInfo.cs\" />\n    <Compile Include=\"Backends\\PVRResultsPanel.cs\">\n      <SubType>UserControl</SubType>\n    </Compile>\n    <Compile Include=\"Backends\\PVRResultsPanel.Designer.cs\">\n      <DependentUpon>PVRResultsPanel.cs</DependentUpon>\n    </Compile>\n    <Compile Include=\"Scrutinizer\\Analysis\\Algorithms.cs\" />\n    <Compile Include=\"Scrutinizer\\UI\\CFGWidget.cs\">\n      <SubType>UserControl</SubType>\n    </Compile>\n    <Compile Include=\"Scrutinizer\\UI\\CFGWidget.Designer.cs\">\n      <DependentUpon>CFGWidget.cs</DependentUpon>\n    </Compile>\n    <Compile Include=\"Scrutinizer\\UI\\InstructionWidget.cs\">\n      <SubType>UserControl</SubType>\n    </Compile>\n    <Compile Include=\"Scrutinizer\\UI\\InstructionWidget.Designer.cs\">\n      <DependentUpon>InstructionWidget.cs</DependentUpon>\n    </Compile>\n    <Compile Include=\"Scrutinizer\\UI\\ParameterWidget.cs\">\n      <SubType>UserControl</SubType>\n    </Compile>\n    <Compile Include=\"Scrutinizer\\UI\\ParameterWidget.Designer.cs\">\n      <DependentUpon>ParameterWidget.cs</DependentUpon>\n    </Compile>\n    <Compile Include=\"Scrutinizer\\UI\\ScrutinizerForm.cs\">\n      <SubType>Form</SubType>\n    </Compile>\n    <Compile Include=\"Scrutinizer\\UI\\ScrutinizerForm.Designer.cs\">\n      <DependentUpon>ScrutinizerForm.cs</DependentUpon>\n    </Compile>\n    <EmbeddedResource Include=\"Backends\\AMDDriverResultsPanel.resx\">\n      <DependentUpon>AMDDriverResultsPanel.cs</DependentUpon>\n    </EmbeddedResource>\n    <EmbeddedResource Include=\"Backends\\GLSlangResultsPanel.resx\">\n      <DependentUpon>GLSlangResultsPanel.cs</DependentUpon>\n    </EmbeddedResource>\n    <EmbeddedResource Include=\"Backends\\IntelShaderAnalyzerResultsPanel.resx\">\n      <DependentUpon>IntelShaderAnalyzerResultsPanel.cs</DependentUpon>\n    </EmbeddedResource>\n    <EmbeddedResource Include=\"Backends\\MaliSCResultsPanel.resx\">\n      <DependentUpon>MaliSCResultsPanel.cs</DependentUpon>\n    </EmbeddedResource>\n    <EmbeddedResource Include=\"MainUI\\AboutBox.resx\">\n      <DependentUpon>AboutBox.cs</DependentUpon>\n    </EmbeddedResource>\n    <EmbeddedResource Include=\"Backends\\CodeXLAnalysisPanel.resx\">\n      <DependentUpon>CodeXLAnalysisPanel.cs</DependentUpon>\n    </EmbeddedResource>\n    <EmbeddedResource Include=\"Backends\\CodeXLResultsPanel.resx\">\n      <DependentUpon>CodeXLResultsPanel.cs</DependentUpon>\n    </EmbeddedResource>\n    <EmbeddedResource Include=\"Backends\\FXCResultsPanel.resx\">\n      <DependentUpon>FXCResultsPanel.cs</DependentUpon>\n    </EmbeddedResource>\n    <EmbeddedResource Include=\"Languages\\GLSLOptionsPanel.resx\">\n      <DependentUpon>GLSLOptionsPanel.cs</DependentUpon>\n    </EmbeddedResource>\n    <EmbeddedResource Include=\"Languages\\HLSLOptionsPanel.resx\">\n      <DependentUpon>HLSLOptionsPanel.cs</DependentUpon>\n    </EmbeddedResource>\n    <EmbeddedResource Include=\"MainUI\\MainForm.resx\">\n      <DependentUpon>MainForm.cs</DependentUpon>\n    </EmbeddedResource>\n    <EmbeddedResource Include=\"MainUI\\OptionsScreen.resx\">\n      <DependentUpon>OptionsScreen.cs</DependentUpon>\n    </EmbeddedResource>\n    <EmbeddedResource Include=\"Properties\\Resources.resx\">\n      <Generator>ResXFileCodeGenerator</Generator>\n      <LastGenOutput>Resources.Designer.cs</LastGenOutput>\n      <SubType>Designer</SubType>\n    </EmbeddedResource>\n    <Compile Include=\"Properties\\Resources.Designer.cs\">\n      <AutoGen>True</AutoGen>\n      <DependentUpon>Resources.resx</DependentUpon>\n      <DesignTime>True</DesignTime>\n    </Compile>\n    <EmbeddedResource Include=\"Backends\\PVRResultsPanel.resx\">\n      <DependentUpon>PVRResultsPanel.cs</DependentUpon>\n    </EmbeddedResource>\n    <EmbeddedResource Include=\"Scrutinizer\\UI\\CFGWidget.resx\">\n      <DependentUpon>CFGWidget.cs</DependentUpon>\n    </EmbeddedResource>\n    <EmbeddedResource Include=\"Scrutinizer\\UI\\InstructionWidget.resx\">\n      <DependentUpon>InstructionWidget.cs</DependentUpon>\n    </EmbeddedResource>\n    <EmbeddedResource Include=\"Scrutinizer\\UI\\ScrutinizerForm.resx\">\n      <DependentUpon>ScrutinizerForm.cs</DependentUpon>\n    </EmbeddedResource>\n    <None Include=\"Properties\\Settings.settings\">\n      <Generator>SettingsSingleFileGenerator</Generator>\n      <LastGenOutput>Settings.Designer.cs</LastGenOutput>\n    </None>\n    <Compile Include=\"Properties\\Settings.Designer.cs\">\n      <AutoGen>True</AutoGen>\n      <DependentUpon>Settings.settings</DependentUpon>\n      <DesignTimeSharedInput>True</DesignTimeSharedInput>\n    </Compile>\n  </ItemGroup>\n  <ItemGroup>\n    <None Include=\"App.config\" />\n  </ItemGroup>\n  <ItemGroup>\n    <BootstrapperPackage Include=\"Microsoft.Net.Client.3.5\">\n      <Visible>False</Visible>\n      <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>\n      <Install>false</Install>\n    </BootstrapperPackage>\n    <BootstrapperPackage Include=\"Microsoft.Net.Framework.3.5.SP1\">\n      <Visible>False</Visible>\n      <ProductName>.NET Framework 3.5 SP1</ProductName>\n      <Install>true</Install>\n    </BootstrapperPackage>\n  </ItemGroup>\n  <ItemGroup>\n    <ProjectReference Include=\"ICSharpCode.TextEditor\\Project\\ICSharpCode.TextEditor.csproj\">\n      <Project>{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}</Project>\n      <Name>ICSharpCode.TextEditor</Name>\n    </ProjectReference>\n    <ProjectReference Include=\"PyramidTypes.csproj\">\n      <Project>{3d7db344-0267-4890-8186-9fc22b78b738}</Project>\n      <Name>PyramidTypes</Name>\n    </ProjectReference>\n    <ProjectReference Include=\"Wrapper\\Wrapper.vcxproj\">\n      <Project>{aeccee3c-29c5-46de-9ae2-afb5df6d110a}</Project>\n      <Name>Wrapper</Name>\n    </ProjectReference>\n  </ItemGroup>\n  <ItemGroup />\n  <Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />\n  <PropertyGroup>\n    <PostBuildEvent>copy $(TargetPath) $(SolutionDir)\\..\\bin</PostBuildEvent>\n  </PropertyGroup>\n  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \n       Other similar extension points exist, see Microsoft.Common.targets.\n  <Target Name=\"BeforeBuild\">\n  </Target>\n  <Target Name=\"AfterBuild\">\n  </Target>\n  -->\n</Project>"
  },
  {
    "path": "src/Pyramid.sln",
    "content": "﻿\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio Express 2013 for Windows Desktop\nVisualStudioVersion = 12.0.40629.0\nMinimumVisualStudioVersion = 10.0.40219.1\nProject(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"Pyramid\", \"Pyramid.csproj\", \"{BFF31873-BEEA-4528-ACE9-27DDFD150BF1}\"\n\tProjectSection(ProjectDependencies) = postProject\n\t\t{AECCEE3C-29C5-46DE-9AE2-AFB5DF6D110A} = {AECCEE3C-29C5-46DE-9AE2-AFB5DF6D110A}\n\tEndProjectSection\nEndProject\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"Wrapper\", \"Wrapper\\Wrapper.vcxproj\", \"{AECCEE3C-29C5-46DE-9AE2-AFB5DF6D110A}\"\n\tProjectSection(ProjectDependencies) = postProject\n\t\t{B475A403-9D9B-410D-8A93-BA49FC4DD811} = {B475A403-9D9B-410D-8A93-BA49FC4DD811}\n\t\t{3B146CC5-B2B8-4573-9D46-6139E2EDFEA3} = {3B146CC5-B2B8-4573-9D46-6139E2EDFEA3}\n\tEndProjectSection\nEndProject\nProject(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"PyramidTypes\", \"PyramidTypes.csproj\", \"{3D7DB344-0267-4890-8186-9FC22B78B738}\"\nEndProject\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"glsl_optimizer_lib_2013\", \"Wrapper\\glsl-optimizer\\projects\\vs2013\\glsl_optimizer_lib_2013.vcxproj\", \"{B475A403-9D9B-410D-8A93-BA49FC4DD811}\"\nEndProject\nProject(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"ICSharpCode.TextEditor\", \"ICSharpCode.TextEditor\\Project\\ICSharpCode.TextEditor.csproj\", \"{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}\"\nEndProject\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"glslang\", \"Wrapper\\GLSlang\\glslang_Pyramid.vcxproj\", \"{3B146CC5-B2B8-4573-9D46-6139E2EDFEA3}\"\nEndProject\nProject(\"{2150E333-8FDC-42A3-9474-1A3956D46DE8}\") = \"Solution Items\", \"Solution Items\", \"{BB77DB07-A9CC-44F1-B567-E77BF5F82440}\"\n\tProjectSection(SolutionItems) = preProject\n\t\t..\\README.md = ..\\README.md\n\tEndProjectSection\nEndProject\nGlobal\n\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n\t\tDebug|Any CPU = Debug|Any CPU\n\t\tDebug|Mixed Platforms = Debug|Mixed Platforms\n\t\tDebug|Win32 = Debug|Win32\n\t\tDebug|x64 = Debug|x64\n\t\tRelease|Any CPU = Release|Any CPU\n\t\tRelease|Mixed Platforms = Release|Mixed Platforms\n\t\tRelease|Win32 = Release|Win32\n\t\tRelease|x64 = Release|x64\n\tEndGlobalSection\n\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n\t\t{BFF31873-BEEA-4528-ACE9-27DDFD150BF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\n\t\t{BFF31873-BEEA-4528-ACE9-27DDFD150BF1}.Debug|Any CPU.Build.0 = Debug|Any CPU\n\t\t{BFF31873-BEEA-4528-ACE9-27DDFD150BF1}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU\n\t\t{BFF31873-BEEA-4528-ACE9-27DDFD150BF1}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU\n\t\t{BFF31873-BEEA-4528-ACE9-27DDFD150BF1}.Debug|Win32.ActiveCfg = Debug|Any CPU\n\t\t{BFF31873-BEEA-4528-ACE9-27DDFD150BF1}.Debug|Win32.Build.0 = Debug|Any CPU\n\t\t{BFF31873-BEEA-4528-ACE9-27DDFD150BF1}.Debug|x64.ActiveCfg = Debug|Any CPU\n\t\t{BFF31873-BEEA-4528-ACE9-27DDFD150BF1}.Release|Any CPU.ActiveCfg = Release|Any CPU\n\t\t{BFF31873-BEEA-4528-ACE9-27DDFD150BF1}.Release|Any CPU.Build.0 = Release|Any CPU\n\t\t{BFF31873-BEEA-4528-ACE9-27DDFD150BF1}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU\n\t\t{BFF31873-BEEA-4528-ACE9-27DDFD150BF1}.Release|Mixed Platforms.Build.0 = Release|Any CPU\n\t\t{BFF31873-BEEA-4528-ACE9-27DDFD150BF1}.Release|Win32.ActiveCfg = Release|Any CPU\n\t\t{BFF31873-BEEA-4528-ACE9-27DDFD150BF1}.Release|Win32.Build.0 = Release|Any CPU\n\t\t{BFF31873-BEEA-4528-ACE9-27DDFD150BF1}.Release|x64.ActiveCfg = Release|Any CPU\n\t\t{AECCEE3C-29C5-46DE-9AE2-AFB5DF6D110A}.Debug|Any CPU.ActiveCfg = Debug|Win32\n\t\t{AECCEE3C-29C5-46DE-9AE2-AFB5DF6D110A}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32\n\t\t{AECCEE3C-29C5-46DE-9AE2-AFB5DF6D110A}.Debug|Mixed Platforms.Build.0 = Debug|Win32\n\t\t{AECCEE3C-29C5-46DE-9AE2-AFB5DF6D110A}.Debug|Win32.ActiveCfg = Debug|Win32\n\t\t{AECCEE3C-29C5-46DE-9AE2-AFB5DF6D110A}.Debug|Win32.Build.0 = Debug|Win32\n\t\t{AECCEE3C-29C5-46DE-9AE2-AFB5DF6D110A}.Debug|x64.ActiveCfg = Debug|Win32\n\t\t{AECCEE3C-29C5-46DE-9AE2-AFB5DF6D110A}.Release|Any CPU.ActiveCfg = Release|Win32\n\t\t{AECCEE3C-29C5-46DE-9AE2-AFB5DF6D110A}.Release|Mixed Platforms.ActiveCfg = Release|Win32\n\t\t{AECCEE3C-29C5-46DE-9AE2-AFB5DF6D110A}.Release|Mixed Platforms.Build.0 = Release|Win32\n\t\t{AECCEE3C-29C5-46DE-9AE2-AFB5DF6D110A}.Release|Win32.ActiveCfg = Release|Win32\n\t\t{AECCEE3C-29C5-46DE-9AE2-AFB5DF6D110A}.Release|Win32.Build.0 = Release|Win32\n\t\t{AECCEE3C-29C5-46DE-9AE2-AFB5DF6D110A}.Release|x64.ActiveCfg = Release|Win32\n\t\t{3D7DB344-0267-4890-8186-9FC22B78B738}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\n\t\t{3D7DB344-0267-4890-8186-9FC22B78B738}.Debug|Any CPU.Build.0 = Debug|Any CPU\n\t\t{3D7DB344-0267-4890-8186-9FC22B78B738}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU\n\t\t{3D7DB344-0267-4890-8186-9FC22B78B738}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU\n\t\t{3D7DB344-0267-4890-8186-9FC22B78B738}.Debug|Win32.ActiveCfg = Debug|Any CPU\n\t\t{3D7DB344-0267-4890-8186-9FC22B78B738}.Debug|Win32.Build.0 = Debug|Any CPU\n\t\t{3D7DB344-0267-4890-8186-9FC22B78B738}.Debug|x64.ActiveCfg = Debug|Any CPU\n\t\t{3D7DB344-0267-4890-8186-9FC22B78B738}.Release|Any CPU.ActiveCfg = Release|Any CPU\n\t\t{3D7DB344-0267-4890-8186-9FC22B78B738}.Release|Any CPU.Build.0 = Release|Any CPU\n\t\t{3D7DB344-0267-4890-8186-9FC22B78B738}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU\n\t\t{3D7DB344-0267-4890-8186-9FC22B78B738}.Release|Mixed Platforms.Build.0 = Release|Any CPU\n\t\t{3D7DB344-0267-4890-8186-9FC22B78B738}.Release|Win32.ActiveCfg = Release|Any CPU\n\t\t{3D7DB344-0267-4890-8186-9FC22B78B738}.Release|Win32.Build.0 = Release|Any CPU\n\t\t{3D7DB344-0267-4890-8186-9FC22B78B738}.Release|x64.ActiveCfg = Release|Any CPU\n\t\t{B475A403-9D9B-410D-8A93-BA49FC4DD811}.Debug|Any CPU.ActiveCfg = Debug|Win32\n\t\t{B475A403-9D9B-410D-8A93-BA49FC4DD811}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32\n\t\t{B475A403-9D9B-410D-8A93-BA49FC4DD811}.Debug|Mixed Platforms.Build.0 = Debug|Win32\n\t\t{B475A403-9D9B-410D-8A93-BA49FC4DD811}.Debug|Win32.ActiveCfg = Debug|Win32\n\t\t{B475A403-9D9B-410D-8A93-BA49FC4DD811}.Debug|Win32.Build.0 = Debug|Win32\n\t\t{B475A403-9D9B-410D-8A93-BA49FC4DD811}.Debug|x64.ActiveCfg = Debug|x64\n\t\t{B475A403-9D9B-410D-8A93-BA49FC4DD811}.Debug|x64.Build.0 = Debug|x64\n\t\t{B475A403-9D9B-410D-8A93-BA49FC4DD811}.Release|Any CPU.ActiveCfg = Release|Win32\n\t\t{B475A403-9D9B-410D-8A93-BA49FC4DD811}.Release|Mixed Platforms.ActiveCfg = Release|Win32\n\t\t{B475A403-9D9B-410D-8A93-BA49FC4DD811}.Release|Mixed Platforms.Build.0 = Release|Win32\n\t\t{B475A403-9D9B-410D-8A93-BA49FC4DD811}.Release|Win32.ActiveCfg = Release|Win32\n\t\t{B475A403-9D9B-410D-8A93-BA49FC4DD811}.Release|Win32.Build.0 = Release|Win32\n\t\t{B475A403-9D9B-410D-8A93-BA49FC4DD811}.Release|x64.ActiveCfg = Release|x64\n\t\t{B475A403-9D9B-410D-8A93-BA49FC4DD811}.Release|x64.Build.0 = Release|x64\n\t\t{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\n\t\t{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Debug|Any CPU.Build.0 = Debug|Any CPU\n\t\t{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU\n\t\t{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU\n\t\t{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Debug|Win32.ActiveCfg = Debug|Any CPU\n\t\t{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Debug|Win32.Build.0 = Debug|Any CPU\n\t\t{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Debug|x64.ActiveCfg = Debug|Any CPU\n\t\t{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Release|Any CPU.ActiveCfg = Release|Any CPU\n\t\t{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Release|Any CPU.Build.0 = Release|Any CPU\n\t\t{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU\n\t\t{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Release|Mixed Platforms.Build.0 = Release|Any CPU\n\t\t{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Release|Win32.ActiveCfg = Release|Any CPU\n\t\t{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Release|Win32.Build.0 = Release|Any CPU\n\t\t{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Release|x64.ActiveCfg = Release|Any CPU\n\t\t{3B146CC5-B2B8-4573-9D46-6139E2EDFEA3}.Debug|Any CPU.ActiveCfg = Debug|Win32\n\t\t{3B146CC5-B2B8-4573-9D46-6139E2EDFEA3}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32\n\t\t{3B146CC5-B2B8-4573-9D46-6139E2EDFEA3}.Debug|Mixed Platforms.Build.0 = Debug|Win32\n\t\t{3B146CC5-B2B8-4573-9D46-6139E2EDFEA3}.Debug|Win32.ActiveCfg = Debug|Win32\n\t\t{3B146CC5-B2B8-4573-9D46-6139E2EDFEA3}.Debug|Win32.Build.0 = Debug|Win32\n\t\t{3B146CC5-B2B8-4573-9D46-6139E2EDFEA3}.Debug|x64.ActiveCfg = Debug|x64\n\t\t{3B146CC5-B2B8-4573-9D46-6139E2EDFEA3}.Debug|x64.Build.0 = Debug|x64\n\t\t{3B146CC5-B2B8-4573-9D46-6139E2EDFEA3}.Release|Any CPU.ActiveCfg = Release|Win32\n\t\t{3B146CC5-B2B8-4573-9D46-6139E2EDFEA3}.Release|Mixed Platforms.ActiveCfg = Release|Win32\n\t\t{3B146CC5-B2B8-4573-9D46-6139E2EDFEA3}.Release|Mixed Platforms.Build.0 = Release|Win32\n\t\t{3B146CC5-B2B8-4573-9D46-6139E2EDFEA3}.Release|Win32.ActiveCfg = Release|Win32\n\t\t{3B146CC5-B2B8-4573-9D46-6139E2EDFEA3}.Release|Win32.Build.0 = Release|Win32\n\t\t{3B146CC5-B2B8-4573-9D46-6139E2EDFEA3}.Release|x64.ActiveCfg = Release|x64\n\t\t{3B146CC5-B2B8-4573-9D46-6139E2EDFEA3}.Release|x64.Build.0 = Release|x64\n\tEndGlobalSection\n\tGlobalSection(SolutionProperties) = preSolution\n\t\tHideSolutionNode = FALSE\n\tEndGlobalSection\nEndGlobal\n"
  },
  {
    "path": "src/PyramidTypes.csproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"12.0\" DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <Import Project=\"$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props\" Condition=\"Exists('$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props')\" />\n  <PropertyGroup>\n    <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>\n    <Platform Condition=\" '$(Platform)' == '' \">AnyCPU</Platform>\n    <ProjectGuid>{3D7DB344-0267-4890-8186-9FC22B78B738}</ProjectGuid>\n    <OutputType>Library</OutputType>\n    <AppDesignerFolder>Properties</AppDesignerFolder>\n    <RootNamespace>PyramidTypes</RootNamespace>\n    <AssemblyName>PyramidTypes</AssemblyName>\n    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>\n    <FileAlignment>512</FileAlignment>\n  </PropertyGroup>\n  <PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' \">\n    <PlatformTarget>AnyCPU</PlatformTarget>\n    <DebugSymbols>true</DebugSymbols>\n    <DebugType>full</DebugType>\n    <Optimize>false</Optimize>\n    <OutputPath>bin\\Debug\\</OutputPath>\n    <DefineConstants>DEBUG;TRACE</DefineConstants>\n    <ErrorReport>prompt</ErrorReport>\n    <WarningLevel>4</WarningLevel>\n  </PropertyGroup>\n  <PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' \">\n    <PlatformTarget>AnyCPU</PlatformTarget>\n    <DebugType>pdbonly</DebugType>\n    <Optimize>true</Optimize>\n    <OutputPath>bin\\Release\\</OutputPath>\n    <DefineConstants>TRACE</DefineConstants>\n    <ErrorReport>prompt</ErrorReport>\n    <WarningLevel>4</WarningLevel>\n  </PropertyGroup>\n  <PropertyGroup>\n    <StartupObject />\n  </PropertyGroup>\n  <ItemGroup>\n    <Compile Include=\"GLSlang.cs\" />\n    <Compile Include=\"GLSLOptimizer.cs\" />\n    <Compile Include=\"GLSLTypes.cs\" />\n    <Compile Include=\"HLSLTypes.cs\" />\n    <Compile Include=\"IAMDDriver.cs\" />\n    <Compile Include=\"IIncludeHandler.cs\" />\n    <Compile Include=\"IWrapper.cs\" />\n    <Compile Include=\"LanguageTypes.cs\" />\n    <Compile Include=\"ScrutinizerTypes.cs\" />\n    <Compile Include=\"SPIRV.cs\" />\n  </ItemGroup>\n  <ItemGroup>\n    <Reference Include=\"System\" />\n  </ItemGroup>\n  <Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />\n  <PropertyGroup>\n    <PostBuildEvent>copy $(TargetPath) $(SolutionDir)\\..\\bin</PostBuildEvent>\n  </PropertyGroup>\n  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \n       Other similar extension points exist, see Microsoft.Common.targets.\n  <Target Name=\"BeforeBuild\">\n  </Target>\n  <Target Name=\"AfterBuild\">\n  </Target>\n  -->\n</Project>"
  },
  {
    "path": "src/SPIRV.cs",
    "content": "﻿using System;\n\nnamespace Pyramid\n{\n    namespace SPIRV\n    {\n        public interface IProgram\n        {\n            string Disassemble();\n            uint[] GetTokens();\n            byte[] GetBytes();\n        }\n\n\n    }\n}"
  },
  {
    "path": "src/Scrutinizer/Analysis/Algorithms.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace Pyramid.Scrutinizer\n{\n\n    public static class Algorithms\n    {\n        public static bool IsCFGReducible( List<BasicBlock> Blocks )\n        {\n            BasicBlock[] blocks = Blocks.ToArray();\n            HashSet<BasicBlock>[] Successors   = new HashSet<BasicBlock>[blocks.Length];\n            HashSet<BasicBlock>[] Predecessors = new HashSet<BasicBlock>[blocks.Length];\n            Dictionary<BasicBlock, int> Index  = new Dictionary<BasicBlock, int>();\n\n            // For reference: http://www.cs.colostate.edu/~mstrout/CS553Fall06/slides/lecture13-control.pdf\n            // A CFG is reducible if it can be reduced to a single node via T1/T2 transforms\n            //  \n            int nBlocks = 0;\n            foreach (BasicBlock b in blocks)\n            {\n                Successors[nBlocks] = new HashSet<BasicBlock>(b.Successors);\n                Predecessors[nBlocks] = new HashSet<BasicBlock>(b.Predecessors);\n                Index.Add(b, nBlocks);\n                nBlocks++;\n            }\n\n            while (nBlocks > 1)\n            {\n                // T1 transform: delete all self-loops\n                for (int i = 0; i < nBlocks; i++)\n                {\n                    BasicBlock bi = blocks[i];\n                    Successors[i].Remove(blocks[i]);\n                    Predecessors[i].Remove(blocks[i]);\n                }\n\n                // find nodes having only one predecessor and merge them into their predecessor\n                int n = nBlocks;\n                nBlocks = 0;\n                for (int i = 0; i < n; i++)\n                {\n                    if (Predecessors[i].Count == 1)\n                    {\n                        // merge this node with its single predecessor\n                        BasicBlock victim = blocks[i];\n                        BasicBlock replacement = Predecessors[i].ElementAt(0);\n\n                        // link successor blocks to replacement\n                        foreach (BasicBlock s in Successors[i])\n                        {\n                            var preds = Predecessors[Index[s]];\n                            preds.Remove(victim);\n                            preds.Add(replacement);\n                        }\n\n                        // link replacement to successors\n                        var replacement_successors = Successors[Index[replacement]];\n                        replacement_successors.Remove(victim);\n                        replacement_successors.UnionWith(Successors[i]);\n                    }\n                    else\n                    {\n                        // compact the array\n                        blocks[nBlocks++] = blocks[i];\n                    }\n                }\n\n                // bail out if we failed to find a reducible node\n                if (n == nBlocks)\n                    return false;\n            }\n\n            return true;\n        }\n\n\n        public static List<BasicBlock> BuildBasicBlocks(List<IInstruction> ops)\n        {\n            // collect set of branch targets\n            HashSet<IInstruction> BranchTargets = new HashSet<IInstruction>();\n            foreach( IInstruction op in ops )\n            {\n                if( op is IJumpInstruction )\n                {\n                    IJumpInstruction it = op as IJumpInstruction;\n                    BranchTargets.Add( it.Target );\n                }\n                else if( op is IBranchInstruction )\n                {\n                    IBranchInstruction it = op as IBranchInstruction;\n                    BranchTargets.Add( it.IfTarget );\n                    BranchTargets.Add( it.ElseTarget );\n                }\n            }\n\n            // walk instruction list and split off blocks at branches or branch targets\n            List<BasicBlock> Blocks = new List<BasicBlock>();\n            int nInstructions = ops.Count;\n            int i = 0;\n            do\n            {\n                BasicBlock block = new BasicBlock();\n                Blocks.Add(block);\n\n                do\n                {\n                    IInstruction op = ops[i++];\n                    block.AddInstruction(op);\n                    op.Block = block;\n\n                    // stop if we just added a branch/jump op\n                    if (op is IJumpInstruction || op is IBranchInstruction)\n                        break;\n\n                    // stop if next instruction is a branch target\n                    if (i<nInstructions && BranchTargets.Contains(ops[i]))\n                        break;\n\n                } while (i < nInstructions);\n               \n            } while (i < nInstructions);\n\n            // construct CFG edges\n            for( int b=0; b<Blocks.Count; b++ )\n            {\n                IInstruction op = Blocks[b].LastInstruction;\n                if (op is IBranchInstruction)\n                {\n                    IBranchInstruction branch = op as IBranchInstruction;\n                    if (branch.IfTarget != null)\n                    {\n                        branch.Block.AddSuccessor(branch.IfTarget.Block);\n                        branch.IfTarget.Block.AddPredecessor(branch.Block);\n                    }\n                    if (branch.ElseTarget != null)\n                    {\n                        branch.Block.AddSuccessor(branch.ElseTarget.Block);\n                        branch.ElseTarget.Block.AddPredecessor(branch.Block);\n                    }\n                }\n                else if (op is IJumpInstruction)\n                {\n                    // unconditional branch or jump, add target as one and only successor\n                    IJumpInstruction jmp = op as IJumpInstruction;\n                    if (jmp.Target != null)\n                    {\n                        jmp.Block.AddSuccessor(jmp.Target.Block);\n                        jmp.Target.Block.AddPredecessor(jmp.Block);\n                    }\n                }\n                else if ( b < Blocks.Count-1 )\n                {\n                    // Block ends in something other than a branch or jump\n                    //  add next block as successor\n                    Blocks[b].AddSuccessor(Blocks[b + 1]);\n                    Blocks[b + 1].AddPredecessor(Blocks[b]);\n                }\n            }\n          \n            return Blocks;\n        }\n\n        /// <summary>\n        ///  Test whether node a dominates node b\n        ///     That is, a is equal to be, or an ancestor of b in the dom tree\n        /// </summary>\n        /// <typeparam name=\"T\"></typeparam>\n        /// <param name=\"a\"></param>\n        /// <param name=\"b\"></param>\n        /// <param name=\"IDOM\"></param>\n        /// <returns></returns>\n        public static bool Dominates<T>( T a, T b, Dictionary<T,T> IDOM ) where T : class\n        {\n            if (a == b)\n                return true;\n\n            T n = IDOM[b];\n            while( n != null && n != a )\n                n = IDOM[n];\n            \n            return n == a;\n        }\n\n\n        /// <summary>\n        ///  Find immediate dominators for each node in a graph\n        /// </summary>\n        /// <param name=\"nodes\"></param>\n        /// <param name=\"edges\"></param>\n        /// <returns></returns>\n\n        public static Dictionary<T,T> FindDominators<T>( T[] nodes, T[][] predecessors ) where T : class\n        {\n            if( nodes.Length == 0 )\n                return new Dictionary<T,T>();\n\n            // Algorithm here is based on Keith Kooper's COMP512 lecture nodes\n            //   from: http://www.cs.rice.edu/~keith/512/2011/Lectures/\n            //\n            // This could be made redonkulously fast using bit vectors, but we're already using C# so why bother...\n\n            // dominator of the start node is the start itself\n            //Dom(n0) = {n0}\n            //// for all other nodes, set all nodes as the dominators\n            //for each n in N - {n0}\n            //    Dom(n) = N;\n            //// iteratively eliminate nodes that are not dominators\n            //while changes in any Dom(n)\n            //    for each n in N - {n0}:  // JDB: Note, just N also works...\n            //        Dom(n) = {n} union with intersection over all p in pred(n) of Dom(p)\n\n\n            Dictionary<T,HashSet<T>> doms = new Dictionary<T,HashSet<T>>();\n            \n\n            \n            // dominator of start node is the node itself\n            //  dom-set of other nodes initially set to entire graph\n            T start = nodes[0];\n            foreach (T b in nodes)\n            {\n                if (b == start)\n                {\n                    HashSet<T> s = new HashSet<T>();\n                    s.Add(b);\n                    doms.Add(b,s);\n                }\n                else\n                {\n                    doms.Add(b, new HashSet<T>(nodes));\n                }\n            }\n\n            //// iteratively eliminate nodes that are not dominators\n            //while changes in any Dom(n)\n            //    for each n in N - {n0}:  // JDB: Note, just N also works...\n            //        Dom(n) = {n} union with intersection over all p in pred(n) of Dom(p)\n            int changes;\n            do\n            {\n                changes = 0;\n                for (int i = 0; i < nodes.Length; i++  )\n                {\n                    HashSet<T> s = new HashSet<T>();\n                    T[] preds = predecessors[i];\n                    if (preds.Length > 0)\n                    {\n                        foreach (T d in doms[preds[0]])\n                            s.Add(d);\n                        for (int j = 1; j < preds.Length; j++)\n                            s.IntersectWith(doms[preds[j]]);\n                    }\n\n                    T n = nodes[i];\n                    s.Add(n);\n\n                    if (!s.SetEquals(doms[n]))\n                        changes++;\n\n                    doms[n] = s;\n                }\n\n            } while (changes != 0);\n\n\n            // find immediate dominator for each block\n            //  IDOM[b] is the node from doms[b] with highest dominator count\n            //    excluding the node itself\n            //\n            //  IDOM[start] = null\n            //\n            Dictionary<T, T> IDOM = new Dictionary<T, T>();\n            for( int i=0; i<nodes.Length; i++ )\n            {\n                IDOM.Add(nodes[i],default(T));\n                int depth = 0;\n                T b = nodes[i];\n                foreach (T d in doms[b])\n                {\n                    if (d == b)\n                        continue;\n\n                    int count = doms[d].Count;\n                    if (depth < count)\n                    {\n                        IDOM[nodes[i]] = d;\n                        depth = count;\n                    }\n                }\n            }\n\n            return IDOM;\n        }\n\n\n\n        public static void FindDominators(List<BasicBlock> Blocks)\n        {\n            BasicBlock[] nodes = Blocks.ToArray();\n            BasicBlock[][] preds = new BasicBlock[nodes.Length][];\n            BasicBlock[][] succs = new BasicBlock[nodes.Length][];\n            for (int i = 0; i < nodes.Length; i++)\n            {\n                preds[i] = nodes[i].Predecessors.ToArray();\n                succs[i] = nodes[i].Successors.ToArray();\n            }\n\n            // dominators\n            Dictionary<BasicBlock,BasicBlock> IDOM = FindDominators(nodes, preds);\n            for( int i=0; i<nodes.Length; i++ )\n                nodes[i].ImmediateDominator = IDOM[nodes[i]];\n\n            // post-dominators\n            Dictionary<BasicBlock,BasicBlock> PDOM = FindDominators( nodes, succs );\n            for (int i = 0; i < nodes.Length; i++)\n                nodes[i].PostDominator = PDOM[nodes[i]];\n        }\n\n\n\n        public static List<Loop> FindLoops( List<BasicBlock> blocks )\n        {\n            // Great reference:  T Mowry's slides on loop invariant code motion\n            // http://www.cs.cmu.edu/afs/cs/academic/class/15745-s11/public/lectures/L7-LICM.pdf\n            //\n            // We assume a reversible flow graph\n            //\n\n            // 1.  Find back edges\n            List<KeyValuePair<BasicBlock, BasicBlock>> BackEdges = new List<KeyValuePair<BasicBlock, BasicBlock>>();\n            foreach (BasicBlock b in blocks)\n                foreach( BasicBlock s in b.Successors )\n                    if (s.Dominates(b))\n                        BackEdges.Add(new KeyValuePair<BasicBlock, BasicBlock>(b, s));\n            \n            // 2.  Identify natural loop for each backedge\n            //    by walking graph upwards to dominator\n            //\n            //  The natural loop of a back edge is the set of blocks dominated by the head\n            //    and which can reach the tail without traversing any backedge\n            //\n            HashSet<BasicBlock>[] LoopSets = new HashSet<BasicBlock>[BackEdges.Count];\n            for (int i = 0; i < BackEdges.Count; i++)\n                LoopSets[i] = new HashSet<BasicBlock>();\n\n            Stack<BasicBlock> S = new Stack<BasicBlock>();\n            for( int i=0; i<BackEdges.Count; i++ )\n            {\n                BasicBlock header = BackEdges[i].Value;\n                S.Push(BackEdges[i].Key);\n                LoopSets[i].Add(BackEdges[i].Key);\n\n                do\n                {\n                    BasicBlock n = S.Pop();\n                    if (n != header)\n                    {\n                        foreach (BasicBlock p in n.Predecessors)\n                        {\n                            if (!LoopSets[i].Contains(p))\n                            {\n                                LoopSets[i].Add(p);\n                                S.Push(p);\n                            }\n                        }\n                    }\n                } while (S.Count > 0);\n            }\n\n            //\n            // 3.  Merge loops with same header wherever one is not a proper subset of the other\n            //\n            List<Loop> loops = new List<Loop>();\n            for (int i = 0; i < BackEdges.Count; i++)\n            {\n                BasicBlock header = BackEdges[i].Value;\n                HashSet<BasicBlock> loop = LoopSets[i];\n                if (loop == null)\n                    continue; // this loop was merged earlier\n\n                // find other loops with same header and merge with them with in with this one\n                for (int j = i + 1; j < BackEdges.Count; j++)\n                {\n                    if (BackEdges[j].Value == header)\n                    {\n                        HashSet<BasicBlock> otherLoop = LoopSets[j];\n                        if (loop.IsProperSubsetOf(otherLoop) )\n                            continue;\n                        if (otherLoop.IsProperSupersetOf(loop)) \n                            continue;\n\n                        LoopSets[i].UnionWith(LoopSets[j]);\n                        LoopSets[j] = null;\n                    }\n                }\n                loops.Add(new Loop(header, loop));\n\n            }\n\n            \n            // Determine nestedness for remaining loops\n            //   Loops are now either disjoint, or one is fully nested in the other\n            // loop i is nested in loop j if j's header dominates i's header\n            //   or they have the same header and j is larger\n            int nLoops = loops.Count;\n            List<int>[] LoopAncestors = new List<int>[nLoops];\n            for (int i = 0; i < nLoops; i++)\n            {\n                List<int> ancestors = new List<int>();\n                Loop li = loops[i];\n\n                for (int j = 0; j < nLoops; j++)\n                {\n                    if (i == j)\n                        continue;\n\n                    Loop lj = loops[j];\n                    if (li.Header != lj.Header )\n                    {\n                        if (lj.Header.Dominates(li.Header))\n                            ancestors.Add(j);\n                    }\n                    else\n                    {\n                        if (lj.BlockCount > li.BlockCount )\n                            ancestors.Add(j);\n                    }\n                }\n\n                LoopAncestors[i] = ancestors;\n            }\n\n            int[] DescendentCounts = new int[nLoops];\n            for (int i = 0; i < nLoops; i++ )\n                foreach (int k in LoopAncestors[i])\n                    DescendentCounts[k]++;\n            \n\n            // Find innermost parent for each loop, \n            //  which is the one with the lowest descendent count\n            for (int i = 0; i < nLoops; i++)\n            {\n                List<int> ancestors = LoopAncestors[i];\n                if ( ancestors.Count != 0 )\n                {\n                    int nImmediateParent = ancestors[0];\n                    for (int j = 1; j < ancestors.Count; j++)\n                        if (DescendentCounts[ancestors[j]] < DescendentCounts[nImmediateParent])\n                            nImmediateParent = ancestors[j];\n\n                    loops[i].Parent = loops[nImmediateParent];\n                }\n            }\n\n            // sort loops inner to outer\n            loops.Sort(\n                delegate(Loop x, Loop y)\n                {\n                    if (x == y)\n                        return 0;\n                    while (true)\n                    {\n                        x = x.Parent;\n                        if (x == null)\n                            return 1;\n                        else if (x == y)\n                            return -1;\n                    }\n                }\n            );\n\n            // Identify innermost loop for each block\n            foreach( Loop l in loops )\n            {\n                foreach (BasicBlock b in l.Blocks)\n                {\n                    if (b.InnerMostLoop == null)\n                        b.InnerMostLoop = l;\n                    else if (l.IsNestedIn(b.InnerMostLoop))\n                        b.InnerMostLoop = l;\n                }\n            }\n\n            return loops;\n            \n        }\n\n\n        static public void ClassifyBranches(  List<IInstruction> ops )\n        {\n            // It can be shown (I think) that, given our irreducible graph/nested loop structure\n            //  for any branch node n in loop L\n            //  at least one of N's two edges must be to a node also in L\n            //\n            // This follows from the construction of the loops\n            //   The loop set is the set of nodes dominated by the header\n            //    having paths to the header using only nodes in the loop set\n            //  \n            //\n            // Note that it is still possible to have a branch that descends into one of two different\n            //  nested sub-loops\n        \n\n            // We can thus classify branch instructions into two types:\n            //   - Fork\n            //     * both targets are nested within the containing block's loop\n            //\n            //   - Break branch\n            //     * At most one target is outside the containing block's loop\n            //\n           \n            foreach( IInstruction op in ops )\n            {\n                if (!(op is IBranchInstruction))\n                    continue;\n\n                IBranchInstruction branch = op as IBranchInstruction;\n                Loop ifLoop    = branch.IfTarget.Block.InnerMostLoop;\n                Loop elseLoop  = branch.ElseTarget.Block.InnerMostLoop;\n                Loop blockLoop = op.Block.InnerMostLoop;\n\n                if (blockLoop == null)\n                {\n                    branch.Category = BranchCategory.FORK_BRANCH;\n                }\n                else\n                {\n                    if (ifLoop == null && elseLoop == null)\n                        branch.Category = BranchCategory.FORK_BRANCH;\n                    else if (ifLoop == null && elseLoop != null)\n                        branch.Category = BranchCategory.BREAK_BRANCH;\n                    else if (ifLoop != null && elseLoop == null)\n                        branch.Category = BranchCategory.BREAK_BRANCH;\n                    else if (ifLoop.IsNestedIn(blockLoop) && elseLoop.IsNestedIn(blockLoop))\n                        branch.Category = BranchCategory.FORK_BRANCH;\n                    else if (ifLoop.IsNestedIn(blockLoop) || elseLoop.IsNestedIn(blockLoop))\n                        branch.Category = BranchCategory.BREAK_BRANCH;\n                    else\n                        throw new System.Exception(\"Ooops\");\n                }\n\n\n                // A \"fork branch\" can, in turn, be classified as:\n                //     - continue (conditional jump back to header)\n                //     - skip (jumps directly to branch's post-dominator)\n                //     - fork (everything else)\n                if( branch.Category == BranchCategory.FORK_BRANCH )\n                {\n                    if (blockLoop != null && (branch.IfTarget == blockLoop.Header || branch.ElseTarget == blockLoop.Header))\n                    {\n                        branch.Category = BranchCategory.CONTINUE_BRANCH;\n                    }\n\n                    if( branch.IfTarget.Block == branch.Block.PostDominator ||\n                        branch.ElseTarget.Block == branch.Block.PostDominator )\n                    {\n                        branch.Category = BranchCategory.SKIP_BRANCH;\n\n                        // a skip branch that jumps around a loop is yet another special case\n                        if( branch.IfTarget.Block != branch.Block.PostDominator && branch.IfTarget.Block.InnerMostLoop != blockLoop )\n                            branch.Category = BranchCategory.LOOPSKIP_BRANCH;\n                        else if (branch.ElseTarget.Block != branch.Block.PostDominator && branch.ElseTarget.Block.InnerMostLoop != blockLoop)\n                            branch.Category = BranchCategory.LOOPSKIP_BRANCH;\n                        \n                    }\n                }\n            }\n\n\n        }\n\n\n        public static void AssignLabels(List<IInstruction> ops)\n        {\n            int nBlock = 0;\n            BasicBlock bl = null;\n            for( int i=0; i<ops.Count; i++ )\n            {\n                if (ops[i].Block != bl)\n                {\n                    ops[i].Label = String.Format(\"Block_{0}\", nBlock++);\n                    bl = ops[i].Block;\n                }\n            }\n\n        }\n\n\n\n        public static List<IInstruction> DoTrace(List<IInstruction> ops, List<BasicBlock> blocks, List<Loop> loops, HashSet<IInstruction> takenBranches )\n        {\n            List<IInstruction> Exec = new List<IInstruction>();\n            Dictionary<Loop, int> LoopCounts = new Dictionary<Loop, int>();\n            foreach (Loop l in loops)\n                LoopCounts.Add(l, 0);\n\n\n\n            BasicBlock b = blocks.First();\n            do\n            {\n                // execute all instructions in current block\n                Exec.AddRange(b.Instructions);\n\n                // if block ends in a branch, determine which edge to take\n                IInstruction blockEnd = b.LastInstruction;\n                BasicBlock next = null;\n                if (blockEnd is IBranchInstruction)\n                {\n                    IBranchInstruction branch = blockEnd as IBranchInstruction;\n                    if( branch.Category == BranchCategory.BREAK_BRANCH )\n                    {\n                        // take a break branch as soon as the iteration count reaches zero\n                        BasicBlock exit = branch.IfTarget.Block;\n                        BasicBlock noexit = branch.ElseTarget.Block;\n                        if (exit.InnerMostLoop == b.InnerMostLoop)\n                        {\n                            exit = branch.ElseTarget.Block;\n                            noexit = branch.IfTarget.Block;\n                        }\n\n                        \n                        if (LoopCounts[b.InnerMostLoop] >= b.InnerMostLoop.DesiredIterations)\n                        {\n                            LoopCounts[b.InnerMostLoop] = 0;\n                            next = exit;\n                        }\n                        else\n                        {\n                            next = noexit;\n                        }\n\n                    }\n                    else if( branch.Category == BranchCategory.LOOPSKIP_BRANCH )\n                    {\n                        // don't enter unless the loop's iteration count is non-zero\n                        BasicBlock loop;\n                        BasicBlock noloop;\n                        if (branch.IfTarget.Block.InnerMostLoop != branch.Block.InnerMostLoop)\n                        {\n                            loop   = branch.IfTarget.Block;\n                            noloop = branch.ElseTarget.Block;\n                        }\n                        else\n                        {\n                            loop   = branch.ElseTarget.Block;\n                            noloop = branch.IfTarget.Block;\n                        }\n\n                        if (loop.InnerMostLoop.DesiredIterations > 0)\n                            next = loop;\n                        else\n                            next = noloop;\n                    }\n                    else if( branch.Category == BranchCategory.CONTINUE_BRANCH )\n                    {\n                        // do NOT take a continue branch if the count's up\n                        BasicBlock go = branch.IfTarget.Block;\n                        BasicBlock nogo = branch.ElseTarget.Block;\n                        if (nogo == b.InnerMostLoop.Header)\n                        {\n                            go = branch.ElseTarget.Block;\n                            nogo = branch.IfTarget.Block; // swap if needed\n                        }\n\n                        if (LoopCounts[b.InnerMostLoop] >= b.InnerMostLoop.DesiredIterations)\n                            next = nogo;\n                        else\n                            next = go;\n                    }\n                    else\n                    {\n                        if (takenBranches.Contains(branch))\n                            next = branch.IfTarget.Block;\n                        else\n                            next = branch.ElseTarget.Block;\n                    }\n                }\n                else if( blockEnd is IJumpInstruction )\n                {\n                    // if block ends in a jump, then jump\n                    IJumpInstruction jump = blockEnd as IJumpInstruction;\n                    next = jump.Target.Block;\n                }\n                else\n                {\n                    // otherwise, proceed to next successor block\n                    if (b.SuccessorCount > 0)\n                        next = b.Successors.First();\n                }\n\n                // increment loop count every time we pass a loop header\n                if( b.InnerMostLoop != null && b.InnerMostLoop.Header == b )\n                    LoopCounts[b.InnerMostLoop]++;\n\n                b = next;\n\n            } while (b != null);\n\n\n            return Exec;\n        }\n    };\n\n\n\n   \n\n}"
  },
  {
    "path": "src/Scrutinizer/UI/CFGWidget.Designer.cs",
    "content": "﻿namespace Pyramid.Scrutinizer.UI\r\n{\r\n    partial class CFGWidget\r\n    {\r\n        /// <summary> \r\n        /// Required designer variable.\r\n        /// </summary>\r\n        private System.ComponentModel.IContainer components = null;\r\n\r\n        /// <summary> \r\n        /// Clean up any resources being used.\r\n        /// </summary>\r\n        /// <param name=\"disposing\">true if managed resources should be disposed; otherwise, false.</param>\r\n        protected override void Dispose(bool disposing)\r\n        {\r\n            if (disposing && (components != null))\r\n            {\r\n                components.Dispose();\r\n            }\r\n            base.Dispose(disposing);\r\n        }\r\n\r\n        #region Component Designer generated code\r\n\r\n        /// <summary> \r\n        /// Required method for Designer support - do not modify \r\n        /// the contents of this method with the code editor.\r\n        /// </summary>\r\n        private void InitializeComponent()\r\n        {\r\n            this.treeView1 = new System.Windows.Forms.TreeView();\r\n            this.SuspendLayout();\r\n            // \r\n            // treeView1\r\n            // \r\n            this.treeView1.Dock = System.Windows.Forms.DockStyle.Fill;\r\n            this.treeView1.Location = new System.Drawing.Point(0, 0);\r\n            this.treeView1.Name = \"treeView1\";\r\n            this.treeView1.Size = new System.Drawing.Size(280, 270);\r\n            this.treeView1.TabIndex = 0;\r\n            this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);\r\n            this.treeView1.Leave += new System.EventHandler(this.treeView1_Leave);\r\n            // \r\n            // CFGWidget\r\n            // \r\n            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\r\n            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\r\n            this.Controls.Add(this.treeView1);\r\n            this.Name = \"CFGWidget\";\r\n            this.Size = new System.Drawing.Size(280, 270);\r\n            this.ResumeLayout(false);\r\n\r\n        }\r\n\r\n        #endregion\r\n\r\n        private System.Windows.Forms.TreeView treeView1;\r\n    }\r\n}\r\n"
  },
  {
    "path": "src/Scrutinizer/UI/CFGWidget.cs",
    "content": "﻿using System;\r\nusing System.Collections.Generic;\r\nusing System.ComponentModel;\r\nusing System.Drawing;\r\nusing System.Data;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Threading.Tasks;\r\nusing System.Windows.Forms;\r\n\r\nnamespace Pyramid.Scrutinizer.UI\r\n{\r\n    /// <summary>\r\n    ///  Control which is responsible for visualizing the control flow graph and\r\n    ///    allowing users to select blocks\r\n    ///    \r\n    /// </summary>\r\n    public partial class CFGWidget : UserControl\r\n    {\r\n        public CFGWidget()\r\n        {\r\n            InitializeComponent();\r\n        }\r\n\r\n        private class Node\r\n        {\r\n            public string NodeType = \"node\";\r\n        };\r\n        \r\n        private class LoopNode : Node\r\n        {\r\n            public LoopNode(Graph sub, Loop loop) \r\n            {\r\n                NodeType = \"loop\";\r\n                SubGraph = sub;\r\n                m_Loop = loop;\r\n            }\r\n\r\n            public Loop m_Loop = null;\r\n            public Graph SubGraph = null;\r\n        \r\n        }\r\n\r\n        private class LeafNode : Node\r\n        {\r\n            public LeafNode( BasicBlock bl )\r\n            {\r\n                Block = bl;\r\n                NodeType = \"node\";\r\n            }\r\n            public BasicBlock Block = null;\r\n        }\r\n\r\n        private class BranchNode : Node\r\n        {\r\n            public Graph IfGraph;\r\n            public Graph ElseGraph;\r\n            public LeafNode Test;\r\n            public List<Node> OwnedNodes;\r\n            public BasicBlock IfTarget;\r\n            public BasicBlock ElseTarget;\r\n\r\n            public BranchNode( LeafNode test )\r\n            {\r\n                Test = test;\r\n                IfGraph = new Graph();\r\n                ElseGraph = new Graph();\r\n                OwnedNodes = new List<Node>();\r\n                OwnedNodes.Add(test);\r\n                NodeType = \"branch\";\r\n\r\n                List<BasicBlock> succs = new List<BasicBlock>(test.Block.Successors);\r\n                IfTarget   = succs[0];\r\n                ElseTarget = succs[1];\r\n            }\r\n        }\r\n\r\n        private class SkipNode : Node\r\n        {\r\n            public Graph BranchGraph;\r\n            public LeafNode Test;\r\n\r\n            public SkipNode(LeafNode test, Graph gr)\r\n            {\r\n                Test = test;\r\n                BranchGraph = gr;\r\n                NodeType = \"skip\";\r\n            }\r\n        }\r\n\r\n        private class Graph\r\n        {\r\n            private Dictionary<Node, List<Node>> m_OutgoingEdges = new Dictionary<Node, List<Node>>();\r\n            private Dictionary<Node, List<Node>> m_IncomingEdges = new Dictionary<Node, List<Node>>();\r\n        \r\n            public void AddNode(Node n)\r\n            {\r\n                m_OutgoingEdges.Add(n, new List<Node>());\r\n                m_IncomingEdges.Add(n, new List<Node>());\r\n            }\r\n\r\n            public void AddNodes(IEnumerable<Node> nodes)\r\n            {\r\n                foreach (Node n in nodes)\r\n                {\r\n                    m_OutgoingEdges.Add(n, new List<Node>());\r\n                    m_IncomingEdges.Add(n, new List<Node>());\r\n                }\r\n            }\r\n\r\n            public void RemoveNodes(IEnumerable<Node> nodes)\r\n            {\r\n                foreach (Node n in nodes)\r\n                {\r\n                    m_OutgoingEdges.Remove(n);\r\n                    m_IncomingEdges.Remove(n);\r\n                }\r\n            }\r\n\r\n            public bool ContainsNode( Node n )\r\n            {\r\n                return m_OutgoingEdges.ContainsKey(n);\r\n            }\r\n\r\n            public void AddEdge( Node from, Node to )\r\n            {\r\n                m_OutgoingEdges[from].Add(to);\r\n                m_IncomingEdges[to].Add(from);\r\n            }\r\n\r\n            public Dictionary<Node,Node> Dominators( List<Node> nodes )\r\n            {\r\n                Node[] objs = nodes.ToArray();\r\n                Node[][] preds = new Node[objs.Length][];\r\n                for (int i = 0; i < objs.Length; i++)\r\n                    preds[i] = m_IncomingEdges[objs[i]].ToArray();\r\n\r\n                return Algorithms.FindDominators(objs, preds);\r\n            }\r\n\r\n            public Dictionary<Node, Node> PostDominators(List<Node> nodes)\r\n            {\r\n                Node[] objs = nodes.ToArray();\r\n                Node[][] preds = new Node[objs.Length][];\r\n                for (int i = 0; i < objs.Length; i++)\r\n                    preds[i] = m_OutgoingEdges[objs[i]].ToArray();\r\n\r\n                return Algorithms.FindDominators(objs, preds);\r\n            }\r\n\r\n            public void TransferEdgesToSubgraph( Graph g )\r\n            {\r\n                foreach( Node n in g.Nodes )\r\n                {\r\n                    foreach (Node e in m_OutgoingEdges[n])\r\n                        if( g.ContainsNode(e))\r\n                            g.AddEdge(n, e);\r\n                }\r\n            }\r\n\r\n            public void CombineNodes( IEnumerable<Node> loopNodes, Node superNode, Graph sub )\r\n            {\r\n                // transfer nodes to subgraph\r\n                foreach (Node b in loopNodes)\r\n                    sub.AddNode(b);\r\n                \r\n                // transfer edges to subgraph \r\n                foreach( Node n in loopNodes )\r\n                    foreach( Node e in m_OutgoingEdges[n] )\r\n                        if (sub.ContainsNode(e))\r\n                            sub.AddEdge(n, e);\r\n\r\n                \r\n                // add super-node to graph\r\n                AddNode(superNode);\r\n\r\n                // find edges from collapsing nodes to non-collapsing one\r\n                // replace these with corresponding edges on the super-node\r\n                foreach( Node n in loopNodes )\r\n                {\r\n                    foreach( Node s in m_OutgoingEdges[n])\r\n                    {\r\n                        if (!sub.ContainsNode(s))\r\n                        {\r\n                            m_IncomingEdges[s].Remove(n);\r\n                            AddEdge(superNode, s);\r\n                        }\r\n                    }\r\n                }\r\n   \r\n                // remove the merged nodes from our graph\r\n                foreach (Node n in loopNodes)\r\n                {\r\n                    m_IncomingEdges.Remove(n);\r\n                    m_OutgoingEdges.Remove(n);\r\n                }\r\n\r\n\r\n                // find all nodes with an edge to a node that was just removed\r\n                //  re-point these edges at the super-node\r\n                foreach( KeyValuePair<Node,List<Node>> p in m_OutgoingEdges )\r\n                {\r\n                    List<Node> children = p.Value;\r\n                    for (int i = 0; i < children.Count; i++)\r\n                    {\r\n                        if (!m_OutgoingEdges.ContainsKey(children[i]))\r\n                        {\r\n                            children[i] = superNode;\r\n                            m_IncomingEdges[superNode].Add(p.Key);\r\n                        }\r\n                    }\r\n                }\r\n            }\r\n\r\n            public IEnumerable<Node> ChildrenOf( Node n )\r\n            {\r\n                return m_OutgoingEdges[n];\r\n            }\r\n\r\n            public IEnumerable<Node> Nodes { get { return m_OutgoingEdges.Keys;  } }\r\n\r\n            public List<Node> ReversePostOrder()\r\n            {\r\n                List<Node> OrderedNodes     = new List<Node>();\r\n                HashSet<Node> AddedNodes = new HashSet<Node>();\r\n\r\n                // collect source nodes\r\n                List<Node> Frontier = new List<Node>();\r\n                foreach (KeyValuePair<Node,List<Node>> p in m_IncomingEdges)\r\n                    if( p.Value.Count == 0 )\r\n                        Frontier.Add(p.Key);\r\n\r\n                do\r\n                {\r\n                    // add frontier nodes to ordered list\r\n                    OrderedNodes.AddRange(Frontier);\r\n                    foreach( Node n in Frontier )\r\n                        AddedNodes.Add(n);\r\n                    \r\n                    // search for new frontier nodes and add them to frontier list\r\n                    //  a node goes on the frontier if it is not added but all \r\n                    //  its predecessors are\r\n                    Frontier.Clear();\r\n                    foreach( KeyValuePair<Node,List<Node>> p in m_IncomingEdges )\r\n                    {\r\n                        if (AddedNodes.Contains(p.Key))\r\n                            continue;\r\n\r\n                        int i = 0;\r\n                        while( i < p.Value.Count )\r\n                        {\r\n                            if (!AddedNodes.Contains(p.Value[i]))\r\n                                break;\r\n                            i++;\r\n                        }\r\n\r\n                        // node is ready to go into the frontier once all its predecessors have been ordered\r\n                        if (i == p.Value.Count )\r\n                            Frontier.Add(p.Key);\r\n                    }\r\n\r\n                } while( Frontier.Count > 0 );\r\n\r\n                return OrderedNodes;\r\n            }\r\n        };\r\n\r\n\r\n\r\n\r\n        private void BuildTree( TreeNode parent, Graph g)\r\n        {\r\n            List<Node> Nodes = g.ReversePostOrder();\r\n\r\n            for( int i=0; i<Nodes.Count; i++ )\r\n            {\r\n                Node n = Nodes[i];\r\n                TreeNode t = new TreeNode();\r\n                t.Tag = n;\r\n                t.Text = n.NodeType;\r\n                parent.Nodes.Add(t);\r\n\r\n                if (n is LoopNode )\r\n                {\r\n                    BuildTree(t, (n as LoopNode).SubGraph);\r\n                }\r\n                else if( n is SkipNode )\r\n                {\r\n                    BuildTree(t, (n as SkipNode).BranchGraph);\r\n                }\r\n                else if( n is BranchNode )\r\n                {\r\n                    BranchNode br = n as BranchNode;\r\n                    TreeNode nIf = new TreeNode();\r\n                    TreeNode nElse = new TreeNode();\r\n                    nIf.Text = \"IF\";\r\n                    nElse.Text = \"ELSE\";\r\n                    nIf.Tag   = br.IfTarget;\r\n                    nElse.Tag = br.ElseTarget;\r\n                    t.Nodes.Add(nIf);\r\n                    t.Nodes.Add(nElse);\r\n\r\n                    BuildTree(nIf, br.IfGraph);\r\n                    BuildTree(nElse, br.ElseGraph);\r\n                }\r\n            }\r\n\r\n        }\r\n\r\n       \r\n\r\n        private void BuildBranchNodes(Graph g)\r\n        {\r\n            // lay out the dag nodes in order\r\n            List<Node> Nodes = g.ReversePostOrder();\r\n\r\n            // Figure out dominance\r\n            Dictionary<Node, Node> IDOM = g.Dominators(Nodes);\r\n           \r\n            for( int i=0; i<Nodes.Count; i++ )\r\n            {\r\n                Node n = Nodes[i];\r\n                if (n is LoopNode)\r\n                {\r\n                    // descend into loop nodes\r\n                    BuildBranchNodes((n as LoopNode).SubGraph);\r\n                }\r\n                else\r\n                {\r\n                    LeafNode leaf = n as LeafNode;\r\n                    BasicBlock bl = leaf.Block;\r\n\r\n                    // mark break, branch, and continue nodes as such\r\n                    if (bl.LastInstruction is IBranchInstruction)\r\n                    {\r\n                        IBranchInstruction branch = bl.LastInstruction as IBranchInstruction;\r\n                        if (branch.Category == BranchCategory.BREAK_BRANCH)\r\n                            leaf.NodeType = \"break\";\r\n                        else if (branch.Category == BranchCategory.CONTINUE_BRANCH)\r\n                            leaf.NodeType = \"continue\";\r\n                        else if (branch.Category == BranchCategory.LOOPSKIP_BRANCH)\r\n                            leaf.NodeType = \"node\";\r\n                        else if (branch.Category == BranchCategory.SKIP_BRANCH)\r\n                            leaf.NodeType = \"skip\";\r\n                        else\r\n                            leaf.NodeType = \"branch\";\r\n                    }\r\n                    else\r\n                    {\r\n                        // mark continue nodes as such\r\n                        if (bl.InnerMostLoop != null && bl.Successors.First() == bl.InnerMostLoop.Header)\r\n                            n.NodeType = \"continue\";\r\n                    }\r\n                }\r\n            }\r\n\r\n\r\n            int k = 0;\r\n            while( k < Nodes.Count )\r\n            {\r\n                if( Nodes[k] is LeafNode && Nodes[k].NodeType.Equals(\"branch\") )\r\n                {\r\n                    BranchNode br = new BranchNode((Nodes[k] as LeafNode));\r\n\r\n                    List<Node> descendents = new List<Node>(g.ChildrenOf(Nodes[k]));\r\n                    Graph[] branchGraphs = new Graph[2];\r\n                    branchGraphs[0] = br.IfGraph;\r\n                    branchGraphs[1] = br.ElseGraph;\r\n                   \r\n                    for (int k0 = k + 1; k0 < Nodes.Count; k0++)\r\n                    {\r\n                        Node n = Nodes[k0];\r\n                        for (int j = 0; j < descendents.Count; j++)\r\n                        {\r\n                            if (Algorithms.Dominates(descendents[j], n, IDOM))\r\n                                branchGraphs[j].AddNode(n);\r\n                        }\r\n                    }\r\n\r\n                    br.OwnedNodes.AddRange(branchGraphs[0].Nodes);\r\n                    br.OwnedNodes.AddRange(branchGraphs[1].Nodes);\r\n\r\n                    Graph branchGraph = new Graph();\r\n                    g.CombineNodes(br.OwnedNodes, br, branchGraph);\r\n                    branchGraph.TransferEdgesToSubgraph(branchGraphs[0]);\r\n                    branchGraph.TransferEdgesToSubgraph(branchGraphs[1]);\r\n                    \r\n                    // do this recursively on the if/else branches\r\n                    BuildBranchNodes(br.IfGraph);\r\n                    BuildBranchNodes(br.ElseGraph);\r\n\r\n                    // start over\r\n                    k = 0;\r\n                    Nodes = g.ReversePostOrder();\r\n                }\r\n                else if (Nodes[k] is LeafNode && Nodes[k].NodeType.Equals(\"skip\"))\r\n                {\r\n                    Dictionary<Node, Node> PDOM = g.PostDominators(Nodes);\r\n                    \r\n                    // find nodes to put into the sub-graph\r\n                    // these are all the nodes which are skipped\r\n                    //  nodes are skipped if they are post-dominated by the convergence node (which post-dominates the test)\r\n                    Node joinPoint = PDOM[Nodes[k]];\r\n                    Graph branchGraph = new Graph();\r\n                    for (int k0 = k + 1; Nodes[k0] != joinPoint; k0++)\r\n                    {\r\n                        Node n = Nodes[k0];\r\n                        if (Algorithms.Dominates(joinPoint, Nodes[k0], PDOM))\r\n                            branchGraph.AddNode(Nodes[k0]);\r\n                    }\r\n\r\n                    SkipNode sk = new SkipNode((Nodes[k] as LeafNode), branchGraph);\r\n\r\n                    // now make a graph containing both test node and all skipped nodes\r\n                    //  combine these into one skip node\r\n                    List<Node> ownedNodes = new List<Node>(branchGraph.Nodes);\r\n                    ownedNodes.Add(Nodes[k]);\r\n                    Graph tmpGraph = new Graph();\r\n                    g.CombineNodes(ownedNodes, sk, tmpGraph);\r\n                    tmpGraph.TransferEdgesToSubgraph(branchGraph);\r\n\r\n                    // do this recursively on the skipped nodes\r\n                    BuildBranchNodes(sk.BranchGraph);\r\n\r\n                    // start over\r\n                    k = 0;\r\n                    Nodes = g.ReversePostOrder();\r\n                }\r\n                else\r\n                {\r\n                    k++;\r\n                }\r\n            }\r\n        }\r\n\r\n\r\n        public void SetProgram(List<Loop> loops, List<BasicBlock> blocks)\r\n        {\r\n            // build DAG of basic blocks\r\n            //  excluding backedges\r\n            Graph g = new Graph();\r\n            Dictionary<BasicBlock, Node> NodeMap = new Dictionary<BasicBlock, Node>();\r\n            foreach (BasicBlock b in blocks)\r\n            { \r\n                Node n = new LeafNode(b);\r\n                g.AddNode(n);\r\n                NodeMap.Add(b,n);\r\n            }\r\n\r\n            foreach (BasicBlock b in blocks)\r\n                foreach (BasicBlock s in b.Successors)\r\n                    if (!s.Dominates(b))\r\n                        g.AddEdge(NodeMap[b], NodeMap[s]);\r\n\r\n            \r\n            // walk over loops inner to outer\r\n            //  for each loop, replace its contents with a single \"super-node\"\r\n            foreach( Loop l in loops )\r\n            {\r\n                HashSet<Node> loopNodes = new HashSet<Node>();\r\n                foreach (BasicBlock b in l.Blocks )\r\n                    loopNodes.Add(NodeMap[b]);\r\n\r\n                LoopNode superNode = new LoopNode(new Graph(), l);\r\n\r\n                g.CombineNodes(loopNodes,superNode,superNode.SubGraph );\r\n\r\n                // all blocks in the loop should now be represented by the super-node\r\n                foreach (BasicBlock b in l.Blocks)\r\n                    NodeMap[b] = superNode;\r\n            }\r\n\r\n\r\n            BuildBranchNodes(g);\r\n\r\n\r\n            // now populate the tree view with loops and branches\r\n            TreeNode root = new TreeNode(\"program\");\r\n            BuildTree(root, g);\r\n            treeView1.Nodes.Add(root);\r\n        }\r\n\r\n\r\n\r\n        public delegate void SelectionClearedHandler(object sender);\r\n        public delegate void BlockSelectedHandler(object sender, BasicBlock bl );\r\n        public delegate void LoopSelectionHandler(object sender, Loop SelectedLoop);\r\n        public delegate void BranchSelectedHandler(object sender, BasicBlock BranchBlock, IBranchInstruction branch);\r\n        public delegate void BranchTargetSelectedHandler(object sender, BasicBlock TargetBlock );\r\n\r\n        public event BlockSelectedHandler           BlockSelected;\r\n        public event LoopSelectionHandler           LoopSelected;\r\n        public event BranchSelectedHandler          BranchSelected;\r\n        public event BranchTargetSelectedHandler    BranchTargetSelected;\r\n        public event SelectionClearedHandler        SelectionCleared;\r\n\r\n        public Loop SelectedLoop { get; private set;  }\r\n        public IBranchInstruction SelectedBranch { get; private set; }\r\n        public BasicBlock SelectedBlock { get; private set; }\r\n\r\n        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)\r\n        {\r\n            this.SelectedLoop   = null;\r\n            this.SelectedBranch = null;\r\n            this.SelectedBlock  = null;\r\n\r\n            if (treeView1.SelectedNode == null)\r\n            {\r\n                if (SelectionCleared != null)\r\n                {\r\n                    SelectionCleared(this);\r\n                    return;\r\n                }\r\n            }\r\n\r\n            object tag = treeView1.SelectedNode.Tag;\r\n            if (tag == null)\r\n            {\r\n                if (SelectionCleared != null)\r\n                {\r\n                    SelectionCleared(this);\r\n                    return;\r\n                }\r\n            }\r\n           \r\n            Node n = tag as Node;\r\n            if ( n is LoopNode )\r\n            {\r\n                Loop l = (n as LoopNode).m_Loop;\r\n                SelectedLoop = l;\r\n                    \r\n                if (LoopSelected != null)\r\n                    LoopSelected(this, l);\r\n            }\r\n            else if( n is BranchNode )\r\n            {\r\n                BranchNode br = n as BranchNode;\r\n                BasicBlock bl = (br.Test as LeafNode).Block;\r\n                SelectedBranch = bl.LastInstruction as IBranchInstruction;\r\n                SelectedBlock  = bl;\r\n\r\n                if( BranchSelected != null )\r\n                    BranchSelected(this, bl, SelectedBranch);\r\n            }\r\n            else if( n is SkipNode )\r\n            {\r\n                SkipNode sk = n as SkipNode;\r\n                BasicBlock bl = (sk.Test as LeafNode).Block;\r\n                SelectedBranch = bl.LastInstruction as IBranchInstruction;\r\n                SelectedBlock = bl;\r\n\r\n                if (BranchSelected != null)\r\n                    BranchSelected(this, bl, SelectedBranch);\r\n            }\r\n            else if( n is LeafNode )\r\n            {\r\n                SelectedBlock = (n as LeafNode).Block;\r\n                if( BlockSelected != null )\r\n                    BlockSelected(this, SelectedBlock);\r\n            }\r\n            else if (tag is BasicBlock)\r\n            {\r\n                SelectedBlock = tag as BasicBlock;\r\n                if (BranchTargetSelected != null )\r\n                    BranchTargetSelected(this, SelectedBlock);\r\n\r\n            }\r\n            \r\n        }\r\n\r\n        private void treeView1_Leave(object sender, EventArgs e)\r\n        {\r\n            treeView1.SelectedNode = null;\r\n \r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "src/Scrutinizer/UI/CFGWidget.resx",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<root>\r\n  <!-- \r\n    Microsoft ResX Schema \r\n    \r\n    Version 2.0\r\n    \r\n    The primary goals of this format is to allow a simple XML format \r\n    that is mostly human readable. The generation and parsing of the \r\n    various data types are done through the TypeConverter classes \r\n    associated with the data types.\r\n    \r\n    Example:\r\n    \r\n    ... ado.net/XML headers & schema ...\r\n    <resheader name=\"resmimetype\">text/microsoft-resx</resheader>\r\n    <resheader name=\"version\">2.0</resheader>\r\n    <resheader name=\"reader\">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\r\n    <resheader name=\"writer\">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\r\n    <data name=\"Name1\"><value>this is my long string</value><comment>this is a comment</comment></data>\r\n    <data name=\"Color1\" type=\"System.Drawing.Color, System.Drawing\">Blue</data>\r\n    <data name=\"Bitmap1\" mimetype=\"application/x-microsoft.net.object.binary.base64\">\r\n        <value>[base64 mime encoded serialized .NET Framework object]</value>\r\n    </data>\r\n    <data name=\"Icon1\" type=\"System.Drawing.Icon, System.Drawing\" mimetype=\"application/x-microsoft.net.object.bytearray.base64\">\r\n        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\r\n        <comment>This is a comment</comment>\r\n    </data>\r\n                \r\n    There are any number of \"resheader\" rows that contain simple \r\n    name/value pairs.\r\n    \r\n    Each data row contains a name, and value. The row also contains a \r\n    type or mimetype. Type corresponds to a .NET class that support \r\n    text/value conversion through the TypeConverter architecture. \r\n    Classes that don't support this are serialized and stored with the \r\n    mimetype set.\r\n    \r\n    The mimetype is used for serialized objects, and tells the \r\n    ResXResourceReader how to depersist the object. This is currently not \r\n    extensible. For a given mimetype the value must be set accordingly:\r\n    \r\n    Note - application/x-microsoft.net.object.binary.base64 is the format \r\n    that the ResXResourceWriter will generate, however the reader can \r\n    read any of the formats listed below.\r\n    \r\n    mimetype: application/x-microsoft.net.object.binary.base64\r\n    value   : The object must be serialized with \r\n            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\r\n            : and then encoded with base64 encoding.\r\n    \r\n    mimetype: application/x-microsoft.net.object.soap.base64\r\n    value   : The object must be serialized with \r\n            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\r\n            : and then encoded with base64 encoding.\r\n\r\n    mimetype: application/x-microsoft.net.object.bytearray.base64\r\n    value   : The object must be serialized into a byte array \r\n            : using a System.ComponentModel.TypeConverter\r\n            : and then encoded with base64 encoding.\r\n    -->\r\n  <xsd:schema id=\"root\" xmlns=\"\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">\r\n    <xsd:import namespace=\"http://www.w3.org/XML/1998/namespace\" />\r\n    <xsd:element name=\"root\" msdata:IsDataSet=\"true\">\r\n      <xsd:complexType>\r\n        <xsd:choice maxOccurs=\"unbounded\">\r\n          <xsd:element name=\"metadata\">\r\n            <xsd:complexType>\r\n              <xsd:sequence>\r\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" />\r\n              </xsd:sequence>\r\n              <xsd:attribute name=\"name\" use=\"required\" type=\"xsd:string\" />\r\n              <xsd:attribute name=\"type\" type=\"xsd:string\" />\r\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" />\r\n              <xsd:attribute ref=\"xml:space\" />\r\n            </xsd:complexType>\r\n          </xsd:element>\r\n          <xsd:element name=\"assembly\">\r\n            <xsd:complexType>\r\n              <xsd:attribute name=\"alias\" type=\"xsd:string\" />\r\n              <xsd:attribute name=\"name\" type=\"xsd:string\" />\r\n            </xsd:complexType>\r\n          </xsd:element>\r\n          <xsd:element name=\"data\">\r\n            <xsd:complexType>\r\n              <xsd:sequence>\r\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\r\n                <xsd:element name=\"comment\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"2\" />\r\n              </xsd:sequence>\r\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" msdata:Ordinal=\"1\" />\r\n              <xsd:attribute name=\"type\" type=\"xsd:string\" msdata:Ordinal=\"3\" />\r\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" msdata:Ordinal=\"4\" />\r\n              <xsd:attribute ref=\"xml:space\" />\r\n            </xsd:complexType>\r\n          </xsd:element>\r\n          <xsd:element name=\"resheader\">\r\n            <xsd:complexType>\r\n              <xsd:sequence>\r\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\r\n              </xsd:sequence>\r\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" />\r\n            </xsd:complexType>\r\n          </xsd:element>\r\n        </xsd:choice>\r\n      </xsd:complexType>\r\n    </xsd:element>\r\n  </xsd:schema>\r\n  <resheader name=\"resmimetype\">\r\n    <value>text/microsoft-resx</value>\r\n  </resheader>\r\n  <resheader name=\"version\">\r\n    <value>2.0</value>\r\n  </resheader>\r\n  <resheader name=\"reader\">\r\n    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r\n  </resheader>\r\n  <resheader name=\"writer\">\r\n    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r\n  </resheader>\r\n</root>"
  },
  {
    "path": "src/Scrutinizer/UI/InstructionWidget.Designer.cs",
    "content": "﻿namespace Pyramid.Scrutinizer.UI\n{\n    partial class InstructionWidget\n    {\n        /// <summary> \n        /// Required designer variable.\n        /// </summary>\n        private System.ComponentModel.IContainer components = null;\n\n        /// <summary> \n        /// Clean up any resources being used.\n        /// </summary>\n        /// <param name=\"disposing\">true if managed resources should be disposed; otherwise, false.</param>\n        protected override void Dispose(bool disposing)\n        {\n            if (disposing && (components != null))\n            {\n                components.Dispose();\n            }\n            base.Dispose(disposing);\n        }\n\n        #region Component Designer generated code\n\n        /// <summary> \n        /// Required method for Designer support - do not modify \n        /// the contents of this method with the code editor.\n        /// </summary>\n        private void InitializeComponent()\n        {\n            this.SuspendLayout();\n            // \n            // InstructionWidget\n            // \n            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\n            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\n            this.Name = \"InstructionWidget\";\n            this.Size = new System.Drawing.Size(738, 20);\n            this.Paint += new System.Windows.Forms.PaintEventHandler(this.InstructionWidget_Paint);\n            this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.InstructionWidget_MouseDown);\n            this.ResumeLayout(false);\n\n        }\n\n        #endregion\n    }\n}\n"
  },
  {
    "path": "src/Scrutinizer/UI/InstructionWidget.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Drawing;\nusing System.Data;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Windows.Forms;\n\nnamespace Pyramid.Scrutinizer.UI\n{\n    public partial class InstructionWidget : UserControl\n    {\n        private IInstruction m_Op;\n        private ComboBox m_FilterBox;\n        private ComboBox m_FormatBox;\n        private Font m_ItalicFont;\n\n        public delegate void TexelFormatChangedHandler( ITextureInstruction op );\n        public delegate void FilterChangedHandler( ISamplingInstruction op );\n\n        public event TexelFormatChangedHandler TexelFormatChanged;\n        public event FilterChangedHandler      FilterChanged;\n\n        private ComboBox CreateFilterBox( IInstruction op )\n        {\n            ComboBox cb = new ComboBox();\n            foreach (string s in Enum.GetNames(typeof(Scrutinizer.TextureFilter)))\n                cb.Items.Add(s);\n            cb.Width = 96;\n            cb.SelectedIndex = (int)(op as ISamplingInstruction).Filter;\n            cb.DropDownStyle = ComboBoxStyle.DropDownList;\n\n            cb.SelectedIndexChanged += delegate(object s, EventArgs e)\n            {\n                if (op is ISamplingInstruction)\n                {\n                    ISamplingInstruction samp = op as ISamplingInstruction;\n                    samp.Filter = (TextureFilter)cb.SelectedIndex;\n                  \n                    if (this.FilterChanged != null )\n                        this.FilterChanged(samp);\n                }\n            };\n\n            return cb;\n        }\n        private ComboBox CreateFormatBox( IInstruction op )\n        {\n            ComboBox cb = new ComboBox();\n            foreach (string s in Enum.GetNames(typeof(Scrutinizer.TexelFormat)))\n                cb.Items.Add(s);\n            cb.Width = 80;\n            cb.SelectedIndex = (int)(op as ITextureInstruction).Format;\n            cb.DropDownStyle = ComboBoxStyle.DropDownList;\n            \n            cb.SelectedIndexChanged += delegate(object s, EventArgs e)\n            {\n                if (op is ITextureInstruction)\n                {\n                    ITextureInstruction samp = op as ITextureInstruction;\n                    samp.Format = (TexelFormat)cb.SelectedIndex;\n\n                    if( this.TexelFormatChanged != null )\n                        this.TexelFormatChanged(samp);\n                }\n               \n            };\n            return cb;\n        }\n\n        public InstructionWidget( IInstruction op )\n        {\n            InitializeComponent();\n            this.Font    = new Font(\"Lucida Console\", 8.25f);\n            m_ItalicFont = new Font(this.Font, FontStyle.Italic);\n\n            this.Height = 15;\n            this.Executed = true;\n            m_Op = op;\n            Selected = false;\n\n\n            if (op is Scrutinizer.ISamplingInstruction)\n            {\n                Panel panel = new Panel();\n                m_FilterBox = CreateFilterBox(op);\n                m_FormatBox = CreateFormatBox(op);\n                panel.Anchor = AnchorStyles.Right;\n                panel.Width = m_FilterBox.Width + m_FormatBox.Width;\n                m_FilterBox.Left = m_FormatBox.Width;\n                panel.Controls.Add(m_FilterBox);\n                panel.Controls.Add(m_FormatBox);\n                this.Controls.Add(panel);\n            }\n            else if (op is Scrutinizer.ITextureInstruction)\n            {\n                m_FormatBox = CreateFormatBox(op);\n                m_FormatBox.Anchor = AnchorStyles.Right;\n                this.Controls.Add(m_FormatBox);\n            }\n        }\n\n        public IInstruction Instruction { get { return m_Op; } }\n        public bool Selected { get; set; }\n        public bool Executed { get; set; }\n\n        public void RefreshInstruction()\n        {\n            if( m_FilterBox != null )\n                m_FilterBox.SelectedIndex = (int) (m_Op as ISamplingInstruction).Filter;\n            if (m_FormatBox != null)\n                m_FormatBox.SelectedIndex = (int) (m_Op as ITextureInstruction).Format;\n        }\n\n        private void InstructionWidget_Paint(object sender, PaintEventArgs e)\n        {\n            if (m_Op == null)\n                return;\n\n            if( Selected )\n            {\n                e.Graphics.FillRectangle(SystemBrushes.HighlightText, new Rectangle(0, 0, this.Width, this.Height));\n            }\n\n            Brush br = SystemBrushes.ControlText;\n            if (!Executed)\n                br = SystemBrushes.InactiveCaption;\n\n            Font f = this.Font;\n            if (!Executed)\n                f = m_ItalicFont;\n\n            e.Graphics.DrawString(m_Op.Disassemble(), f, br, new PointF(80+96, 0));\n\n            if( !String.IsNullOrEmpty(m_Op.SimNotes)  )\n                e.Graphics.DrawString(m_Op.SimNotes, this.Font, SystemBrushes.ControlText, new PointF(this.Width - 200, 0));\n            \n           \n        }\n\n\n        private void InstructionWidget_MouseDown(object sender, MouseEventArgs e)\n        {\n            this.Parent.Focus();\n        }\n\n       \n    }\n}\n"
  },
  {
    "path": "src/Scrutinizer/UI/InstructionWidget.resx",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n  <!-- \n    Microsoft ResX Schema \n    \n    Version 2.0\n    \n    The primary goals of this format is to allow a simple XML format \n    that is mostly human readable. The generation and parsing of the \n    various data types are done through the TypeConverter classes \n    associated with the data types.\n    \n    Example:\n    \n    ... ado.net/XML headers & schema ...\n    <resheader name=\"resmimetype\">text/microsoft-resx</resheader>\n    <resheader name=\"version\">2.0</resheader>\n    <resheader name=\"reader\">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\n    <resheader name=\"writer\">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\n    <data name=\"Name1\"><value>this is my long string</value><comment>this is a comment</comment></data>\n    <data name=\"Color1\" type=\"System.Drawing.Color, System.Drawing\">Blue</data>\n    <data name=\"Bitmap1\" mimetype=\"application/x-microsoft.net.object.binary.base64\">\n        <value>[base64 mime encoded serialized .NET Framework object]</value>\n    </data>\n    <data name=\"Icon1\" type=\"System.Drawing.Icon, System.Drawing\" mimetype=\"application/x-microsoft.net.object.bytearray.base64\">\n        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\n        <comment>This is a comment</comment>\n    </data>\n                \n    There are any number of \"resheader\" rows that contain simple \n    name/value pairs.\n    \n    Each data row contains a name, and value. The row also contains a \n    type or mimetype. Type corresponds to a .NET class that support \n    text/value conversion through the TypeConverter architecture. \n    Classes that don't support this are serialized and stored with the \n    mimetype set.\n    \n    The mimetype is used for serialized objects, and tells the \n    ResXResourceReader how to depersist the object. This is currently not \n    extensible. For a given mimetype the value must be set accordingly:\n    \n    Note - application/x-microsoft.net.object.binary.base64 is the format \n    that the ResXResourceWriter will generate, however the reader can \n    read any of the formats listed below.\n    \n    mimetype: application/x-microsoft.net.object.binary.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\n            : and then encoded with base64 encoding.\n    \n    mimetype: application/x-microsoft.net.object.soap.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\n            : and then encoded with base64 encoding.\n\n    mimetype: application/x-microsoft.net.object.bytearray.base64\n    value   : The object must be serialized into a byte array \n            : using a System.ComponentModel.TypeConverter\n            : and then encoded with base64 encoding.\n    -->\n  <xsd:schema id=\"root\" xmlns=\"\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">\n    <xsd:import namespace=\"http://www.w3.org/XML/1998/namespace\" />\n    <xsd:element name=\"root\" msdata:IsDataSet=\"true\">\n      <xsd:complexType>\n        <xsd:choice maxOccurs=\"unbounded\">\n          <xsd:element name=\"metadata\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" use=\"required\" type=\"xsd:string\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"assembly\">\n            <xsd:complexType>\n              <xsd:attribute name=\"alias\" type=\"xsd:string\" />\n              <xsd:attribute name=\"name\" type=\"xsd:string\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"data\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n                <xsd:element name=\"comment\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"2\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" msdata:Ordinal=\"1\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" msdata:Ordinal=\"3\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" msdata:Ordinal=\"4\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"resheader\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" />\n            </xsd:complexType>\n          </xsd:element>\n        </xsd:choice>\n      </xsd:complexType>\n    </xsd:element>\n  </xsd:schema>\n  <resheader name=\"resmimetype\">\n    <value>text/microsoft-resx</value>\n  </resheader>\n  <resheader name=\"version\">\n    <value>2.0</value>\n  </resheader>\n  <resheader name=\"reader\">\n    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n  <resheader name=\"writer\">\n    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n</root>"
  },
  {
    "path": "src/Scrutinizer/UI/ParameterWidget.Designer.cs",
    "content": "﻿namespace Pyramid.Scrutinizer.UI\n{\n    partial class ParameterWidget\n    {\n        /// <summary> \n        /// Required designer variable.\n        /// </summary>\n        private System.ComponentModel.IContainer components = null;\n\n        /// <summary> \n        /// Clean up any resources being used.\n        /// </summary>\n        /// <param name=\"disposing\">true if managed resources should be disposed; otherwise, false.</param>\n        protected override void Dispose(bool disposing)\n        {\n            if (disposing && (components != null))\n            {\n                components.Dispose();\n            }\n            base.Dispose(disposing);\n        }\n\n        #region Component Designer generated code\n\n        /// <summary> \n        /// Required method for Designer support - do not modify \n        /// the contents of this method with the code editor.\n        /// </summary>\n        private void InitializeComponent()\n        {\n            components = new System.ComponentModel.Container();\n            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\n        }\n\n        #endregion\n    }\n}\n"
  },
  {
    "path": "src/Scrutinizer/UI/ParameterWidget.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Drawing;\nusing System.Data;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Windows.Forms;\n\nnamespace Pyramid.Scrutinizer.UI\n{\n    public partial class ParameterWidget : UserControl\n    {\n        const int TEXTBOX_WIDTH = 40;\n        const int LAYOUT_PAD = 4;\n\n        private List<IParameterGUI> m_Parameters = new List<IParameterGUI>();\n\n        public ParameterWidget()\n        {\n            InitializeComponent();\n        }\n\n        interface IParameterGUI\n        {\n            bool Assign();\n            IEnumerable<Control> Controls { get; }\n        };\n\n        class ParameterGUI_Int : IParameterGUI\n        {\n            private List<Control> m_Controls = new List<Control>();\n            private TextBox m_Box;\n            private SimulationParameterInt m_Param;\n\n            public IEnumerable<Control> Controls { get { return m_Controls; } }\n\n            public ParameterGUI_Int(SimulationParameterInt p)\n            {\n                TextBox box = new TextBox();\n                box.Width = TEXTBOX_WIDTH;\n                box.Text = Convert.ToString(p.Default);\n                box.Top  = 0;\n                box.Left = LAYOUT_PAD;\n\n                Label l = new Label();\n                l.AutoSize = true;\n                l.Text = p.Name;\n                l.TextAlign = ContentAlignment.MiddleLeft;\n                l.Top  = (box.Height/2) - (l.Height / 2);\n                l.Left = box.Right + LAYOUT_PAD;\n\n                m_Controls.Add(l);\n                m_Controls.Add(box);\n                \n                m_Box = box;\n                m_Param = p;\n            }\n\n            public bool Assign( )\n            {\n                try\n                { \n                    int n = Convert.ToInt32(m_Box.Text);\n                    if( n < m_Param.Min || n > m_Param.Max )\n                    {\n                        MessageBox.Show( \n                            String.Format( \"{0} must be between {1} and {2}\", m_Param.Name,\n                                           m_Param.Min, m_Param.Max ) );\n                        m_Box.Focus();\n                        return false;\n                    }\n                    m_Param.Value = n;\n                }\n                catch( System.Exception e )\n                {\n                    MessageBox.Show(e.Message);\n                    m_Box.Focus();\n                    return false;\n                }\n                return true;\n            }\n        }\n\n\n        class ParameterGUI_Double : IParameterGUI\n        {\n\n            private List<Control> m_Controls = new List<Control>();\n            private TextBox m_Box;\n            private SimulationParameterDouble m_Param;\n\n            public IEnumerable<Control> Controls { get { return m_Controls; } }\n\n            public ParameterGUI_Double( SimulationParameterDouble p)\n            {\n                TextBox box = new TextBox();\n                box.Width = TEXTBOX_WIDTH;\n                box.Text = Convert.ToString(p.Default);\n                box.Top = 0;\n                box.Left = LAYOUT_PAD;\n\n                Label l = new Label();\n                l.AutoSize = true;\n                l.Text = p.Name;\n                l.TextAlign = ContentAlignment.MiddleLeft;\n                l.Top = (box.Height / 2) - (l.Height / 2);\n                l.Left = box.Right + LAYOUT_PAD;\n                m_Controls.Add(l);\n                m_Controls.Add(box);\n                m_Box = box;\n                m_Param = p;\n            }\n            \n            public bool Assign()\n            {\n                try\n                {\n                    double n = Convert.ToDouble(m_Box.Text);\n                    if (n < m_Param.Min || n > m_Param.Max)\n                    {\n                        MessageBox.Show(\n                            String.Format(\"{0} must be between {1] and {2}\", m_Param.Name,\n                                           m_Param.Min, m_Param.Max));\n                        m_Box.Focus();\n                        return false;\n                    }\n                    m_Param.Value = n;\n                }\n                catch (System.Exception e)\n                {\n                    MessageBox.Show(e.Message);\n                    m_Box.Focus();\n                    return false;\n                }\n                return true;\n            }\n        }\n\n\n        /// <summary>\n        ///  Called to transfer values from UI to the parameters\n        /// </summary>\n        /// <returns></returns>\n        public bool UpdateParameters( )\n        {\n            foreach( IParameterGUI gui in m_Parameters )\n            {\n                if (!gui.Assign())\n                    return false;\n            }\n            return true;\n        }\n\n        public void BuildUI( IEnumerable<Scrutinizer.ISimulationParameter> ParamSet )\n        {\n            m_Parameters.Clear();\n\n            foreach( Scrutinizer.ISimulationParameter p in ParamSet )\n            {\n                if( p is Scrutinizer.SimulationParameterInt )\n                {\n                    m_Parameters.Add(new ParameterGUI_Int(p as SimulationParameterInt));\n                }\n                if( p is Scrutinizer.SimulationParameterDouble )\n                {\n                    m_Parameters.Add(new ParameterGUI_Double(p as SimulationParameterDouble));\n                }\n            }\n\n            // lay out the controls\n            int Y = LAYOUT_PAD;\n            foreach( IParameterGUI gui in m_Parameters )\n            {\n                int h = 0;\n                foreach (Control c in gui.Controls)\n                {\n                    this.Controls.Add(c);\n                    c.Top = c.Top + Y;\n                   \n                    h = Math.Max(h, c.Height);\n                }\n                Y += h + LAYOUT_PAD;\n            }\n\n            this.Refresh();\n        }\n    }\n}\n"
  },
  {
    "path": "src/Scrutinizer/UI/ScrutinizerForm.Designer.cs",
    "content": "﻿namespace Pyramid.Scrutinizer.UI\n{\n    partial class ScrutinizerForm\n    {\n        /// <summary>\n        /// Required designer variable.\n        /// </summary>\n        private System.ComponentModel.IContainer components = null;\n\n        /// <summary>\n        /// Clean up any resources being used.\n        /// </summary>\n        /// <param name=\"disposing\">true if managed resources should be disposed; otherwise, false.</param>\n        protected override void Dispose(bool disposing)\n        {\n            if (disposing && (components != null))\n            {\n                components.Dispose();\n            }\n            base.Dispose(disposing);\n        }\n\n        #region Windows Form Designer generated code\n\n        /// <summary>\n        /// Required method for Designer support - do not modify\n        /// the contents of this method with the code editor.\n        /// </summary>\n        private void InitializeComponent()\n        {\n            this.panel1 = new System.Windows.Forms.Panel();\n            this.lblIterations = new System.Windows.Forms.Label();\n            this.txtLoopCount = new System.Windows.Forms.TextBox();\n            this.btnSimulate = new System.Windows.Forms.Button();\n            this.chkTaken = new System.Windows.Forms.CheckBox();\n            this.parameterWidget1 = new Scrutinizer.UI.ParameterWidget();\n            this.cfgWidget1 = new Scrutinizer.UI.CFGWidget();\n            this.SuspendLayout();\n            // \n            // panel1\n            // \n            this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) \n            | System.Windows.Forms.AnchorStyles.Left) \n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.panel1.AutoScroll = true;\n            this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;\n            this.panel1.Location = new System.Drawing.Point(13, 13);\n            this.panel1.Name = \"panel1\";\n            this.panel1.Size = new System.Drawing.Size(561, 460);\n            this.panel1.TabIndex = 2;\n            this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseDown);\n            // \n            // lblIterations\n            // \n            this.lblIterations.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\n            this.lblIterations.AutoSize = true;\n            this.lblIterations.Location = new System.Drawing.Point(676, 268);\n            this.lblIterations.Name = \"lblIterations\";\n            this.lblIterations.Size = new System.Drawing.Size(50, 13);\n            this.lblIterations.TabIndex = 4;\n            this.lblIterations.Text = \"Iterations\";\n            // \n            // txtLoopCount\n            // \n            this.txtLoopCount.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\n            this.txtLoopCount.Location = new System.Drawing.Point(728, 265);\n            this.txtLoopCount.Name = \"txtLoopCount\";\n            this.txtLoopCount.Size = new System.Drawing.Size(100, 20);\n            this.txtLoopCount.TabIndex = 3;\n            this.txtLoopCount.WordWrap = false;\n            this.txtLoopCount.TextChanged += new System.EventHandler(this.txtLoopCount_TextChanged);\n            // \n            // btnSimulate\n            // \n            this.btnSimulate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\n            this.btnSimulate.Location = new System.Drawing.Point(766, 291);\n            this.btnSimulate.Name = \"btnSimulate\";\n            this.btnSimulate.Size = new System.Drawing.Size(62, 21);\n            this.btnSimulate.TabIndex = 5;\n            this.btnSimulate.Text = \"Simulate\";\n            this.btnSimulate.UseVisualStyleBackColor = true;\n            this.btnSimulate.Click += new System.EventHandler(this.btnSimulate_Click);\n            // \n            // chkTaken\n            // \n            this.chkTaken.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\n            this.chkTaken.AutoSize = true;\n            this.chkTaken.Location = new System.Drawing.Point(590, 266);\n            this.chkTaken.Name = \"chkTaken\";\n            this.chkTaken.Size = new System.Drawing.Size(57, 17);\n            this.chkTaken.TabIndex = 14;\n            this.chkTaken.Text = \"Taken\";\n            this.chkTaken.UseVisualStyleBackColor = true;\n            this.chkTaken.Visible = false;\n            this.chkTaken.CheckedChanged += new System.EventHandler(this.chkTaken_CheckedChanged);\n            // \n            // parameterWidget1\n            // \n            this.parameterWidget1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) \n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.parameterWidget1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;\n            this.parameterWidget1.Location = new System.Drawing.Point(590, 332);\n            this.parameterWidget1.Name = \"parameterWidget1\";\n            this.parameterWidget1.Size = new System.Drawing.Size(238, 150);\n            this.parameterWidget1.TabIndex = 15;\n            // \n            // cfgWidget1\n            // \n            this.cfgWidget1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\n            this.cfgWidget1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;\n            this.cfgWidget1.Location = new System.Drawing.Point(580, 12);\n            this.cfgWidget1.Name = \"cfgWidget1\";\n            this.cfgWidget1.Size = new System.Drawing.Size(248, 247);\n            this.cfgWidget1.TabIndex = 1;\n            this.cfgWidget1.BlockSelected += new Scrutinizer.UI.CFGWidget.BlockSelectedHandler(this.cfgWidget1_BlockSelected);\n            this.cfgWidget1.LoopSelected += new Scrutinizer.UI.CFGWidget.LoopSelectionHandler(this.cfgWidget1_LoopSelected);\n            this.cfgWidget1.BranchSelected += new Scrutinizer.UI.CFGWidget.BranchSelectedHandler(this.cfgWidget1_BranchSelected);\n            this.cfgWidget1.BranchTargetSelected += new Scrutinizer.UI.CFGWidget.BranchTargetSelectedHandler(this.cfgWidget1_BranchTargetSelected);\n            this.cfgWidget1.SelectionCleared += new Scrutinizer.UI.CFGWidget.SelectionClearedHandler(this.cfgWidget1_SelectionCleared);\n            // \n            // ScrutinizerForm\n            // \n            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\n            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\n            this.ClientSize = new System.Drawing.Size(840, 494);\n            this.Controls.Add(this.parameterWidget1);\n            this.Controls.Add(this.chkTaken);\n            this.Controls.Add(this.btnSimulate);\n            this.Controls.Add(this.lblIterations);\n            this.Controls.Add(this.txtLoopCount);\n            this.Controls.Add(this.panel1);\n            this.Controls.Add(this.cfgWidget1);\n            this.Name = \"ScrutinizerForm\";\n            this.Text = \"Scrutinizer\";\n            this.ResumeLayout(false);\n            this.PerformLayout();\n\n        }\n\n        #endregion\n\n        private CFGWidget cfgWidget1;\n        private System.Windows.Forms.Panel panel1;\n        private System.Windows.Forms.Label lblIterations;\n        private System.Windows.Forms.TextBox txtLoopCount;\n        private System.Windows.Forms.Button btnSimulate;\n        private System.Windows.Forms.CheckBox chkTaken;\n        private ParameterWidget parameterWidget1;\n    }\n}"
  },
  {
    "path": "src/Scrutinizer/UI/ScrutinizerForm.cs",
    "content": "﻿using System;\r\nusing System.Collections.Generic;\r\nusing System.ComponentModel;\r\nusing System.Data;\r\nusing System.Drawing;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Threading.Tasks;\r\nusing System.Windows.Forms;\r\n\r\nnamespace Pyramid.Scrutinizer.UI\r\n{\r\n    public partial class ScrutinizerForm : Form\r\n    {\r\n        private List<IInstruction> m_FetchShader;\r\n        private List<IInstruction> m_Ops;\r\n        private List<BasicBlock> m_Blocks;\r\n        private List<Loop> m_Loops;\r\n        private IScrutinizer m_Backend;\r\n        \r\n        private HashSet<IInstruction> m_TakenBranches = new HashSet<IInstruction>();\r\n        private HashSet<InstructionWidget> m_SelectedOps = new HashSet<InstructionWidget>();\r\n        private InstructionWidget m_LastClicked = null;\r\n\r\n        private Dictionary<IInstruction, InstructionWidget> m_InstructionWidgets = new Dictionary<IInstruction, InstructionWidget>();\r\n        private Dictionary<IInstruction, int> m_InstructionIndexMap = new Dictionary<IInstruction, int>();\r\n\r\n        private void ClearSelectedInstructions()\r\n        {\r\n            // de-select everything on a right click\r\n            foreach (InstructionWidget i in m_SelectedOps)\r\n            {\r\n                i.Selected = false;\r\n                i.Refresh();\r\n            }\r\n            m_SelectedOps.Clear();\r\n        }\r\n\r\n        private void SelectInstruction( IInstruction op )\r\n        {\r\n            InstructionWidget widget = m_InstructionWidgets[op];\r\n            m_SelectedOps.Add(widget);\r\n            widget.Selected = true;\r\n            widget.Refresh();\r\n        }\r\n      \r\n        private void OnInstructionClick( InstructionWidget w, MouseEventArgs e )\r\n        {\r\n            if (e.Button == MouseButtons.Left)\r\n            {\r\n                if (Form.ModifierKeys == Keys.Control)\r\n                {\r\n                    // ctrl+click: toggle state of one widget\r\n                    w.Selected = !w.Selected;\r\n                    w.Refresh();\r\n                    if (w.Selected)\r\n                        m_SelectedOps.Add(w);\r\n                    else\r\n                        m_SelectedOps.Remove(w);\r\n                }\r\n                else if( Form.ModifierKeys == Keys.Shift && m_LastClicked != null )\r\n                {\r\n                    // shift+click: select everything between last clicked widget\r\n                    //  and current widget\r\n                   \r\n                    int i = m_InstructionIndexMap[m_LastClicked.Instruction];\r\n                    int j = m_InstructionIndexMap[w.Instruction];\r\n                    int first = Math.Min(i, j);\r\n                    int last = Math.Max(i, j);\r\n                    for (int x = first; x <= last; x++)\r\n                        SelectInstruction(m_Ops[x]);\r\n                }\r\n                else\r\n                {\r\n                    // unmodified click.  Select only the clicked widget\r\n                    ClearSelectedInstructions();\r\n                    SelectInstruction(w.Instruction);\r\n                }\r\n                \r\n                m_LastClicked = w;\r\n            }\r\n            else if (e.Button == MouseButtons.Right)\r\n            {\r\n                // de-select everything on a right click\r\n                ClearSelectedInstructions();\r\n            }\r\n        }\r\n\r\n        public void AddInstructionToPanel( InstructionWidget widget, IInstruction op )\r\n        {\r\n            m_InstructionIndexMap.Add(op, m_InstructionWidgets.Count);\r\n            m_InstructionWidgets.Add(op, widget);\r\n                        \r\n            widget.Click += delegate(object s, EventArgs e)\r\n            {\r\n                this.OnInstructionClick(widget, e as MouseEventArgs);\r\n            };\r\n\r\n            // change format on all selected instructions whenever one of them is changed\r\n            widget.TexelFormatChanged += delegate(ITextureInstruction inst )\r\n            {\r\n                if (!widget.Selected)\r\n                    return;\r\n                foreach( InstructionWidget s in m_SelectedOps )\r\n                {\r\n                    ITextureInstruction tx = s.Instruction as ITextureInstruction;\r\n                    if( tx != null && tx != inst )\r\n                        tx.Format = inst.Format;\r\n                    s.RefreshInstruction();\r\n                }\r\n            };\r\n\r\n            // change filter on all selected instructions whenever one of them is changed\r\n            widget.FilterChanged += delegate(ISamplingInstruction inst)\r\n            {\r\n                if (!widget.Selected)\r\n                    return;\r\n\r\n                foreach (InstructionWidget s in m_SelectedOps)\r\n                {\r\n                    ISamplingInstruction tx = s.Instruction as ISamplingInstruction;\r\n                    if (tx != null && tx != inst)\r\n                        tx.Filter = inst.Filter;\r\n                    s.RefreshInstruction();\r\n                }\r\n            };\r\n\r\n            panel1.Controls.Add(widget);\r\n        }\r\n\r\n\r\n\r\n       \r\n        public ScrutinizerForm( List<IInstruction> FetchShader, List<IInstruction> Shader, IScrutinizer backend )\r\n        {\r\n            InitializeComponent();\r\n            m_Backend     = backend;\r\n            m_FetchShader = FetchShader;\r\n            m_Ops = Shader;\r\n\r\n            try\r\n            {\r\n                Wrapper w = new Wrapper();\r\n                \r\n                List<IInstruction> Ops = m_Backend.BuildProgram();\r\n\r\n                m_Ops = Ops;\r\n                m_Blocks = Algorithms.BuildBasicBlocks(Ops);\r\n                if (!Algorithms.IsCFGReducible(m_Blocks))\r\n                {\r\n                    MessageBox.Show(\"Non-reducible flow-graph detected.  Can't analyze this.\");\r\n                    return;\r\n                }\r\n\r\n                Algorithms.FindDominators(m_Blocks);\r\n\r\n                m_Loops = Algorithms.FindLoops(m_Blocks);\r\n                Algorithms.ClassifyBranches(m_Ops);\r\n\r\n                Algorithms.AssignLabels(m_Ops);\r\n\r\n                int Y = 0;\r\n                if( m_FetchShader.Count > 0 )\r\n                {\r\n                    Label l0 = new Label();\r\n                    Label l1 = new Label();\r\n                    l0.AutoSize = true;\r\n                    l1.AutoSize = true;\r\n                    l0.Text = \"*** INSTRUCTIONS BELOW ARE AN APPROXIMATION TO THE FETCH SHADER***\";\r\n                    l1.Text = \"******************************************************************\";\r\n                    l0.Left = 128;\r\n                    l1.Left = 128;\r\n                    panel1.Controls.Add(l0);\r\n                    Y = l0.Height;\r\n\r\n                    foreach( IInstruction op in m_FetchShader )\r\n                    {\r\n                        InstructionWidget widget = new InstructionWidget(op);\r\n                        AddInstructionToPanel(widget, op);\r\n                        widget.Top = Y;\r\n                        widget.Left = 0;\r\n                        Y += widget.Height;\r\n                    }\r\n\r\n                    l1.Top = Y;\r\n                    panel1.Controls.Add(l1);\r\n                    Y += l1.Height;\r\n                }\r\n\r\n                foreach (BasicBlock b in m_Blocks)\r\n                {\r\n                    foreach (IInstruction op in b.Instructions)\r\n                    {\r\n                        if( !String.IsNullOrEmpty(op.Label))\r\n                        {\r\n                            Label l = new Label();\r\n                            l.Font = new Font(\"Lucida Console\", 8);\r\n                            l.AutoSize = true;\r\n                            l.Text = op.Label;\r\n                            l.Left = 100;\r\n                            l.Top = Y;\r\n                            panel1.Controls.Add(l);\r\n                            Y += l.Height;\r\n                        }\r\n\r\n                        InstructionWidget widget = new InstructionWidget(op);\r\n                        AddInstructionToPanel(widget, op);\r\n                        widget.Top = Y;\r\n                        widget.Left = 0;\r\n                        Y += widget.Height;\r\n                    }\r\n                    Y += 15;\r\n                }\r\n\r\n                cfgWidget1.SetProgram(m_Loops, m_Blocks);\r\n                parameterWidget1.BuildUI(m_Backend.SimulationParameters);\r\n\r\n                MarkExecutedInstructions();\r\n            }\r\n            catch( System.Exception ex )\r\n            {\r\n                MessageBox.Show(ex.Message);\r\n            }\r\n        }\r\n\r\n\r\n        private void SelectDominatedInstructions( BasicBlock dominator )\r\n        {\r\n            foreach( BasicBlock b in m_Blocks )\r\n                if (dominator.Dominates(b) )\r\n                    foreach (IInstruction op in b.Instructions)\r\n                        SelectInstruction(op);\r\n            \r\n        }\r\n\r\n        private void cfgWidget1_BlockSelected(object sender, BasicBlock SelectedBlock)\r\n        {\r\n            ClearSelectedInstructions();\r\n            foreach (IInstruction i in SelectedBlock.Instructions)\r\n                SelectInstruction(i);\r\n\r\n            panel1.Refresh();\r\n            \r\n            txtLoopCount.Visible  = false;\r\n            lblIterations.Visible = false;\r\n            chkTaken.Visible      = false;\r\n        }\r\n\r\n        private void cfgWidget1_BranchTargetSelected(object sender, BasicBlock TargetBlock)\r\n        {\r\n            ClearSelectedInstructions();\r\n            foreach (BasicBlock b in m_Blocks)\r\n                if (TargetBlock.Dominates(b))\r\n                    foreach (IInstruction i in b.Instructions)\r\n                        SelectInstruction(i);\r\n            panel1.Refresh();\r\n\r\n            txtLoopCount.Visible  = false;\r\n            lblIterations.Visible = false;\r\n            chkTaken.Visible      = false;\r\n        }\r\n\r\n        private void cfgWidget1_LoopSelected(object sender, Loop SelectedLoop)\r\n        {\r\n            ClearSelectedInstructions();\r\n            foreach (BasicBlock SelectedBlock in SelectedLoop.Blocks)\r\n                foreach (IInstruction i in SelectedBlock.Instructions)\r\n                    SelectInstruction(i);\r\n\r\n            lblIterations.Visible = true;\r\n            txtLoopCount.Visible  = true; \r\n            chkTaken.Visible      = false;\r\n            txtLoopCount.Text = SelectedLoop.DesiredIterations.ToString();\r\n        }\r\n\r\n        private void cfgWidget1_SelectionCleared(object sender)\r\n        {\r\n            ClearSelectedInstructions();\r\n\r\n            panel1.Refresh(); \r\n            \r\n            txtLoopCount.Visible  = false;\r\n            lblIterations.Visible = false;\r\n            chkTaken.Visible      = false;\r\n        }\r\n\r\n        private void cfgWidget1_BranchSelected(object sender, BasicBlock BranchBlock, IBranchInstruction branch)\r\n        {\r\n            ClearSelectedInstructions();\r\n            foreach (IInstruction i in BranchBlock.Instructions)\r\n                SelectInstruction(i);\r\n             \r\n            IBranchInstruction br = BranchBlock.LastInstruction as IBranchInstruction;\r\n            \r\n            if( br.IfTarget.Block != br.Block.PostDominator )\r\n                SelectDominatedInstructions(br.IfTarget.Block);\r\n            if (br.ElseTarget.Block != br.Block.PostDominator)\r\n                SelectDominatedInstructions(br.ElseTarget.Block);\r\n           \r\n\r\n            txtLoopCount.Visible  = false;\r\n            lblIterations.Visible = false;\r\n            chkTaken.Visible = true;\r\n            chkTaken.Checked = m_TakenBranches.Contains(branch);\r\n        }\r\n\r\n\r\n        private void panel1_MouseDown(object sender, MouseEventArgs e)\r\n        {\r\n            panel1.Focus();\r\n        }\r\n\r\n        private void MarkExecutedInstructions()\r\n        {\r\n            List<IInstruction> ops = Algorithms.DoTrace(m_Ops, m_Blocks, m_Loops, m_TakenBranches);\r\n            HashSet<IInstruction> distinctOps = new HashSet<IInstruction>();\r\n            foreach (IInstruction op in ops)\r\n                distinctOps.Add(op);\r\n\r\n            foreach( InstructionWidget w in m_InstructionWidgets.Values )\r\n                w.Executed = false;\r\n\r\n            foreach (IInstruction op in distinctOps)\r\n                m_InstructionWidgets[op].Executed = true;\r\n        }\r\n\r\n        private void txtLoopCount_TextChanged(object sender, EventArgs e)\r\n        {\r\n            int n = 0;\r\n            try\r\n            {\r\n                n = Convert.ToInt32(txtLoopCount.Text);\r\n                cfgWidget1.SelectedLoop.DesiredIterations = n;\r\n\r\n                MarkExecutedInstructions();\r\n            }\r\n            catch(System.Exception )\r\n            {\r\n            }\r\n        }\r\n\r\n        private void btnSimulate_Click(object sender, EventArgs e)\r\n        {\r\n            if (m_FetchShader != null)\r\n            {\r\n                foreach (IInstruction op in m_FetchShader)\r\n                    op.SimNotes = \"\";\r\n            }\r\n\r\n            foreach (IInstruction op in m_Ops)\r\n                op.SimNotes = \"\";\r\n\r\n            try\r\n            {\r\n                if (parameterWidget1.UpdateParameters())\r\n                {\r\n                    List<IInstruction> trace = new List<IInstruction>();\r\n                    if (m_FetchShader != null)\r\n                        trace.AddRange(m_FetchShader);\r\n\r\n                    trace.AddRange(Algorithms.DoTrace(m_Ops, m_Blocks, m_Loops, m_TakenBranches));\r\n\r\n\r\n                    string sim = m_Backend.AnalyzeExecutionTrace(trace);\r\n\r\n                    MessageBox.Show(sim);\r\n                    panel1.Refresh();\r\n                }\r\n            }\r\n            catch( System.Exception ex )\r\n            {\r\n                MessageBox.Show(ex.Message);\r\n            }\r\n        }\r\n\r\n        private void chkTaken_CheckedChanged(object sender, EventArgs e)\r\n        {\r\n            if (m_TakenBranches.Contains(cfgWidget1.SelectedBranch))\r\n                m_TakenBranches.Remove(cfgWidget1.SelectedBranch);\r\n            else\r\n                m_TakenBranches.Add(cfgWidget1.SelectedBranch);\r\n            MarkExecutedInstructions();\r\n            panel1.Refresh();\r\n        }\r\n\r\n\r\n     \r\n\r\n     \r\n        \r\n\r\n\r\n    }\r\n}\r\n"
  },
  {
    "path": "src/Scrutinizer/UI/ScrutinizerForm.resx",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n  <!-- \n    Microsoft ResX Schema \n    \n    Version 2.0\n    \n    The primary goals of this format is to allow a simple XML format \n    that is mostly human readable. The generation and parsing of the \n    various data types are done through the TypeConverter classes \n    associated with the data types.\n    \n    Example:\n    \n    ... ado.net/XML headers & schema ...\n    <resheader name=\"resmimetype\">text/microsoft-resx</resheader>\n    <resheader name=\"version\">2.0</resheader>\n    <resheader name=\"reader\">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\n    <resheader name=\"writer\">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\n    <data name=\"Name1\"><value>this is my long string</value><comment>this is a comment</comment></data>\n    <data name=\"Color1\" type=\"System.Drawing.Color, System.Drawing\">Blue</data>\n    <data name=\"Bitmap1\" mimetype=\"application/x-microsoft.net.object.binary.base64\">\n        <value>[base64 mime encoded serialized .NET Framework object]</value>\n    </data>\n    <data name=\"Icon1\" type=\"System.Drawing.Icon, System.Drawing\" mimetype=\"application/x-microsoft.net.object.bytearray.base64\">\n        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\n        <comment>This is a comment</comment>\n    </data>\n                \n    There are any number of \"resheader\" rows that contain simple \n    name/value pairs.\n    \n    Each data row contains a name, and value. The row also contains a \n    type or mimetype. Type corresponds to a .NET class that support \n    text/value conversion through the TypeConverter architecture. \n    Classes that don't support this are serialized and stored with the \n    mimetype set.\n    \n    The mimetype is used for serialized objects, and tells the \n    ResXResourceReader how to depersist the object. This is currently not \n    extensible. For a given mimetype the value must be set accordingly:\n    \n    Note - application/x-microsoft.net.object.binary.base64 is the format \n    that the ResXResourceWriter will generate, however the reader can \n    read any of the formats listed below.\n    \n    mimetype: application/x-microsoft.net.object.binary.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\n            : and then encoded with base64 encoding.\n    \n    mimetype: application/x-microsoft.net.object.soap.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\n            : and then encoded with base64 encoding.\n\n    mimetype: application/x-microsoft.net.object.bytearray.base64\n    value   : The object must be serialized into a byte array \n            : using a System.ComponentModel.TypeConverter\n            : and then encoded with base64 encoding.\n    -->\n  <xsd:schema id=\"root\" xmlns=\"\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">\n    <xsd:import namespace=\"http://www.w3.org/XML/1998/namespace\" />\n    <xsd:element name=\"root\" msdata:IsDataSet=\"true\">\n      <xsd:complexType>\n        <xsd:choice maxOccurs=\"unbounded\">\n          <xsd:element name=\"metadata\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" use=\"required\" type=\"xsd:string\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"assembly\">\n            <xsd:complexType>\n              <xsd:attribute name=\"alias\" type=\"xsd:string\" />\n              <xsd:attribute name=\"name\" type=\"xsd:string\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"data\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n                <xsd:element name=\"comment\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"2\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" msdata:Ordinal=\"1\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" msdata:Ordinal=\"3\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" msdata:Ordinal=\"4\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"resheader\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" />\n            </xsd:complexType>\n          </xsd:element>\n        </xsd:choice>\n      </xsd:complexType>\n    </xsd:element>\n  </xsd:schema>\n  <resheader name=\"resmimetype\">\n    <value>text/microsoft-resx</value>\n  </resheader>\n  <resheader name=\"version\">\n    <value>2.0</value>\n  </resheader>\n  <resheader name=\"reader\">\n    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n  <resheader name=\"writer\">\n    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n</root>"
  },
  {
    "path": "src/ScrutinizerTypes.cs",
    "content": "﻿using System.Collections.Generic;\n\nnamespace Pyramid.Scrutinizer\n{\n    public enum BranchCategory\n    {\n        FORK_BRANCH,        /// Branch for which both targets are nested in same loop as current block\n        CONTINUE_BRANCH,    /// Fork branch where one target is loop's header\n        SKIP_BRANCH,        /// Fork branch where one target is the post-dominator of the loop\n        LOOPSKIP_BRANCH,    /// A skip branch which jumps around a complete loop\n\n        BREAK_BRANCH,       /// Not a fork branch\n         \n    };\n\n    public class BasicBlock\n    {\n        public IEnumerable<IInstruction> Instructions { get { return m_Instructions; } }\n        public IEnumerable<BasicBlock> Predecessors { get { return m_Predecessors; } }\n        public IEnumerable<BasicBlock> Successors { get { return m_Successors; } }\n        public int SuccessorCount { get { return m_Successors.Count;  } }\n        public IInstruction LastInstruction { get { return m_Instructions[m_Instructions.Count - 1]; } }\n\n        public BasicBlock PostDominator { get; set; }\n        public BasicBlock ImmediateDominator { get; set; }\n        public Loop InnerMostLoop { get; set; }\n        public void AddSuccessor(BasicBlock bl) { m_Successors.Add(bl); }\n        public void AddPredecessor(BasicBlock bl) { m_Predecessors.Add(bl); }\n        public void AddInstruction(IInstruction i) { m_Instructions.Add(i); }\n        private List<IInstruction> m_Instructions = new List<IInstruction>();\n        private List<BasicBlock> m_Predecessors = new List<BasicBlock>();\n        private List<BasicBlock> m_Successors = new List<BasicBlock>();\n\n        public bool Dominates( BasicBlock b )\n        {\n            if (b == this)\n                return true;\n\n            BasicBlock dom = b.ImmediateDominator;\n            while( dom != null )\n            {\n                if (dom == this)\n                    return true;\n                dom = dom.ImmediateDominator;\n            }\n            return false;\n        }\n    };\n\n    public class Loop\n    {\n        private List<BasicBlock> m_Blocks;\n        private BasicBlock m_Header;\n        \n        public Loop( BasicBlock header, IEnumerable<BasicBlock> blocks )\n        {\n            m_Header = header;\n            m_Blocks = new List<BasicBlock>(blocks);\n            Parent = null;\n            DesiredIterations = 1;\n        }\n\n        public int DesiredIterations { get; set; }\n\n        public IEnumerable<BasicBlock> Blocks { get { return m_Blocks; } }\n        public BasicBlock Header { get { return m_Header; } }\n        public Loop Parent { get; set; }\n        public int BlockCount { get { return m_Blocks.Count; } }\n\n        public bool IsNestedIn( Loop p )\n        {\n            Loop n = this;\n            while (n != null)\n            {\n                if (n == p)\n                    return true;\n                n = n.Parent;\n            }\n            return false;\n        }\n    }\n\n    public interface IInstruction\n    {\n        BasicBlock Block { get; set;  }\n        string Label { get; set; }\n        string SimNotes { get; set; } // String field used to display simulation results\n        string Disassemble();\n    };\n\n    public interface IBranchInstruction : IInstruction\n    {\n        BranchCategory Category { get; set; }\n        IInstruction IfTarget { get; }\n        IInstruction ElseTarget { get; }\n    };\n\n    public interface IJumpInstruction : IInstruction\n    {\n        IInstruction Target { get; }\n    };\n\n    public enum TexelFormat\n    {\n        R8,\n        RG8,\n        RGBA8,\n        R16,\n        RG16,\n        RGBA16,\n        R16F,\n        RG16F,\n        RGBA16F,\n        R32F,\n        RG32F,\n        RGBA32F,\n        BC1,\n        BC2,\n        BC3,\n        BC4,\n        BC5,\n        BC6,\n        BC7\n    };\n    public enum TextureFilter\n    {\n        POINT,\n        BILINEAR,\n        TRILINEAR,\n        ANISO_2X,\n        ANISO_4X,\n        ANISO_8X\n    };\n\n    /// <summary>\n    ///  Interface for instructions which can be annoted with a texture format\n    /// </summary>\n    public interface ITextureInstruction : IInstruction\n    {\n        TexelFormat Format { get; set; }\n    };\n\n    /// <summary>\n    ///  Interface for instructions which can be annoted with a texture format\n    ///   or a filtering mode\n    /// </summary>\n    public interface ISamplingInstruction : ITextureInstruction\n    {\n        TextureFilter Filter { get; set; }\n    };\n\n   \n\n    public interface ISimulationParameter\n    {\n        string Name { get; }\n    };\n\n    public class SimulationParameterInt : ISimulationParameter\n    {\n        public SimulationParameterInt( int nMin, int nMax, int nDefault, string sName )\n        {\n            Min = nMin;\n            Max = nMax;\n            Default = nDefault;\n            Value = Default;\n            Name = sName;\n        }\n        public string Name { get; private set; }\n        public int Min     { get; private set; }\n        public int Max     { get; private set; }\n        public int Default { get; private set; }\n        public int Value   { get; set; }\n    };\n\n    public class SimulationParameterDouble : ISimulationParameter\n    {\n        public SimulationParameterDouble(double fMin, double fMax, double fDefault, string sName )\n        {\n            Min     = fMin;\n            Max     = fMax;\n            Default = fDefault;\n            Value   = Default;\n            Name    = sName;\n        }\n        public string Name { get; private set;  }\n        public double Min     { get; private set; }\n        public double Max     { get; private set; }\n        public double Default { get; private set; }\n        public double Value   { get; set; }\n    };\n\n\n\n    public interface IScrutinizer\n    {\n        List<IInstruction> BuildProgram( );\n\n        List<IInstruction> BuildDXFetchShader(IDXShaderReflection refl);\n\n        IEnumerable<ISimulationParameter> SimulationParameters { get; }\n\n        string AnalyzeExecutionTrace(List<IInstruction> ops);\n\n    };\n\n}"
  },
  {
    "path": "src/Wrapper/AMDAsic_Impl.cpp",
    "content": "\n#include \"AMDAsic_Impl.h\"\n#include \"Utilities.h\"\n\n#include \"amd-codexl-analyzer/Common/Src/DeviceInfo/DeviceInfoUtils.h\"\n#include \"AMDTBackend/Include/Common/asic_reg/atiid.h\"\n#include \"AMDTBackend/Include/Common/asic_reg/si_id.h\"\n#include \"AMDTBackend/Include/Common/asic_reg/ci_id.h\"\n#include \"AMDTBackend/Include/Common/asic_reg/vi_id.h\"\n#include \"AMDTBackend/Include/Common/asic_reg/cz_id.h\"\n#include \"AMDTBackend/Include/Common/asic_reg/kv_id.h\"\n\nstatic void GetDeviceChipFamilyRevision(\n    GDT_HW_ASIC_TYPE type,\n    unsigned int&          chipFamily,\n    unsigned int&          chipRevision) \n{\n    chipFamily = (unsigned int) - 1;\n    chipRevision = (unsigned int) - 1;\n\n    switch (type)\n    {\n        default:\n            // The 600's EG, and NI are no longer supported by OpenCL.\n            // For GSA the earliest DX/GL support is SI.\n            break;\n\n        case GDT_TAHITI_PRO:\n        case GDT_TAHITI_XT:\n            chipFamily = FAMILY_SI;\n            chipRevision = SI_TAHITI_P_B1;\n            break;\n\n        case GDT_PITCAIRN_PRO:\n        case GDT_PITCAIRN_XT:\n            chipFamily = FAMILY_SI;\n            chipRevision = SI_PITCAIRN_PM_A1;\n            break;\n\n        case GDT_CAPEVERDE_PRO:\n        case GDT_CAPEVERDE_XT:\n            chipFamily = FAMILY_SI;\n            chipRevision = SI_CAPEVERDE_M_A1;\n            break;\n\n        case GDT_OLAND:\n            chipFamily = FAMILY_SI;\n            chipRevision = SI_OLAND_M_A0;\n            break;\n\n        case GDT_HAINAN:\n            chipFamily = FAMILY_SI;\n            chipRevision = SI_HAINAN_V_A0;\n            break;\n\n        case GDT_BONAIRE:\n            chipFamily = FAMILY_CI;\n            chipRevision = CI_BONAIRE_M_A0;\n            break;\n\n        case GDT_HAWAII:\n            chipFamily = FAMILY_CI;\n            chipRevision = CI_HAWAII_P_A0;\n            break;\n\n        case GDT_KALINDI:\n            chipFamily = FAMILY_CI;\n            chipRevision = CI_BONAIRE_M_A0;\n            break;\n\n        case GDT_SPECTRE:\n        case GDT_SPECTRE_SL:\n        case GDT_SPECTRE_LITE:\n            chipFamily = FAMILY_CI;\n            chipRevision = KV_SPECTRE_A0;\n            break;\n\n        case GDT_SPOOKY:\n            chipFamily = FAMILY_CI;\n            chipRevision = KV_SPOOKY_A0;\n            break;\n\n        case GDT_ICELAND:\n            chipFamily = FAMILY_VI;\n            chipRevision = VI_ICELAND_M_A0;\n            break;\n\n        case GDT_TONGA:\n            chipFamily = FAMILY_VI;\n            chipRevision = VI_TONGA_P_A0;\n            break;\n\n        case GDT_CARRIZO:\n            chipFamily = FAMILY_VI;\n            chipRevision = CARRIZO_A0;\n            break;\n\n        case GDT_FIJI:\n            chipFamily = FAMILY_VI;\n            chipRevision = VI_FIJI_P_A0;\n            break;\n    }\n\n}\n\n\n\nAMDAsic_Impl::AMDAsic_Impl( const GDT_GfxCardInfo& rCard )\n    : m_pmName( MakeString(rCard.m_szCALName) )\n{\n    unsigned int nChipFamily;\n    unsigned int nChipRevision;\n    GetDeviceChipFamilyRevision(rCard.m_asicType, nChipFamily, nChipRevision);\n\n    switch( rCard.m_generation )\n    {\n    case GDT_HW_GENERATION_SOUTHERNISLAND:\n    case GDT_HW_GENERATION_SEAISLAND:\n        m_pDecoder =  GCN::IDecoder::Create(GCN::IDecoder::GCN1);\n        break;\n    case GDT_HW_GENERATION_VOLCANICISLAND:\n        m_pDecoder =  GCN::IDecoder::Create(GCN::IDecoder::GCN3);\n        break;\n    }\n\n    m_nChipFamily   = nChipFamily;\n    m_nChipRevision = nChipRevision;\n}\n\nAMDAsic_Impl::~AMDAsic_Impl()\n{\n    GCN::IDecoder::Destroy(m_pDecoder);\n    m_pDecoder=0;\n}\n\n "
  },
  {
    "path": "src/Wrapper/AMDAsic_Impl.h",
    "content": "#pragma unmanaged\n#include \"GCNDecoder.h\"\n#pragma managed\n\nstruct GDT_GfxCardInfo;\n\nprivate ref class AMDAsic_Impl : Pyramid::IAMDAsic\n{\npublic:\n    AMDAsic_Impl( const GDT_GfxCardInfo& rCardInfo );\n    \n    ~AMDAsic_Impl();\n\n    property System::String^ Name {\n        virtual System::String^ get() { return m_pmName; }\n    }\n  \n\ninternal:\n    System::String^ m_pmName;\n    GCN::IDecoder* m_pDecoder;\n    unsigned int m_nChipFamily;\n    unsigned int m_nChipRevision;\n};"
  },
  {
    "path": "src/Wrapper/AMDDriver_Impl.cpp",
    "content": "\n#pragma unmanaged\n#include <windows.h>\n#include <algorithm>\n#include \"elf.h\"\n#include \"GCNDisassembler.h\"\n#include \"GCNDecoder.h\"\n#include \"GCNBufferedPrinter.h\"\n#pragma managed\n\n#include \"AMDDriver_Impl.h\"\n#include \"AMDAsic_Impl.h\"\n#include \"AMDShader_Impl.h\"\n#include \"Utilities.h\"\n\n#undef DOMAIN // seriously Microsoft?!?!?\n\n#include \"amd-codexl-analyzer/Common/Src/DeviceInfo/DeviceInfoUtils.h\"\n\n\nstatic bool GfxCardInfoSortPredicate(const GDT_GfxCardInfo& a, const GDT_GfxCardInfo& b)\n{\n\t// Generation is the primary key.\n\tif (a.m_generation < b.m_generation) { return true; }\n\n\tif (a.m_generation > b.m_generation) { return false; }\n\n\t// CAL name is next.\n\tint ret = ::strcmp(a.m_szCALName, b.m_szCALName);\n\n\tif (ret < 0) { return true; }\n\n\tif (ret > 0) { return false; }\n\n\t// Marketing name next.\n\tret = ::strcmp(a.m_szMarketingName, b.m_szMarketingName);\n\n\tif (ret < 0) { return true; }\n\n\tif (ret > 0) { return false; }\n\n\t// DeviceID last.\n\treturn a.m_deviceID < b.m_deviceID;\n}\n\n\n\nAMDDriver_Impl::AMDDriver_Impl( System::String^ path )\n{\n    MarshalledString sPath(path);\n    HMODULE hAMDDriver = LoadLibraryA( sPath );\n    if( !hAMDDriver )\n        throw gcnew System::Exception( System::String::Format( \"AMD driver dll not found at {0}\", path ));\n\n    FARPROC pCompile = GetProcAddress( hAMDDriver, \"AmdDxGsaCompileShader\" );\n    FARPROC pFree    = GetProcAddress( hAMDDriver, \"AmdDxGsaFreeCompiledShader\" );\n    if( !pCompile || !pFree )\n    {\n        FreeLibrary(hAMDDriver);\n        throw gcnew System::Exception( System::String::Format( \"GSA entrypoints not found in {0}\", path ));\n    }\n\n    m_pCompileFunc = (COMPILE_SHADER) pCompile;\n    m_pFreeFunc    = (FREE_SHADER) pFree;\n\n    m_pmAsics = gcnew System::Collections::Generic::List<Pyramid::IAMDAsic^>();\n\n    // Populate the sorted device (card) info table.\n    std::vector<GDT_GfxCardInfo> cardList;\n    std::vector<GDT_GfxCardInfo> DXDeviceTable;\n\n    // DX support now only SI, CI and VI\n    if (AMDTDeviceInfoUtils::Instance()->GetAllCardsInHardwareGeneration(GDT_HW_GENERATION_SOUTHERNISLAND, cardList))\n    {\n        DXDeviceTable.insert(DXDeviceTable.end(), cardList.begin(), cardList.end());\n    }\n\n    if (AMDTDeviceInfoUtils::Instance()->GetAllCardsInHardwareGeneration(GDT_HW_GENERATION_SEAISLAND, cardList))\n    {\n        DXDeviceTable.insert(DXDeviceTable.end(), cardList.begin(), cardList.end());\n    }\n\n    if (AMDTDeviceInfoUtils::Instance()->GetAllCardsInHardwareGeneration(GDT_HW_GENERATION_VOLCANICISLAND, cardList))\n    {\n        DXDeviceTable.insert(DXDeviceTable.end(), cardList.begin(), cardList.end());\n    }\n\n    std::sort(DXDeviceTable.begin(), DXDeviceTable.end(), GfxCardInfoSortPredicate);\n    \n    // de-duplicate cards based on cal name\n    //  Some of these things are pre-release or otherwise unsupported by the driver (at least the current one)\n    //  there are also a few hundred entries in the device table, but only about a dozen or so \"cal names\"\n    size_t i=0;\n    while( i < DXDeviceTable.size() )\n    {\n        m_pmAsics->Add( gcnew AMDAsic_Impl(DXDeviceTable[i] ) );\n\n        const char* pName = DXDeviceTable[i].m_szCALName;\n        do\n        {\n            i++;\n        } while( i < DXDeviceTable.size() && strcmp( pName, DXDeviceTable[i].m_szCALName ) == 0 );\n    }\n\n}\n\n\nPyramid::IAMDShader^  AMDDriver_Impl::CompileDXBlob(Pyramid::IAMDAsic^ asic, array<byte>^ blob, Pyramid::IDXShaderReflection^ reflection )\n{\n    AMDAsic_Impl^ a = dynamic_cast<AMDAsic_Impl^>(asic);\n    \n    MarshalledBlob^ bl = gcnew MarshalledBlob(blob);\n\n    AmdDxGsaCompileShaderInput args;\n    args.byteCodeLength = bl->GetLength();\n    args.pShaderByteCode = bl->GetBlob();\n    args.pCompileOptions = 0;\n    args.numCompileOptions = 0;\n    args.chipRevision   = a->m_nChipRevision;\n    args.chipFamily     = a->m_nChipFamily;\n    memset( args.reserved, 0, sizeof(args.reserved) );\n\n    AmdDxGsaCompileShaderOutput result;\n    result.size = sizeof(result);\n    result.pShaderBinary = 0;\n    result.shaderBinarySize = 0;\n    DWORD hResult = m_pCompileFunc( &args, &result );\n\n    if( hResult != 0 )\n        throw gcnew System::Exception( \"Error returned from AMD driver compile\" );\n\n    AMDShader_Impl::ShaderType eType;\n    switch( reflection->GetShaderType() )\n    {\n    case Pyramid::HLSLShaderType::VERTEX:   eType = AMDShader_Impl::ShaderType::ST_VERTEX;   break;\n    case Pyramid::HLSLShaderType::PIXEL:    eType = AMDShader_Impl::ShaderType::ST_PIXEL;    break;\n    case Pyramid::HLSLShaderType::GEOMETRY: eType = AMDShader_Impl::ShaderType::ST_GEOMETRY; break;\n    case Pyramid::HLSLShaderType::DOMAIN:   eType = AMDShader_Impl::ShaderType::ST_DOMAIN;   break;\n    case Pyramid::HLSLShaderType::HULL:     eType = AMDShader_Impl::ShaderType::ST_HULL;     break;\n    case Pyramid::HLSLShaderType::COMPUTE:  eType = AMDShader_Impl::ShaderType::ST_COMPUTE;  break;\n    default:\n        throw gcnew System::Exception( \"Bad shader type enum???\");\n    }\n\n    DWORD nThreadsPerGroup = reflection->GetThreadsPerGroup();\n\n    return gcnew AMDShader_Impl( this, a, (Elf32_Ehdr*)result.pShaderBinary, result.shaderBinarySize, nThreadsPerGroup, eType );\n}\n"
  },
  {
    "path": "src/Wrapper/AMDDriver_Impl.h",
    "content": "#pragma unmanaged\n#include \"AMDTBackend/Include/Common/AmdDxGsaCompile.h\"\ntypedef PfnAmdDxGsaCompileShader COMPILE_SHADER;\ntypedef PfnAmdDxGsaFreeCompiledShader FREE_SHADER;\n#pragma managed\n\nprivate ref class AMDDriver_Impl : public Pyramid::IAMDDriver\n{\npublic:\n\n    AMDDriver_Impl( System::String^ path );\n    \n\n    property System::Collections::Generic::IEnumerable<Pyramid::IAMDAsic^>^ Asics\n    {\n        virtual System::Collections::Generic::IEnumerable<Pyramid::IAMDAsic^>^ get()\n        {\n            return m_pmAsics;\n        }\n    }\n\n    virtual Pyramid::IAMDShader^  CompileDXBlob(Pyramid::IAMDAsic^ asic, array<byte>^ exe, Pyramid::IDXShaderReflection^ reflection );\n\ninternal:\n\n    COMPILE_SHADER  m_pCompileFunc;\n    FREE_SHADER     m_pFreeFunc;\n    \nprivate:\n\n    System::Collections::Generic::List<Pyramid::IAMDAsic^>^ m_pmAsics;\n};"
  },
  {
    "path": "src/Wrapper/AMDShader_Impl.cpp",
    "content": "\n#pragma unmanaged\n#include <windows.h>\n#include \"elf.h\"\n#include \"GCNDisassembler.h\"\n#include \"GCNDecoder.h\"\n#include \"GCNBufferedPrinter.h\"\n#pragma managed\n\n#include \"AMDShader_Impl.h\"\n#include \"AMDDriver_Impl.h\"\n#include \"AMDAsic_Impl.h\"\n#include \"Utilities.h\"\n\n#include \"Scrutinizer_GCN.h\"\n\nAMDShader_Impl::AMDShader_Impl( AMDDriver_Impl^ pOwner, AMDAsic_Impl^ asic, Elf32_Ehdr* pElf, DWORD nElfSize,\n                                DWORD nThreadsPerGroup, ShaderType eShaderType )\n    : m_pmDriver(pOwner), \n        m_pmAsic(asic), \n        m_pElf(pElf),\n        m_nElfSize(nElfSize),\n        m_pISA(0),\n        m_nISASize(0),\n        m_pStats(0),\n        m_nStatsSize(0),\n        m_nThreadsPerThreadGroup(nThreadsPerGroup),\n        m_eShaderType(eShaderType)\n{\n    // make sure they're using ELF\n    if( pElf->e_ident[0] != 0x7f || \n        pElf->e_ident[1] != 'E' || \n        pElf->e_ident[2] != 'L' ||\n        pElf->e_ident[3] != 'F' )\n        throw gcnew System::Exception(\"Blob received from AMD driver is not an elf binary\");\n\n    // find the '.text' section, which contains the code\n    byte* pElfBytes = (byte*)pElf;\n    Elf32_Shdr* pSections = (Elf32_Shdr*) (pElfBytes + pElf->e_shoff);\n\n    Elf32_Shdr* pStringTable = pSections + pElf->e_shstrndx;\n    byte* pElfStringTable    = pElfBytes + pStringTable->sh_offset;\n    for( DWORD i=0; i<pElf->e_shnum; i++ )\n    {\n        DWORD nString = pSections[i].sh_name;\n        byte* pSectionName = pElfStringTable + pSections[i].sh_name;\n        if( strcmp( (const char*) pSectionName, \".text\" ) == 0 )\n        {\n            m_pISA     = pElfBytes + pSections[i].sh_offset;\n            m_nISASize = pSections[i].sh_size;           \n        }\n        if( strcmp( (const char*) pSectionName, \".stats\" ) == 0 )\n        {\n            m_pStats = (DWORD*) (pElfBytes + pSections[i].sh_offset);\n            m_nStatsSize = pSections[i].sh_size;\n        }\n    }\n\n    // didn't find it.  Kick and scream\n    if( !m_pISA )\n        throw gcnew System::Exception( \"Blob received from AMD driver does not contain a '.text' section\");\n    if( !m_pStats || (m_nStatsSize % 4) )\n        throw gcnew System::Exception( \"'.stats' section from driver blob is missing or misaligned\");\n}\n\nAMDShader_Impl::~AMDShader_Impl()\n{\n    GCN::IDecoder::Destroy( m_pDecoder );\n    m_pmDriver->m_pFreeFunc(m_pElf);\n    m_pElf=0;\n    m_nElfSize=0;\n    m_pStats=0;\n    m_nStatsSize=0;\n    m_pISA=0;\n    m_nISASize=0;\n}\n\n\narray<byte>^ AMDShader_Impl::ReadISABytes()\n{\n    array<byte>^ bytes = gcnew array<byte>(m_nISASize);\n    for( DWORD i=0; i<m_nISASize; i++ )\n        bytes[i] = m_pISA[i];\n    return bytes;\n}\n\nSystem::String^ AMDShader_Impl::Disassemble()\n{\n    GCN::Disassembler::BufferedPrinter printer;\n\n    if( !GCN::Disassembler::DisassembleProgram( *m_pmAsic->m_pDecoder, printer, m_pISA, m_nISASize ) )\n        printer.Push(\"Disassembly terminated due to encoding error\\n\");\n\n    printer.m_Bytes.push_back(0);\n\n    System::String^ str = MakeString( printer.m_Bytes.data() );\n    return str->Replace( \"\\n\", System::Environment::NewLine );\n}\n\nSystem::String^ AMDShader_Impl::ListEncodings()\n{\n    GCN::Disassembler::BufferedPrinter  printer;\n\n    if( !GCN::Disassembler::ListEncodings( *m_pmAsic->m_pDecoder, printer, m_pISA, m_nISASize ) )\n        printer.Push(\"Disassembly terminated due to encoding error\\n\");\n\n    printer.m_Bytes.push_back(0);\n\n    System::String^ str = MakeString( printer.m_Bytes.data() );\n    return str->Replace( \"\\n\", System::Environment::NewLine );\n}\n\n\nSystem::String^ AMDShader_Impl::PrintStats( )\n{\n    DWORD nSGPRs        = m_pStats[0];\n    DWORD nMaxSGPRs     = m_pStats[1];\n    DWORD nVGPRs        = m_pStats[2];\n    DWORD nMaxVGPRs     = m_pStats[3];\n    DWORD nUsedLDS      = m_pStats[4];\n    DWORD nMaxLDS       = m_pStats[5];\n    DWORD nScratchBytes = m_pStats[6];\n    DWORD nALUOps       = m_pStats[7];\n    DWORD nScalarOps    = m_pStats[8];\n    DWORD nMemoryOps    = m_pStats[9];\n\n    // NOTE:\n    //   SI and CI had to have GPRs allocated in multiples of 4\n    //     According to docs this is true for VI as well.\n    //\n    //  However, for VI chips, driver is reporting VGPR counts that are not multiples of 4\n    //     I do not know if this is a driver bug or a doc bug, but\n    //     I'm going to assume the latter\n    //\n    DWORD nVGPROccupancy=10;\n    DWORD nSGPROccupancy=10;\n    if( nVGPRs )\n        nVGPROccupancy = nMaxVGPRs/nVGPRs;\n    if( nSGPRs )\n        nSGPROccupancy = 512/nSGPRs;\n\n    if( nVGPROccupancy > 10 )\n        nVGPROccupancy = 10;\n    if( nSGPROccupancy > 10 )\n        nSGPROccupancy = 10;\n\n    DWORD nLDSOccupancy = 0;\n    if( nUsedLDS )\n        nLDSOccupancy = nMaxLDS / nUsedLDS;\n\n    DWORD nWavesPerGroup = (m_nThreadsPerThreadGroup+63)/64;\n    \n\n    char buffer[4096];\n    sprintf( buffer,\n        \"SGPRs:          %3u / %u\\n\"\n        \"VGPRs:          %3u / %u\\n\"\n        \"LDS bytes/tg %6u / %u\\n\"\n        \"Waves/Group:    %u\\n\"\n        \"Occupancy:\\n\"\n        \"   S: %2u waves/SIMD\\n\"\n        \"   V: %2u waves/SIMD\\n\"\n        \"   L: %2u groups/CU\\n\"\n        \"      %2u waves/CU\\n\"\n        \"       %.2f waves/SIMD \\n\"\n        \"Ops:\\n\"\n        \"   VALU: %u\\n\"\n        \"   S:    %u\\n\"\n        \"   VMEM: %u\\n\",\n        nSGPRs,nMaxSGPRs,\n        nVGPRs,nMaxVGPRs,\n        nUsedLDS,nMaxLDS,\n        nWavesPerGroup,\n        nSGPROccupancy,\n        nVGPROccupancy,\n        nLDSOccupancy*2,\n        nLDSOccupancy*2*nWavesPerGroup,\n        (nLDSOccupancy*2*nWavesPerGroup)/4.0f,\n        nALUOps,\n        nScalarOps,\n        nMemoryOps\n        );\n\n    System::String^ str = gcnew System::String(buffer);\n    return str->Replace(\"\\n\", System::Environment::NewLine );\n}\n\nsize_t AMDShader_Impl::GetWaveOccupancy()\n{\n    DWORD nSGPRs        = m_pStats[0];\n    DWORD nMaxSGPRs     = m_pStats[1];\n    DWORD nVGPRs        = m_pStats[2];\n    DWORD nMaxVGPRs     = m_pStats[3];\n    DWORD nUsedLDS      = m_pStats[4];\n    DWORD nMaxLDS       = m_pStats[5];\n    DWORD nScratchBytes = m_pStats[6];\n    DWORD nALUOps       = m_pStats[7];\n    DWORD nScalarOps    = m_pStats[8];\n    DWORD nMemoryOps    = m_pStats[9];\n\n    // NOTE:\n    //   SI and CI had to have GPRs allocated in multiples of 4\n    //     According to docs this is true for VI as well.\n    //\n    //  However, for VI chips, driver is reporting VGPR counts that are not multiples of 4\n    //     I do not know if this is a driver bug or a doc bug, but\n    //     I'm going to assume the latter\n    //\n    DWORD nVGPROccupancy=10;\n    DWORD nSGPROccupancy=10;\n    if( nVGPRs )\n        nVGPROccupancy = nMaxVGPRs/nVGPRs;\n    if( nSGPRs )\n        nSGPROccupancy = 512/nSGPRs;\n\n    if( nVGPROccupancy > 10 )\n        nVGPROccupancy = 10;\n    if( nSGPROccupancy > 10 )\n        nSGPROccupancy = 10;\n\n    return (nVGPROccupancy < nSGPROccupancy) ? nVGPROccupancy : nSGPROccupancy;\n}\n\nsize_t AMDShader_Impl::GetGroupOccupancy()\n{\n    DWORD nUsedLDS      = m_pStats[4];\n    DWORD nMaxLDS       = m_pStats[5];\n    if( !nUsedLDS )\n        return 40/GetWavesPerThreadGroup();\n    \n    size_t nMaxGroupsLDS = (nMaxLDS/nUsedLDS)*2;\n    size_t nMaxGroupsWaveSlots = 40/GetWavesPerThreadGroup();\n\n    return min(nMaxGroupsLDS,nMaxGroupsWaveSlots);\n}\n\nPyramid::Scrutinizer::IScrutinizer^ AMDShader_Impl::CreateScrutinizer()\n{\n    switch( m_eShaderType )\n    {\n    case ShaderType::ST_VERTEX:\n        return gcnew Scrutinizer_GCN_VS( m_pmAsic, this );\n    case ShaderType::ST_PIXEL:\n        return gcnew Scrutinizer_GCN_PS( m_pmAsic, this );\n    case ShaderType::ST_COMPUTE:\n        return gcnew Scrutinizer_GCN_CS( m_pmAsic, this );\n    default:\n        return nullptr;\n    }\n}\n\n\nPyramid::IAMDAsic^ AMDShader_Impl::Asic::get()\n{\n    return m_pmAsic;\n}"
  },
  {
    "path": "src/Wrapper/AMDShader_Impl.h",
    "content": "\n\n#pragma unmanaged\n#include \"elf.h\"\ntypedef unsigned long DWORD;\ntypedef unsigned char byte;\n#pragma managed\n\nref class AMDAsic_Impl;\nref class AMDDriver_Impl;\n\nprivate ref class AMDShader_Impl : public Pyramid::IAMDShader\n{\npublic:\n\n    enum class ShaderType\n    {\n        ST_VERTEX,\n        ST_PIXEL,\n        ST_GEOMETRY,\n        ST_HULL,\n        ST_DOMAIN,\n        ST_COMPUTE\n    };\n\n    AMDShader_Impl( AMDDriver_Impl^ pOwner, AMDAsic_Impl^ asic, Elf32_Ehdr* pElf, \n                    DWORD nElfSize, DWORD nThreadsPerThreadGroup,\n                    ShaderType eShaderType );\n      \n\n    ~AMDShader_Impl();\n\n    virtual array<byte>^ ReadISABytes();\n   \n    virtual System::String^ Disassemble();\n  \n\n    \n    virtual System::String^ ListEncodings();\n\n    virtual System::String^ PrintStats( );\n\n    property Pyramid::IAMDAsic^ Asic\n    {\n        virtual Pyramid::IAMDAsic^ get();\n    }\n\n    size_t GetWaveOccupancy();\n    size_t GetGroupOccupancy();\n    size_t GetThreadsPerThreadGroup()  { return m_nThreadsPerThreadGroup; }\n    size_t GetWavesPerThreadGroup() { return (m_nThreadsPerThreadGroup+63)/64;}\n\n    virtual Pyramid::Scrutinizer::IScrutinizer^ CreateScrutinizer();\n\ninternal:\n    AMDDriver_Impl^ m_pmDriver;\n    AMDAsic_Impl^ m_pmAsic; \n    Elf32_Ehdr* m_pElf;\n    DWORD m_nElfSize;\n\n    DWORD* m_pStats;\n    DWORD  m_nStatsSize;\n\n    byte* m_pISA;\n    DWORD m_nISASize;\n    GCN::IDecoder* m_pDecoder;\n\n    DWORD m_nThreadsPerThreadGroup;\n    ShaderType m_eShaderType;\n};\n"
  },
  {
    "path": "src/Wrapper/D3DCompiler_Impl.cpp",
    "content": "#include \"D3DCompiler_Impl.h\"\n#include \"Utilities.h\"\n\n#include <Windows.h>\n\n#pragma unmanaged\n#include <vector>\n#include <atlbase.h>\n#include \"dxc/dxcapi.h\"\n#pragma managed\n\n///////////////////////////////////////////////////////////////////////////////////////\n\nclass PyramidD3DIncludeHandler : public ID3DInclude\n{\npublic:\n    PyramidD3DIncludeHandler( Pyramid::IIncludeHandler^ pmInclude, System::String^ root )\n        : m_pmInclude(pmInclude)\n    {\n        // D3D compiler doesn't pass the source file path to you\n        //  They expect you to track it yourself.\n        m_Stack.push_back(root);\n    }\n\n    virtual  HRESULT __stdcall Open(\n         D3D_INCLUDE_TYPE IncludeType,\n         LPCSTR           pFileName,\n         LPCVOID          pParentData,\n          LPCVOID          *ppData,\n         UINT             *pBytes) override\n    {\n        *ppData=0;\n        *pBytes=0;\n\n        Pyramid::IIncludeHandler^ pmInclude = static_cast<Pyramid::IIncludeHandler^>(m_pmInclude);\n        if( pmInclude == nullptr )\n            return E_FAIL;\n        \n        Pyramid::IncludeType eType;\n        switch( IncludeType )\n        {\n        case D3D_INCLUDE_SYSTEM: eType = Pyramid::IncludeType::System; break;\n        case D3D_INCLUDE_LOCAL:  eType = Pyramid::IncludeType::User; break;\n        default: return E_FAIL;\n        }\n\n        \n        Pyramid::IIncludeResult^ result = pmInclude->OpenInclude(eType,MakeString(pFileName),m_Stack.back() );\n        if( result == nullptr )\n            return E_FAIL;\n        \n        array<unsigned char>^ pFileContents =  result->Contents;\n        void* pNative = malloc(pFileContents->Length);\n\n        Marshal::Copy( pFileContents, 0, System::IntPtr(pNative), pFileContents->Length);\n        \n        *ppData = pNative;\n        *pBytes = pFileContents->Length;\n        m_Stack.push_back( result->FullPath );\n        return S_OK;\n    }\n\n    virtual HRESULT __stdcall Close(LPCVOID pData) override\n    {\n        if( !pData )\n            return S_OK;\n\n        free((void*)pData);\n        m_Stack.pop_back();\n        return S_OK;\n    }\n\nprivate:\n    gcroot<Pyramid::IIncludeHandler^> m_pmInclude;\n    std::vector< gcroot<System::String^> > m_Stack;\n\n};\n\n///////////////////////////////////////////////////////////////////////////////////////\nDXBCRootSignatureBlob_Impl::DXBCRootSignatureBlob_Impl( ID3DBlob* pBlob,D3DCompiler_Impl^ pCompiler ) : m_pBlob( pBlob ),m_pmCompiler( pCompiler )\n{\n}\n\nDXBCRootSignatureBlob_Impl::~DXBCRootSignatureBlob_Impl()\n{\n    if ( m_pBlob )\n        m_pBlob->Release();\n}\narray<byte>^ DXBCRootSignatureBlob_Impl::ReadBytes()\n{\n    if ( !m_pBlob )\n        return nullptr;\n\n    size_t size  = m_pBlob->GetBufferSize();\n    byte* pBytes = (byte*)m_pBlob->GetBufferPointer();\n    array<byte>^ pmBytes = gcnew array<byte>( m_pBlob->GetBufferSize() );\n    for ( size_t i=0; i<size; i++ )\n        pmBytes[i] = pBytes[i];\n\n    return pmBytes;\n}\n///////////////////////////////////////////////////////////////////////////////////////\n\nDXBCShaderBlob_Impl::DXBCShaderBlob_Impl( ID3DBlob* pBlob, D3DCompiler_Impl^ pCompiler ) : m_pBlob(pBlob), m_pmCompiler(pCompiler)\n{\n}\nDXBCShaderBlob_Impl::~DXBCShaderBlob_Impl()\n{\n    if( m_pBlob )\n        m_pBlob->Release();\n}\n\nPyramid::IDXBlob^ DXBCShaderBlob_Impl::ExtractRootSignature()\n{\n    if ( m_pBlob )\n    {\n        ID3DBlob* pRSBlob;\n        HRESULT hr = m_pmCompiler->m_pGetBlob( m_pBlob->GetBufferPointer(),m_pBlob->GetBufferSize(),D3D_BLOB_ROOT_SIGNATURE,0,&pRSBlob );\n        if ( SUCCEEDED( hr ) && pRSBlob != nullptr )\n        {\n            return gcnew DXBCRootSignatureBlob_Impl( pRSBlob,m_pmCompiler );\n        }\n    }\n    return nullptr;\n}\n\nSystem::String^ DXBCShaderBlob_Impl::Disassemble()\n{\n    if( m_pBlob )\n    {\n        ID3DBlob* pAsm=0;\n        HRESULT hr = m_pmCompiler->m_pDisassemble( m_pBlob->GetBufferPointer(), m_pBlob->GetBufferSize(), 0, 0, &pAsm );\n        if( SUCCEEDED(hr) && pAsm )\n        {\n            System::String^ IR = Marshal::PtrToStringAnsi( System::IntPtr(pAsm->GetBufferPointer()) );\n            IR = IR->Replace( gcnew System::String(\"\\n\"), System::Environment::NewLine );\n            pAsm->Release();\n            return IR;\n        }\n    }\n    return gcnew System::String(\"\");\n}\narray<byte>^ DXBCShaderBlob_Impl::ReadBytes()\n{\n    if( !m_pBlob )\n        return nullptr;\n\n    size_t size  = m_pBlob->GetBufferSize();\n    byte* pBytes = (byte*) m_pBlob->GetBufferPointer();\n    array<byte>^ pmBytes = gcnew array<byte>( m_pBlob->GetBufferSize() );\n    for( size_t i=0; i<size; i++ )\n        pmBytes[i] = pBytes[i];\n\n    return pmBytes;\n}\n\nPyramid::IDXBCShaderBlob^ DXBCShaderBlob_Impl::Strip()\n{\n    if( !m_pBlob )\n        return nullptr;\n\n    UINT uFlags = D3DCOMPILER_STRIP_REFLECTION_DATA|\n                  D3DCOMPILER_STRIP_DEBUG_INFO|\n                  D3DCOMPILER_STRIP_TEST_BLOBS|\n                  D3DCOMPILER_STRIP_PRIVATE_DATA;\n\n    ID3DBlob* pStripped=0;\n    HRESULT hr = m_pmCompiler->m_pStrip( m_pBlob->GetBufferPointer(), m_pBlob->GetBufferSize(), uFlags, &pStripped );\n    if( !SUCCEEDED(hr))\n        throw gcnew System::Exception(\"D3DStripShader failed\");\n\n    return gcnew DXBCShaderBlob_Impl(pStripped,m_pmCompiler);\n}\n\n\nPyramid::IDXBCShaderBlob^ DXBCShaderBlob_Impl::GetSignatureBlob()\n{\n    if( !m_pBlob )\n        return nullptr;\n\n    ID3DBlob* pSignature=0;\n    \n    HRESULT hr = m_pmCompiler->m_pGetBlob( m_pBlob->GetBufferPointer(), m_pBlob->GetBufferSize(), D3D_BLOB_INPUT_AND_OUTPUT_SIGNATURE_BLOB,0, &pSignature );\n    if( !SUCCEEDED(hr))\n        throw gcnew System::Exception(\"D3DGetBlobPart failed\");\n\n    return gcnew DXBCShaderBlob_Impl(pSignature,m_pmCompiler);\n}\n\nPyramid::IDXBCShaderBlob^ DXBCShaderBlob_Impl::GetExecutableBlob()\n{\n    if( !m_pBlob )\n        return nullptr;\n\n    // The actual, executable bytecode is signaled by a magic 4cc code\n    //   Following the fourcc is the size of the executable code in bytes\n    // \n    DWORD nSM4Sentinel = MAKEFOURCC('S','H','D','R');\n    DWORD nSM5Sentinel = MAKEFOURCC('S','H','E','X');\n    DWORD* pBlob = (DWORD*) m_pBlob->GetBufferPointer();\n    for( UINT i=0; i<m_pBlob->GetBufferSize(); i+= 4 )\n    {\n        if( pBlob[i/4] == nSM5Sentinel || pBlob[i/4] == nSM4Sentinel )\n        {\n            DWORD nCodeSizeInBytes = pBlob[(i/4) + 1];\n            \n            ID3DBlob* pResultBlob=0;\n            if( FAILED(m_pmCompiler->m_pCreateBlob( nCodeSizeInBytes, &pResultBlob ) ) )\n                throw gcnew System::Exception(\"D3DCreateBlob failed\");\n\n            memcpy( pResultBlob->GetBufferPointer(), pBlob + (i/4)+2, nCodeSizeInBytes );\n            return gcnew DXBCShaderBlob_Impl( pResultBlob, m_pmCompiler );\n        }\n    }\n    \n    return nullptr; // no code in this blob\n}\n\nPyramid::IDXShaderReflection^ DXBCShaderBlob_Impl::Reflect()\n{\n    ID3D11ShaderReflection* pReflect=0;\n    HRESULT hr = m_pmCompiler->m_pReflect( m_pBlob->GetBufferPointer(), m_pBlob->GetBufferSize(), __uuidof(ID3D11ShaderReflection), (void**) &pReflect );\n    if( FAILED(hr) )\n        throw gcnew System::Exception(\"Shader reflection failed\");\n\n    return gcnew DXShaderReflection_Impl(pReflect);\n}\n\n\n///////////////////////////////////////////////////////////////////////////////////////\n\nD3DCompiler_Impl::D3DCompiler_Impl( System::String^ DLLPath,  Pyramid::IIncludeHandler^ pmInclude )\n{\n    MarshalledString DLL(DLLPath);\n    \n    HMODULE hDLL = LoadLibraryA( DLL );\n    if( !hDLL )\n        throw gcnew System::Exception(System::String::Format( \"LoadLibrary failed for {0}\", DLLPath ));\n    \n    void* pCompile2Func = GetProcAddress( hDLL, \"D3DCompile2\" );\n    \n    void* pCompileFunc = GetProcAddress( hDLL, \"D3DCompile\" );\n    if( !pCompileFunc )\n        throw gcnew System::Exception(System::String::Format( \"GetProcAddress failed for 'D3DCompile'\"));\n    \n    void* pDisassembleFunc = GetProcAddress( hDLL, \"D3DDisassemble\" );\n    if( !pDisassembleFunc )\n        throw gcnew System::Exception(System::String::Format(\"GetProcAddress failed for 'D3DDisassemble'\"));\n   \n    void* pStripFunc = GetProcAddress(hDLL,\"D3DStripShader\");\n    if( !pStripFunc )\n        throw gcnew System::Exception(System::String::Format(\"GetProcAddress failed for 'D3DStripShader'\"));\n\n    void* pGetBlobPartFunc = GetProcAddress(hDLL,\"D3DGetBlobPart\");\n    if( !pGetBlobPartFunc )\n        throw gcnew System::Exception(System::String::Format(\"GetProcAddress failed for 'D3DGetBlobPart'\"));\n\n    void* pCreateBlobFunc = GetProcAddress(hDLL, \"D3DCreateBlob\" );\n    if( !pCreateBlobFunc )\n        throw gcnew System::Exception(System::String::Format(\"GetProcAddress failed for 'D3DCreateBlob'\"));\n\n    void* pReflectFunc = GetProcAddress(hDLL, \"D3DReflect\");\n    if( !pReflectFunc )\n        throw gcnew System::Exception(System::String::Format(\"GetProcAddress failed for 'D3DReflect'\"));\n\n\n    m_pCompile2    = (D3DCOMPILE2_FUNC) pCompile2Func;\n    m_pCompile     = (D3DCOMPILE_FUNC) pCompileFunc;\n    m_pDisassemble = (D3DDISASSEMBLE_FUNC) pDisassembleFunc;\n    m_pStrip       = (D3DSTRIP_FUNC)pStripFunc;\n    m_pGetBlob     = (D3DGETBLOBPART_FUNC)pGetBlobPartFunc;\n    m_pCreateBlob  = (D3DCREATEBLOB_FUNC) pCreateBlobFunc;\n    m_pReflect     = (D3DREFLECT_FUNC) pReflectFunc;\n    m_pmInclude    = pmInclude;\n}\n\n\n\nbool D3DCompiler_Impl::Compile( System::String^ Shader,\n    Pyramid::IHLSLOptions^ opts,\n    System::String^ fileName,\n    Pyramid::IDXBCShaderBlob^% IR,\n    System::String^% Messages )\n{\n   \n     \n    ID3DBlob* pCode=0;\n    ID3DBlob* pMessages=0;\n    HRESULT hr;\n    MarshalledString hlsl( Shader );\n    MarshalledString entry( opts->EntryPoint );\n    MarshalledString profile( opts->Target.ToString() );\n\n    PyramidD3DIncludeHandler include( m_pmInclude,fileName );\n\n\n    if ( m_pCompile2 )\n    {\n        hr = m_pCompile2( hlsl.GetString(),\n            hlsl.Length()+1,\n            \"\",\n            0,\n            &include,\n            entry,profile,opts->GetD3DCompileFlagBits(),0,\n            0,0,0,\n            &pCode,&pMessages );\n    }\n    else\n    {\n        hr = m_pCompile( hlsl.GetString(),\n            hlsl.Length()+1,\n            \"\",\n            0,\n            &include,\n            entry,profile,opts->GetD3DCompileFlagBits(),0,&pCode,&pMessages );\n    }\n   \n    if ( SUCCEEDED( hr ) )\n        IR = gcnew DXBCShaderBlob_Impl( pCode,this );\n\n    Messages = nullptr;\n    if ( pMessages )\n    {\n        Messages = Marshal::PtrToStringAnsi( System::IntPtr( pMessages->GetBufferPointer() ) );\n        Messages = Messages->Replace( gcnew System::String( \"\\n\" ),System::Environment::NewLine );\n        pMessages->Release();\n    }\n\n    return SUCCEEDED( hr );\n}\n\nbool D3DCompiler_Impl::CompileRootSignature(\n        System::String^ Shader,\n        Pyramid::IHLSLOptions^ opts,\n        System::String^ Path,\n        Pyramid::IDXBlob^% blob,\n        System::String^% Messages )\n{\n\n\n    ID3DBlob* pCode=0;\n    ID3DBlob* pMessages=0;\n    HRESULT hr;\n    MarshalledString hlsl( Shader );\n    MarshalledString entry( opts->RootSigMacro );\n    MarshalledString profile( opts->RootSigTarget.ToString() );\n\n    PyramidD3DIncludeHandler include( m_pmInclude,Path );\n\n\n    {\n        hr = m_pCompile( hlsl.GetString(),\n            hlsl.Length()+1,\n            \"\",\n            0,\n            &include,\n            entry,profile,opts->GetD3DCompileFlagBits(),0,&pCode,&pMessages );\n    }\n\n    if ( SUCCEEDED( hr ) )\n        blob = gcnew DXBCRootSignatureBlob_Impl( pCode,this );\n\n    Messages = nullptr;\n    if ( pMessages )\n    {\n        Messages = Marshal::PtrToStringAnsi( System::IntPtr( pMessages->GetBufferPointer() ) );\n        Messages = Messages->Replace( gcnew System::String( \"\\n\" ),System::Environment::NewLine );\n        pMessages->Release();\n    }\n\n    return SUCCEEDED( hr );\n\n}"
  },
  {
    "path": "src/Wrapper/D3DCompiler_Impl.h",
    "content": "\n#ifndef _D3D_COMPILER_IMPL_H_\n#define _D3D_COMPILER_IMPL_H_\n\n#pragma unmanaged\n#include <d3dcompiler.h>\n#pragma managed\n\ntypedef HRESULT (WINAPI *D3DCOMPILE_FUNC)(\n                     LPCVOID pSrcData,\n                     SIZE_T SrcDataSize,\n                     LPCSTR pSourceName,\n                     const D3D_SHADER_MACRO *pDefines,\n                     ID3DInclude *pInclude,\n                     LPCSTR pEntrypoint,\n                     LPCSTR pTarget,\n                     UINT Flags1,\n                     UINT Flags2,\n                     ID3DBlob **ppCode,\n                     ID3DBlob **ppErrorMsgs);\n\n\ntypedef HRESULT (WINAPI *D3DCOMPILE2_FUNC)(\n  LPCVOID pSrcData,\n  SIZE_T SrcDataSize,\n  LPCSTR pSourceName,\n  const D3D_SHADER_MACRO* pDefines,\n  ID3DInclude* pInclude,\n  LPCSTR pEntrypoint,\n  LPCSTR pTarget,\n  UINT Flags1,\n  UINT Flags2,\n  UINT SecondaryDataFlags,\n  LPCVOID pSecondaryData,\n  SIZE_T SecondaryDataSize,\n  ID3DBlob** ppCode,\n  ID3DBlob** ppErrorMsgs\n);\n\ntypedef HRESULT (WINAPI *D3DDISASSEMBLE_FUNC)(\n    LPCVOID pSrcData,\n    SIZE_T SrcDataSize,\n    UINT Flags,\n    LPCSTR szComments,\n    ID3DBlob **ppDisassembly\n);\n\ntypedef HRESULT (WINAPI *D3DSTRIP_FUNC)(\n       LPCVOID pShaderBytecode,\n       SIZE_T BytecodeLength,\n       UINT uStripFlags,\n       ID3DBlob **ppStrippedBlob\n    );\n\ntypedef HRESULT (WINAPI *D3DGETBLOBPART_FUNC)(\n       LPCVOID pShaderBytecode,\n       SIZE_T BytecodeLength,\n       UINT uBlobPartEnum,\n       UINT uFlags,\n       ID3DBlob **ppBlob\n    );\n\ntypedef HRESULT (WINAPI *D3DCREATEBLOB_FUNC)(\n        SIZE_T nBytes,\n        ID3DBlob** ppBlob\n    );\n\ntypedef HRESULT (WINAPI *D3DREFLECT_FUNC)(\n   LPCVOID pSrcData,\n   SIZE_T SrcDataSize,\n   REFIID pInterface,\n   void** ppReflector\n    );\n\nref class D3DCompiler_Impl;\n\nprivate ref class DXBCRootSignatureBlob_Impl : Pyramid::IDXBlob\n{\npublic:\n    DXBCRootSignatureBlob_Impl( ID3DBlob* pBlob,D3DCompiler_Impl^ pCompiler );\n    ~DXBCRootSignatureBlob_Impl();\n\n    virtual array<byte>^ ReadBytes();\n\n\nprivate:\n    ID3DBlob* m_pBlob;\n    D3DCompiler_Impl^ m_pmCompiler;\n};\n\n\nprivate ref class DXBCShaderBlob_Impl : Pyramid::IDXBCShaderBlob\n{\npublic:\n    DXBCShaderBlob_Impl( ID3DBlob* pBlob, D3DCompiler_Impl^ pCompiler );\n    ~DXBCShaderBlob_Impl( );\n\n    virtual Pyramid::IDXBlob^ ExtractRootSignature();\n    virtual System::String^ Disassemble();\n    virtual array<byte>^ ReadBytes();\n    virtual Pyramid::IDXBCShaderBlob^ Strip();\n    virtual Pyramid::IDXBCShaderBlob^ GetSignatureBlob();\n    virtual Pyramid::IDXBCShaderBlob^ GetExecutableBlob();\n    virtual Pyramid::IDXShaderReflection^ Reflect();\n\nprivate:\n    ID3DBlob* m_pBlob;\n    D3DCompiler_Impl^ m_pmCompiler;\n};\n\n\nprivate ref class D3DCompiler_Impl : Pyramid::ID3DCompiler\n{\npublic:\n\n    D3DCompiler_Impl( System::String^ DLLPath, Pyramid::IIncludeHandler^ pmIncludes );\n    \n    virtual bool CompileRootSignature( System::String^ Shader,\n                                        Pyramid::IHLSLOptions^ opts,\n                                        System::String^ Path,\n                                        Pyramid::IDXBlob^% blob,\n                                        System::String^% Errors );\n\n    virtual bool Compile( System::String^ Shader, \n                          Pyramid::IHLSLOptions^ opts,\n                          System::String^ Path,\n                          Pyramid::IDXBCShaderBlob^% blob,  \n                          System::String^% Errors  );\n\ninternal:\n    \n    D3DCOMPILE_FUNC m_pCompile;\n    D3DCOMPILE2_FUNC m_pCompile2;\n    D3DDISASSEMBLE_FUNC m_pDisassemble;\n    D3DSTRIP_FUNC m_pStrip;\n    D3DGETBLOBPART_FUNC m_pGetBlob;\n    D3DCREATEBLOB_FUNC m_pCreateBlob;\n    D3DREFLECT_FUNC m_pReflect;\n    Pyramid::IIncludeHandler^ m_pmInclude;\n};\n\n\n\nprivate ref class DXShaderReflection_Impl : public Pyramid::IDXShaderReflection\n{\npublic:\n    DXShaderReflection_Impl( ID3D11ShaderReflection* pRef )\n        : m_pRef(pRef)\n    {\n    }\n\n    ~DXShaderReflection_Impl()\n    {\n        m_pRef->Release();\n    }\n\n    virtual UINT GetThreadsPerGroup()\n    {\n        UINT SizeX, SizeY, SizeZ;\n        m_pRef->GetThreadGroupSize(&SizeX,&SizeY,&SizeZ);\n        return SizeX*SizeY*SizeZ;\n    }\n\n    virtual Pyramid::HLSLShaderType GetShaderType()\n    {\n        D3D11_SHADER_DESC d;\n        m_pRef->GetDesc(&d);\n\n        UINT type = D3D11_SHVER_GET_TYPE(d.Version);\n        switch(type)\n        {\n        case D3D11_SHVER_PIXEL_SHADER:      return Pyramid::HLSLShaderType::PIXEL;\n        case D3D11_SHVER_VERTEX_SHADER:     return Pyramid::HLSLShaderType::VERTEX;\n        case D3D11_SHVER_GEOMETRY_SHADER:   return Pyramid::HLSLShaderType::GEOMETRY;\n        case D3D11_SHVER_HULL_SHADER:       return Pyramid::HLSLShaderType::HULL;\n        case D3D11_SHVER_DOMAIN_SHADER:     return Pyramid::HLSLShaderType::DOMAIN;\n        case D3D11_SHVER_COMPUTE_SHADER:    return Pyramid::HLSLShaderType::COMPUTE;\n        }\n\n        throw gcnew System::Exception(\"Bad DX shader type??\");\n    }\n\n    ID3D11ShaderReflection* m_pRef;\n\n};\n\n#endif"
  },
  {
    "path": "src/Wrapper/DXILCompiler_Impl.cpp",
    "content": "#include \"DXILCompiler_Impl.h\"\n#include \"Utilities.h\"\n\n\n#pragma unmanaged\n#include <vector>\n#include <atlbase.h>\n#include <d3dcompiler.h>\n#include \"dxc/hlsl/DxilContainer.h\"\n#pragma managed\n\n\n\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n\n// Use our own blob class bc we don't have any path for IDxcBlob from raw bytes\n//  without somehow guessing the encoding.  Marcello has punted this problem to us\n//   and we shall punt it back to him.... :)\n#pragma unmanaged\nclass MyBlob : public IDxcBlob\n{\npublic:\n\n    MyBlob( void* p, size_t l ) : m_cRef( 1 ),m_pPtr( p ),m_nSize( l ) {}\n    ~MyBlob()\n    {\n        free( m_pPtr );\n    }\n    ULONG STDMETHODCALLTYPE AddRef()\n    {\n        InterlockedIncrement( &m_cRef );\n        return m_cRef;\n    }\n    ULONG STDMETHODCALLTYPE Release()\n    {\n        // Decrement the object's internal counter.\n        ULONG ulRefCount = InterlockedDecrement( &m_cRef );\n        if ( 0 == m_cRef )\n        {\n            delete this;\n        }\n        return ulRefCount;\n    }\n\n    HRESULT STDMETHODCALLTYPE QueryInterface( REFIID   riid, LPVOID * ppvObj )\n    {\n        // Always set out parameter to NULL, validating it first.\n        if ( !ppvObj )\n            return E_INVALIDARG;\n        *ppvObj = NULL;\n        if ( riid == IID_IUnknown || riid == __uuidof(IDxcBlob) )\n        {\n            // Increment the reference count and return the pointer.\n            *ppvObj = (LPVOID)this;\n            AddRef();\n            return NOERROR;\n        }\n        return E_NOINTERFACE;\n    }\n\n    virtual LPVOID STDMETHODCALLTYPE GetBufferPointer( void ) { return m_pPtr; }\n    virtual SIZE_T STDMETHODCALLTYPE GetBufferSize( void ) { return m_nSize; }\n\n    ULONG m_cRef;\n    void* m_pPtr;\n    size_t m_nSize;\n};\n#pragma managed\n\n\nclass PyramidDxilIncludeHandler : public IDxcIncludeHandler\n{\npublic:\n    PyramidDxilIncludeHandler( Pyramid::IIncludeHandler^ pmInclude, IDxcLibrary* pDXCLibrary )\n        : m_pmInclude( pmInclude ),\n          m_pDXCLibrary( pDXCLibrary ), m_cRef(1)\n    {\n    }\n\n    virtual HRESULT STDMETHODCALLTYPE LoadSource(\n        _In_ LPCWSTR pFilename,                                   // Candidate filename.\n        _COM_Outptr_result_maybenull_ IDxcBlob **ppIncludeSource  // Resultant source object for included file, nullptr if not found.\n    ) override\n    {\n\n        Pyramid::IIncludeHandler^ pmInclude = static_cast<Pyramid::IIncludeHandler^>(m_pmInclude);\n        if ( pmInclude == nullptr )\n            return E_FAIL;\n\n  \n        Pyramid::IIncludeResult^ result = pmInclude->OpenInclude( Pyramid::IncludeType::User,MakeString( pFilename ), nullptr );\n        if ( result == nullptr )\n        {\n            *ppIncludeSource = nullptr;\n            return S_OK;\n        }\n\n        array<unsigned char>^ pFileContents =  result->Contents;\n        void* pNative = malloc( pFileContents->Length );\n\n        Marshal::Copy( pFileContents,0,System::IntPtr( pNative ),pFileContents->Length );\n\n        *ppIncludeSource = new MyBlob( pNative,pFileContents->Length );\n        return S_OK;\n    }\n\n    ULONG STDMETHODCALLTYPE AddRef()\n    {\n        InterlockedIncrement( &m_cRef );\n        return m_cRef;\n    }\n    ULONG STDMETHODCALLTYPE Release()\n    {\n        // Decrement the object's internal counter.\n        ULONG ulRefCount = InterlockedDecrement( &m_cRef );\n        if ( 0 == m_cRef )\n        {\n            delete this;\n        }\n        return ulRefCount;\n    }\n\n    HRESULT STDMETHODCALLTYPE QueryInterface( REFIID   riid,LPVOID * ppvObj )\n    {\n        // Always set out parameter to NULL, validating it first.\n        if ( !ppvObj )\n            return E_INVALIDARG;\n        *ppvObj = NULL;\n        if ( riid == IID_IUnknown || riid == __uuidof(IDxcIncludeHandler) )\n        {\n            // Increment the reference count and return the pointer.\n            *ppvObj = (LPVOID)this;\n            AddRef();\n            return NOERROR;\n        }\n        return E_NOINTERFACE;\n    }\n\nprivate:\n    gcroot<Pyramid::IIncludeHandler^> m_pmInclude;\n    IDxcLibrary* m_pDXCLibrary = nullptr;\n\n    ULONG m_cRef;\n\n};\n\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n///////////////////////////////////////////////////////////////////////////////////////\n\nDXILShaderBlob_Impl::DXILShaderBlob_Impl( IDxcBlob* pBlob,DXILCompiler_Impl^ pCompiler ) : m_pBlob( pBlob ),m_pmCompiler( pCompiler )\n{\n}\nDXILShaderBlob_Impl::~DXILShaderBlob_Impl()\n{\n    if ( m_pBlob )\n        m_pBlob->Release();\n}\n\nSystem::String^ DXILShaderBlob_Impl::Disassemble()\n{\n    if ( m_pBlob )\n    {\n        IDxcBlobEncoding* pAsm=0;\n        HRESULT hr = m_pmCompiler->m_pDXCCompiler->Disassemble( m_pBlob, &pAsm );\n\n        if ( SUCCEEDED( hr ) && pAsm )\n        {\n            IDxcBlobEncoding* pUTF16 = nullptr;\n            hr = m_pmCompiler->m_pDXCLibrary->GetBlobAsUtf16( pAsm, &pUTF16 );\n            if ( SUCCEEDED( hr ) )\n            {\n                System::String^ IR = Marshal::PtrToStringUni( System::IntPtr( pUTF16->GetBufferPointer() ) );\n                IR = IR->Replace( gcnew System::String( \"\\n\" ),System::Environment::NewLine );\n                pAsm->Release();\n                return IR;\n            }\n        }\n    }\n    return gcnew System::String( \"\" );\n}\n\nPyramid::IDXBlob^ DXILShaderBlob_Impl::ExtractRootSignature()\n{\n    CComPtr<IDxcContainerReflection> pReflector;\n    HRESULT hr = m_pmCompiler->m_pfnCreateInstance( CLSID_DxcContainerReflection,__uuidof(IDxcContainerReflection),(void**)&pReflector );\n    if ( pReflector == nullptr || FAILED( hr ) )\n        return nullptr;\n\n    hr = pReflector->Load( m_pBlob );\n    if ( FAILED( hr ) )\n        return nullptr;\n\n    UINT32 partIdx;\n    hr = pReflector->FindFirstPartKind( hlsl::DFCC_RootSignature,&partIdx );\n    if ( FAILED( hr ) )\n        return nullptr;\n\n    IDxcBlob* pBlob;\n    hr = pReflector->GetPartContent( partIdx,&pBlob );\n    if ( FAILED( hr ) )\n        return nullptr;\n\n    return gcnew DXILRootSignatureBlob_Impl( pBlob,m_pmCompiler );\n}\n\narray<byte>^ DXILShaderBlob_Impl::ReadBytes()\n{\n    if ( !m_pBlob )\n        return nullptr;\n\n    size_t size  = m_pBlob->GetBufferSize();\n    byte* pBytes = (byte*)m_pBlob->GetBufferPointer();\n    array<byte>^ pmBytes = gcnew array<byte>( m_pBlob->GetBufferSize() );\n    for ( size_t i=0; i<size; i++ )\n        pmBytes[i] = pBytes[i];\n\n    return pmBytes;\n}\n\n///////////////////////////////////////////////////////////////////////////////////////\n///////////////////////////////////////////////////////////////////////////////////////\nDXILRootSignatureBlob_Impl::DXILRootSignatureBlob_Impl( IDxcBlob* pBlob,DXILCompiler_Impl^ pCompiler ) : m_pBlob( pBlob ),m_pmCompiler( pCompiler )\n{\n}\n\nDXILRootSignatureBlob_Impl::~DXILRootSignatureBlob_Impl()\n{\n    if ( m_pBlob )\n        m_pBlob->Release();\n}\narray<byte>^ DXILRootSignatureBlob_Impl::ReadBytes()\n{\n    if ( !m_pBlob )\n        return nullptr;\n\n    size_t size  = m_pBlob->GetBufferSize();\n    byte* pBytes = (byte*)m_pBlob->GetBufferPointer();\n    array<byte>^ pmBytes = gcnew array<byte>( m_pBlob->GetBufferSize() );\n    for ( size_t i=0; i<size; i++ )\n        pmBytes[i] = pBytes[i];\n\n    return pmBytes;\n}\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n///////////////////////////////////////////////////////////////////////////////////////\n\nDXILCompiler_Impl::DXILCompiler_Impl( System::String^ DLLPath, Pyramid::IIncludeHandler^ pmInclude )\n{\n    m_pDXCCompiler = nullptr;\n    m_pDXCLibrary = nullptr;\n    \n    MarshalledString DLL(DLLPath);\n    \n    HMODULE hDLL = LoadLibraryA( DLL );\n    if( !hDLL )\n        throw gcnew System::Exception(System::String::Format( \"LoadLibrary failed for {0}\", DLLPath ));\n       \n    DxcCreateInstanceProc pfnDxcCreateInstance = DxcCreateInstanceProc( GetProcAddress( hDLL,\"DxcCreateInstance\" ) );\n    if ( !pfnDxcCreateInstance )\n        throw gcnew System::Exception( System::String::Format( \"No entrypoint named DxcCreateInstance in {0}\",DLLPath ) );\n\n    IDxcCompiler* pCompiler = nullptr;\n    IDxcLibrary* pLibrary   = nullptr;\n\n    if ( FAILED( pfnDxcCreateInstance( CLSID_DxcLibrary,__uuidof(IDxcLibrary),(void**)&pLibrary ) ) )\n        throw gcnew System::Exception( System::String::Format( \"DXCLibrary create failed in {0} \",DLLPath ) );\n\n    if ( FAILED( pfnDxcCreateInstance( CLSID_DxcCompiler,__uuidof(IDxcCompiler),(void**)&pCompiler ) ) )\n    {\n        pLibrary->Release();\n        throw gcnew System::Exception( System::String::Format( \"DXCCompiler create failed in {0} \",DLLPath ) );\n    }\n\n    m_pDXCCompiler = pCompiler;\n    m_pDXCLibrary = pLibrary;\n    m_pmInclude    = pmInclude;\n    m_pfnCreateInstance = pfnDxcCreateInstance;\n}\n\n\nDXILCompiler_Impl::~DXILCompiler_Impl()\n{\n    if ( m_pDXCCompiler )\n        m_pDXCCompiler->Release();\n    if ( m_pDXCLibrary )\n        m_pDXCLibrary->Release();\n}\n\n\n#pragma unmanaged\nstatic HRESULT CompileFromBlob( \n    IDxcCompiler* pCompiler,\n    IDxcBlobEncoding *pSource,LPCWSTR pSourceName,\n    const D3D_SHADER_MACRO *pDefines,IDxcIncludeHandler *pInclude,\n    LPWSTR pEntrypointW, LPWSTR pTargetProfileW,UINT Flags1, \n    IDxcBlob **ppCode,\n    IDxcBlobEncoding **ppErrorMsgs )\n{\n    CComPtr<IDxcOperationResult> operationResult;\n    HRESULT hr;\n\n\n    try {\n        std::vector<std::wstring> defineValues;\n        std::vector<DxcDefine> defines;\n\n        std::vector<LPCWSTR> arguments;\n        // /Gec, /Ges Not implemented:\n        //if(Flags1 & D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY) arguments.push_back(L\"/Gec\");\n        //if(Flags1 & D3DCOMPILE_ENABLE_STRICTNESS) arguments.push_back(L\"/Ges\");\n        if ( Flags1 & D3DCOMPILE_IEEE_STRICTNESS ) arguments.push_back( L\"/Gis\" );\n        if ( Flags1 & D3DCOMPILE_OPTIMIZATION_LEVEL2 )\n        {\n            switch ( Flags1 & D3DCOMPILE_OPTIMIZATION_LEVEL2 )\n            {\n            case D3DCOMPILE_OPTIMIZATION_LEVEL0: arguments.push_back( L\"/O0\" ); break;\n            case D3DCOMPILE_OPTIMIZATION_LEVEL2: arguments.push_back( L\"/O2\" ); break;\n            case D3DCOMPILE_OPTIMIZATION_LEVEL3: arguments.push_back( L\"/O3\" ); break;\n            }\n        }\n\n        // Currently, /Od turns off too many optimization passes, causing incorrect DXIL to be generated.\n        // Re-enable once /Od is implemented properly:\n        //if(Flags1 & D3DCOMPILE_SKIP_OPTIMIZATION) arguments.push_back(L\"/Od\");\n        if ( Flags1 & D3DCOMPILE_DEBUG ) arguments.push_back( L\"/Zi\" );\n        if ( Flags1 & D3DCOMPILE_PACK_MATRIX_ROW_MAJOR ) arguments.push_back( L\"/Zpr\" );\n        if ( Flags1 & D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR ) arguments.push_back( L\"/Zpc\" );\n        if ( Flags1 & D3DCOMPILE_AVOID_FLOW_CONTROL ) arguments.push_back( L\"/Gfa\" );\n        if ( Flags1 & D3DCOMPILE_PREFER_FLOW_CONTROL ) arguments.push_back( L\"/Gfp\" );\n\n        // We don't implement this:\n        //if(Flags1 & D3DCOMPILE_PARTIAL_PRECISION) arguments.push_back(L\"/Gpp\");\n        if ( Flags1 & D3DCOMPILE_RESOURCES_MAY_ALIAS ) arguments.push_back( L\"/res_may_alias\" );\n\n        if ( Flags1 & D3DCOMPILE_SKIP_VALIDATION ) arguments.push_back( L\"-Vd\" );\n\n        if ( wcscmp( pTargetProfileW+3,L\"6_2\" ) == 0 )\n        {\n            // if compiling to SM6_2, turn on 16-bit types\n            //  (because Microsoft decided that shader model 2 should be \"extra-optional\")\n            //  also need to disable validation because the validator apparently doesn't know about SM_6_2 yet,\n            //   at least as of when I built it\n            arguments.push_back( L\"/enable-16bit-types\" );\n            arguments.push_back( L\"-Vd\" );\n        }\n        \n        if ( FAILED( pCompiler->Compile( pSource,pSourceName,pEntrypointW,pTargetProfileW,\n            arguments.data(),(UINT)arguments.size(),\n            defines.data(),(UINT)defines.size(),pInclude,\n            &operationResult ) ) )\n        {\n            return E_FAIL;\n        }\n    }\n    catch ( const std::bad_alloc & ) {\n        return E_OUTOFMEMORY;\n    }\n    catch ( const CAtlException &err ) {\n        return err.m_hr;\n    }\n\n    operationResult->GetStatus( &hr );\n    if ( SUCCEEDED( hr ) ) {\n        return operationResult->GetResult( (IDxcBlob **)ppCode );\n    }\n    else {\n        if ( ppErrorMsgs )\n            operationResult->GetErrorBuffer( (IDxcBlobEncoding **)ppErrorMsgs );\n        return hr;\n    }\n}\n#pragma managed\n\nbool DXILCompiler_Impl::Compile( System::String^ Shader,\n    Pyramid::IHLSLOptions^ opts,\n    System::String^ fileName,\n    Pyramid::IDXILShaderBlob^% IR,\n    System::String^% Messages )\n{\n    System::String^ targetString = opts->Target.ToString();\n\n    // DXIL path\n    if ( !m_pDXCLibrary )\n        return false;\n\n    IDxcBlob* pCode = nullptr;\n    IDxcBlobEncoding* pMessages = nullptr;\n\n    DWORD flags = opts->GetD3DCompileFlagBits();\n    MarshalledString hlsl( Shader );\n    MarshalledStringW entry( opts->EntryPoint );\n    MarshalledStringW profile( targetString );\n    MarshalledStringW file( fileName );\n\n    IDxcBlobEncoding* pBlobEncoding = nullptr;\n    HRESULT hr = m_pDXCLibrary->CreateBlobWithEncodingFromPinned( (LPBYTE) hlsl.GetString(), hlsl.Length()+1, CP_UTF8, &pBlobEncoding );\n    if ( !SUCCEEDED( hr ) )\n        return false;\n\n    PyramidDxilIncludeHandler kHandler( m_pmInclude,m_pDXCLibrary );\n    hr = CompileFromBlob( m_pDXCCompiler,\n                            pBlobEncoding,\n                            file.GetString(),\n                            nullptr, &kHandler,\n                            entry.GetString(), profile.GetString(), flags, &pCode,&pMessages );\n\n    pBlobEncoding->Release();\n\n    if ( SUCCEEDED( hr ) )\n        IR = gcnew DXILShaderBlob_Impl( pCode,this );\n\n    Messages = nullptr;\n    if ( pMessages )\n    {\n        IDxcBlobEncoding* pMessagesUni = nullptr;\n        HRESULT hr2 = m_pDXCLibrary->GetBlobAsUtf16( pMessages,&pMessagesUni );\n        if ( SUCCEEDED( hr2 ) )\n        {\n            Messages = Marshal::PtrToStringUni( System::IntPtr( pMessagesUni->GetBufferPointer() ) );\n            Messages = Messages->Replace( gcnew System::String( \"\\n\" ),System::Environment::NewLine );\n            pMessagesUni->Release();\n        }\n        pMessages->Release();\n    }\n\n    return SUCCEEDED( hr );\n}\n\n\nbool DXILCompiler_Impl::CompileRootSignature( System::String^ Shader,\n                                                Pyramid::IHLSLOptions^ opts,\n                                                System::String^ fileName,\n                                                Pyramid::IDXBlob^% IR,\n                                                System::String^% Messages )\n{\n    \n    // DXIL path\n    if ( !m_pDXCLibrary )\n        return false;\n\n    IDxcBlob* pCode = nullptr;\n    IDxcBlobEncoding* pMessages = nullptr;\n\n    DWORD flags = opts->GetD3DCompileFlagBits();\n    MarshalledString hlsl( Shader->Replace( System::Environment::NewLine,\"\\n\" ) );\n    MarshalledStringW entry( opts->RootSigMacro );\n    MarshalledStringW profile( opts->RootSigTarget.ToString() );\n    MarshalledStringW file( fileName );\n\n    IDxcBlobEncoding* pBlobEncoding = nullptr;\n    HRESULT hr = m_pDXCLibrary->CreateBlobWithEncodingFromPinned( (LPBYTE)hlsl.GetString(),hlsl.Length()+1,CP_UTF8,&pBlobEncoding );\n    if ( !SUCCEEDED( hr ) )\n        return false;\n\n    PyramidDxilIncludeHandler kHandler( m_pmInclude,m_pDXCLibrary );\n    hr = CompileFromBlob( m_pDXCCompiler,\n        pBlobEncoding,\n        file.GetString(),\n        nullptr,&kHandler,\n        entry.GetString(),profile.GetString(),flags,&pCode,&pMessages );\n\n    pBlobEncoding->Release();\n\n    if ( SUCCEEDED( hr ) )\n        IR = gcnew DXILRootSignatureBlob_Impl( pCode,this );\n\n    Messages = nullptr;\n    if ( pMessages )\n    {\n        IDxcBlobEncoding* pMessagesUni = nullptr;\n        HRESULT hr2 = m_pDXCLibrary->GetBlobAsUtf16( pMessages,&pMessagesUni );\n        if ( SUCCEEDED( hr2 ) )\n        {\n            Messages = Marshal::PtrToStringUni( System::IntPtr( pMessagesUni->GetBufferPointer() ) );\n            Messages = Messages->Replace( gcnew System::String( \"\\n\" ),System::Environment::NewLine );\n            pMessagesUni->Release();\n        }\n        pMessages->Release();\n    }\n\n    return SUCCEEDED( hr );\n}"
  },
  {
    "path": "src/Wrapper/DXILCompiler_Impl.h",
    "content": "\n#ifndef _DXIL_COMPILER_IMPL_H_\n#define _DXIL_COMPILER_IMPL_H_\n\n#pragma unmanaged\n#include <Windows.h>\n#include \"dxc/dxcapi.h\"\nstruct IDxcLibrary;\nstruct IDxcCompiler;\nstruct IDxcBlob;\n#pragma managed\n\ntypedef unsigned char byte;\n\nref class DXILCompiler_Impl;\n\nprivate ref class DXILRootSignatureBlob_Impl : Pyramid::IDXBlob\n{\npublic:\n    DXILRootSignatureBlob_Impl( IDxcBlob* pBlob,DXILCompiler_Impl^ pCompiler );\n    ~DXILRootSignatureBlob_Impl();\n\n    virtual array<byte>^ ReadBytes();\n\n\nprivate:\n    IDxcBlob* m_pBlob;\n    DXILCompiler_Impl^ m_pmCompiler;\n};\n\nprivate ref class DXILShaderBlob_Impl : Pyramid::IDXILShaderBlob\n{\npublic:\n    DXILShaderBlob_Impl( IDxcBlob* pBlob,DXILCompiler_Impl^ pCompiler );\n    ~DXILShaderBlob_Impl();\n\n    virtual Pyramid::IDXBlob^ ExtractRootSignature();\n    virtual System::String^ Disassemble();\n    virtual array<byte>^ ReadBytes();\n\nprivate:\n    IDxcBlob* m_pBlob;\n    DXILCompiler_Impl^ m_pmCompiler;\n};\n\n\nprivate ref class DXILCompiler_Impl : Pyramid::IDXILCompiler\n{\npublic:\n\n    DXILCompiler_Impl( System::String^ DLLPath,Pyramid::IIncludeHandler^ pmIncludes );\n    ~DXILCompiler_Impl();\n\n    virtual bool CompileRootSignature( System::String^ Shader,\n        Pyramid::IHLSLOptions^ opts,\n        System::String^ Path,\n        Pyramid::IDXBlob^% blob,\n        System::String^% Errors );\n\n    virtual bool Compile( System::String^ Shader,\n        Pyramid::IHLSLOptions^ opts,\n        System::String^ Path,\n        Pyramid::IDXILShaderBlob^% blob,\n        System::String^% Errors );\n\ninternal:\n\n    Pyramid::IIncludeHandler^ m_pmInclude;\n    IDxcLibrary* m_pDXCLibrary = nullptr;\n    IDxcCompiler* m_pDXCCompiler = nullptr;\n    DxcCreateInstanceProc m_pfnCreateInstance = nullptr;\n};\n\n\n\n#endif"
  },
  {
    "path": "src/Wrapper/GCN1Decoder.cpp",
    "content": "//\n//    Helper class responsible for decoding GCN instructions into a standardized form\n//\n//     A decoder abstraction is necessary because AMD decided to change the \n//       microcode formats and opcode numbers for GCN3.   \n//\n//      Copyright 2015 Joshua Barczak, all rights reserved.\n//\n#pragma unmanaged\n#include \"GCNEnums.h\"\n#include \"GCNIsa.h\"\n#include \"GCN1Decoder.h\"\n\n#include <string.h>\n\nnamespace GCN{\nnamespace _GCN1Decoder_INTERNAL\n{\n    struct EnumLUT\n    {\n        uint eEnum;\n        uint  nEncoding;\n    };\n\n    static uint LUTLookup( const EnumLUT* pLUT, size_t nLUTSize,uint en, uint TInvalid )\n    {\n        size_t n = nLUTSize/sizeof(EnumLUT);\n        for( size_t i=0; i<n; i++ ) \n            if( pLUT[i].nEncoding == en ) \n                return pLUT[i].eEnum; \n        return TInvalid;\n    }\n\n#define BEGIN_TRANSLATOR(T,Name) static const EnumLUT LUT_##T_##Name[] = {\n#define ENUM(Enum,Value) { Enum, Value },\n#define END_TRANSLATOR(T,Name,TInvalid) \\\n    };\\\n    T Translate_##Name( uint en ) {\\\n        const EnumLUT* pLUT = LUT_##T_##Name;\\\n        size_t n = sizeof(LUT_##T_##Name);\\\n        return (T) LUTLookup(pLUT,n,en,TInvalid);\\\n    };\n\n\n    BEGIN_TRANSLATOR(ScalarInstructions,SOP2Opcodes)\n        ENUM(S_ADD_U32              ,0 )\n        ENUM(S_SUB_U32              ,1 )\n        ENUM(S_ADD_I32              ,2 )\n        ENUM(S_SUB_I32              ,3 )\n        ENUM(S_ADDC_U32             ,4 )\n        ENUM(S_SUBB_U32             ,5 )\n        ENUM(S_MIN_I32              ,6 )\n        ENUM(S_MIN_U32              ,7 )\n        ENUM(S_MAX_I32              ,8 )\n        ENUM(S_MAX_U32              ,9 )\n        ENUM(S_CSELECT_B32          ,10)\n        ENUM(S_CSELECT_B64          ,11)                        \n        ENUM(S_AND_B32              ,14)\n        ENUM(S_AND_B64              ,15)\n        ENUM(S_OR_B32               ,16)\n        ENUM(S_OR_B64               ,17)\n        ENUM(S_XOR_B32              ,18)\n        ENUM(S_XOR_B64              ,19)\n        ENUM(S_ANDN2_B32            ,20)\n        ENUM(S_ANDN2_B64            ,21)\n        ENUM(S_ORN2_B32             ,22)\n        ENUM(S_ORN2_B64             ,23)\n        ENUM(S_NAND_B32             ,24)\n        ENUM(S_NAND_B64             ,25)\n        ENUM(S_NOR_B32              ,26)\n        ENUM(S_NOR_B64              ,27)\n        ENUM(S_XNOR_B32             ,28)\n        ENUM(S_XNOR_B64             ,29)\n        ENUM(S_LSHL_B32             ,30)\n        ENUM(S_LSHL_B64             ,31)\n        ENUM(S_LSHR_B32             ,32)\n        ENUM(S_LSHR_B64             ,33)\n        ENUM(S_ASHR_I32             ,34)\n        ENUM(S_ASHR_I64             ,35)\n        ENUM(S_BFM_B32              ,36)\n        ENUM(S_BFM_B64              ,37)\n        ENUM(S_MUL_I32              ,38)\n        ENUM(S_BFE_U32              ,39)\n        ENUM(S_BFE_I32              ,40)\n        ENUM(S_BFE_U64              ,41)\n        ENUM(S_BFE_I64              ,42)\n        ENUM(S_CBRANCH_G_FORK       ,43)\n        ENUM(S_ABSDIFF_I32          ,44)\n    END_TRANSLATOR(ScalarInstructions,SOP2Opcodes,S_INVALID);\n\n\n    BEGIN_TRANSLATOR(ScalarInstructions,SOPKOpcodes)\n        ENUM( S_MOVK_I32              ,0 )\n        ENUM( S_CMOVK_I32             ,2 )\n        ENUM( S_CMPK_EQ_I32           ,3 )\n        ENUM( S_CMPK_LG_I32           ,4 )\n        ENUM( S_CMPK_GT_I32           ,5 )\n        ENUM( S_CMPK_GE_I32           ,6 )\n        ENUM( S_CMPK_LT_I32           ,7 )\n        ENUM( S_CMPK_LE_I32           ,8 )\n        ENUM( S_CMPK_EQ_U32           ,9 )\n        ENUM( S_CMPK_LG_U32           ,10)\n        ENUM( S_CMPK_GT_U32           ,11)\n        ENUM( S_CMPK_GE_U32           ,12)\n        ENUM( S_CMPK_LT_U32           ,13)\n        ENUM( S_CMPK_LE_U32           ,14)\n        ENUM( S_ADDK_I32              ,15)\n        ENUM( S_MULK_I32              ,16)\n        ENUM( S_CBRANCH_I_FORK        ,17)\n        ENUM( S_GETREG_B32            ,18) \n        ENUM( S_SETREG_B32            ,19) \n        ENUM( S_SETREG_IMM32_B32      ,21)\n    END_TRANSLATOR(ScalarInstructions,SOPKOpcodes,S_INVALID);\n\n    BEGIN_TRANSLATOR(ScalarInstructions,SOP1Opcodes)\n        ENUM(S_MOV_B32             ,   3 ) //: D.u = S0.u.\n        ENUM(S_MOV_B64             ,   4 ) //: D/u = S0.u.\n        ENUM(S_CMOV_B32            ,   5 ) //: if(SCC) D.u = S0.u; else NOP.\n        ENUM(S_CMOV_B64            ,   6 ) //: if(SCC) D.u = S0.u; else NOP.\n        ENUM(S_NOT_B32             ,   7 ) //: D.u = ~S0.u SCC = 1 if result non-zero.\n        ENUM(S_NOT_B64             ,   8 ) //: D.u = ~S0.u SCC = 1 if result non-zero.\n        ENUM(S_WQM_B32             ,   9 ) //: D.u = WholeQuadMode(S0.u). SCC = 1 if result is non-zero.\n        ENUM(S_WQM_B64             ,   10) //: D.u = WholeQuadMode(S0.u). SCC = 1 if result is non-zero.\n        ENUM(S_BREV_B32            ,   11) //: D.u = S0.u[0:31] (reverse bits).\n        ENUM(S_BREV_B64            ,   12) //: D.u = S0.u[0:63] (reverse bits).\n        ENUM(S_BCNT0_I32_B32       ,   13) //: D.i = CountZeroBits(S0.u). SCC = 1 if result is non-zero.\n        ENUM(S_BCNT0_I32_B64       ,   14) //: D.i = CountZeroBits(S0.u). SCC = 1 if result is non-zero.\n        ENUM(S_BCNT1_I32_B32       ,   15) //: D.i = CountOneBits(S0.u). SCC = 1 if result is non-zero.\n        ENUM(S_BCNT1_I32_B64       ,   16) //: D.i = CountOneBits(S0.u). SCC = 1 if result is non-zero.\n        ENUM(S_FF0_I32_B32         ,   17) //: D.i = FindFirstZero(S0.u) from LSB; if no zeros, return -1.\n        ENUM(S_FF0_I32_B64         ,   18) //: D.i = FindFirstZero(S0.u) from LSB; if no zeros, return -1.\n        ENUM(S_FF1_I32_B32         ,   19) //: D.i = FindFirstOne(S0.u) from LSB; if no ones, return -1.\n        ENUM(S_FF1_I32_B64         ,   20) //: D.i = FindFirstOne(S0.u) from LSB; if no ones, return -1.\n        ENUM(S_FLBIT_I32_B32       ,   21) //: D.i = FindFirstOne(S0.u) from MSB; if no ones, return -1.\n        ENUM(S_FLBIT_I32_B64       ,   22) //: D.i = FindFirstOne(S0.u) from MSB; if no ones, return -1.\n        ENUM(S_FLBIT_I32           ,   23) //: D.i = Find first bit opposite of sign bit from MSB. If S0 == -1, return -1.\n        ENUM(S_FLBIT_I32_I64       ,   24) //: D.i = Find first bit opposite of sign bit from MSB. If S0 == -1, return -1.\n        ENUM(S_SEXT_I32_I8         ,   25) //: D.i = signext(S0.i[7:0]).\n        ENUM(S_SEXT_I32_I16        ,   26) //: D.i = signext(S0.i[15:0]).\n        ENUM(S_BITSET0_B32         ,   27) //: D.u[S0.u[4:0]] = 0.\n        ENUM(S_BITSET0_B64         ,   28) //: D.u[S0.u[5:0]] = 0.\n        ENUM(S_BITSET1_B32         ,   29) //: D.u[S0.u[4:0]] = 1.\n        ENUM(S_BITSET1_B64         ,   30) //: D.u[S0.u[5:0]] = 1.\n        ENUM(S_GETPC_B64           ,   31) //: D.u = PC + 4; destination receives the byte address of the next instruction.\n        ENUM(S_SETPC_B64           ,   32) //: PC = S0.u; S0.u is a byte address of the instruction to jump to.\n        ENUM(S_SWAPPC_B64          ,   33) //: D.u = PC + 4; PC = S0.u.\n        ENUM(S_RFE_B64             ,   34) //: Return from Exception; PC = TTMP1,0.\n        ENUM(S_AND_SAVEEXEC_B64    ,   36) //: D.u = EXEC, EXEC = S0.u & EXEC. SCC = 1 if the new value of EXEC is non-zero.\n        ENUM(S_OR_SAVEEXEC_B64     ,   37) //: D.u = EXEC, EXEC = S0.u | EXEC. SCC = 1 if the newvalue of EXEC is non-zero.\n        ENUM(S_XOR_SAVEEXEC_B64    ,   38) //: D.u = EXEC, EXEC = S0.u ^ EXEC. SCC = 1 if the new value of EXEC is non-zero.\n        ENUM(S_ANDN2_SAVEEXEC_B64  ,   39) //: D.u = EXEC, EXEC = S0.u & ~EXEC. SCC =1 if the new value of EXEC is non-zero.\n        ENUM(S_ORN2_SAVEEXEC_B64   ,   40) //: D.u = EXEC, EXEC = S0.u | ~EXEC. SCC = 1 if the new value of EXEC is non-zero.\n        ENUM(S_NAND_SAVEEXEC_B64   ,   41) //: D.u = EXEC, EXEC = ~(S0.u & EXEC). SCC =1 if the new value of EXEC is non-zero.\n        ENUM(S_NOR_SAVEEXEC_B64    ,   42)//: D.u = EXEC, EXEC = ~(S0.u | EXEC). SCC = 1 if the new value of EXEC is non-zero.\n        ENUM(S_XNOR_SAVEEXEC_B64   ,   43)//: D.u = EXEC, EXEC = ~(S0.u ^ EXEC). SCC = 1 if the new value of EXEC is non-zero.\n        ENUM(S_QUADMASK_B32        ,   44)//: D.u = QuadMask(S0.u). D[0] = OR(S0[3:0]), D[1] = OR(S0[7:4]) .... SCC = 1 if result is non-zero.\n        ENUM(S_QUADMASK_B64        ,   45)//: D.u = QuadMask(S0.u). D[0] = OR(S0[3:0]),D[1] = OR(S0[7:4]) .... SCC = 1 if result is non-zero\n        ENUM(S_MOVRELS_B32         ,   46)//: SGPR[D.u] = SGPR[S0.u + M0.u].\n        ENUM(S_MOVRELS_B64         ,   47)//: SGPR[D.u] = SGPR[S0.u + M0.u].\n        ENUM(S_MOVRELD_B32         ,   48)//: SGPR[D.u + M0.u] = SGPR[S0.u].\n        ENUM(S_MOVRELD_B64         ,   49)//: SGPR[D.u + M0.u] = SGPR[S0.u].\n        ENUM(S_CBRANCH_JOIN        ,   50)//: Conditional branch join point. Arg0 = saved CSP value. No dest.\n        ENUM(S_ABS_I32             ,   52)      //: D.i = abs(S0.i). SCC=1 if result is non-zero.\n        ENUM(S_MOV_FED_B32         ,   53)      //: D.u = S0.u, introduce edc double error upon write to dest sgpr.\n    END_TRANSLATOR(ScalarInstructions,SOP1Opcodes,S_INVALID)\n\n\n    BEGIN_TRANSLATOR(ScalarInstructions,SOPCOpcodes)\n        ENUM( S_CMP_EQ_I32     ,0 )   //: SCC = (S0.i == S1.i).\n        ENUM( S_CMP_LG_I32     ,1 )   //: SCC = (S0.i != S1.i).\n        ENUM( S_CMP_GT_I32     ,2 )   //: SCC = (S0.i > S1.i).\n        ENUM( S_CMP_GE_I32     ,3 )   //: SCC = (S0.i >= S1.i).\n        ENUM( S_CMP_LT_I32     ,4 )   //: SCC = (S0.i < S1.i).\n        ENUM( S_CMP_LE_I32     ,5 )   //: SCC = (S0.i <= S1.i).\n        ENUM( S_CMP_EQ_U32     ,6 )   //: SCC = (S0.u == S1.u).\n        ENUM( S_CMP_LG_U32     ,7 )   //: SCC = (S0.u != S1.u).\n        ENUM( S_CMP_GT_U32     ,8 )   //: SCC = (S0.u > S1.u).\n        ENUM( S_CMP_GE_U32     ,9 )   //: SCC = (S0.u >= S1.u).\n        ENUM( S_CMP_LT_U32     ,10)   //: SCC = (S0.u < S1.u).\n        ENUM( S_CMP_LE_U32     ,11)   //: SCC = (S0.u <= S1.u).\n        ENUM( S_BITCMP0_B32    ,12)   //: SCC = (S0.u[S1.u[4:0]] == 0).\n        ENUM( S_BITCMP1_B32    ,13)   //: SCC = (S0.u[S1.u[4:0]] == 1).\n        ENUM( S_BITCMP0_B64    ,14)   //: SCC = (S0.u[S1.u[5:0]] == 0).\n        ENUM( S_BITCMP1_B64    ,15)   //: SCC = (S0.u[S1.u[5:0]] == 1).\n        ENUM( S_SETVSKIP       ,16)   //: VSKIP = S0.u[S1.u[4:0]].\n    END_TRANSLATOR(ScalarInstructions,SOPCOpcodes,S_INVALID)\n\n\n    BEGIN_TRANSLATOR(ScalarInstructions,SOPPOpcodes)\n        ENUM(S_NOP                      ,0  )  //: do nothing. Repeat NOP 1..8 times based on SIMM16[2:0]. 0 = 1 time, 7 = 8 times.\n        ENUM(S_ENDPGM                   ,1  )  //: end of program; terminate wavefront.\n        ENUM(S_BRANCH                   ,2  )  //: PC = PC + signext(SIMM16 * 4) + 4.\n        ENUM(S_CBRANCH_SCC0             ,4  )  //: if(SCC == 0) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n        ENUM(S_CBRANCH_SCC1             ,5  )  //: if(SCC == 1) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n        ENUM(S_CBRANCH_VCCZ             ,6  )  //: if(VCC == 0) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n        ENUM(S_CBRANCH_VCCNZ            ,7  )  //: if(VCC != 0) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n        ENUM(S_CBRANCH_EXECZ            ,8  )  //: if(EXEC == 0) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n        ENUM(S_CBRANCH_EXECNZ           ,9  )  //: if(EXEC != 0) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n        ENUM(S_BARRIER                  ,10 )  //: Sync waves within a thread group.\n        ENUM(S_WAITCNT                  ,12 )  //: Wait for count of outstanding lds, vector-memory and\n        ENUM(S_SETHALT                  ,13 )  //: set HALT bit to value of SIMM16[0]. 1=halt, 0=resume. Halt is ignored while priv=1.\n        ENUM(S_SLEEP                    ,14 )  //: Cause a wave to sleep for approximately 64*SIMM16[2:0] clocks.\n        ENUM(S_SETPRIO                  ,15 )  //: User settable wave priority. 0 = lowest, 3 = highest.\n        ENUM(S_SENDMSG                  ,16 )  //: Send a message.\n        ENUM(S_SENDMSGHALT              ,17 )  //: Send a message and then HALT.\n        ENUM(S_TRAP                     ,18 )  //: Enter the trap handler. TrapID = SIMM16[7:0]. Wait for all instructions to complete, \n        ENUM(S_ICACHE_INV               ,19 )  //: Invalidate entire L1 I cache.\n        ENUM(S_INCPERFLEVEL             ,20 )  //: Increment performance counter specified in SIMM16[3:0] by 1.\n        ENUM(S_DECPERFLEVEL             ,21 )  //: Decrement performance counter specified in SIMM16[3:0] by 1.\n        ENUM(S_TTRACEDATA               ,22 )  //: Send M0 as user data to thread-trace.\n        ENUM(S_CBRANCH_CDBGSYS          ,23 )// : If (conditional_debug_system != 0) then PC = PC + signext(SIMM16 * 4) + 4; else NOP.\n        ENUM(S_CBRANCH_CDBGUSER         ,24 )// : If (conditional_debug_user != 0) then PC = PC + signext(SIMM16 * 4) + 4; else NOP.\n        ENUM(S_CBRANCH_CDBGSYS_OR_USER  ,25 )// : If (conditional_debug_system || conditional_debug_user) then PC = PC + signext(SIMM16 * 4) + 4; else NOP.\n        ENUM(S_CBRANCH_CDBGSYS_AND_USER ,26 )// : If (conditional_debug_system && conditional_debug_user) then PC = PC + signext(SIMM16 * 4) + 4; else NOP.\n    END_TRANSLATOR(ScalarInstructions,SOPPOpcodes,S_INVALID)\n\n    BEGIN_TRANSLATOR(ScalarMemoryInstructions,SMRDOpcodes)\n        ENUM(S_LOAD_DWORD               ,0 ) // : Read from read-only constant memory.\n        ENUM(S_LOAD_DWORDX2             ,1 ) // : Read from read-only constant memory.\n        ENUM(S_LOAD_DWORDX4             ,2 ) // : Read from read-only constant memory.\n        ENUM(S_LOAD_DWORDX8             ,3 ) // : Read from read-only constant memory.\n        ENUM(S_LOAD_DWORDX16            ,4 ) // : Read from read-only constant memory.\n        ENUM(S_BUFFER_LOAD_DWORD        ,8 ) // : Read from read-only constant memory.\n        ENUM(S_BUFFER_LOAD_DWORDX2      ,9 ) // : Read from read-only constant memory.\n        ENUM(S_BUFFER_LOAD_DWORDX4      ,10) // : Read from read-only constant memory.\n        ENUM(S_BUFFER_LOAD_DWORDX8      ,11) // : Read from read-only constant memory.\n        ENUM(S_BUFFER_LOAD_DWORDX16     ,12) // : Read from read-only constant memory.\n        ENUM(S_DCACHE_INV_VOL           ,29) // : Invalidate all volatile lines in L1 constant cache.\n        ENUM(S_MEMTIME                  ,30) // : Return current 64-bit timestamp.\n        ENUM(S_DCACHE_INV               ,31) // : Invalidate entire L1 K cache.\n    END_TRANSLATOR(ScalarMemoryInstructions,SMRDOpcodes,S_INVALID)\n\n\n    BEGIN_TRANSLATOR(VectorInstructions,VOP2Opcodes)\n        ENUM(V_CNDMASK_B32              , 0 )\n        ENUM(V_READLANE_B32             , 1 )\n        ENUM(V_WRITELANE_B32            , 2 )\n        ENUM(V_ADD_F32                  , 3 )\n        ENUM(V_SUB_F32                  , 4 )\n        ENUM(V_SUBREV_F32               , 5 )\n        ENUM(V_MAC_LEGACY_F32           , 6 )\n        ENUM(V_MUL_LEGACY_F32           , 7 )\n        ENUM(V_MUL_F32                  , 8 )\n        ENUM(V_MUL_I32_I24              , 9 )\n        ENUM(V_MUL_HI_I32_I24           , 10)\n        ENUM(V_MUL_U32_U24              , 11)\n        ENUM(V_MUL_HI_U32_U24           , 12)\n        ENUM(V_MIN_LEGACY_F32           , 13)\n        ENUM(V_MAX_LEGACY_F32           , 14)\n        ENUM(V_MIN_F32                  , 15)\n        ENUM(V_MAX_F32                  , 16)\n        ENUM(V_MIN_I32                  , 17)\n        ENUM(V_MAX_I32                  , 18)\n        ENUM(V_MIN_U32                  , 19)\n        ENUM(V_MAX_U32                  , 20)\n        ENUM(V_LSHR_B32                 , 21)\n        ENUM(V_LSHRREV_B32              , 22)\n        ENUM(V_ASHR_I32                 , 23)\n        ENUM(V_ASHRREV_I32              , 24)\n        ENUM(V_LSHL_B32                 , 25)\n        ENUM(V_LSHLREV_B32              , 26)\n        ENUM(V_AND_B32                  , 27)\n        ENUM(V_OR_B32                   , 28)\n        ENUM(V_XOR_B32                  , 29)\n        ENUM(V_BFM_B32                  , 30)\n        ENUM(V_MAC_F32                  , 31)\n        ENUM(V_MADMK_F32                , 32)\n        ENUM(V_MADAK_F32                , 33)\n        ENUM(V_BCNT_U32_B32             , 34)\n        ENUM(V_MBCNT_LO_U32_B32         , 35)\n        ENUM(V_MBCNT_HI_U32_B32         , 36)                          \n        ENUM(V_ADD_I32                  , 37)\n        ENUM(V_SUB_I32                  , 38)\n        ENUM(V_SUBREV_I32               , 39)\n        ENUM(V_ADDC_U32                 , 40)\n        ENUM(V_SUBB_U32                 , 41)\n        ENUM(V_SUBBREV_U32              , 42)\n        ENUM(V_LDEXP_F32                , 43)\n        ENUM(V_CVT_PKACCUM_U8_F32       , 44)\n        ENUM(V_CVT_PKNORM_I16_F32       , 45)\n        ENUM(V_CVT_PKNORM_U16_F32       , 46)\n        ENUM(V_CVT_PKRTZ_F16_F32        , 47)\n        ENUM(V_CVT_PK_U16_U32           , 48)\n        ENUM(V_CVT_PK_I16_I32           , 49)\n    END_TRANSLATOR(VectorInstructions,VOP2Opcodes,V_INVALID)\n\n\n    BEGIN_TRANSLATOR(VectorInstructions,VOP1Opcodes)\n        ENUM(V_NOP                      , 0  )\n        ENUM(V_MOV_B32                  , 1  )\n        ENUM(V_READFIRSTLANE_B32        , 2  )\n        ENUM(V_CVT_I32_F64              , 3  )\n        ENUM(V_CVT_F64_I32              , 4  )\n        ENUM(V_CVT_F32_I32              , 5  )\n        ENUM(V_CVT_F32_U32              , 6  )\n        ENUM(V_CVT_U32_F32              , 7  )\n        ENUM(V_CVT_I32_F32              , 8  )\n        ENUM(V_MOV_FED_B32              , 9  )\n        ENUM(V_CVT_F16_F32              , 10 )\n        ENUM(V_CVT_F32_F16              , 11 )\n        ENUM(V_CVT_RPI_I32_F32          , 12 )\n        ENUM(V_CVT_FLR_I32_F32          , 13 )\n        ENUM(V_CVT_OFF_F32_I4           , 14 )\n        ENUM(V_CVT_F32_F64              , 15 )\n        ENUM(V_CVT_F64_F32              , 16 )\n        ENUM(V_CVT_F32_UBYTE0           , 17 )\n        ENUM(V_CVT_F32_UBYTE1           , 18 )\n        ENUM(V_CVT_F32_UBYTE2           , 19 )\n        ENUM(V_CVT_F32_UBYTE3           , 20 )\n        ENUM(V_CVT_U32_F64              , 21 )\n        ENUM(V_CVT_F64_U32              , 22 )\n        ENUM(V_TRUNC_F64                , 23 )\n        ENUM(V_CEIL_F64                 , 24 )\n        ENUM(V_RNDNE_F64                , 25 )\n        ENUM(V_FLOOR_F64                , 26 )\n        ENUM(V_FRACT_F32                , 32 )\n        ENUM(V_TRUNC_F32                , 33 )\n        ENUM(V_CEIL_F32                 , 34 )\n        ENUM(V_RNDNE_F32                , 35 )\n        ENUM(V_FLOOR_F32                , 36 )\n        ENUM(V_EXP_F32                  , 37 )\n        ENUM(V_LOG_CLAMP_F32            , 38 )\n        ENUM(V_LOG_F32                  , 39 )\n        ENUM(V_RCP_CLAMP_F32            , 40 )\n        ENUM(V_RCP_LEGACY_F32           , 41 )\n        ENUM(V_RCP_F32                  , 42 )\n        ENUM(V_RCP_IFLAG_F32            , 43 )\n        ENUM(V_RSQ_CLAMP_F32            , 44 )\n        ENUM(V_RSQ_LEGACY_F32           , 45 )\n        ENUM(V_RSQ_F32                  , 46 )\n        ENUM(V_RCP_F64                  , 47 )\n        ENUM(V_RCP_CLAMP_F64            , 48 )\n        ENUM(V_RSQ_F64                  , 49 )\n        ENUM(V_RSQ_CLAMP_F64            , 50 )\n        ENUM(V_SQRT_F32                 , 51 )\n        ENUM(V_SQRT_F64                 , 52 )\n        ENUM(V_SIN_F32                  , 53 )\n        ENUM(V_COS_F32                  , 54 )\n        ENUM(V_NOT_B32                  , 55 )\n        ENUM(V_BFREV_B32                , 56 )\n        ENUM(V_FFBH_U32                 , 57 )\n        ENUM(V_FFBL_B32                 , 58 )\n        ENUM(V_FFBH_I32                 , 59 )\n        ENUM(V_FREXP_EXP_I32_F64        , 60 )\n        ENUM(V_FREXP_MANT_F64           , 61 )\n        ENUM(V_FRACT_F64                , 62 )\n        ENUM(V_FREXP_EXP_I32_F32        , 63 )                                      \n        ENUM(V_FREXP_MANT_F32           , 64 )                        \n        ENUM(V_CLREXCP                  , 65 )\n        ENUM(V_MOVRELD_B32              , 66 )\n        ENUM(V_MOVRELS_B32              , 67 )\n        ENUM(V_MOVRELSD_B32             , 68 )\n        ENUM(V_LOG_LEGACY_F32           , 69 )\n        ENUM(V_EXP_LEGACY_F32           , 70 )\n    END_TRANSLATOR(VectorInstructions,VOP1Opcodes,V_INVALID)\n\n\n    static VectorInstructions Translate_VOPCOpcodes( uint n )\n    {\n        switch( n & 0xf0)\n        {\n        case 0x00:  return (VectorInstructions)(V_CMP_F_F32   + (n&0xf));\n        case 0x10:  return (VectorInstructions)(V_CMPX_F_F32  + (n&0xf));\n        case 0x20:  return (VectorInstructions)(V_CMP_F_F64   + (n&0xf));\n        case 0x30:  return (VectorInstructions)(V_CMPX_F_F64  + (n&0xf));\n        case 0x40:  return (VectorInstructions)(V_CMPS_F_F32  + (n&0xf));\n        case 0x50:  return (VectorInstructions)(V_CMPSX_F_F32 + (n&0xf));\n        case 0x60:  return (VectorInstructions)(V_CMPS_F_F64  + (n&0xf));\n        case 0x70:  return (VectorInstructions)(V_CMPSX_F_F64 + (n&0xf));\n        default:\n            switch( n & 0xf8 )\n            {\n            case 0x80: return (VectorInstructions)(V_CMP_F_I32   + (n&0xf));\n            case 0x90: return (VectorInstructions)(V_CMPX_F_I32  + (n&0xf));\n            case 0xA0: return (VectorInstructions)(V_CMP_F_I64   + (n&0xf));\n            case 0xB0: return (VectorInstructions)(V_CMPX_F_I64  + (n&0xf));\n            case 0xC0: return (VectorInstructions)(V_CMP_F_U32   + (n&0xf));\n            case 0xD0: return (VectorInstructions)(V_CMPX_F_U32  + (n&0xf));\n            case 0xE0: return (VectorInstructions)(V_CMP_F_U64   + (n&0xf));\n            case 0xF0: return (VectorInstructions)(V_CMPx_F_U64  + (n&0xf));\n            case 0x88: return V_CMP_CLASS_F32;\n            case 0x98: return V_CMPX_CLASS_F32;\n            case 0xA8: return V_CMP_CLASS_F64;\n            case 0xB8: return V_CMPX_CLASS_F64;\n            }\n        }\n        return V_INVALID;\n    }\n\n\n    BEGIN_TRANSLATOR(VectorInstructions,VOP3OpcodesExtra)\n         ENUM(V_CNDMASK_B32          ,256)\n         ENUM(V_READLANE_B32         ,257)                                    \n         ENUM(V_WRITELANE_B32        ,258)                                    \n         ENUM(V_ADD_F32              ,259)\n         ENUM(V_SUB_F32              ,260)\n         ENUM(V_SUBREV_F32           ,261)\n         ENUM(V_MAC_LEGACY_F32       ,262)\n         ENUM(V_MUL_LEGACY_F32       ,263)\n         ENUM(V_MUL_F32              ,264)\n         ENUM(V_MUL_I32_I24          ,265)\n         ENUM(V_MUL_HI_I32_I24       ,266)\n         ENUM(V_MUL_U32_U24          ,267)\n         ENUM(V_MUL_HI_U32_U24       ,268)\n         ENUM(V_MIN_LEGACY_F32       ,269)\n         ENUM(V_MAX_LEGACY_F32       ,270)\n         ENUM(V_MIN_F32              ,271)\n         ENUM(V_MAX_F32              ,272)\n         ENUM(V_MIN_I32              ,273)\n         ENUM(V_MAX_I32              ,274)\n         ENUM(V_MIN_U32              ,275)\n         ENUM(V_MAX_U32              ,276)\n         ENUM(V_LSHR_B32             ,277)\n         ENUM(V_LSHRREV_B32          ,278)\n         ENUM(V_ASHR_I32             ,279)\n         ENUM(V_ASHRREV_I32          ,280)\n         ENUM(V_LSHL_B32             ,281)\n         ENUM(V_LSHLREV_B32          ,282)\n         ENUM(V_AND_B32              ,283)\n         ENUM(V_OR_B32               ,284)\n         ENUM(V_XOR_B32              ,285)\n         ENUM(V_BFM_B32              ,286)\n         ENUM(V_MAC_F32              ,287)\n         ENUM(V_MADMK_F32            ,288)\n         ENUM(V_MADAK_F32            ,289)\n         ENUM(V_BCNT_U32_B32         ,290)\n         ENUM(V_MBCNT_LO_U32_B32     ,291)\n         ENUM(V_MBCNT_HI_U32_B32     ,292)\n         ENUM(V_ADD_I32              ,293)\n         ENUM(V_SUB_I32              ,294)\n         ENUM(V_SUBREV_I32           ,295)\n         ENUM(V_ADDC_U32             ,296)\n         ENUM(V_SUBB_U32             ,297)\n         ENUM(V_SUBBREV_U32          ,298)\n         ENUM(V_DIV_SCALE_F32        ,365)\n         ENUM(V_DIV_SCALE_F64        ,366)\n         ENUM(V_LDEXP_F32            ,299)\n         ENUM(V_CVT_PKACCUM_U8_F32   ,300)\n         ENUM(V_CVT_PKNORM_I16_F32   ,301)\n         ENUM(V_CVT_PKNORM_U16_F32   ,302)\n         ENUM(V_CVT_PKRTZ_F16_F32    ,303)\n         ENUM(V_CVT_PK_U16_U32       ,304)\n         ENUM(V_CVT_PK_I16_I32       ,305)\n         ENUM(V_MAD_LEGACY_F32       ,320)  \n         ENUM(V_MAD_F32              ,321)  \n         ENUM(V_MAD_I32_I24          ,322)  \n         ENUM(V_MAD_U32_U24          ,323)  \n         ENUM(V_CUBEID_F32           ,324)  \n         ENUM(V_CUBESC_F32           ,325)  \n         ENUM(V_CUBETC_F32           ,326)  \n         ENUM(V_CUBEMA_F32           ,327)  \n         ENUM(V_BFE_U32              ,328)  \n         ENUM(V_BFE_I32              ,329)  \n         ENUM(V_BFI_B32              ,330)  \n         ENUM(V_FMA_F32              ,331)  \n         ENUM(V_FMA_F64              ,332)  \n         ENUM(V_LERP_U8              ,333)  \n         ENUM(V_ALIGNBIT_B32         ,334)  \n         ENUM(V_ALIGNBYTE_B32        ,335)  \n         ENUM(V_MULLIT_F32           ,336)  \n         ENUM(V_MIN3_F32             ,337)  \n         ENUM(V_MIN3_I32             ,338)  \n         ENUM(V_MIN3_U32             ,339)  \n         ENUM(V_MAX3_F32             ,340)  \n         ENUM(V_MAX3_I32             ,341)  \n         ENUM(V_MAX3_U32             ,342)  \n         ENUM(V_MED3_F32             ,343)  \n         ENUM(V_MED3_I32             ,344)  \n         ENUM(V_MED3_U32             ,345)  \n         ENUM(V_SAD_U8               ,346)  \n         ENUM(V_SAD_HI_U8            ,347)  \n         ENUM(V_SAD_U16              ,348)  \n         ENUM(V_SAD_U32              ,349)  \n         ENUM(V_CVT_PK_U8_F32        ,350) \n         ENUM(V_DIV_FIXUP_F32        ,351) \n         ENUM(V_DIV_FIXUP_F64        ,352) \n         ENUM(V_LSHL_B64             ,353) \n         ENUM(V_LSHR_B64             ,354) \n         ENUM(V_ASHR_I64             ,355) \n         ENUM(V_ADD_F64              ,356) \n         ENUM(V_MUL_F64              ,357) \n         ENUM(V_MIN_F64              ,358) \n         ENUM(V_MAX_F64              ,359) \n         ENUM(V_LDEXP_F64            ,360) \n         ENUM(V_MUL_LO_U32           ,361) \n         ENUM(V_MUL_HI_U32           ,362) \n         ENUM(V_MUL_LO_I32           ,363) \n         ENUM(V_MUL_HI_I32           ,364) \n         ENUM(V_DIV_FMAS_F32         ,367) \n         ENUM(V_DIV_FMAS_F64         ,368) \n         ENUM(V_MSAD_U8              ,369) \n         ENUM(V_QSAD_U8              ,370) \n         ENUM(V_MQSAD_U8             ,371) \n         ENUM(V_QSAD_PK_U16_U8       ,370) \n         ENUM(V_MQSAD_PK_U16_U8      ,371) \n         ENUM(V_TRIG_PREOP_F64       ,372)\n         ENUM(V_MQSAD_U32_U8         ,373)  \n         ENUM(V_MAD_U64_U32          ,374)  \n         ENUM(V_MAD_I64_I32          ,375)  \n         ENUM(V_NOP                  ,384)\n         ENUM(V_MOV_B32              ,385)\n         ENUM(V_READFIRSTLANE_B32    ,386)\n         ENUM(V_CVT_I32_F64          ,387)\n         ENUM(V_CVT_F64_I32          ,388)\n         ENUM(V_CVT_F32_I32          ,389)\n         ENUM(V_CVT_F32_U32          ,390)\n         ENUM(V_CVT_U32_F32          ,391)\n         ENUM(V_CVT_I32_F32          ,392)\n         ENUM(V_MOV_FED_B32          ,393)\n         ENUM(V_CVT_F16_F32          ,394)\n         ENUM(V_CVT_F32_F16          ,395)\n         ENUM(V_CVT_RPI_I32_F32      ,396)\n         ENUM(V_CVT_FLR_I32_F32      ,397)\n         ENUM(V_CVT_OFF_F32_I4       ,398)\n         ENUM(V_CVT_F32_F64          ,399)\n         ENUM(V_CVT_F64_F32          ,400)\n         ENUM(V_CVT_F32_UBYTE0       ,401)\n         ENUM(V_CVT_F32_UBYTE1       ,402)\n         ENUM(V_CVT_F32_UBYTE2       ,403)\n         ENUM(V_CVT_F32_UBYTE3       ,404)\n         ENUM(V_CVT_U32_F64          ,405)\n         ENUM(V_CVT_F64_U32          ,406)\n         ENUM(V_FRACT_F32            ,416)\n         ENUM(V_TRUNC_F32            ,417)\n         ENUM(V_CEIL_F32             ,418)\n         ENUM(V_RNDNE_F32            ,419)\n         ENUM(V_FLOOR_F32            ,420)\n         ENUM(V_EXP_F32              ,421)\n         ENUM(V_LOG_CLAMP_F32        ,422)\n         ENUM(V_LOG_F32              ,423)\n         ENUM(V_RCP_CLAMP_F32        ,424)\n         ENUM(V_RCP_LEGACY_F32       ,425)\n         ENUM(V_RCP_F32              ,426)\n         ENUM(V_RCP_IFLAG_F32        ,427)\n         ENUM(V_RSQ_CLAMP_F32        ,428)\n         ENUM(V_RSQ_LEGACY_F32       ,429)\n         ENUM(V_RSQ_F32              ,430)\n         ENUM(V_RCP_F64              ,431)\n         ENUM(V_RCP_CLAMP_F64        ,432)\n         ENUM(V_RSQ_F64              ,433)\n         ENUM(V_RSQ_CLAMP_F64        ,434)\n         ENUM(V_SQRT_F32             ,435)\n         ENUM(V_SQRT_F64             ,436)  \n         ENUM(V_SIN_F32              ,437)  \n         ENUM(V_COS_F32              ,438)  \n         ENUM(V_NOT_B32              ,439)  \n         ENUM(V_BFREV_B32            ,440)  \n         ENUM(V_FFBH_U32             ,441)  \n         ENUM(V_FFBL_B32             ,442)  \n         ENUM(V_FFBH_I32             ,443)  \n         ENUM(V_FREXP_EXP_I32_F64    ,444)  \n         ENUM(V_FREXP_MANT_F64       ,445)  \n         ENUM(V_FRACT_F64            ,446)  \n         ENUM(V_FREXP_EXP_I32_F32    ,447)  \n         ENUM(V_FREXP_MANT_F32       ,448)                                                                             \n         ENUM(V_CLREXCP              ,449)    \n         ENUM(V_MOVRELD_B32          ,450)    \n         ENUM(V_MOVRELS_B32          ,451)    \n         ENUM(V_MOVRELSD_B32         ,452)    \n    END_TRANSLATOR(VectorInstructions,VOP3OpcodesExtra,V_INVALID)\n        \n    static VectorInstructions Translate_VOP3Opcodes( uint n )\n    {\n        if( n <= 255 )\n            return Translate_VOPCOpcodes(n);\n        return Translate_VOP3OpcodesExtra(n);\n    }\n\n    static VectorInstructions Translate_VINTERPOpcodes( uint n )\n    {\n        switch(n)\n        {\n        case 0: return V_INTERP_P1_F32  ; //  : D = P10 * S + P0; parameter interpolation.\n        case 1: return V_INTERP_P2_F32  ; //  : D = P20 * S + D; parameter interpolation.\n        case 2: return V_INTERP_MOV_F32 ; //  : D = {P10,P20,P0}[S]; parameter load.\n        default: return V_INVALID;\n        }\n    }\n\n    BEGIN_TRANSLATOR(Dests,ScalarDestOddballs)\n        ENUM(SRC_FSCR_LO          , 104)\n        ENUM(SRC_FSCR_HI          , 105)\n        ENUM(SRC_VCC_LO           , 106)\n        ENUM(SRC_VCC_HI           , 107)\n        ENUM(SRC_TBA_LO           , 108)\n        ENUM(SRC_TBA_HI           , 109)\n        ENUM(SRC_TMA_LO           , 110)\n        ENUM(SRC_TMA_HI           , 111)\n        ENUM(SRC_M0               , 124)\n        ENUM(SRC_EXEC_LO          , 126)\n        ENUM(SRC_EXEC_HI          , 127)\n    END_TRANSLATOR(Dests,ScalarDestOddballs, DEST_INVALID)\n\n    BEGIN_TRANSLATOR(Sources,ScalarSourceOddballs)\n        ENUM(SRC_FSCR_LO          , 104)\n        ENUM(SRC_FSCR_HI          , 105)\n        ENUM(SRC_VCC_LO           , 106)\n        ENUM(SRC_VCC_HI           , 107)\n        ENUM(SRC_TBA_LO           , 108)\n        ENUM(SRC_TBA_HI           , 109)\n        ENUM(SRC_TMA_LO           , 110)\n        ENUM(SRC_TMA_HI           , 111)\n        ENUM(SRC_M0               , 124)\n        ENUM(SRC_EXEC_LO          , 126)\n        ENUM(SRC_EXEC_HI          , 127)\n        ENUM(SRC_C_ZERO           , 128)\n        ENUM(SRC_CF_ONEHALF       , 240)\n        ENUM(SRC_CF_MINUS_ONEHALF , 241)\n        ENUM(SRC_CF_ONE           , 242)\n        ENUM(SRC_CF_MINUS_ONE     , 243)\n        ENUM(SRC_CF_TWO           , 244)\n        ENUM(SRC_CF_MINUS_TWO     , 245)\n        ENUM(SRC_CF_FOUR          , 246)\n        ENUM(SRC_CF_MINUS_FOUR    , 247)\n        ENUM(SRC_VCCZ             , 251)\n        ENUM(SRC_EXECZ            , 252)\n        ENUM(SRC_SCC              , 253)\n        ENUM(SRC_LDS_DIRECT       , 254)\n        ENUM(SRC_LITERAL          , 255)\n    END_TRANSLATOR(Sources,ScalarSourceOddballs,SRC_INVALID)\n    \n    BEGIN_TRANSLATOR(DSInstructions,DSOpcodes)\n      ENUM(DS_ADD_U32              , 0 )   \n      ENUM(DS_SUB_U32              , 1 )   \n      ENUM(DS_RSUB_U32             , 2 )   \n      ENUM(DS_INC_U32              , 3 )   \n      ENUM(DS_DEC_U32              , 4 )   \n      ENUM(DS_MIN_I32              , 5 )   \n      ENUM(DS_MAX_I32              , 6 )   \n      ENUM(DS_MIN_U32              , 7 )   \n      ENUM(DS_MAX_U32              , 8 )   \n      ENUM(DS_AND_B32              , 9 )   \n      ENUM(DS_OR_B32               ,10 )   \n      ENUM(DS_XOR_B32              ,11 )   \n      ENUM(DS_MSKOR_B32            ,12 )   \n      ENUM(DS_WRITE_B32            ,13 )   \n      ENUM(DS_WRITE2_B32           ,14 )   \n      ENUM(DS_WRITE2ST64_B32       ,15 )   \n      ENUM(DS_CMPST_B32            ,16 )   \n      ENUM(DS_CMPST_F32            ,17 )   \n      ENUM(DS_MIN_F32              ,18 )   \n      ENUM(DS_MAX_F32              ,19 )   \n      ENUM(DS_NOP                  ,20 )  \n      ENUM(DS_GWS_SEMA_RELEASE_ALL ,24 )  \n      ENUM(DS_GWS_INIT             ,25 )   \n      ENUM(DS_GWS_SEMA_V           ,26 )   \n      ENUM(DS_GWS_SEMA_BR          ,27 )   \n      ENUM(DS_GWS_SEMA_P           ,28 )   \n      ENUM(DS_GWS_BARRIER          ,29 )   \n      ENUM(DS_WRITE_B8             ,30 )   \n      ENUM(DS_WRITE_B16            ,31 )   \n      ENUM(DS_ADD_RTN_U32          ,32 )   \n      ENUM(DS_SUB_RTN_U32          ,33 )   \n      ENUM(DS_RSUB_RTN_U32         ,34 )   \n      ENUM(DS_INC_RTN_U32          ,35 )   \n      ENUM(DS_DEC_RTN_U32          ,36 )   \n      ENUM(DS_MIN_RTN_I32          ,37 )   \n      ENUM(DS_MAX_RTN_I32          ,38 )   \n      ENUM(DS_MIN_RTN_U32          ,39 )   \n      ENUM(DS_MAX_RTN_U32          ,40 )   \n      ENUM(DS_AND_RTN_B32          ,41 )   \n      ENUM(DS_OR_RTN_B32           ,42 )   \n      ENUM(DS_XOR_RTN_B32          ,43 )   \n      ENUM(DS_MSKOR_RTN_B32        ,44 )   \n      ENUM(DS_WRXCHG_RTN_B32       ,45 )   \n      ENUM(DS_WRXCHG2_RTN_B32      ,46 )   \n      ENUM(DS_WRXCHG2ST64_RTN_B32  ,47 )   \n      ENUM(DS_CMPST_RTN_B32        ,48 )   \n      ENUM(DS_CMPST_RTN_F32        ,49 )   \n      ENUM(DS_MIN_RTN_F32          ,50 )   \n      ENUM(DS_MAX_RTN_F32          ,51 )   \n      ENUM(DS_WRAP_RTN_B32         ,52 )   \n      ENUM(DS_SWIZZLE_B32          ,53 )   \n      ENUM(DS_READ_B32             ,54 )   \n      ENUM(DS_READ2_B32            ,55 )   \n      ENUM(DS_READ2ST64_B32        ,56 )   \n      ENUM(DS_READ_I8              ,57 )   \n      ENUM(DS_READ_U8              ,58 )   \n      ENUM(DS_READ_I16             ,59 )   \n      ENUM(DS_READ_U16             ,60 )   \n      ENUM(DS_CONSUME              ,61 )   \n      ENUM(DS_APPEND               ,62 )   \n      ENUM(DS_ORDERED_COUNT        ,63 )   \n      ENUM(DS_ADD_U64              ,64 )   \n      ENUM(DS_SUB_U64              ,65 )   \n      ENUM(DS_RSUB_U64             ,66 )   \n      ENUM(DS_INC_U64              ,67 )   \n      ENUM(DS_DEC_U64              ,68 )   \n      ENUM(DS_MIN_I64              ,69 )   \n      ENUM(DS_MAX_I64              ,70 )   \n      ENUM(DS_MIN_U64              ,71 )   \n      ENUM(DS_MAX_U64              ,72 )   \n      ENUM(DS_AND_B64              ,73 )   \n      ENUM(DS_OR_B64               ,74 )   \n      ENUM(DS_XOR_B64              ,75 )   \n      ENUM(DS_MSKOR_B64            ,76 )   \n      ENUM(DS_WRITE_B64            ,77 )   \n      ENUM(DS_WRITE2_B64           ,78 )   \n      ENUM(DS_WRITE2ST64_B64       ,79 )   \n      ENUM(DS_CMPST_B64            ,80 )   \n      ENUM(DS_CMPST_F64            ,81 )   \n      ENUM(DS_MIN_F64              ,82 )   \n      ENUM(DS_MAX_F64              ,83 )   \n      ENUM(DS_ADD_RTN_U64          ,96 )   \n      ENUM(DS_SUB_RTN_U64          ,97 )   \n      ENUM(DS_RSUB_RTN_U64         ,98 )   \n      ENUM(DS_INC_RTN_U64          ,99 )   \n      ENUM(DS_DEC_RTN_U64          ,100)   \n      ENUM(DS_MIN_RTN_I64          ,101)   \n      ENUM(DS_MAX_RTN_I64          ,102)   \n      ENUM(DS_MIN_RTN_U64          ,103)   \n      ENUM(DS_MAX_RTN_U64          ,104)   \n      ENUM(DS_AND_RTN_B64          ,105)   \n      ENUM(DS_OR_RTN_B64           ,106)   \n      ENUM(DS_XOR_RTN_B64          ,107)   \n      ENUM(DS_MSKOR_RTN_B64        ,108)   \n      ENUM(DS_WRXCHG_RTN_B64       ,109)   \n      ENUM(DS_WRXCHG2_RTN_B64      ,110)   \n      ENUM(DS_WRXCHG2ST64_RTN_B64  ,111)   \n      ENUM(DS_CMPST_RTN_B64        ,112)   \n      ENUM(DS_CMPST_RTN_F64        ,113)   \n      ENUM(DS_MIN_RTN_F64          ,114)   \n      ENUM(DS_MAX_RTN_F64          ,115)   \n      ENUM(DS_READ_B64             ,118)   \n      ENUM(DS_READ2_B64            ,119)   \n      ENUM(DS_READ2ST64_B64        ,120)   \n      ENUM(DS_CONDXCHG32_RTN_B64   ,126)   \n      ENUM(DS_ADD_SRC2_U32         ,128)   \n      ENUM(DS_SUB_SRC2_U32         ,129)   \n      ENUM(DS_RSUB_SRC2_U32        ,130)   \n      ENUM(DS_INC_SRC2_U32         ,131)   \n      ENUM(DS_DEC_SRC2_U32         ,132)   \n      ENUM(DS_MIN_SRC2_I32         ,133)   \n      ENUM(DS_MAX_SRC2_I32         ,134)   \n      ENUM(DS_MIN_SRC2_U32         ,135)   \n      ENUM(DS_MAX_SRC2_U32         ,136)   \n      ENUM(DS_AND_SRC2_B32         ,137)   \n      ENUM(DS_OR_SRC2_B32          ,138)   \n      ENUM(DS_XOR_SRC2_B32         ,139)   \n      ENUM(DS_WRITE_SRC2_B32       ,140)   \n      ENUM(DS_MIN_SRC2_F32         ,146)   \n      ENUM(DS_MAX_SRC2_F32         ,147)   \n      ENUM(DS_ADD_SRC2_U64         ,192)   \n      ENUM(DS_SUB_SRC2_U64         ,193)   \n      ENUM(DS_RSUB_SRC2_U64        ,194)   \n      ENUM(DS_INC_SRC2_U64         ,195)   \n      ENUM(DS_DEC_SRC2_U64         ,196)   \n      ENUM(DS_MIN_SRC2_I64         ,197)   \n      ENUM(DS_MAX_SRC2_I64         ,198)   \n      ENUM(DS_MIN_SRC2_U64         ,199)   \n      ENUM(DS_MAX_SRC2_U64         ,200)   \n      ENUM(DS_AND_SRC2_B64         ,201)   \n      ENUM(DS_OR_SRC2_B64          ,202)   \n      ENUM(DS_XOR_SRC2_B64         ,203)   \n      ENUM(DS_WRITE_SRC2_B64       ,204)   \n      ENUM(DS_MIN_SRC2_F64         ,210)   \n      ENUM(DS_MAX_SRC2_F64         ,211)   \n      ENUM(DS_WRITE_B96            ,222)  \n      ENUM(DS_WRITE_B128           ,223)  \n      ENUM(DS_CONDXCHG32_RTN_B128  ,253)  \n      ENUM(DS_READ_B96             ,254)  \n      ENUM(DS_READ_B128            ,255) \n    END_TRANSLATOR(DSInstructions,DSOpcodes,DS_INVALID)\n\n\n    BEGIN_TRANSLATOR(BufferInstructions,MUBUFFOpcodes)\n    ENUM( BUFFER_LOAD_FORMAT_X       ,0    )\n    ENUM( BUFFER_LOAD_FORMAT_XY      ,1    )\n    ENUM( BUFFER_LOAD_FORMAT_XYZ     ,2    )\n    ENUM( BUFFER_LOAD_FORMAT_XYZW    ,3    )\n    ENUM( BUFFER_STORE_FORMAT_X      ,4    )\n    ENUM( BUFFER_STORE_FORMAT_XY     ,5    )\n    ENUM( BUFFER_STORE_FORMAT_XYZ    ,6    )\n    ENUM( BUFFER_STORE_FORMAT_XYZW   ,7    )\n    ENUM( BUFFER_LOAD_UBYTE          ,8    )\n    ENUM( BUFFER_LOAD_SBYTE          ,9    )\n    ENUM( BUFFER_LOAD_USHORT         ,10   )\n    ENUM( BUFFER_LOAD_SSHORT         ,11   )\n    ENUM( BUFFER_LOAD_DWORD          ,12   )\n    ENUM( BUFFER_LOAD_DWORDX2        ,13   )\n    ENUM( BUFFER_LOAD_DWORDX4        ,14   )\n    ENUM( BUFFER_LOAD_DWORDX3        ,15   )\n    ENUM( BUFFER_STORE_BYTE          ,24   )\n    ENUM( BUFFER_STORE_SHORT         ,26   )\n    ENUM( BUFFER_STORE_DWORD         ,28   )\n    ENUM( BUFFER_STORE_DWORDX2       ,29   )\n    ENUM( BUFFER_STORE_DWORDX4       ,30   )\n    ENUM( BUFFER_STORE_DWORDX3       ,31   )\n    ENUM( BUFFER_ATOMIC_SWAP         ,48   )\n    ENUM( BUFFER_ATOMIC_CMPSWAP      ,49   )\n    ENUM( BUFFER_ATOMIC_ADD          ,50   )\n    ENUM( BUFFER_ATOMIC_SUB          ,51   )\n    ENUM( BUFFER_ATOMIC_RSUB         ,52   )\n    ENUM( BUFFER_ATOMIC_SMIN         ,53   )\n    ENUM( BUFFER_ATOMIC_UMIN         ,54   )\n    ENUM( BUFFER_ATOMIC_SMAX         ,55   )\n    ENUM( BUFFER_ATOMIC_UMAX         ,56   )\n    ENUM( BUFFER_ATOMIC_AND          ,57   )\n    ENUM( BUFFER_ATOMIC_OR           ,58   )\n    ENUM( BUFFER_ATOMIC_XOR          ,59   )\n    ENUM( BUFFER_ATOMIC_INC          ,60   )\n    ENUM( BUFFER_ATOMIC_DEC          ,61   )\n    ENUM( BUFFER_ATOMIC_FCMPSWAP     ,62   )\n    ENUM( BUFFER_ATOMIC_FMIN         ,63   )\n    ENUM( BUFFER_ATOMIC_FMAX         ,64   )\n    ENUM( BUFFER_ATOMIC_SWAP_X2      ,80   )\n    ENUM( BUFFER_ATOMIC_CMPSWAP_X2   ,81   )\n    ENUM( BUFFER_ATOMIC_ADD_X2       ,82   )\n    ENUM( BUFFER_ATOMIC_SUB_X2       ,83   )\n    ENUM( BUFFER_ATOMIC_RSUB_X2      ,84   )\n    ENUM( BUFFER_ATOMIC_SMIN_X2      ,85   )\n    ENUM( BUFFER_ATOMIC_UMIN_X2      ,86   )\n    ENUM( BUFFER_ATOMIC_SMAX_X2      ,87   )\n    ENUM( BUFFER_ATOMIC_UMAX_X2      ,88   )\n    ENUM( BUFFER_ATOMIC_AND_X2       ,89   )\n    ENUM( BUFFER_ATOMIC_OR_X2        ,90   )\n    ENUM( BUFFER_ATOMIC_XOR_X2       ,91   )\n    ENUM( BUFFER_ATOMIC_INC_X2       ,92   )\n    ENUM( BUFFER_ATOMIC_DEC_X2       ,93   )\n    ENUM( BUFFER_ATOMIC_FCMPSWAP_X2  ,94   )\n    ENUM( BUFFER_ATOMIC_FMIN_X2      ,95   )\n    ENUM( BUFFER_ATOMIC_FMAX_X2      ,96   )\n    ENUM( BUFFER_WBINVL1_SC          ,112  )\n    ENUM( BUFFER_WBINVL1             ,113  )\n    END_TRANSLATOR(BufferInstructions,MUBUFFOpcodes,BUFFER_INVALID)\n\n    BEGIN_TRANSLATOR(BufferInstructions,MTBUFFOpcodes)\n        ENUM(TBUFFER_LOAD_FORMAT_X     ,0) //  : Untyped buffer load 1 Dword with format conversion.\n        ENUM(TBUFFER_LOAD_FORMAT_XY    ,1) //  : Untyped buffer load 2 Dwords with format conversion.\n        ENUM(TBUFFER_LOAD_FORMAT_XYZ   ,2) //  : Untyped buffer load 3 Dwords with format conversion.\n        ENUM(TBUFFER_LOAD_FORMAT_XYZW  ,3) //  : Untyped buffer load 4 Dwords with format conversion.\n        ENUM(TBUFFER_STORE_FORMAT_X    ,4) //  : Untyped buffer store 1 Dword with format conversion.\n        ENUM(TBUFFER_STORE_FORMAT_XY   ,5) //  : Untyped buffer store 2 Dwords with format conversion.\n        ENUM(TBUFFER_STORE_FORMAT_XYZ  ,6) //  : Untyped buffer store 3 Dwords with format conversion.\n        ENUM(TBUFFER_STORE_FORMAT_XYZW ,7) //  : Untyped buffer store 4 Dwords with format conversion.\n    END_TRANSLATOR(BufferInstructions,MTBUFFOpcodes,TBUFFER_INVALID)\n\n    BEGIN_TRANSLATOR(ImageInstructions,MIMGOpcodes)\n        ENUM(IMAGE_LOAD                ,0    )\n        ENUM(IMAGE_LOAD_MIP            ,1    )\n        ENUM(IMAGE_LOAD_PCK            ,2    )\n        ENUM(IMAGE_LOAD_PCK_SGN        ,3    )\n        ENUM(IMAGE_LOAD_MIP_PCK        ,4    )\n        ENUM(IMAGE_LOAD_MIP_PCK_SGN    ,5    )\n        ENUM(IMAGE_STORE               ,8    )\n        ENUM(IMAGE_STORE_MIP           ,9    )\n        ENUM(IMAGE_STORE_PCK           ,10   )\n        ENUM(IMAGE_STORE_MIP_PCK       ,11   )\n        ENUM(IMAGE_GET_RESINFO         ,14   )\n        ENUM(IMAGE_ATOMIC_SWAP         ,15   )\n        ENUM(IMAGE_ATOMIC_CMPSWAP      ,16   )\n        ENUM(IMAGE_ATOMIC_ADD          ,17   )\n        ENUM(IMAGE_ATOMIC_SUB          ,18   )\n        ENUM(IMAGE_ATOMIC_RSUB         ,19   )\n        ENUM(IMAGE_ATOMIC_SMIN         ,20   )\n        ENUM(IMAGE_ATOMIC_UMIN         ,21   )\n        ENUM(IMAGE_ATOMIC_SMAX         ,22   )\n        ENUM(IMAGE_ATOMIC_UMAX         ,23   )\n        ENUM(IMAGE_ATOMIC_AND          ,24   )\n        ENUM(IMAGE_ATOMIC_OR           ,25   )\n        ENUM(IMAGE_ATOMIC_XOR          ,26   )\n        ENUM(IMAGE_ATOMIC_INC          ,27   )\n        ENUM(IMAGE_ATOMIC_DEC          ,28   )\n        ENUM(IMAGE_ATOMIC_FCMPSWAP     ,29   )\n        ENUM(IMAGE_ATOMIC_FMIN         ,30   )\n        ENUM(IMAGE_ATOMIC_FMAX         ,31   )\n        ENUM(IMAGE_SAMPLE              ,32   )\n        ENUM(IMAGE_SAMPLE_CL           ,33   )\n        ENUM(IMAGE_SAMPLE_D            ,34   )\n        ENUM(IMAGE_SAMPLE_D_CL         ,35   )\n        ENUM(IMAGE_SAMPLE_L            ,36   )\n        ENUM(IMAGE_SAMPLE_B            ,37   )\n        ENUM(IMAGE_SAMPLE_B_CL         ,38   )\n        ENUM(IMAGE_SAMPLE_LZ           ,39   )\n        ENUM(IMAGE_SAMPLE_C            ,40   )\n        ENUM(IMAGE_SAMPLE_C_CL         ,41   )\n        ENUM(IMAGE_SAMPLE_C_D          ,42   )\n        ENUM(IMAGE_SAMPLE_C_D_CL       ,43   )\n        ENUM(IMAGE_SAMPLE_C_L          ,44   )\n        ENUM(IMAGE_SAMPLE_C_B          ,45   )\n        ENUM(IMAGE_SAMPLE_C_B_CL       ,46   )\n        ENUM(IMAGE_SAMPLE_C_LZ         ,47   )\n        ENUM(IMAGE_SAMPLE_O            ,48   )\n        ENUM(IMAGE_SAMPLE_CL_O         ,49   )\n        ENUM(IMAGE_SAMPLE_D_O          ,50   )\n        ENUM(IMAGE_SAMPLE_D_CL_O       ,51   )\n        ENUM(IMAGE_SAMPLE_L_O          ,52   )\n        ENUM(IMAGE_SAMPLE_B_O          ,53   )\n        ENUM(IMAGE_SAMPLE_B_CL_O       ,54   )\n        ENUM(IMAGE_SAMPLE_LZ_O         ,55   )\n        ENUM(IMAGE_SAMPLE_C_O          ,56   )\n        ENUM(IMAGE_SAMPLE_C_CL_O       ,57   )\n        ENUM(IMAGE_SAMPLE_C_D_O        ,58   )\n        ENUM(IMAGE_SAMPLE_C_D_CL_O     ,59   )\n        ENUM(IMAGE_SAMPLE_C_L_O        ,60   )\n        ENUM(IMAGE_SAMPLE_C_B_O        ,61   )\n        ENUM(IMAGE_SAMPLE_C_B_CL_O     ,62   )\n        ENUM(IMAGE_SAMPLE_C_LZ_O       ,63   )\n        ENUM(IMAGE_GATHER4             ,64   )\n        ENUM(IMAGE_GATHER4_CL          ,65   )\n        ENUM(IMAGE_GATHER4_L           ,66   )\n        ENUM(IMAGE_GATHER4_B           ,67   )\n        ENUM(IMAGE_GATHER4_B_CL        ,68   )\n        ENUM(IMAGE_GATHER4_LZ          ,69   )\n        ENUM(IMAGE_GATHER4_C           ,70   )\n        ENUM(IMAGE_GATHER4_C_CL        ,71   )\n        ENUM(IMAGE_GATHER4_C_L         ,76   )\n        ENUM(IMAGE_GATHER4_C_B         ,77   )\n        ENUM(IMAGE_GATHER4_C_B_CL      ,78   )\n        ENUM(IMAGE_GATHER4_C_LZ        ,79   )\n        ENUM(IMAGE_GATHER4_O           ,80   )\n        ENUM(IMAGE_GATHER4_CL_O        ,81   )\n        ENUM(IMAGE_GATHER4_L_O         ,84   )\n        ENUM(IMAGE_GATHER4_B_O         ,85   )\n        ENUM(IMAGE_GATHER4_B_CL_O      ,86   )\n        ENUM(IMAGE_GATHER4_LZ_O        ,87   )\n        ENUM(IMAGE_GATHER4_C_O         ,88   )\n        ENUM(IMAGE_GATHER4_C_CL_O      ,89   )\n        ENUM(IMAGE_GATHER4_C_L_O       ,92   )\n        ENUM(IMAGE_GATHER4_C_B_O       ,93   )\n        ENUM(IMAGE_GATHER4_C_B_CL_O    ,94   )\n        ENUM(IMAGE_GATHER4_C_LZ_O      ,95   )\n        ENUM(IMAGE_GET_LOD             ,96   )\n        ENUM(IMAGE_SAMPLE_CD           ,104  )\n        ENUM(IMAGE_SAMPLE_CD_CL        ,105  )\n        ENUM(IMAGE_SAMPLE_C_CD         ,106  )\n        ENUM(IMAGE_SAMPLE_C_CD_CL      ,107  )\n        ENUM(IMAGE_SAMPLE_CD_O         ,108  )\n        ENUM(IMAGE_SAMPLE_CD_CL_O      ,109  )\n        ENUM(IMAGE_SAMPLE_C_CD_O       ,110  )\n        ENUM(IMAGE_SAMPLE_C_CD_CL_O    ,111  )\n    END_TRANSLATOR(ImageInstructions,MIMGOpcodes,IMAGE_INVALID)\n\n\n    BEGIN_TRANSLATOR(TBufferNumberFormats,MTBUFF_NumberFormat)\n        ENUM(NF_UNORM       , 0)\n        ENUM(NF_SNORM       , 1)\n        ENUM(NF_USCALED     , 2)\n        ENUM(NF_SSCALED     , 3)\n        ENUM(NF_UINT        , 4)\n        ENUM(NF_SINT        , 5)\n        ENUM(NF_SNORM_NZ    , 6)\n        ENUM(NF_FLOAT       , 7)\n        ENUM(NF_SRGB        , 9)\n        ENUM(NF_UBNORM      , 10)\n        ENUM(NF_UBNORM_NZ   , 11)\n        ENUM(NF_UBINT       , 12)\n        ENUM(NF_UBSCALED    , 13)\n    END_TRANSLATOR(TBufferNumberFormats,MTBUFF_NumberFormat,NF_INVALID)\n\n    BEGIN_TRANSLATOR(TBufferDataFormats,MTBUFF_DataFormat)\n        ENUM( DF_8          , 1    )\n        ENUM( DF_16         , 2    )\n        ENUM( DF_8_8        , 3    )\n        ENUM( DF_32         , 4    )\n        ENUM( DF_16_16      , 5    )\n        ENUM( DF_10_11_11   , 6    )\n        ENUM( DF_11_11_10   , 7    )\n        ENUM( DF_10_10_10_2 , 8    )\n        ENUM( DF_2_10_10_10 , 9    )\n        ENUM( DF_8_8_8_8    , 10   )\n        ENUM( DF_32_32      , 11   )\n        ENUM( DF_16_16_16_16, 12   )\n        ENUM( DF_32_32_32   , 13   )\n        ENUM( DF_32_32_32_32, 14   )\n    END_TRANSLATOR(TBufferDataFormats,MTBUFF_DataFormat,DF_INVALID)\n\n    BEGIN_TRANSLATOR(ExportTargets, EXPTarget)\n        ENUM( EXP_MRT0     ,0   )\n        ENUM( EXP_MRT1     ,1   )\n        ENUM( EXP_MRT2     ,2   )\n        ENUM( EXP_MRT3     ,3   )\n        ENUM( EXP_MRT4     ,4   )\n        ENUM( EXP_MRT5     ,5   )\n        ENUM( EXP_MRT6     ,6   )\n        ENUM( EXP_MRT7     ,7   )\n        ENUM( EXP_Z        ,8   )\n        ENUM( EXP_NULL     ,9   )\n        ENUM( EXP_POS0     ,12  )\n        ENUM( EXP_POS1     ,13  )\n        ENUM( EXP_POS2     ,14  )\n        ENUM( EXP_POS3     ,15  )\n        ENUM( EXP_PARAM0   ,32  )\n        ENUM( EXP_PARAM1   ,33 ) \n        ENUM( EXP_PARAM2   ,34 ) \n        ENUM( EXP_PARAM3   ,35 ) \n        ENUM( EXP_PARAM4   ,36 ) \n        ENUM( EXP_PARAM5   ,37 ) \n        ENUM( EXP_PARAM6   ,38 ) \n        ENUM( EXP_PARAM7   ,39 ) \n        ENUM( EXP_PARAM8   ,40 ) \n        ENUM( EXP_PARAM9   ,41 ) \n        ENUM( EXP_PARAM10   ,42 ) \n        ENUM( EXP_PARAM11   ,43 ) \n        ENUM( EXP_PARAM12   ,44 ) \n        ENUM( EXP_PARAM13   ,45 ) \n        ENUM( EXP_PARAM14   ,46 ) \n        ENUM( EXP_PARAM15   ,47 ) \n        ENUM( EXP_PARAM16   ,48 ) \n        ENUM( EXP_PARAM17   ,49 ) \n        ENUM( EXP_PARAM18   ,50 ) \n        ENUM( EXP_PARAM19   ,51 ) \n        ENUM( EXP_PARAM20   ,52 ) \n        ENUM( EXP_PARAM21   ,53 ) \n        ENUM( EXP_PARAM22   ,54 ) \n        ENUM( EXP_PARAM23   ,55 ) \n        ENUM( EXP_PARAM24   ,56 ) \n        ENUM( EXP_PARAM25   ,57 ) \n        ENUM( EXP_PARAM26   ,58 ) \n        ENUM( EXP_PARAM27   ,59 ) \n        ENUM( EXP_PARAM28   ,60 ) \n        ENUM( EXP_PARAM29   ,61 ) \n        ENUM( EXP_PARAM30   ,62 ) \n        ENUM( EXP_PARAM31   ,63 ) \n    END_TRANSLATOR(ExportTargets,EXPTarget,EXP_INVALID)\n\n    Dests Translate_SDest( uint n )\n    {\n        if( n <= 103 )\n            return (Dests)(DEST_SGPR_FIRST+n);\n        else\n            return Translate_ScalarDestOddballs(n);\n    }\n\n    Sources Translate_SSrc( uint n )\n    {\n        if( n <= 103 )\n            return (Sources)(SRC_SGPR_FIRST+n); // SGPRs\n        if( n >= 112 && n <= 123 )\n            return (Sources)(SRC_TTMP_FIRST+(n-112)); // trap handler temps\n        if( n >= 256 && n<= 511 )\n            return (Sources)(SRC_VGPR_FIRST+(n-256)); // VGPRs\n        if( n >= 129 && n <= 192 )\n            return(Sources) (SRC_CI_POSITIVE_FIRST+(n-129));\n        if( n >= 193 && n <= 208 )\n            return (Sources) (SRC_CI_NEGATIVE_FIRST+(n-193));\n\n        return Translate_ScalarSourceOddballs(n);\n    }\n\n    Sources Translate_VSrc( uint n )\n    {\n        return (Sources)(SRC_VGPR_FIRST+n);\n    }\n    Dests Translate_VDest( uint n )\n    {\n        return (Dests)(DEST_VGPR_FIRST+n);\n    }\n\n    class Instruction\n    {\n    public:\n\n        uint32 ReadTrailingLiteral() const {\n            const uint32* pDWORD = (const uint32*)this;\n            return pDWORD[1];\n        }\n\n    protected:\n\n        int SignExt( uint n, uint sign )\n        {\n            uint bit = (1<<sign);\n        }\n\n        uint ReadBits( uint hi, uint lo ) const\n        {\n            uint shift = lo % 32;\n            uint mask = (1<<(hi-lo+1))-1;\n            return ( ((const uint32*)this)[lo/32]>>shift)&mask;\n        }\n        bool ReadBit( uint bit ) const\n        {\n            uint shift = bit % 32;\n            return (( ((const uint32*)this)[bit/32]>>shift)&1) != 0;\n        }\n    private:\n    };\n\n\n    class SOP2Instruction : public Instruction\n    {\n    public:\n        bool HasLiteral() const { return ((GetSrc0() == SRC_LITERAL || GetSrc1() == SRC_LITERAL)); }\n        uint   GetLength()              const { return 4 + 4*HasLiteral(); };\n        ScalarInstructions   GetOpcode()const { return Translate_SOP2Opcodes(ReadBits( 29, 23 )); }\n        Sources   GetSrc0()             const { return Translate_SSrc(ReadBits( 7,0 )); }\n        Sources   GetSrc1()             const { return Translate_SSrc(ReadBits( 15,8)); }\n        Dests   GetDest()               const { return Translate_SDest(ReadBits( 22,16)); }\n    };\n\n    class SOP1Instruction : public Instruction\n    {\n    public:\n        bool HasLiteral() const { return (GetSrc0() == SRC_LITERAL); }\n        uint   GetLength()                const { return 4 + 4*HasLiteral(); };\n        ScalarInstructions   GetOpcode()  const { return Translate_SOP1Opcodes(ReadBits( 15,8 )); }\n        Sources   GetSrc0()               const { return Translate_SSrc( ReadBits(7,0) ); }\n        Dests     GetDest()               const { return Translate_SDest(ReadBits(22,16)); }\n    };\n\n    class SOPKInstruction : public Instruction\n    {\n    public:\n        InstructionFormat GetFormat() const { return IF_SOPK; }\n        bool HasLiteral() const { return (GetOpcode() == S_SETREG_IMM32_B32); }\n        uint GetLength() const { return 4 + 4*HasLiteral(); };\n\n        ScalarInstructions GetOpcode() const { return Translate_SOPKOpcodes(ReadBits( 27,23 )); }\n        Dests GetDest()           const { return Translate_SDest( ReadBits(22,16) ); }\n\n        int ReadSIMM16() const { return *((const int16*)this); }\n        uint ReadSIMMBits( uint hi, uint lo) const { return ReadBits(hi,lo); }\n        uint32 ReadIMM32() const { return ReadBits(63,32); }\n        \n        const uint8* GetBranchTarget() const\n        {\n            if( GetOpcode() != S_CBRANCH_I_FORK )\n                return 0;\n            int offset = this->ReadSIMM16();\n            const uint32* pThis = (const uint32*)this;\n            return (const uint8*) (pThis+1+offset);\n        }\n\n    };\n\n    class SOPCInstruction : public Instruction\n    {\n    public:\n        InstructionFormat GetFormat() const { return IF_SOPC; }\n        bool HasLiteral() const { return (GetSrc0() == SRC_LITERAL || GetSrc1() == SRC_LITERAL);}\n        uint GetLength()  const { return 4 + 4*HasLiteral(); };\n\n        ScalarInstructions GetOpcode()  const { return Translate_SOPCOpcodes(ReadBits( 22,16 )); }\n        Sources GetSrc0()            const { return Translate_SSrc(ReadBits(7,0)); }\n        Sources GetSrc1()            const { return Translate_SSrc(ReadBits(15,8 )); }\n        Dests GetDest() const { return GetOpcode() == S_SETVSKIP ? DEST_VSKIP : DEST_SCC; }\n        \n    };\n\n    class SOPPInstruction : public Instruction\n    {\n    public:\n        InstructionFormat GetFormat() const { return IF_SOPP; }\n        uint GetLength() const  { return 4; }\n\n        int ReadSIMM16() const { return *((const int16*)this); }\n        uint ReadSIMMBits( uint hi, uint lo ) const { return ReadBits(hi,lo); }\n\n        ScalarInstructions GetOpcode() const { return Translate_SOPPOpcodes(ReadBits( 22,16 )); }\n        const uint8* GetBranchTarget() const\n        {\n            switch( GetOpcode() )\n            {\n            case S_BRANCH                :\n            case S_CBRANCH_SCC0          :\n            case S_CBRANCH_SCC1          :\n            case S_CBRANCH_VCCZ          :\n            case S_CBRANCH_VCCNZ         :\n            case S_CBRANCH_EXECZ         :\n            case S_CBRANCH_EXECNZ        :\n            case S_CBRANCH_CDBGSYS            :\n            case S_CBRANCH_CDBGUSER           :\n            case S_CBRANCH_CDBGSYS_OR_USER    :\n            case S_CBRANCH_CDBGSYS_AND_USER   :\n                {\n                    int n = this->ReadSIMM16();\n                    int offset = this->ReadSIMM16();\n                    const uint32* pThis = (const uint32*)this;\n                    return (const uint8*) (pThis+1+offset);\n                }\n            default:\n                return 0;\n            }\n            \n        }\n\n        \n    };\n\n    class SMRDInstruction : public Instruction\n    {\n    public:\n        InstructionFormat GetFormat() const { return IF_SMEM; }\n        uint GetLength()       const { return 4 + 4*(!IsOffsetIMM() && GetOffset() == SRC_LITERAL); }\n        ScalarMemoryInstructions GetOpcode()  const { return Translate_SMRDOpcodes(ReadBits(26,22)); }\n        Dests GetDest()                 const { return Translate_SDest(ReadBits( 21,15)); }\n        Dests GetBase()                 const { return Translate_SDest(2*ReadBits( 14,9 )); } // base of SGPR pair containing address\n        uint GetOffset()               const { return IsOffsetIMM() ? 4*ReadBits(7,0) : ReadBits(7,0); }\n        bool IsOffsetIMM()             const { return ReadBits( 8, 8 )!=0; }\n        // SI and CI use dword offsets, but VI uses byte.\n    };\n\n    class VOP2Instruction : public Instruction\n    {\n    public:\n        \n        InstructionFormat GetFormat() const { return IF_VOP2; }\n        bool HasLiteral() const { return (GetSrc0() == SRC_LITERAL || GetOpcode() == V_MADAK_F32 || GetOpcode() == V_MADMK_F32); }\n        uint GetLength() const { return 4 + 4*HasLiteral(); }\n\n        VectorInstructions GetOpcode() const { return Translate_VOP2Opcodes(ReadBits(30,25)); }\n        Sources GetSrc0()           const { return Translate_SSrc(ReadBits(8,0)); }\n        Sources GetVSrc1()          const { return Translate_VSrc(ReadBits(16,9)); }\n        Dests GetVDst()           const   { return Translate_VDest(ReadBits(24,17)); }\n        \n        uint GetResultWidthInDWORDS() const { return 1; }\n    };\n\n    class VOP1Instruction : public Instruction\n    {\n    public:\n        \n        InstructionFormat GetFormat() const { return IF_VOP1; }\n        bool HasLiteral() const { \n            switch( GetOpcode())\n            {\n            default:\n                return GetSrc0() == SRC_LITERAL;\n            case V_NOP:\n            case V_CLREXCP:             \n                return false;\n            }\n        }\n        uint GetLength() const \n        {\n            return 4 + 4*HasLiteral();\n        }\n\n        VectorInstructions GetOpcode() const { return Translate_VOP1Opcodes( ReadBits(16,9) ); }\n        Dests GetDst() const \n\t\t{\n\t\t\tif(GetOpcode() == V_READFIRSTLANE_B32)\n\t\t\t{\n\t\t\t\treturn Translate_SDest(ReadBits(24, 17));\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\treturn Translate_VDest(ReadBits(24, 17));\n\t\t\t}\n\t\t}\n        Sources GetSrc0()         const { return Translate_SSrc(ReadBits(8,0)); }\n        \n        uint GetResultWidthInDWORDS() const;\n        uint GetOperandWidthInDWORDS() const;\n        \n\n        const Instruction* GetBranchTarget() const { return 0; }\n        bool IsBranch() const { return false; }\n    };\n\n    class VOPCInstruction : public Instruction\n    {\n    public:\n        \n        InstructionFormat GetFormat() const { return IF_VOPC; }\n        bool HasLiteral() const { return (GetSrc0() == SRC_LITERAL); }\n        uint GetLength() const { return 4 + 4*HasLiteral(); }\n\n        VectorInstructions GetOpcode() const { return Translate_VOPCOpcodes(ReadBits(24,17)); }\n        Sources GetSrc0()           const { return Translate_SSrc(ReadBits( 8,0 )); }\n        Sources GetVSrc1()          const { return Translate_VSrc(ReadBits( 16,9 )); }\n      \n        uint GetOperandWidthInDWORDs() const;\n        \n\n        const Instruction* GetBranchTarget() const { return 0; }\n        bool IsBranch() const { return false; }\n    };\n\n    class VINTERPInstruction : public Instruction\n    {\n    public:\n        \n        InstructionFormat GetFormat() const { return IF_VINTERP; }\n        uint GetLength() const { return 4; }\n\n        VectorInstructions GetOpcode() const { return Translate_VINTERPOpcodes( ReadBits(17,16) ); }\n        uint GetAttributeChannel() const { return ReadBits(9,8); };\n        uint GetAttributeIndex() const { return ReadBits(15,10); };\n        Sources GetVSrc0() const { return Translate_VSrc( ReadBits(7,0) ); }\n        Dests GetVDst() const { return Translate_VDest(ReadBits(25,18)); }\n\n    };\n\n    class VOP3Instruction : public Instruction\n    {\n    public:\n        \n        InstructionFormat GetFormat() const { return IF_VOP3; }\n        uint GetLength() const { return 8; }\n        \n        VectorInstructions GetOpcode() const { return Translate_VOP3Opcodes(ReadBits(25,17));}\n       \n        Dests GetVDst() const { \n            uint dst = ReadBits(7,0);\n            if( IsCompare() )\n                return Translate_SDest(dst);\n            return Translate_VDest(dst); \n        }\n        Sources GetSrc0() const { return Translate_SSrc(ReadBits(40,32)); }\n        Sources GetSrc1() const { return Translate_SSrc(ReadBits(49,41)); }\n        Sources GetSrc2() const { return Translate_SSrc(ReadBits(58,50)); }\n        uint GetSourceNegateMask() const { return ReadBits(63,61); };\n        uint GetOMod() const { return ReadBits(60,59); }\n     \n        bool IsCompare() const { return ReadBits(25,17) < 255; } // opcodes 0-255 are vcmps.\n\n        bool IsVOP3bOp() const\n        {\n            // NOTE: ISA Doc, section 6, claims that vcmp is vop3b.  But AMD disassembler thinks its VOP3a\n            //\n            switch( GetOpcode() )\n            {\n            case V_ADD_I32      :   //  : D.u = S0.u + S1.u; VCC=carry-out (VOP3:sgpr=carry-out).\n            case V_SUB_I32      :   //  : D.u = S0.u - S1.u; VCC=carry-out (VOP3:sgpr=carry-out).\n            case V_SUBREV_I32   :   //  : D.u = S1.u - S0.u; VCC=carry-out (VOP3:sgpr=carry-out).\n            case V_ADDC_U32     :   //  : D.u = S0.u + S1.u + VCC; VCC=carry-out (VOP3:sgpr=carryout,S2.u=carry-in).\n            case V_SUBB_U32     :   //  : D.u = S0.u - S1.u - VCC; VCC=carry-out (VOP3:sgpr=carry-out,S2.u=carry-in).\n            case V_SUBBREV_U32  :   //  : D.u = S1.u - S0.u - VCC; VCC=carry-out (VOP3:sgpr=carryout,S2.u=carry-in).\n            case V_DIV_SCALE_F32:   //  = D.f = Special case divide preop and flags(s0.f = Quotient,s1.f = Denominator, s2.f = Numerator) s0 must equal s1 or s2.\n            case V_DIV_SCALE_F64:   //  = D.d = Special case divide preop and flags(s0.d = Quotient,s1.d = Denominator, s2.d = Numerator) s0 must equal s1 or s2.\n                return true;\n            default:\n                return false;\n            }\n        }\n\n        // VOP3a only\n        uint GetSourceAbsMask() const { return ReadBits(10,8); }\n        bool GetClamp() const { return ReadBit(11); }\n\n        // VOP3b only\n        Dests GetSDst() const { return Translate_SDest(ReadBits(14,8)); }\n\n    };\n\n    class MUBUFFInstruction : public Instruction\n    {\n    public:\n        \n        InstructionFormat GetFormat() const { return IF_MUBUFF; }\n        BufferInstructions GetOpcode() const { return Translate_MUBUFFOpcodes(ReadBits(24,18)); }\n        uint GetLength() const { return 8; }\n        uint GetResultWidthInDWORDS() const ;\n\n        uint GetOffset() const { return ReadBits(11,0); }\n        Sources GetVAddr() const { return Translate_VSrc(ReadBits(39,32)); }\n        Sources GetVData() const { return Translate_VSrc(ReadBits(47,40)); }\n        Sources GetSResource() const { return (Sources)(SRC_SGPR_FIRST+4*ReadBits(52,48)); }\n        Sources GetSOffset() const { return Translate_SSrc(ReadBits(63,56)); }\n        \n        bool IsOffN() const     { return ReadBit(12); }\n        bool IsIdxN() const     { return ReadBit(13); }\n        bool IsAddr64() const   { return ReadBit(15); }\n        bool IsDirectToLDS() const { return ReadBit(16); }\n        bool GetSLCBit() const { return ReadBit(54); }\n        bool GetGLCBit() const { return ReadBit(14); }\n        bool GetTFEBit() const { return ReadBit(55); }\n        \n    };\n\n    class MTBUFFInstruction : public Instruction\n    {\n    public:\n        \n        InstructionFormat GetFormat() const { return IF_MTBUFF; }\n        BufferInstructions GetOpcode() const { return Translate_MTBUFFOpcodes(ReadBits(18,16)); }\n        uint GetLength() const { return 8; }\n\n        uint GetResultWidthInDWORDS() const ;\n\n        TBufferNumberFormats GetNumberFormat() const { return Translate_MTBUFF_NumberFormat( ReadBits(25,23) ); }\n        TBufferDataFormats GetDataFormat() const { return Translate_MTBUFF_DataFormat( ReadBits(22,19) ); }\n\n        uint GetOffset() const    { return ReadBits(11,0); }\n        Sources GetVAddr() const     { return Translate_VSrc(ReadBits(39,32)); }\n        Sources GetVData() const     { return Translate_VSrc(ReadBits(47,40)); }\n        Sources GetSResource() const { return (Sources)(SRC_SGPR_FIRST+4*ReadBits(52,48)); }\n        Sources GetSOffset() const { return Translate_SSrc(ReadBits(63,56)); }\n        \n        bool IsOffN() const     { return ReadBit(12); }\n        bool IsIdxN() const     { return ReadBit(13); }\n        bool IsAddr64() const   { return ReadBit(15); }\n        bool GetSLCBit() const  { return ReadBit(54); }\n        bool GetGLCBit() const  { return ReadBit(14); }\n        bool GetTFEBit() const  { return ReadBit(55); }\n        \n    };\n    \n   \n\n    class MIMGInstruction : public Instruction\n    {\n    public:\n        \n        InstructionFormat GetFormat() const { return IF_MIMG; }\n        ImageInstructions GetOpcode() const { return Translate_MIMGOpcodes( ReadBits(24,18) ); }\n        uint GetLength() const { return 8; }\n\n        bool IsSLC() const { return ReadBit(25); }\n        bool IsGLC() const { return ReadBit(13); }\n        bool IsTFE() const { return ReadBit(16); }\n        bool IsLWE() const { return ReadBit(17); }\n        bool IsArray() const { return ReadBit(14); }\n        bool IsUnormalized() const { return ReadBit(12); }\n        bool IsRes256() const { return !ReadBit(15);};\n       \n        uint GetDMask() const { return ReadBits(11,8); }\n        Sources GetSSampler() const  { return (Sources)(SRC_SGPR_FIRST+4*ReadBits(57,53)); }\n        Sources GetSResource() const { return (Sources)(SRC_SGPR_FIRST+4*ReadBits(52,48)); }\n        Sources GetVData() const { return Translate_VSrc( ReadBits(47,40) ); }\n        Sources GetVAddr() const { return Translate_VSrc( ReadBits(39,32) ); }\n\n        uint GetSamplerWidthInDWORDS() const;  // 0, 4\n        uint GetResultWidthInDWORDS() const;\n        \n\n    };\n\n    class DSInstruction : public Instruction\n    {\n    public:\n        uint GetOffset0() const { return ReadBits(7,0); }  // Instructions can have one 16 bit offset field or two 8-bit offset fields\n        uint GetOffset1() const { return ReadBits(15,8); }\n        uint GetOffset16() const { return ReadBits(15,0); }\n        DSInstructions GetOpcode() const { return Translate_DSOpcodes(ReadBits(25,18)); }\n        Dests GetVDest()  const { return Translate_VDest(ReadBits(63,56)); }\n        Sources GetVData0() const { return Translate_VSrc(ReadBits(47,40)); }\n        Sources GetVData1() const { return Translate_VSrc(ReadBits(55,48)); }\n        Sources GetVAddr()  const { return Translate_VSrc(ReadBits(39,32)); }\n        bool IsGDS()     const { return ReadBit(17); }  \n    };\n\n    class EXPInstruction : public Instruction\n    {\n    public:\n        InstructionFormat GetFormat() const { return IF_EXP; }\n        uint GetLength() const { return 8; }\n  \n        bool GetCompressBit() const { return ReadBit(10); }\n        bool GetDoneBit() const { return ReadBit(11); }\n        bool GetValidMaskBit() const { return ReadBit(12); }\n\n        ExportTargets GetTarget() const { return Translate_EXPTarget(ReadBits(9,4)); }\n        uint GetExportMask() const { return ReadBits(3,0); }\n        Sources GetVSrc0() const { return Translate_VSrc(ReadBits(39,32)); }\n        Sources GetVSrc1() const { return Translate_VSrc(ReadBits(47,40)); }\n        Sources GetVSrc2() const { return Translate_VSrc(ReadBits(55,48)); }\n        Sources GetVSrc3() const { return Translate_VSrc(ReadBits(63,56)); }\n    };\n\n \n\n}}\n\n\n\nnamespace GCN\n{\n    InstructionFormat GCN1Decoder::ReadInstructionFormat( const uint8* pLocation )\n    {\n        uint32 n = *((const uint32*)pLocation);\n\n        //\n        // The instruction format is inferred from magic numbers packed into the upper bits of the first DWORD\n        //   vop2    is    0.......\n        //   vop1    is    0111 111\n        //   vopc    is    0111 110\n        //   sop2    is    10......\n        //   sopK    is    1011 .......\n        //   sopc    is    1011 1111 0\n        //   sopp    is    1011 1111 1\n        //   sop1    is    1011 1110 1\n        //   vinterp is    1100 10\n        //   smrd    is    1100 0\n        //   vop3    is    1101 00  \n        //   flat    is    1101 11\n        //   ds      is    1101 10\n        //   mubuff  is    1110 00\n        //   mtbuff  is    1110 10\n        //   mimg    is    1111 00\n        //   exp     is    1111 10\n\n        switch( n & (0xFF800000) )       // 1111 1111 1000 ... (9 bit)\n        {\n        case 0xBF000000: return IF_SOPC; // 1011 1111 0....\n        case 0xBF800000: return IF_SOPP; // 1011 1111 1....\n        case 0xBE800000: return IF_SOP1; // 1011 1110 1....\n        default:\n            switch( n & (0xFE000000) )       // 1111 1110 ... (7 bit)\n            {\n            case 0x7E000000: return IF_VOP1; // 0111 1110 ...\n            case 0x7C000000: return IF_VOPC; // 0111 1100 ...\n            default:\n                switch( n & (0xFC000000) )          // 1111 1100 ... (6 bit)\n                {\n                case 0xC8000000: return IF_VINTERP; // 1100 10.. ....\n                case 0xD0000000: return IF_VOP3;    // 1101 00.. ...\n                case 0xDC000000: return IF_FLAT;    // 1101 11.. ....\n                case 0xD8000000: return IF_DS;      // 1101 10.. ....\n                case 0xE0000000: return IF_MUBUFF;  // 1110 00..\n                case 0xE8000000: return IF_MTBUFF;  // 1110 10..\n                case 0xF0000000: return IF_MIMG;    // 1111 00..\n                case 0xF8000000: return IF_EXP;     // 1111 10..\n                default:\n                    switch( n & (0xF8000000) ) // 1111 1000 (5bit)\n                    {\n                    case 0xC0000000: return IF_SMRD; // 1100 0... ....\n                    case 0xB0000000: return IF_SOPK; // 1011 0.........\n                    case 0xB8000000: return IF_SOPK; // 1011 1.........\n                    default:\n                        if( (n & 0xC0000000) == 0x80000000 ) // 1100....\n                            return IF_SOP2; // 1000 ....\n                        if( !(n & 0x80000000) )\n                            return IF_VOP2; // 0......\n                    }\n                }\n            }\n        }\n\n        return IF_UNKNOWN;       \n    }\n\n    size_t GCN1Decoder::DetermineInstructionLength( const uint8* pLocation, InstructionFormat eEncoding )\n    {\n        switch( eEncoding )\n        {\n        case IF_VOP2:       return ((const _GCN1Decoder_INTERNAL::VOP2Instruction*)pLocation)->GetLength();\n        case IF_VOP1:       return ((const _GCN1Decoder_INTERNAL::VOP1Instruction*)pLocation)->GetLength();\n        case IF_VOPC:       return ((const _GCN1Decoder_INTERNAL::VOPCInstruction*)pLocation)->GetLength();\n        case IF_SOP2:       return ((const _GCN1Decoder_INTERNAL::SOP2Instruction*)pLocation)->GetLength();\n        case IF_SOPK:       return ((const _GCN1Decoder_INTERNAL::SOPKInstruction*)pLocation)->GetLength();\n        case IF_SOP1:       return ((const _GCN1Decoder_INTERNAL::SOP1Instruction*)pLocation)->GetLength();\n        case IF_SOPC:       return ((const _GCN1Decoder_INTERNAL::SOPCInstruction*)pLocation)->GetLength();\n        case IF_SMRD:       return ((const _GCN1Decoder_INTERNAL::SMRDInstruction*)pLocation)->GetLength();\n\n        case IF_SOPP:\n        case IF_VINTERP:    \n            return 4;\n\n        case IF_DS:         \n        case IF_VOP3:       \n        case IF_MTBUFF:     \n        case IF_MUBUFF:     \n        case IF_MIMG:       \n        case IF_EXP:        \n        case IF_FLAT:       \n            return 8;\n\n        case IF_UNKNOWN:  \n        default:\n            return 0;\n        }\n    }\n\n    void GCN1Decoder::Decode( Instruction* pInst, const uint8* pLocation, InstructionFormat eEncoding ) \n    {\n        memset(pInst,0,sizeof(*pInst));\n\n        switch( eEncoding )\n        {     \n        case IF_SOP2:       \n        case IF_SOPK:       \n        case IF_SOP1:       \n        case IF_SOPC:       \n        case IF_SOPP:\n            pInst->m_eClass = IC_SCALAR;\n            break;\n        case IF_SMRD:  \n            pInst->m_eClass = IC_SCALAR_MEM;\n            break;\n            \n        case IF_VOP2:       \n        case IF_VOP1:       \n        case IF_VOPC:  \n        case IF_VOP3:  \n            pInst->m_eClass = IC_VECTOR;\n            break;\n        case IF_VINTERP:  \n            pInst->m_eClass = IC_VECTOR_INTERP;\n            break;\n        case IF_DS:   \n            pInst->m_eClass = IC_DS;\n            break;\n        case IF_MTBUFF: \n        case IF_MUBUFF:  \n            pInst->m_eClass = IC_BUFFER;\n            break;\n\n        case IF_MIMG:      \n            pInst->m_eClass = IC_IMAGE;\n            break;\n        case IF_EXP:\n            pInst->m_eClass = IC_EXPORT;\n            break;\n\n        case IF_FLAT:       \n        case IF_UNKNOWN:  \n        default:\n            pInst->m_eClass = IC_INVALID;\n        }\n        \n\n\n\n        using namespace _GCN1Decoder_INTERNAL;\n        switch( eEncoding )\n        {\n        case IF_SOP2:       \n            {\n                auto* pIt = (const SOP2Instruction*)pLocation;\n                auto& Fields          = pInst->Fields.Scalar;\n                pInst->m_eClass       = IC_SCALAR;\n                Fields.m_Dest         = pIt->GetDest();\n                Fields.m_eOpcode      = pIt->GetOpcode();\n                Fields.m_nSourceCount = 2;\n                Fields.m_Sources[0]   = pIt->GetSrc0();\n                Fields.m_Sources[1]   = pIt->GetSrc1();\n                if( pIt->HasLiteral() )\n                    Fields.m_Literal.UInt = pIt->ReadTrailingLiteral();\n            }\n            break;\n        case IF_SOPK: \n            {\n                auto* pIt = (const SOPKInstruction*) pLocation;\n                auto& Fields = pInst->Fields.Scalar;\n                Fields.m_Dest          = pIt->GetDest();\n                Fields.m_eOpcode       = pIt->GetOpcode();\n                Fields.m_nSourceCount  = 0;\n                Fields.m_nSIMM16       = pIt->ReadSIMM16();\n                Fields.m_pBranchTarget = pIt->GetBranchTarget();\n                if( pIt->HasLiteral() )\n                    Fields.m_Literal.UInt = pIt->ReadTrailingLiteral();\n            }\n            break;\n        case IF_SOP1:       \n            {\n                auto* pIt = (const SOP1Instruction*) pLocation;\n                auto& Fields = pInst->Fields.Scalar;\n                Fields.m_Dest         = pIt->GetDest();\n                Fields.m_eOpcode      = pIt->GetOpcode();\n                Fields.m_nSourceCount = 1;\n                Fields.m_Sources[0]   = pIt->GetSrc0();\n                if( pIt->HasLiteral())\n                    Fields.m_Literal.UInt = pIt->ReadTrailingLiteral();\n            }\n            break;\n        case IF_SOPC: \n            {\n                auto* pIt = (const SOPCInstruction*) pLocation;\n                auto& Fields = pInst->Fields.Scalar;\n                Fields.m_eOpcode = pIt->GetOpcode();\n                Fields.m_Dest = pIt->GetDest();\n                Fields.m_nSourceCount = 2;\n                Fields.m_Sources[0] = pIt->GetSrc0();\n                Fields.m_Sources[1] = pIt->GetSrc1();\n                if( pIt->HasLiteral() )\n                    Fields.m_Literal.UInt = pIt->ReadTrailingLiteral();\n            }\n            break;\n        case IF_SOPP:    \n            {\n                auto* pIt = (const SOPPInstruction*) pLocation;\n                auto& Fields = pInst->Fields.Scalar;\n                Fields.m_eOpcode= pIt->GetOpcode();\n                Fields.m_Dest = DEST_INVALID;\n                Fields.m_nSourceCount = 0;\n                Fields.m_nSIMM16 = pIt->ReadSIMM16();\n                Fields.m_pBranchTarget = pIt->GetBranchTarget();\n            }\n            break;\n        case IF_SMRD: \n            {\n                auto* pIt = (const SMRDInstruction*) pLocation;\n                auto& Fields = pInst->Fields.ScalarMem;\n                Fields.m_bIsOffsetIMM = pIt->IsOffsetIMM();\n                Fields.m_eOpcode      = pIt->GetOpcode();\n                Fields.m_Dest         = pIt->GetDest();\n                Fields.m_nBaseReg     = pIt->GetBase();\n                Fields.m_nOffset      = pIt->GetOffset();\n                Fields.m_bIsGLC       = false;\n            }\n            break;\n\n        case IF_VOP2: \n            {\n                auto* pIt = (const VOP2Instruction*) pLocation;\n                auto& Fields = pInst->Fields.Vector;\n                Fields.m_eOpcode = pIt->GetOpcode();\n                Fields.m_nSrcCount  = 2;\n                Fields.m_nDestCount = 1;\n                Fields.m_Sources[0] = pIt->GetSrc0();\n                Fields.m_Sources[1] = pIt->GetVSrc1();\n                Fields.m_Dests[0] = pIt->GetVDst();\n                if( pIt->HasLiteral() )\n                    Fields.m_Literal.UInt = pIt->ReadTrailingLiteral();\n            }\n            break;\n        case IF_VOP1:       \n            {\n                auto* pIt = (const VOP1Instruction*) pLocation;\n                auto& Fields = pInst->Fields.Vector;\n                Fields.m_eOpcode = pIt->GetOpcode();\n                Fields.m_nSrcCount  = 1;\n                Fields.m_nDestCount = 1;\n                Fields.m_Sources[0] = pIt->GetSrc0();\n                Fields.m_Dests[0] = pIt->GetDst();\n                if( pIt->HasLiteral() )\n                    Fields.m_Literal.UInt = pIt->ReadTrailingLiteral();\n            }\n            break;\n        case IF_VOPC:       \n            {\n                auto* pIt = (const VOPCInstruction*) pLocation;\n                auto& Fields = pInst->Fields.Vector;\n                Fields.m_eOpcode = pIt->GetOpcode();\n                Fields.m_nSrcCount  = 2;\n                Fields.m_nDestCount = 1;\n                Fields.m_Sources[0] = pIt->GetSrc0();\n                Fields.m_Sources[1] = pIt->GetVSrc1();\n                Fields.m_Dests[0]   = DEST_VCC;\n                if( pIt->HasLiteral() )\n                    Fields.m_Literal.UInt = pIt->ReadTrailingLiteral();\n            }\n            break;\n        case IF_VOP3:      \n            {\n                auto* pIt = (const VOP3Instruction*) pLocation;\n                auto& Fields = pInst->Fields.Vector;\n                Fields.m_eOpcode = pIt->GetOpcode();\n                \n                if( pIt->IsVOP3bOp() )\n                {\n                    Fields.m_nDestCount = 2;\n                    Fields.m_Dests[0] = pIt->GetVDst();\n                    Fields.m_Dests[1] = pIt->GetSDst();\n                }\n                else\n                {\n                    Fields.m_nDestCount = 1;\n                    Fields.m_Dests[0] = pIt->GetVDst();\n                    Fields.m_nClamp = pIt->GetClamp();\n                    Fields.m_nSourceAbs = pIt->GetSourceAbsMask();\n                }\n\n                Fields.m_nSourceNegate= pIt->GetSourceNegateMask();\n                Fields.m_nOMOD = pIt->GetOMod();\n                Fields.m_nSrcCount  = GetSourceCountForInstruction( Fields.m_eOpcode );\n                Fields.m_Sources[0] = pIt->GetSrc0();\n                Fields.m_Sources[1] = pIt->GetSrc1();\n                Fields.m_Sources[2] = pIt->GetSrc2();\n            }\n            break;\n\n        case IF_VINTERP:\n            {\n                auto* pIt = (const VINTERPInstruction*) pLocation;\n                auto& Fields = pInst->Fields.Interp;\n                Fields.m_eOpcode = pIt->GetOpcode();\n                Fields.m_nAttributeChannel = pIt->GetAttributeChannel();\n                Fields.m_nAttributeIndex = pIt->GetAttributeIndex();\n                Fields.m_VDst = pIt->GetVDst();\n                Fields.m_VSrc = pIt->GetVSrc0();\n            }\n            break;\n\n        case IF_EXP:        \n            {\n                auto* pIt = (const EXPInstruction*) pLocation;\n                auto& Fields = pInst->Fields.Export;\n                Fields.m_ChannelMask = pIt->GetExportMask();\n                Fields.m_Compress = pIt->GetCompressBit();\n                Fields.m_Done = pIt->GetDoneBit();\n                Fields.m_eTarget    = pIt->GetTarget();\n                Fields.m_ValidMask  = pIt->GetValidMaskBit();\n                Fields.m_Sources[0] = pIt->GetVSrc0();\n                Fields.m_Sources[1] = pIt->GetVSrc1();\n                Fields.m_Sources[2] = pIt->GetVSrc2();\n                Fields.m_Sources[3] = pIt->GetVSrc3();\n            }\n            break;\n        \n        case IF_DS:       \n            {\n                auto* pIt = (const DSInstruction*) pLocation;\n                auto& Fields = pInst->Fields.DS;\n                Fields.m_bGDS = pIt->IsGDS();\n                Fields.m_Dest = pIt->GetVDest();\n                Fields.m_eOpcode = pIt->GetOpcode();\n                Fields.m_nOffset0 = pIt->GetOffset0();\n                Fields.m_nOffset1 = pIt->GetOffset1();\n                Fields.m_nOffset16 = pIt->GetOffset16();\n                Fields.m_VAddr = pIt->GetVAddr();\n                Fields.m_VData0 = pIt->GetVData0();\n                Fields.m_VData1 = pIt->GetVData1();\n            }\n            break;\n\n        case IF_MTBUFF:     \n            {\n                auto* pIt = (const MTBUFFInstruction*) pLocation;\n                auto& Fields = pInst->Fields.Buffer;\n                Fields.m_bAddr64 = pIt->IsAddr64();\n                Fields.m_bGLC = pIt->GetGLCBit();\n                Fields.m_bIdxN = pIt->IsIdxN();\n                Fields.m_bLDSDirect = 0;\n                Fields.m_bOffN = pIt->IsOffN();\n                Fields.m_bSLC = pIt->GetSLCBit();\n                Fields.m_bTFE = pIt->GetTFEBit();\n                Fields.m_eDataFormat = pIt->GetDataFormat();\n                Fields.m_eNumberFormat = pIt->GetNumberFormat();\n                Fields.m_eOpcode = pIt->GetOpcode();\n                Fields.m_nOffset = pIt->GetOffset();\n                Fields.m_SOffset = pIt->GetSOffset();\n                Fields.m_SResource = pIt->GetSResource();\n                Fields.m_VAddr = pIt->GetVAddr();\n                Fields.m_VData = pIt->GetVData();\n            }\n            break;\n\n        case IF_MUBUFF:    \n            {\n                auto* pIt = (const MUBUFFInstruction*) pLocation;\n                auto& Fields = pInst->Fields.Buffer;\n                Fields.m_bAddr64 = pIt->IsAddr64();\n                Fields.m_bGLC = pIt->GetGLCBit();\n                Fields.m_bIdxN = pIt->IsIdxN();\n                Fields.m_bLDSDirect = pIt->IsDirectToLDS();\n                Fields.m_bOffN = pIt->IsOffN();\n                Fields.m_bSLC = pIt->GetSLCBit();\n                Fields.m_bTFE = pIt->GetTFEBit();\n                Fields.m_eOpcode = pIt->GetOpcode();\n                Fields.m_nOffset = pIt->GetOffset();\n                Fields.m_SOffset = pIt->GetSOffset();\n                Fields.m_SResource = pIt->GetSResource();\n                Fields.m_VAddr = pIt->GetVAddr();\n                Fields.m_VData = pIt->GetVData();\n            }\n            break;\n\n        case IF_MIMG:     \n            {\n                auto* pIt = (const MIMGInstruction*) pLocation;\n                auto& Fields = pInst->Fields.Image;\n                Fields.m_bArray = pIt->IsArray();\n                Fields.m_bGLC = pIt->IsGLC();\n                Fields.m_bLWE = pIt->IsLWE();\n                Fields.m_bRes256 = pIt->IsRes256();\n                Fields.m_bSLC = pIt->IsSLC();\n                Fields.m_bTFE = pIt->IsTFE();\n                Fields.m_bUnnormalized = pIt->IsUnormalized();\n                Fields.m_eOpcode = pIt->GetOpcode();\n                Fields.m_nDMask = pIt->GetDMask();\n                Fields.m_SResource = pIt->GetSResource();\n                Fields.m_SSampler = pIt->GetSSampler();\n                Fields.m_VAddr = pIt->GetVAddr();\n                Fields.m_VData = pIt->GetVData();\n                Fields.m_bIsD16 = 0;\n            }\n            break;\n\n        case IF_FLAT:               \n        default:\n            return;\n        }\n    }\n\n\n\n\n}"
  },
  {
    "path": "src/Wrapper/GCN1Decoder.h",
    "content": "//\n//    Decoder for early GCN chips (SI and CI)\n//\n//      Copyright 2015 Joshua Barczak, all rights reserved.\n//\n#ifndef _GCN1_DECODER_H_\n#define _GCN1_DECODER_H_\n#pragma once\n\n#include \"GCNDecoder.h\"\n\nnamespace GCN\n{\n    class GCN1Decoder : public IDecoder\n    {\n    public:\n        virtual InstructionFormat ReadInstructionFormat( const uint8* pLocation );\n        virtual size_t DetermineInstructionLength( const uint8* pLocation, InstructionFormat eEncoding );\n        virtual void Decode( Instruction* pInst, const uint8* pLocation, InstructionFormat eEncoding ) ;\n    };\n}\n\n#endif"
  },
  {
    "path": "src/Wrapper/GCN3Decoder.cpp",
    "content": "\n#pragma unmanaged\n#include \"GCNEnums.h\"\n#include \"GCNIsa.h\"\n#include \"GCN3Decoder.h\"\n#include <string.h>\n#include <math.h>\n\nnamespace GCN{\nnamespace _GCN3Decoder_INTERNAL\n{\n    struct EnumLUT\n    {\n        uint eEnum;\n        uint  nEncoding;\n    };\n\n    static uint LUTLookup( const EnumLUT* pLUT, size_t nLUTSize,uint en, uint TInvalid )\n    {\n        size_t n = nLUTSize/sizeof(EnumLUT);\n        for( size_t i=0; i<n; i++ ) \n            if( pLUT[i].nEncoding == en ) \n                return pLUT[i].eEnum; \n        return TInvalid;\n    }\n\n#define BEGIN_TRANSLATOR(T,Name) static const EnumLUT LUT_##T_##Name[] = {\n#define ENUM(Enum,Value) { Enum, Value },\n#define END_TRANSLATOR(T,Name,TInvalid) \\\n    };\\\n    T Translate_##Name( uint en ) {\\\n        const EnumLUT* pLUT = LUT_##T_##Name;\\\n        size_t n = sizeof(LUT_##T_##Name);\\\n        return (T) LUTLookup(pLUT,n,en,TInvalid);\\\n    };\n\n\n\n    BEGIN_TRANSLATOR(ScalarInstructions,SOP2Opcodes)\n        ENUM( S_ADD_U32             ,        0 )\n        ENUM( S_SUB_U32             ,        1 )\n        ENUM( S_ADD_I32             ,        2 )\n        ENUM( S_SUB_I32             ,        3 )\n        ENUM( S_ADDC_U32            ,        4 )\n        ENUM( S_SUBB_U32            ,        5 )\n        ENUM( S_MIN_I32             ,        6 )\n        ENUM( S_MIN_U32             ,        7 )\n        ENUM( S_MAX_I32             ,        8 )\n        ENUM( S_MAX_U32             ,        9 )\n        ENUM( S_CSELECT_B32         ,        10)\n        ENUM( S_CSELECT_B64         ,        11)\n        ENUM( S_AND_B32             ,        12)\n        ENUM( S_AND_B64             ,        13)\n        ENUM( S_OR_B32              ,        14)\n        ENUM( S_OR_B64              ,        15)\n        ENUM( S_XOR_B32             ,        16)\n        ENUM( S_XOR_B64             ,        17)\n        ENUM( S_ANDN2_B32           ,        18)\n        ENUM( S_ANDN2_B64           ,        19)\n        ENUM( S_ORN2_B32            ,        20)\n        ENUM( S_ORN2_B64            ,        21)\n        ENUM( S_NAND_B32            ,        22)\n        ENUM( S_NAND_B64            ,        23)\n        ENUM( S_NOR_B32             ,        24)\n        ENUM( S_NOR_B64             ,        25)\n        ENUM( S_XNOR_B32            ,        26)\n        ENUM( S_XNOR_B64            ,        27)\n        ENUM( S_LSHL_B32            ,        28)\n        ENUM( S_LSHL_B64            ,        29)\n        ENUM( S_LSHR_B32            ,        30)\n        ENUM( S_LSHR_B64            ,        31)\n        ENUM( S_ASHR_I32            ,        32)\n        ENUM( S_ASHR_I64            ,        33)\n        ENUM( S_BFM_B32             ,        34)\n        ENUM( S_BFM_B64             ,        35)\n        ENUM( S_MUL_I32             ,        36)\n        ENUM( S_BFE_U32             ,        37)\n        ENUM( S_BFE_I32             ,        38)\n        ENUM( S_BFE_U64             ,        39)\n        ENUM( S_BFE_I64             ,        40)\n        ENUM( S_CBRANCH_G_FORK      ,        41)\n        ENUM( S_ABSDIFF_I32         ,        42)\n        ENUM( S_RFE_RESTORE_B64     ,        43)\n    END_TRANSLATOR(ScalarInstructions,SOP2Opcodes,S_INVALID);\n\n\n    BEGIN_TRANSLATOR(ScalarInstructions,SOPKOpcodes)\n        ENUM( S_MOVK_I32            , 0     )\n        ENUM( S_CMOVK_I32           , 1     )\n        ENUM( S_CMPK_EQ_I32         , 2     )\n        ENUM( S_CMPK_LG_I32         , 3     )\n        ENUM( S_CMPK_GT_I32         , 4     )\n        ENUM( S_CMPK_GE_I32         , 5     )\n        ENUM( S_CMPK_LT_I32         , 6     )\n        ENUM( S_CMPK_LE_I32         , 7     )\n        ENUM( S_CMPK_EQ_U32         , 8     )\n        ENUM( S_CMPK_LG_U32         , 9     )\n        ENUM( S_CMPK_GT_U32         , 10    )\n        ENUM( S_CMPK_GE_U32         , 11    )\n        ENUM( S_CMPK_LT_U32         , 12    )\n        ENUM( S_CMPK_LE_U32         , 13    )\n        ENUM( S_ADDK_I32            , 14    )\n        ENUM( S_MULK_I32            , 15    )\n        ENUM( S_CBRANCH_I_FORK      , 16    )\n        ENUM( S_GETREG_B32          , 17    )\n        ENUM( S_SETREG_B32          , 18    )\n        ENUM( S_SETREG_IMM32_B32    , 20    )\n    END_TRANSLATOR(ScalarInstructions,SOPKOpcodes,S_INVALID);\n\n    BEGIN_TRANSLATOR(ScalarInstructions,SOP1Opcodes)\n        ENUM(   S_MOV_B32              , 0   )\n        ENUM(   S_MOV_B64              , 1   )\n        ENUM(   S_CMOV_B32             , 2   )\n        ENUM(   S_CMOV_B64             , 3   )\n        ENUM(   S_NOT_B32              , 4   )\n        ENUM(   S_NOT_B64              , 5   )\n        ENUM(   S_WQM_B32              , 6   )\n        ENUM(   S_WQM_B64              , 7   )\n        ENUM(   S_BREV_B32             , 8   )\n        ENUM(   S_BREV_B64             , 9   )\n        ENUM(   S_BCNT0_I32_B32        , 10  )\n        ENUM(   S_BCNT0_I32_B64        , 11  )\n        ENUM(   S_BCNT1_I32_B32        , 12  )\n        ENUM(   S_BCNT1_I32_B64        , 13  )\n        ENUM(   S_FF0_I32_B32          , 14  )\n        ENUM(   S_FF0_I32_B64          , 15  )\n        ENUM(   S_FF1_I32_B32          , 16  )\n        ENUM(   S_FF1_I32_B64          , 17  )\n        ENUM(   S_FLBIT_I32_B32        , 18  )\n        ENUM(   S_FLBIT_I32_B64        , 19  )\n        ENUM(   S_FLBIT_I32            , 20  )\n        ENUM(   S_FLBIT_I32_I64        , 21  )\n        ENUM(   S_SEXT_I32_I8          , 22  )\n        ENUM(   S_SEXT_I32_I16         , 23  )\n        ENUM(   S_BITSET0_B32          , 24  )\n        ENUM(   S_BITSET0_B64          , 25  )\n        ENUM(   S_BITSET1_B32          , 26  )\n        ENUM(   S_BITSET1_B64          , 27  )\n        ENUM(   S_GETPC_B64            , 28  )\n        ENUM(   S_SETPC_B64            , 29  )\n        ENUM(   S_SWAPPC_B64           , 30  )\n        ENUM(   S_RFE_B64              , 31  )\n        ENUM(   S_AND_SAVEEXEC_B64     , 32  )\n        ENUM(   S_OR_SAVEEXEC_B64      , 33  )\n        ENUM(   S_XOR_SAVEEXEC_B64     , 34  )\n        ENUM(   S_ANDN2_SAVEEXEC_B64   , 35  )\n        ENUM(   S_ORN2_SAVEEXEC_B64    , 36  )\n        ENUM(   S_NAND_SAVEEXEC_B64    , 37  )\n        ENUM(   S_NOR_SAVEEXEC_B64     , 38  )\n        ENUM(   S_XNOR_SAVEEXEC_B64    , 39  )\n        ENUM(   S_QUADMASK_B32         , 40  )\n        ENUM(   S_QUADMASK_B64         , 41  )\n        ENUM(   S_MOVRELS_B32          , 42  )\n        ENUM(   S_MOVRELS_B64          , 43  )\n        ENUM(   S_MOVRELD_B32          , 44  )\n        ENUM(   S_MOVRELD_B64          , 45  )\n        ENUM(   S_CBRANCH_JOIN         , 46  )\n        ENUM(   S_ABS_I32              , 48  )\n        ENUM(   S_SET_GPR_IDX_IDX      , 49  )\n    END_TRANSLATOR(ScalarInstructions,SOP1Opcodes,S_INVALID)\n\n\n    BEGIN_TRANSLATOR(ScalarInstructions,SOPCOpcodes)\n        ENUM( S_CMP_EQ_I32     ,0 )   //: SCC = (S0.i == S1.i).\n        ENUM( S_CMP_LG_I32     ,1 )   //: SCC = (S0.i != S1.i).\n        ENUM( S_CMP_GT_I32     ,2 )   //: SCC = (S0.i > S1.i).\n        ENUM( S_CMP_GE_I32     ,3 )   //: SCC = (S0.i >= S1.i).\n        ENUM( S_CMP_LT_I32     ,4 )   //: SCC = (S0.i < S1.i).\n        ENUM( S_CMP_LE_I32     ,5 )   //: SCC = (S0.i <= S1.i).\n        ENUM( S_CMP_EQ_U32     ,6 )   //: SCC = (S0.u == S1.u).\n        ENUM( S_CMP_LG_U32     ,7 )   //: SCC = (S0.u != S1.u).\n        ENUM( S_CMP_GT_U32     ,8 )   //: SCC = (S0.u > S1.u).\n        ENUM( S_CMP_GE_U32     ,9 )   //: SCC = (S0.u >= S1.u).\n        ENUM( S_CMP_LT_U32     ,10)   //: SCC = (S0.u < S1.u).\n        ENUM( S_CMP_LE_U32     ,11)   //: SCC = (S0.u <= S1.u).\n        ENUM( S_BITCMP0_B32    ,12)   //: SCC = (S0.u[S1.u[4:0]] == 0).\n        ENUM( S_BITCMP1_B32    ,13)   //: SCC = (S0.u[S1.u[4:0]] == 1).\n        ENUM( S_BITCMP0_B64    ,14)   //: SCC = (S0.u[S1.u[5:0]] == 0).\n        ENUM( S_BITCMP1_B64    ,15)   //: SCC = (S0.u[S1.u[5:0]] == 1).\n        ENUM( S_SETVSKIP       ,16)   //: VSKIP = S0.u[S1.u[4:0]].\n        ENUM( S_SET_GPR_IDX_ON    , 17  )\n        ENUM( S_CMP_EQ_U64        , 18  )\n        ENUM( S_CMP_NE_U64        , 19  )\n    END_TRANSLATOR(ScalarInstructions,SOPCOpcodes,S_INVALID)\n\n\n    BEGIN_TRANSLATOR(ScalarInstructions,SOPPOpcodes)\n        ENUM(S_NOP                      ,0  )  //: do nothing. Repeat NOP 1..8 times based on SIMM16[2:0]. 0 = 1 time, 7 = 8 times.\n        ENUM(S_ENDPGM                   ,1  )  //: end of program; terminate wavefront.\n        ENUM(S_BRANCH                   ,2  )  //: PC = PC + signext(SIMM16 * 4) + 4.\n        ENUM(S_CBRANCH_SCC0             ,4  )  //: if(SCC == 0) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n        ENUM(S_CBRANCH_SCC1             ,5  )  //: if(SCC == 1) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n        ENUM(S_CBRANCH_VCCZ             ,6  )  //: if(VCC == 0) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n        ENUM(S_CBRANCH_VCCNZ            ,7  )  //: if(VCC != 0) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n        ENUM(S_CBRANCH_EXECZ            ,8  )  //: if(EXEC == 0) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n        ENUM(S_CBRANCH_EXECNZ           ,9  )  //: if(EXEC != 0) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n        ENUM(S_BARRIER                  ,10 )  //: Sync waves within a thread group.\n        ENUM(S_SETKILL                  ,11 )\n        ENUM(S_WAITCNT                  ,12 )  //: Wait for count of outstanding lds, vector-memory and\n        ENUM(S_SETHALT                  ,13 )  //: set HALT bit to value of SIMM16[0]. 1=halt, 0=resume. Halt is ignored while priv=1.\n        ENUM(S_SLEEP                    ,14 )  //: Cause a wave to sleep for approximately 64*SIMM16[2:0] clocks.\n        ENUM(S_SETPRIO                  ,15 )  //: User settable wave priority. 0 = lowest, 3 = highest.\n        ENUM(S_SENDMSG                  ,16 )  //: Send a message.\n        ENUM(S_SENDMSGHALT              ,17 )  //: Send a message and then HALT.\n        ENUM(S_TRAP                     ,18 )  //: Enter the trap handler. TrapID = SIMM16[7:0]. Wait for all instructions to complete, \n        ENUM(S_ICACHE_INV               ,19 )  //: Invalidate entire L1 I cache.\n        ENUM(S_INCPERFLEVEL             ,20 )  //: Increment performance counter specified in SIMM16[3:0] by 1.\n        ENUM(S_DECPERFLEVEL             ,21 )  //: Decrement performance counter specified in SIMM16[3:0] by 1.\n        ENUM(S_TTRACEDATA               ,22 )  //: Send M0 as user data to thread-trace.\n        ENUM(S_CBRANCH_CDBGSYS          ,23 )// : If (conditional_debug_system != 0) then PC = PC + signext(SIMM16 * 4) + 4; else NOP.\n        ENUM(S_CBRANCH_CDBGUSER         ,24 )// : If (conditional_debug_user != 0) then PC = PC + signext(SIMM16 * 4) + 4; else NOP.\n        ENUM(S_CBRANCH_CDBGSYS_OR_USER  ,25 )// : If (conditional_debug_system || conditional_debug_user) then PC = PC + signext(SIMM16 * 4) + 4; else NOP.\n        ENUM(S_CBRANCH_CDBGSYS_AND_USER ,26 )// : If (conditional_debug_system && conditional_debug_user) then PC = PC + signext(SIMM16 * 4) + 4; else NOP.\n        ENUM( S_ENDPGM_SAVED     , 27 ) \n        ENUM( S_SET_GPR_IDX_OFF  , 28 ) \n        ENUM( S_SET_GPR_IDX_MODE , 29 ) \n        \n    END_TRANSLATOR(ScalarInstructions,SOPPOpcodes,S_INVALID)\n\n    BEGIN_TRANSLATOR(ScalarMemoryInstructions,SMEMOpcodes)\n       ENUM(  S_LOAD_DWORD                , 0   )\n       ENUM(  S_LOAD_DWORDX2              , 1   )\n       ENUM(  S_LOAD_DWORDX4              , 2   )\n       ENUM(  S_LOAD_DWORDX8              , 3   )\n       ENUM(  S_LOAD_DWORDX16             , 4   )\n       ENUM(  S_BUFFER_LOAD_DWORD         , 8   )\n       ENUM(  S_BUFFER_LOAD_DWORDX2       , 9   )\n       ENUM(  S_BUFFER_LOAD_DWORDX4       , 10  )\n       ENUM(  S_BUFFER_LOAD_DWORDX8       , 11  )\n       ENUM(  S_BUFFER_LOAD_DWORDX16      , 12  )\n       ENUM(  S_STORE_DWORD               , 16  )\n       ENUM(  S_STORE_DWORDX2             , 17  )\n       ENUM(  S_STORE_DWORDX4             , 18  )\n       ENUM(  S_BUFFER_STORE_DWORD        , 24  )\n       ENUM(  S_BUFFER_STORE_DWORDX2      , 25  )\n       ENUM(  S_BUFFER_STORE_DWORDX4      , 26  )\n       ENUM(  S_DCACHE_INV                , 32  )\n       ENUM(  S_DCACHE_WB                 , 33  )\n       ENUM(  S_DCACHE_INV_VOL            , 34  )\n       ENUM(  S_DCACHE_WB_VOL             , 35  )\n       ENUM(  S_MEMTIME                   , 36  )\n       ENUM(  S_MEMREALTIME               , 37  )\n       ENUM(  S_ATC_PROBE                 , 38  )\n       ENUM(  S_ATC_PROBE_BUFFER          , 39  )\n    END_TRANSLATOR(ScalarMemoryInstructions,SMEMOpcodes,S_INVALID)\n\n\n    BEGIN_TRANSLATOR(VectorInstructions,VOP2Opcodes)\n       ENUM( V_CNDMASK_B32          , 0  )\n       ENUM( V_ADD_F32              , 1  )\n       ENUM( V_SUB_F32              , 2  )\n       ENUM( V_SUBREV_F32           , 3  )\n       ENUM( V_MUL_LEGACY_F32       , 4  )\n       ENUM( V_MUL_F32              , 5  )\n       ENUM( V_MUL_I32_I24          , 6  )\n       ENUM( V_MUL_HI_I32_I24       , 7  )\n       ENUM( V_MUL_U32_U24          , 8  )\n       ENUM( V_MUL_HI_U32_U24       , 9  )\n       ENUM( V_MIN_F32              , 10 )\n       ENUM( V_MAX_F32              , 11 )\n       ENUM( V_MIN_I32              , 12 )\n       ENUM( V_MAX_I32              , 13 )\n       ENUM( V_MIN_U32              , 14 )\n       ENUM( V_MAX_U32              , 15 )\n       ENUM( V_LSHRREV_B32          , 16 )\n       ENUM( V_ASHRREV_I32          , 17 )\n       ENUM( V_LSHLREV_B32          , 18 )\n       ENUM( V_AND_B32              , 19 )\n       ENUM( V_OR_B32               , 20 )\n       ENUM( V_XOR_B32              , 21 )\n       ENUM( V_MAC_F32              , 22 )\n       ENUM( V_MADMK_F32            , 23 )\n       ENUM( V_MADAK_F32            , 24 )\n       ENUM( V_ADD_U32              , 25 )\n       ENUM( V_SUB_U32              , 26 )\n       ENUM( V_SUBREV_U32           , 27 )\n       ENUM( V_ADDC_U32             , 28 )\n       ENUM( V_SUBB_U32             , 29 )\n       ENUM( V_SUBBREV_U32          , 30 )\n       ENUM( V_ADD_F16              , 31 )\n       ENUM( V_SUB_F16              , 32 )\n       ENUM( V_SUBREV_F16           , 33 )\n       ENUM( V_MUL_F16              , 34 )\n       ENUM( V_MAC_F16              , 35 )\n       ENUM( V_MADMK_F16            , 36 )\n       ENUM( V_MADAK_F16            , 37 )\n       ENUM( V_ADD_U16              , 38 )\n       ENUM( V_SUB_U16              , 39 )\n       ENUM( V_SUBREV_U16           , 40 )\n       ENUM( V_MUL_LO_U16           , 41 )\n       ENUM( V_LSHLREV_B16          , 42 )\n       ENUM( V_LSHRREV_B16          , 43 )\n       ENUM( V_ASHRREV_I16          , 44 )\n       ENUM( V_MAX_F16              , 45 )\n       ENUM( V_MIN_F16              , 46 )\n       ENUM( V_MAX_U16              , 47 )\n       ENUM( V_MAX_I16              , 48 )\n       ENUM( V_MIN_U16              , 49 )\n       ENUM( V_MIN_I16              , 50 )\n       ENUM( V_LDEXP_F16            , 51 )\n    END_TRANSLATOR(VectorInstructions,VOP2Opcodes,V_INVALID)\n\n\n    BEGIN_TRANSLATOR(VectorInstructions,VOP1Opcodes)\n        ENUM(  V_NOP                    , 0   )\n        ENUM(  V_MOV_B32                , 1   )\n        ENUM(  V_READFIRSTLANE_B32      , 2   )\n        ENUM(  V_CVT_I32_F64            , 3   )\n        ENUM(  V_CVT_F64_I32            , 4   )\n        ENUM(  V_CVT_F32_I32            , 5   )\n        ENUM(  V_CVT_F32_U32            , 6   )\n        ENUM(  V_CVT_U32_F32            , 7   )\n        ENUM(  V_CVT_I32_F32            , 8   )\n        ENUM(  V_CVT_F16_F32            , 10  )\n        ENUM(  V_CVT_F32_F16            , 11  )\n        ENUM(  V_CVT_RPI_I32_F32        , 12  )\n        ENUM(  V_CVT_FLR_I32_F32        , 13  )\n        ENUM(  V_CVT_OFF_F32_I4         , 14  )\n        ENUM(  V_CVT_F32_F64            , 15  )\n        ENUM(  V_CVT_F64_F32            , 16  )\n        ENUM(  V_CVT_F32_UBYTE0         , 17  )\n        ENUM(  V_CVT_F32_UBYTE1         , 18  )\n        ENUM(  V_CVT_F32_UBYTE2         , 19  )\n        ENUM(  V_CVT_F32_UBYTE3         , 20  )\n        ENUM(  V_CVT_U32_F64            , 21  )\n        ENUM(  V_CVT_F64_U32            , 22  )\n        ENUM(  V_TRUNC_F64              , 23  )\n        ENUM(  V_CEIL_F64               , 24  )\n        ENUM(  V_RNDNE_F64              , 25  )\n        ENUM(  V_FLOOR_F64              , 26  )\n        ENUM(  V_FRACT_F32              , 27  )\n        ENUM(  V_TRUNC_F32              , 28  )\n        ENUM(  V_CEIL_F32               , 29  )\n        ENUM(  V_RNDNE_F32              , 30  )\n        ENUM(  V_FLOOR_F32              , 31  )\n        ENUM(  V_EXP_F32                , 32  )\n        ENUM(  V_LOG_F32                , 33  )\n        ENUM(  V_RCP_F32                , 34  )\n        ENUM(  V_RCP_IFLAG_F32          , 35  )\n        ENUM(  V_RSQ_F32                , 36  )\n        ENUM(  V_RCP_F64                , 37  )\n        ENUM(  V_RSQ_F64                , 38  )\n        ENUM(  V_SQRT_F32               , 39  )\n        ENUM(  V_SQRT_F64               , 40  )\n        ENUM(  V_SIN_F32                , 41  )\n        ENUM(  V_COS_F32                , 42  )\n        ENUM(  V_NOT_B32                , 43  )\n        ENUM(  V_BFREV_B32              , 44  )\n        ENUM(  V_FFBH_U32               , 45  )\n        ENUM(  V_FFBL_B32               , 46  )\n        ENUM(  V_FFBH_I32               , 47  )\n        ENUM(  V_FREXP_EXP_I32_F64      , 48  )\n        ENUM(  V_FREXP_MANT_F64         , 49  )\n        ENUM(  V_FRACT_F64              , 50  )\n        ENUM(  V_FREXP_EXP_I32_F32      , 51  )\n        ENUM(  V_FREXP_MANT_F32         , 52  )\n        ENUM(  V_CLREXCP                , 53  )\n        ENUM(  V_MOVRELD_B32            , 54  )\n        ENUM(  V_MOVRELS_B32            , 55  )\n        ENUM(  V_MOVRELSD_B32           , 56  )\n        ENUM(  V_CVT_F16_U16            , 57  )\n        ENUM(  V_CVT_F16_I16            , 58  )\n        ENUM(  V_CVT_U16_F16            , 59  )\n        ENUM(  V_CVT_I16_F16            , 60  )\n        ENUM(  V_RCP_F16                , 61  )\n        ENUM(  V_SQRT_F16               , 62  )\n        ENUM(  V_RSQ_F16                , 63  )\n        ENUM(  V_LOG_F16                , 64  )\n        ENUM(  V_EXP_F16                , 65  )\n        ENUM(  V_FREXP_MANT_F16         , 66  )\n        ENUM(  V_FREXP_EXP_I16_F16      , 67  )\n        ENUM(  V_FLOOR_F16              , 68  )\n        ENUM(  V_CEIL_F16               , 69  )\n        ENUM(  V_TRUNC_F16              , 70  )\n        ENUM(  V_RNDNE_F16              , 71  )\n        ENUM(  V_FRACT_F16              , 72  )\n        ENUM(  V_SIN_F16                , 73  )\n        ENUM(  V_COS_F16                , 74  )\n        ENUM(  V_EXP_LEGACY_F32         , 75  )\n        ENUM(  V_LOG_LEGACY_F32         , 76  )        \n    END_TRANSLATOR(VectorInstructions,VOP1Opcodes,V_INVALID)\n\n    static VectorInstructions Translate_VOPCOpcodes( uint n )\n    {\n        switch( n & 0xf0 )\n        {\n        case 0x10:\n            switch( n & 0xf ) \n            {\n            case 0: return V_CMP_CLASS_F32;\n            case 1: return V_CMPX_CLASS_F32;\n            case 2: return V_CMP_CLASS_F64;\n            case 3: return V_CMPX_CLASS_F64;\n            case 4: return V_CMP_CLASS_F16;\n            case 5: return V_CMPX_CLASS_F16;\n            }\n        case 0X20: return (VectorInstructions)( V_CMP_F_F16  + (n&0xf)); \n        case 0x30: return (VectorInstructions)( V_CMPX_F_F16 + (n&0xf)); \n        case 0x40: return (VectorInstructions)( V_CMP_F_F32  + (n&0xf)); \n        case 0x50: return (VectorInstructions)( V_CMPX_F_F32 + (n&0xf)); \n        case 0x60: return (VectorInstructions)( V_CMP_F_F64  + (n&0xf)); \n        case 0x70: return (VectorInstructions)( V_CMPX_F_F64 + (n&0xf)); \n        default:\n            switch( n&0xf8 )\n            {\n            case 0xA0: return (VectorInstructions)( V_CMP_F_I16  + (n&0x7)); \n            case 0xA8: return (VectorInstructions)( V_CMP_F_U16  + (n&0x7)); \n            case 0xB0: return (VectorInstructions)( V_CMPx_F_I16 + (n&0x7)); \n            case 0xB8: return (VectorInstructions)( V_CMPx_F_U16 + (n&0x7)); \n            case 0xC0: return (VectorInstructions)( V_CMP_F_I32  + (n&0x7)); \n            case 0xC8: return (VectorInstructions)( V_CMP_F_U32  + (n&0x7)); \n            case 0xD0: return (VectorInstructions)( V_CMPX_F_I32 + (n&0x7)); \n            case 0xD8: return (VectorInstructions)( V_CMPX_F_U32 + (n&0x7)); \n            case 0xE0: return (VectorInstructions)( V_CMP_F_I64  + (n&0x7)); \n            case 0xE8: return (VectorInstructions)( V_CMP_F_U64  + (n&0x7)); \n            case 0xF0: return (VectorInstructions)( V_CMPX_F_I64 + (n&0x7)); \n            case 0xF8: return (VectorInstructions)( V_CMPx_F_U64 + (n&0x7)); \n            }\n        }\n        return V_INVALID;\n    }\n\n\n\n\n\n    BEGIN_TRANSLATOR(VectorInstructions,VOP3OpcodesExtra)\n       ENUM( V_MAD_LEGACY_F32      , 448   )\n       ENUM( V_MAD_F32             , 449   )\n       ENUM( V_MAD_I32_I24         , 450   )\n       ENUM( V_MAD_U32_U24         , 451   )\n       ENUM( V_CUBEID_F32          , 452   )\n       ENUM( V_CUBESC_F32          , 453   )\n       ENUM( V_CUBETC_F32          , 454   )\n       ENUM( V_CUBEMA_F32          , 455   )\n       ENUM( V_BFE_U32             , 456   )\n       ENUM( V_BFE_I32             , 457   )\n       ENUM( V_BFI_B32             , 458   )\n       ENUM( V_FMA_F32             , 459   )\n       ENUM( V_FMA_F64             , 460   )\n       ENUM( V_LERP_U8             , 461   )\n       ENUM( V_ALIGNBIT_B32        , 462   )\n       ENUM( V_ALIGNBYTE_B32       , 463   )\n       ENUM( V_MIN3_F32            , 464   )\n       ENUM( V_MIN3_I32            , 465   )\n       ENUM( V_MIN3_U32            , 466   )\n       ENUM( V_MAX3_F32            , 467   )\n       ENUM( V_MAX3_I32            , 468   )\n       ENUM( V_MAX3_U32            , 469   )\n       ENUM( V_MED3_F32            , 470   )\n       ENUM( V_MED3_I32            , 471   )\n       ENUM( V_MED3_U32            , 472   )\n       ENUM( V_SAD_U8              , 473   )\n       ENUM( V_SAD_HI_U8           , 474   )\n       ENUM( V_SAD_U16             , 475   )\n       ENUM( V_SAD_U32             , 476   )\n       ENUM( V_CVT_PK_U8_F32       , 477   )\n       ENUM( V_DIV_FIXUP_F32       , 478   )\n       ENUM( V_DIV_FIXUP_F64       , 479   )\n       ENUM( V_DIV_SCALE_F32       , 480   )  \n       ENUM( V_DIV_SCALE_F64       , 481   )                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           \n       ENUM( V_DIV_FMAS_F32        , 482   )\n       ENUM( V_DIV_FMAS_F64        , 483   )\n       ENUM( V_MSAD_U8             , 484   )\n       ENUM( V_QSAD_PK_U16_U8      , 485   )\n       ENUM( V_MQSAD_PK_U16_U8     , 486   )\n       ENUM( V_MQSAD_U32_U8        , 487   )\n       ENUM( V_MAD_U64_U32         , 488   )\n       ENUM( V_MAD_I64_I32         , 489   )\n       ENUM( V_MAD_F16             , 490   )\n       ENUM( V_MAD_U16             , 491   )\n       ENUM( V_MAD_I16             , 492   )\n       ENUM( V_PERM_B32            , 493   )\n       ENUM( V_FMA_F16             , 494   )\n       ENUM( V_DIV_FIXUP_F16       , 495   )\n       ENUM( V_CVT_PKACCUM_U8_F32  , 496   )\n       ENUM( V_INTERP_P1_F32       , 624   )\n       ENUM( V_INTERP_P2_F32       , 625   )\n       ENUM( V_INTERP_MOV_F32      , 626   )\n       ENUM( V_INTERP_P1LL_F16     , 628   )\n       ENUM( V_INTERP_P1LV_F16     , 629   )\n       ENUM( V_INTERP_P2_F16       , 630   )\n       ENUM( V_ADD_F64             , 640   )\n       ENUM( V_MUL_F64             , 641   )\n       ENUM( V_MIN_F64             , 642   )\n       ENUM( V_MAX_F64             , 643   )\n       ENUM( V_LDEXP_F64           , 644   )\n       ENUM( V_MUL_LO_U32          , 645   )\n       ENUM( V_MUL_HI_U32          , 646   )\n       ENUM( V_MUL_HI_I32          , 647   )\n       ENUM( V_LDEXP_F32           , 648   )\n       ENUM( V_READLANE_B32        , 649   )\n       ENUM( V_WRITELANE_B32       , 650   )\n       ENUM( V_BCNT_U32_B32        , 651   )\n       ENUM( V_MBCNT_LO_U32_B32    , 652   )\n       ENUM( V_MBCNT_HI_U32_B32    , 653   )\n       ENUM( V_LSHLREV_B64         , 655   )\n       ENUM( V_LSHRREV_B64         , 656   )\n       ENUM( V_ASHRREV_I64         , 657   )\n       ENUM( V_TRIG_PREOP_F64      , 658   )\n       ENUM( V_BFM_B32             , 659   )\n       ENUM( V_CVT_PKNORM_I16_F32  , 660   )\n       ENUM( V_CVT_PKNORM_U16_F32  , 661   )\n       ENUM( V_CVT_PKRTZ_F16_F32   , 662   )\n       ENUM( V_CVT_PK_U16_U32      , 663   )\n       ENUM( V_CVT_PK_I16_I32      , 664   )\n\n    END_TRANSLATOR(VectorInstructions,VOP3OpcodesExtra,V_INVALID)\n        \n    static VectorInstructions Translate_VOP3Opcodes( uint n )\n    {\n        if( n <= 255 )\n            return Translate_VOPCOpcodes(n);\n        if( n >= 256 && n <= 319 )\n            return Translate_VOP2Opcodes(n-256);\n        if( n >= 320 && n <= 447 )\n            return Translate_VOP1Opcodes(n-320);\n\n        return Translate_VOP3OpcodesExtra(n);\n    }\n\n    static VectorInstructions Translate_VINTERPOpcodes( uint n )\n    {\n        switch(n)\n        {\n        case 0: return V_INTERP_P1_F32  ; //  : D = P10 * S + P0; parameter interpolation.\n        case 1: return V_INTERP_P2_F32  ; //  : D = P20 * S + D; parameter interpolation.\n        case 2: return V_INTERP_MOV_F32 ; //  : D = {P10,P20,P0}[S]; parameter load.\n        default: return V_INVALID;\n        }\n    }\n\n\n\n    BEGIN_TRANSLATOR(DSInstructions,DSOpcodes)\n        ENUM( DS_ADD_U32              , 0   )  \n        ENUM( DS_SUB_U32              , 1   )\n        ENUM( DS_RSUB_U32             , 2   )\n        ENUM( DS_INC_U32              , 3   )\n        ENUM( DS_DEC_U32              , 4   )\n        ENUM( DS_MIN_I32              , 5   )\n        ENUM( DS_MAX_I32              , 6   )\n        ENUM( DS_MIN_U32              , 7   )\n        ENUM( DS_MAX_U32              , 8   )\n        ENUM( DS_AND_B32              , 9   )\n        ENUM( DS_OR_B32               , 10   )\n        ENUM( DS_XOR_B32              , 11   )\n        ENUM( DS_MSKOR_B32            , 12   )\n        ENUM( DS_WRITE_B32            , 13   )\n        ENUM( DS_WRITE2_B32           , 14   )\n        ENUM( DS_WRITE2ST64_B32       , 15   )\n        ENUM( DS_CMPST_B32            , 16   )\n        ENUM( DS_CMPST_F32            , 17   )\n        ENUM( DS_MIN_F32              , 18   )\n        ENUM( DS_MAX_F32              , 19   )\n        ENUM( DS_NOP                  , 20   )\n        ENUM( DS_ADD_F32              , 21   )\n        ENUM( DS_WRITE_B8             , 30   )\n        ENUM( DS_WRITE_B16            , 31   )\n        ENUM( DS_ADD_RTN_U32          , 32   )\n        ENUM( DS_SUB_RTN_U32          , 33   )\n        ENUM( DS_RSUB_RTN_U32         , 34   )\n        ENUM( DS_INC_RTN_U32          , 35   )\n        ENUM( DS_DEC_RTN_U32          , 36   )\n        ENUM( DS_MIN_RTN_I32          , 37   )\n        ENUM( DS_MAX_RTN_I32          , 38   )\n        ENUM( DS_MIN_RTN_U32          , 39   )\n        ENUM( DS_MAX_RTN_U32          , 40   )\n        ENUM( DS_AND_RTN_B32          , 41   )\n        ENUM( DS_OR_RTN_B32           , 42   )\n        ENUM( DS_XOR_RTN_B32          , 43   )\n        ENUM( DS_MSKOR_RTN_B32        , 44   )\n        ENUM( DS_WRXCHG_RTN_B32       , 45   )\n        ENUM( DS_WRXCHG2_RTN_B32      , 46   )\n        ENUM( DS_WRXCHG2ST64_RTN_B32  , 47   )\n        ENUM( DS_CMPST_RTN_B32        , 48   )\n        ENUM( DS_CMPST_RTN_F32        , 49   )\n        ENUM( DS_MIN_RTN_F32          , 50   )\n        ENUM( DS_MAX_RTN_F32          , 51   )\n        ENUM( DS_WRAP_RTN_B32         , 52   )\n        ENUM( DS_SWIZZLE_B32          , 61   )\n        ENUM( DS_READ_B32             , 54   )\n        ENUM( DS_READ2_B32            , 55   )\n        ENUM( DS_READ2ST64_B32        , 56   )\n        ENUM( DS_READ_I8              , 57   )\n        ENUM( DS_READ_U8              , 58   )\n        ENUM( DS_READ_I16             , 59   )\n        ENUM( DS_READ_U16             , 60   )\n        ENUM( DS_PERMUTE_B32          , 62   )\n        ENUM( DS_BPERMUTE_B32         , 63   )\n        ENUM( DS_ADD_U64              , 64   )\n        ENUM( DS_SUB_U64              , 65   )\n        ENUM( DS_RSUB_U64             , 66   )\n        ENUM( DS_INC_U64              , 67   )\n        ENUM( DS_DEC_U64              , 68   )\n        ENUM( DS_MIN_I64              , 69   )\n        ENUM( DS_MAX_I64              , 70   )\n        ENUM( DS_MIN_U64              , 71   )\n        ENUM( DS_MAX_U64              , 72   )\n        ENUM( DS_AND_B64              , 73   )\n        ENUM( DS_OR_B64               , 74   )\n        ENUM( DS_XOR_B64              , 75   )\n        ENUM( DS_MSKOR_B64            , 76   )\n        ENUM( DS_WRITE_B64            , 77   )\n        ENUM( DS_WRITE2_B64           , 78   )\n        ENUM( DS_WRITE2ST64_B64       , 79   )\n        ENUM( DS_CMPST_B64            , 80   )\n        ENUM( DS_CMPST_F64            , 81   )\n        ENUM( DS_MIN_F64              , 82   )\n        ENUM( DS_MAX_F64              , 83   )\n        ENUM( DS_ADD_RTN_U64          , 96   )\n        ENUM( DS_SUB_RTN_U64          , 97   )\n        ENUM( DS_RSUB_RTN_U64         , 98   )\n        ENUM( DS_INC_RTN_U64          , 99   )\n        ENUM( DS_DEC_RTN_U64          , 100  )\n        ENUM( DS_MIN_RTN_I64          , 101  )\n        ENUM( DS_MAX_RTN_I64          , 102  )\n        ENUM( DS_MIN_RTN_U64          , 103  )\n        ENUM( DS_MAX_RTN_U64          , 104  )\n        ENUM( DS_AND_RTN_B64          , 105  )\n        ENUM( DS_OR_RTN_B64           , 106  )\n        ENUM( DS_XOR_RTN_B64          , 107  )\n        ENUM( DS_MSKOR_RTN_B64        , 108  )\n        ENUM( DS_WRXCHG_RTN_B64       , 109  )\n        ENUM( DS_WRXCHG2_RTN_B64      , 110  )\n        ENUM( DS_WRXCHG2ST64_RTN_B64  , 111  )\n        ENUM( DS_CMPST_RTN_B64        , 112  )\n        ENUM( DS_CMPST_RTN_F64        , 113  )\n        ENUM( DS_MIN_RTN_F64          , 114  )\n        ENUM( DS_MAX_RTN_F64          , 115  )\n        ENUM( DS_READ_B64             , 118  )\n        ENUM( DS_READ2_B64            , 119  )\n        ENUM( DS_READ2ST64_B64        , 120  )\n        ENUM( DS_CONDXCHG32_RTN_B64   , 126  )\n        ENUM( DS_ADD_SRC2_U32         , 128  )\n        ENUM( DS_SUB_SRC2_U32         , 129  )\n        ENUM( DS_RSUB_SRC2_U32        , 130  )\n        ENUM( DS_INC_SRC2_U32         , 131  )\n        ENUM( DS_DEC_SRC2_U32         , 132  )\n        ENUM( DS_MIN_SRC2_I32         , 133  )\n        ENUM( DS_MAX_SRC2_I32         , 134  )\n        ENUM( DS_MIN_SRC2_U32         , 135  )\n        ENUM( DS_MAX_SRC2_U32         , 136  )\n        ENUM( DS_AND_SRC2_B32         , 137  )\n        ENUM( DS_OR_SRC2_B32          , 138  )\n        ENUM( DS_XOR_SRC2_B32         , 139  )\n        ENUM( DS_WRITE_SRC2_B32       , 140  )\n        ENUM( DS_MIN_SRC2_F32         , 146  )\n        ENUM( DS_MAX_SRC2_F32         , 147  )\n        ENUM( DS_GWS_SEMA_RELEASE_ALL , 152  )\n        ENUM( DS_GWS_INIT             , 153  )\n        ENUM( DS_GWS_SEMA_V           , 154  )\n        ENUM( DS_GWS_SEMA_BR          , 155  )\n        ENUM( DS_GWS_SEMA_P           , 156  )\n        ENUM( DS_GWS_BARRIER          , 157  )\n        ENUM( DS_CONSUME              , 189  )\n        ENUM( DS_APPEND               , 190  )\n        ENUM( DS_ORDERED_COUNT        , 191  )\n        ENUM( DS_ADD_SRC2_U64         , 192  )\n        ENUM( DS_SUB_SRC2_U64         , 193  )\n        ENUM( DS_RSUB_SRC2_U64        , 194  )\n        ENUM( DS_INC_SRC2_U64         , 195  )\n        ENUM( DS_DEC_SRC2_U64         , 196  )\n        ENUM( DS_MIN_SRC2_I64         , 197  )\n        ENUM( DS_MAX_SRC2_I64         , 198  )\n        ENUM( DS_MIN_SRC2_U64         , 199  )\n        ENUM( DS_MAX_SRC2_U64         , 200  )\n        ENUM( DS_AND_SRC2_B64         , 201  )\n        ENUM( DS_OR_SRC2_B64          , 202  )\n        ENUM( DS_XOR_SRC2_B64         , 203  )\n        ENUM( DS_WRITE_SRC2_B64       , 204  )\n        ENUM( DS_MIN_SRC2_F64         , 210  )\n        ENUM( DS_MAX_SRC2_F64         , 211  )\n        ENUM( DS_WRITE_B96            , 222  )\n        ENUM( DS_WRITE_B128           , 223  )\n        ENUM( DS_CONDXCHG32_RTN_B128  , 253  )\n        ENUM( DS_READ_B96             , 254  )\n        ENUM( DS_READ_B128            , 255  )   \n    END_TRANSLATOR(DSInstructions,DSOpcodes,DS_INVALID)\n\n\n    BEGIN_TRANSLATOR(BufferInstructions,MUBUFFOpcodes)\n       ENUM(BUFFER_LOAD_FORMAT_X        , 0  ) \n       ENUM(BUFFER_LOAD_FORMAT_XY       , 1  )  \n       ENUM(BUFFER_LOAD_FORMAT_XYZ      , 2  ) \n       ENUM(BUFFER_LOAD_FORMAT_XYZW     , 3  ) \n       ENUM(BUFFER_STORE_FORMAT_X       , 4  ) \n       ENUM(BUFFER_STORE_FORMAT_XY      , 5  ) \n       ENUM(BUFFER_STORE_FORMAT_XYZ     , 6  ) \n       ENUM(BUFFER_STORE_FORMAT_XYZW    , 7  ) \n       ENUM(BUFFER_LOAD_FORMAT_D16_X    , 8  ) \n       ENUM(BUFFER_LOAD_FORMAT_D16_XY   , 9  ) \n       ENUM(BUFFER_LOAD_FORMAT_D16_XYZ  , 10 ) \n       ENUM(BUFFER_LOAD_FORMAT_D16_XYZW , 11 ) \n       ENUM(BUFFER_STORE_FORMAT_D16_X   , 12 ) \n       ENUM(BUFFER_STORE_FORMAT_D16_XY  , 13 ) \n       ENUM(BUFFER_STORE_FORMAT_D16_XYZ , 14 ) \n       ENUM(BUFFER_STORE_FORMAT_D16_XYZW, 15 ) \n       ENUM(BUFFER_LOAD_UBYTE           , 16 ) \n       ENUM(BUFFER_LOAD_SBYTE           , 17 ) \n       ENUM(BUFFER_LOAD_USHORT          , 18 ) \n       ENUM(BUFFER_LOAD_SSHORT          , 19 ) \n       ENUM(BUFFER_LOAD_DWORD           , 20 ) \n       ENUM(BUFFER_LOAD_DWORDX2         , 21 ) \n       ENUM(BUFFER_LOAD_DWORDX3         , 22 ) \n       ENUM(BUFFER_LOAD_DWORDX4         , 23 ) \n       ENUM(BUFFER_STORE_BYTE           , 24 ) \n       ENUM(BUFFER_STORE_SHORT          , 26 ) \n       ENUM(BUFFER_STORE_DWORD          , 28 ) \n       ENUM(BUFFER_STORE_DWORDX2        , 29 ) \n       ENUM(BUFFER_STORE_DWORDX3        , 30 ) \n       ENUM(BUFFER_STORE_DWORDX4        , 31 ) \n       ENUM(BUFFER_STORE_LDS_DWORD      , 61 ) \n       ENUM(BUFFER_WBINVL1              , 62 ) \n       ENUM(BUFFER_WBINVL1_VOL          , 63 ) \n       ENUM(BUFFER_ATOMIC_SWAP          , 64 ) \n       ENUM(BUFFER_ATOMIC_CMPSWAP       , 65 ) \n       ENUM(BUFFER_ATOMIC_ADD           , 66 ) \n       ENUM(BUFFER_ATOMIC_SUB           , 67 ) \n       ENUM(BUFFER_ATOMIC_SMIN          , 68 ) \n       ENUM(BUFFER_ATOMIC_UMIN          , 69 ) \n       ENUM(BUFFER_ATOMIC_SMAX          , 70 ) \n       ENUM(BUFFER_ATOMIC_UMAX          , 71 ) \n       ENUM(BUFFER_ATOMIC_AND           , 72 ) \n       ENUM(BUFFER_ATOMIC_OR            , 73 ) \n       ENUM(BUFFER_ATOMIC_XOR           , 74 ) \n       ENUM(BUFFER_ATOMIC_INC           , 75 ) \n       ENUM(BUFFER_ATOMIC_DEC           , 76 ) \n       ENUM(BUFFER_ATOMIC_SWAP_X2       , 96 ) \n       ENUM(BUFFER_ATOMIC_CMPSWAP_X2    , 97 ) \n       ENUM(BUFFER_ATOMIC_ADD_X2        , 98 ) \n       ENUM(BUFFER_ATOMIC_SUB_X2        , 99 ) \n       ENUM(BUFFER_ATOMIC_SMIN_X2       , 100) \n       ENUM(BUFFER_ATOMIC_UMIN_X2       , 101) \n       ENUM(BUFFER_ATOMIC_SMAX_X2       , 102) \n       ENUM(BUFFER_ATOMIC_UMAX_X2       , 103) \n       ENUM(BUFFER_ATOMIC_AND_X2        , 104) \n       ENUM(BUFFER_ATOMIC_OR_X2         , 105) \n       ENUM(BUFFER_ATOMIC_XOR_X2        , 106) \n       ENUM(BUFFER_ATOMIC_INC_X2        , 107) \n       ENUM(BUFFER_ATOMIC_DEC_X2        , 108) \n    END_TRANSLATOR(BufferInstructions,MUBUFFOpcodes,BUFFER_INVALID)\n\n    BEGIN_TRANSLATOR(BufferInstructions,MTBUFFOpcodes)\n         ENUM( TBUFFER_LOAD_FORMAT_X             , 0   )\n         ENUM( TBUFFER_LOAD_FORMAT_XY            , 1   )\n         ENUM( TBUFFER_LOAD_FORMAT_XYZ           , 2   )\n         ENUM( TBUFFER_LOAD_FORMAT_XYZW          , 3   )\n         ENUM( TBUFFER_STORE_FORMAT_X            , 4   )\n         ENUM( TBUFFER_STORE_FORMAT_XY           , 5   )\n         ENUM( TBUFFER_STORE_FORMAT_XYZ          , 6   )\n         ENUM( TBUFFER_STORE_FORMAT_XYZW         , 7   )\n         ENUM( TBUFFER_LOAD_FORMAT_D16_X         , 8   )\n         ENUM( TBUFFER_LOAD_FORMAT_D16_XY        , 9   )\n         ENUM( TBUFFER_LOAD_FORMAT_D16_XYZ       , 10  )\n         ENUM( TBUFFER_LOAD_FORMAT_D16_XYZW      , 11  )\n         ENUM( TBUFFER_STORE_FORMAT_D16_X        , 12  )\n         ENUM( TBUFFER_STORE_FORMAT_D16_XY       , 13  )\n         ENUM( TBUFFER_STORE_FORMAT_D16_XYZ      , 14  )\n         ENUM( TBUFFER_STORE_FORMAT_D16_XYZW     , 15  )\n    END_TRANSLATOR(BufferInstructions,MTBUFFOpcodes,TBUFFER_INVALID)\n\n    BEGIN_TRANSLATOR(ImageInstructions,MIMGOpcodes)\n        ENUM( IMAGE_LOAD                 , 0    )\n        ENUM( IMAGE_LOAD_MIP             , 1    )\n        ENUM( IMAGE_LOAD_PCK             , 2    )\n        ENUM( IMAGE_LOAD_PCK_SGN         , 3    )\n        ENUM( IMAGE_LOAD_MIP_PCK         , 4    )\n        ENUM( IMAGE_LOAD_MIP_PCK_SGN     , 5    )\n        ENUM( IMAGE_STORE                , 8    )\n        ENUM( IMAGE_STORE_MIP            , 9    )\n        ENUM( IMAGE_STORE_PCK            , 10   )\n        ENUM( IMAGE_STORE_MIP_PCK        , 11   )\n        ENUM( IMAGE_GET_RESINFO          , 14   )\n        ENUM( IMAGE_ATOMIC_SWAP          , 15   )\n        ENUM( IMAGE_ATOMIC_CMPSWAP       , 16   )\n        ENUM( IMAGE_ATOMIC_ADD           , 17   )\n        ENUM( IMAGE_ATOMIC_SUB           , 18   )\n        ENUM( IMAGE_ATOMIC_SMIN          , 20   )\n        ENUM( IMAGE_ATOMIC_UMIN          , 21   )\n        ENUM( IMAGE_ATOMIC_SMAX          , 22   )\n        ENUM( IMAGE_ATOMIC_UMAX          , 23   )\n        ENUM( IMAGE_ATOMIC_AND           , 24   )\n        ENUM( IMAGE_ATOMIC_OR            , 25   )\n        ENUM( IMAGE_ATOMIC_XOR           , 26   )\n        ENUM( IMAGE_ATOMIC_INC           , 27   )\n        ENUM( IMAGE_ATOMIC_DEC           , 28   )\n        ENUM( IMAGE_SAMPLE               , 32   )\n        ENUM( IMAGE_SAMPLE_CL            , 33   )\n        ENUM( IMAGE_SAMPLE_D             , 34   )\n        ENUM( IMAGE_SAMPLE_D_CL          , 35   )\n        ENUM( IMAGE_SAMPLE_L             , 36   )\n        ENUM( IMAGE_SAMPLE_B             , 37   )\n        ENUM( IMAGE_SAMPLE_B_CL          , 38   )\n        ENUM( IMAGE_SAMPLE_LZ            , 39   )\n        ENUM( IMAGE_SAMPLE_C             , 40   )\n        ENUM( IMAGE_SAMPLE_C_CL          , 41   )\n        ENUM( IMAGE_SAMPLE_C_D           , 42   )\n        ENUM( IMAGE_SAMPLE_C_D_CL        , 43   )\n        ENUM( IMAGE_SAMPLE_C_L           , 44   )\n        ENUM( IMAGE_SAMPLE_C_B           , 45   )\n        ENUM( IMAGE_SAMPLE_C_B_CL        , 46   )\n        ENUM( IMAGE_SAMPLE_C_LZ          , 47   )\n        ENUM( IMAGE_SAMPLE_O             , 48   )\n        ENUM( IMAGE_SAMPLE_CL_O          , 49   )\n        ENUM( IMAGE_SAMPLE_D_O           , 50   )\n        ENUM( IMAGE_SAMPLE_D_CL_O        , 51   )\n        ENUM( IMAGE_SAMPLE_L_O           , 52   )\n        ENUM( IMAGE_SAMPLE_B_O           , 53   )\n        ENUM( IMAGE_SAMPLE_B_CL_O        , 54   )\n        ENUM( IMAGE_SAMPLE_LZ_O          , 55   )\n        ENUM( IMAGE_SAMPLE_C_O           , 56   )\n        ENUM( IMAGE_SAMPLE_C_CL_O        , 57   )\n        ENUM( IMAGE_SAMPLE_C_D_O         , 58   )\n        ENUM( IMAGE_SAMPLE_C_D_CL_O      , 59   )\n        ENUM( IMAGE_SAMPLE_C_L_O         , 60   )\n        ENUM( IMAGE_SAMPLE_C_B_O         , 61   )\n        ENUM( IMAGE_SAMPLE_C_B_CL_O      , 62   )\n        ENUM( IMAGE_SAMPLE_C_LZ_O        , 63   )\n        ENUM( IMAGE_GATHER4              , 64   )\n        ENUM( IMAGE_GATHER4_CL           , 65   )\n        ENUM( IMAGE_GATHER4_L            , 66   )\n        ENUM( IMAGE_GATHER4_B            , 67   )\n        ENUM( IMAGE_GATHER4_B_CL         , 68   )\n        ENUM( IMAGE_GATHER4_LZ           , 69   )\n        ENUM( IMAGE_GATHER4_C            , 70   )\n        ENUM( IMAGE_GATHER4_C_CL         , 71   )\n        ENUM( IMAGE_GATHER4_C_L          , 76   )\n        ENUM( IMAGE_GATHER4_C_B          , 77   )\n        ENUM( IMAGE_GATHER4_C_B_CL       , 78   )\n        ENUM( IMAGE_GATHER4_C_LZ         , 79   )\n        ENUM( IMAGE_GATHER4_O            , 80   )\n        ENUM( IMAGE_GATHER4_CL_O         , 81   )\n        ENUM( IMAGE_GATHER4_L_O          , 84   )\n        ENUM( IMAGE_GATHER4_B_O          , 85   )\n        ENUM( IMAGE_GATHER4_B_CL_O       , 86   )\n        ENUM( IMAGE_GATHER4_LZ_O         , 87   )\n        ENUM( IMAGE_GATHER4_C_O          , 88   )\n        ENUM( IMAGE_GATHER4_C_CL_O       , 89   )\n        ENUM( IMAGE_GATHER4_C_L_O        , 92   )\n        ENUM( IMAGE_GATHER4_C_B_O        , 93   )\n        ENUM( IMAGE_GATHER4_C_B_CL_O     , 94   )\n        ENUM( IMAGE_GATHER4_C_LZ_O       , 95   )\n        ENUM( IMAGE_GET_LOD              , 96   )\n        ENUM( IMAGE_SAMPLE_CD            , 104  )\n        ENUM( IMAGE_SAMPLE_CD_CL         , 105  )\n        ENUM( IMAGE_SAMPLE_C_CD          , 106  )\n        ENUM( IMAGE_SAMPLE_C_CD_CL       , 107  )\n        ENUM( IMAGE_SAMPLE_CD_O          , 108  )\n        ENUM( IMAGE_SAMPLE_CD_CL_O       , 109  )\n        ENUM( IMAGE_SAMPLE_C_CD_O        , 110  )\n        ENUM( IMAGE_SAMPLE_C_CD_CL_O     , 111  )\n    END_TRANSLATOR(ImageInstructions,MIMGOpcodes,IMAGE_INVALID)\n\n\n    BEGIN_TRANSLATOR(TBufferNumberFormats,MTBUFF_NumberFormat)\n        ENUM(NF_UNORM       , 0)\n        ENUM(NF_SNORM       , 1)\n        ENUM(NF_USCALED     , 2)\n        ENUM(NF_SSCALED     , 3)\n        ENUM(NF_UINT        , 4)\n        ENUM(NF_SINT        , 5)\n        ENUM(NF_FLOAT       , 7)\n    END_TRANSLATOR(TBufferNumberFormats,MTBUFF_NumberFormat,NF_INVALID)\n\n    BEGIN_TRANSLATOR(TBufferDataFormats,MTBUFF_DataFormat)\n        ENUM( DF_8          , 1    )\n        ENUM( DF_16         , 2    )\n        ENUM( DF_8_8        , 3    )\n        ENUM( DF_32         , 4    )\n        ENUM( DF_16_16      , 5    )\n        ENUM( DF_10_11_11   , 6    )\n        ENUM( DF_10_10_10_2 , 8    )\n        ENUM( DF_2_10_10_10 , 9    )\n        ENUM( DF_8_8_8_8    , 10   )\n        ENUM( DF_32_32      , 11   )\n        ENUM( DF_16_16_16_16, 12   )\n        ENUM( DF_32_32_32   , 13   )\n        ENUM( DF_32_32_32_32, 14   )\n    END_TRANSLATOR(TBufferDataFormats,MTBUFF_DataFormat,DF_INVALID)\n\n    BEGIN_TRANSLATOR(ExportTargets, EXPTarget)\n        ENUM( EXP_MRT0     ,0   )\n        ENUM( EXP_MRT1     ,1   )\n        ENUM( EXP_MRT2     ,2   )\n        ENUM( EXP_MRT3     ,3   )\n        ENUM( EXP_MRT4     ,4   )\n        ENUM( EXP_MRT5     ,5   )\n        ENUM( EXP_MRT6     ,6   )\n        ENUM( EXP_MRT7     ,7   )\n        ENUM( EXP_Z        ,8   )\n        ENUM( EXP_NULL     ,9   )\n        ENUM( EXP_POS0     ,12  )\n        ENUM( EXP_POS1     ,13  )\n        ENUM( EXP_POS2     ,14  )\n        ENUM( EXP_POS3     ,15  )\n        ENUM( EXP_PARAM0   ,32  )\n        ENUM( EXP_PARAM1   ,33 ) \n        ENUM( EXP_PARAM2   ,34 ) \n        ENUM( EXP_PARAM3   ,35 ) \n        ENUM( EXP_PARAM4   ,36 ) \n        ENUM( EXP_PARAM5   ,37 ) \n        ENUM( EXP_PARAM6   ,38 ) \n        ENUM( EXP_PARAM7   ,39 ) \n        ENUM( EXP_PARAM8   ,40 ) \n        ENUM( EXP_PARAM9   ,41 ) \n        ENUM( EXP_PARAM10   ,42 ) \n        ENUM( EXP_PARAM11   ,43 ) \n        ENUM( EXP_PARAM12   ,44 ) \n        ENUM( EXP_PARAM13   ,45 ) \n        ENUM( EXP_PARAM14   ,46 ) \n        ENUM( EXP_PARAM15   ,47 ) \n        ENUM( EXP_PARAM16   ,48 ) \n        ENUM( EXP_PARAM17   ,49 ) \n        ENUM( EXP_PARAM18   ,50 ) \n        ENUM( EXP_PARAM19   ,51 ) \n        ENUM( EXP_PARAM20   ,52 ) \n        ENUM( EXP_PARAM21   ,53 ) \n        ENUM( EXP_PARAM22   ,54 ) \n        ENUM( EXP_PARAM23   ,55 ) \n        ENUM( EXP_PARAM24   ,56 ) \n        ENUM( EXP_PARAM25   ,57 ) \n        ENUM( EXP_PARAM26   ,58 ) \n        ENUM( EXP_PARAM27   ,59 ) \n        ENUM( EXP_PARAM28   ,60 ) \n        ENUM( EXP_PARAM29   ,61 ) \n        ENUM( EXP_PARAM30   ,62 ) \n        ENUM( EXP_PARAM31   ,63 ) \n    END_TRANSLATOR(ExportTargets,EXPTarget,EXP_INVALID)\n\n\n    BEGIN_TRANSLATOR(Dests,ScalarDestOddballs)\n        ENUM(SRC_FSCR_LO          , 102)\n        ENUM(SRC_FSCR_HI          , 103)\n        ENUM(SRC_XNACK_MASK_LO    , 104)\n        ENUM(SRC_XNACK_MASK_HI    , 105)\n        ENUM(SRC_VCC_LO           , 106)\n        ENUM(SRC_VCC_HI           , 107)\n        ENUM(SRC_TBA_LO           , 108)\n        ENUM(SRC_TBA_HI           , 109)\n        ENUM(SRC_TMA_LO           , 110)\n        ENUM(SRC_TMA_HI           , 111)\n        ENUM(SRC_M0               , 124)\n        ENUM(SRC_EXEC_LO          , 126)\n        ENUM(SRC_EXEC_HI          , 127)\n    END_TRANSLATOR(Dests,ScalarDestOddballs, DEST_INVALID)\n\n    BEGIN_TRANSLATOR(Sources,ScalarSourceOddballs)\n        ENUM(SRC_FSCR_LO          , 102)\n        ENUM(SRC_FSCR_HI          , 103)\n        ENUM(SRC_XNACK_MASK_LO    , 104)\n        ENUM(SRC_XNACK_MASK_HI    , 105)\n        ENUM(SRC_VCC_LO           , 106)\n        ENUM(SRC_VCC_HI           , 107)\n        ENUM(SRC_TBA_LO           , 108)\n        ENUM(SRC_TBA_HI           , 109)\n        ENUM(SRC_TMA_LO           , 110)\n        ENUM(SRC_TMA_HI           , 111)\n        ENUM(SRC_M0               , 124)\n        ENUM(SRC_EXEC_LO          , 126)\n        ENUM(SRC_EXEC_HI          , 127)\n        ENUM(SRC_C_ZERO           , 128)\n        ENUM(SRC_CF_ONEHALF       , 240)\n        ENUM(SRC_CF_MINUS_ONEHALF , 241)\n        ENUM(SRC_CF_ONE           , 242)\n        ENUM(SRC_CF_MINUS_ONE     , 243)\n        ENUM(SRC_CF_TWO           , 244)\n        ENUM(SRC_CF_MINUS_TWO     , 245)\n        ENUM(SRC_CF_FOUR          , 246)\n        ENUM(SRC_CF_MINUS_FOUR    , 247)\n        ENUM(SRC_CF_INV_2PI       , 248)\n        ENUM(SRC_VCCZ             , 251)\n        ENUM(SRC_EXECZ            , 252)\n        ENUM(SRC_SCC              , 253)\n        ENUM(SRC_LDS_DIRECT       , 254)\n        ENUM(SRC_LITERAL          , 255)\n    END_TRANSLATOR(Sources,ScalarSourceOddballs,SRC_INVALID)\n\n    Dests Translate_SDest( uint n )\n    {\n        if( n <= 101 )\n            return (Dests)(DEST_SGPR_FIRST+n);\n        else\n            return Translate_ScalarDestOddballs(n);\n    }\n\n    Sources Translate_SSrc( uint n )\n    {\n        if( n <= 101 )\n            return (Sources)(SRC_SGPR_FIRST+n); // SGPRs\n        if( n >= 112 && n <= 123 )\n            return (Sources)(SRC_TTMP_FIRST+(n-112)); // trap handler temps\n        if( n >= 256 && n<= 511 )\n            return (Sources)(SRC_VGPR_FIRST+(n-256)); // VGPRs\n        if( n >= 129 && n <= 192 )\n            return(Sources) (SRC_CI_POSITIVE_FIRST+(n-129));\n        if( n >= 193 && n <= 208 )\n            return (Sources) (SRC_CI_NEGATIVE_FIRST+(n-193));\n\n        return Translate_ScalarSourceOddballs(n);\n    }\n\n    Sources Translate_VSrc( uint n )\n    {\n        return (Sources)(SRC_VGPR_FIRST+n);\n    }\n    Dests Translate_VDest( uint n )\n    {\n        return (Dests)(DEST_VGPR_FIRST+n);\n    }\n\n    class Instruction\n    {\n    public:\n\n        uint32 ReadTrailingLiteral() const {\n            const uint32* pDWORD = (const uint32*)this;\n            return pDWORD[1];\n        }\n\n    protected:\n\n        int SignExt( uint n, uint sign )\n        {\n            uint bit = (1<<sign);\n        }\n\n        uint ReadBits( uint hi, uint lo ) const\n        {\n            uint shift = lo % 32;\n            uint mask = (1<<(hi-lo+1))-1;\n            return ( ((const uint32*)this)[lo/32]>>shift)&mask;\n        }\n        bool ReadBit( uint bit ) const\n        {\n            uint shift = bit % 32;\n            return (( ((const uint32*)this)[bit/32]>>shift)&1) != 0;\n        }\n    private:\n    };\n\n\n    class SOP2Instruction : public Instruction\n    {\n    public:\n        bool HasLiteral() const { return ((GetSrc0() == SRC_LITERAL || GetSrc1() == SRC_LITERAL)); }\n        uint   GetLength()              const { return 4 + 4*HasLiteral(); };\n        ScalarInstructions   GetOpcode()const { return Translate_SOP2Opcodes(ReadBits( 29, 23 )); }\n        Sources   GetSrc0()             const { return Translate_SSrc(ReadBits( 7,0 )); }\n        Sources   GetSrc1()             const { return Translate_SSrc(ReadBits( 15,8)); }\n        Dests   GetDest()               const { return Translate_SDest(ReadBits( 22,16)); }\n    };\n\n    class SOP1Instruction : public Instruction\n    {\n    public:\n        bool HasLiteral() const { return (GetSrc0() == SRC_LITERAL); }\n        uint   GetLength()                const { return 4 + 4*HasLiteral(); };\n        ScalarInstructions   GetOpcode()  const { return Translate_SOP1Opcodes(ReadBits( 15,8 )); }\n        Sources   GetSrc0()               const { return Translate_SSrc( ReadBits(7,0) ); }\n        Dests     GetDest()               const { return Translate_SDest(ReadBits(22,16)); }\n    };\n\n    class SOPKInstruction : public Instruction\n    {\n    public:\n        InstructionFormat GetFormat() const { return IF_SOPK; }\n        bool HasLiteral() const { return (GetOpcode() == S_SETREG_IMM32_B32); }\n        uint GetLength() const { return 4 + 4*HasLiteral(); };\n\n        ScalarInstructions GetOpcode() const { return Translate_SOPKOpcodes(ReadBits( 27,23 )); }\n        Dests GetDest()           const { return Translate_SDest( ReadBits(22,16) ); }\n\n        int ReadSIMM16() const { return *((const int16*)this); }\n        uint ReadSIMMBits( uint hi, uint lo) const { return ReadBits(hi,lo); }\n        uint32 ReadIMM32() const { return ReadBits(63,32); }\n        \n        const uint8* GetBranchTarget() const\n        {\n            if( GetOpcode() != S_CBRANCH_I_FORK )\n                return 0;\n            int offset = this->ReadSIMM16();\n            const uint32* pThis = (const uint32*)this;\n            return (const uint8*) (pThis+1+offset);\n        }\n\n    };\n\n    class SOPCInstruction : public Instruction\n    {\n    public:\n        InstructionFormat GetFormat() const { return IF_SOPC; }\n        bool HasLiteral() const { return (GetSrc0() == SRC_LITERAL || GetSrc1() == SRC_LITERAL);}\n        uint GetLength()  const { return 4 + 4*HasLiteral(); };\n\n        ScalarInstructions GetOpcode()  const { return Translate_SOPCOpcodes(ReadBits( 22,16 )); }\n        Sources GetSrc0()            const { return Translate_SSrc(ReadBits(7,0)); }\n        Sources GetSrc1()            const { return Translate_SSrc(ReadBits(15,8 )); }\n        uint GetSrc1Raw() const { return ReadBits(15,8); }\n        Dests GetDest() const { return GetOpcode() == S_SETVSKIP ? DEST_VSKIP : DEST_SCC; }\n        \n    };\n\n    class SOPPInstruction : public Instruction\n    {\n    public:\n        InstructionFormat GetFormat() const { return IF_SOPP; }\n        uint GetLength() const  { return 4; }\n\n        int ReadSIMM16() const { return *((const int16*)this); }\n        uint ReadSIMMBits( uint hi, uint lo ) const { return ReadBits(hi,lo); }\n\n        ScalarInstructions GetOpcode() const { return Translate_SOPPOpcodes(ReadBits( 22,16 )); }\n        const uint8* GetBranchTarget() const\n        {\n            switch( GetOpcode() )\n            {\n            case S_BRANCH                :\n            case S_CBRANCH_SCC0          :\n            case S_CBRANCH_SCC1          :\n            case S_CBRANCH_VCCZ          :\n            case S_CBRANCH_VCCNZ         :\n            case S_CBRANCH_EXECZ         :\n            case S_CBRANCH_EXECNZ        :\n            case S_CBRANCH_CDBGSYS            :\n            case S_CBRANCH_CDBGUSER           :\n            case S_CBRANCH_CDBGSYS_OR_USER    :\n            case S_CBRANCH_CDBGSYS_AND_USER   :\n                {\n                    int n = this->ReadSIMM16();\n                    int offset = this->ReadSIMM16();\n                    const uint32* pThis = (const uint32*)this;\n                    return (const uint8*) (pThis+1+offset);\n                }\n            default:\n                return 0;\n            }\n            \n        }\n\n        \n    };\n\n    \n    class SMEMInstruction : public Instruction\n    {\n    public:\n        uint GetLength()       const { return 8; }\n        ScalarMemoryInstructions GetOpcode()  const { return Translate_SMEMOpcodes(ReadBits(25,18)); }\n        Dests GetSData()                 const { return Translate_SDest(ReadBits( 12,6)); }\n        Dests GetSBase()                 const { return Translate_SDest(2*ReadBits( 5,0 )); } // base of SGPR pair containing address\n        uint GetOffset()               const { return ReadBits(51,32); }\n        bool IsOffsetIMM()             const { return ReadBit(17); }\n        // SI and CI use dword offsets, but VI uses byte.\n    };\n\n    class VOP2Instruction : public Instruction\n    {\n    public:\n        \n        InstructionFormat GetFormat() const { return IF_VOP2; }\n        bool HasLiteral() const { \n            uint eOp = GetOpcode();\n            return (GetSrc0() == SRC_LITERAL ||\n                    eOp == V_MADAK_F32 || \n                    eOp == V_MADMK_F32 ||\n                    eOp == V_MADMK_F16 ||\n                    eOp == V_MADMK_F16 ); \n        }\n        uint GetLength() const { return 4 + 4*HasLiteral(); }\n\n        VectorInstructions GetOpcode() const { return Translate_VOP2Opcodes(ReadBits(30,25)); }\n        Sources GetSrc0()           const { return Translate_SSrc(ReadBits(8,0)); }\n        Sources GetVSrc1()          const { return Translate_VSrc(ReadBits(16,9)); }\n        Dests GetVDst()           const   { return Translate_VDest(ReadBits(24,17)); }\n        \n        uint GetResultWidthInDWORDS() const { return 1; }\n    };\n\n    class VOP1Instruction : public Instruction\n    {\n    public:\n        \n        InstructionFormat GetFormat() const { return IF_VOP1; }\n        bool HasLiteral() const { \n            switch( GetOpcode())\n            {\n            default:\n                return GetSrc0() == SRC_LITERAL;\n            case V_NOP:\n            case V_CLREXCP:             \n                return false;\n            }\n        }\n        uint GetLength() const \n        {\n            return 4 + 4*HasLiteral();\n        }\n\n        VectorInstructions GetOpcode() const { return Translate_VOP1Opcodes( ReadBits(16,9) ); }\n        Dests GetDst() const \n\t\t{ \n\t\t\tif (GetOpcode() == V_READFIRSTLANE_B32)\n\t\t\t{\n\t\t\t\treturn Translate_SDest(ReadBits(24, 17));\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\treturn Translate_VDest(ReadBits(24, 17));\n\t\t\t}\n\t\t}\n        Sources GetSrc0()         const { return Translate_SSrc(ReadBits(8,0)); }\n    };\n\n    class VOPCInstruction : public Instruction\n    {\n    public:\n        \n        InstructionFormat GetFormat() const { return IF_VOPC; }\n        bool HasLiteral() const { return (GetSrc0() == SRC_LITERAL); }\n        uint GetLength() const { return 4 + 4*HasLiteral(); }\n\n        VectorInstructions GetOpcode() const { return Translate_VOPCOpcodes(ReadBits(24,17)); }\n        Sources GetSrc0()           const { return Translate_SSrc(ReadBits( 8,0 )); }\n        Sources GetVSrc1()          const { return Translate_VSrc(ReadBits( 16,9 )); }\n      \n        uint GetOperandWidthInDWORDs() const;\n        \n\n        bool IsBranch() const { return false; }\n    };\n\n    class VINTERPInstruction : public Instruction\n    {\n    public:\n        \n        InstructionFormat GetFormat() const { return IF_VINTERP; }\n        uint GetLength() const { return 4; }\n\n        VectorInstructions GetOpcode() const { return Translate_VINTERPOpcodes( ReadBits(17,16) ); }\n        uint GetAttributeChannel() const { return ReadBits(9,8); };\n        uint GetAttributeIndex() const { return ReadBits(15,10); };\n        Sources GetVSrc0() const { return Translate_VSrc( ReadBits(7,0) ); }\n        Dests GetVDst() const { return Translate_VDest(ReadBits(25,18)); }\n\n    };\n\n    class VOP3Instruction : public Instruction\n    {\n    public:\n        \n        InstructionFormat GetFormat() const { return IF_VOP3; }\n        uint GetLength() const { return 8; }\n        \n        VectorInstructions GetOpcode() const { return Translate_VOP3Opcodes(ReadBits(25,16));}\n       \n        Dests GetVDst() const { \n            uint dst = ReadBits(7,0);\n            if( IsCompare() )\n                return Translate_SDest(dst);\n            return Translate_VDest(dst); \n        }\n        Sources GetSrc0() const { return Translate_SSrc(ReadBits(40,32)); }\n        Sources GetSrc1() const { return Translate_SSrc(ReadBits(49,41)); }\n        Sources GetSrc2() const { return Translate_SSrc(ReadBits(58,50)); }\n        uint GetSourceNegateMask() const { return ReadBits(63,61); };\n        uint GetOMod() const { return ReadBits(60,59); }\n     \n        bool IsCompare() const { return ReadBits(25,16) < 255; } // opcodes 0-255 are vcmps.\n\n        bool IsVOP3bOp() const\n        {\n            // NOTE: ISA Doc, section 6, claims that vcmp is vop3b.  But AMD disassembler thinks its VOP3a\n            //\n            switch( GetOpcode() )\n            {\n            case V_ADD_I32      :   //  : D.u = S0.u + S1.u; VCC=carry-out (VOP3:sgpr=carry-out).\n            case V_SUB_I32      :   //  : D.u = S0.u - S1.u; VCC=carry-out (VOP3:sgpr=carry-out).\n            case V_SUBREV_I32   :   //  : D.u = S1.u - S0.u; VCC=carry-out (VOP3:sgpr=carry-out).\n            case V_ADD_U32      :\n            case V_SUB_U32      :\n            case V_SUBREV_U32   :\n            case V_ADDC_U32     :   //  : D.u = S0.u + S1.u + VCC; VCC=carry-out (VOP3:sgpr=carryout,S2.u=carry-in).\n            case V_SUBB_U32     :   //  : D.u = S0.u - S1.u - VCC; VCC=carry-out (VOP3:sgpr=carry-out,S2.u=carry-in).\n            case V_SUBBREV_U32  :   //  : D.u = S1.u - S0.u - VCC; VCC=carry-out (VOP3:sgpr=carryout,S2.u=carry-in).\n            case V_DIV_SCALE_F32:   //  = D.f = Special case divide preop and flags(s0.f = Quotient,s1.f = Denominator, s2.f = Numerator) s0 must equal s1 or s2.\n            case V_DIV_SCALE_F64:   //  = D.d = Special case divide preop and flags(s0.d = Quotient,s1.d = Denominator, s2.d = Numerator) s0 must equal s1 or s2.\n                return true;\n            default:\n                return false;\n            }\n        }\n\n        // VOP3a only\n        uint GetSourceAbsMask() const { return ReadBits(10,8); }\n        bool GetClamp() const { return ReadBit(15); }\n\n        // VOP3b only\n        Dests GetSDst() const { return Translate_SDest(ReadBits(14,8)); }\n\n    };\n\n    class MUBUFFInstruction : public Instruction\n    {\n    public:\n        \n        InstructionFormat GetFormat() const { return IF_MUBUFF; }\n        BufferInstructions GetOpcode() const { return Translate_MUBUFFOpcodes(ReadBits(24,18)); }\n        uint GetLength() const { return 8; }\n        \n        uint GetOffset() const { return ReadBits(11,0); }\n        Sources GetVAddr() const { return Translate_VSrc(ReadBits(39,32)); }\n        Sources GetVData() const { return Translate_VSrc(ReadBits(47,40)); }\n        Sources GetSResource() const { return (Sources)(SRC_SGPR_FIRST+4*ReadBits(52,48)); }\n        Sources GetSOffset() const { return Translate_SSrc(ReadBits(63,56)); }\n        \n        bool IsOffN() const     { return ReadBit(12); }\n        bool IsIdxN() const     { return ReadBit(13); }\n        bool IsAddr64() const   { return false; } // this bit was removed in VI\n        bool IsDirectToLDS() const { return ReadBit(16); }\n        bool GetSLCBit() const { return ReadBit(17); }\n        bool GetGLCBit() const { return ReadBit(14); }\n        bool GetTFEBit() const { return ReadBit(55); }\n        \n    };\n\n    class MTBUFFInstruction : public Instruction\n    {\n    public:\n        \n        InstructionFormat GetFormat() const { return IF_MTBUFF; }\n        BufferInstructions GetOpcode() const { return Translate_MTBUFFOpcodes(ReadBits(18,15)); }\n        uint GetLength() const { return 8; }\n\n        uint GetResultWidthInDWORDS() const ;\n\n        TBufferNumberFormats GetNumberFormat() const { return Translate_MTBUFF_NumberFormat( ReadBits(25,23) ); }\n        TBufferDataFormats GetDataFormat() const { return Translate_MTBUFF_DataFormat( ReadBits(22,19) ); }\n\n        uint GetOffset() const    { return ReadBits(11,0); }\n        Sources GetVAddr() const     { return Translate_VSrc(ReadBits(39,32)); }\n        Sources GetVData() const     { return Translate_VSrc(ReadBits(47,40)); }\n        Sources GetSResource() const { return (Sources)(SRC_SGPR_FIRST+4*ReadBits(52,48)); }\n        Sources GetSOffset() const { return Translate_SSrc(ReadBits(63,56)); }\n        \n        bool IsOffN() const     { return ReadBit(12); }\n        bool IsIdxN() const     { return ReadBit(13); }\n        bool IsAddr64() const   { return false; } // removed in VI\n        bool GetSLCBit() const  { return ReadBit(54); }\n        bool GetGLCBit() const  { return ReadBit(14); }\n        bool GetTFEBit() const  { return ReadBit(55); }\n        \n    };\n    \n   \n\n    class MIMGInstruction : public Instruction\n    {\n    public:\n        \n        InstructionFormat GetFormat() const { return IF_MIMG; }\n        ImageInstructions GetOpcode() const { return Translate_MIMGOpcodes( ReadBits(24,18) ); }\n        uint GetLength() const { return 8; }\n\n        bool IsSLC() const { return ReadBit(25); }\n        bool IsGLC() const { return ReadBit(13); }\n        bool IsTFE() const { return ReadBit(16); }\n        bool IsLWE() const { return ReadBit(17); }\n        bool IsArray() const { return ReadBit(14); }\n        bool IsUnormalized() const { return ReadBit(12); }\n        bool IsRes256() const { return !ReadBit(15);};\n        bool IsD16() const { return ReadBit(63); }\n       \n        uint GetDMask() const { return ReadBits(11,8); }\n        Sources GetSSampler() const  { return (Sources)(SRC_SGPR_FIRST+4*ReadBits(57,53)); }\n        Sources GetSResource() const { return (Sources)(SRC_SGPR_FIRST+4*ReadBits(52,48)); }\n        Sources GetVData() const { return Translate_VSrc( ReadBits(47,40) ); }\n        Sources GetVAddr() const { return Translate_VSrc( ReadBits(39,32) ); }\n\n    };\n\n    class DSInstruction : public Instruction\n    {\n    public:\n        uint GetOffset0() const { return ReadBits(7,0); }  // Instructions can have one 16 bit offset field or two 8-bit offset fields\n        uint GetOffset1() const { return ReadBits(15,8); }\n        uint GetOffset16() const { return ReadBits(15,0); }\n        DSInstructions GetOpcode() const { return Translate_DSOpcodes(ReadBits(24,17)); }\n        Dests GetVDest()  const { return Translate_VDest(ReadBits(63,56)); }\n        Sources GetVData0() const { return Translate_VSrc(ReadBits(47,40)); }\n        Sources GetVData1() const { return Translate_VSrc(ReadBits(55,48)); }\n        Sources GetVAddr()  const { return Translate_VSrc(ReadBits(39,32)); }\n        bool IsGDS()     const { return ReadBit(16); }  \n    };\n\n    class EXPInstruction : public Instruction\n    {\n    public:\n        InstructionFormat GetFormat() const { return IF_EXP; }\n        uint GetLength() const { return 8; }\n  \n        bool GetCompressBit() const { return ReadBit(10); }\n        bool GetDoneBit() const { return ReadBit(11); }\n        bool GetValidMaskBit() const { return ReadBit(12); }\n\n        ExportTargets GetTarget() const { return Translate_EXPTarget(ReadBits(9,4)); }\n        uint GetExportMask() const { return ReadBits(3,0); }\n        Sources GetVSrc0() const { return Translate_VSrc(ReadBits(39,32)); }\n        Sources GetVSrc1() const { return Translate_VSrc(ReadBits(47,40)); }\n        Sources GetVSrc2() const { return Translate_VSrc(ReadBits(55,48)); }\n        Sources GetVSrc3() const { return Translate_VSrc(ReadBits(63,56)); }\n    };\n\n\n}}\n\n\n\n\nnamespace GCN\n{\n    InstructionFormat GCN3Decoder::ReadInstructionFormat( const uint8* pLocation )\n    {\n        uint32 n = *((const uint32*)pLocation);\n\n        //\n        // The instruction format is inferred from magic numbers packed into the upper bits of the first DWORD\n        //   vop2    is    0.......\n        //   vop1    is    0111 111\n        //   vopc    is    0111 110\n        //   sop2    is    10......\n        //   sopK    is    1011 .......\n        //   sopc    is    1011 1111 0\n        //   sopp    is    1011 1111 1\n        //   sop1    is    1011 1110 1\n        //   vinterp is    1100 10 (according to doc) but 1101 10 according to sane reality\n        //   smem    is    1100 00 (changed from 1100 0... in SI)\n        //   vop3    is    1101 00  \n        //   flat    is    1101 11\n        //   ds      is    1101 10\n        //   mubuff  is    1110 00\n        //   mtbuff  is    1110 10\n        //   mimg    is    1111 00\n        //   exp     is    1100 01 (changed from 1111 10... in SI)\n\n        switch( n & (0xFF800000) )       // 1111 1111 1000 ... (9 bit)\n        {\n        case 0xBF000000: return IF_SOPC; // 1011 1111 0....\n        case 0xBF800000: return IF_SOPP; // 1011 1111 1....\n        case 0xBE800000: return IF_SOP1; // 1011 1110 1....\n        default:\n            switch( n & (0xFE000000) )       // 1111 1110 ... (7 bit)\n            {\n            case 0x7E000000: return IF_VOP1; // 0111 1110 ...\n            case 0x7C000000: return IF_VOPC; // 0111 1100 ...\n            default:\n                switch( n & (0xFC000000) )          // 1111 1100 ... (6 bit)\n                {\n                case 0xD4000000:                    // 1101 10.....\n                case 0xC8000000: return IF_VINTERP; // 1100 10.. ....                \n                case 0xD0000000: return IF_VOP3;    // 1101 00.. ...\n                case 0xDC000000: return IF_FLAT;    // 1101 11.. ....\n                case 0xD8000000: return IF_DS;      // 1101 10.. ....\n                case 0xE0000000: return IF_MUBUFF;  // 1110 00..\n                case 0xE8000000: return IF_MTBUFF;  // 1110 10..\n                case 0xF0000000: return IF_MIMG;    // 1111 00..\n                case 0xC4000000: return IF_EXP;     // 1100 01..\n                case 0xC0000000: return IF_SMEM;    // 1100 00..\n                default:\n                    switch( n & (0xF8000000) ) // 1111 1000 (5bit)\n                    {\n                    case 0xB0000000: return IF_SOPK; // 1011 0.........\n                    case 0xB8000000: return IF_SOPK; // 1011 1.........\n                    default:\n                        if( (n & 0xC0000000) == 0x80000000 ) // 1100....\n                            return IF_SOP2; // 1000 ....\n                        if( !(n & 0x80000000) )\n                            return IF_VOP2; // 0......\n                    }\n                }\n            }\n        }\n\n        return IF_UNKNOWN;       \n    }\n\n    size_t GCN3Decoder::DetermineInstructionLength( const uint8* pLocation, InstructionFormat eEncoding )\n    {\n        using namespace _GCN3Decoder_INTERNAL;\n        switch( eEncoding )\n        {\n        case IF_VOP2:       return ((const VOP2Instruction*)pLocation)->GetLength();\n        case IF_VOP1:       return ((const VOP1Instruction*)pLocation)->GetLength();\n        case IF_VOPC:       return ((const VOPCInstruction*)pLocation)->GetLength();\n        case IF_SOP2:       return ((const SOP2Instruction*)pLocation)->GetLength();\n        case IF_SOPK:       return ((const SOPKInstruction*)pLocation)->GetLength();\n        case IF_SOP1:       return ((const SOP1Instruction*)pLocation)->GetLength();\n        case IF_SOPC:       return ((const SOPCInstruction*)pLocation)->GetLength();\n\n        case IF_SOPP:\n        case IF_VINTERP:    \n            return 4;\n\n        case IF_DS:         \n        case IF_VOP3:       \n        case IF_MTBUFF:     \n        case IF_MUBUFF:     \n        case IF_MIMG:       \n        case IF_EXP:        \n        case IF_FLAT:   \n        case IF_SMEM:\n            return 8;\n                \n        case IF_UNKNOWN:\n        default:\n            return 0;\n        }\n    }\n\n    void GCN3Decoder::Decode( Instruction* pInst, const uint8* pLocation, InstructionFormat eEncoding ) \n    {   \n        memset(pInst,0,sizeof(*pInst));\n\n\n        using namespace _GCN3Decoder_INTERNAL;\n        switch( eEncoding )\n        {\n        case IF_SOP2:       \n            {\n                auto* pIt = (const SOP2Instruction*)pLocation;\n                auto& Fields          = pInst->Fields.Scalar;              \n                pInst->m_eClass       = IC_SCALAR;\n                Fields.m_Dest         = pIt->GetDest();\n                Fields.m_eOpcode      = pIt->GetOpcode();\n                Fields.m_nSourceCount = 2;\n                Fields.m_Sources[0]   = pIt->GetSrc0();\n                Fields.m_Sources[1]   = pIt->GetSrc1();\n                if( pIt->HasLiteral() )\n                    Fields.m_Literal.UInt = pIt->ReadTrailingLiteral();\n            }\n            break;\n        case IF_SOPK: \n            {\n                auto* pIt = (const SOPKInstruction*) pLocation;\n                auto& Fields = pInst->Fields.Scalar;\n                pInst->m_eClass = IC_SCALAR;\n                Fields.m_Dest          = pIt->GetDest();\n                Fields.m_eOpcode       = pIt->GetOpcode();\n                Fields.m_nSourceCount  = 0;\n                Fields.m_nSIMM16       = pIt->ReadSIMM16();\n                Fields.m_pBranchTarget = pIt->GetBranchTarget();\n                if( pIt->HasLiteral() )\n                    Fields.m_Literal.UInt = pIt->ReadTrailingLiteral();\n            }\n            break;\n        case IF_SOP1:       \n            {\n                auto* pIt = (const SOP1Instruction*) pLocation;\n                auto& Fields = pInst->Fields.Scalar;\n                pInst->m_eClass = IC_SCALAR;\n                Fields.m_Dest         = pIt->GetDest();\n                Fields.m_eOpcode      = pIt->GetOpcode();\n                Fields.m_nSourceCount = 1;\n                Fields.m_Sources[0]   = pIt->GetSrc0();\n                if( pIt->HasLiteral())\n                    Fields.m_Literal.UInt = pIt->ReadTrailingLiteral();\n\n            }\n            break;\n        case IF_SOPC: \n            {\n                auto* pIt = (const SOPCInstruction*) pLocation;\n                auto& Fields = pInst->Fields.Scalar;\n                pInst->m_eClass = IC_SCALAR;\n                Fields.m_eOpcode = pIt->GetOpcode();\n                Fields.m_Dest = pIt->GetDest();\n                Fields.m_nSourceCount = 2;\n                Fields.m_Sources[0] = pIt->GetSrc0();\n                Fields.m_Sources[1] = pIt->GetSrc1();\n                if( pIt->HasLiteral() )\n                    Fields.m_Literal.UInt = pIt->ReadTrailingLiteral();\n\n                //   - S_SET_GPR_IDX_ON (sopc) is a special little fella.  His Src1 field gets ripped out and used as an immediate\n                //       * Move to the SIMM16 field in the scalar instruction class\n                if( Fields.m_eOpcode == S_SET_GPR_IDX_ON )\n                   Fields.m_nSIMM16 = pIt->GetSrc1Raw();\n                \n            }\n            break;\n        case IF_SOPP:    \n            {\n                auto* pIt = (const SOPPInstruction*) pLocation;\n                auto& Fields = pInst->Fields.Scalar;\n                pInst->m_eClass = IC_SCALAR;\n                Fields.m_eOpcode= pIt->GetOpcode();\n                Fields.m_Dest = DEST_INVALID;\n                Fields.m_nSourceCount = 0;\n                Fields.m_nSIMM16 = pIt->ReadSIMM16();\n                Fields.m_pBranchTarget = pIt->GetBranchTarget();\n            }\n            break;\n        case IF_SMEM: \n            {\n                auto* pIt = (const SMEMInstruction*) pLocation;\n                auto& Fields = pInst->Fields.ScalarMem;\n                pInst->m_eClass = IC_SCALAR_MEM;\n                Fields.m_bIsOffsetIMM = pIt->IsOffsetIMM();\n                Fields.m_eOpcode      = pIt->GetOpcode();\n                Fields.m_Dest         = pIt->GetSData();\n                Fields.m_nBaseReg     = pIt->GetSBase();\n                Fields.m_nOffset      = pIt->GetOffset();\n                Fields.m_bIsGLC       = false;\n            }\n            break;\n\n        case IF_VOP2: \n            {\n                auto* pIt = (const VOP2Instruction*) pLocation;\n                auto& Fields = pInst->Fields.Vector;\n                pInst->m_eClass = IC_VECTOR;\n                Fields.m_eOpcode = pIt->GetOpcode();\n                Fields.m_nSrcCount  = 2;\n                Fields.m_nDestCount = 1;\n                Fields.m_Sources[0] = pIt->GetSrc0();\n                Fields.m_Sources[1] = pIt->GetVSrc1();\n                Fields.m_Dests[0] = pIt->GetVDst();\n                if( pIt->HasLiteral() )\n                    Fields.m_Literal.UInt = pIt->ReadTrailingLiteral();\n\n                // convert float16 literals to float32 ones to make the disassembler's job easier\n                switch( Fields.m_eOpcode )\n                {\n                case V_MADAK_F16:\n                case V_MADMK_F16:\n                    {\n                        uint32 f16 = Fields.m_Literal.UInt;\n                        uint32 sign  = (f16 & 0x8000)<<16;\n                        int   exp    = ((f16 & 0x7C00)>>5)-15;\n                        uint mant    = f16 & 0x3fff;\n\n                        switch( exp ) // nan\n                        {\n                        default:    // normalized\n                            Fields.m_Literal.UInt = sign|((exp+127)<<23)|(mant<<13);\n                            break;\n                        case 16:    // inf/nan\n                            Fields.m_Literal.UInt = sign|(0xff<<23)|(mant<<13);\n                            break;\n                        case -15:  // FP16 denorm\n                            Fields.m_Literal.Float  = ldexpf(sign?-1.0f:1.0f,-14) * (mant/1023.0f);\n                            break;\n                        }\n\n                    }\n                    break;\n                }\n            }\n            break;\n        case IF_VOP1:       \n            {\n                auto* pIt = (const VOP1Instruction*) pLocation;\n                auto& Fields = pInst->Fields.Vector;\n                pInst->m_eClass = IC_VECTOR;\n                Fields.m_eOpcode = pIt->GetOpcode();\n                Fields.m_nSrcCount  = 1;\n                Fields.m_nDestCount = 1;\n                Fields.m_Sources[0] = pIt->GetSrc0();\n                Fields.m_Dests[0] = pIt->GetDst();\n                if( pIt->HasLiteral() )\n                    Fields.m_Literal.UInt = pIt->ReadTrailingLiteral();\n            }\n            break;\n        case IF_VOPC:       \n            {\n                auto* pIt = (const VOPCInstruction*) pLocation;\n                auto& Fields = pInst->Fields.Vector;\n                pInst->m_eClass = IC_VECTOR;                \n                Fields.m_eOpcode = pIt->GetOpcode();\n                Fields.m_nSrcCount  = 2;\n                Fields.m_nDestCount = 1;\n                Fields.m_Sources[0] = pIt->GetSrc0();\n                Fields.m_Sources[1] = pIt->GetVSrc1();\n                Fields.m_Dests[0]   = DEST_VCC;\n                if( pIt->HasLiteral() )\n                    Fields.m_Literal.UInt = pIt->ReadTrailingLiteral();\n            }\n            break;\n        case IF_VOP3:      \n            {\n                auto* pIt = (const VOP3Instruction*) pLocation;\n                auto& Fields = pInst->Fields.Vector;\n                Fields.m_eOpcode = pIt->GetOpcode();\n                pInst->m_eClass = IC_VECTOR;\n                \n                // TODO: Detect VOP3-encoded interp ops here and treat them as VC_INTERP?\n                //   so we can get better disassembly output?\n                //   Are they allowed to use abs, clamp, and all that goodness??\n                //   How do the attribute fields get encoded?  Doc is not helpful here...\n\n                if( pIt->IsVOP3bOp() )\n                {\n                    Fields.m_nDestCount = 2;\n                    Fields.m_Dests[0] = pIt->GetVDst();\n                    Fields.m_Dests[1] = pIt->GetSDst();\n                }\n                else\n                {\n                    Fields.m_nDestCount = 1;\n                    Fields.m_Dests[0] = pIt->GetVDst();\n                    Fields.m_nSourceAbs = pIt->GetSourceAbsMask();\n                }\n                     \n                Fields.m_nClamp = pIt->GetClamp();\n                Fields.m_nSourceNegate= pIt->GetSourceNegateMask();\n                Fields.m_nOMOD = pIt->GetOMod();\n                Fields.m_nSrcCount  = GetSourceCountForInstruction( Fields.m_eOpcode );\n                Fields.m_Sources[0] = pIt->GetSrc0();\n                Fields.m_Sources[1] = pIt->GetSrc1();\n                Fields.m_Sources[2] = pIt->GetSrc2();\n            }\n            break;\n\n        case IF_VINTERP:\n            {\n                auto* pIt = (const VINTERPInstruction*) pLocation;\n                auto& Fields = pInst->Fields.Interp;\n                pInst->m_eClass = IC_VECTOR_INTERP;\n                Fields.m_eOpcode = pIt->GetOpcode();\n                Fields.m_nAttributeChannel = pIt->GetAttributeChannel();\n                Fields.m_nAttributeIndex = pIt->GetAttributeIndex();\n                Fields.m_VDst = pIt->GetVDst();\n                Fields.m_VSrc = pIt->GetVSrc0();\n            }\n            break;\n\n        case IF_EXP:        \n            {\n                auto* pIt = (const EXPInstruction*) pLocation;\n                auto& Fields = pInst->Fields.Export;\n                pInst->m_eClass = IC_EXPORT;                \n                Fields.m_ChannelMask = pIt->GetExportMask();\n                Fields.m_Compress = pIt->GetCompressBit();\n                Fields.m_Done = pIt->GetDoneBit();\n                Fields.m_eTarget    = pIt->GetTarget();\n                Fields.m_ValidMask  = pIt->GetValidMaskBit();\n                Fields.m_Sources[0] = pIt->GetVSrc0();\n                Fields.m_Sources[1] = pIt->GetVSrc1();\n                Fields.m_Sources[2] = pIt->GetVSrc2();\n                Fields.m_Sources[3] = pIt->GetVSrc3();\n            }\n            break;\n        \n        case IF_DS:       \n            {\n                auto* pIt = (const DSInstruction*) pLocation;\n                auto& Fields = pInst->Fields.DS;\n                pInst->m_eClass = IC_DS;\n                Fields.m_bGDS = pIt->IsGDS();\n                Fields.m_Dest = pIt->GetVDest();\n                Fields.m_eOpcode = pIt->GetOpcode();\n                Fields.m_nOffset0 = pIt->GetOffset0();\n                Fields.m_nOffset1 = pIt->GetOffset1();\n                Fields.m_nOffset16 = pIt->GetOffset16();\n                Fields.m_VAddr = pIt->GetVAddr();\n                Fields.m_VData0 = pIt->GetVData0();\n                Fields.m_VData1 = pIt->GetVData1();\n            }\n            break;\n\n        case IF_MTBUFF:     \n            {\n                auto* pIt = (const MTBUFFInstruction*) pLocation;\n                auto& Fields = pInst->Fields.Buffer;\n                pInst->m_eClass = IC_BUFFER;\n                \n                Fields.m_bAddr64 = pIt->IsAddr64();\n                Fields.m_bGLC = pIt->GetGLCBit();\n                Fields.m_bIdxN = pIt->IsIdxN();\n                Fields.m_bLDSDirect = 0;\n                Fields.m_bOffN = pIt->IsOffN();\n                Fields.m_bSLC = pIt->GetSLCBit();\n                Fields.m_bTFE = pIt->GetTFEBit();\n                Fields.m_eDataFormat = pIt->GetDataFormat();\n                Fields.m_eNumberFormat = pIt->GetNumberFormat();\n                Fields.m_eOpcode = pIt->GetOpcode();\n                Fields.m_nOffset = pIt->GetOffset();\n                Fields.m_SOffset = pIt->GetSOffset();\n                Fields.m_SResource = pIt->GetSResource();\n                Fields.m_VAddr = pIt->GetVAddr();\n                Fields.m_VData = pIt->GetVData();\n            }\n            break;\n\n        case IF_MUBUFF:    \n            {\n                auto* pIt = (const MUBUFFInstruction*) pLocation;\n                auto& Fields = pInst->Fields.Buffer;\n                pInst->m_eClass = IC_BUFFER;\n                Fields.m_bAddr64 = pIt->IsAddr64();\n                Fields.m_bGLC = pIt->GetGLCBit();\n                Fields.m_bIdxN = pIt->IsIdxN();\n                Fields.m_bLDSDirect = pIt->IsDirectToLDS();\n                Fields.m_bOffN = pIt->IsOffN();\n                Fields.m_bSLC = pIt->GetSLCBit();\n                Fields.m_bTFE = pIt->GetTFEBit();\n                Fields.m_eOpcode = pIt->GetOpcode();\n                Fields.m_nOffset = pIt->GetOffset();\n                Fields.m_SOffset = pIt->GetSOffset();\n                Fields.m_SResource = pIt->GetSResource();\n                Fields.m_VAddr = pIt->GetVAddr();\n                Fields.m_VData = pIt->GetVData();\n\n                \n                //  - BUFFER_STORE_LDS_DWORD\n                //          set the LDS bit, so that disassembler treats it like an LDS direct read\n                ///         Not sure if this is supposed to use M0 or a vgpr and of course the doc don't say\n                if( Fields.m_eOpcode == BUFFER_STORE_LDS_DWORD )\n                    Fields.m_bLDSDirect = true;\n            }\n            break;\n\n        case IF_MIMG:     \n            {\n                auto* pIt = (const MIMGInstruction*) pLocation;\n                auto& Fields = pInst->Fields.Image;\n                pInst->m_eClass = IC_IMAGE;\n                Fields.m_bArray = pIt->IsArray();\n                Fields.m_bGLC = pIt->IsGLC();\n                Fields.m_bLWE = pIt->IsLWE();\n                Fields.m_bRes256 = pIt->IsRes256();\n                Fields.m_bSLC = pIt->IsSLC();\n                Fields.m_bTFE = pIt->IsTFE();\n                Fields.m_bUnnormalized = pIt->IsUnormalized();\n                Fields.m_eOpcode = pIt->GetOpcode();\n                Fields.m_nDMask = pIt->GetDMask();\n                Fields.m_SResource = pIt->GetSResource();\n                Fields.m_SSampler = pIt->GetSSampler();\n                Fields.m_VAddr = pIt->GetVAddr();\n                Fields.m_VData = pIt->GetVData();\n                Fields.m_bIsD16 = pIt->IsD16();\n            }\n            break;\n\n        case IF_FLAT:               \n        default:\n            return;\n        }\n\n\n\n\n    }\n\n\n\n\n}"
  },
  {
    "path": "src/Wrapper/GCN3Decoder.h",
    "content": "//\n//    Decoder for GCN3\n//\n//      Copyright 2015 Joshua Barczak, all rights reserved.\n//\n#ifndef _GCN3_DECODER_H_\n#define _GCN3_DECODER_H_\n#pragma once\n\n#include \"GCNDecoder.h\"\n\nnamespace GCN\n{\n    class GCN3Decoder : public IDecoder\n    {\n    public:\n        virtual InstructionFormat ReadInstructionFormat( const uint8* pLocation );\n        virtual size_t DetermineInstructionLength( const uint8* pLocation, InstructionFormat eEncoding );\n        virtual void Decode( Instruction* pInst, const uint8* pLocation, InstructionFormat eEncoding ) ;\n    };\n}\n\n#endif"
  },
  {
    "path": "src/Wrapper/GCNBufferedPrinter.h",
    "content": "\n//\n//    GCN disassembler\n//      Copyright 2015 Joshua Barczak, all rights reserved.\n//\n#ifndef _GCN_BUFFERED_PRINTER_H_\n#define _GCN_BUFFERED_PRINTER_H_\n#pragma once\n\n#include \"GCNDisassembler.h\"\n#include <vector>\n#include <string.h>\n\nnamespace GCN{\nnamespace Disassembler{\n    class BufferedPrinter : public GCN::Disassembler::IPrinter\n    {\n    public:\n        virtual void Push( const char* p )\n        {\n            m_Bytes.insert( m_Bytes.end(), p, p + strlen(p) );\n        }\n\n        std::vector<char> m_Bytes;\n    };\n\n}}\n\n#endif\n"
  },
  {
    "path": "src/Wrapper/GCNDecoder.cpp",
    "content": "//\n//    The decoder class is responsible for decoding GCN instructions into a standardized form\n//\n//     A decoder abstraction is necessary because AMD decided to change the \n//       microcode formats and opcode numbers for GCN3.   \n//\n//      Copyright 2015 Joshua Barczak, all rights reserved.\n//\n\n#pragma unmanaged\n#include \"GCNDecoder.h\"\n#include \"GCN1Decoder.h\"\n#include \"GCN3Decoder.h\"\n\nnamespace GCN\n{\n    IDecoder* IDecoder::Create( GCNVersions eVersion )\n    {\n        switch( eVersion )\n        {\n        case GCN1: return new GCN1Decoder();\n        case GCN3: return new GCN3Decoder();\n        default:\n            return 0;\n        }\n    }\n\n    void IDecoder::Destroy( IDecoder* p )\n    {\n        delete p;\n    }\n}"
  },
  {
    "path": "src/Wrapper/GCNDecoder.h",
    "content": "//\n//    The decoder class is responsible for decoding GCN instructions into a standardized form\n//\n//     A decoder abstraction is necessary because AMD decided to change the \n//       microcode formats and opcode numbers for GCN3.   \n//\n//      Copyright 2015 Joshua Barczak, all rights reserved.\n//\n#ifndef _GCN_DECODER_H_\n#define _GCN_DECODER_H_\n#pragma once\n\nnamespace GCN\n{\n    typedef unsigned char  uint8;\n    typedef unsigned short uint16;\n    typedef unsigned int   uint32;\n    typedef unsigned int   uint;\n    typedef short int16;\n\n    static_assert( sizeof(uint8)  == 1, \"Fix typedefs\" );\n    static_assert( sizeof(int16)  == 2, \"Fix typedefs\" );\n    static_assert( sizeof(uint16) == 2, \"Fix typedefs\" );\n    static_assert( sizeof(uint32) == 4, \"Fix typedefs\" );\n\n    enum InstructionFormat;\n    class Instruction;\n\n    class IDecoder\n    {\n    public:\n\n        enum GCNVersions\n        {\n            GCN1,\n            GCN3,\n        };\n\n        /// Decoder factory\n        static IDecoder* Create( GCNVersions eVersion );\n\n        static void Destroy( IDecoder* pDecoder );\n\n        /// Determine the format of the instruction at 'pLocation' by parsing the encoding bits\n        virtual InstructionFormat ReadInstructionFormat( const uint8* pLocation ) = 0;\n\n        /// Determine the length in bytes of the instruction at 'pLocation'\n        virtual size_t DetermineInstructionLength( const uint8* pLocation, InstructionFormat eEncoding ) = 0;\n\n        /// Decode the instruction at 'pLocation'\n        virtual void Decode( Instruction* pInst, const uint8* pLocation, InstructionFormat eEncoding ) = 0;\n    \n    protected:\n\n        // Utility methods which can be used by decoder implementations\n\n        uint ReadBits( const uint8* pWhere, uint hi, uint lo ) const\n        {\n            uint shift = lo % 32;\n            uint mask = (1<<(hi-lo+1))-1;\n            return ( ((const uint32*)pWhere)[lo/32]>>shift)&mask;\n        }\n        bool ReadBit( const uint8* pWhere, uint bit ) const\n        {\n            uint shift = bit % 32;\n            return (( ((const uint32*)pWhere)[bit/32]>>shift)&1) != 0;\n        }\n\n    };\n}\n\n\n#endif"
  },
  {
    "path": "src/Wrapper/GCNDisassembler.cpp",
    "content": "//\n//    GCN disassembler\n//      Copyright 2015 Joshua Barczak, all rights reserved.\n//\n#pragma unmanaged\n#include \"GCNDisassembler.h\"\n#include \"GCNIsa.h\"\n#include \"GCNDecoder.h\"\n\n#define _CRT_SECURE_NO_WARNINGS\n#include <stdarg.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n#include <vector>\n#include <algorithm>\n\ntypedef unsigned char uint8;\ntypedef unsigned int uint;\n\n\n\n\n\nnamespace GCN{\nnamespace Disassembler{\n    namespace _INTERNAL\n    {\n        #define OPCODE_FORMAT \"%22s\"\n        static const char* BINARY_OP_FORMAT = OPCODE_FORMAT \" %6s,%6s,%6s\\n\";\n        static const char* UNARY_OP_FORMAT  = OPCODE_FORMAT \" %6s,%6s\\n\";   \n\n        void Printf( IPrinter& printer, const char* Format, ... )\n        {\n            va_list vl;\n            va_start(vl,Format);\n\n            char scratch[2048];\n            char* p = scratch;\n\n            int n = _vscprintf( Format, vl );\n            if( n+1 > sizeof(scratch) )\n                p = (char*) malloc( n+1 );\n            \n            vsprintf(p,Format,vl);\n            printer.Push(p);\n\n            if( p != scratch )\n                free(p);\n\n            va_end(vl);\n        }\n\n        \n        void addprintf( char* buff, const char* Format, ... )\n        {\n            va_list vl;\n            va_start(vl,Format);\n            size_t n = strlen(buff);\n            if( n )\n            {\n                strcat( buff, \"+\");\n                vsprintf( buff+n+1, Format, vl );\n            }\n            else\n            {\n                vsprintf( buff, Format, vl );\n            }\n\n            va_end(vl);\n        }\n\n        \n        void catprintf( char* buff, const char* Format, ... )\n        {\n            va_list vl;\n            va_start(vl,Format);\n            \n            vsprintf( buff+strlen(buff), Format, vl );\n           \n            va_end(vl);\n        }\n\n\n\n        void FormatIndexedReg( char* buff, const char* pPrefix, uint nRegNum, uint nDWORDs )\n        {\n            if( nDWORDs>1)\n                sprintf( buff, \"%s%u[%u]\",pPrefix, nRegNum, nDWORDs );\n            else\n                sprintf( buff, \"%s%u\", pPrefix, nRegNum );\n        }\n       \n        void FormatReg64( char* buff, const char* pPrefix, uint nHiLo, uint nDWORDS )\n        {\n            if( nDWORDS == 1 ) // partial reg write\n                sprintf( buff, \"%s[%s]\", pPrefix, nHiLo ? \"HI\" : \"LO\" );\n            else // assumed full reg write\n                strcpy(buff, pPrefix );\n        }\n\n        void FormatVReg( char* buff, uint nSrc, uint nDWORDS )\n        {\n            FormatIndexedReg(buff, \"v\", nSrc, nDWORDS );\n        }\n        void FormatSReg( char* buff, uint nSrc, uint nDWORDS )\n        {\n            FormatIndexedReg(buff, \"s\", nSrc, nDWORDS );\n        }\n\n        static void FormatVSrc( char* pBuff, Sources nReg, uint nWidth )\n        {\n            FormatVReg(pBuff,nReg-SRC_VGPR_FIRST,nWidth);\n        }\n        static void FormatVDest( char* pBuff, Dests nReg, uint nWidth )\n        {\n            FormatVReg(pBuff,nReg-DEST_VGPR_FIRST,nWidth);\n        }\n       \n        void FormatGenericSource( char* buff, Sources nSrc, uint nDWORDs )\n        {\n            if( nSrc >= SRC_SGPR_FIRST && nSrc <= SRC_SGPR_LAST ) // sgpr\n            {\n                FormatSReg( buff,  nSrc-SRC_SGPR_FIRST, nDWORDs );\n                return; // sgpr\n            }\n            if( nSrc >= SRC_TTMP_FIRST && nSrc <= SRC_TTMP_LAST ) // trap temporaries\n            {\n                FormatIndexedReg( buff, \"TT\", nSrc-SRC_TTMP_FIRST, nDWORDs );\n                return; // sgpr\n            }\n            if( nSrc >= SRC_VGPR_FIRST && nSrc <= SRC_VGPR_LAST ) // vgpr\n            {\n                FormatVReg( buff, nSrc-SRC_VGPR_FIRST, nDWORDs );\n                return; // sgpr\n            }\n\n            if( nSrc >= SRC_CI_POSITIVE_FIRST && nSrc <= SRC_CI_POSITIVE_LAST ) // positive int 1 to 64\n            {\n                sprintf( buff, \"%d\", (nSrc - SRC_CI_POSITIVE_FIRST)+1 );\n                return;\n            }\n            if( nSrc >= SRC_CI_NEGATIVE_FIRST && nSrc <= SRC_CI_NEGATIVE_LAST ) // negative int, -1 to 16\n            {\n                sprintf( buff, \"%d\", (SRC_CI_NEGATIVE_FIRST-1)-nSrc);\n                return;\n            }\n            \n            // various 64-bit architectural regs\n            switch( nSrc )\n            {\n            case SRC_FSCR_LO:\n            case SRC_FSCR_HI:\n                FormatReg64( buff, \"FSCR\", nSrc-SRC_FSCR_LO, nDWORDs );\n                return ;\n            case SRC_VCC_LO  : \n            case SRC_VCC_HI  : \n                FormatReg64( buff, \"VCC\", nSrc-SRC_VCC_LO, nDWORDs );\n                return;\n            case SRC_TBA_LO  : \n            case SRC_TBA_HI  : \n                FormatReg64( buff, \"TBA\", nSrc-SRC_TBA_LO, nDWORDs );\n                return;\n            case SRC_TMA_LO  : \n            case SRC_TMA_HI  :\n                FormatReg64( buff, \"TMA\", nSrc-SRC_TMA_LO, nDWORDs );\n                return;\n            case SRC_EXEC_LO :\n            case SRC_EXEC_HI :\n                FormatReg64( buff, \"EXEC\", nSrc-SRC_EXEC_LO, nDWORDs );\n                return;\n            case SRC_XNACK_MASK_LO:\n            case SRC_XNACK_MASK_HI:\n                FormatReg64( buff, \"XNACK\", nSrc-SRC_XNACK_MASK_LO,nDWORDs );\n                break;\n            }\n\n            switch( nSrc )\n            {\n            case SRC_M0:                strcpy( buff, \"M0\" );     break;\n            case SRC_C_ZERO:            strcpy( buff, \"0\" );      break;\n            case SRC_CF_ONEHALF:        strcpy( buff, \"0.5\");     break;\n            case SRC_CF_MINUS_ONEHALF:  strcpy( buff, \"-0.5\");    break;\n            case SRC_CF_ONE:            strcpy( buff, \"1.0\");     break;\n            case SRC_CF_MINUS_ONE:      strcpy( buff, \"-1.0\");    break;\n            case SRC_CF_TWO:            strcpy( buff, \"2.0\");     break;\n            case SRC_CF_MINUS_TWO:      strcpy( buff, \"-2.0\");    break;\n            case SRC_CF_FOUR:           strcpy( buff, \"4.0\");     break;\n            case SRC_CF_MINUS_FOUR:     strcpy( buff, \"-4.0\");    break;\n            case SRC_CF_INV_2PI:        strcpy( buff, \"1/2PI\");   break;\n            case SRC_VCCZ       :       strcpy( buff, \"VCCZ\");    break;\n            case SRC_EXECZ      :       strcpy( buff, \"EXECZ\");   break;\n            case SRC_SCC        :       strcpy( buff, \"SCC\");     break;\n            case SRC_LDS_DIRECT :       strcpy( buff, \"LDS[M0]\"); break;\n            default:                    strcpy( buff, \"???SOURCE???\");  break;\n            }\n        }\n\n        void FormatDest( char* buff, Dests nSrc, uint nDWORDs )\n        {\n            if( nSrc >= DEST_SGPR_FIRST && nSrc <= DEST_SGPR_LAST ) // sgpr\n            {\n                FormatSReg( buff,  nSrc-DEST_SGPR_FIRST, nDWORDs );\n                return; // sgpr\n            }\n            if( nSrc >= DEST_TTMP_FIRST && nSrc <= DEST_TTMP_LAST ) // trap temporaries\n            {\n                FormatIndexedReg( buff, \"TT\", nSrc-DEST_TTMP_FIRST, nDWORDs );\n                return; // sgpr\n            }\n            if( nSrc >= DEST_VGPR_FIRST && nSrc <= DEST_VGPR_LAST ) // vgpr\n            {\n                FormatVReg( buff, nSrc-DEST_VGPR_FIRST, nDWORDs );\n                return; // sgpr\n            }\n\n            // various 64-bit architectural regs\n            switch( nSrc )\n            {\n            case DEST_FSCR_LO:\n            case DEST_FSCR_HI:\n                FormatReg64( buff, \"FSCR\", nSrc-DEST_FSCR_LO, nDWORDs );\n                return ;\n            case DEST_VCC_LO  : \n            case DEST_VCC_HI  : \n                FormatReg64( buff, \"VCC\", nSrc-DEST_VCC_LO, nDWORDs );\n                return;\n            case DEST_TBA_LO  : \n            case DEST_TBA_HI  : \n                FormatReg64( buff, \"TBA\", nSrc-DEST_TBA_LO, nDWORDs );\n                return;\n            case DEST_TMA_LO  : \n            case DEST_TMA_HI  :\n                FormatReg64( buff, \"TMA\", nSrc-DEST_TMA_LO, nDWORDs );\n                return;\n            case DEST_EXEC_LO :\n            case DEST_EXEC_HI :\n                FormatReg64( buff, \"EXEC\", nSrc-DEST_EXEC_LO, nDWORDs );\n                return;\n            case DEST_XNACK_MASK_HI:\n            case DEST_XNACK_MASK_LO:\n                FormatReg64( buff, \"XNACK\", nSrc-DEST_XNACK_MASK_LO, nDWORDs);\n                break;\n            }\n\n            switch( nSrc )\n            {\n            case DEST_M0:    strcpy( buff, \"M0\" );    break;\n            case DEST_SCC:   strcpy( buff, \"SCC\");    break;\n            case DEST_VCC:   strcpy( buff, \"VCC\");    break;\n            case DEST_VSKIP: strcpy( buff, \"VSKIP\");  break;\n            default:         strcpy( buff, \"???DEST??\"); break;\n            }\n        }\n       \n\n        template< class TInstruction >\n        void FormatTrailingLiteral( char* buff, const TInstruction* pI )\n        {\n            uint n = pI->GetLiteralAsDWORD();\n            sprintf( buff, \"0x%x\", n );\n        }\n\n        template< class TInstruction >\n        void FormatSource( char* buff, Sources nSrc, uint nDWORDs, const TInstruction* pI )\n        {\n            if( nSrc == SRC_LITERAL )\n                FormatTrailingLiteral( buff, pI ) ; \n            else\n                FormatGenericSource( buff, nSrc, nDWORDs );\n        }\n\n        void FormatVOPSource( char* buff, uint nDWORDS, Sources nSrc, bool abs, bool negate, const VectorInstruction* pI )\n        {\n            if( nSrc == SRC_LITERAL )\n            {\n                FormatTrailingLiteral(buff,pI);\n                return;\n            }\n\n            char tmp0[64];\n            char tmp1[64];\n            FormatGenericSource( tmp0, nSrc, nDWORDS );\n            if( abs )\n            {\n                sprintf( tmp1, \"|%s|\", tmp0 );\n                strcpy( tmp0, tmp1 );\n            }\n            if( negate )\n            {\n                sprintf( tmp1, \"-%s\", tmp0 );\n                strcpy(tmp0,tmp1 );\n            }\n            strcpy(buff,tmp0);\n        }\n\n\n        static void SynthesizeLabelName( char* out, const GCN::ScalarInstruction* pInst, const std::vector<const uint8*>* pLabels )\n        {\n            const uint8* pTarget = pInst->GetBranchTarget();\n            size_t i=0;\n            while( pLabels && i < pLabels->size() )\n            {\n                if( pLabels->at(i) == pTarget )\n                    break;\n                i++;\n            }\n\n            if( pLabels && i < pLabels->size() )\n            {\n                sprintf( out, \"Label_%04u\", i );\n            }\n            else if( pInst->GetBranchTarget() )\n            {\n                sprintf( out, \"PC + %d\", pInst->GetBranchOffset() );\n            }\n            else\n            {\n                sprintf( out, \"????\");\n            }\n        }\n\n        void PrintLabeledBranch( IPrinter& printer, const ScalarInstruction* pInst, const char* pLabelName )\n        {\n            Printf( printer, OPCODE_FORMAT\" %s\\n\", EnumToString(pInst->GetOpcode()), pLabelName );\n        }\n\n        \n        void Disassemble( IPrinter& printer, const ScalarInstruction* pInst, const char* pLabelName )\n        {\n            const char* pOpcode = EnumToString(pInst->GetOpcode());\n            char src0[64];\n            char src1[64];\n            char dst[64];\n                \n            switch( pInst->GetOpcode() )\n            {\n            case S_BARRIER:\n            case S_ENDPGM:\n            case S_ENDPGM_SAVED:\n            case S_SET_GPR_IDX_OFF:\n            case S_ICACHE_INV:\n                Printf( printer, OPCODE_FORMAT\"\\n\",pOpcode); \n                break;\n            case S_NOP:     \n                Printf( printer, OPCODE_FORMAT\"(%u)\\n\",\"S_NOP\",pInst->ReadSIMMBits(2,0)+1); \n                break;\n            case S_SETHALT:\n                Printf( printer, OPCODE_FORMAT\"(%u)\\n\", \"S_SETHALT\", pInst->ReadSIMMBits(0,0) );\n                break;\n            case S_SLEEP:\n                Printf( printer, OPCODE_FORMAT\"(%u)\\n\", \"S_SLEEP\", 64*pInst->ReadSIMMBits(2,0) );\n                break;\n            case S_SETPRIO:\n                Printf( printer, OPCODE_FORMAT\"(%u)\\n\", \"S_SETPRIO\", pInst->ReadSIMMBits(1,0) );\n                break;\n            case S_TRAP:\n                Printf( printer, OPCODE_FORMAT\"(%u)\\n\", \"S_TRAP\", pInst->ReadSIMMBits(7,0) );\n                break;\n            case S_INCPERFLEVEL:\n            case S_DECPERFLEVEL:\n                Printf( printer, OPCODE_FORMAT\"(%u)\\n\", pOpcode, pInst->ReadSIMMBits(3,0) );\n                break;\n\n            case S_SENDMSG:\n            case S_SENDMSGHALT:\n                {\n                    uint nMsg = pInst->ReadSIMMBits(3,0);\n                    switch( nMsg )\n                    {\n                    case 1: // interrupt\n                        Printf(printer,OPCODE_FORMAT\"  INTERRUPT(M0)\\n\",pOpcode);\n                        break; \n                    case 2: // geometry shader goodness\n                    case 3:\n                        {\n                            // 2 is GS.  3 is GS_DONE\n                            // the GS op is NOP(0), CUT(1), EMIT(2), EMIT-CUT(3)\n                            uint nGSOp = pInst->ReadSIMMBits(5,4);                            \n                            Printf( printer, OPCODE_FORMAT\"  GS: %s%s%s\\n\",\n                                   pOpcode,\n                                   (nGSOp&2) ? \" EMIT \" : \"\",\n                                   (nGSOp&1) ? \" CUT \" : \"\",\n                                   (nMsg == 3) ? \"DONE\" : \"\");\n                        }                       \n                        break; \n\n                    default: // something mysterious\n                        Printf(printer,OPCODE_FORMAT\"  0x%04x\\n\",pOpcode,pInst->ReadSIMMBits(15,0) );\n                        break; \n                    }\n\n                }\n                break;\n\n            case S_WAITCNT:\n                {\n                    uint VMCNT   = pInst->GetVMwaitCount();\n                    uint EXPCNT  = pInst->GetEXPWaitCount();\n                    uint LKGMCNT = pInst->GetLCGMWaitCount();\n                    \n                    char COUNTS[256]=\"\";\n                    if( VMCNT != 15 )\n                        catprintf(COUNTS, \"vmcnt(%u) \",VMCNT);\n                    if( EXPCNT != 7 )\n                        catprintf(COUNTS, \"expcnt(%u) \",EXPCNT);\n                    if( LKGMCNT != 15 )\n                        catprintf(COUNTS, \"lkgmcnt(%u) \",LKGMCNT );\n\n                    // NOTE: Max for LKGMCNT is really 31, but AMD driver seems to\n                    //  think its 15, because it constantly waits on that.\n\n                    Printf( printer, OPCODE_FORMAT\"     %s\\n\", \"S_WAITCNT\", COUNTS );\n                }\n                break;\n\n            case S_BRANCH         :         //: PC = PC + signext(SIMM16 * 4) + 4.\n            case S_CBRANCH_SCC0   :         //: if(SCC == 0) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n            case S_CBRANCH_SCC1   :         //: if(SCC == 1) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n            case S_CBRANCH_VCCZ   :         //: if(VCC == 0) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n            case S_CBRANCH_VCCNZ  :         //: if(VCC != 0) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n            case S_CBRANCH_EXECZ  :         //: if(EXEC == 0) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n            case S_CBRANCH_EXECNZ :         //: if(EXEC != 0) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n            case S_CBRANCH_CDBGSYS :        // : If (conditional_debug_system != 0) then PC = PC + signext(SIMM16 * 4) + 4; else NOP.\n            case S_CBRANCH_CDBGUSER:        // : If (conditional_debug_user != 0) then PC = PC + signext(SIMM16 * 4) + 4; else NOP.\n            case S_CBRANCH_CDBGSYS_OR_USER: // : I f (conditional_debug_system || conditional_debug_user) then PC = PC + signext(SIMM16 * 4) + 4; else NOP.\n            case S_CBRANCH_CDBGSYS_AND_USER:// : If (conditional_debug_system && conditional_debug_user) then PC = PC + signext(SIMM16 * 4) + 4; else NOP.\n                PrintLabeledBranch(printer,pInst,pLabelName);\n                break;\n            case S_CBRANCH_G_FORK:\n                {\n                    FormatGenericSource(src0,pInst->GetSource(0),2);\n                    FormatGenericSource(src1,pInst->GetSource(1),2);\n                    Printf(printer,UNARY_OP_FORMAT, pOpcode, src0,src1 );\n                }\n                break;\n\n\n          \n            case S_MOVRELD_B32:\n                {\n                    FormatSReg(dst,pInst->GetDest(),1);\n                    FormatSource(src0,pInst->GetSource(0),1,pInst);\n                    Printf(printer,OPCODE_FORMAT \" s[M0+%s] = s[%s]\\n\", \"S_MOVRELD_B32\", dst, src0 );\n                }\n                break;\n            case S_MOVRELD_B64:\n                {\n                    FormatSReg(dst,pInst->GetDest(),1);\n                    FormatSource(src0,pInst->GetSource(0),1,pInst);\n                    Printf(printer,OPCODE_FORMAT \" s[M0+%s][2] = s[%s][2]\\n\", \"S_MOVRELD_B64\", dst, src0 );\n                }\n                break;\n            case S_MOVRELS_B32:\n                {\n                    FormatSReg(dst,pInst->GetDest(),1);\n                    FormatSource(src0,pInst->GetSource(0),1,pInst);\n                    Printf(printer,OPCODE_FORMAT \" s[%s] = s[M0+%s]\\n\", \"S_MOVRELS_B32\", dst, src0 );\n                }\n                break;\n            case S_MOVRELS_B64:\n                {\n                    FormatSReg(dst,pInst->GetDest(),1);\n                    FormatSource(src0,pInst->GetSource(0),1,pInst);\n                    Printf(printer,OPCODE_FORMAT \" s[%s][2] = s[M0+%s][2]\\n\", \"S_MOVRELS_B64\", dst, src0 );\n                }\n                break;\n           \n            case S_MOVK_I32          :\n            case S_CMOVK_I32         :\n            case S_CMPK_EQ_I32       :\n            case S_CMPK_LG_I32       :\n            case S_CMPK_GT_I32       :\n            case S_CMPK_GE_I32       :\n            case S_CMPK_LT_I32       :\n            case S_CMPK_LE_I32       :\n            case S_CMPK_EQ_U32       :\n            case S_CMPK_LG_U32       :\n            case S_CMPK_GT_U32       :\n            case S_CMPK_GE_U32       :\n            case S_CMPK_LT_U32       :\n            case S_CMPK_LE_U32       :\n            case S_ADDK_I32          :\n            case S_MULK_I32          :\n                {\n                    char dst[64];\n                    FormatDest(dst,pInst->GetDest(),1);\n                    Printf( printer, OPCODE_FORMAT \" %6s,%6d\\n\", EnumToString(pInst->GetOpcode()), dst, pInst->GetSIMM16());\n                }\n                break;\n\n            case S_SET_GPR_IDX_MODE:\n                {\n                    uint nIMM4 = pInst->GetSIMM16();\n                    char flags[256]=\"\";\n                    if( nIMM4 & 1 )\n                        catprintf(flags, \", VSRC0_REL\");\n                    if( nIMM4 & 2 )\n                        catprintf(flags, \", VSRC1_REL\");\n                    if( nIMM4 & 4 )\n                        catprintf(flags, \", VSRC2_REL\");\n                    if( nIMM4 & 8 )\n                        catprintf(flags, \", VDST_REL\");\n                    \n                    Printf( printer, OPCODE_FORMAT \" %s\\n\", pOpcode,flags);\n                }\n                break;\n            case S_SET_GPR_IDX_ON:\n                {\n                    char src0[64];\n                    FormatSource(src0,pInst->GetSource(0),1,pInst);\n\n                    uint nIMM4 = pInst->GetSIMM16();\n                    char flags[256]=\"\";\n                    if( nIMM4 & 1 )\n                        catprintf(flags, \", VSRC0_REL\");\n                    if( nIMM4 & 2 )\n                        catprintf(flags, \", VSRC1_REL\");\n                    if( nIMM4 & 4 )\n                        catprintf(flags, \", VSRC2_REL\");\n                    if( nIMM4 & 8 )\n                        catprintf(flags, \", VDST_REL\");\n\n                    Printf( printer, OPCODE_FORMAT \" %6s%s\\n\", pOpcode, src0,flags);\n                }\n                break;\n\n\n\n            case S_CBRANCH_I_FORK:\n                PrintLabeledBranch(printer,pInst,pLabelName);\n                break;\n\n            case S_GETREG_B32:\n            case S_SETREG_B32:\n            case S_SETREG_IMM32_B32:\n                {\n                    char dst[64];\n                    FormatDest(dst,pInst->GetDest(),1);\n                    uint nSize  = pInst->ReadSIMMBits(10,6);\n                    uint nStart = pInst->ReadSIMMBits(15,11);\n                    uint nEnd   = nSize+nStart+1;\n                    uint nReg   = pInst->ReadSIMMBits(5,0);\n\n                    char HWReg[128];\n                    sprintf( HWReg, \"HWREG%u(%u:%u)\", nReg,nEnd,nStart );\n\n                    switch( pInst->GetOpcode() )\n                    {\n                    case S_GETREG_B32:\n                        Printf(printer, OPCODE_FORMAT \" %s = %s\\n\", EnumToString(pInst->GetOpcode()), dst, HWReg );\n                        break;\n\n                    case S_SETREG_B32:\n                        Printf(printer, OPCODE_FORMAT \" %s = %s\\n\", EnumToString(pInst->GetOpcode()), HWReg, dst);\n                        break;\n\n                    case S_SETREG_IMM32_B32:\n                        Printf(printer, OPCODE_FORMAT \" %s = %x\\n\", EnumToString(pInst->GetOpcode()), \n                               HWReg, \n                               pInst->GetLiteralAsDWORD() & ((1<<nSize)-1));\n                        break;\n                    }\n                }\n                break;\n\n\n            default:\n                {\n\n                    switch( pInst->GetSourceCount() )\n                    {\n                    case 2:\n                        {\n                            FormatSource( src0, pInst->GetSource(0), pInst->GetArg0WidthInDWORDs(), pInst );\n                            FormatSource( src1, pInst->GetSource(1), pInst->GetArg1WidthInDWORDs(), pInst );\n                            FormatDest( dst, pInst->GetDest( ), pInst->GetResultWidthInDWORDs() );\n                            Printf( printer, BINARY_OP_FORMAT, pOpcode, dst, src0, src1 );\n                        }\n                        break;\n                    case 1:\n                        {\n                            uint nDstWidth = pInst->GetResultWidthInDWORDs();\n                            uint nSrcWidth = pInst->GetArg0WidthInDWORDs();\n                            const char* pOpcode = EnumToString(pInst->GetOpcode());\n                            FormatSource( src0, pInst->GetSource(0),  nSrcWidth, pInst );\n                            FormatDest( dst,    pInst->GetDest(),  nDstWidth );\n                            Printf( printer, UNARY_OP_FORMAT, pOpcode,dst,src0);\n                        }\n                        break;\n                    default:\n                        {\n                            Printf(printer,\"????SCALAR?????\\n\");\n                        }\n                        break;\n                    }\n                }\n            }\n\n        }\n\n\n        void Disassemble( IPrinter& printer, const ScalarMemoryInstruction* pInst )\n        {\n            char glc[4]=\"\";\n            if( pInst->IsGLC() )\n                strcpy(glc,\"GLC\");\n\n            switch( pInst->GetOpcode() )\n            {\n            case S_LOAD_DWORD          : \n            case S_LOAD_DWORDX2        : \n            case S_LOAD_DWORDX4        : \n            case S_LOAD_DWORDX8        : \n            case S_LOAD_DWORDX16       : \n            case S_BUFFER_LOAD_DWORD   : \n            case S_BUFFER_LOAD_DWORDX2 : \n            case S_BUFFER_LOAD_DWORDX4 : \n            case S_BUFFER_LOAD_DWORDX8 : \n            case S_BUFFER_LOAD_DWORDX16: \n            case S_STORE_DWORD            :\n            case S_STORE_DWORDX2          :\n            case S_STORE_DWORDX4          :\n            case S_BUFFER_STORE_DWORD     :\n            case S_BUFFER_STORE_DWORDX2   :\n            case S_BUFFER_STORE_DWORDX4   :\n                {\n                    char base[64];\n                    char dest[64];\n                    char offs[64];\n                    uint nBaseReg = pInst->GetBase();\n                    FormatDest( dest, pInst->GetDest(), pInst->GetResultWidthInDWORDs() );\n                    FormatSReg( base, nBaseReg, pInst->GetResourceWidthInDWORDs() );\n\n                    uint nOffset = pInst->GetOffset();\n                    if( pInst->IsOffsetIMM() )\n                        sprintf( offs, \"%u\", nOffset );\n                    else\n                        FormatSReg( offs, nOffset, 1 );\n\n                    Printf( printer, OPCODE_FORMAT \" %6s, %6s, %6s %s\\n\", EnumToString(pInst->GetOpcode()), dest, base, offs, glc);\n                }\n                break;\n            case S_ATC_PROBE:\n            case S_ATC_PROBE_BUFFER:\n                {\n                    char base[64];\n                    char offs[64];\n                    uint nBaseReg = pInst->GetBase();\n                    FormatSReg( base, nBaseReg, 2 );\n\n                    uint nOffset = pInst->GetOffset();\n                    if( pInst->IsOffsetIMM() )\n                        sprintf( offs, \"%u\", nOffset );\n                    else\n                        FormatSReg( offs, nOffset, 1 );\n\n                    Printf( printer, OPCODE_FORMAT \" %6s, %6s  %s\\n\", EnumToString(pInst->GetOpcode()), base, offs, glc );\n   \n                }\n                break;\n\n            case S_MEMTIME: \n            case S_MEMREALTIME:\n                {\n                    char dst[64];\n                    FormatDest(dst,pInst->GetDest(), 2 );\n                    Printf( printer, OPCODE_FORMAT \" %6s  %s\\n\", EnumToString(pInst->GetOpcode()),dst, glc);\n                }\n                break;\n\n            case S_DCACHE_WB:\n            case S_DCACHE_WB_VOL:\n            case S_DCACHE_INV_VOL      : \n            case S_DCACHE_INV          :   \n                Printf( printer, OPCODE_FORMAT \"  %s \\n\", EnumToString(pInst->GetOpcode()), glc );\n                break;\n            default:\n                Printf( printer, OPCODE_FORMAT \"\\n\", \"???SMEM???\");\n                break;\n            }\n        }\n\n\n        void Disassemble( IPrinter& printer, const VectorInstruction* pInst )\n        {\n            const char* pOpcode = EnumToString(pInst->GetOpcode());\n            char src0[64];\n            char src1[64];\n            char src2[64];\n            char vdst[64];\n            char sdst[64];\n            char suffixes[64];\n\n            uint abs    = pInst->GetSourceAbsMask();\n            uint negate = pInst->GetSourceNegateMask();\n\n            // TODO: DXX doesn't seem to use 'omod' and I can't tell what the values are supposed to map to\n            if( pInst->GetOMod() )\n                sprintf( suffixes, \"OMOD(%u)\", pInst->GetOMod());\n            else\n                sprintf( suffixes, \"\" );\n\n            bool clamp  = pInst->GetClamp();\n            if( clamp )\n                catprintf( suffixes, \"CLAMP\");\n           \n            switch( pInst->GetOpcode() )\n            {\n            case V_MADAK_F16:\n            case V_MADAK_F32: \n                FormatDest(vdst,pInst->GetVDst(),1);\n                FormatVOPSource( src0, 1, pInst->GetSrc0(), (abs & 1) != 0, (negate & 1) != 0, pInst );\n                FormatVOPSource( src1, 1, pInst->GetVSrc1(), (abs & 2) != 0, (negate & 2) != 0, pInst );\n                Printf(printer, OPCODE_FORMAT \" %6s=%6s*%s + %f\\n\", pOpcode, vdst, src0, src1, pInst->GetLiteralAsFloat() );\n                break;\n            \n            case V_MADMK_F16:\n            case V_MADMK_F32:\n                FormatDest(vdst,pInst->GetVDst(),1);\n                FormatVOPSource( src0, 1, pInst->GetSrc0(), (abs & 1) != 0, (negate & 1) != 0, pInst );\n                FormatVOPSource( src1, 1, pInst->GetVSrc1(), (abs & 2) != 0, (negate & 2) != 0, pInst );\n                Printf(printer, OPCODE_FORMAT \" %6s=%6s *%10f + %s\\n\", pOpcode, vdst, src0, pInst->GetLiteralAsFloat(), src1 );\n                break;\n\n            case V_NOP:     Printf( printer, OPCODE_FORMAT\"\\n\", \"V_NOP\"    ); break; \n            case V_CLREXCP: Printf( printer, OPCODE_FORMAT\"\\n\", \"V_CLREXCP\"); break;\n            case V_MOVRELD_B32:\n                {\n                    FormatDest(vdst,pInst->GetVDst(),1);\n                    FormatVOPSource(src0,1,pInst->GetSrc0(),abs&1,negate&1,pInst);\n                    Printf(printer,OPCODE_FORMAT \" v[M0+%s] = v[%s]\\n\", \"V_MOVRELD\", vdst, src0 );\n                }\n                break;\n            case V_MOVRELS_B32:\n                {\n                    FormatDest(vdst,pInst->GetVDst(),1);\n                    FormatVOPSource(src0,1, pInst->GetSrc0(),abs&1,negate&1,pInst);\n                    Printf(printer,OPCODE_FORMAT \" v[%s] = v[M0+%s]\\n\", \"V_MOVRELS\", vdst, src0 );\n                }\n                break;\n            case V_MOVRELSD_B32:\n                {\n                    FormatDest(vdst,pInst->GetVDst(),1);\n                    FormatVOPSource(src0,1, pInst->GetSrc0(),abs&1,negate&1,pInst);\n                    Printf(printer,OPCODE_FORMAT \" v[M0+%s] = v[M0+%s]\\n\", \"V_MOVRELSD\", vdst, src0 );\n                }\n                break;      \n\n            default:\n                {\n                    uint nSrc0Width   = pInst->GetSrc0WidthInDWORDS();\n                    uint nSrc1Width   = pInst->GetSrc1WidthInDWORDS();\n                    uint nSrc2Width   = pInst->GetSrc2WidthInDWORDS();\n                    uint nResultWidth = pInst->GetResultWidthInDWORDS();\n\n                    FormatDest( vdst, pInst->GetVDst(), nResultWidth );\n                  \n                    if( pInst->GetDestCount() == 2 )\n                    {\n                        FormatDest( sdst, pInst->GetSDst(), 1 );\n                        char out[64];\n                        sprintf( out, \"(%s,%s)\", vdst, sdst );\n                        Printf(printer,OPCODE_FORMAT \" %10s,\",pOpcode,out);\n                    }\n                    else\n                    {\n                        Printf(printer,OPCODE_FORMAT \" %6s,\", pOpcode, vdst );\n                    }\n\n                    switch( pInst->GetSourceCount() )\n                    {\n                    case 3:\n                        FormatVOPSource( src0, nSrc0Width, pInst->GetSrc0(), (abs & 1) != 0, (negate & 1) != 0, pInst );\n                        FormatVOPSource( src1, nSrc1Width, pInst->GetVSrc1(), (abs & 2) != 0, (negate & 2) != 0, pInst );\n                        FormatVOPSource( src2, nSrc2Width, pInst->GetVSrc2(), (abs & 4) != 0, (negate & 4) != 0, pInst );\n                        Printf(printer, \"%6s,%6s,%6s   %s\\n\", src0,src1,src2,suffixes );\n                        break;\n\n                    case 2:\n                        FormatVOPSource( src0, nSrc0Width, pInst->GetSrc0(), (abs & 1) != 0, (negate & 1) != 0, pInst );\n                        FormatVOPSource( src1, nSrc1Width, pInst->GetVSrc1(), (abs & 2) != 0, (negate & 2) != 0, pInst );\n                        Printf(printer, \"%6s,%6s   %s\\n\", src0,src1,suffixes );\n                        break;\n\n                    case 1:\n                        FormatVOPSource( src0, nSrc0Width, pInst->GetSrc0(), (abs & 1) != 0, (negate & 1) != 0, pInst );\n                        Printf(printer, \"%6s   %s\\n\", src0,suffixes );\n                        break;\n                    }\n\n                }\n                break;\n            }\n        }\n\n\n        \n        void Disassemble( IPrinter& printer, const InterpolationInstruction* pInst  )\n        {\n            uint nSrc = pInst->GetVSrc() - SRC_VGPR_FIRST;\n            char dst[8];\n            sprintf( dst, \"v%u\", pInst->GetVDst() - DEST_VGPR_FIRST );\n\n            static const char* CHANNELS[] = { \"X\",\"Y\",\"Z\",\"W\"};\n            static const char* SOURCES[]  = { \"P10\",\"P20\",\"P0\" };\n\n            char op[256];\n            sprintf( op, \"%s(a%0u.%s)\",\n                    EnumToString(pInst->GetOpcode()),\n                    pInst->GetAttributeIndex(),\n                    CHANNELS[pInst->GetAttributeChannel()] );\n\n            switch(pInst->GetOpcode())\n            {\n            case V_INTERP_P1LL_F16:\n            case V_INTERP_P1_F32:   Printf( printer ,OPCODE_FORMAT \" %6s =  P10*v%u + P0\\n\", op, dst, nSrc ); break;\n            case V_INTERP_P2_F16:\n            case V_INTERP_P2_F32:   Printf( printer, OPCODE_FORMAT \" %6s += P20*v%u\\n\", op, dst, nSrc ); break;\n            case V_INTERP_MOV_F32:Printf( printer, OPCODE_FORMAT \" %6s = %s\\n\", op, dst, SOURCES[nSrc&3] ); break;\n            default: Printf(printer,\"????INTERP????\\n\"); break;\n                // TODO\n             //V_INTERP_P1LV_F16,     // : D.f32 = P10.f16 * S0.f32 + (S2.u32 >> (attr_word * 16)).f16. 'LV' stands for 'One LDS and one VGPR argument'. S2 holds two parameters, attr_word selects the high or low word of the VGPR for this calculation, as well as the high or low half of the LDS data.\" Meant for use with 16-bank LDS. NOTE: In textual representations the I/J VGPR is the first source and the attribute is the second source; however in the VOP3 encoding the attribute is stored in the src0 field and the VGPR is stored in the src1 field.\n             \n            }\n        }\n\n\n        void Disassemble( IPrinter& printer, const ExportInstruction* pInst  )\n        {\n            uint nTarget = pInst->GetTarget();\n            uint nRegMask = pInst->GetExportMask();\n\n            char r[4][8];\n            sprintf( r[0], \"v%u\", pInst->GetVSrc0() - SRC_VGPR_FIRST );\n            sprintf( r[1], \"v%u\", pInst->GetVSrc1() - SRC_VGPR_FIRST );\n            sprintf( r[2], \"v%u\", pInst->GetVSrc2() - SRC_VGPR_FIRST );\n            sprintf( r[3], \"v%u\", pInst->GetVSrc3() - SRC_VGPR_FIRST );\n\n            const char* pOpcode = pInst->GetCompressBit() ? \"EXP_FP16\" : \"EXP\";\n                \n            char flags[256];\n            sprintf(flags, \"(%s%s%s)\", \n                    EnumToString(pInst->GetTarget()),\n                    pInst->GetValidMaskBit() ? \",VM\" : \"\",\n                    pInst->GetDoneBit() ? \",DONE\" : \"\" );\n\n            Printf( printer, OPCODE_FORMAT \" %6s,%4s,%4s,%4s %s\\n\",\n                    pOpcode,\n                    nRegMask&1 ? r[0] : \"____\",\n                    nRegMask&2 ? r[1] : \"____\",\n                    nRegMask&4 ? r[2] : \"____\",\n                    nRegMask&8 ? r[3] : \"____\",\n                    flags );\n\n        }\n       \n\n        \n        template< class BUFFInstruction >\n        void FormatBuffAddress( char* offset, const BUFFInstruction* pInst )\n        {\n            if( pInst->IsAddr64() )\n            {\n                // address is:  resource_base + soffset+ioffset + vgpr[2]\n                if( pInst->GetSOffset() != SRC_C_ZERO )\n                    FormatGenericSource(offset,pInst->GetSOffset(), 1 );\n\n                if( pInst->GetOffset() )\n                    addprintf( offset, \"%u\", pInst->GetOffset() );\n                \n                // send voffset[2] as full address\n                char reg[64];\n                FormatVReg( reg, pInst->GetVAddr(), 2 );\n                addprintf(offset, \"%s\", reg );\n            }\n            else\n            {\n                // address is: resource_base + soffset+(ioffset or vgpr) + resource_stride*(vgpr_idx)\n\n                // byte offset\n                if( pInst->GetSOffset() != SRC_C_ZERO )\n                    FormatGenericSource(offset,pInst->GetSOffset(), 1 );\n                \n                if( !pInst->IsOffN() )\n                {\n                    // send literal offset from instruction\n                    if( pInst->GetOffset() )\n                        addprintf( offset, \"%u\", pInst->GetOffset() );  \n                }\n                else\n                {                    \n                    // send vaddr gpr as offset.  If both index and offset are used, offset is the second one\n                    Sources nOffsetReg = pInst->GetVAddr();\n                    if( pInst->IsIdxN() )\n                        nOffsetReg = (Sources)(nOffsetReg+1);\n\n                    char reg[64];\n                    FormatVSrc( reg, nOffsetReg, 1 );\n                    addprintf( offset, \"%s\", reg );\n                }\n\n                if( pInst->IsIdxN() )\n                {\n                    char idx[64];\n                    FormatVSrc( idx, pInst->GetVAddr(), 1 );      // vaddr as an index\n                    addprintf( offset, \"%s*STRIDE\", idx );\n                }\n            }\n        }\n\n        \n        template< class BUFFInstruction >\n        void FormatBuffFlags( char* flags, const BUFFInstruction* pInst )\n        {\n            if( pInst->GetTFEBit() )\n                addprintf(flags,\"TFE\");\n            if( pInst->GetGLCBit() )\n                addprintf(flags,\"GLC\");\n            if( pInst->GetSLCBit() )\n                addprintf(flags,\"SLC\");\n        }\n        \n        void Disassemble( IPrinter& printer, const BufferInstruction* pInst )\n        {\n            uint nResultWidth = pInst->GetResultWidthInDWORDS();\n            if( !nResultWidth )\n            {\n                // oddballs like cache invalidation\n                Printf( printer, OPCODE_FORMAT\"\\n\", EnumToString(pInst->GetOpcode()) );\n            }\n            else\n            {\n                // destination\n                char dst[64];\n                if( pInst->IsDirectToLDS())\n                    sprintf(dst,\"LDS[M0]\");\n                else\n                    FormatVSrc( dst, pInst->GetVData(), nResultWidth );\n            \n                // resource constant\n                char rsrc[64]=\"\";\n                FormatSReg(rsrc, pInst->GetSResource(), 4 );\n\n                // address\n                char address[256]=\"\";\n                FormatBuffAddress(address,pInst);\n\n                \n                // flags\n                char flags[256]=\"\";\n                FormatBuffFlags(flags,pInst);\n\n                // format\n                char fmt[256]= \"\";\n                if( pInst->IsTBuffer() )\n                    sprintf( fmt, \"%s_%s\", EnumToString(pInst->GetDataFormat()), EnumToString(pInst->GetNumberFormat()) );\n\n                Printf( printer, OPCODE_FORMAT \" %6s, %8s [%s] %s %s\\n\",\n                        EnumToString(pInst->GetOpcode()), dst, rsrc,address,fmt,flags);\n            }\n             \n        }\n\n\n        void Disassemble( IPrinter& printer, const ImageInstruction* pInst )\n        {\n            char sampler[64]  = \"\";\n            char resource[64] = \"\";\n            uint nResourceWidth  = pInst->GetResourceWidthInDWORDS();\n            uint nSamplerWidth   = pInst->GetSamplerWidthInDWORDS();\n            if( nSamplerWidth )\n                FormatGenericSource( sampler, pInst->GetSSampler(), nSamplerWidth );\n            if( nResourceWidth )\n                FormatGenericSource( resource, pInst->GetSResource(), nResourceWidth );\n\n            char dmask[64]=\"\";\n            uint nDMask = pInst->GetDMask();\n            if( nDMask & 1 ) catprintf(dmask, \"R\");\n            if( nDMask & 2 ) catprintf(dmask, \"G\");\n            if( nDMask & 4 ) catprintf(dmask, \"B\");\n            if( nDMask & 8 ) catprintf(dmask, \"A\");\n\n            char flags[256] = \"\";\n            if( pInst->IsGLC() ) addprintf(flags,\"GLC\");\n            if( pInst->IsSLC() ) addprintf(flags,\"SLC\");\n            if( pInst->IsLWE() ) addprintf(flags,\"LWE\");\n            if( pInst->IsTFE() ) addprintf(flags,\"TFE\");\n            if( pInst->IsArray() ) addprintf(flags,\"ARRAY\");\n            if( pInst->IsUnnormalized() ) addprintf( flags,\"UNNORM\");\n            if( pInst->IsD16() ) addprintf(flags,\"D16\");\n\n            // NOTE: There is no way to infer the address width, because\n            //      it depends on the resource dimension, which in turn depends on the descriptor\n            //\n            char vaddr[64]=\"\";\n            char vdata[64]=\"\";\n            FormatVSrc(vaddr,pInst->GetVAddr(),1); \n            FormatVSrc(vdata,pInst->GetVData(),pInst->GetResultWidthInDWORDS());\n            \n            char opcode[512];\n            sprintf( opcode, \"%s(%s)\", EnumToString(pInst->GetOpcode()),dmask);\n\n            Printf(printer,OPCODE_FORMAT \" %6s,%6s,    T:%6s\", opcode,vdata,vaddr,resource);\n            \n            if( nSamplerWidth )\n                Printf(printer,\",    S:%6s\",sampler);\n\n            Printf(printer,\"    %s\\n\", flags);\n        }\n\n        \n\n        static void FormatDSAddress( char* pBuff, Sources nReg, uint nOffset )\n        {\n            char A[64];\n            FormatVReg(A,nReg-SRC_VGPR_FIRST,1);\n            if( nOffset )\n                sprintf(pBuff,\"DS[%s+%u]\", A,nOffset );\n            else\n                sprintf(pBuff,\"DS[%s]\", A );\n        }\n       \n\n        void Disassemble( IPrinter& printer, const DataShareInstruction* pInst ) \n        {\n            char opcode[256];\n            sprintf(opcode, \"%s%s\", EnumToString(pInst->GetOpcode()), pInst->IsGDS() ? \"(GDS)\":\"\");\n\n            switch( pInst->GetOpcode() )\n            {\n            // oddballs\n            default:     \n            case DS_NOP:\n                Printf( printer, OPCODE_FORMAT\"\\n\", opcode ); \n                break;\n\n            case DS_PERMUTE_B32:\n            case DS_BPERMUTE_B32:\n            case DS_SWIZZLE_B32         :   //  R = swizzle(Data(vgpr), offset1:offset0). Dword swizzle. no data is written to LDS. see ds_opcodes.docx for details.\n                {\n                    char R[64];\n                    char D[64];\n                    FormatVSrc(R,pInst->GetVData0(), 1);\n                    FormatVDest(D,pInst->GetVDest(), 1 );\n                    Printf( printer, OPCODE_FORMAT\" %6s,%6s,   0x%04x\\n\", opcode, R, D, pInst->GetOffset16() );\n                }\n                break;\n\n            case DS_GWS_SEMA_RELEASE_ALL:   //  GDS Only. Release all wavefronts waiting on this semaphore. ResourceID is in offset[4:0]. SEA ISLANDS ONLY\n            case DS_GWS_INIT            :   //  GDS only.\n            case DS_GWS_SEMA_V          :   //  GDS only.\n            case DS_GWS_SEMA_BR         :   //  GDS only.\n            case DS_GWS_SEMA_P          :   //  GDS only.\n            case DS_GWS_BARRIER         :   //  GDS only.\n                {\n                    uint nSemaphoreID = pInst->GetOffset16()& (0x1f);\n                    Printf( printer, OPCODE_FORMAT\" %u\\n\", EnumToString(pInst->GetOpcode()),nSemaphoreID);\n                }\n                break;\n\n            // 1 address, 1 data\n            case DS_ADD_U32             :  //  DS[A] = DS[A] + D0; uint add.\n            case DS_SUB_U32             :  //  DS[A] = DS[A] - D0; uint subtract.\n            case DS_RSUB_U32            :  //  DS[A] = D0 - DS[A]; uint reverse subtract.\n            case DS_INC_U32             :  //  DS[A] = (DS[A] >= D0 ? 0 : DS[A] + 1); uint increment.\n            case DS_DEC_U32             :  //  DS[A] = (DS[A] == 0 || DS[A] > D0 ? D0 : DS[A] - 1); uint decrement.\n            case DS_MIN_I32             :  //  DS[A] = min(DS[A], D0); int min.\n            case DS_MAX_I32             :  //  DS[A] = max(DS[A], D0); int max.\n            case DS_MIN_U32             :  //  DS[A] = min(DS[A], D0); uint min.\n            case DS_MAX_U32             :  //  DS[A] = max(DS[A], D0); uint max.\n            case DS_AND_B32             :  //  DS[A] = DS[A] & D0; Dword AND.\n            case DS_OR_B32              :  //  DS[A] = DS[A] | D0; Dword OR.\n            case DS_XOR_B32             :  //  DS[A] = DS[A] ^ D0; Dword XOR.\n            case DS_MSKOR_B32           :  //  DS[A] = (DS[A] ^ ~D0) | D1; masked Dword OR.\n            case DS_WRITE_B32           :  //  DS[A] = D0; write a Dword.\n            case DS_WRITE_B8            :  //  DS[A] = D0[7:0]; byte write.\n            case DS_WRITE_B16           :  //  DS[A] = D0[15:0]; short write.\n            case DS_ADD_U64             :  //  Uint add.\n            case DS_SUB_U64             :  //  Uint subtract.\n            case DS_RSUB_U64            :  //  Uint reverse subtract.\n            case DS_INC_U64             :  //  Uint increment.\n            case DS_DEC_U64             :  //  Uint decrement.\n            case DS_MIN_I64             :  //  Int min.\n            case DS_MAX_I64             :  //  Int max.\n            case DS_MIN_U64             :  //  Uint min.\n            case DS_MAX_U64             :  //  Uint max.\n            case DS_AND_B64             :  //  Dword AND.\n            case DS_OR_B64              :  //  Dword OR.\n            case DS_XOR_B64             :  //  Dword XOR.\n            case DS_MSKOR_B64           :  //  Masked Dword XOR.\n            case DS_WRITE_B64           :  //  Write.\n            case DS_MIN_F64             :  //  DS[A] = (D0 < DS[A]) ? D0 : DS[A]; float, handles NaN/INF/denorm.\n            case DS_MAX_F64             :  //  DS[A] = (D0 > DS[A]) ? D0 : DS[A]; float, handles NaN/INF/denorm.\n            case DS_MAX_F32             :  //  DS[A] = (D0 > DS[A]) ? D0 : DS[A]; float, handles NaN/INF/denorm.\n            case DS_WRITE_B96           :   //{DS[A+2], DS[A+1], DS[A]} = D0[95:0]; tri-dword write.\n            case DS_WRITE_B128          :   //{DS[A+3], DS[A+2], DS[A+1], DS[A]} = D0[127:0]; qword write.\n                {\n                    char D[64];\n                    FormatVSrc(D,pInst->GetVData0(),pInst->GetDataWidthInDWORDS() );\n\n                    char A[64];\n                    FormatVSrc(A,pInst->GetVAddr(), pInst->GetOffset16());\n\n                    Printf(printer,OPCODE_FORMAT\" %6s, %s\\n\", opcode, D, A );\n                }\n                break;\n\n                // address + result\n            case DS_READ_B32            :  //  R = DS[A]; Dword read.\n            case DS_READ_I8             :  //  R = signext(DS[A][7:0]}; signed byte read.\n            case DS_READ_U8             :  //  R = {24h0,DS[A][7:0]}; unsigned byte read.\n            case DS_READ_I16            :  //  R = signext(DS[A][15:0]}; signed short read.\n            case DS_READ_U16            :  //  R = {16h0,DS[A][15:0]}; unsigned short read.\n            case DS_READ_B64            :  // Dword read.\n            case DS_READ_B96            :   //Tri-Dword read.\n            case DS_READ_B128           :   //Qword read.\n                {\n                    char Dst[64];\n                    FormatVDest(Dst,pInst->GetVDest(),pInst->GetDataWidthInDWORDS() );\n\n                    char A[64];\n                    FormatDSAddress(A,pInst->GetVAddr(), pInst->GetOffset16());\n\n                    Printf(printer,OPCODE_FORMAT\" %6s, %s\\n\", opcode, Dst, A );\n                }\n                break;\n\n\n            // 1 address, 1 data, 1 return (return atomics, cas)\n            // NOTE: Some of these I'm not sure about, but am erring on the side of caution\n            //   Docs are not very explicit about some of these...\n            case DS_MIN_F32             :  //  DS[A] = (DS[A] < D1) ? D0 : DS[A]; float compare swap (handles NaN/INF/denorm).  NOTE: Doc says this uses D1 and D0.  Typo??\n            case DS_CMPST_B32           :  //  DS[A] = (DS[A] == D0 ? D1 : DS[A]); compare store.\n            case DS_CMPST_F32           :  //  DS[A] = (DS[A] == D0 ? D1 : DS[A]); compare store with float rules.\n            case DS_ADD_RTN_U32         :  //  Uint add.\n            case DS_SUB_RTN_U32         :  //  Uint subtract.\n            case DS_RSUB_RTN_U32        :  //  Uint reverse subtract.\n            case DS_INC_RTN_U32         :  //  Uint increment.\n            case DS_DEC_RTN_U32         :  //  Uint decrement.\n            case DS_MIN_RTN_I32         :  //  Int min.\n            case DS_MAX_RTN_I32         :  //  Int max.\n            case DS_MIN_RTN_U32         :  //  Uint min.\n            case DS_MAX_RTN_U32         :  //  Uint max.\n            case DS_AND_RTN_B32         :  //  Dword AND.\n            case DS_OR_RTN_B32          :  //  Dword OR.\n            case DS_XOR_RTN_B32         :  //  Dword XOR.\n            case DS_MSKOR_RTN_B32       :  //  Masked Dword OR.\n            case DS_MIN_RTN_F32         :  //  DS[A] = (DS[A] < D1) ? D0 : DS[A]; float compare swap (handles NaN/INF/denorm).\n            case DS_MAX_RTN_F32         :  //  DS[A] = (D0 > DS[A]) ? D0 : DS[A]; float, handles NaN/INF/denorm .\n            case DS_WRAP_RTN_B32        :  //  DS[A] = (DS[A] >= D0) ? DS[A] - D0 : DS[A] + D1. SEA ISLANDS ONLY\n            case DS_CMPST_B64           :  //  Compare store.\n            case DS_CMPST_F64           :  //  Compare store with float rules.\n            case DS_ADD_RTN_U64         :  //  Uint add.\n            case DS_SUB_RTN_U64         :  //  Uint subtract.\n            case DS_RSUB_RTN_U64        :  //  Uint reverse subtract.\n            case DS_INC_RTN_U64         :  //  Uint increment.\n            case DS_DEC_RTN_U64         :  // Uint decrement.\n            case DS_MIN_RTN_I64         :  // Int min.\n            case DS_MAX_RTN_I64         :  // Int max.\n            case DS_MIN_RTN_U64         :  // Uint min.\n            case DS_MAX_RTN_U64         :  // Uint max.\n            case DS_AND_RTN_B64         :  // Dword AND.\n            case DS_OR_RTN_B64          :  // Dword OR.\n            case DS_XOR_RTN_B64         :  // Dword XOR.\n            case DS_MSKOR_RTN_B64       :  // Masked Dword XOR.\n            case DS_CMPST_RTN_B64       :  // Compare store.\n            case DS_CMPST_RTN_F64       :  // Compare store with float rules.\n            case DS_MIN_RTN_F64         :  // DS[A] = (D0 < DS[A]) ? D0 : DS[A]; float, handles NaN/INF/denorm.\n            case DS_MAX_RTN_F64         :  // DS[A] = (D0 > DS[A]) ? D0 : DS[A]; float, handles NaN/INF/denorm.\n            case DS_WRXCHG_RTN_B32      :  //  Write exchange. Offset = {offset1,offset0}. A = ADDR+offset. D=DS[Addr]. DS[Addr]=D0.\n            case DS_WRXCHG_RTN_B64      :  //  Write exchange.\n            case DS_CONSUME             :  //  Consume entries from a buffer.\n            case DS_APPEND              :  //  Append one or more entries to a buffer.\n            case DS_ORDERED_COUNT       :  //  Increment an append counter. Operation is done in order of wavefront creation.\n                {\n                    char Dst[64];\n                    char Arg[64];\n                    FormatVDest(Dst,pInst->GetVDest(),pInst->GetDataWidthInDWORDS() );\n                    FormatVSrc(Arg,pInst->GetVData0(),pInst->GetDataWidthInDWORDS() );\n                    \n                    char A[64];\n                    FormatDSAddress(A,pInst->GetVAddr(),pInst->GetOffset16());\n\n                    Printf(printer,OPCODE_FORMAT\" %6s,%6s, %s\\n\", opcode, Dst,Arg, A );\n                }\n                break;\n\n                // 1 address, 2 data, 1 return\n            case DS_CMPST_RTN_B32       :  //  Compare store.\n            case DS_CMPST_RTN_F32       :  //  Compare store with float rules.\n            case DS_CONDXCHG32_RTN_B128 :  //  Conditional write exchange.\n            case DS_CONDXCHG32_RTN_B64  :  //  Conditional write exchange. SEA ISLANDS ONLY\n                {\n                    char Dst[64];\n                    char Arg0[64];\n                    char Arg1[64];\n                    FormatVDest(Dst,pInst->GetVDest(),pInst->GetDataWidthInDWORDS() );\n                    FormatVSrc(Arg0,pInst->GetVData0(),pInst->GetDataWidthInDWORDS() );\n                    FormatVSrc(Arg1,pInst->GetVData1(),1);\n                    \n                    char A[64];\n                    FormatDSAddress(A,pInst->GetVAddr(),pInst->GetOffset16());\n\n                    Printf(printer,OPCODE_FORMAT\" %6s,%6s,%6s %s\\n\", opcode, Dst,Arg0, Arg1, A );\n                }\n                break;\n\n            // 2 address, 2 data (2x write)\n            case DS_WRITE2_B32          :   //  DS[ADDR+offset0*4] = D0;DS[ADDR+offset1*4] = D1; write 2 Dwords.\n            case DS_WRITE2ST64_B32      :   //  DS[ADDR+offset0*4*64] = D0;DS[ADDR+offset1*4*64] = D1; write 2 Dwords.\n            case DS_WRITE2_B64          :   //  DS[ADDR+offset0*8] = D0;DS[ADDR+offset1*8] = D1; write 2 Dwords.\n            case DS_WRITE2ST64_B64      :   //  DS[ADDR+offset0*8*64] = D0; DS[ADDR+offset1*8*64] = D1; write 2 Dwords.\n            case DS_WRXCHG2_RTN_B64     :   //  Write exchange 2 dwords.\n            case DS_WRXCHG2_RTN_B32     :   //  Write exchange 2 separate Dwords.\n                {\n                    uint nAddressMultiplier=0;                    \n                    switch( pInst->GetOpcode() )\n                    {\n                    case DS_WRXCHG2ST64_RTN_B64 : nAddressMultiplier=64;   break;\n                    case DS_WRXCHG2ST64_RTN_B32 : nAddressMultiplier=64;   break;\n                    case DS_WRITE2_B32          : nAddressMultiplier=4;    break;\n                    case DS_WRITE2ST64_B32      : nAddressMultiplier=4*64; break;\n                    case DS_WRITE2_B64          : nAddressMultiplier=8;    break;\n                    case DS_WRITE2ST64_B64      : nAddressMultiplier=8*64; break;\n                    }\n\n                    uint nDataWidth = pInst->GetDataWidthInDWORDS();\n                    \n                    char D0[64];\n                    char D1[64];\n                    FormatVSrc( D0, pInst->GetVData0(), nDataWidth );\n                    FormatVSrc( D1, pInst->GetVData1(), nDataWidth );\n\n                    char A0[64];\n                    char A1[64];\n                    uint nOffs0 = pInst->GetOffset0()*nAddressMultiplier;\n                    uint nOffs1 = pInst->GetOffset1()*nAddressMultiplier;\n                    FormatDSAddress(A0,pInst->GetVAddr(),nOffs0);\n                    FormatDSAddress(A1,pInst->GetVAddr(),nOffs1);\n\n                    Printf(printer,OPCODE_FORMAT\" %6s,%6s, %s  %s\\n\", opcode, D0,D1, A0,A1 );\n                }\n                break;\n\n            // 2 address, 1 data (read2)\n            case DS_READ2_B32           :   // R = DS[ADDR+offset0*4], R+1 = DS[ADDR+offset1*4]. Read 2 Dwords.\n            case DS_READ2ST64_B32       :   // R = DS[ADDR+offset0*4*64], R+1 = DS[ADDR+offset1*4*64]. Read 2 Dwords.\n            case DS_READ2_B64           :   // R = DS[ADDR+offset0*8], R+1 = DS[ADDR+offset1*8]. Read 2 Dwords\n            case DS_READ2ST64_B64       :   // R = DS[ADDR+offset0*8*64], R+1 = DS[ADDR+offset1*8*64]. Read 2 Dwords.\n                {\n                    uint nAddressMultiplier=0;\n                    switch( pInst->GetOpcode() )\n                    {\n                    case DS_READ2_B32      : nAddressMultiplier=4;    break;\n                    case DS_READ2ST64_B32  : nAddressMultiplier=4*64; break;\n                    case DS_READ2_B64      : nAddressMultiplier=8;    break;\n                    case DS_READ2ST64_B64  : nAddressMultiplier=8*64; break;\n                    }\n\n                    uint nDataWidth =  pInst->GetDataWidthInDWORDS();\n                    \n\n                    char Dst[64];\n                    FormatVDest(Dst,pInst->GetVDest(),nDataWidth );\n\n                    char A0[64];\n                    char A1[64];\n                    uint nOffs0 = pInst->GetOffset0()*nAddressMultiplier;\n                    uint nOffs1 = pInst->GetOffset1()*nAddressMultiplier;\n                    FormatDSAddress(A0,pInst->GetVAddr(),nOffs0);\n                    FormatDSAddress(A1,pInst->GetVAddr(),nOffs1);\n                    Printf(printer,OPCODE_FORMAT\" %6s, %s  %s\\n\", opcode, Dst, A0,A1 );\n                \n                }\n                break;\n\n            // weird stuff \n            case DS_ADD_SRC2_U32       :   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} : {offset1[6],offset1[6:0],offset0}). DS[A] = DS[A] + DS[B]; uint add.\n            case DS_SUB_SRC2_U32       :   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} : {offset1[6],offset1[6:0],offset0}). DS[A] = DS[A] - DS[B]; uint subtract.\n            case DS_RSUB_SRC2_U32      :   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} : {offset1[6],offset1[6:0],offset0}). DS[A] = DS[B]- DS[A]; uint reverse subtract.\n            case DS_INC_SRC2_U32       :   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} :{offset1[6],offset1[6:0],offset0}). DS[A] = (DS[A] >= DS[B] ? 0 : DS[A] + 1); uint increment.\n            case DS_DEC_SRC2_U32       :   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} :{offset1[6],offset1[6:0],offset0}). DS[A] = (DS[A]== 0 || DS[A] > DS[B] ? DS[B] : DS[A] - 1); uintdecrement.\n            case DS_MIN_SRC2_I32       :   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} :{offset1[6],offset1[6:0],offset0}). DS[A] =min(DS[A], DS[B]); int min.\n            case DS_MAX_SRC2_I32       :   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} : {offset1[6],offset1[6:0],offset0}). DS[A] =max(DS[A], DS[B]); int max.\n            case DS_MIN_SRC2_U32       :   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} :{offset1[6],offset1[6:0],offset0}). DS[A] = min(DS[A], DS[B]); uint min.\n            case DS_MAX_SRC2_U32       :   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} : {offset1[6],offset1[6:0],offset0}). DS[A] =max(DS[A], DS[B]); uint maxw\n            case DS_AND_SRC2_B32       :   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} : {offset1[6],offset1[6:0],offset0}). DS[A] = DS[A]& DS[B]; Dword AND.\n            case DS_OR_SRC2_B32        :   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} :  {offset1[6],offset1[6:0],offset0}). DS[A] = DS[A] |DS[B]; Dword OR.\n            case DS_XOR_SRC2_B32       :   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} :{offset1[6],offset1[6:0],offset0}). DS[A] = DS[A] ^DS[B]; Dword XOR.\n            case DS_WRITE_SRC2_B32     :   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} :{offset1[6],offset1[6:0],offset0}). DS[A] = DS[B];write Dword.\n            case DS_MIN_SRC2_F32       :   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} :{offset1[6],offset1[6:0],offset0}). DS[A] = (DS[B] < DS[A]) ? DS[B] : DS[A]; float, handles NaN/INF/denorm.\n            case DS_MAX_SRC2_F32       :   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} : {offset1[6],offset1[6:0],offset0}). DS[A] = (DS[B] > DS[A]) ? DS[B] : DS[A]; float, handles NaN/INF/denorm.\n            case DS_ADD_SRC2_U64       :   // Uint add.\n            case DS_SUB_SRC2_U64       :   // Uint subtract.\n            case DS_RSUB_SRC2_U64      :   // Uint reverse subtract.\n            case DS_INC_SRC2_U64       :   // Uint increment.\n            case DS_DEC_SRC2_U64       :   // Uint decrement.\n            case DS_MIN_SRC2_I64       :   // Int min.\n            case DS_MAX_SRC2_I64       :   // Int max.\n            case DS_MIN_SRC2_U64       :   // Uint min.\n            case DS_MAX_SRC2_U64       :   // Uint max.\n            case DS_AND_SRC2_B64       :   // Dword AND.\n            case DS_OR_SRC2_B64        :   // Dword OR.\n            case DS_XOR_SRC2_B64       :   // Dword XOR.\n            case DS_WRITE_SRC2_B64     :   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} :{offset1[6],offset1[6:0],offset0}). DS[A] = DS[B]; write Qword.\n            case DS_MIN_SRC2_F64       :   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} :{offset1[6],offset1[6:0],offset0}). [A] = (D0 < DS[A]) ? D0 : DS[A]; float, handlesNaN/INF/denorm.\n            case DS_MAX_SRC2_F64       :   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} :{offset1[6],offset1[6:0],offset0}). [A] = (D0 > DS[A]) ? D0 : DS[A]; float, handlesNaN/INF/denorm.\n                {\n                    char Addr[64];\n                    FormatVSrc(Addr,pInst->GetVAddr(),1);\n\n                    Printf(printer,OPCODE_FORMAT\" %6s, off0(0x%02x),off1(0x%02x)\\n\", Addr, pInst->GetOffset0(),pInst->GetOffset0());\n                }\n                break;\n            }\n        }\n        \n\n\n        \n        static void Disassemble( IPrinter& printer, const Instruction* pInst, const char* pLabelName )\n        {\n            switch( pInst->GetClass() )\n            {\n            case IC_SCALAR:         _INTERNAL::Disassemble( printer, (const ScalarInstruction*)pInst, pLabelName ); break;\n            case IC_SCALAR_MEM:     _INTERNAL::Disassemble( printer, (const ScalarMemoryInstruction*)pInst ); break;\n            case IC_VECTOR:         _INTERNAL::Disassemble( printer, (const VectorInstruction*)pInst ); break;\n            case IC_VECTOR_INTERP:  _INTERNAL::Disassemble( printer, (const InterpolationInstruction*)pInst ); break;\n            case IC_EXPORT:         _INTERNAL::Disassemble( printer, (const ExportInstruction*) pInst ); break;\n            case IC_DS:             _INTERNAL::Disassemble( printer, (const DataShareInstruction*)pInst ); break;\n            case IC_BUFFER:         _INTERNAL::Disassemble( printer, (const BufferInstruction*)pInst); break;\n            case IC_IMAGE:          _INTERNAL::Disassemble( printer, (const ImageInstruction*) pInst ); break;\n            default:\n                _INTERNAL::Printf( printer, \"No disassembler for instruction at 0x%016x.\\n\", pInst );\n                break;\n            }\n        }\n    }\n     \n    void Disassemble( IPrinter& printer, const Instruction* pOp, const char* pLabelName )\n    {\n        char n[128]=\"\";\n        if( !pLabelName && pOp->GetClass() == IC_SCALAR )\n        {\n            const GCN::ScalarInstruction* pScalar = static_cast<const GCN::ScalarInstruction*>(pOp);\n            _INTERNAL::SynthesizeLabelName(n,pScalar,0);\n            pLabelName = n;\n        }\n            \n        _INTERNAL::Disassemble(printer, pOp, pLabelName);    \n    }\n\n    bool DisassembleProgram( IDecoder& decoder, IPrinter& printer, const void* pISA, size_t nISASize )\n    {\n        std::vector<const uint8*> Labels;\n        std::vector<const uint8*> Branches;\n\n        // first pass to identify basic blocks and validate encodings\n        const uint8* pInst = (const uint8*) pISA;\n        const uint8* pEnd  = pInst + nISASize;\n        while( pInst < pEnd )\n        {\n            InstructionFormat eFormat = decoder.ReadInstructionFormat( pInst );\n            const uint32* pDWORDS = reinterpret_cast<const uint32*>(pInst);\n            if( eFormat == IF_UNKNOWN )\n            {\n                _INTERNAL::Printf( printer, \"ERROR: Can't determine encoding for instruction at: 0x%016x\\n\", pInst );\n                _INTERNAL::Printf( printer, \"First DWORD is: 0x%08x\\n\", pDWORDS[0] );\n                return false;\n            }\n\n            size_t nLength = decoder.DetermineInstructionLength(pInst,eFormat);            \n            if( (pInst+nLength) > pEnd )\n            {\n                _INTERNAL::Printf( printer, \"ERROR: Instruction at: 0x%016x overruns specified buffer\\n\", pInst );\n                return false;\n            }\n\n            if( nLength == 0 || nLength%4 != 0 )\n            {\n                _INTERNAL::Printf( printer, \"INTERNAL ERROR: Bad length deduced for instruction at: 0x%016x\\n\", pInst );\n                return false;\n            }\n\n            Instruction tmp;\n            decoder.Decode( &tmp, pInst, eFormat );\n\n            if( tmp.GetClass() == IC_SCALAR )\n            {\n                const ScalarInstruction* pI = static_cast<const ScalarInstruction*>(&tmp);\n                if( pI->IsControlFlowOp() )\n                {\n                    Branches.push_back( pInst );\n                    const uint8* pTarget = pI->GetBranchTarget();\n                    if( pTarget )\n                        Labels.push_back(pTarget);\n                }\n            }\n\n            pInst += nLength;\n        }\n\n        std::sort( Labels.begin(), Labels.end() );\n\n        Branches.push_back( pEnd ); // so there's always at least one\n        Labels.push_back( pEnd );\n\n        size_t nLabel   = 0;\n        size_t nBranch  = 0;\n        pInst = (const uint8*)pISA;\n        while( pInst < pEnd )\n        {\n            InstructionFormat eFormat = decoder.ReadInstructionFormat( pInst );\n       \n            // print labels\n            if( pInst == Labels[nLabel] )\n            {\n                _INTERNAL::Printf(printer, \"Label_%04u:\\n\", nLabel );\n                nLabel++;\n            }\n           \n            // disassemble instruction\n            Instruction tmp;\n            decoder.Decode( &tmp, pInst, eFormat );\n            \n            // resolve label names for branch targets\n            char name[128]=\"\";\n            if( tmp.GetClass() == GCN::IC_SCALAR )\n                _INTERNAL::SynthesizeLabelName(name, static_cast<GCN::ScalarInstruction*>(&tmp),&Labels);\n\n            _INTERNAL::Disassemble(printer,&tmp,name);\n\n            // extra newline after a branch or before a label\n            if( pInst == Branches[nBranch] ) \n            {\n                printer.Push(\"\\n\");\n                nBranch++;\n            }\n            else if( pInst == Labels[nLabel] )\n            {\n                printer.Push(\"\\n\");\n            }\n\n            pInst += decoder.DetermineInstructionLength(pInst,eFormat);\n        }\n\n        return true;\n    }\n\n\n    bool ListEncodings( IDecoder& decoder, IPrinter& printer, const void* pISA, size_t nISASize )\n    {\n        const uint8* pInst   = (const uint8*)pISA;\n        const uint8* pEnd     = ((const uint8*)pISA) + nISASize;\n        while( pInst < pEnd )\n        {\n            InstructionFormat eFormat = decoder.ReadInstructionFormat( pInst );\n            const uint32* pDWORDS = reinterpret_cast<const uint32*>(pInst);\n            \n            if( eFormat == IF_UNKNOWN )\n            {\n                _INTERNAL::Printf( printer, \"ERROR: Can't determine encoding for instruction at: 0x%016x\\n\", pInst );\n                _INTERNAL::Printf( printer, \"First DWORD is: 0x%08x\\n\", pDWORDS[0] );\n                return false;\n            }\n\n            size_t nLength = decoder.DetermineInstructionLength(pInst,eFormat);            \n            if( (pInst+nLength) > pEnd )\n            {\n                _INTERNAL::Printf( printer, \"ERROR: Instruction at: 0x%016x overruns specified buffer\\n\", pInst );\n                return false;\n            }\n\n            if( nLength == 0 || nLength%4 != 0 )\n            {\n                _INTERNAL::Printf( printer, \"INTERNAL ERROR: Bad length deduced for instruction at: 0x%016x\\n\", pInst );\n                return false;\n            }\n\n            switch( eFormat )\n            {\n            case IF_SOP2:       printer.Push(\"SOP2    \"); break;\n            case IF_SOPK:       printer.Push(\"SOPK    \"); break;\n            case IF_SOP1:       printer.Push(\"SOP1    \"); break;\n            case IF_SOPC:       printer.Push(\"SOPC    \"); break;\n            case IF_SOPP:       printer.Push(\"SOPP    \"); break;\n            case IF_SMEM:       printer.Push(\"SMEM    \"); break;\n            case IF_SMRD:       printer.Push(\"SMRD    \"); break;\n            case IF_VOP2:       printer.Push(\"VOP2    \"); break;\n            case IF_VOP1:       printer.Push(\"VOP1    \"); break;\n            case IF_VOPC:       printer.Push(\"VOPC    \"); break;\n            case IF_VOP3:       printer.Push(\"VOP3    \"); break;\n            case IF_VINTERP:    printer.Push(\"VINTERP \"); break;\n            case IF_DS:         printer.Push(\"DS      \"); break;\n            case IF_MTBUFF:     printer.Push(\"MTBUFF  \"); break;\n            case IF_MUBUFF:     printer.Push(\"MUBUFF  \"); break;\n            case IF_MIMG:       printer.Push(\"MIMG    \"); break;\n            case IF_EXP:        printer.Push(\"EXP     \"); break;\n            case IF_FLAT:       printer.Push(\"FLAT    \"); break;\n            }\n\n            for( uint i=0; i<nLength; i+= 4 )\n                _INTERNAL::Printf( printer, \"0x%08x \", pDWORDS[i/4]);\n            printer.Push(\"\\n\");\n\n            pInst += nLength;\n        }\n\n        return true;\n    }\n}}\n"
  },
  {
    "path": "src/Wrapper/GCNDisassembler.h",
    "content": "//\n//    GCN disassembler\n//      Copyright 2015 Joshua Barczak, all rights reserved.\n//\n#ifndef _GCN_DISASSEMBLER_H_\n#define _GCN_DISASSEMBLER_H_\n#pragma once\n\nnamespace GCN{\n    class Instruction;\n    class IDecoder;\nnamespace Disassembler{\n\n    /// Interface that receives a series of text strings\n    class IPrinter\n    {\n    public:\n        virtual void Push( const char* pText ) = 0;\n    };\n\n    /// Disassemble a single instruction\n    ///   Instruction is assumed to be well formed\n    ///    If pLabelName is non-null it will be used as the name of the target instruction\n    ///     for a branch/jump.\n    ///\n    void Disassemble( IPrinter& printer, const Instruction* pIt, const char* pLabelName );\n\n    /// Disassemble a full program, returns false if an instruction is encountered whose encoding\n    ///  wasn't recognized\n    bool DisassembleProgram( IDecoder& decoder, IPrinter& printer, const void* pISA, size_t nISASize );\n\n    /// List encodings and hex bytes for each instruction.  Returns false if an instruction is encountered\n    ///  whose encoding wasn't recognized. In this case, returns early\n    bool ListEncodings( IDecoder& decoder, IPrinter& printer, const void* pISA, size_t nISASize );\n}}\n\n#endif"
  },
  {
    "path": "src/Wrapper/GCNEnums.cpp",
    "content": "#pragma unmanaged\n#include \"GCNEnums.h\"\n\nnamespace GCN\n{\n    namespace _INTERNAL\n    {\n        struct EnumLookup\n        {\n            unsigned int n;\n            const char* str;\n        };\n\n        #define START_ENUM_TABLE(en) static const EnumLookup en##LUT[] = {\n        #define ENUM(en) { en , #en },\n        #define END_ENUM_TABLE {0,0} };\n\n        START_ENUM_TABLE(ScalarInstructions)\n            ENUM(S_ADD_U32)   \n            ENUM(S_SUB_U32         )   \n            ENUM(S_ADD_I32         )   \n            ENUM(S_SUB_I32         )   \n            ENUM(S_ADDC_U32        )   \n            ENUM(S_SUBB_U32        )   \n            ENUM(S_MIN_I32         )   \n            ENUM(S_MIN_U32         )   \n            ENUM(S_MAX_I32         )   \n            ENUM(S_MAX_U32         )   \n            ENUM(S_CSELECT_B32     )   \n            ENUM(S_CSELECT_B64     )   \n            ENUM(S_AND_B32         )   \n            ENUM(S_AND_B64         )   \n            ENUM(S_OR_B32          )   \n            ENUM(S_OR_B64          )   \n            ENUM(S_XOR_B32         )   \n            ENUM(S_XOR_B64         )   \n            ENUM(S_ANDN2_B32       )   \n            ENUM(S_ANDN2_B64       )   \n            ENUM(S_ORN2_B32        )   \n            ENUM(S_ORN2_B64        )   \n            ENUM(S_NAND_B32        )   \n            ENUM(S_NAND_B64        )   \n            ENUM(S_NOR_B32         )   \n            ENUM(S_NOR_B64         )   \n            ENUM(S_XNOR_B32        )   \n            ENUM(S_XNOR_B64        )   \n            ENUM(S_LSHL_B32        )   \n            ENUM(S_LSHL_B64        )   \n            ENUM(S_LSHR_B32        )   \n            ENUM(S_LSHR_B64        )   \n            ENUM(S_ASHR_I32        )   \n            ENUM(S_ASHR_I64        )   \n            ENUM(S_BFM_B32         )   \n            ENUM(S_BFM_B64         )   \n            ENUM(S_MUL_I32         )   \n            ENUM(S_BFE_U32         )   \n            ENUM(S_BFE_I32         )   \n            ENUM(S_BFE_U64         )   \n            ENUM(S_BFE_I64         )   \n            ENUM(S_CBRANCH_G_FORK  )   \n            ENUM(S_ABSDIFF_I32     )   \n             ENUM(S_MOVK_I32         )    \n             ENUM(S_CMOVK_I32        )    \n             ENUM(S_CMPK_EQ_I32      )    \n             ENUM(S_CMPK_LG_I32      )    \n             ENUM(S_CMPK_GT_I32      )    \n             ENUM(S_CMPK_GE_I32      )    \n             ENUM(S_CMPK_LT_I32      )    \n             ENUM(S_CMPK_LE_I32      )    \n             ENUM(S_CMPK_EQ_U32      )    \n             ENUM(S_CMPK_LG_U32      )    \n             ENUM(S_CMPK_GT_U32      )    \n             ENUM(S_CMPK_GE_U32      )    \n             ENUM(S_CMPK_LT_U32      )    \n             ENUM(S_CMPK_LE_U32      )    \n             ENUM(S_ADDK_I32         )    \n             ENUM(S_MULK_I32         )    \n             ENUM(S_CBRANCH_I_FORK   )    \n             ENUM(S_GETREG_B32       )    \n             ENUM(S_SETREG_B32       )    \n             ENUM(S_SETREG_IMM32_B32 )    \n           ENUM( S_MOV_B32            ) \n           ENUM( S_MOV_B64            ) \n           ENUM( S_CMOV_B32           ) \n           ENUM( S_CMOV_B64           ) \n           ENUM( S_NOT_B32            ) \n           ENUM( S_NOT_B64            ) \n           ENUM( S_WQM_B32            ) \n           ENUM( S_WQM_B64            ) \n           ENUM( S_BREV_B32           ) \n           ENUM( S_BREV_B64           ) \n           ENUM( S_BCNT0_I32_B32      ) \n           ENUM( S_BCNT0_I32_B64      ) \n           ENUM( S_BCNT1_I32_B32      ) \n           ENUM( S_BCNT1_I32_B64      ) \n           ENUM( S_FF0_I32_B32        ) \n           ENUM( S_FF0_I32_B64        ) \n           ENUM( S_FF1_I32_B32        ) \n           ENUM( S_FF1_I32_B64        ) \n           ENUM( S_FLBIT_I32_B32      ) \n           ENUM( S_FLBIT_I32_B64      ) \n           ENUM( S_FLBIT_I32          ) \n           ENUM( S_FLBIT_I32_I64      ) \n           ENUM( S_SEXT_I32_I8        ) \n           ENUM( S_SEXT_I32_I16       ) \n           ENUM( S_BITSET0_B32        ) \n           ENUM( S_BITSET0_B64        ) \n           ENUM( S_BITSET1_B32        ) \n           ENUM( S_BITSET1_B64        ) \n           ENUM( S_GETPC_B64          ) \n           ENUM( S_SETPC_B64          ) \n           ENUM( S_SWAPPC_B64         ) \n           ENUM( S_RFE_B64            ) \n           ENUM( S_AND_SAVEEXEC_B64   ) \n           ENUM( S_OR_SAVEEXEC_B64    ) \n           ENUM( S_XOR_SAVEEXEC_B64   ) \n           ENUM( S_ANDN2_SAVEEXEC_B64 ) \n           ENUM( S_ORN2_SAVEEXEC_B64  ) \n           ENUM( S_NAND_SAVEEXEC_B64  ) \n           ENUM( S_NOR_SAVEEXEC_B64   ) \n           ENUM( S_XNOR_SAVEEXEC_B64  ) \n           ENUM( S_QUADMASK_B32       ) \n           ENUM( S_QUADMASK_B64       ) \n           ENUM( S_MOVRELS_B32        ) \n           ENUM( S_MOVRELS_B64        ) \n           ENUM( S_MOVRELD_B32        ) \n           ENUM( S_MOVRELD_B64        ) \n           ENUM( S_CBRANCH_JOIN       ) \n           ENUM( S_ABS_I32            ) \n           ENUM( S_MOV_FED_B32        ) \n            ENUM(S_CMP_EQ_I32    )      \n            ENUM(S_CMP_LG_I32    )      \n            ENUM(S_CMP_GT_I32    )      \n            ENUM(S_CMP_GE_I32    )      \n            ENUM(S_CMP_LT_I32    )      \n            ENUM(S_CMP_LE_I32    )      \n            ENUM(S_CMP_EQ_U32    )      \n            ENUM(S_CMP_LG_U32    )      \n            ENUM(S_CMP_GT_U32    )      \n            ENUM(S_CMP_GE_U32    )      \n            ENUM(S_CMP_LT_U32    )      \n            ENUM(S_CMP_LE_U32    )      \n            ENUM(S_BITCMP0_B32   )      \n            ENUM(S_BITCMP1_B32   )      \n            ENUM(S_BITCMP0_B64   )      \n            ENUM(S_BITCMP1_B64   )      \n            ENUM(S_SETVSKIP      )      \n            ENUM(S_NOP                      )\n            ENUM(S_ENDPGM                   )\n            ENUM(S_BRANCH                   )\n            ENUM(S_CBRANCH_SCC0             )\n            ENUM(S_CBRANCH_SCC1             )\n            ENUM(S_CBRANCH_VCCZ             )\n            ENUM(S_CBRANCH_VCCNZ            )\n            ENUM(S_CBRANCH_EXECZ            )\n            ENUM(S_CBRANCH_EXECNZ           )\n            ENUM(S_BARRIER                  )\n            ENUM(S_WAITCNT                  )\n            ENUM(S_SETHALT                  )\n            ENUM(S_SLEEP                    )\n            ENUM(S_SETPRIO                  )\n            ENUM(S_SENDMSG                  )\n            ENUM(S_SENDMSGHALT              )\n            ENUM(S_TRAP                     )\n            ENUM(S_ICACHE_INV               )\n            ENUM(S_INCPERFLEVEL             )\n            ENUM(S_DECPERFLEVEL             )\n            ENUM(S_TTRACEDATA               )\n            ENUM(S_CBRANCH_CDBGSYS          )\n            ENUM(S_CBRANCH_CDBGUSER         )\n            ENUM(S_CBRANCH_CDBGSYS_OR_USER  )\n            ENUM(S_CBRANCH_CDBGSYS_AND_USER )\n            ENUM(S_RFE_RESTORE_B64)\n            ENUM(S_SET_GPR_IDX_IDX)\n            ENUM(S_SET_GPR_IDX_ON)\n            ENUM(S_CMP_EQ_U64) \n            ENUM(S_CMP_NE_U64)\n            ENUM(S_ENDPGM_SAVED)\n            ENUM(S_SET_GPR_IDX_OFF)\n            ENUM(S_SET_GPR_IDX_MODE)\n            ENUM(S_SETKILL)\n        END_ENUM_TABLE\n\n        START_ENUM_TABLE(ScalarMemoryInstructions)\n            ENUM(S_LOAD_DWORD            )\n            ENUM(S_LOAD_DWORDX2          )\n            ENUM(S_LOAD_DWORDX4          )\n            ENUM(S_LOAD_DWORDX8          )\n            ENUM(S_LOAD_DWORDX16         )\n            ENUM(S_BUFFER_LOAD_DWORD     )\n            ENUM(S_BUFFER_LOAD_DWORDX2   )\n            ENUM(S_BUFFER_LOAD_DWORDX4   )\n            ENUM(S_BUFFER_LOAD_DWORDX8   )\n            ENUM(S_BUFFER_LOAD_DWORDX16  )\n            ENUM(S_DCACHE_INV_VOL        )\n            ENUM(S_MEMTIME               )\n            ENUM(S_DCACHE_INV            )\n            ENUM(S_STORE_DWORD           )   \n            ENUM(S_STORE_DWORDX2         )  \n            ENUM(S_STORE_DWORDX4         )  \n            ENUM(S_BUFFER_STORE_DWORD    )  \n            ENUM(S_BUFFER_STORE_DWORDX2  )  \n            ENUM(S_BUFFER_STORE_DWORDX4  )  \n            ENUM(S_DCACHE_WB             )  \n            ENUM(S_DCACHE_WB_VOL         )  \n            ENUM(S_MEMREALTIME           )  \n            ENUM(S_ATC_PROBE             )  \n            ENUM(S_ATC_PROBE_BUFFER      )  \n\n        END_ENUM_TABLE\n\n        START_ENUM_TABLE(VectorInstructions)\n            ENUM( V_CNDMASK_B32          )    \n            ENUM( V_READLANE_B32         )    \n            ENUM( V_WRITELANE_B32        )    \n            ENUM( V_ADD_F32              )    \n            ENUM( V_SUB_F32              )    \n            ENUM( V_SUBREV_F32           )    \n            ENUM( V_MAC_LEGACY_F32       )    \n            ENUM( V_MUL_LEGACY_F32       )    \n            ENUM( V_MUL_F32              )    \n            ENUM( V_MUL_I32_I24          )    \n            ENUM( V_MUL_HI_I32_I24       )    \n            ENUM( V_MUL_U32_U24          )    \n            ENUM( V_MUL_HI_U32_U24       )    \n            ENUM( V_MIN_LEGACY_F32       )    \n            ENUM( V_MAX_LEGACY_F32       )    \n            ENUM( V_MIN_F32              )    \n            ENUM( V_MAX_F32              )    \n            ENUM( V_MIN_I32              )    \n            ENUM( V_MAX_I32              )    \n            ENUM( V_MIN_U32              )    \n            ENUM( V_MAX_U32              )    \n            ENUM( V_LSHR_B32             )    \n            ENUM( V_LSHRREV_B32          )    \n            ENUM( V_ASHR_I32             )    \n            ENUM( V_ASHRREV_I32          )    \n            ENUM( V_LSHL_B32             )    \n            ENUM( V_LSHLREV_B32          )    \n            ENUM( V_AND_B32              )    \n            ENUM( V_OR_B32               )    \n            ENUM( V_XOR_B32              )    \n            ENUM( V_BFM_B32              )    \n            ENUM( V_MAC_F32              )    \n            ENUM( V_MADMK_F32            )    \n            ENUM( V_MADAK_F32            )    \n            ENUM( V_BCNT_U32_B32         )    \n            ENUM( V_MBCNT_LO_U32_B32     )    \n            ENUM( V_MBCNT_HI_U32_B32     )                                         \n            ENUM( V_ADD_I32              )    \n            ENUM( V_SUB_I32              )    \n            ENUM( V_SUBREV_I32           )    \n            ENUM( V_ADDC_U32             )    \n            ENUM( V_SUBB_U32             )    \n            ENUM( V_SUBBREV_U32          )    \n            ENUM( V_LDEXP_F32            )    \n            ENUM( V_CVT_PKACCUM_U8_F32   )    \n            ENUM( V_CVT_PKNORM_I16_F32   )    \n            ENUM( V_CVT_PKNORM_U16_F32   )    \n            ENUM( V_CVT_PKRTZ_F16_F32    )    \n            ENUM( V_CVT_PK_U16_U32       )    \n            ENUM( V_CVT_PK_I16_I32       )    \n           ENUM(V_NOP                  ) \n           ENUM(V_MOV_B32              ) \n           ENUM(V_READFIRSTLANE_B32    )        \n           ENUM(V_CVT_I32_F64          ) \n           ENUM(V_CVT_F64_I32          ) \n           ENUM(V_CVT_F32_I32          ) \n           ENUM(V_CVT_F32_U32          ) \n           ENUM(V_CVT_U32_F32          ) \n           ENUM(V_CVT_I32_F32          ) \n           ENUM(V_MOV_FED_B32          ) \n           ENUM(V_CVT_F16_F32          ) \n           ENUM(V_CVT_F32_F16          ) \n           ENUM(V_CVT_RPI_I32_F32      ) \n           ENUM(V_CVT_FLR_I32_F32      ) \n           ENUM(V_CVT_OFF_F32_I4       ) \n           ENUM(V_CVT_F32_F64          ) \n           ENUM(V_CVT_F64_F32          ) \n           ENUM(V_CVT_F32_UBYTE0       ) \n           ENUM(V_CVT_F32_UBYTE1       ) \n           ENUM(V_CVT_F32_UBYTE2       ) \n           ENUM(V_CVT_F32_UBYTE3       ) \n           ENUM(V_CVT_U32_F64          ) \n           ENUM(V_CVT_F64_U32          ) \n           ENUM(V_TRUNC_F64            ) \n           ENUM(V_CEIL_F64             ) \n           ENUM(V_RNDNE_F64            ) \n           ENUM(V_FLOOR_F64            ) \n           ENUM(V_FRACT_F32            ) \n           ENUM(V_TRUNC_F32            ) \n           ENUM(V_CEIL_F32             ) \n           ENUM(V_RNDNE_F32            ) \n           ENUM(V_FLOOR_F32            ) \n           ENUM(V_EXP_F32              ) \n           ENUM(V_LOG_CLAMP_F32        ) \n           ENUM(V_LOG_F32              ) \n           ENUM(V_RCP_CLAMP_F32        ) \n           ENUM(V_RCP_LEGACY_F32       ) \n           ENUM(V_RCP_F32              ) \n           ENUM(V_RCP_IFLAG_F32        ) \n           ENUM(V_RSQ_CLAMP_F32        ) \n           ENUM(V_RSQ_LEGACY_F32       ) \n           ENUM(V_RSQ_F32              ) \n           ENUM(V_RCP_F64              ) \n           ENUM(V_RCP_CLAMP_F64        ) \n           ENUM(V_RSQ_F64              ) \n           ENUM(V_RSQ_CLAMP_F64        ) \n           ENUM(V_SQRT_F32             ) \n           ENUM(V_SQRT_F64             ) \n           ENUM(V_SIN_F32              ) \n           ENUM(V_COS_F32              ) \n           ENUM(V_NOT_B32              ) \n           ENUM(V_BFREV_B32            ) \n           ENUM(V_FFBH_U32             ) \n           ENUM(V_FFBL_B32             ) \n           ENUM(V_FFBH_I32             ) \n           ENUM(V_FREXP_EXP_I32_F64    ) \n           ENUM(V_FREXP_MANT_F64       ) \n           ENUM(V_FRACT_F64            ) \n           ENUM(V_FREXP_EXP_I32_F32    ) \n           ENUM(V_FREXP_MANT_F32       ) \n           ENUM(V_CLREXCP              ) \n           ENUM(V_MOVRELD_B32          ) \n           ENUM(V_MOVRELS_B32          ) \n           ENUM(V_MOVRELSD_B32         ) \n           ENUM(V_LOG_LEGACY_F32       )\n           ENUM(V_EXP_LEGACY_F32       ) \n            ENUM(V_CMP_F_F32        )\n            ENUM(V_CMP_LT_F32       )\n            ENUM(V_CMP_EQ_F32       )\n            ENUM(V_CMP_LE_F32       )\n            ENUM(V_CMP_GT_F32       )\n            ENUM(V_CMP_LG_F32       )\n            ENUM(V_CMP_GE_F32       )\n            ENUM(V_CMP_O_F32        )\n            ENUM(V_CMP_U_F32        )\n            ENUM(V_CMP_NGE_F32      )\n            ENUM(V_CMP_NLG_F32      )\n            ENUM(V_CMP_NGT_F32      )\n            ENUM(V_CMP_NLE_F32      )\n            ENUM(V_CMP_NEQ_F32      )\n            ENUM(V_CMP_NLT_F32      )\n            ENUM(V_CMP_TRU_F32      )\n            ENUM(V_CMPX_F_F32       )\n            ENUM(V_CMPX_LT_F32      )\n            ENUM(V_CMPX_EQ_F32      )\n            ENUM(V_CMPX_LE_F32      )\n            ENUM(V_CMPX_GT_F32      )\n            ENUM(V_CMPX_LG_F32      )\n            ENUM(V_CMPX_GE_F32      )\n            ENUM(V_CMPX_O_F32       )\n            ENUM(V_CMPX_U_F32       )\n            ENUM(V_CMPX_NGE_F32     )\n            ENUM(V_CMPX_NLG_F32     )\n            ENUM(V_CMPX_NGT_F32     )\n            ENUM(V_CMPX_NLE_F32     )\n            ENUM(V_CMPX_NEQ_F32     )\n            ENUM(V_CMPX_NLT_F32     )\n            ENUM(V_CMPX_TRU_F32     )\n            ENUM(V_CMP_F_F64        )\n            ENUM(V_CMP_LT_F64       )\n            ENUM(V_CMP_EQ_F64       )\n            ENUM(V_CMP_LE_F64       )\n            ENUM(V_CMP_GT_F64       )\n            ENUM(V_CMP_LG_F64       )\n            ENUM(V_CMP_GE_F64       )\n            ENUM(V_CMP_O_F64        )\n            ENUM(V_CMP_U_F64        )\n            ENUM(V_CMP_NGE_F64      )\n            ENUM(V_CMP_NLG_F64      )\n            ENUM(V_CMP_NGT_F64      )\n            ENUM(V_CMP_NLE_F64      )\n            ENUM(V_CMP_NEQ_F64      )\n            ENUM(V_CMP_NLT_F64      )\n            ENUM(V_CMP_TRU_F64      )\n            ENUM(V_CMPX_F_F64       )\n            ENUM(V_CMPX_LT_F64      )\n            ENUM(V_CMPX_EQ_F64      )\n            ENUM(V_CMPX_LE_F64      )\n            ENUM(V_CMPX_GT_F64      )\n            ENUM(V_CMPX_LG_F64      )\n            ENUM(V_CMPX_GE_F64      )\n            ENUM(V_CMPX_O_F64       )\n            ENUM(V_CMPX_U_F64       )\n            ENUM(V_CMPX_NGE_F64     )\n            ENUM(V_CMPX_NLG_F64     )\n            ENUM(V_CMPX_NGT_F64     )\n            ENUM(V_CMPX_NLE_F64     )\n            ENUM(V_CMPX_NEQ_F64     )\n            ENUM(V_CMPX_NLT_F64     )\n            ENUM(V_CMPX_TRU_F64     )\n            ENUM(V_CMPS_F_F32       )\n            ENUM(V_CMPS_LT_F32      )\n            ENUM(V_CMPS_EQ_F32      )\n            ENUM(V_CMPS_LE_F32      )\n            ENUM(V_CMPS_GT_F32      )\n            ENUM(V_CMPS_LG_F32      )\n            ENUM(V_CMPS_GE_F32      )\n            ENUM(V_CMPS_O_F32       )\n            ENUM(V_CMPS_U_F32       )\n            ENUM(V_CMPS_NGE_F32     )\n            ENUM(V_CMPS_NLG_F32     )\n            ENUM(V_CMPS_NGT_F32     )\n            ENUM(V_CMPS_NLE_F32     )\n            ENUM(V_CMPS_NEQ_F32     )\n            ENUM(V_CMPS_NLT_F32     )\n            ENUM(V_CMPS_TRU_F32     )\n            ENUM(V_CMPSX_F_F32      )\n            ENUM(V_CMPSX_LT_F32     )\n            ENUM(V_CMPSX_EQ_F32     )\n            ENUM(V_CMPSX_LE_F32     )\n            ENUM(V_CMPSX_GT_F32     )\n            ENUM(V_CMPSX_LG_F32     )\n            ENUM(V_CMPSX_GE_F32     )\n            ENUM(V_CMPSX_O_F32      )\n            ENUM(V_CMPSX_U_F32      )\n            ENUM(V_CMPSX_NGE_F32    )\n            ENUM(V_CMPSX_NLG_F32    )\n            ENUM(V_CMPSX_NGT_F32    )\n            ENUM(V_CMPSX_NLE_F32    )\n            ENUM(V_CMPSX_NEQ_F32    )\n            ENUM(V_CMPSX_NLT_F32    )\n            ENUM(V_CMPSX_TRU_F32    )\n            ENUM(V_CMPS_F_F64       )\n            ENUM(V_CMPS_LT_F64      )\n            ENUM(V_CMPS_EQ_F64      )\n            ENUM(V_CMPS_LE_F64      )\n            ENUM(V_CMPS_GT_F64      )\n            ENUM(V_CMPS_LG_F64      )\n            ENUM(V_CMPS_GE_F64      )\n            ENUM(V_CMPS_O_F64       )\n            ENUM(V_CMPS_U_F64       )\n            ENUM(V_CMPS_NGE_F64     )\n            ENUM(V_CMPS_NLG_F64     )\n            ENUM(V_CMPS_NGT_F64     )\n            ENUM(V_CMPS_NLE_F64     )\n            ENUM(V_CMPS_NEQ_F64     )\n            ENUM(V_CMPS_NLT_F64     )\n            ENUM(V_CMPS_TRU_F64     )\n            ENUM(V_CMPSX_F_F64      )\n            ENUM(V_CMPSX_LT_F64     )\n            ENUM(V_CMPSX_EQ_F64     )\n            ENUM(V_CMPSX_LE_F64     )\n            ENUM(V_CMPSX_GT_F64     )\n            ENUM(V_CMPSX_LG_F64     )\n            ENUM(V_CMPSX_GE_F64     )\n            ENUM(V_CMPSX_O_F64      )\n            ENUM(V_CMPSX_U_F64      )\n            ENUM(V_CMPSX_NGE_F64    )\n            ENUM(V_CMPSX_NLG_F64    )\n            ENUM(V_CMPSX_NGT_F64    )\n            ENUM(V_CMPSX_NLE_F64    )\n            ENUM(V_CMPSX_NEQ_F64    )\n            ENUM(V_CMPSX_NLT_F64    )\n            ENUM(V_CMPSX_TRU_F64    )\n            ENUM(V_CMP_F_I32        )\n            ENUM(V_CMP_LT_I32       )\n            ENUM(V_CMP_EQ_I32       )\n            ENUM(V_CMP_LE_I32       )\n            ENUM(V_CMP_GT_I32       )\n            ENUM(V_CMP_LG_I32       )\n            ENUM(V_CMP_GE_I32       )\n            ENUM(V_CMP_TRU_I32      )\n            ENUM(V_CMPX_F_I32       )\n            ENUM(V_CMPX_LT_I32      )\n            ENUM(V_CMPX_EQ_I32      )\n            ENUM(V_CMPX_LE_I32      )\n            ENUM(V_CMPX_GT_I32      )\n            ENUM(V_CMPX_LG_I32      )\n            ENUM(V_CMPX_GE_I32      )\n            ENUM(V_CMPX_TRU_I32     )\n            ENUM(V_CMP_F_I64        )\n            ENUM(V_CMP_LT_I64       )\n            ENUM(V_CMP_EQ_I64       )\n            ENUM(V_CMP_LE_I64       )\n            ENUM(V_CMP_GT_I64       )\n            ENUM(V_CMP_LG_I64       )\n            ENUM(V_CMP_GE_I64       )\n            ENUM(V_CMP_TRU_I64      )\n            ENUM(V_CMPX_F_I64       )\n            ENUM(V_CMPX_LT_I64      )\n            ENUM(V_CMPX_EQ_I64      )\n            ENUM(V_CMPX_LE_I64      )\n            ENUM(V_CMPX_GT_I64      )\n            ENUM(V_CMPX_LG_I64      )\n            ENUM(V_CMPX_GE_I64      )\n            ENUM(V_CMPX_TRU_I64     )\n            ENUM(V_CMP_F_U32        )\n            ENUM(V_CMP_LT_U32       )\n            ENUM(V_CMP_EQ_U32       )\n            ENUM(V_CMP_LE_U32       )\n            ENUM(V_CMP_GT_U32       )\n            ENUM(V_CMP_LG_U32       )\n            ENUM(V_CMP_GE_U32       )\n            ENUM(V_CMP_TRU_U32      )\n            ENUM(V_CMPX_F_U32       )\n            ENUM(V_CMPX_LT_U32      )\n            ENUM(V_CMPX_EQ_U32      )\n            ENUM(V_CMPX_LE_U32      )\n            ENUM(V_CMPX_GT_U32      )\n            ENUM(V_CMPX_LG_U32      )\n            ENUM(V_CMPX_GE_U32      )\n            ENUM(V_CMPX_TRU_U32     )\n            ENUM(V_CMP_F_U64        )\n            ENUM(V_CMP_LT_U64       )\n            ENUM(V_CMP_EQ_U64       )\n            ENUM(V_CMP_LE_U64       )\n            ENUM(V_CMP_GT_U64       )\n            ENUM(V_CMP_LG_U64       )\n            ENUM(V_CMP_GE_U64       )\n            ENUM(V_CMP_TRU_U64      )\n            ENUM(V_CMPx_F_U64       )\n            ENUM(V_CMPx_LT_U64      )\n            ENUM(V_CMPx_EQ_U64      )\n            ENUM(V_CMPx_LE_U64      )\n            ENUM(V_CMPx_GT_U64      )\n            ENUM(V_CMPx_LG_U64      )\n            ENUM(V_CMPx_GE_U64      )\n            ENUM(V_CMPx_TRU_U64     )\n            ENUM(V_CMP_CLASS_F32    )\n            ENUM(V_CMPX_CLASS_F32   )\n            ENUM(V_CMP_CLASS_F64    )\n            ENUM(V_CMPX_CLASS_F64   )\n           ENUM(V_DIV_SCALE_F32    )  //  = D.f = Special case divide preop and flags(s0.f = Quotient,s1.f = Denominator, s2.f = Numerator) s0 must equal s1 or s2.\n           ENUM(V_DIV_SCALE_F64    )  //  = D.d = Special case divide preop and flags(s0.d = Quotient,s1.d = Denominator, s2.d = Numerator) s0 must equal s1 or s2.\n           ENUM(V_MAD_LEGACY_F32   )//   = D.f = S0.f * S1.f + S2.f (DX9 rules, 0.0*x = 0.0).\n           ENUM(V_MAD_F32          )//   = D.f = S0.f * S1.f + S2.f.\n           ENUM(V_MAD_I32_I24      )//   = D.i = S0.i * S1.i + S2.iD.i = S0.i * S1.i + S2.i.\n           ENUM(V_MAD_U32_U24      )//   = D.u = S0.u * S1.u + S2.u.\n           ENUM(V_CUBEID_F32       )//   = Rm.w <- Rn,x, Rn,y, Rn.z.\n           ENUM(V_CUBESC_F32       )//   = Rm.y <- Rn,x, Rn,y, Rn.z.\n           ENUM(V_CUBETC_F32       )//   = Rm.x <- Rn,x, Rn,y, Rn.z.\n           ENUM(V_CUBEMA_F32       )//   = Rm.z <- Rn,x, Rn,y, Rn.z\n           ENUM(V_BFE_U32          )//   = D.u = (S0.u>>S1.u[4:0]) & ((1<<S2.u[4:0])-1); bitfield extract,S0=data, S1=field_offset, S2=field_width.\n           ENUM(V_BFE_I32          )//   = D.i = (S0.i>>S1.u[4:0]) & ((1<<S2.u[4:0])-1); bitfield extract, S0=data, S1=field_offset, S2=field_width.\n           ENUM(V_BFI_B32          )//   = D.u = (S0.u & S1.u) | (~S0.u & S2.u); bitfield insert.\n           ENUM(V_FMA_F32          )//   = D.f = S0.f * S1.f + S2.f\n           ENUM(V_FMA_F64          )//   = D.d = S0.d * S1.d + S2.d.\n           ENUM(V_LERP_U8          )//  = D.u = ((S0.u[31:24] + S1.u[31:24] + S2.u[24]) >> 1) << 24 +\n           ENUM(V_ALIGNBIT_B32     )//  = D.u = ({S0,S1} >> S2.u[4:0]) & 0xFFFFFFFF.\n           ENUM(V_ALIGNBYTE_B32    )//  = D.u = ({S0,S1} >> (8*S2.u[4:0])) & 0xFFFFFFFF.\n           ENUM(V_MULLIT_F32       )//  = D.f = S0.f * S1.f, replicate result into 4 components (0.0 * x = 0.0; special INF, NaN, overflow rules).\n           ENUM(V_MIN3_F32         )//  = D.f = min(S0.f, S1.f, S2.f).\n           ENUM(V_MIN3_I32         )//  = D.i = min(S0.i, S1.i, S2.i).\n           ENUM(V_MIN3_U32         )//  = 0x153 D.u = min(S0.u, S1.u, S2.u).\n           ENUM(V_MAX3_F32         )//  = D.f = max(S0.f, S1.f, S2.f).\n           ENUM(V_MAX3_I32         )//  = D.i = max(S0.i, S1.i, S2.i).\n           ENUM(V_MAX3_U32         )//  = D.u = max(S0.u, S1.u, S2.u).\n           ENUM(V_MED3_F32         )//  = D.f = median(S0.f, S1.f, S2.f).\n           ENUM(V_MED3_I32         )//  = D.i = median(S0.i, S1.i, S2.i).\n           ENUM(V_MED3_U32         )//  = D.u = median(S0.u, S1.u, S2.u).\n           ENUM(V_SAD_U8           )//  = D.u = Byte SAD with accum_lo(S0.u, S1.u, S2.u).\n           ENUM(V_SAD_HI_U8        )//  = D.u = Byte SAD with accum_hi(S0.u, S1.u, S2.u).\n           ENUM(V_SAD_U16          )//  = D.u = Word SAD with accum(S0.u, S1.u, S2.u).\n           ENUM(V_SAD_U32          )//  = D.u = Dword SAD with accum(S0.u, S1.u, S2.u).\n           ENUM(V_CVT_PK_U8_F32    )//  = f32->u8(s0.f), pack into byte(s1.u), of dword(s2).\n           ENUM(V_DIV_FIXUP_F32    )//  = D.f = Special case divide fixup and flags(s0.f = Quotient,   s1.f = Denominator, s2.f = Numerator).\n           ENUM(V_DIV_FIXUP_F64    )//  = D.d = Special case divide fixup and flags(s0.d = Quotient,  s1.d = Denominator, s2.d = Numerator).\n           ENUM(V_LSHL_B64         )//  = D = S0.u << S1.u[4:0].\n           ENUM(V_LSHR_B64         )//  = D = S0.u >> S1.u[4:0].\n           ENUM(V_ASHR_I64         )//  = D = S0.u >> S1.u[4:0].\n           ENUM(V_ADD_F64          )//  = D.d = S0.d + S1.d.\n           ENUM(V_MUL_F64          )//  = D.d = S0.d * S1.d.\n           ENUM(V_MIN_F64          )//  = D.d = min(S0.d, S1.d).\n           ENUM(V_MAX_F64          )//  = D.d = max(S0.d, S1.d).\n           ENUM(V_LDEXP_F64        )//  = D.d = pow(S0.d, S1.i[31:0]).\n           ENUM(V_MUL_LO_U32       )//  = D.u = S0.u * S1.u.\n           ENUM(V_MUL_HI_U32       )//  = D.u = (S0.u * S1.u)>>32.\n           ENUM(V_MUL_LO_I32       )//  = D.i = S0.i * S1.i.\n           ENUM(V_MUL_HI_I32       )//  = D.i = (S0.i * S1.i)>>32.\n           ENUM(V_DIV_FMAS_F32     ) \n           ENUM(V_DIV_FMAS_F64     ) \n           ENUM(V_MSAD_U8          ) \n           ENUM(V_QSAD_U8          ) \n           ENUM(V_MQSAD_U8         ) \n           ENUM(V_QSAD_PK_U16_U8   ) \n           ENUM(V_MQSAD_PK_U16_U8  ) \n           ENUM(V_TRIG_PREOP_F64   )\n           ENUM(V_MQSAD_U32_U8     )\n           ENUM(V_MAD_U64_U32      )\n           ENUM(V_MAD_I64_I32      )\n           ENUM( V_ADD_F16     )             \n           ENUM( V_SUB_F16     )            \n           ENUM( V_SUBREV_F16  )            \n           ENUM( V_MUL_F16     )            \n           ENUM( V_MAC_F16     )            \n           ENUM( V_MADMK_F16   )            \n           ENUM( V_MADAK_F16   )            \n           ENUM( V_ADD_U16     )            \n           ENUM( V_SUB_U16     )            \n           ENUM( V_SUBREV_U16  )            \n           ENUM( V_MUL_LO_U16  )            \n           ENUM( V_LSHLREV_B16 )            \n           ENUM( V_LSHRREV_B16 )            \n           ENUM( V_ASHRREV_I16 )            \n           ENUM( V_MAX_F16     )            \n           ENUM( V_MIN_F16     )            \n           ENUM( V_MAX_U16     )            \n           ENUM( V_MAX_I16     )            \n           ENUM( V_MIN_U16     )            \n           ENUM( V_MIN_I16     )            \n           ENUM( V_LDEXP_F16   )            \n           ENUM(V_CVT_F16_U16        )    \n           ENUM(V_CVT_F16_I16        )  \n           ENUM(V_CVT_U16_F16        )  \n           ENUM(V_CVT_I16_F16        )  \n           ENUM(V_RCP_F16            )  \n           ENUM(V_SQRT_F16           )  \n           ENUM(V_RSQ_F16            )  \n           ENUM(V_LOG_F16            )  \n           ENUM(V_EXP_F16            )  \n           ENUM(V_FREXP_MANT_F16     )  \n           ENUM(V_FREXP_EXP_I16_F16  )  \n           ENUM(V_FLOOR_F16          )  \n           ENUM(V_CEIL_F16           )  \n           ENUM(V_TRUNC_F16          )  \n           ENUM(V_RNDNE_F16          )  \n           ENUM(V_FRACT_F16          )  \n           ENUM(V_SIN_F16            )  \n           ENUM(V_COS_F16            )  \n            ENUM(V_CMP_F_F16        )\n            ENUM(V_CMP_LT_F16       )\n            ENUM(V_CMP_EQ_F16       )\n            ENUM(V_CMP_LE_F16       )\n            ENUM(V_CMP_GT_F16       )\n            ENUM(V_CMP_LG_F16       )\n            ENUM(V_CMP_GE_F16       )\n            ENUM(V_CMP_O_F16        )\n            ENUM(V_CMP_U_F16        )\n            ENUM(V_CMP_NGE_F16      )\n            ENUM(V_CMP_NLG_F16      )\n            ENUM(V_CMP_NGT_F16      )\n            ENUM(V_CMP_NLE_F16      )\n            ENUM(V_CMP_NEQ_F16      )\n            ENUM(V_CMP_NLT_F16      )\n            ENUM(V_CMP_TRU_F16      )\n            ENUM(V_CMPX_F_F16       )\n            ENUM(V_CMPX_LT_F16      )\n            ENUM(V_CMPX_EQ_F16      )\n            ENUM(V_CMPX_LE_F16      )\n            ENUM(V_CMPX_GT_F16      )\n            ENUM(V_CMPX_LG_F16      )\n            ENUM(V_CMPX_GE_F16      )\n            ENUM(V_CMPX_O_F16       )\n            ENUM(V_CMPX_U_F16       )\n            ENUM(V_CMPX_NGE_F16     )\n            ENUM(V_CMPX_NLG_F16     )\n            ENUM(V_CMPX_NGT_F16     )\n            ENUM(V_CMPX_NLE_F16     )\n            ENUM(V_CMPX_NEQ_F16     )\n            ENUM(V_CMPX_NLT_F16     )\n            ENUM(V_CMPX_TRU_F16     )\n            ENUM(V_CMP_F_U16        )\n            ENUM(V_CMP_LT_U16       )\n            ENUM(V_CMP_EQ_U16       )\n            ENUM(V_CMP_LE_U16       )\n            ENUM(V_CMP_GT_U16       )\n            ENUM(V_CMP_LG_U16       )\n            ENUM(V_CMP_GE_U16       )\n            ENUM(V_CMP_TRU_U16      )\n            ENUM(V_CMPx_F_U16       )\n            ENUM(V_CMPx_LT_U16      )\n            ENUM(V_CMPx_EQ_U16      )\n            ENUM(V_CMPx_LE_U16      )\n            ENUM(V_CMPx_GT_U16      )\n            ENUM(V_CMPx_LG_U16      )\n            ENUM(V_CMPx_GE_U16      )\n            ENUM(V_CMPx_TRU_U16     )\n            ENUM(V_CMP_F_I16        )\n            ENUM(V_CMP_LT_I16       )\n            ENUM(V_CMP_EQ_I16       )\n            ENUM(V_CMP_LE_I16       )\n            ENUM(V_CMP_GT_I16       )\n            ENUM(V_CMP_LG_I16       )\n            ENUM(V_CMP_GE_I16       )\n            ENUM(V_CMP_TRU_I16      )\n            ENUM(V_CMPx_F_I16       )\n            ENUM(V_CMPx_LT_I16      )\n            ENUM(V_CMPx_EQ_I16      )\n            ENUM(V_CMPx_LE_I16      )\n            ENUM(V_CMPx_GT_I16      )\n            ENUM(V_CMPx_LG_I16      )\n            ENUM(V_CMPx_GE_I16      )\n            ENUM(V_CMPx_TRU_I16     )  \n            ENUM(V_CMP_CLASS_F16)\n            ENUM(V_CMPX_CLASS_F16)\n\n\n            ENUM(V_MAD_F16             )     \n            ENUM(V_MAD_U16             )     \n            ENUM(V_MAD_I16             )     \n            ENUM(V_PERM_B32            )               \n            ENUM(V_FMA_F16             )  \n            ENUM(V_DIV_FIXUP_F16       )\n\n            ENUM( V_ADD_U32    )\n            ENUM( V_SUB_U32    )\n            ENUM( V_SUBREV_U32 )\n            ENUM( V_LSHLREV_B64      )\n            ENUM( V_LSHRREV_B64 )\n            ENUM( V_ASHRREV_I64 )\n\n\n\n            ENUM(V_INTERP_P1_F32 )\n            ENUM(V_INTERP_P2_F32 )\n            ENUM(V_INTERP_MOV_F32)\n            \n            ENUM(V_INTERP_P1LL_F16)\n            ENUM(V_INTERP_P1LV_F16)\n            ENUM(V_INTERP_P2_F16  )\n\n\n        END_ENUM_TABLE\n\n        START_ENUM_TABLE(DSInstructions)\n             ENUM( DS_ADD_U32             )\n             ENUM( DS_SUB_U32             )\n             ENUM( DS_RSUB_U32            )\n             ENUM( DS_INC_U32             )\n             ENUM( DS_DEC_U32             )\n             ENUM( DS_MIN_I32             )\n             ENUM( DS_MAX_I32             )\n             ENUM( DS_MIN_U32             )\n             ENUM( DS_MAX_U32             )\n             ENUM( DS_AND_B32             )\n             ENUM( DS_OR_B32              )\n             ENUM( DS_XOR_B32             )\n             ENUM( DS_MSKOR_B32           )\n             ENUM( DS_WRITE_B32           )\n             ENUM( DS_WRITE2_B32          )\n             ENUM( DS_WRITE2ST64_B32      )\n             ENUM( DS_CMPST_B32           )\n             ENUM( DS_CMPST_F32           )\n             ENUM( DS_MIN_F32             )\n             ENUM( DS_MAX_F32             )\n             ENUM( DS_NOP                 )\n             ENUM( DS_GWS_SEMA_RELEASE_ALL)\n             ENUM( DS_GWS_INIT            )\n             ENUM( DS_GWS_SEMA_V          )\n             ENUM( DS_GWS_SEMA_BR         )\n             ENUM( DS_GWS_SEMA_P          )\n             ENUM( DS_GWS_BARRIER         )\n             ENUM( DS_WRITE_B8            )\n             ENUM( DS_WRITE_B16           )\n             ENUM( DS_ADD_RTN_U32         )\n             ENUM( DS_SUB_RTN_U32         )\n             ENUM( DS_RSUB_RTN_U32        )\n             ENUM( DS_INC_RTN_U32         )\n             ENUM( DS_DEC_RTN_U32         )\n             ENUM( DS_MIN_RTN_I32         )\n             ENUM( DS_MAX_RTN_I32         )\n             ENUM( DS_MIN_RTN_U32         )\n             ENUM( DS_MAX_RTN_U32         )\n             ENUM( DS_AND_RTN_B32         )\n             ENUM( DS_OR_RTN_B32          )\n             ENUM( DS_XOR_RTN_B32         )\n             ENUM( DS_MSKOR_RTN_B32       )\n             ENUM( DS_WRXCHG_RTN_B32      )\n             ENUM( DS_WRXCHG2_RTN_B32     )\n             ENUM( DS_WRXCHG2ST64_RTN_B32 )\n             ENUM( DS_CMPST_RTN_B32       )\n             ENUM( DS_CMPST_RTN_F32       )\n             ENUM( DS_MIN_RTN_F32         )\n             ENUM( DS_MAX_RTN_F32         )\n             ENUM( DS_WRAP_RTN_B32        )\n             ENUM( DS_SWIZZLE_B32         )\n             ENUM( DS_READ_B32            )\n             ENUM( DS_READ2_B32           )\n             ENUM( DS_READ2ST64_B32       )\n             ENUM( DS_READ_I8             )\n             ENUM( DS_READ_U8             )\n             ENUM( DS_READ_I16            )\n             ENUM( DS_READ_U16            )\n             ENUM( DS_CONSUME             )\n             ENUM( DS_APPEND              )\n             ENUM( DS_ORDERED_COUNT       )\n             ENUM( DS_ADD_U64             )\n             ENUM( DS_SUB_U64             )\n             ENUM( DS_RSUB_U64            )\n             ENUM( DS_INC_U64             )\n             ENUM( DS_DEC_U64             )\n             ENUM( DS_MIN_I64             )\n             ENUM( DS_MAX_I64             )\n             ENUM( DS_MIN_U64             )\n             ENUM( DS_MAX_U64             )\n             ENUM( DS_AND_B64             )\n             ENUM( DS_OR_B64              )\n             ENUM( DS_XOR_B64             )\n             ENUM( DS_MSKOR_B64           )\n             ENUM( DS_WRITE_B64           )\n             ENUM( DS_WRITE2_B64          )\n             ENUM( DS_WRITE2ST64_B64      )\n             ENUM( DS_CMPST_B64           )\n             ENUM( DS_CMPST_F64           )\n             ENUM( DS_MIN_F64             )\n             ENUM( DS_MAX_F64             )\n             ENUM( DS_ADD_RTN_U64         )\n             ENUM( DS_SUB_RTN_U64         )\n             ENUM( DS_RSUB_RTN_U64        )\n             ENUM( DS_INC_RTN_U64         )\n             ENUM( DS_DEC_RTN_U64         )\n             ENUM( DS_MIN_RTN_I64         )\n             ENUM( DS_MAX_RTN_I64         )\n             ENUM( DS_MIN_RTN_U64         )\n             ENUM( DS_MAX_RTN_U64         )\n             ENUM( DS_AND_RTN_B64         )\n             ENUM( DS_OR_RTN_B64          )\n             ENUM( DS_XOR_RTN_B64         )\n             ENUM( DS_MSKOR_RTN_B64       )\n             ENUM( DS_WRXCHG_RTN_B64      )\n             ENUM( DS_WRXCHG2_RTN_B64     )\n             ENUM( DS_WRXCHG2ST64_RTN_B64 )\n             ENUM( DS_CMPST_RTN_B64       )\n             ENUM( DS_CMPST_RTN_F64       )\n             ENUM( DS_MIN_RTN_F64         )\n             ENUM( DS_MAX_RTN_F64         )\n             ENUM( DS_READ_B64            )\n             ENUM( DS_READ2_B64           )\n             ENUM( DS_READ2ST64_B64       )\n             ENUM( DS_CONDXCHG32_RTN_B64  )\n             ENUM( DS_ADD_SRC2_U32        )\n             ENUM( DS_SUB_SRC2_U32        )\n             ENUM( DS_RSUB_SRC2_U32       )\n             ENUM( DS_INC_SRC2_U32        )\n             ENUM( DS_DEC_SRC2_U32        )\n             ENUM( DS_MIN_SRC2_I32        )\n             ENUM( DS_MAX_SRC2_I32        )\n             ENUM( DS_MIN_SRC2_U32        )\n             ENUM( DS_MAX_SRC2_U32        )\n             ENUM( DS_AND_SRC2_B32        )\n             ENUM( DS_OR_SRC2_B32         )\n             ENUM( DS_XOR_SRC2_B32        )\n             ENUM( DS_WRITE_SRC2_B32      )\n             ENUM( DS_MIN_SRC2_F32        )\n             ENUM( DS_MAX_SRC2_F32        )\n             ENUM( DS_ADD_SRC2_U64        )\n             ENUM( DS_SUB_SRC2_U64        )\n             ENUM( DS_RSUB_SRC2_U64       )\n             ENUM( DS_INC_SRC2_U64        )\n             ENUM( DS_DEC_SRC2_U64        )\n             ENUM( DS_MIN_SRC2_I64        )\n             ENUM( DS_MAX_SRC2_I64        )\n             ENUM( DS_MIN_SRC2_U64        )\n             ENUM( DS_MAX_SRC2_U64        )\n             ENUM( DS_AND_SRC2_B64        )\n             ENUM( DS_OR_SRC2_B64         )\n             ENUM( DS_XOR_SRC2_B64        )\n             ENUM( DS_WRITE_SRC2_B64      )\n             ENUM( DS_MIN_SRC2_F64        )\n             ENUM( DS_MAX_SRC2_F64        )\n             ENUM( DS_WRITE_B96           )\n             ENUM( DS_WRITE_B128          )\n             ENUM( DS_CONDXCHG32_RTN_B128 )\n             ENUM( DS_READ_B96            )\n             ENUM( DS_READ_B128           )\n             ENUM( DS_PERMUTE_B32 )\n             ENUM( DS_BPERMUTE_B32 )\n             ENUM( DS_ADD_F32 )\n        END_ENUM_TABLE          \n                  \n        START_ENUM_TABLE(BufferInstructions)\n            ENUM(BUFFER_LOAD_FORMAT_X        )\n            ENUM(BUFFER_LOAD_FORMAT_XY       )\n            ENUM(BUFFER_LOAD_FORMAT_XYZ      )\n            ENUM(BUFFER_LOAD_FORMAT_XYZW     )\n            ENUM(BUFFER_STORE_FORMAT_X       )\n            ENUM(BUFFER_STORE_FORMAT_XY      )\n            ENUM(BUFFER_STORE_FORMAT_XYZ     )\n            ENUM(BUFFER_STORE_FORMAT_XYZW    )\n            ENUM(BUFFER_LOAD_UBYTE           )\n            ENUM(BUFFER_LOAD_SBYTE           )\n            ENUM(BUFFER_LOAD_USHORT          )\n            ENUM(BUFFER_LOAD_SSHORT          )\n            ENUM(BUFFER_LOAD_DWORD           )\n            ENUM(BUFFER_LOAD_DWORDX2         )\n            ENUM(BUFFER_LOAD_DWORDX4         )\n            ENUM(BUFFER_LOAD_DWORDX3         )\n            ENUM(BUFFER_STORE_BYTE           )\n            ENUM(BUFFER_STORE_SHORT          )\n            ENUM(BUFFER_STORE_DWORD          )\n            ENUM(BUFFER_STORE_DWORDX2        )\n            ENUM(BUFFER_STORE_DWORDX4        )\n            ENUM(BUFFER_STORE_DWORDX3        )\n            ENUM(BUFFER_ATOMIC_SWAP          )\n            ENUM(BUFFER_ATOMIC_CMPSWAP       )\n            ENUM(BUFFER_ATOMIC_ADD           )\n            ENUM(BUFFER_ATOMIC_SUB           )\n            ENUM(BUFFER_ATOMIC_RSUB          )\n            ENUM(BUFFER_ATOMIC_SMIN          )\n            ENUM(BUFFER_ATOMIC_UMIN          )\n            ENUM(BUFFER_ATOMIC_SMAX          )\n            ENUM(BUFFER_ATOMIC_UMAX          )\n            ENUM(BUFFER_ATOMIC_AND           )\n            ENUM(BUFFER_ATOMIC_OR            )\n            ENUM(BUFFER_ATOMIC_XOR           )\n            ENUM(BUFFER_ATOMIC_INC           )\n            ENUM(BUFFER_ATOMIC_DEC           )\n            ENUM(BUFFER_ATOMIC_FCMPSWAP      )\n            ENUM(BUFFER_ATOMIC_FMIN          )\n            ENUM(BUFFER_ATOMIC_FMAX          )\n            ENUM(BUFFER_ATOMIC_SWAP_X2       )\n            ENUM(BUFFER_ATOMIC_CMPSWAP_X2    )\n            ENUM(BUFFER_ATOMIC_ADD_X2        )\n            ENUM(BUFFER_ATOMIC_SUB_X2        )\n            ENUM(BUFFER_ATOMIC_RSUB_X2       )\n            ENUM(BUFFER_ATOMIC_SMIN_X2       )\n            ENUM(BUFFER_ATOMIC_UMIN_X2       )\n            ENUM(BUFFER_ATOMIC_SMAX_X2       )\n            ENUM(BUFFER_ATOMIC_UMAX_X2       )\n            ENUM(BUFFER_ATOMIC_AND_X2        )\n            ENUM(BUFFER_ATOMIC_OR_X2         )\n            ENUM(BUFFER_ATOMIC_XOR_X2        )\n            ENUM(BUFFER_ATOMIC_INC_X2        )\n            ENUM(BUFFER_ATOMIC_DEC_X2        )\n            ENUM(BUFFER_ATOMIC_FCMPSWAP_X2   )\n            ENUM(BUFFER_ATOMIC_FMIN_X2       )\n            ENUM(BUFFER_ATOMIC_FMAX_X2       )\n            ENUM(BUFFER_WBINVL1_SC           )\n            ENUM(BUFFER_WBINVL1              )\n            ENUM(TBUFFER_LOAD_FORMAT_X      )\n            ENUM(TBUFFER_LOAD_FORMAT_XY     )\n            ENUM(TBUFFER_LOAD_FORMAT_XYZ    )\n            ENUM(TBUFFER_LOAD_FORMAT_XYZW   )\n            ENUM(TBUFFER_STORE_FORMAT_X     )\n            ENUM(TBUFFER_STORE_FORMAT_XY    )\n            ENUM(TBUFFER_STORE_FORMAT_XYZ   )\n            ENUM(TBUFFER_STORE_FORMAT_XYZW  )\n\n            ENUM(BUFFER_WBINVL1_VOL          )   \n            ENUM(BUFFER_STORE_LDS_DWORD      )\n            ENUM(BUFFER_LOAD_FORMAT_D16_X    )\n            ENUM(BUFFER_LOAD_FORMAT_D16_XY   )\n            ENUM(BUFFER_LOAD_FORMAT_D16_XYZ  )\n            ENUM(BUFFER_LOAD_FORMAT_D16_XYZW )\n            ENUM(BUFFER_STORE_FORMAT_D16_X   )\n            ENUM(BUFFER_STORE_FORMAT_D16_XY  )\n            ENUM(BUFFER_STORE_FORMAT_D16_XYZ )\n            ENUM(BUFFER_STORE_FORMAT_D16_XYZW)\n            ENUM(TBUFFER_LOAD_FORMAT_D16_X      )\n            ENUM(TBUFFER_LOAD_FORMAT_D16_XY     )\n            ENUM(TBUFFER_LOAD_FORMAT_D16_XYZ    )\n            ENUM(TBUFFER_LOAD_FORMAT_D16_XYZW   )\n            ENUM(TBUFFER_STORE_FORMAT_D16_X     )\n            ENUM(TBUFFER_STORE_FORMAT_D16_XY    )\n            ENUM(TBUFFER_STORE_FORMAT_D16_XYZ   )\n            ENUM(TBUFFER_STORE_FORMAT_D16_XYZW  )\n\n\n        END_ENUM_TABLE\n\n\n        START_ENUM_TABLE(ImageInstructions)\n            ENUM(IMAGE_LOAD                )\n            ENUM(IMAGE_LOAD_MIP            )\n            ENUM(IMAGE_LOAD_PCK            )\n            ENUM(IMAGE_LOAD_PCK_SGN        )\n            ENUM(IMAGE_LOAD_MIP_PCK        )\n            ENUM(IMAGE_LOAD_MIP_PCK_SGN    )\n            ENUM(IMAGE_STORE               )\n            ENUM(IMAGE_STORE_MIP           )\n            ENUM(IMAGE_STORE_PCK           )\n            ENUM(IMAGE_STORE_MIP_PCK       )\n            ENUM(IMAGE_GET_RESINFO         )\n            ENUM(IMAGE_ATOMIC_SWAP         )\n            ENUM(IMAGE_ATOMIC_CMPSWAP      )\n            ENUM(IMAGE_ATOMIC_ADD          )\n            ENUM(IMAGE_ATOMIC_SUB          )\n            ENUM(IMAGE_ATOMIC_RSUB         )\n            ENUM(IMAGE_ATOMIC_SMIN         )\n            ENUM(IMAGE_ATOMIC_UMIN         )\n            ENUM(IMAGE_ATOMIC_SMAX         )\n            ENUM(IMAGE_ATOMIC_UMAX         )\n            ENUM(IMAGE_ATOMIC_AND          )\n            ENUM(IMAGE_ATOMIC_OR           )\n            ENUM(IMAGE_ATOMIC_XOR          )\n            ENUM(IMAGE_ATOMIC_INC          )\n            ENUM(IMAGE_ATOMIC_DEC          )\n            ENUM(IMAGE_ATOMIC_FCMPSWAP     )\n            ENUM(IMAGE_ATOMIC_FMIN         )\n            ENUM(IMAGE_ATOMIC_FMAX         )\n            ENUM(IMAGE_SAMPLE              )\n            ENUM(IMAGE_SAMPLE_CL           )\n            ENUM(IMAGE_SAMPLE_D            )\n            ENUM(IMAGE_SAMPLE_D_CL         )\n            ENUM(IMAGE_SAMPLE_L            )\n            ENUM(IMAGE_SAMPLE_B            )\n            ENUM(IMAGE_SAMPLE_B_CL         )\n            ENUM(IMAGE_SAMPLE_LZ           )\n            ENUM(IMAGE_SAMPLE_C            )\n            ENUM(IMAGE_SAMPLE_C_CL         )\n            ENUM(IMAGE_SAMPLE_C_D          )\n            ENUM(IMAGE_SAMPLE_C_D_CL       )\n            ENUM(IMAGE_SAMPLE_C_L          )\n            ENUM(IMAGE_SAMPLE_C_B          )\n            ENUM(IMAGE_SAMPLE_C_B_CL       )\n            ENUM(IMAGE_SAMPLE_C_LZ         )\n            ENUM(IMAGE_SAMPLE_O            )\n            ENUM(IMAGE_SAMPLE_CL_O         )\n            ENUM(IMAGE_SAMPLE_D_O          )\n            ENUM(IMAGE_SAMPLE_D_CL_O       )\n            ENUM(IMAGE_SAMPLE_L_O          )\n            ENUM(IMAGE_SAMPLE_B_O          )\n            ENUM(IMAGE_SAMPLE_B_CL_O       )\n            ENUM(IMAGE_SAMPLE_LZ_O         )\n            ENUM(IMAGE_SAMPLE_C_O          )\n            ENUM(IMAGE_SAMPLE_C_CL_O       )\n            ENUM(IMAGE_SAMPLE_C_D_O        )\n            ENUM(IMAGE_SAMPLE_C_D_CL_O     )\n            ENUM(IMAGE_SAMPLE_C_L_O        )\n            ENUM(IMAGE_SAMPLE_C_B_O        )\n            ENUM(IMAGE_SAMPLE_C_B_CL_O     )\n            ENUM(IMAGE_SAMPLE_C_LZ_O       )\n            ENUM(IMAGE_GATHER4             )\n            ENUM(IMAGE_GATHER4_CL          )\n            ENUM(IMAGE_GATHER4_L           )\n            ENUM(IMAGE_GATHER4_B           )\n            ENUM(IMAGE_GATHER4_B_CL        )\n            ENUM(IMAGE_GATHER4_LZ          )\n            ENUM(IMAGE_GATHER4_C           )\n            ENUM(IMAGE_GATHER4_C_CL        )\n            ENUM(IMAGE_GATHER4_C_L         )\n            ENUM(IMAGE_GATHER4_C_B         )\n            ENUM(IMAGE_GATHER4_C_B_CL      )\n            ENUM(IMAGE_GATHER4_C_LZ        )\n            ENUM(IMAGE_GATHER4_O           )\n            ENUM(IMAGE_GATHER4_CL_O        )\n            ENUM(IMAGE_GATHER4_L_O         )\n            ENUM(IMAGE_GATHER4_B_O         )\n            ENUM(IMAGE_GATHER4_B_CL_O      )\n            ENUM(IMAGE_GATHER4_LZ_O        )\n            ENUM(IMAGE_GATHER4_C_O         )\n            ENUM(IMAGE_GATHER4_C_CL_O      )\n            ENUM(IMAGE_GATHER4_C_L_O       )\n            ENUM(IMAGE_GATHER4_C_B_O       )\n            ENUM(IMAGE_GATHER4_C_B_CL_O    )\n            ENUM(IMAGE_GATHER4_C_LZ_O      )\n            ENUM(IMAGE_GET_LOD             )\n            ENUM(IMAGE_SAMPLE_CD           )\n            ENUM(IMAGE_SAMPLE_CD_CL        )\n            ENUM(IMAGE_SAMPLE_C_CD         )\n            ENUM(IMAGE_SAMPLE_C_CD_CL      )\n            ENUM(IMAGE_SAMPLE_CD_O         )\n            ENUM(IMAGE_SAMPLE_CD_CL_O      )\n            ENUM(IMAGE_SAMPLE_C_CD_O       )\n            ENUM(IMAGE_SAMPLE_C_CD_CL_O    )       \n        END_ENUM_TABLE\n\n\n        START_ENUM_TABLE(FlatInstructions)\n            ENUM(FLAT_LOAD_UBYTE          )\n            ENUM(FLAT_LOAD_SBYTE          )\n            ENUM(FLAT_LOAD_USHORT         )\n            ENUM(FLAT_LOAD_SSHORT         )\n            ENUM(FLAT_LOAD_DWORD          )\n            ENUM(FLAT_LOAD_DWORDX2        )\n            ENUM(FLAT_LOAD_DWORDX4        )\n            ENUM(FLAT_LOAD_DWORDX3        )\n            ENUM(FLAT_STORE_BYTE          )\n            ENUM(FLAT_STORE_SHORT         )\n            ENUM(FLAT_STORE_DWORD         )\n            ENUM(FLAT_STORE_DWORDX2       )\n            ENUM(FLAT_STORE_DWORDX4       )\n            ENUM(FLAT_STORE_DWORDX3       )\n            ENUM(FLAT_ATOMIC_SWAP         )\n            ENUM(FLAT_ATOMIC_CMPSWAP      )\n            ENUM(FLAT_ATOMIC_ADD          )\n            ENUM(FLAT_ATOMIC_SUB          )\n            ENUM(FLAT_ATOMIC_SMIN         )\n            ENUM(FLAT_ATOMIC_UMIN         )\n            ENUM(FLAT_ATOMIC_SMAX         )\n            ENUM(FLAT_ATOMIC_UMAX         )\n            ENUM(FLAT_ATOMIC_AND          )\n            ENUM(FLAT_ATOMIC_OR           )\n            ENUM(FLAT_ATOMIC_XOR          )\n            ENUM(FLAT_ATOMIC_INC          )\n            ENUM(FLAT_ATOMIC_DEC          )\n            ENUM(FLAT_ATOMIC_FCMPSWAP     )\n            ENUM(FLAT_ATOMIC_FMIN         )\n            ENUM(FLAT_ATOMIC_FMAX         )\n            ENUM(FLAT_ATOMIC_SWAP_X2      )\n            ENUM(FLAT_ATOMIC_CMPSWAP_X2   )\n            ENUM(FLAT_ATOMIC_ADD_X2       )\n            ENUM(FLAT_ATOMIC_SUB_X2       )\n            ENUM(FLAT_ATOMIC_SMIN_X2      )\n            ENUM(FLAT_ATOMIC_UMIN_X2      )\n            ENUM(FLAT_ATOMIC_SMAX_X2      )\n            ENUM(FLAT_ATOMIC_UMAX_X2      )\n            ENUM(FLAT_ATOMIC_AND_X2       )\n            ENUM(FLAT_ATOMIC_OR_X2        )\n            ENUM(FLAT_ATOMIC_XOR_X2       )\n            ENUM(FLAT_ATOMIC_INC_X2       )\n            ENUM(FLAT_ATOMIC_DEC_X2       )\n            ENUM(FLAT_ATOMIC_FCMPSWAP_X2  )\n            ENUM(FLAT_ATOMIC_FMIN_X2      )\n            ENUM(FLAT_ATOMIC_FMAX_X2      )\n        END_ENUM_TABLE\n\n        #define ENUM_EXP(x) { EXP_##x, #x },\n        START_ENUM_TABLE(ExportTargets)\n            ENUM_EXP(MRT0      )\n            ENUM_EXP(MRT1      )\n            ENUM_EXP(MRT2      )\n            ENUM_EXP(MRT3      )\n            ENUM_EXP(MRT4      )\n            ENUM_EXP(MRT5      )\n            ENUM_EXP(MRT6      )\n            ENUM_EXP(MRT7      )\n            ENUM_EXP(Z         )\n            ENUM_EXP(NULL      )\n            ENUM_EXP(POS0      )\n            ENUM_EXP(POS1      )\n            ENUM_EXP(POS2      )\n            ENUM_EXP(POS3      )\n            ENUM_EXP(PARAM0    )\n            ENUM_EXP(PARAM1    )\n            ENUM_EXP(PARAM2    )\n            ENUM_EXP(PARAM3    )\n            ENUM_EXP(PARAM4    )\n            ENUM_EXP(PARAM5    )\n            ENUM_EXP(PARAM6    )\n            ENUM_EXP(PARAM7    )\n            ENUM_EXP(PARAM8    )\n            ENUM_EXP(PARAM9    )\n            ENUM_EXP(PARAM10   )\n            ENUM_EXP(PARAM11   )\n            ENUM_EXP(PARAM12   )\n            ENUM_EXP(PARAM13   )\n            ENUM_EXP(PARAM14   )\n            ENUM_EXP(PARAM15   )\n            ENUM_EXP(PARAM16   )\n            ENUM_EXP(PARAM17   )\n            ENUM_EXP(PARAM18   )\n            ENUM_EXP(PARAM19   )\n            ENUM_EXP(PARAM20   )\n            ENUM_EXP(PARAM21   )\n            ENUM_EXP(PARAM22   )\n            ENUM_EXP(PARAM23   )\n            ENUM_EXP(PARAM24   )\n            ENUM_EXP(PARAM25   )\n            ENUM_EXP(PARAM26   )\n            ENUM_EXP(PARAM27   )\n            ENUM_EXP(PARAM28   )\n            ENUM_EXP(PARAM29   )\n            ENUM_EXP(PARAM30   )\n            ENUM_EXP(PARAM31   )\n        END_ENUM_TABLE\n\n        #define ENUM_NF(x) { NF_##x, #x },\n        START_ENUM_TABLE(TBufferNumberFormats)\n            ENUM_NF(UNORM     )\n            ENUM_NF(SNORM     )\n            ENUM_NF(USCALED   )\n            ENUM_NF(SSCALED   )\n            ENUM_NF(UINT      )\n            ENUM_NF(SINT      )\n            ENUM_NF(SNORM_NZ  )\n            ENUM_NF(FLOAT     )\n            ENUM_NF(SRGB      )\n            ENUM_NF(UBNORM    )\n            ENUM_NF(UBNORM_NZ )\n            ENUM_NF(UBINT     )\n            ENUM_NF(UBSCALED  )\n        END_ENUM_TABLE\n        \n    #define ENUM_DF(x) { DF_##x, #x },\n        START_ENUM_TABLE(TBufferDataFormats)\n            ENUM_DF(INVALID    )\n            ENUM_DF(8          )\n            ENUM_DF(16         )\n            ENUM_DF(8_8        )\n            ENUM_DF(32         )\n            ENUM_DF(16_16      )\n            ENUM_DF(10_11_11   )\n            ENUM_DF(11_11_10   )\n            ENUM_DF(10_10_10_2 )\n            ENUM_DF(2_10_10_10 )\n            ENUM_DF(8_8_8_8    )\n            ENUM_DF(32_32      )\n            ENUM_DF(16_16_16_16)\n            ENUM_DF(32_32_32   )\n            ENUM_DF(32_32_32_32)\n        END_ENUM_TABLE\n\n        const char* Search( const EnumLookup* pTable, unsigned int nValue )\n        {\n            do  // NOTE: could be a binary search, except that the vop3 table is out of order\n            {\n                if( pTable->n == nValue )\n                    break;\n                ++pTable;\n            } while( pTable->str );   \n            return pTable->str;\n        }\n    }\n\n    #define IMPLEMENT_ENUM_LOOKUP(en) \\\n    const char* EnumToString(en op) {\\\n        const char* p = _INTERNAL::Search( _INTERNAL::en##LUT, op ); \\\n        return p ? p : \"?????????\"#en; }\n\n    IMPLEMENT_ENUM_LOOKUP(ScalarInstructions);\n    \n    IMPLEMENT_ENUM_LOOKUP(ScalarMemoryInstructions);\n    IMPLEMENT_ENUM_LOOKUP(VectorInstructions);\n    IMPLEMENT_ENUM_LOOKUP(BufferInstructions)\n    IMPLEMENT_ENUM_LOOKUP(ImageInstructions)\n    IMPLEMENT_ENUM_LOOKUP(DSInstructions);\n    IMPLEMENT_ENUM_LOOKUP(ExportTargets);\n    IMPLEMENT_ENUM_LOOKUP(FlatInstructions);\n    IMPLEMENT_ENUM_LOOKUP(TBufferDataFormats);\n    IMPLEMENT_ENUM_LOOKUP(TBufferNumberFormats);\n\n}"
  },
  {
    "path": "src/Wrapper/GCNEnums.h",
    "content": "//\n//    GCN Opcodes, register types, and other things.  Based on a trawling of the ISA docs.\n//      Copyright 2015 Joshua Barczak, all rights reserved.\n//\n#ifndef _GCN_ENUMS_H_\n#define _GCN_ENUMS_H_\n#pragma once\n\nnamespace GCN\n{\n \n    enum InstructionFormat\n    {\n        IF_SOP2,\n        IF_SOPK,\n        IF_SOP1,\n        IF_SOPC,\n        IF_SOPP,\n        IF_SMRD, // SI and CI\n        IF_SMEM, // GCN3+\n        IF_VOP2,\n        IF_VOP1,\n        IF_VOPC,\n        IF_VOP3, \n        IF_VINTERP,\n        IF_DS,\n        IF_MTBUFF,\n        IF_MUBUFF,\n        IF_MIMG,\n        IF_EXP,\n        IF_FLAT, // SEA ISLANDS and up\n        IF_UNKNOWN,\n    };\n\n    enum InstructionClass\n    {\n        IC_SCALAR,\n        IC_SCALAR_MEM,\n        IC_VECTOR,\n        IC_VECTOR_INTERP,\n        IC_BUFFER,\n        IC_IMAGE,\n        IC_EXPORT,\n        IC_DS,\n        IC_INVALID\n    };\n\n    /// Scalar dests\n    enum Dests\n    {\n        DEST_SGPR_FIRST  = 0,   \n        DEST_SGPR_LAST   = 103, // NOTE: GCN3 only allows 0-101, and stores VCC in s102 and s103\n        DEST_FSCR_LO     = 104, // flat scratch memory descriptor, low (SEA ISLANDS+)\n        DEST_FSCR_HI     = 105, // flat scratcy memory descriptor, hi (SEA ISLANDS)\n        DEST_VCC_LO      = 106, // Vector condition code\n        DEST_VCC_HI,\n        DEST_TBA_LO,         // Trap handler base address\n        DEST_TBA_HI,\n        DEST_TMA_LO,         // Pointer to data in memory used by trap handler\n        DEST_TMA_HI,\n        DEST_TTMP_FIRST   ,      // Trap handler temporary regs (priviledged)\n        DEST_TTMP_LAST    = 123,\n        DEST_M0           = 124,        // Magical memory register used for various things\n        DEST_EXEC_LO      =126,     // Vector exec mask\n        DEST_EXEC_HI       ,\n        DEST_VGPR_FIRST   = 256,\n        DEST_VGPR_LAST    = 511,\n\n\n        DEST_SCC,\n        DEST_VSKIP, // implied dests for compare and vskip instructions\n        DEST_VCC,\n\n        DEST_XNACK_MASK_LO,\n        DEST_XNACK_MASK_HI,\n\n        DEST_INVALID      = 0xffffffff\n    };\n\n    /// Sources\n    enum Sources\n    {\n        SRC_SGPR_FIRST  = 0,   \n        SRC_SGPR_LAST   = 103, // NOTE: GCN3 only allows 0-101, and stores VCC in s102 and s103\n        SRC_FSCR_LO     , // flat scratch memory descriptor, low (SEA ISLANDS+)\n        SRC_FSCR_HI     , // flat scratcy memory descriptor, hi (SEA ISLANDS)\n        SRC_VCC_LO      ,     // Vector condition code\n        SRC_VCC_HI,\n        SRC_TBA_LO,         // Trap handler base address\n        SRC_TBA_HI,\n        SRC_TMA_LO,         // Pointer to data in memory used by trap handler\n        SRC_TMA_HI,\n        SRC_TTMP_FIRST   ,      // Trap handler temporary regs (priviledged)\n        SRC_TTMP_LAST    = 123,\n        SRC_M0           ,        // Magical memory register used for various things\n\n        // 125 reserved\n\n        SRC_EXEC_LO      =126,     // Vector exec mask\n        SRC_EXEC_HI       ,\n        SRC_C_ZERO=128,\n        SRC_CI_POSITIVE_FIRST= 129, // Signed integers 1 to 64\n        SRC_CI_POSITIVE_LAST = 192,\n        SRC_CI_NEGATIVE_FIRST=193, // Signed integers -1 to -16\n        SRC_CI_NEGATIVE_LAST = 208,\n\n        // 209-239 reserved\n\n        SRC_CF_ONEHALF      =240, // float constants\n        SRC_CF_MINUS_ONEHALF,\n        SRC_CF_ONE,\n        SRC_CF_MINUS_ONE,\n        SRC_CF_TWO,\n        SRC_CF_MINUS_TWO,\n        SRC_CF_FOUR,\n        SRC_CF_MINUS_FOUR,\n        SRC_CF_INV_2PI = 248,\n\n\n\n        // 249-250 reserved\n\n        SRC_VCCZ        = 251, // Vector condition code\n        SRC_EXECZ       = 252, // Vector EXEC mask\n        SRC_SCC         = 253, // Scalar condition code\n\n        SRC_LDS_DIRECT  = 254, // direct LDS access, with address from 'M0' (vector only\n        \n        SRC_LITERAL= 255, // DWORD literal following instruction\n\n        SRC_VGPR_FIRST = 256,\n        SRC_VGPR_LAST  = 511,\n\n        SRC_XNACK_MASK_LO, // Carrizo apu only.  Something to do with address translation\n        SRC_XNACK_MASK_HI,\n\n        SRC_INVALID =0xffffffff\n    };\n\n    enum ScalarInstructions\n    {\n        S_INVALID = 0xffffffff,\n        \n        /////////////////////////////////////////\n        // SOP2\n        /////////////////////////////////////////\n        S_ADD_U32               ,   //: D.u = S0.u + S1.u. SCC = carry out.\n        S_SUB_U32               ,   //: D.u = S0.u - S1.u. SCC = carry out.\n        S_ADD_I32               ,   //: D.u = S0.i + S1.i. SCC = overflow.\n        S_SUB_I32               ,   //: D.u = S0.i - S1.i. SCC = overflow.\n        S_ADDC_U32              ,   //: D.u = S0.u + S1.u + SCC. SCC = carry-out.\n        S_SUBB_U32              ,   //: D.u = S0.u - S1.u - SCC. SCC = carry-out.\n        S_MIN_I32               ,   //: D.i = (S0.i < S1.i) ? S0.i : S1.i. SCC = 1 if S0 is min.\n        S_MIN_U32               ,   //: D.u = (S0.u < S1.u) ? S0.u : S1.u. SCC = 1 if S0 is min.\n        S_MAX_I32               ,   //: D.i = (S0.i > S1.i) ? S0.i : S1.i. SCC = 1 if S0 is max.\n        S_MAX_U32               ,   //: D.u = (S0.u > S1.u) ? S0.u : S1.u. SCC = 1 if S0 is max.\n        S_CSELECT_B32           ,   //: D.u = SCC ? S0.u : S1.u.\n        S_CSELECT_B64           ,   //: D.u = SCC ? S0.u : S1.u.\n        S_AND_B32               ,   //: D.u = S0.u & S1.u. SCC = 1 if result is non-zero.\n        S_AND_B64               ,   //: D.u = S0.u & S1.u. SCC = 1 if result is non-zero.\n        S_OR_B32                ,   //: D.u = S0.u | S1.u. SCC = 1 if result is non-zero.\n        S_OR_B64                ,   //: D.u = S0.u | S1.u. SCC = 1 if result is non-zero.\n        S_XOR_B32               ,   //: D.u = S0.u ^ S1.u. SCC = 1 if result is non-zero.\n        S_XOR_B64               ,   //: D.u = S0.u ^ S1.u. SCC = 1 if result is non-zero.\n        S_ANDN2_B32             ,   //: D.u = S0.u & ~S1.u. SCC = 1 if result is non-zero.\n        S_ANDN2_B64             ,   //: D.u = S0.u & ~S1.u. SCC = 1 if result is non-zero.\n        S_ORN2_B32              ,   //: D.u = S0.u | ~S1.u. SCC = 1 if result is non-zero.\n        S_ORN2_B64              ,   //: D.u = S0.u | ~S1.u. SCC = 1 if result is non-zero.\n        S_NAND_B32              ,   //: D.u = ~(S0.u & S1.u). SCC = 1 if result is non-zero.\n        S_NAND_B64              ,   //: D.u = ~(S0.u & S1.u). SCC = 1 if result is non-zero.\n        S_NOR_B32               ,   //: D.u = ~(S0.u | S1.u). SCC = 1 if result is non-zero.\n        S_NOR_B64               ,   //: D.u = ~(S0.u | S1.u). SCC = 1 if result is non-zero.\n        S_XNOR_B32              ,   //: D.u = ~(S0.u ^ S1.u). SCC = 1 if result is non-zero.\n        S_XNOR_B64              ,   //: D.u = ~(S0.u ^ S1.u). SCC = 1 if result is non-zero.\n        S_LSHL_B32              ,   //: D.u = S0.u << S1.u[4:0]. SCC = 1 if result is non-zero.\n        S_LSHL_B64              ,   //: D.u = S0.u << S1.u[5:0]. SCC = 1 if result is non-zero.\n        S_LSHR_B32              ,   //: D.u = S0.u >> S1.u[4:0]. SCC = 1 if result is non-zero.\n        S_LSHR_B64              ,   //: D.u = S0.u >> S1.u[5:0]. SCC = 1 if result is non-zero.\n        S_ASHR_I32              ,   //: D.i = signtext(S0.i) >> S1.i[4:0]. SCC = 1 if result is non-zero.\n        S_ASHR_I64              ,   //: D.i = signtext(S0.i) >> S1.i[5:0]. SCC = 1 if result is non-zero.\n        S_BFM_B32               ,   //: D.u = ((1 << S0.u[4:0]) - 1) << S1.u[4:0]; bitfield mask.\n        S_BFM_B64               ,   //: D.u = ((1 << S0.u[5:0]) - 1) << S1.u[5:0]; bitfield mask.\n        S_MUL_I32               ,   //: D.i = S0.i * S1.i.\n        S_BFE_U32               ,    // : Bit field extract. S0 is data, S1[4:0] is field offset, S1[22:16] is field width. D.u = (S0.u >> S1.u[4:0]) & ((1 << S1.u[22:16]) - 1). SCC = 1 if resultis non-zero.\n        S_BFE_I32               ,\n        S_BFE_U64               ,\n        S_BFE_I64               ,\n        S_CBRANCH_G_FORK        , // Conditional branch using branch stack. Arg0 = compare mask (VCC or any SGPR), Arg1 = 64-bit byte address of target instruction.\n        S_ABSDIFF_I32           ,  //  D.i = abs(S0.i >> S1.i). SCC = 1 if result is non-zero.\n        \n        // VI+\n        S_RFE_RESTORE_B64       , // Return from exception handler and set: INST_ATC = S1.U32[0]\n        \n        /////////////////////////////////////////\n        // SOPK\n        /////////////////////////////////////////\n        S_MOVK_I32              ,  //: D.i = signext(SIMM16).\n        S_CMOVK_I32             ,  //: if (SCC) D.i = signext(SIMM16); else NOP.\n        S_CMPK_EQ_I32           ,  //: SCC = (D.i == signext(SIMM16).\n        S_CMPK_LG_I32           ,  //: SCC = (D.i != signext(SIMM16).\n        S_CMPK_GT_I32           ,  //: SCC = (D.i != signext(SIMM16)).\n        S_CMPK_GE_I32           ,  //: SCC = (D.i >= signext(SIMM16)).\n        S_CMPK_LT_I32           ,  //: SCC = (D.i < signext(SIMM16)).\n        S_CMPK_LE_I32           ,  //: SCC = (D.i <= signext(SIMM16)).\n        S_CMPK_EQ_U32           ,  //: SCC = (D.u == SIMM16).\n        S_CMPK_LG_U32           , //: SCC = (D.u != SIMM16).\n        S_CMPK_GT_U32           , //: SCC = (D.u > SIMM16).\n        S_CMPK_GE_U32           , //: SCC = (D.u >= SIMM16).\n        S_CMPK_LT_U32           , //: SCC = (D.u < SIMM16).\n        S_CMPK_LE_U32           , //: D.u = SCC = (D.u <= SIMM16).\n        S_ADDK_I32              , //: D.i = D.i + signext(SIMM16). SCC = overflow.\n        S_MULK_I32              , //: D.i = D.i * signext(SIMM16). SCC = overflow.\n        S_CBRANCH_I_FORK        , //: Conditional branch using branch-stack.\n                                          // Arg0(sdst) = compare mask (VCC or any SGPR), SIMM16 = signed DWORD\n                                          // branch offset relative to next instruction.\n        S_GETREG_B32            , // : D.u = hardware register. Read some or all of a hardware register\n                                      //     into the LSBs of D. SIMM16 = {size[4:0], offset[4:0], hwRegId[5:0]}; offset\n                                      //     is 031, size is 132.\n        S_SETREG_B32            , // : hardware register = D.u. Write some or all of the LSBs of D\n                                         //     into a hardware register (note that D is a source SGPR).\n                                         //     SIMM16 = {size[4:0], offset[4:0], hwRegId[5:0]}; offset is 031, size is 132.\n                                //20 reserved.          //\n        S_SETREG_IMM32_B32      , //: This instruction uses a 32-bit literal constant. Write\n                                         //    some or all of the LSBs of IMM32 into a hardware register.\n                                         //    SIMM16 = {size[4:0], offset[4:0], hwRegId[5:0]}; offset is 031, size is 132.\n                            \n        /////////////////////////////////////////\n        // SOP1\n        /////////////////////////////////////////\n        S_MOV_B32              ,//: D.u = S0.u.\n        S_MOV_B64              ,//: D/u = S0.u.\n        S_CMOV_B32             ,//: if(SCC) D.u = S0.u; else NOP.\n        S_CMOV_B64             ,//: if(SCC) D.u = S0.u; else NOP.\n        S_NOT_B32              ,//: D.u = ~S0.u SCC = 1 if result non-zero.\n        S_NOT_B64              ,//: D.u = ~S0.u SCC = 1 if result non-zero.\n        S_WQM_B32              ,//: D.u = WholeQuadMode(S0.u). SCC = 1 if result is non-zero.\n        S_WQM_B64              ,//: D.u = WholeQuadMode(S0.u). SCC = 1 if result is non-zero.\n        S_BREV_B32             ,//: D.u = S0.u[0:31] (reverse bits).\n        S_BREV_B64             ,//: D.u = S0.u[0:63] (reverse bits).\n        S_BCNT0_I32_B32        ,//: D.i = CountZeroBits(S0.u). SCC = 1 if result is non-zero.\n        S_BCNT0_I32_B64        ,//: D.i = CountZeroBits(S0.u). SCC = 1 if result is non-zero.\n        S_BCNT1_I32_B32        ,//: D.i = CountOneBits(S0.u). SCC = 1 if result is non-zero.\n        S_BCNT1_I32_B64        ,//: D.i = CountOneBits(S0.u). SCC = 1 if result is non-zero.\n        S_FF0_I32_B32          ,//: D.i = FindFirstZero(S0.u) from LSB; if no zeros, return -1.\n        S_FF0_I32_B64          ,//: D.i = FindFirstZero(S0.u) from LSB; if no zeros, return -1.\n        S_FF1_I32_B32          ,//: D.i = FindFirstOne(S0.u) from LSB; if no ones, return -1.\n        S_FF1_I32_B64          ,//: D.i = FindFirstOne(S0.u) from LSB; if no ones, return -1.\n        S_FLBIT_I32_B32        ,//: D.i = FindFirstOne(S0.u) from MSB; if no ones, return -1.\n        S_FLBIT_I32_B64        ,//: D.i = FindFirstOne(S0.u) from MSB; if no ones, return -1.\n        S_FLBIT_I32            ,//: D.i = Find first bit opposite of sign bit from MSB. If S0 == -1, return -1.\n        S_FLBIT_I32_I64        ,//: D.i = Find first bit opposite of sign bit from MSB. If S0 == -1, return -1.\n        S_SEXT_I32_I8          ,//: D.i = signext(S0.i[7:0]).\n        S_SEXT_I32_I16         ,//: D.i = signext(S0.i[15:0]).\n        S_BITSET0_B32          ,//: D.u[S0.u[4:0]] = 0.\n        S_BITSET0_B64          ,//: D.u[S0.u[5:0]] = 0.\n        S_BITSET1_B32          ,//: D.u[S0.u[4:0]] = 1.\n        S_BITSET1_B64          ,//: D.u[S0.u[5:0]] = 1.\n        S_GETPC_B64            ,//: D.u = PC + 4; destination receives the byte address of the next instruction.\n        S_SETPC_B64            ,//: PC = S0.u; S0.u is a byte address of the instruction to jump to.\n        S_SWAPPC_B64           ,//: D.u = PC + 4; PC = S0.u.\n        S_RFE_B64              ,//: Return from Exception; PC = TTMP1,0.\n        S_AND_SAVEEXEC_B64     ,//: D.u = EXEC, EXEC = S0.u & EXEC. SCC = 1 if the new value of EXEC is non-zero.\n        S_OR_SAVEEXEC_B64      ,//: D.u = EXEC, EXEC = S0.u | EXEC. SCC = 1 if the newvalue of EXEC is non-zero.\n        S_XOR_SAVEEXEC_B64     ,//: D.u = EXEC, EXEC = S0.u ^ EXEC. SCC = 1 if the new value of EXEC is non-zero.\n        S_ANDN2_SAVEEXEC_B64   ,//: D.u = EXEC, EXEC = S0.u & ~EXEC. SCC =1 if the new value of EXEC is non-zero.\n        S_ORN2_SAVEEXEC_B64    ,//: D.u = EXEC, EXEC = S0.u | ~EXEC. SCC = 1 if the new value of EXEC is non-zero.\n        S_NAND_SAVEEXEC_B64    ,//: D.u = EXEC, EXEC = ~(S0.u & EXEC). SCC =1 if the new value of EXEC is non-zero.\n        S_NOR_SAVEEXEC_B64     ,//: D.u = EXEC, EXEC = ~(S0.u | EXEC). SCC = 1 if the new value of EXEC is non-zero.\n        S_XNOR_SAVEEXEC_B64    ,//: D.u = EXEC, EXEC = ~(S0.u ^ EXEC). SCC = 1 if the new value of EXEC is non-zero.\n        S_QUADMASK_B32         ,//: D.u = QuadMask(S0.u). D[0] = OR(S0[3:0]), D[1] = OR(S0[7:4]) .... SCC = 1 if result is non-zero.\n        S_QUADMASK_B64         ,//: D.u = QuadMask(S0.u). D[0] = OR(S0[3:0]),D[1] = OR(S0[7:4]) .... SCC = 1 if result is non-zero\n        S_MOVRELS_B32          ,//: SGPR[D.u] = SGPR[S0.u + M0.u].\n        S_MOVRELS_B64          ,//: SGPR[D.u] = SGPR[S0.u + M0.u].\n        S_MOVRELD_B32          ,//: SGPR[D.u + M0.u] = SGPR[S0.u].\n        S_MOVRELD_B64          ,//: SGPR[D.u + M0.u] = SGPR[S0.u].\n        S_CBRANCH_JOIN         ,//: Conditional branch join point. Arg0 = saved CSP value. No dest.\n        S_ABS_I32              ,      //: D.i = abs(S0.i). SCC=1 if result is non-zero.\n        S_MOV_FED_B32          ,      //: D.u = S0.u, introduce edc double error upon write to dest sgpr.  \n        \n        // VI+\n        S_SET_GPR_IDX_IDX      ,//: Set offset for GPR indexing (GCN3+) M0[7:0] = S0.U[7:0]\n   \n\n        /////////////////////////////////////////\n        // SOPC\n        /////////////////////////////////////////\n       \n        S_CMP_EQ_I32          ,     //: SCC = (S0.i == S1.i).\n        S_CMP_LG_I32          ,     //: SCC = (S0.i != S1.i).\n        S_CMP_GT_I32          ,     //: SCC = (S0.i > S1.i).\n        S_CMP_GE_I32          ,     //: SCC = (S0.i >= S1.i).\n        S_CMP_LT_I32          ,     //: SCC = (S0.i < S1.i).\n        S_CMP_LE_I32          ,     //: SCC = (S0.i <= S1.i).\n        S_CMP_EQ_U32          ,     //: SCC = (S0.u == S1.u).\n        S_CMP_LG_U32          ,     //: SCC = (S0.u != S1.u).\n        S_CMP_GT_U32          ,     //: SCC = (S0.u > S1.u).\n        S_CMP_GE_U32          ,     //: SCC = (S0.u >= S1.u).\n        S_CMP_LT_U32          ,     //: SCC = (S0.u < S1.u).\n        S_CMP_LE_U32          ,     //: SCC = (S0.u <= S1.u).\n        S_BITCMP0_B32         ,     //: SCC = (S0.u[S1.u[4:0]] == 0).\n        S_BITCMP1_B32         ,     //: SCC = (S0.u[S1.u[4:0]] == 1).\n        S_BITCMP0_B64         ,     //: SCC = (S0.u[S1.u[5:0]] == 0).\n        S_BITCMP1_B64         ,     //: SCC = (S0.u[S1.u[5:0]] == 1).\n        S_SETVSKIP            ,     //: VSKIP = S0.u[S1.u[4:0]].\n\n        // VI+\n        S_CMP_EQ_U64          , // SCC = SCC = (S0.i64 == S1.i64).\n        S_CMP_NE_U64          , // SXCCX = (S0 != S1).\n        S_SET_GPR_IDX_ON      , //: Enable GPR indexing mode. Vector operations after this will perform relative GPR addressing based on the contents of M0.\n                                // The structure SQ_M0_GPR_IDX_WORD may be used to decode M0. \n                                //  The raw contents of the S1 field are read and used to set the enable bits. \n                                //  S1[0] = VSRC0_REL, S1[1] = VSRC1_REL, S1[2] = VSRC2_REL, and S1[3] = VDST_REL.\n                                //    MODE.gpr_idx_en = 1;\n                                //    M0[7:0] = S0.u[7:0];\n                                //    M0[15:12] = SIMM4 (direct contents of S1 field);\n\n\n\n\n        /////////////////////////////////////////\n        // SOPP\n        /////////////////////////////////////////\n  \n        S_NOP                      ,  //: do nothing. Repeat NOP 1..8 times based on SIMM16[2:0]. 0 = 1 time, 7 = 8 times.\n        S_ENDPGM                   ,  //: end of program; terminate wavefront.\n        S_BRANCH                   ,  //: PC = PC + signext(SIMM16 * 4) + 4.\n        S_CBRANCH_SCC0             ,  //: if(SCC == 0) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n        S_CBRANCH_SCC1             ,  //: if(SCC == 1) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n        S_CBRANCH_VCCZ             ,  //: if(VCC == 0) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n        S_CBRANCH_VCCNZ            ,  //: if(VCC != 0) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n        S_CBRANCH_EXECZ            ,  //: if(EXEC == 0) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n        S_CBRANCH_EXECNZ           ,  //: if(EXEC != 0) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n        S_BARRIER                  ,  //: Sync waves within a thread group.                              \n        S_WAITCNT                  ,  //: Wait for count of outstanding lds, vector-memory and\n                                          //  export/vmem-write-data to be at or below the specified levels. simm16[3:0] =\n                                          //  vmcount, simm16[6:4] = export/mem-write-data count, simm16[12:8] =\n                                          //  LGKM_cnt (scalar-mem/GDS/LDS count).\n        S_SETHALT                  ,  //: set HALT bit to value of SIMM16[0]. 1=halt, 0=resume. Halt is ignored while priv=1.\n        S_SLEEP                    ,  //: Cause a wave to sleep for approximately 64*SIMM16[2:0] clocks.\n        S_SETPRIO                  ,  //: User settable wave priority. 0 = lowest, 3 = highest.\n        S_SENDMSG                  ,  //: Send a message.\n        S_SENDMSGHALT              ,  //: Send a message and then HALT.\n        S_TRAP                     ,  //: Enter the trap handler. TrapID = SIMM16[7:0]. Wait for all instructions to complete, \n                                          //    save {pc_rewind,trapID,pc} into ttmp0,1; load TBA into PC,\n                                          //    set PRIV=1 and continue.\n        S_ICACHE_INV               ,  //: Invalidate entire L1 I cache.\n        S_INCPERFLEVEL             ,  //: Increment performance counter specified in SIMM16[3:0] by 1.\n        S_DECPERFLEVEL             ,  //: Decrement performance counter specified in SIMM16[3:0] by 1.\n        S_TTRACEDATA               ,  //: Send M0 as user data to thread-trace.\n\n        // Sea islands and above only...\n        S_CBRANCH_CDBGSYS          ,// : If (conditional_debug_system != 0) then PC = PC + signext(SIMM16 * 4) + 4; else NOP.\n        S_CBRANCH_CDBGUSER         ,// : If (conditional_debug_user != 0) then PC = PC + signext(SIMM16 * 4) + 4; else NOP.\n        S_CBRANCH_CDBGSYS_OR_USER  ,// : If (conditional_debug_system || conditional_debug_user) then PC = PC + signext(SIMM16 * 4) + 4; else NOP.\n        S_CBRANCH_CDBGSYS_AND_USER ,// : If (conditional_debug_system && conditional_debug_user) then PC = PC + signext(SIMM16 * 4) + 4; else NOP.\n\n        // VI+\n        S_ENDPGM_SAVED,\n        S_SET_GPR_IDX_OFF,\n        S_SET_GPR_IDX_MODE,\n        S_SETKILL,\n\n    };\n\n\n    enum ScalarMemoryInstructions\n    {\n        /////////////////////////////////////////\n        // SMRD (GCN1) SMEM(GCN3)\n        /////////////////////////////////////////\n  \n        S_LOAD_DWORD               ,// : Read from read-only constant memory.\n        S_LOAD_DWORDX2             ,// : Read from read-only constant memory.\n        S_LOAD_DWORDX4             ,// : Read from read-only constant memory.\n        S_LOAD_DWORDX8             ,// : Read from read-only constant memory.\n        S_LOAD_DWORDX16            ,// : Read from read-only constant memory.\n        S_BUFFER_LOAD_DWORD        ,// : Read from read-only constant memory.\n        S_BUFFER_LOAD_DWORDX2      ,// : Read from read-only constant memory.\n        S_BUFFER_LOAD_DWORDX4      ,// : Read from read-only constant memory.\n        S_BUFFER_LOAD_DWORDX8      ,// : Read from read-only constant memory.\n        S_BUFFER_LOAD_DWORDX16     ,// : Read from read-only constant memory.\n        S_DCACHE_INV_VOL           ,// : Invalidate all volatile lines in L1 constant cache.\n        S_MEMTIME                  ,// : Return current 64-bit timestamp.\n        S_DCACHE_INV               ,// : Invalidate entire L1 K cache.\n\n        // VI+\n        S_STORE_DWORD              ,//: Write one Dword to scalar data cache. If the offset is specified as an SGPR, the SGPR contains an unsigned BYTE offset (the two LSBs are ignored). If the offset is specified as an immediate 20-bit constant, the constant is an unsigned byte offset.\n        S_STORE_DWORDX2            ,//: Write two Dwords to scalar data cache. See S_STORE_DWORD for details on the offset input.\n        S_STORE_DWORDX4            ,//: Write four Dwords to scalar data cache. See S_STORE_DWORD for details on the offset input.\n        S_BUFFER_STORE_DWORD       ,//: Write one Dword to scalar data cache. See S_STORE_DWORD for details on the offset input.\n        S_BUFFER_STORE_DWORDX2     ,//: Write two Dwords to scalar data cache. See S_STORE_DWORD for details on the offset input\n        S_BUFFER_STORE_DWORDX4     ,//: Write four Dwords to scalar data cache. See S_STORE_DWORD for details on the offset input.\n        S_DCACHE_WB                ,//: Write back dirty data in the scalar data cache.\n        S_DCACHE_WB_VOL            ,//: Write back dirty data in the scalar data cache volatile lines.\n        S_MEMREALTIME              ,//: Return current 64-bit RTC.\n        S_ATC_PROBE                ,//: Probe or prefetch an address into the SQC data cache.\n        S_ATC_PROBE_BUFFER         ,//: Probe or prefetch an address into the SQC data cache.\n       \n\n    };\n\n\n    enum VectorInstructions\n    {\n        V_INVALID = 0xffffffff,\n\n        /////////////////////////////////////////\n        // VOP2, or VOP3a\n        /////////////////////////////////////////\n  \n        V_CNDMASK_B32              ,  //: D.u = VCC[i] ? S1.u : S0.u (i = threadID in wave).\n        V_READLANE_B32             ,  //: copy one VGPR value to one SGPR. Dst = SGPR-dest,\n                                      //     Src0 = Source Data (VGPR# or M0(lds-direct)), Src1 = Lane Select (SGPR\n                                      //     or M0). Ignores exec mask.\n        V_WRITELANE_B32            ,  //: Write value into one VGPR one one lane. Dst = VGPRdest,\n                                      //  Src0 = Source Data (sgpr, m0, exec or constants), Src1 = Lane Select\n                                      // (SGPR or M0). Ignores exec mask.\n        V_ADD_F32                  ,  //: D.f = S0.f + S1.f.\n        V_SUB_F32                  ,  //: D.f = S0.f - S1.f.\n        V_SUBREV_F32               ,  //: D.f = S1.f - S0.f.\n        V_MAC_LEGACY_F32           ,  //: D.f = S0.F * S1.f + D.f.\n        V_MUL_LEGACY_F32           ,  //: D.f = S0.f * S1.f (DX9 rules, 0.0*x = 0.0).\n        V_MUL_F32                  ,  //: D.f = S0.f * S1.f.\n        V_MUL_I32_I24              ,  //: D.i = S0.i[23:0] * S1.i[23:0].\n        V_MUL_HI_I32_I24           ,  //: D.i = (S0.i[23:0] * S1.i[23:0])>>32.\n        V_MUL_U32_U24              ,  //: D.u = S0.u[23:0] * S1.u[23:0].\n        V_MUL_HI_U32_U24           ,  //: D.i = (S0.u[23:0] * S1.u[23:0])>>32.\n        V_MIN_LEGACY_F32           ,  //: D.f = min(S0.f, S1.f) (DX9 rules for NaN).\n        V_MAX_LEGACY_F32           ,  //: D.f = max(S0.f, S1.f) (DX9 rules for NaN).\n        V_MIN_F32                  ,  //: D.f = min(S0.f, S1.f).\n        V_MAX_F32                  ,  //: D.f = max(S0.f, S1.f).\n        V_MIN_I32                  ,  //: D.i = min(S0.i, S1.i).\n        V_MAX_I32                  ,  //: D.i = max(S0.i, S1.i).\n        V_MIN_U32                  ,  //: D.u = min(S0.u, S1.u).\n        V_MAX_U32                  ,  //: D.u = max(S0.u, S1.u).\n        V_LSHR_B32                 ,  //: D.u = S0.u >> S1.u[4:0].\n        V_LSHRREV_B32              ,  //: D.u = S1.u >> S0.u[4:0].\n        V_ASHR_I32                 ,  //: D.i = S0.i >> S1.i[4:0].\n        V_ASHRREV_I32              ,  //: D.i = S1.i >> S0.i[4:0].\n        V_LSHL_B32                 ,  //: D.u = S0.u << S1.u[4:0].\n        V_LSHLREV_B32              ,  //: D.u = S1.u << S0.u[4:0].\n        V_AND_B32                  ,  //: D.u = S0.u & S1.u.\n        V_OR_B32                   ,  //: D.u = S0.u | S1.u.\n        V_XOR_B32                  ,  //: D.u = S0.u ^ S1.u.\n        V_BFM_B32                  ,  //: D.u = ((1<<S0.u[4:0])-1) << S1.u[4:0]; S0=bitfield_width,S1=bitfield_offset.\n        V_MAC_F32                  ,  //: D.f = S0.f * S1.f + D.f.\n        V_MADMK_F32                ,  //: D.f = S0.f * K + S1.f; K is a 32-bit inline constant.\n        V_MADAK_F32                ,  //: D.f = S0.f * S1.f + K; K is a 32-bit inline constant.\n        V_BCNT_U32_B32             ,  //: D.u = CountOneBits(S0.u) + S1.u. Bit count.\n        V_MBCNT_LO_U32_B32         ,  //: ThreadMask = (1 << ThreadPosition) - 1; \n                                      //    D.u = CountOneBits(S0.u & ThreadMask[31:0]) + S1.u. Masked bit count, ThreadPosition\n                                      //    is the position of this thread in the wavefront (in 0 63).\n        V_MBCNT_HI_U32_B32         ,  //: ThreadMask = (1 << ThreadPosition) - 1; \n                                      //    D.u = CountOneBits(S0.u & ThreadMask[63:32]) + S1.u. Masked bit count,\n                                      //   ThreadPosition is the position of this thread in the wavefront (in 0..63).\n                                   \n        V_ADD_I32                  , // : D.u = S0.u + S1.u; VCC=carry-out (VOP3:sgpr=carry-out).\n        V_SUB_I32                  , // : D.u = S0.u - S1.u; VCC=carry-out (VOP3:sgpr=carry-out).\n        V_SUBREV_I32               , // : D.u = S1.u - S0.u; VCC=carry-out (VOP3:sgpr=carry-out).\n        V_ADDC_U32                 , // : D.u = S0.u + S1.u + VCC; VCC=carry-out (VOP3:sgpr=carryout, S2.u=carry-in).\n        V_SUBB_U32                 , // : D.u = S0.u - S1.u - VCC; VCC=carry-out (VOP3:sgpr=carry-out,S2.u=carry-in).\n        V_SUBBREV_U32              , // : D.u = S1.u - S0.u - VCC; VCC=carry-out (VOP3:sgpr=carryout,S2.u=carry-in).\n        V_LDEXP_F32                , // : D.d = pow(S0.f, S1.i).\n        V_CVT_PKACCUM_U8_F32       , // : f32->u8(s0.f), pack into byte(s1.u), of dst.\n        V_CVT_PKNORM_I16_F32       , // : D = {(snorm)S1.f, (snorm)S0.f}.\n        V_CVT_PKNORM_U16_F32       , // : D = {(unorm)S1.f, (unorm)S0.f}.\n        V_CVT_PKRTZ_F16_F32        , // : D = {flt32_to_flt16(S1.f),flt32_to_flt16(S0.f)}, with round-toward-zero.\n        V_CVT_PK_U16_U32           , // : D = {(u32->u16)S1.u, (u32->u16)S0.u}.\n        V_CVT_PK_I16_I32           , // : D = {(i32->i16)S1.i, (i32->i16)S0.i}.\n        \n\n        // Volcanic islands\n        V_ADD_F16                  ,//     : D.f16 = S0.f16 + S1.f16. Supports denormals, round mode, exception flags, saturation.\n        V_SUB_F16                  ,//     : D.f16 = S0.f16 - S1.f16. Supports denormals, round mode, exception flags, saturation. SQ translates to V_ADD_F16.\n        V_SUBREV_F16               ,//     : D.f16 = S1.f16 - S0.f16. Supports denormals, round mode, exception flags, saturation. SQ translates to V_ADD_F16.\n        V_MUL_F16                  ,//     : D.f16 = S0.f16 * S1.f16. Supports denormals, round mode, exception flags, saturation.\n        V_MAC_F16                  ,//     : D.f16 = S0.f16 * S1.f16 + D.f16. Supports round mode, exception flags, saturation. SQ translates this to V_MAD_F16.\n        V_MADMK_F16                ,//     : D.f16 = S0.f16 * K.f16 + S1.f16; K is a 16-bit inline constant stored in the following literal Dword. This opcode cannot use the VOP3 encoding and cannot use input/output modifiers. Supports round mode, exception flags, saturation. SQ translates this to V_MAD_F16.\n        V_MADAK_F16                ,//     : D.f16 = S0.f16 * S1.f16 + K.f16; K is a 16-bit inline constant stored in the following literal Dword. This opcode cannot use the VOP3 encoding and cannot use input/output modifiers. Supports round mode, exception flags, saturation. SQ translates this to V_MAD_F16.\n        V_ADD_U16                  ,//     : D.u16 = S0.u16 + S1.u16. Supports saturation (unsigned 16-bit integer domain).\n        V_SUB_U16                  ,//     : D.u16 = S0.u16 - S1.u16. Supports saturation (unsigned 16-bit integer domain).\n        V_SUBREV_U16               ,//     : D.u16 = S1.u16 - S0.u16. Supports saturation (unsigned 16-bit integer domain). SQ translates this to V_SUB_U16 with reversed operands.\n        V_MUL_LO_U16               ,//     : D.u16 = S0.u16 * S1.u16. Supports saturation (unsigned 16-bit integer domain).\n        V_LSHLREV_B16              ,//     : D.u[15:0] = S1.u[15:0] << S0.u[3:0]. SQ translates this to an internal SP opcode.\n        V_LSHRREV_B16              ,//     : D.u[15:0] = S1.u[15:0] >> S0.u[3:0]. The vacated bits are set to zero. SQ translates this to an internal SP opcode.\n        V_ASHRREV_I16              ,//     : D.i[15:0] = signext(S1.i[15:0]) >> S0.i[3:0]. The vacated bits are set to the sign bit of the input value. SQ translates this to an internal SP opcode.\n        V_MAX_F16                  ,//     : D.f16 = max(S0.f16, S1.f16). IEEE compliant. Supports denormals, round mode, exception flags, saturation.\n        V_MIN_F16                  ,//     : D.f16 = min(S0.f16, S1.f16). IEEE compliant. Supports denormals, round mode, exception flags, saturation.\n        V_MAX_U16                  ,//     : D.u[15:0] = max(S0.u[15:0], S1.u[15:0]).\n        V_MAX_I16                  ,//     : D.i[15:0] = max(S0.i[15:0], S1.i[15:0]).\n        V_MIN_U16                  ,//     : D.u[15:0] = min(S0.u[15:0], S1.u[15:0]).\n        V_MIN_I16                  ,//     : D.i[15:0] = min(S0.i[15:0], S1.i[15:0]).\n        V_LDEXP_F16                ,//     : D.f16 = S0.f16 * (2 ** S1.i16).\n        \n\n\n        \n        /////////////////////////////////////////\n        // VOP1, or VOP3a\n        /////////////////////////////////////////\n        V_NOP                     ,     //: do nothing.\n        V_MOV_B32                 ,     //: D.u = S0.u.\n        V_READFIRSTLANE_B32       ,     //: copy one VGPR value to one SGPR. Dst = SGPRdest,\n                                        //         Src0 = Source Data (VGPR# or M0(lds-direct)), Lane# =\n                                        //         FindFirst1fromLSB(exec) (lane = 0 if exec is zero). Ignores exec mask.\n        V_CVT_I32_F64             ,     //: D.i = (int)S0.d.\n        V_CVT_F64_I32             ,     //: D.f = (float)S0.i.\n        V_CVT_F32_I32             ,     //: D.f = (float)S0.i.\n        V_CVT_F32_U32             ,     //: D.f = (float)S0.u.\n        V_CVT_U32_F32             ,     //: D.u = (unsigned)S0.f.\n        V_CVT_I32_F32             ,     //: D.i = (int)S0.f.\n        V_MOV_FED_B32             ,     //: D.u = S0.u, introduce edc double error upon write to dest vgpr without causing an exception.\n        V_CVT_F16_F32             ,    //: D.f16 = flt32_to_flt16(S0.f).\n        V_CVT_F32_F16             ,    //: D.f = flt16_to_flt32(S0.f16).\n        V_CVT_RPI_I32_F32         ,    //: D.i = (int)floor(S0.f + 0.5).\n        V_CVT_FLR_I32_F32         ,    //: D.i = (int)floor(S0.f).\n        V_CVT_OFF_F32_I4          ,    //: 4-bit signed int to 32-bit float. For interpolation in shader.\n        V_CVT_F32_F64             ,    //: D.f = (float)S0.d.\n        V_CVT_F64_F32             ,    //: D.d = (double)S0.f.\n        V_CVT_F32_UBYTE0          ,    //: D.f = UINT2FLT(S0.u[7:0]).\n        V_CVT_F32_UBYTE1          ,    //: D.f = UINT2FLT(S0.u[15:8]).\n        V_CVT_F32_UBYTE2          ,    //: D.f = UINT2FLT(S0.u[23:16]).\n        V_CVT_F32_UBYTE3          ,    //: D.f = UINT2FLT(S0.u[31:24]).\n        V_CVT_U32_F64             ,    //: D.u = (uint)S0.d.\n        V_CVT_F64_U32             ,    //: D.d = (double)S0.u.\n        // 23-26 Sea islands only\n        V_TRUNC_F64                , //: D.d = trunc(S0.d), return integer part of S0.d.\n        V_CEIL_F64                 , //: D.d = trunc(S0.d); if (S0.d > 0.0 && S0.d != D.d), D.d += 1.0.\n        V_RNDNE_F64                , //: D.d = round_nearest_even(S0.d).\n        V_FLOOR_F64                , //: D.d = trunc(S0.d); if (S0.d < 0.0 && S0.d != D.d), D.d += -1.0.\n        //    27  31 reserved.\n        V_FRACT_F32               ,    //: D.f = S0.f - floor(S0.f).\n        V_TRUNC_F32               ,    //: D.f = trunc(S0.f), return integer part of S0.\n        V_CEIL_F32                ,    //: D.f = ceil(S0.f). Implemented as: D.f = trunc(S0.f);  if (S0 > 0.0 && S0 != D), D += 1.0.\n        V_RNDNE_F32               ,    //: D.f = round_nearest_even(S0.f).\n        V_FLOOR_F32               ,    //: D.f = trunc(S0); if ((S0 < 0.0) && (S0 != D)) D += -1.0.\n        V_EXP_F32                 ,    //: D.f = pow(2.0, S0.f).\n        V_LOG_CLAMP_F32           ,    //: D.f = log2(S0.f), clamp -infinity to -max_float.\n        V_LOG_F32                 ,    //: D.f = log2(S0.f).\n        V_RCP_CLAMP_F32           ,    //: D.f = 1.0 / S0.f, result clamped to +-max_float.\n        V_RCP_LEGACY_F32          ,    //: D.f = 1.0 / S0.f, +-infinity result clamped to +-0.0.\n        V_RCP_F32                 ,    //: D.f = 1.0 / S0.f.\n        V_RCP_IFLAG_F32           ,    //: D.f = 1.0 / S0.f, only integer div_by_zero flag can be raised.\n        V_RSQ_CLAMP_F32           ,    //: D.f = 1.0 / sqrt(S0.f), result clamped to +-max_float.\n        V_RSQ_LEGACY_F32          ,    //: D.f = 1.0 / sqrt(S0.f).\n        V_RSQ_F32                 ,    //: D.f = 1.0 / sqrt(S0.f).\n        V_RCP_F64                 ,    //: D.d = 1.0 / (S0.d).\n        V_RCP_CLAMP_F64           ,    //: D.f = 1.0 / (S0.f), result clamped to +-max_float.\n        V_RSQ_F64                 ,    //: D.f = 1.0 / sqrt(S0.f).\n        V_RSQ_CLAMP_F64           ,    //: D.d = 1.0 / sqrt(S0.d), result clamped to +-max_float.\n        V_SQRT_F32                ,    //: D.f = sqrt(S0.f).\n        V_SQRT_F64                ,    //: D.d = sqrt(S0.d).\n        V_SIN_F32                 ,    //: D.f = sin(S0.f).\n        V_COS_F32                 ,    //: D.f = cos(S0.f).\n        V_NOT_B32                 ,    //: D.u = ~S0.u.\n        V_BFREV_B32               ,    //: D.u[31:0] = S0.u[0:31], bitfield reverse.\n        V_FFBH_U32                ,    //: D.u = position of first 1 in S0 from MSB; D=0xFFFFFFFF if S0==0.\n        V_FFBL_B32                ,    //: D.u = position of first 1 in S0 from LSB; D=0xFFFFFFFF if S0==0.\n        V_FFBH_I32                ,    //: D.u = position of first bit different from sign bit in S0 from MSB;D=0xFFFFFFFF if S0==0 or 0xFFFFFFFF.\n        V_FREXP_EXP_I32_F64       ,    //: See V_FREXP_EXP_I32_F32.\n        V_FREXP_MANT_F64          ,    //: See V_FREXP_MANT_F32.\n        V_FRACT_F64               ,    //: S0.d - floor(S0.d).\n        V_FREXP_EXP_I32_F32       ,    //: If (S0.f == INF || S0.f == NAN), then D.i = 0; else D.i\n                                        //    = TwosComplement(Exponent(S0.f) - 127 + 1). Returns exponent of single\n                                        //    precision float input, such that S0.f = significand * (2 ** exponent). See also\n                                        //    FREXP_MANT_F32, which returns the significand.\n        V_FREXP_MANT_F32          ,    //: if (S0.f == INF || S0.f == NAN) then D.f = S0.f; else D.f =\n                                          // Mantissa(S0.f). Result range is in (-1.0,-0.5][0.5,1.0) in normal cases.\n                                          // Returns binary significand of single precision float input, such that S0.f = significand\n                                          // * (2 ** exponent). See also FREXP_EXP_I32_F32, which returns integer\n                                          // exponent.\n        V_CLREXCP                 ,    //: Clear wave's exception state in SIMD(SP).\n        V_MOVRELD_B32             ,    //: VGPR[D.u + M0.u] = VGPR[S0.u].\n        V_MOVRELS_B32             ,    //: VGPR[D.u] = VGPR[S0.u + M0.u].\n        V_MOVRELSD_B32            ,    //: VGPR[D.u + M0.u] = VGPR[S0.u + M0.u].\n        // Sea Islands only..\n        V_LOG_LEGACY_F32          ,    //: D.f = log2(S0.f). Base 2 logarithm. Same as Southern Islands. (CI Doc says \"..same as Sea Islands\" typo?)\n        V_EXP_LEGACY_F32          ,    //: D.f = pow(2.0, S0.f). Same as Southern Islands.\n\n\n        // VI+\n        V_CVT_F16_U16             ,// : D.f16 = uint16_to_flt16(S.u16). Supports denormals, rounding, exception flags and saturation.\n        V_CVT_F16_I16             ,// : D.f16 = int16_to_flt16(S.i16). Supports denormals, rounding, exception flags and saturation.\n        V_CVT_U16_F16             ,// : D.u16 = flt16_to_uint16(S.f16). Supports rounding, exception flags and saturation.\n        V_CVT_I16_F16             ,// : D.i16 = flt16_to_int16(S.f16). Supports rounding, exception flags and saturation.\n        V_RCP_F16                 ,// : if(S0.f16 == 1.0f), D.f16 = 1.0f; else D.f16 = ApproximateRecip(S0.f16).\n        V_SQRT_F16                ,// : if(S0.f16 == 1.0f)\\tD.f16 = 1.0f; else D.f16 = ApproximateSqrt(S0.f16).\n        V_RSQ_F16                 ,// : if(S0.f16 == 1.0f) D.f16 = 1.0f; else D.f16 = ApproximateRecipSqrt(S0.f16).\n        V_LOG_F16                 ,// : if(S0.f16 == 1.0f) D.f16 = 0.0f; else D.f16 = ApproximateLog2(S0.f16).\n        V_EXP_F16                 ,// : if(S0.f16 == 0.0f) D.f16 = 1.0f; else D.f16 = Approximate2ToX(S0.f16).\n        V_FREXP_MANT_F16          ,// : if(S0.f16 == +-INF || S0.f16 == NAN) D.f16 = S0.f16; else D.f16 = mantissa(S0.f16). Result range is (-1.0,-0.5][0.5,1.0). C math library frexp function. Returns binary significand of half precision float input, such that the original single float = significand * (2 ** exponent).\n        V_FREXP_EXP_I16_F16       ,// : if(S0.f16 == +-INF || S0.f16 == NAN) D.i16 = 0; else D.i16 = 2s_complement(exponent(S0.f16) - 15 + 1). C math library frexp function. Returns exponent of half precision float input, such that the original single float = significand * (2 ** exponent).\n        V_FLOOR_F16               ,// : D.f16 = trunc(S0.f16); if(S0.f16 < 0.0f && S0.f16 != D.f16) then D.f16 -= 1.0f.\n        V_CEIL_F16                ,// : D.f16 = trunc(S0.f16); if(S0.f16 > 0.0f && S0.f16 != D.f16) then D.f16 += 1.0f.\n        V_TRUNC_F16               ,// : D.f16 = trunc(S0.f16).\\n\\nRound-to-zero semantics.\n        V_RNDNE_F16               ,// : D.f16 = FLOOR(S0.f16 + 0.5f); if(floor(S0.f16) is even && fract(S0.f16) == 0.5f) then D.f16 -= 1.0f. Round-to-nearest-even semantics.\n        V_FRACT_F16               ,// : D.f16 = S0.f16 + -floor(S0.f16).\n        V_SIN_F16                 ,// : D.f16 = sin(S0.f16 * 2 * PI).\n        V_COS_F16                 ,// : D.f16 = cos(S0.f16 * 2 * PI).\n\n\n        /////////////////////////////////////////\n        // VOPC, or VOP3a\n        /////////////////////////////////////////\n        \n        V_CMP_F_F32         , // D.u = 0    //   Signal on sNaN input only.\n        V_CMP_LT_F32        , // D.u = (S0 < S1)\n        V_CMP_EQ_F32        , // D.u = (S0 == S1)\n        V_CMP_LE_F32        , // D.u = (S0 <= S1)\n        V_CMP_GT_F32        , // D.u = (S0 > S1)\n        V_CMP_LG_F32        , // D.u = (S0 <> S1)\n        V_CMP_GE_F32        , // D.u = (S0 >= S1)\n        V_CMP_O_F32         , // D.u = (!isNaN(S0) && !isNaN(S1))\n        V_CMP_U_F32         , // D.u = (!isNaN(S0) || !isNaN(S1))\n        V_CMP_NGE_F32       , // D.u = !(S0 >= S1)\n        V_CMP_NLG_F32       , // D.u = !(S0 <> S1)\n        V_CMP_NGT_F32       , // D.u = !(S0 > S1)\n        V_CMP_NLE_F32       , // D.u = !(S0 <= S1)\n        V_CMP_NEQ_F32       , // D.u = !(S0 == S1)\n        V_CMP_NLT_F32       , // D.u = !(S0 < S1)\n        V_CMP_TRU_F32       , // D.u = 1\n        V_CMPX_F_F32        , //   Signal on sNaN input only. Also write EXEC.\n        V_CMPX_LT_F32       ,  // D.u = (S0 < S1)            \n        V_CMPX_EQ_F32       ,  // D.u = (S0 == S1) \n        V_CMPX_LE_F32       ,  // D.u = (S0 <= S1) \n        V_CMPX_GT_F32       ,  // D.u = (S0 > S1) \n        V_CMPX_LG_F32       ,  // D.u = (S0 <> S1) \n        V_CMPX_GE_F32       ,  // D.u = (S0 >= S1) \n        V_CMPX_O_F32        ,  // D.u = (!isNaN(S0) && !isNaN(S1))  \n        V_CMPX_U_F32        ,  // D.u = (!isNaN(S0) || !isNaN(S1))  \n        V_CMPX_NGE_F32      ,  // D.u = !(S0 >= S1)\n        V_CMPX_NLG_F32      ,  // D.u = !(S0 <> S1)\n        V_CMPX_NGT_F32      ,  // D.u = !(S0 > S1)\n        V_CMPX_NLE_F32      ,  // D.u = !(S0 <= S1)\n        V_CMPX_NEQ_F32      ,  // D.u = !(S0 == S1)\n        V_CMPX_NLT_F32      ,  // D.u = !(S0 < S1)\n        V_CMPX_TRU_F32      ,  // D.u = 1\n        V_CMP_F_F64         , //   Signal on sNaN input only.\n        V_CMP_LT_F64        ,   // D.u = (S0 < S1)\n        V_CMP_EQ_F64        ,   // D.u = (S0 == S1)\n        V_CMP_LE_F64        ,   // D.u = (S0 <= S1)\n        V_CMP_GT_F64        ,   // D.u = (S0 > S1)\n        V_CMP_LG_F64        ,   // D.u = (S0 <> S1)\n        V_CMP_GE_F64        ,   // D.u = (S0 >= S1)\n        V_CMP_O_F64         ,   // D.u = (!isNaN(S0) && !isNaN(S1)) \n        V_CMP_U_F64         ,   // D.u = (!isNaN(S0) || !isNaN(S1)) \n        V_CMP_NGE_F64       ,   // D.u = !(S0 >= S1)\n        V_CMP_NLG_F64       ,   // D.u = !(S0 <> S1)\n        V_CMP_NGT_F64       ,   // D.u = !(S0 > S1)\n        V_CMP_NLE_F64       ,   // D.u = !(S0 <= S1)\n        V_CMP_NEQ_F64       ,   // D.u = !(S0 == S1)\n        V_CMP_NLT_F64       ,   // D.u = !(S0 < S1)\n        V_CMP_TRU_F64       ,   // D.u = 1\n        V_CMPX_F_F64        ,  //   Signal on sNaN input only. Also write EXEC.\n        V_CMPX_LT_F64       ,   // D.u = (S0 < S1)\n        V_CMPX_EQ_F64       ,   // D.u = (S0 == S1)\n        V_CMPX_LE_F64       ,   // D.u = (S0 <= S1)\n        V_CMPX_GT_F64       ,   // D.u = (S0 > S1)\n        V_CMPX_LG_F64       ,   // D.u = (S0 <> S1)\n        V_CMPX_GE_F64       ,   // D.u = (S0 >= S1)\n        V_CMPX_O_F64        ,   // D.u = (!isNaN(S0) && !isNaN(S1)) \n        V_CMPX_U_F64        ,   // D.u = (!isNaN(S0) || !isNaN(S1)) \n        V_CMPX_NGE_F64      ,   // D.u = !(S0 >= S1)\n        V_CMPX_NLG_F64      ,   // D.u = !(S0 <> S1)\n        V_CMPX_NGT_F64      ,   // D.u = !(S0 > S1)\n        V_CMPX_NLE_F64      ,   // D.u = !(S0 <= S1)\n        V_CMPX_NEQ_F64      ,   // D.u = !(S0 == S1)\n        V_CMPX_NLT_F64      ,   // D.u = !(S0 < S1)\n        V_CMPX_TRU_F64      ,   // D.u = 1\n        V_CMPS_F_F32        ,  //   Signal on any NaN.\n        V_CMPS_LT_F32       ,  // D.u = (S0 < S1)\n        V_CMPS_EQ_F32       ,  // D.u = (S0 == S1)\n        V_CMPS_LE_F32       ,  // D.u = (S0 <= S1)\n        V_CMPS_GT_F32       ,  // D.u = (S0 > S1)\n        V_CMPS_LG_F32       ,  // D.u = (S0 <> S1)\n        V_CMPS_GE_F32       ,  // D.u = (S0 >= S1)\n        V_CMPS_O_F32        ,  // D.u = (!isNaN(S0) && !isNaN(S1)) \n        V_CMPS_U_F32        ,  // D.u = (!isNaN(S0) || !isNaN(S1)) \n        V_CMPS_NGE_F32      ,  // D.u = !(S0 >= S1)\n        V_CMPS_NLG_F32      ,  // D.u = !(S0 <> S1)\n        V_CMPS_NGT_F32      ,  // D.u = !(S0 > S1)\n        V_CMPS_NLE_F32      ,  // D.u = !(S0 <= S1)\n        V_CMPS_NEQ_F32      ,  // D.u = !(S0 == S1)\n        V_CMPS_NLT_F32      ,  // D.u = !(S0 < S1)\n        V_CMPS_TRU_F32      ,  // D.u = 1\n        V_CMPSX_F_F32       , //   Signal on any NaN. Also write EXEC.\n        V_CMPSX_LT_F32      ,  // D.u = (S0 < S1)\n        V_CMPSX_EQ_F32      ,  // D.u = (S0 == S1)\n        V_CMPSX_LE_F32      ,  // D.u = (S0 <= S1)\n        V_CMPSX_GT_F32      ,  // D.u = (S0 > S1)\n        V_CMPSX_LG_F32      ,  // D.u = (S0 <> S1)\n        V_CMPSX_GE_F32      ,  // D.u = (S0 >= S1)\n        V_CMPSX_O_F32       ,  // D.u = (!isNaN(S0) && !isNaN(S1)) \n        V_CMPSX_U_F32       ,  // D.u = (!isNaN(S0) || !isNaN(S1)) \n        V_CMPSX_NGE_F32     ,  // D.u = !(S0 >= S1)\n        V_CMPSX_NLG_F32     ,  // D.u = !(S0 <> S1)\n        V_CMPSX_NGT_F32     ,  // D.u = !(S0 > S1)\n        V_CMPSX_NLE_F32     ,  // D.u = !(S0 <= S1)\n        V_CMPSX_NEQ_F32     ,  // D.u = !(S0 == S1)\n        V_CMPSX_NLT_F32     ,  // D.u = !(S0 < S1)\n        V_CMPSX_TRU_F32     ,  // D.u = 1\n        V_CMPS_F_F64        ,  //   Signal on any NaN.\n        V_CMPS_LT_F64       ,   // D.u = (S0 < S1)\n        V_CMPS_EQ_F64       ,   // D.u = (S0 == S1)\n        V_CMPS_LE_F64       ,   // D.u = (S0 <= S1)\n        V_CMPS_GT_F64       ,   // D.u = (S0 > S1)\n        V_CMPS_LG_F64       ,   // D.u = (S0 <> S1)\n        V_CMPS_GE_F64       ,   // D.u = (S0 >= S1)\n        V_CMPS_O_F64        ,   // D.u = (!isNaN(S0) && !isNaN(S1)) \n        V_CMPS_U_F64        ,   // D.u = (!isNaN(S0) || !isNaN(S1)) \n        V_CMPS_NGE_F64      ,   // D.u = !(S0 >= S1)\n        V_CMPS_NLG_F64      ,   // D.u = !(S0 <> S1)\n        V_CMPS_NGT_F64      ,   // D.u = !(S0 > S1)\n        V_CMPS_NLE_F64      ,   // D.u = !(S0 <= S1)\n        V_CMPS_NEQ_F64      ,   // D.u = !(S0 == S1)\n        V_CMPS_NLT_F64      ,   // D.u = !(S0 < S1)\n        V_CMPS_TRU_F64      ,   // D.u = 1\n        V_CMPSX_F_F64       ,   //   Signal on any NaN. Also write EXEC.\n        V_CMPSX_LT_F64      ,   // D.u = (S0 < S1)\n        V_CMPSX_EQ_F64      ,   // D.u = (S0 == S1)\n        V_CMPSX_LE_F64      ,   // D.u = (S0 <= S1)\n        V_CMPSX_GT_F64      ,   // D.u = (S0 > S1)\n        V_CMPSX_LG_F64      ,   // D.u = (S0 <> S1)\n        V_CMPSX_GE_F64      ,   // D.u = (S0 >= S1)\n        V_CMPSX_O_F64       ,   // D.u = (!isNaN(S0) && !isNaN(S1)) \n        V_CMPSX_U_F64       ,   // D.u = (!isNaN(S0) || !isNaN(S1)) \n        V_CMPSX_NGE_F64     ,   // D.u = !(S0 >= S1)\n        V_CMPSX_NLG_F64     ,   // D.u = !(S0 <> S1)\n        V_CMPSX_NGT_F64     ,   // D.u = !(S0 > S1)\n        V_CMPSX_NLE_F64     ,   // D.u = !(S0 <= S1)\n        V_CMPSX_NEQ_F64     ,   // D.u = !(S0 == S1)\n        V_CMPSX_NLT_F64     ,   // D.u = !(S0 < S1)\n        V_CMPSX_TRU_F64     ,   // D.u = 1\n        V_CMP_F_I32         ,  //D.u = 0  , //   On 32-bit integers.\n        V_CMP_LT_I32        , //D.u = (S0 < S1)\n        V_CMP_EQ_I32        , //D.u = (S0 == S1)\n        V_CMP_LE_I32        , //D.u = (S0 <= S1)\n        V_CMP_GT_I32        , //D.u = (S0 > S1)\n        V_CMP_LG_I32        , //D.u = (S0 <> S1)\n        V_CMP_GE_I32        , //D.u = (S0 >= S1)\n        V_CMP_TRU_I32       , //D.u = 1\n        V_CMPX_F_I32        , //   Also write EXEC.\n        V_CMPX_LT_I32       ,//D.u = (S0 < S1)\n        V_CMPX_EQ_I32       ,//D.u = (S0 == S1)\n        V_CMPX_LE_I32       ,//D.u = (S0 <= S1)\n        V_CMPX_GT_I32       ,//D.u = (S0 > S1)\n        V_CMPX_LG_I32       ,//D.u = (S0 <> S1)\n        V_CMPX_GE_I32       ,//D.u = (S0 >= S1)\n        V_CMPX_TRU_I32      ,//D.u = 1\n        V_CMP_F_I64         , //    On 64-bit integers.\n        V_CMP_LT_I64        ,//D.u = (S0 < S1)\n        V_CMP_EQ_I64        ,//D.u = (S0 == S1)\n        V_CMP_LE_I64        ,//D.u = (S0 <= S1)\n        V_CMP_GT_I64        ,//D.u = (S0 > S1)\n        V_CMP_LG_I64        ,//D.u = (S0 <> S1)\n        V_CMP_GE_I64        ,//D.u = (S0 >= S1)\n        V_CMP_TRU_I64       ,//D.u = 1\n        V_CMPX_F_I64        , //    Also write EXEC.\n        V_CMPX_LT_I64       ,//D.u = (S0 < S1)\n        V_CMPX_EQ_I64       ,//D.u = (S0 == S1)\n        V_CMPX_LE_I64       ,//D.u = (S0 <= S1)\n        V_CMPX_GT_I64       ,//D.u = (S0 > S1)\n        V_CMPX_LG_I64       ,//D.u = (S0 <> S1)\n        V_CMPX_GE_I64       ,//D.u = (S0 >= S1)\n        V_CMPX_TRU_I64      ,//D.u = 1\n        V_CMP_F_U32         , //    On unsigned 32-bit integers.\n        V_CMP_LT_U32        ,//D.u = (S0 < S1)\n        V_CMP_EQ_U32        ,//D.u = (S0 == S1)\n        V_CMP_LE_U32        ,//D.u = (S0 <= S1)\n        V_CMP_GT_U32        ,//D.u = (S0 > S1)\n        V_CMP_LG_U32        ,//D.u = (S0 <> S1)\n        V_CMP_GE_U32        ,//D.u = (S0 >= S1)\n        V_CMP_TRU_U32       ,//D.u = 1\n        V_CMPX_F_U32        , //    Also write EXEC.\n        V_CMPX_LT_U32       ,//D.u = (S0 < S1)\n        V_CMPX_EQ_U32       ,//D.u = (S0 == S1)\n        V_CMPX_LE_U32       ,//D.u = (S0 <= S1)\n        V_CMPX_GT_U32       ,//D.u = (S0 > S1)\n        V_CMPX_LG_U32       ,//D.u = (S0 <> S1)\n        V_CMPX_GE_U32       ,//D.u = (S0 >= S1)\n        V_CMPX_TRU_U32      ,//D.u = 1\n        V_CMP_F_U64         , //    On unsigned 64-bit integers.\n        V_CMP_LT_U64        ,//D.u = (S0 < S1)\n        V_CMP_EQ_U64        ,//D.u = (S0 == S1)\n        V_CMP_LE_U64        ,//D.u = (S0 <= S1)\n        V_CMP_GT_U64        ,//D.u = (S0 > S1)\n        V_CMP_LG_U64        ,//D.u = (S0 <> S1)\n        V_CMP_GE_U64        ,//D.u = (S0 >= S1)\n        V_CMP_TRU_U64       ,//D.u = 1\n        V_CMPx_F_U64        , //    Also write EXEC.\n        V_CMPx_LT_U64       ,//D.u = (S0 < S1)\n        V_CMPx_EQ_U64       ,//D.u = (S0 == S1)\n        V_CMPx_LE_U64       ,//D.u = (S0 <= S1)\n        V_CMPx_GT_U64       ,//D.u = (S0 > S1)\n        V_CMPx_LG_U64       ,//D.u = (S0 <> S1)\n        V_CMPx_GE_U64       ,//D.u = (S0 >= S1)\n        V_CMPx_TRU_U64      ,//D.u = 1\n        V_CMP_CLASS_F32     , //  D = IEEE numeric class function specified in S1.u, performed on S0.f.\n        V_CMPX_CLASS_F32    , //  D = IEEE numeric class function specified in S1.u, performed on S0.f. Also write EXEC.\n        V_CMP_CLASS_F64     , //  D = IEEE numeric class function specified in S1.u, performed on S0.d.\n        V_CMPX_CLASS_F64    , //  D = IEEE numeric class function specified inS1.u, performed on S0.d. Also write EXEC.\n        \n        // VI only\n        V_CMP_F_F16          , \n        V_CMP_LT_F16         ,\n        V_CMP_EQ_F16         ,\n        V_CMP_LE_F16         ,\n        V_CMP_GT_F16         ,\n        V_CMP_LG_F16         ,\n        V_CMP_GE_F16         ,\n        V_CMP_O_F16          ,\n        V_CMP_U_F16          ,\n        V_CMP_NGE_F16        ,\n        V_CMP_NLG_F16        ,\n        V_CMP_NGT_F16        ,\n        V_CMP_NLE_F16        ,\n        V_CMP_NEQ_F16        ,\n        V_CMP_NLT_F16        ,\n        V_CMP_TRU_F16        ,\n        V_CMPX_F_F16         ,\n        V_CMPX_LT_F16        ,\n        V_CMPX_EQ_F16        ,\n        V_CMPX_LE_F16        ,\n        V_CMPX_GT_F16        ,\n        V_CMPX_LG_F16        ,\n        V_CMPX_GE_F16        ,\n        V_CMPX_O_F16         ,\n        V_CMPX_U_F16         ,\n        V_CMPX_NGE_F16       ,\n        V_CMPX_NLG_F16       ,\n        V_CMPX_NGT_F16       ,\n        V_CMPX_NLE_F16       ,\n        V_CMPX_NEQ_F16       ,\n        V_CMPX_NLT_F16       ,\n        V_CMPX_TRU_F16       ,\n        V_CMP_F_U16         , \n        V_CMP_LT_U16        ,\n        V_CMP_EQ_U16        ,\n        V_CMP_LE_U16        ,\n        V_CMP_GT_U16        ,\n        V_CMP_LG_U16        ,\n        V_CMP_GE_U16        ,\n        V_CMP_TRU_U16       ,\n        V_CMPx_F_U16        ,\n        V_CMPx_LT_U16       ,\n        V_CMPx_EQ_U16       ,\n        V_CMPx_LE_U16       ,\n        V_CMPx_GT_U16       ,\n        V_CMPx_LG_U16       ,\n        V_CMPx_GE_U16       ,\n        V_CMPx_TRU_U16      ,\n        V_CMP_F_I16        ,\n        V_CMP_LT_I16       ,\n        V_CMP_EQ_I16       ,\n        V_CMP_LE_I16       ,\n        V_CMP_GT_I16       ,\n        V_CMP_LG_I16       ,\n        V_CMP_GE_I16       ,\n        V_CMP_TRU_I16      ,\n        V_CMPx_F_I16       ,\n        V_CMPx_LT_I16      ,\n        V_CMPx_EQ_I16      ,\n        V_CMPx_LE_I16      ,\n        V_CMPx_GT_I16      ,\n        V_CMPx_LG_I16      ,\n        V_CMPx_GE_I16      ,\n        V_CMPx_TRU_I16     ,\n        V_CMP_CLASS_F16,\n        V_CMPX_CLASS_F16,\n\n                                 \n        //////////////////////////////////////////////////////\n        //  VOP3b\n        //////////////////////////////////////////////////////\n        V_DIV_SCALE_F32       ,  //  = D.f = Special case divide preop and flags(s0.f = Quotient,s1.f = Denominator, s2.f = Numerator) s0 must equal s1 or s2.\n        V_DIV_SCALE_F64       ,  //  = D.d = Special case divide preop and flags(s0.d = Quotient,s1.d = Denominator, s2.d = Numerator) s0 must equal s1 or s2.\n        \n        //////////////////////////////////////////////////////\n        //  VOP3a \n        //////////////////////////////////////////////////////\n        V_MAD_LEGACY_F32   ,   //   = D.f = S0.f * S1.f + S2.f (DX9 rules, 0.0*x = 0.0).\n        V_MAD_F32          ,   //   = D.f = S0.f * S1.f + S2.f.\n        V_MAD_I32_I24      ,   //   = D.i = S0.i * S1.i + S2.iD.i = S0.i * S1.i + S2.i.\n        V_MAD_U32_U24      ,   //   = D.u = S0.u * S1.u + S2.u.\n        V_CUBEID_F32       ,   //   = Rm.w <- Rn,x, Rn,y, Rn.z.\n        V_CUBESC_F32       ,   //   = Rm.y <- Rn,x, Rn,y, Rn.z.\n        V_CUBETC_F32       ,   //   = Rm.x <- Rn,x, Rn,y, Rn.z.\n        V_CUBEMA_F32       ,   //   = Rm.z <- Rn,x, Rn,y, Rn.z\n        V_BFE_U32          ,   //   = D.u = (S0.u>>S1.u[4:0]) & ((1<<S2.u[4:0])-1); bitfield extract,S0=data, S1=field_offset, S2=field_width.\n        V_BFE_I32          ,   //   = D.i = (S0.i>>S1.u[4:0]) & ((1<<S2.u[4:0])-1); bitfield extract, S0=data, S1=field_offset, S2=field_width.\n        V_BFI_B32          ,   //   = D.u = (S0.u & S1.u) | (~S0.u & S2.u); bitfield insert.\n        V_FMA_F32          ,   //   = D.f = S0.f * S1.f + S2.f\n        V_FMA_F64          ,   //   = D.d = S0.d * S1.d + S2.d.\n                              //\n        V_LERP_U8          ,   //  = D.u = ((S0.u[31:24] + S1.u[31:24] + S2.u[24]) >> 1) << 24 +\n                                     //       S1.u[15:8] + S2.u[8]) >> 1) << 8 + ((S0.u[7:0] + S1.u[7:0] + S2.u[0]) >> 1).\n                                     //       Unsigned eight-bit pixel average on packed unsigned bytes (linear interpolation).\n                                     //       S2 acts as a round mode; if set, 0.5 rounds up; otherwise, 0.5 truncates.\n        V_ALIGNBIT_B32     ,   //  = D.u = ({S0,S1} >> S2.u[4:0]) & 0xFFFFFFFF.\n        V_ALIGNBYTE_B32    ,   //  = D.u = ({S0,S1} >> (8*S2.u[4:0])) & 0xFFFFFFFF.\n        V_MULLIT_F32       ,   //  = D.f = S0.f * S1.f, replicate result into 4 components (0.0 * x = 0.0; special INF, NaN, overflow rules).\n        V_MIN3_F32         ,   //  = D.f = min(S0.f, S1.f, S2.f).\n        V_MIN3_I32         ,   //  = D.i = min(S0.i, S1.i, S2.i).\n        V_MIN3_U32         ,   //  = 0x153 D.u = min(S0.u, S1.u, S2.u).\n        V_MAX3_F32         ,   //  = D.f = max(S0.f, S1.f, S2.f).\n        V_MAX3_I32         ,   //  = D.i = max(S0.i, S1.i, S2.i).\n        V_MAX3_U32         ,   //  = D.u = max(S0.u, S1.u, S2.u).\n        V_MED3_F32         ,   //  = D.f = median(S0.f, S1.f, S2.f).\n        V_MED3_I32         ,   //  = D.i = median(S0.i, S1.i, S2.i).\n        V_MED3_U32         ,   //  = D.u = median(S0.u, S1.u, S2.u).\n        V_SAD_U8           ,   //  = D.u = Byte SAD with accum_lo(S0.u, S1.u, S2.u).\n        V_SAD_HI_U8        ,   //  = D.u = Byte SAD with accum_hi(S0.u, S1.u, S2.u).\n        V_SAD_U16          ,   //  = D.u = Word SAD with accum(S0.u, S1.u, S2.u).\n        V_SAD_U32          ,   //  = D.u = Dword SAD with accum(S0.u, S1.u, S2.u).\n        V_CVT_PK_U8_F32    ,   //  = f32->u8(s0.f), pack into byte(s1.u), of dword(s2).\n        V_DIV_FIXUP_F32    ,   //  = D.f = Special case divide fixup and flags(s0.f = Quotient,   s1.f = Denominator, s2.f = Numerator).\n        V_DIV_FIXUP_F64    ,   //  = D.d = Special case divide fixup and flags(s0.d = Quotient,  s1.d = Denominator, s2.d = Numerator).\n        V_LSHL_B64         ,   //  = D = S0.u << S1.u[4:0].\n        V_LSHR_B64         ,   //  = D = S0.u >> S1.u[4:0].\n        V_ASHR_I64         ,   //  = D = S0.u >> S1.u[4:0].\n        V_ADD_F64          ,   //  = D.d = S0.d + S1.d.\n        V_MUL_F64          ,   //  = D.d = S0.d * S1.d.\n        V_MIN_F64          ,   //  = D.d = min(S0.d, S1.d).\n        V_MAX_F64          ,   //  = D.d = max(S0.d, S1.d).\n        V_LDEXP_F64        ,   //  = D.d = pow(S0.d, S1.i[31:0]).\n        V_MUL_LO_U32       ,   //  = D.u = S0.u * S1.u.\n        V_MUL_HI_U32       ,   //  = D.u = (S0.u * S1.u)>>32.\n        V_MUL_LO_I32       ,   //  = D.i = S0.i * S1.i.\n        V_MUL_HI_I32       ,   //  = D.i = (S0.i * S1.i)>>32.\n\n        //365  366 See corresponding opcode numbers in VOP3 (3 in, 2 out), (VOP3b).\n\n        V_DIV_FMAS_F32    ,  // = D.f = Special case divide FMA with scale and flags(s0.f = Quotient, s1.f = Denominator, s2.f = Numerator).\n        V_DIV_FMAS_F64    ,  // = D.d = Special case divide FMA with scale and flags(s0.d= Quotient, s1.d = Denominator, s2.d = Numerator).\n        V_MSAD_U8         ,  // = D.u = Masked Byte SAD with accum_lo(S0.u, S1.u, S2.u).\n        \n        // Opcodes 370/371 were renamed between SI and CI.  Not sure if they behave differently or not\n        V_QSAD_U8         ,  // = D.u = Quad-Byte SAD with accum_lo/hiu(S0.u[63:0], S1.u[31:0], S2.u[63:0]).\n        V_MQSAD_U8        ,  // = D.u = Masked Quad-Byte SAD with accum_lo/hi(S0.u[63:0],S1.u[31:0], S2.u[63:0]).       \n        V_QSAD_PK_U16_U8  ,  // : D.u = Quad-Byte SAD with accum_lo/hiu(S0.u[63:0], S1.u[31:0], S2.u[63:0]).\n        V_MQSAD_PK_U16_U8 ,  // = D.u = Masked Quad-Byte SAD with accum_lo/hi(S0.u[63:0], S1.u[31:0], S2.u[63:0]).\n        //\n\n        V_TRIG_PREOP_F64  ,  // = D.d = Look Up 2/PI (S0.d) with segment select  S1.u[4:0].\n\n        // these 3 are Sea Islands only\n        V_MQSAD_U32_U8    ,   // : D.u128 = Masked Quad-Byte SAD with 32-bit accum_lo/hi(S0.u[63:0], S1.u[31:0], S2.u[127:0]).\n        V_MAD_U64_U32     ,   // : {vcc_out,D.u64} = S0.u32 * S1.u32 + S2.u64.\n        V_MAD_I64_I32     ,   // : {vcc_out,D.i64} = S0.i32 * S1.i32 + S2.i64.\n\n\n        // new opcodes for VI\n        V_MAD_F16     ,       //: D.f16 = S0.f16 * S1.f16 + S2.f16 Supports round mode, exception flags, saturation.\n        V_MAD_U16     ,       //: D.u16 = S0.u16 * S1.u16 + S2.u16. Supports saturation (unsigned 16-bit integer domain).\n        V_MAD_I16     ,       //: D.i16 = S0.i16 * S1.i16 + S2.i16. Supports saturation (signed 16-bit integer domain).\n        V_PERM_B32    ,       //: D.u[31:24] = permute({S0.u, S1.u}, S2.u[31:24]);\n                             //   D.u[23:16] = permute({S0.u, S1.u}, S2.u[23:16]);\n                             //   D.u[15:8] = permute({S0.u, S1.u}, S2.u[15:8]);\n                             //   D.u[7:0] = permute({S0.u, S1.u}, S2.u[7:0]);\n                             //   byte permute(byte in[8], byte sel) {\n                             //   if(sel>=13) then return 0xff;\n                             //   elsif(sel==12) then return 0x00;\n                             //   elsif(sel==11) then return in[7][7] * 0xff;\n                             //   elsif(sel==10) then return in[5][7] * 0xff;\n                             //   elsif(sel==9) then return in[3][7] * 0xff;\n                             //   elsif(sel==8) then return in[1][7] * 0xff;\n                             //   else return in[sel];\n                             //   }\n                             //   Byte permute.\n        V_FMA_F16        ,    //   : D.f16 = S0.f16 * S1.f16 + S2.f16.\\n\\nFused half precision multiply add.\n        V_DIV_FIXUP_F16  ,             \n        \n        V_ADD_U32,\n        V_SUB_U32,\n        V_SUBREV_U32,\n        V_LSHLREV_B64 ,\n        V_LSHRREV_B64 ,\n        V_ASHRREV_I64 ,\n        \n        //////////////////////////////////////////////////////\n        //  VINTERP (can be vop3 on GCN3)\n        //////////////////////////////////////////////////////\n\n        V_INTERP_P1_F32  , //  : D = P10 * S + P0; parameter interpolation.\n        V_INTERP_P2_F32  , //  : D = P20 * S + D; parameter interpolation.\n        V_INTERP_MOV_F32 , //  : D = {P10,P20,P0}[S]; parameter load.\n        \n        // New interps for VI, encoded as VOP3\n        V_INTERP_P1LL_F16,     // : D.f32 = P10.f16 * S0.f32 + P0.f16. 'LL' stands for 'two LDS arguments'. attr_word selects the high or low half 16 bits of each LDS dword accessed. This opcode is available for 32-bank LDS only. NOTE: In textual representations the I/J VGPR is the first source and the attribute is the second source; however in the VOP3 encoding the attribute is stored in the src0 field and the VGPR is stored in the src1 field.\n        V_INTERP_P1LV_F16,     // : D.f32 = P10.f16 * S0.f32 + (S2.u32 >> (attr_word * 16)).f16. 'LV' stands for 'One LDS and one VGPR argument'. S2 holds two parameters, attr_word selects the high or low word of the VGPR for this calculation, as well as the high or low half of the LDS data.\" Meant for use with 16-bank LDS. NOTE: In textual representations the I/J VGPR is the first source and the attribute is the second source; however in the VOP3 encoding the attribute is stored in the src0 field and the VGPR is stored in the src1 field.\n        V_INTERP_P2_F16  ,     // : D.f16 = P20.f16 * S0.f32 + S2.f32. Final computation. attr_word selects LDS high or low 16bits. Used for both 16- and 32-bank LDS. Result is always written to the 16 LSBs of the destination VGPR. NOTE: In textual representations the I/J VGPR is the first source and the attribute is the second source; however in the VOP3 encoding the attribute is stored in the src0 field and the VGPR is stored in the src1 field.\n\n    };\n\n    enum DSInstructions\n    {\n        DS_INVALID=0xffffffff,\n\n       DS_ADD_U32             =  0 ,   //  DS[A] = DS[A] + D0; uint add.\n       DS_SUB_U32             =  1 ,   //  DS[A] = DS[A] - D0; uint subtract.\n       DS_RSUB_U32            =  2 ,   //  DS[A] = D0 - DS[A]; uint reverse subtract.\n       DS_INC_U32             =  3 ,   //  DS[A] = (DS[A] >= D0 ? 0 : DS[A] + 1); uint increment.\n       DS_DEC_U32             =  4 ,   //  DS[A] = (DS[A] == 0 || DS[A] > D0 ? D0 : DS[A] - 1); uint decrement.\n       DS_MIN_I32             =  5 ,   //  DS[A] = min(DS[A], D0); int min.\n       DS_MAX_I32             =  6 ,   //  DS[A] = max(DS[A], D0); int max.\n       DS_MIN_U32             =  7 ,   //  DS[A] = min(DS[A], D0); uint min.\n       DS_MAX_U32             =  8 ,   //  DS[A] = max(DS[A], D0); uint max.\n       DS_AND_B32             =  9 ,   //  DS[A] = DS[A] & D0; Dword AND.\n       DS_OR_B32              = 10 ,   //  DS[A] = DS[A] | D0; Dword OR.\n       DS_XOR_B32             = 11 ,   //  DS[A] = DS[A] ^ D0; Dword XOR.\n       DS_MSKOR_B32           = 12 ,   //  DS[A] = (DS[A] ^ ~D0) | D1; masked Dword OR.\n       DS_WRITE_B32           = 13 ,   //  DS[A] = D0; write a Dword.\n       DS_WRITE2_B32          = 14 ,   //  DS[ADDR+offset0*4] = D0;DS[ADDR+offset1*4] = D1; write 2 Dwords.\n       DS_WRITE2ST64_B32      = 15 ,   //  DS[ADDR+offset0*4*64] = D0;DS[ADDR+offset1*4*64] = D1; write 2 Dwords.\n       DS_CMPST_B32           = 16 ,   //  DS[A] = (DS[A] == D0 ? D1 : DS[A]); compare store.\n       DS_CMPST_F32           = 17 ,   //  DS[A] = (DS[A] == D0 ? D1 : DS[A]); compare store with float rules.\n       DS_MIN_F32             = 18 ,   //  DS[A] = (DS[A] < D1) ? D0 : DS[A]; float compare swap (handles NaN/INF/denorm).\n       DS_MAX_F32             = 19 ,   //  DS[A] = (D0 > DS[A]) ? D0 : DS[A]; float, handles NaN/INF/denorm.\n       DS_NOP                  = 20,   // Do nothing.  SEA ISLANDS ONLY\n       DS_GWS_SEMA_RELEASE_ALL = 24,   // GDS Only. Release all wavefronts waiting on this semaphore. ResourceID is in offset[4:0]. SEA ISLANDS ONLY\n       DS_GWS_INIT            = 25 ,   //  GDS only.\n       DS_GWS_SEMA_V          = 26 ,   //  GDS only.\n       DS_GWS_SEMA_BR         = 27 ,   //  GDS only.\n       DS_GWS_SEMA_P          = 28 ,   //  GDS only.\n       DS_GWS_BARRIER         = 29 ,   //  GDS only.\n       DS_WRITE_B8            = 30 ,   //  DS[A] = D0[7:0]; byte write.\n       DS_WRITE_B16           = 31 ,   //  DS[A] = D0[15:0]; short write.\n       DS_ADD_RTN_U32         = 32 ,   //  Uint add.\n       DS_SUB_RTN_U32         = 33 ,   //  Uint subtract.\n       DS_RSUB_RTN_U32        = 34 ,   //  Uint reverse subtract.\n       DS_INC_RTN_U32         = 35 ,   //  Uint increment.\n       DS_DEC_RTN_U32         = 36 ,   //  Uint decrement.\n       DS_MIN_RTN_I32         = 37 ,   //  Int min.\n       DS_MAX_RTN_I32         = 38 ,   //  Int max.\n       DS_MIN_RTN_U32         = 39 ,   //  Uint min.\n       DS_MAX_RTN_U32         = 40 ,   //  Uint max.\n       DS_AND_RTN_B32         = 41 ,   //  Dword AND.\n       DS_OR_RTN_B32          = 42 ,   //  Dword OR.\n       DS_XOR_RTN_B32         = 43 ,   //  Dword XOR.\n       DS_MSKOR_RTN_B32       = 44 ,   //  Masked Dword OR.\n       DS_WRXCHG_RTN_B32      = 45 ,   //  Write exchange. Offset = {offset1,offset0}. A = ADDR+offset. D=DS[Addr]. DS[Addr]=D0.\n       DS_WRXCHG2_RTN_B32     = 46 ,   //  Write exchange 2 separate Dwords.\n       DS_WRXCHG2ST64_RTN_B32 = 47 ,   //  Write echange 2 Dwords, stride 64.\n       DS_CMPST_RTN_B32       = 48 ,   //  Compare store.\n       DS_CMPST_RTN_F32       = 49 ,   //  Compare store with float rules.\n       DS_MIN_RTN_F32         = 50 ,   //  DS[A] = (DS[A] < D1) ? D0 : DS[A]; float compare swap (handles NaN/INF/denorm).\n       DS_MAX_RTN_F32         = 51 ,   //  DS[A] = (D0 > DS[A]) ? D0 : DS[A]; float, handles NaN/INF/denorm .\n       DS_WRAP_RTN_B32        = 52 ,   // DS[A] = (DS[A] >= D0) ? DS[A] - D0 : DS[A] + D1. SEA ISLANDS ONLY\n       DS_SWIZZLE_B32         = 53 ,   //  R = swizzle(Data(vgpr), offset1:offset0). Dword swizzle. no data is written to LDS. see ds_opcodes.docx for details.\n       DS_READ_B32            = 54 ,   //  R = DS[A]; Dword read.\n       DS_READ2_B32           = 55 ,   //  R = DS[ADDR+offset0*4], R+1 = DS[ADDR+offset1*4]. Read 2 Dwords.\n       DS_READ2ST64_B32       = 56 ,   //  R = DS[ADDR+offset0*4*64], R+1 = DS[ADDR+offset1*4*64]. Read 2 Dwords.\n       DS_READ_I8             = 57 ,   //  R = signext(DS[A][7:0]}; signed byte read.\n       DS_READ_U8             = 58 ,   //  R = {24h0,DS[A][7:0]}; unsigned byte read.\n       DS_READ_I16            = 59 ,   //  R = signext(DS[A][15:0]}; signed short read.\n       DS_READ_U16            = 60 ,   //  R = {16h0,DS[A][15:0]}; unsigned short read.\n       DS_CONSUME             = 61 ,   //  Consume entries from a buffer.\n       DS_APPEND              = 62 ,   //  Append one or more entries to a buffer.\n       DS_ORDERED_COUNT       = 63 ,   //  Increment an append counter. Operation is done in order of wavefront creation.\n       DS_ADD_U64             = 64 ,   //  Uint add.\n       DS_SUB_U64             = 65 ,   //  Uint subtract.\n       DS_RSUB_U64            = 66 ,   //  Uint reverse subtract.\n       DS_INC_U64             = 67 ,   //  Uint increment.\n       DS_DEC_U64             = 68 ,   //  Uint decrement.\n       DS_MIN_I64             = 69 ,   //  Int min.\n       DS_MAX_I64             = 70 ,   //  Int max.\n       DS_MIN_U64             = 71 ,   //  Uint min.\n       DS_MAX_U64             = 72 ,   //  Uint max.\n       DS_AND_B64             = 73 ,   //  Dword AND.\n       DS_OR_B64              = 74 ,   //  Dword OR.\n       DS_XOR_B64             = 75 ,   //  Dword XOR.\n       DS_MSKOR_B64           = 76 ,   //  Masked Dword XOR.\n       DS_WRITE_B64           = 77 ,   //  Write.\n       DS_WRITE2_B64          = 78 ,   //  DS[ADDR+offset0*8] = D0;DS[ADDR+offset1*8] = D1; write 2 Dwords.\n       DS_WRITE2ST64_B64      = 79 ,   //  DS[ADDR+offset0*8*64] = D0; DS[ADDR+offset1*8*64] = D1; write 2 Dwords.\n       DS_CMPST_B64           = 80 ,   //  Compare store.\n       DS_CMPST_F64           = 81 ,   //  Compare store with float rules.\n       DS_MIN_F64             = 82 ,   //  DS[A] = (D0 < DS[A]) ? D0 : DS[A]; float, handles NaN/INF/denorm.\n       DS_MAX_F64             = 83 ,   //  DS[A] = (D0 > DS[A]) ? D0 : DS[A]; float, handles NaN/INF/denorm.\n       DS_ADD_RTN_U64         = 96 ,   //  Uint add.\n       DS_SUB_RTN_U64         = 97 ,   //  Uint subtract.\n       DS_RSUB_RTN_U64        = 98 ,   //  Uint reverse subtract.\n       DS_INC_RTN_U64         = 99 ,   //  Uint increment.\n       DS_DEC_RTN_U64         = 100,   // Uint decrement.\n       DS_MIN_RTN_I64         = 101,   // Int min.\n       DS_MAX_RTN_I64         = 102,   // Int max.\n       DS_MIN_RTN_U64         = 103,   // Uint min.\n       DS_MAX_RTN_U64         = 104,   // Uint max.\n       DS_AND_RTN_B64         = 105,   // Dword AND.\n       DS_OR_RTN_B64          = 106,   // Dword OR.\n       DS_XOR_RTN_B64         = 107,   // Dword XOR.\n       DS_MSKOR_RTN_B64       = 108,   // Masked Dword XOR.\n       DS_WRXCHG_RTN_B64      = 109,   // Write exchange.\n       DS_WRXCHG2_RTN_B64     = 110,   // Write exchange relative.\n       DS_WRXCHG2ST64_RTN_B64 = 111,   // Write echange 2 Dwords.\n       DS_CMPST_RTN_B64       = 112,   // Compare store.\n       DS_CMPST_RTN_F64       = 113,   // Compare store with float rules.\n       DS_MIN_RTN_F64         = 114,   // DS[A] = (D0 < DS[A]) ? D0 : DS[A]; float, handles NaN/INF/denorm.\n       DS_MAX_RTN_F64         = 115,   // DS[A] = (D0 > DS[A]) ? D0 : DS[A]; float, handles NaN/INF/denorm.\n       DS_READ_B64            = 118,   // Dword read.\n       DS_READ2_B64           = 119,   // R = DS[ADDR+offset0*8], R+1 = DS[ADDR+offset1*8]. Read 2 Dwords\n       DS_READ2ST64_B64       = 120,   // R = DS[ADDR+offset0*8*64], R+1 = DS[ADDR+offset1*8*64]. Read 2 Dwords.\n       DS_CONDXCHG32_RTN_B64  = 126,   // Conditional write exchange. SEA ISLANDS ONLY\n       DS_ADD_SRC2_U32        = 128,   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} : {offset1[6],offset1[6:0],offset0}). DS[A] = DS[A] + DS[B]; uint add.\n       DS_SUB_SRC2_U32        = 129,   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} : {offset1[6],offset1[6:0],offset0}). DS[A] = DS[A] - DS[B]; uint subtract.\n       DS_RSUB_SRC2_U32       = 130,   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} : {offset1[6],offset1[6:0],offset0}). DS[A] = DS[B]- DS[A]; uint reverse subtract.\n       DS_INC_SRC2_U32        = 131,   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} :{offset1[6],offset1[6:0],offset0}). DS[A] = (DS[A] >= DS[B] ? 0 : DS[A] + 1); uint increment.\n       DS_DEC_SRC2_U32        = 132,   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} :{offset1[6],offset1[6:0],offset0}). DS[A] = (DS[A]== 0 || DS[A] > DS[B] ? DS[B] : DS[A] - 1); uintdecrement.\n       DS_MIN_SRC2_I32        = 133,   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} :{offset1[6],offset1[6:0],offset0}). DS[A] =min(DS[A], DS[B]); int min.\n       DS_MAX_SRC2_I32        = 134,   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} : {offset1[6],offset1[6:0],offset0}). DS[A] =max(DS[A], DS[B]); int max.\n       DS_MIN_SRC2_U32        = 135,   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} :{offset1[6],offset1[6:0],offset0}). DS[A] = min(DS[A], DS[B]); uint min.\n       DS_MAX_SRC2_U32        = 136,   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} : {offset1[6],offset1[6:0],offset0}). DS[A] =max(DS[A], DS[B]); uint maxw\n       DS_AND_SRC2_B32        = 137,   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} : {offset1[6],offset1[6:0],offset0}). DS[A] = DS[A]& DS[B]; Dword AND.\n       DS_OR_SRC2_B32         = 138,   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} :  {offset1[6],offset1[6:0],offset0}). DS[A] = DS[A] |DS[B]; Dword OR.\n       DS_XOR_SRC2_B32        = 139,   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} :{offset1[6],offset1[6:0],offset0}). DS[A] = DS[A] ^DS[B]; Dword XOR.\n       DS_WRITE_SRC2_B32      = 140,   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} :{offset1[6],offset1[6:0],offset0}). DS[A] = DS[B];write Dword.\n       DS_MIN_SRC2_F32        = 146,   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} :{offset1[6],offset1[6:0],offset0}). DS[A] = (DS[B] < DS[A]) ? DS[B] : DS[A]; float, handles NaN/INF/denorm.\n       DS_MAX_SRC2_F32        = 147,   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} : {offset1[6],offset1[6:0],offset0}). DS[A] = (DS[B] > DS[A]) ? DS[B] : DS[A]; float, handles NaN/INF/denorm.\n       DS_ADD_SRC2_U64        = 192,   // Uint add.\n       DS_SUB_SRC2_U64        = 193,   // Uint subtract.\n       DS_RSUB_SRC2_U64       = 194,   // Uint reverse subtract.\n       DS_INC_SRC2_U64        = 195,   // Uint increment.\n       DS_DEC_SRC2_U64        = 196,   // Uint decrement.\n       DS_MIN_SRC2_I64        = 197,   // Int min.\n       DS_MAX_SRC2_I64        = 198,   // Int max.\n       DS_MIN_SRC2_U64        = 199,   // Uint min.\n       DS_MAX_SRC2_U64        = 200,   // Uint max.\n       DS_AND_SRC2_B64        = 201,   // Dword AND.\n       DS_OR_SRC2_B64         = 202,   // Dword OR.\n       DS_XOR_SRC2_B64        = 203,   // Dword XOR.\n       DS_WRITE_SRC2_B64      = 204,   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} :{offset1[6],offset1[6:0],offset0}). DS[A] = DS[B]; write Qword.\n       DS_MIN_SRC2_F64        = 210,   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} :{offset1[6],offset1[6:0],offset0}). [A] = (D0 < DS[A]) ? D0 : DS[A]; float, handlesNaN/INF/denorm.\n       DS_MAX_SRC2_F64        = 211,   // B = A + 4*(offset1[7] ? {A[31],A[31:17]} :{offset1[6],offset1[6:0],offset0}). [A] = (D0 > DS[A]) ? D0 : DS[A]; float, handlesNaN/INF/denorm.\n       // SEA ISLANDS ONLY \n       DS_WRITE_B96            = 222,   //{DS[A+2], DS[A+1], DS[A]} = D0[95:0]; tri-dword write.\n       DS_WRITE_B128           = 223,   //{DS[A+3], DS[A+2], DS[A+1], DS[A]} = D0[127:0]; qword write.\n       DS_CONDXCHG32_RTN_B128  = 253,   //Conditional write exchange.\n       DS_READ_B96             = 254,   //Tri-Dword read.\n       DS_READ_B128            = 255,   //Qword read.\n\n        // new for VI\n       DS_PERMUTE_B32       , // : Forward permute. Does not write any LDS memory. LDS[dst] = src0\n                              //     returnVal = LDS[thread_id] Where thread_id is 0..63.\n       DS_BPERMUTE_B32      , // : Backward permute. Does not actually write any LDS memory. LDS[thread_id] = src0 Where thread_id is 0..63.\n                              //     returnVal = LDS[dst]\n       DS_ADD_F32, \n       //All other values are reserved.\n    };\n\n\n\n    enum BufferInstructions\n    {\n                                         // Memory Buffer Instructions 12-39\n                                         //  2012 Advanced Micro Devices, Inc. All rights reserved.\n        BUFFER_LOAD_FORMAT_X     = 0 ,   // : Untyped buffer load 1 Dword with format conversion.\n        BUFFER_LOAD_FORMAT_XY    = 1 ,   // : Untyped buffer load 2 Dwords with format conversion.\n        BUFFER_LOAD_FORMAT_XYZ   = 2 ,   // : Untyped buffer load 3 Dwords with format conversion.\n        BUFFER_LOAD_FORMAT_XYZW  = 3 ,   // : Untyped buffer load 4 Dwords with format conversion.\n        BUFFER_STORE_FORMAT_X    = 4 ,   // : Untyped buffer store 1 Dword with format conversion.\n        BUFFER_STORE_FORMAT_XY   = 5 ,   // : Untyped buffer store 2 Dwords with format conversion.\n        BUFFER_STORE_FORMAT_XYZ  = 6 ,   // : Untyped buffer store 3 Dwords with format conversion.\n        BUFFER_STORE_FORMAT_XYZW = 7 ,   // : Untyped buffer store 4 Dwords with format conversion.\n        BUFFER_LOAD_UBYTE        = 8 ,   // : Untyped buffer load unsigned byte.\n        BUFFER_LOAD_SBYTE        = 9 ,   // : Untyped buffer load signed byte.\n        BUFFER_LOAD_USHORT       = 10,   // : Untyped buffer load unsigned short.\n        BUFFER_LOAD_SSHORT       = 11,   // : Untyped buffer load signed short.\n        BUFFER_LOAD_DWORD        = 12,   // : Untyped buffer load Dword.\n        BUFFER_LOAD_DWORDX2      = 13,   // : Untyped buffer load 2 Dwords.\n        BUFFER_LOAD_DWORDX4      = 14,   // : Untyped buffer load 4 Dwords.\n        BUFFER_LOAD_DWORDX3      = 15,   // : Untyped buffer load 3 Dwords. SEA ISLANDS\n         //16  23 reserved.             //\n        BUFFER_STORE_BYTE        = 24,   // : Untyped buffer store byte.\n        //25 reserved.\n        BUFFER_STORE_SHORT       = 26 , //  : Untyped buffer store short.\n        //27 reserved.\n        BUFFER_STORE_DWORD      = 28 , //   : Untyped buffer store Dword.\n        BUFFER_STORE_DWORDX2    = 29 , //   : Untyped buffer store 2 Dwords.\n        BUFFER_STORE_DWORDX4    = 30 , //   : Untyped buffer store 4 Dwords.\n        BUFFER_STORE_DWORDX3    = 31 , //   : Untyped buffer store 3 Dwords.  SEA ISLANDS\n        //31  47 reserved.\n        BUFFER_ATOMIC_SWAP      = 48, //    : 32b. dst=src, returns previous value if glc==1.\n        BUFFER_ATOMIC_CMPSWAP   = 49, //    : 32b, dst = (dst==cmp) ? src : dst. Returns previous value if glc==1. src comes from the first data-vgpr, cmp from the second.\n        BUFFER_ATOMIC_ADD       = 50, //    : 32b, dst += src. Returns previous value if glc==1.\n        BUFFER_ATOMIC_SUB       = 51, //    : 32b, dst -= src. Returns previous value if glc==1.\n        BUFFER_ATOMIC_RSUB      = 52, //    : 32b, dst = src-dst. Returns previous value if glc==1.  SI ONLY\n        BUFFER_ATOMIC_SMIN      = 53, //    : 32b, dst = (src < dst) ? src : dst (signed). Returns previous value if glc==1.\n        BUFFER_ATOMIC_UMIN      = 54, //    : 32b, dst = (src < dst) ? src : dst (unsigned). Returns previous value if glc==1.\n        BUFFER_ATOMIC_SMAX      = 55, //    : 32b, dst = (src > dst) ? src : dst (signed). Returns previousvalue if glc==1.\n        BUFFER_ATOMIC_UMAX      = 56, //    : 32b, dst = (src > dst) ? src : dst (unsigned). Returns previous value if glc==1.\n        BUFFER_ATOMIC_AND       = 57, //    : 32b, dst &= src. Returns previous value if glc==1.\n        BUFFER_ATOMIC_OR        = 58, //    : 32b, dst |= src. Returns previous value if glc==1.\n        BUFFER_ATOMIC_XOR       = 59, //    : 32b, dst ^= src. Returns previous value if glc==1.\n        BUFFER_ATOMIC_INC       = 60, //    : 32b, dst = (dst >= src) ? 0 : dst+1. Returns previous value if glc==1.\n        BUFFER_ATOMIC_DEC       = 61, //    : 32b, dst = ((dst==0 || (dst > src)) ? src : dst-1. Returns previous value if glc==1.\n        BUFFER_ATOMIC_FCMPSWAP  = 62, //    : 32b , dst = (dst == cmp) ? src : dst, returns previous  value if glc==1. Float compare swap (handles NaN/INF/denorm). srccomes from the first data-vgpr; cmp from the second.\n        BUFFER_ATOMIC_FMIN      = 63, //    : 32b , dst = (src < dst) ? src : dst,. Returns previousvalue if glc==1. float, handles NaN/INF/denorm.\n        BUFFER_ATOMIC_FMAX      = 64, //    : 32b , dst = (src > dst) ? src : dst, returns previous valueif glc==1. float, handles NaN/INF/denorm.\n       // 65  79 reserved.\n        BUFFER_ATOMIC_SWAP_X2    = 80, //     : 64b. dst=src, returns previous value if glc==1.\n        BUFFER_ATOMIC_CMPSWAP_X2 = 81, //     : 64b, dst = (dst==cmp) ? src : dst. Returns previous value if glc==1. src comes from the first two data-vgprs, cmp from the second two.\n        BUFFER_ATOMIC_ADD_X2     = 82, //     : 64b, dst += src. Returns previous value if glc==1.\n        BUFFER_ATOMIC_SUB_X2     = 83, //     : 64b, dst -= src. Returns previous value if glc==1.\n        BUFFER_ATOMIC_RSUB_X2    = 84, //     : 64b, dst = src-dst. Returns previous value if glc==1.  SI ONLY\n        BUFFER_ATOMIC_SMIN_X2    = 85, //     : 64b, dst = (src < dst) ? src : dst (signed). Returnsprevious value if glc==1.\n        BUFFER_ATOMIC_UMIN_X2    = 86, //     : 64b, dst = (src < dst) ? src : dst (unsigned).Returns previous value if glc==1.\n        BUFFER_ATOMIC_SMAX_X2    = 87, //     : 64b, dst = (src > dst) ? src : dst (signed). Returnsprevious value if glc==1.\n        BUFFER_ATOMIC_UMAX_X2    = 88, //     : 64b, dst = (src > dst) ? src : dst (unsigned). Returns previous value if glc==1.\n\n        // NOTE: BUFFER_ATOMIC_RSUB(53) and RSUB_X2(84) is SI only\n\n        BUFFER_ATOMIC_AND_X2       = 89 , //     : 64b, dst &= src. Returns previous value if glc==1.\n        BUFFER_ATOMIC_OR_X2        = 90 , //     : 64b, dst |= src. Returns previous value if glc==1.\n        BUFFER_ATOMIC_XOR_X2       = 91 , //     : 64b, dst ^= src. Returns previous value if glc==1.\n        BUFFER_ATOMIC_INC_X2       = 92 , //     : 64b, dst = (dst >= src) ? 0 : dst+1. Returns previous value if glc==1.\n        BUFFER_ATOMIC_DEC_X2       = 93 , //     : 64b, dst = ((dst==0 || (dst > src)) ? src : dst-1. Returns previous value if glc==1.\n        BUFFER_ATOMIC_FCMPSWAP_X2  = 94 , //     : 64b , dst = (dst == cmp) ? src : dst, returns previous value if glc==1. Double compare swap (handles NaN/INF/denorm). src comes from the first two data-vgprs, cmp from the second two.\n        BUFFER_ATOMIC_FMIN_X2      = 95 , //     : 64b , dst = (src < dst) ? src : dst, returns previous value if glc==1. Double, handles NaN/INF/denorm.\n        BUFFER_ATOMIC_FMAX_X2      = 96 , //     : 64b , dst = (src > dst) ? src : dst, returns previous value if glc==1. Double, handles NaN/INF/denorm.\n        //97  111 reserved.\n        BUFFER_WBINVL1_SC          = 112 , //      : write back and invalidate the shader L1 only for lines of MTYPE SC and GC. Always returns ACK to shader.\n        BUFFER_WBINVL1             = 113 , //      : write back and invalidate the shader L1. Always returns ACK to shader.\n        \n        // new for VI\n        BUFFER_WBINVL1_VOL              , //: Write back and invalidate the shader L1 only for lines that are marked volatile. Always returns ACK to shader.\n        BUFFER_STORE_LDS_DWORD          , //: Store one Dword from LDS memory to system memory without using VGPRs.\n        BUFFER_LOAD_FORMAT_D16_X        ,//: Untyped buffer load 1 dword with format conversion.\n        BUFFER_LOAD_FORMAT_D16_XY       ,//: Untyped buffer load 2 dwords with format conversion.\n        BUFFER_LOAD_FORMAT_D16_XYZ      ,//: Untyped buffer load 3 dwords with format conversion.\n        BUFFER_LOAD_FORMAT_D16_XYZW     ,//: Untyped buffer load 4 dwords with format conversion.\n        BUFFER_STORE_FORMAT_D16_X       ,//: Untyped buffer store 1 dword with format conversion.\n        BUFFER_STORE_FORMAT_D16_XY      ,//: Untyped buffer store 2 dwords with format conversion.\n        BUFFER_STORE_FORMAT_D16_XYZ     ,//: Untyped buffer store 3 dwords with format conversion.\n        BUFFER_STORE_FORMAT_D16_XYZW    ,//: Untyped buffer store 4 dwords with format conversion.\n\n\n        TBUFFER_LOAD_FORMAT_X      , //  : Untyped buffer load 1 Dword with format conversion.\n        TBUFFER_LOAD_FORMAT_XY     , //  : Untyped buffer load 2 Dwords with format conversion.\n        TBUFFER_LOAD_FORMAT_XYZ    , //  : Untyped buffer load 3 Dwords with format conversion.\n        TBUFFER_LOAD_FORMAT_XYZW   , //  : Untyped buffer load 4 Dwords with format conversion.\n        TBUFFER_STORE_FORMAT_X     , //  : Untyped buffer store 1 Dword with format conversion.\n        TBUFFER_STORE_FORMAT_XY    , //  : Untyped buffer store 2 Dwords with format conversion.\n        TBUFFER_STORE_FORMAT_XYZ   , //  : Untyped buffer store 3 Dwords with format conversion.\n        TBUFFER_STORE_FORMAT_XYZW  , //  : Untyped buffer store 4 Dwords with format conversion.\n\n        TBUFFER_LOAD_FORMAT_D16_X      ,// : Typed buffer load 1 dword with format conversion.\n        TBUFFER_LOAD_FORMAT_D16_XY     ,// : Typed buffer load 2 dwords with format conversion.\n        TBUFFER_LOAD_FORMAT_D16_XYZ    ,// : Typed buffer load 3 dwords with format conversion.\n        TBUFFER_LOAD_FORMAT_D16_XYZW   ,//     : Typed buffer load 4 dwords with format conversion.\n        TBUFFER_STORE_FORMAT_D16_X     ,// : Typed buffer store 1 dword with format conversion.\n        TBUFFER_STORE_FORMAT_D16_XY    ,// : Typed buffer store 2 dwords with format conversion.\n        TBUFFER_STORE_FORMAT_D16_XYZ   ,// : Typed buffer store 3 dwords with format conversion.\n        TBUFFER_STORE_FORMAT_D16_XYZW  ,// : Typed buffer store 4 dwords with format conversion.\n\n\n\n        TBUFFER_INVALID = 0xffffffff,\n        BUFFER_INVALID = 0xffffffff\n    };\n\n\n    \n    enum TBufferNumberFormats\n    {\n        NF_UNORM       ,\n        NF_SNORM       ,\n        NF_USCALED     ,\n        NF_SSCALED     ,\n        NF_UINT        ,\n        NF_SINT        ,\n        NF_SNORM_NZ    ,\n        NF_FLOAT       ,\n         //8 reserved\n        NF_SRGB       =9,\n        NF_UBNORM      ,\n        NF_UBNORM_NZ   ,\n        NF_UBINT       ,\n        NF_UBSCALED    ,\n        NF_INVALID = 0xfffffff\n    };\n    enum TBufferDataFormats\n    {\n        DF_INVALID=0,\n        DF_8,\n        DF_16,\n        DF_8_8,\n        DF_32,\n        DF_16_16,\n        DF_10_11_11,\n        DF_11_11_10,\n        DF_10_10_10_2,\n        DF_2_10_10_10,\n        DF_8_8_8_8,\n        DF_32_32,\n        DF_16_16_16_16,\n        DF_32_32_32,\n        DF_32_32_32_32,\n      \n    };\n\n    enum ImageInstructions\n    {\n        IMAGE_LOAD             ,   // Image memory load with format conversion specified in T#. No sampler.\n        IMAGE_LOAD_MIP         ,   // Image memory load with user-supplied mip level. No sampler.\n        IMAGE_LOAD_PCK         ,   // Image memory load with no format conversion. No sampler.\n        IMAGE_LOAD_PCK_SGN     ,   // Image memory load with with no format conversion and sign extension. No sampler.\n        IMAGE_LOAD_MIP_PCK     ,   // Image memory load with user-supplied mip level, no format conversion. No sampler.\n        IMAGE_LOAD_MIP_PCK_SGN ,   // Image memory load with user-supplied mip level, no format conversion and with sign extension. No sampler.\n        //6  7 reserved.\n        IMAGE_STORE          ,     //: Image memory store with format conversion specified in T#. No sampler.\n        IMAGE_STORE_MIP      ,     //: Image memory store with format conversion specified in T# to user specified mip level. No sampler.\n        IMAGE_STORE_PCK      ,     //: Image memory store of packed data without format conversion. No sampler.\n        IMAGE_STORE_MIP_PCK  ,    //: Image memory store of packed data without format conversion to user-supplied mip level. No sampler.\n        //12  13 reserved.\n        IMAGE_GET_RESINFO     ,    //: return resource info. No sampler.\n        IMAGE_ATOMIC_SWAP     ,    //: dst=src, returns previous value if glc==1.\n        IMAGE_ATOMIC_CMPSWAP  ,    //: dst = (dst==cmp) ? src : dst. Returns previous value if glc==1.\n        IMAGE_ATOMIC_ADD      ,    //: dst += src. Returns previous value if glc==1.\n        IMAGE_ATOMIC_SUB      ,    //: dst -= src. Returns previous value if glc==1.\n        IMAGE_ATOMIC_RSUB     ,    //: dst = src-dst. Returns previous value if glc==1.  SI ONLY\n        IMAGE_ATOMIC_SMIN     ,    //: dst = (src < dst) ? src : dst (signed). Returns previous value if glc==1.\n        IMAGE_ATOMIC_UMIN     ,    //: dst = (src < dst) ? src : dst (unsigned). Returns previous value if glc==1.\n        IMAGE_ATOMIC_SMAX     ,    //: dst = (src > dst) ? src : dst (signed). Returns previous value if glc==1.\n        IMAGE_ATOMIC_UMAX     ,    //: dst = (src > dst) ? src : dst (unsigned). Returns previous value if glc==1.\n        IMAGE_ATOMIC_AND      ,    //: dst &= src. Returns previous value if glc==1.\n        IMAGE_ATOMIC_OR       ,    //: dst |= src. Returns previous value if glc==1.\n        IMAGE_ATOMIC_XOR      ,    //: dst ^= src. Returns previous value if glc==1.\n        IMAGE_ATOMIC_INC      ,    //: dst = (dst >= src) ? 0 : dst+1. Returns previous value if glc==1.\n        IMAGE_ATOMIC_DEC      ,    //: dst = ((dst==0 || (dst > src)) ? src : dst-1. Returns previous value if glc==1.\n        IMAGE_ATOMIC_FCMPSWAP ,    //: dst = (dst == cmp) ? src : dst, returns previous value of dst if glc==1 - double and float atomic compare swap. Obeys floating point compare rules for special values.\n        IMAGE_ATOMIC_FMIN     ,    //: dst = (src < dst) ? src : dst, returns previous value of dst if glc==1 - double and float atomic min (handles NaN/INF/denorm).\n        IMAGE_ATOMIC_FMAX     ,    //: dst = (src > dst) ? src : dst, returns previous value of dst if glc==1 - double and float atomic min (handles NaN/INF/denorm).\n        IMAGE_SAMPLE          ,    //: sample texture map.\n        IMAGE_SAMPLE_CL       ,    //: sample texture map, with LOD clamp specified in shader.\n        IMAGE_SAMPLE_D        ,    //: sample texture map, with user derivatives.\n        IMAGE_SAMPLE_D_CL     ,    //: sample texture map, with LOD clamp specified in shader, with user derivatives.\n        IMAGE_SAMPLE_L        ,    //: sample texture map, with user LOD.\n        IMAGE_SAMPLE_B        ,    //: sample texture map, with lod bias.\n        IMAGE_SAMPLE_B_CL     ,    //: sample texture map, with LOD clamp specified in shader, with lod bias.\n        IMAGE_SAMPLE_LZ       ,    //: sample texture map, from level 0.\n        IMAGE_SAMPLE_C        ,    //: sample texture map, with PCF.\n        IMAGE_SAMPLE_C_CL     ,    //: SAMPLE_C, with LOD clamp specified in shader.\n        IMAGE_SAMPLE_C_D      ,    //: SAMPLE_C, with user derivatives.\n        IMAGE_SAMPLE_C_D_CL   ,    //: SAMPLE_C, with LOD clamp specified in shader,with user derivatives.\n        IMAGE_SAMPLE_C_L      ,    //: SAMPLE_C, with user LOD.\n        IMAGE_SAMPLE_C_B      ,    //: SAMPLE_C, with lod bias.\n        IMAGE_SAMPLE_C_B_CL   ,    //: SAMPLE_C, with LOD clamp specified in shader, with lod bias.\n        IMAGE_SAMPLE_C_LZ      , //     : SAMPLE_C, from level 0.\n        IMAGE_SAMPLE_O         , // : sample texture map, with user offsets.\n        IMAGE_SAMPLE_CL_O      , //     : SAMPLE_O with LOD clamp specified in shader.\n        IMAGE_SAMPLE_D_O       , // : SAMPLE_O, with user derivatives.\n        IMAGE_SAMPLE_D_CL_O    , //     : SAMPLE_O, with LOD clamp specified in shader,with user derivatives.\n        IMAGE_SAMPLE_L_O       , // : SAMPLE_O, with user LOD.\n        IMAGE_SAMPLE_B_O       , // : SAMPLE_O, with lod bias.\n        IMAGE_SAMPLE_B_CL_O    , // : SAMPLE_O, with LOD clamp specified in shader,with lod bias.\n        IMAGE_SAMPLE_LZ_O      , // : SAMPLE_O, from level 0.\n        IMAGE_SAMPLE_C_O       , // : SAMPLE_C with user specified offsets.\n        IMAGE_SAMPLE_C_CL_O    , // : SAMPLE_C_O, with LOD clamp specified in shader.\n        IMAGE_SAMPLE_C_D_O     , // : SAMPLE_C_O, with user derivatives.\n        IMAGE_SAMPLE_C_D_CL_O  , // : SAMPLE_C_O, with LOD clamp specified in shader, with user derivatives.\n        IMAGE_SAMPLE_C_L_O     , // : SAMPLE_C_O, with user LOD.\n        IMAGE_SAMPLE_C_B_O     , // : SAMPLE_C_O, with lod bias.\n        IMAGE_SAMPLE_C_B_CL_O  , // : SAMPLE_C_O, with LOD clamp specified in shader, with lod bias.\n        IMAGE_SAMPLE_C_LZ_O    , // : SAMPLE_C_O, from level 0.\n        IMAGE_GATHER4          , // : gather 4 single component elements (2x2).\n        IMAGE_GATHER4_CL       , // : gather 4 single component elements (2x2) with user LOD clamp.\n        IMAGE_GATHER4_L        , // : gather 4 single component elements (2x2) with user LOD.\n        IMAGE_GATHER4_B        , // : gather 4 single component elements (2x2) with user bias.\n        IMAGE_GATHER4_B_CL     , // : gather 4 single component elements (2x2) with user bias and clamp.\n        IMAGE_GATHER4_LZ       , // : gather 4 single component elements (2x2) at level 0.\n        IMAGE_GATHER4_C        , // : gather 4 single component elements (2x2) with PCF.\n        IMAGE_GATHER4_C_CL     , // : gather 4 single component elements (2x2) with user LOD clamp and PCF.\n        //72  75 reserved.          //\n        IMAGE_GATHER4_C_L    ,  // : gather 4 single component elements (2x2) with user LOD and PCF.\n        IMAGE_GATHER4_C_B    ,  // : gather 4 single component elements (2x2) with user bias and PCF.\n        IMAGE_GATHER4_C_B_CL ,  // : gather 4 single component elements (2x2) with user bias, clamp and PCF.\n        IMAGE_GATHER4_C_LZ   ,  // : gather 4 single component elements (2x2) at level 0, with PCF.\n        IMAGE_GATHER4_O      ,  // : GATHER4, with user offsets.\n        IMAGE_GATHER4_CL_O   ,  // : GATHER4_CL, with user offsets.\n        //82  83 reserved.           //\n        IMAGE_GATHER4_L_O     ,  // : GATHER4_L, with user offsets.\n        IMAGE_GATHER4_B_O     ,  // : GATHER4_B, with user offsets.\n        IMAGE_GATHER4_B_CL_O  ,  // : GATHER4_B_CL, with user offsets.\n        IMAGE_GATHER4_LZ_O    ,  // : GATHER4_LZ, with user offsets.\n        IMAGE_GATHER4_C_O     ,  // : GATHER4_C, with user offsets.\n        IMAGE_GATHER4_C_CL_O  ,  // : GATHER4_C_CL, with user offsets.\n        //90  91 reserved.          //\n        IMAGE_GATHER4_C_L_O   ,  // : GATHER4_C_L, with user offsets.\n        IMAGE_GATHER4_C_B_O   ,  // : GATHER4_B, with user offsets.\n        IMAGE_GATHER4_C_B_CL_O,  // : GATHER4_B_CL, with user offsets.\n        IMAGE_GATHER4_C_LZ_O  ,  // : GATHER4_C_LZ, with user offsets.\n        IMAGE_GET_LOD         ,  // : Return calculated LOD.\n        //97  103 reserved.         //\n        IMAGE_SAMPLE_CD        , // : sample texture map, with user derivatives (LOD per quad)\n        IMAGE_SAMPLE_CD_CL     , // : sample texture map, with LOD clamp specified in  shader, with user derivatives (LOD per quad).\n        IMAGE_SAMPLE_C_CD      , // : SAMPLE_C, with user derivatives (LOD per quad).\n        IMAGE_SAMPLE_C_CD_CL   , // : SAMPLE_C, with LOD clamp specified in shader, with user derivatives (LOD per quad).\n        IMAGE_SAMPLE_CD_O      , // : SAMPLE_O, with user derivatives (LOD per quad).\n        IMAGE_SAMPLE_CD_CL_O   , // : SAMPLE_O, with LOD clamp specified in shader, with user derivatives (LOD per quad).\n        IMAGE_SAMPLE_C_CD_O    , // : SAMPLE_C_O, with user derivatives (LOD per quad).\n        IMAGE_SAMPLE_C_CD_CL_O , // : SAMPLE_C_O, with LOD clamp specified in shader, with user derivatives (LOD per quad).\n        \n        IMAGE_INVALID = 0xffffffff\n       // All other values are reserved.\n    };\n\n    enum FlatInstructions // Flat opcode family is SEA ISLANDS ONLY (and above)\n    {\n        //0 - 7 reserved.\n        FLAT_LOAD_UBYTE       =  8,  //: Flat load unsigned byte. Zero extend to VGPR destination.\n        FLAT_LOAD_SBYTE       =  9,  //: Flat load signed byte. Sign extend to VGPR destination.\n        FLAT_LOAD_USHORT      = 10,  //: Flat load unsigned short. Zero extend to VGPR destination.\n        FLAT_LOAD_SSHORT      = 11,  //: Flat load signed short. Sign extend to VGPR destination.\n        FLAT_LOAD_DWORD       = 12,  //: Flat load Dword.\n        FLAT_LOAD_DWORDX2     = 13,  //: Flat load 2 Dwords.\n        FLAT_LOAD_DWORDX4     = 14,  //: Flat load 4 Dwords.\n        FLAT_LOAD_DWORDX3     = 15,  //: Flat load 3 Dwords.\n        //16 - 23 reserved.          //\n        FLAT_STORE_BYTE       = 24,  //: Flat store byte.\n        //25reserved.                //\n        FLAT_STORE_SHORT      = 26,  //: Flat store short.\n        //27reserved.                //\n        FLAT_STORE_DWORD      = 28,  //: Flat store Dword.\n        FLAT_STORE_DWORDX2    = 29,  //: Flat store 2 Dwords.\n        FLAT_STORE_DWORDX4    = 30,  //: Flat store 4 Dwords.\n        FLAT_STORE_DWORDX3    = 31,  //: Flat store 3 Dwords.\n        //32  47 reserved.          //\n        FLAT_ATOMIC_SWAP      = 48,  //: 32b. dst=src, returns previous value if rtn==1.\n        FLAT_ATOMIC_CMPSWAP   = 49,  //: 32b, dst = (dst==cmp) ? src : dst. Returns previous value if rtn==1. src comes from the first data-VGPR, cmp from the second.\n        FLAT_ATOMIC_ADD       = 50,  //: 32b, dst += src. Returns previous value if rtn==1.\n        FLAT_ATOMIC_SUB       = 51,  //: 32b, dst -= src. Returns previous value if rtn==1.\n        //52reserved.                //\n        FLAT_ATOMIC_SMIN      = 53,  //: 32b, dst = (src < dst) ? src : dst (signed comparison). Returns previous value if rtn==1.\n        FLAT_ATOMIC_UMIN      = 54,  //: 32b, dst = (src < dst) ? src : dst (unsigned comparison). Returns previous value if rtn==1.\n        FLAT_ATOMIC_SMAX      = 55,  //: 32b, dst = (src > dst) ? src : dst (signed comparison). Returns previous value if rtn==1.\n                                     //\n        FLAT_ATOMIC_UMAX       = 56,  //: 32b, dst = (src > dst) ? src : dst (unsigned comparison). Returns previous value if rtn==1.\n        FLAT_ATOMIC_AND        = 57,  //: 32b, dst &= src. Returns previous value if rtn==1.\n        FLAT_ATOMIC_OR         = 58,  //: 32b, dst |= src. Returns previous value if rtn==1.\n        FLAT_ATOMIC_XOR        = 59,  //: 32b, dst ^= src. Returns previous value if rtn==1.\n        FLAT_ATOMIC_INC        = 60,  //: 32b, dst = (dst >= src) ? 0 : dst+1 (unsigned comparison). Returns previous value if rtn==1.\n        FLAT_ATOMIC_DEC        = 61,  //: 32b, dst = ((dst==0 || (dst > src)) ? src : dst-1 (unsigned comparison). Returns previous value if rtn==1.\n        FLAT_ATOMIC_FCMPSWAP   = 62,  //: 32b , dst = (dst == cmp) ? src : dst, returns previous value if rtn==1. Floating point compare-swap handles NaN/INF/denorm. src comes from the first data-VGPR; cmp from the second.\n        FLAT_ATOMIC_FMIN       = 63,  //: 32b , dst = (src < dst) ? src : dst. Returns previous value if rtn==1. float, handles NaN/INF/denorm.\n        FLAT_ATOMIC_FMAX       = 64,  //: 32b , dst = (src > dst) ? src : dst, returns previous value if rtn==1. Floating point compare handles NaN/INF/denorm.\n        //65  79 reserved.           //\n        FLAT_ATOMIC_SWAP_X2     = 80, //: 64b. dst=src, returns previous value if rtn==1.\n        FLAT_ATOMIC_CMPSWAP_X2  = 81, //: 64b, dst = (dst==cmp) ? src : dst. Returns previous value if rtn==1. src comes from the first two data-VGPRs, cmp from the second two.\n        FLAT_ATOMIC_ADD_X2      = 82, //: 64b, dst += src. Returns previous value if rtn==1.\n        FLAT_ATOMIC_SUB_X2      = 83, //: 64b, dst -= src. Returns previous value if rtn==1.\n        //84reserved.                 //\n        FLAT_ATOMIC_SMIN_X2     = 85, //: 64b, dst = (src < dst) ? src : dst (signed comparison). Returns previous value if rtn==1.\n        FLAT_ATOMIC_UMIN_X2     = 86, //: 64b, dst = (src < dst) ? src : dst (unsigned comparison). Returns previous value if rtn==1.\n        FLAT_ATOMIC_SMAX_X2     = 87, //: 64b, dst = (src > dst) ? src : dst (signed comparison). Returns previous value if rtn==1.\n        FLAT_ATOMIC_UMAX_X2     = 88, //: 64b, dst = (src > dst) ? src : dst (unsigned comparison). Returns previous value if rtn==1.\n        FLAT_ATOMIC_AND_X2      = 89, //: 64b, dst &= src. Returns previous value if rtn==1.\n        FLAT_ATOMIC_OR_X2       = 90, //: 64b, dst |= src. Returns previous value if rtn==1.\n        FLAT_ATOMIC_XOR_X2      = 91, //: 64b, dst ^= src. Returns previous value if rtn==1.\n        FLAT_ATOMIC_INC_X2      = 92, //: 64b, dst = (dst >= src) ? 0 : dst+1. Returns previous value if rtn==1.\n        FLAT_ATOMIC_DEC_X2      = 93, //: 64b, dst = ((dst==0 || (dst > src)) ? src : dst - 1. Returns previous value if rtn==1.\n        FLAT_ATOMIC_FCMPSWAP_X2 = 94, //: 64b , dst = (dst == cmp) ? src : dst, returns previous value if rtn==1. Double compare swap (handles NaN/INF/denorm). src comes from the first two data-VGPRs, cmp from the second two.\n        FLAT_ATOMIC_FMIN_X2     = 95, //: 64b , dst = (src < dst) ? src : dst, returns previous value if rtn==1. Double, handles NaN/INF/denorm.\n        FLAT_ATOMIC_FMAX_X2     = 96, //: 64b , dst = (src > dst) ? src : dst, returns previous value if rtn==1. Double, handles NaN/INF/denorm.\n        \n        //All other values are reserved.\n    };\n\n\n    enum ExportTargets\n    {\n        EXP_MRT0      = 0,\n        EXP_MRT1      = 1,\n        EXP_MRT2      = 2,\n        EXP_MRT3      = 3,\n        EXP_MRT4      = 4,\n        EXP_MRT5      = 5,\n        EXP_MRT6      = 6,\n        EXP_MRT7      = 7,\n        EXP_Z         = 8,\n        EXP_NULL      = 9,\n        EXP_POS0      = 12,\n        EXP_POS1      = 13,\n        EXP_POS2      = 14,\n        EXP_POS3      = 15,\n        EXP_PARAM0    = 32,\n        EXP_PARAM1,\n        EXP_PARAM2,\n        EXP_PARAM3,\n        EXP_PARAM4,\n        EXP_PARAM5,\n        EXP_PARAM6,\n        EXP_PARAM7,\n        EXP_PARAM8,\n        EXP_PARAM9,\n        EXP_PARAM10,\n        EXP_PARAM11,\n        EXP_PARAM12,\n        EXP_PARAM13,\n        EXP_PARAM14,\n        EXP_PARAM15,\n        EXP_PARAM16,\n        EXP_PARAM17,\n        EXP_PARAM18,\n        EXP_PARAM19,\n        EXP_PARAM20,\n        EXP_PARAM21,\n        EXP_PARAM22,\n        EXP_PARAM23,\n        EXP_PARAM24,\n        EXP_PARAM25,\n        EXP_PARAM26,\n        EXP_PARAM27,\n        EXP_PARAM28,\n        EXP_PARAM29,\n        EXP_PARAM30,\n        EXP_PARAM31,\n        EXP_INVALID = 0xffffffff\n    };\n\n    const char* EnumToString(ScalarInstructions);\n    const char* EnumToString(ScalarMemoryInstructions);\n    const char* EnumToString(VectorInstructions);\n    const char* EnumToString(DSInstructions);\n    const char* EnumToString(BufferInstructions);\n    const char* EnumToString(ImageInstructions);\n    const char* EnumToString(FlatInstructions);\n    const char* EnumToString(ExportTargets);\n    const char* EnumToString(TBufferNumberFormats);\n    const char* EnumToString(TBufferDataFormats);\n}\n\n\n\n#endif"
  },
  {
    "path": "src/Wrapper/GCNIsa.cpp",
    "content": "#pragma unmanaged\n#include \"GCNIsa.h\"\n\nnamespace GCN\n{\n    uint GetSourceCountForInstruction( VectorInstructions eOp )\n    {\n        switch( eOp )\n        {\n        default: return 0;\n        \n        case V_MAD_F16              :\n        case V_MAD_U16              :\n        case V_MAD_I16              :\n        case V_PERM_B32             :\n        case V_FMA_F16              :\n        case V_DIV_FIXUP_F16        :\n            return 3;\n\n        case V_CVT_F16_U16        :      \n        case V_CVT_F16_I16        :   \n        case V_CVT_U16_F16        :   \n        case V_CVT_I16_F16        :   \n        case V_RCP_F16            :   \n        case V_SQRT_F16           :   \n        case V_RSQ_F16            :   \n        case V_LOG_F16            :   \n        case V_EXP_F16            :   \n        case V_FREXP_MANT_F16     :   \n        case V_FREXP_EXP_I16_F16  :   \n        case V_FLOOR_F16          :   \n        case V_CEIL_F16           :   \n        case V_TRUNC_F16          :   \n        case V_RNDNE_F16          :   \n        case V_FRACT_F16          :   \n        case V_SIN_F16            :   \n        case V_COS_F16            :   \n            return 1;\n\n        case V_ADD_U32:\n        case V_SUB_U32:\n        case V_SUBREV_U32:\n        case V_LSHLREV_B64:\n        case V_LSHRREV_B64:\n        case V_ASHRREV_I64:\n        case V_ADD_F16            : \n        case V_SUB_F16            : \n        case V_SUBREV_F16         : \n        case V_MUL_F16            : \n        case V_MAC_F16            : \n        case V_MADMK_F16          : \n        case V_MADAK_F16          : \n        case V_ADD_U16            : \n        case V_SUB_U16            : \n        case V_SUBREV_U16         : \n        case V_MUL_LO_U16         : \n        case V_LSHLREV_B16        : \n        case V_LSHRREV_B16        : \n        case V_ASHRREV_I16        : \n        case V_MAX_F16            : \n        case V_MIN_F16            : \n        case V_MAX_U16            : \n        case V_MAX_I16            : \n        case V_MIN_U16            : \n        case V_MIN_I16            : \n        case V_LDEXP_F16          : \n        case V_CNDMASK_B32        :     \n        case V_READLANE_B32             :                          \n        case V_WRITELANE_B32            :\n        case V_ADD_F32                  :\n        case V_SUB_F32                  :\n        case V_SUBREV_F32               :\n        case V_MAC_LEGACY_F32           :\n        case V_MUL_LEGACY_F32           :\n        case V_MUL_F32                  :\n        case V_MUL_I32_I24              :\n        case V_MUL_HI_I32_I24           :\n        case V_MUL_U32_U24              :\n        case V_MUL_HI_U32_U24           :\n        case V_MIN_LEGACY_F32           :\n        case V_MAX_LEGACY_F32           :\n        case V_MIN_F32                  :\n        case V_MAX_F32                  :\n        case V_MIN_I32                  :\n        case V_MAX_I32                  :\n        case V_MIN_U32                  :\n        case V_MAX_U32                  :\n        case V_LSHR_B32                 :\n        case V_LSHRREV_B32              :\n        case V_ASHR_I32                 :\n        case V_ASHRREV_I32              :\n        case V_LSHL_B32                 :\n        case V_LSHLREV_B32              :\n        case V_AND_B32                  :\n        case V_OR_B32                   :\n        case V_XOR_B32                  :\n        case V_BFM_B32                  :\n        case V_MAC_F32                  :\n        case V_MADMK_F32                :\n        case V_MADAK_F32                :\n        case V_BCNT_U32_B32             :\n        case V_MBCNT_LO_U32_B32         :                                                          \n        case V_MBCNT_HI_U32_B32         :                    \n        case V_ADD_I32                  :\n        case V_SUB_I32                  :\n        case V_SUBREV_I32               :\n        case V_ADDC_U32                 :\n        case V_SUBB_U32                 :\n        case V_SUBBREV_U32              :\n        case V_LDEXP_F32                :\n        case V_CVT_PKACCUM_U8_F32       :\n        case V_CVT_PKNORM_I16_F32       :\n        case V_CVT_PKNORM_U16_F32       :\n        case V_CVT_PKRTZ_F16_F32        :\n        case V_CVT_PK_U16_U32           :\n        case V_CVT_PK_I16_I32           :\n        case V_CMP_F_F32            :\n        case V_CMP_LT_F32           :\n        case V_CMP_EQ_F32           :\n        case V_CMP_LE_F32           :\n        case V_CMP_GT_F32           :\n        case V_CMP_LG_F32           :\n        case V_CMP_GE_F32           :\n        case V_CMP_O_F32            :\n        case V_CMP_U_F32            :\n        case V_CMP_NGE_F32          :\n        case V_CMP_NLG_F32          :\n        case V_CMP_NGT_F32          :\n        case V_CMP_NLE_F32          :\n        case V_CMP_NEQ_F32          :\n        case V_CMP_NLT_F32          :\n        case V_CMP_TRU_F32          :\n        case V_CMPX_F_F32           :\n        case V_CMPX_LT_F32          :\n        case V_CMPX_EQ_F32          :\n        case V_CMPX_LE_F32          :\n        case V_CMPX_GT_F32          :\n        case V_CMPX_LG_F32          :\n        case V_CMPX_GE_F32          :\n        case V_CMPX_O_F32           :\n        case V_CMPX_U_F32           :\n        case V_CMPX_NGE_F32         :\n        case V_CMPX_NLG_F32         :\n        case V_CMPX_NGT_F32         :\n        case V_CMPX_NLE_F32         :\n        case V_CMPX_NEQ_F32         :\n        case V_CMPX_NLT_F32         :\n        case V_CMPX_TRU_F32         :\n        case V_CMP_F_F64            :\n        case V_CMP_LT_F64           :\n        case V_CMP_EQ_F64           :\n        case V_CMP_LE_F64           :\n        case V_CMP_GT_F64           :\n        case V_CMP_LG_F64           :\n        case V_CMP_GE_F64           :\n        case V_CMP_O_F64            :\n        case V_CMP_U_F64            :\n        case V_CMP_NGE_F64          :\n        case V_CMP_NLG_F64          :\n        case V_CMP_NGT_F64          :\n        case V_CMP_NLE_F64          :\n        case V_CMP_NEQ_F64          :\n        case V_CMP_NLT_F64          :\n        case V_CMP_TRU_F64          :\n        case V_CMPX_F_F64           :\n        case V_CMPX_LT_F64          :\n        case V_CMPX_EQ_F64          :\n        case V_CMPX_LE_F64          :\n        case V_CMPX_GT_F64          :\n        case V_CMPX_LG_F64          :\n        case V_CMPX_GE_F64          :\n        case V_CMPX_O_F64           :\n        case V_CMPX_U_F64           :\n        case V_CMPX_NGE_F64         :\n        case V_CMPX_NLG_F64         :\n        case V_CMPX_NGT_F64         :\n        case V_CMPX_NLE_F64         :\n        case V_CMPX_NEQ_F64         :\n        case V_CMPX_NLT_F64         :\n        case V_CMPX_TRU_F64         :\n        case V_CMPS_F_F32           :\n        case V_CMPS_LT_F32          :\n        case V_CMPS_EQ_F32          :\n        case V_CMPS_LE_F32          :\n        case V_CMPS_GT_F32          :\n        case V_CMPS_LG_F32          :\n        case V_CMPS_GE_F32          :\n        case V_CMPS_O_F32           :\n        case V_CMPS_U_F32           :\n        case V_CMPS_NGE_F32         :\n        case V_CMPS_NLG_F32         :\n        case V_CMPS_NGT_F32         :\n        case V_CMPS_NLE_F32         :\n        case V_CMPS_NEQ_F32         :\n        case V_CMPS_NLT_F32         :\n        case V_CMPS_TRU_F32         :\n        case V_CMPSX_F_F32          :\n        case V_CMPSX_LT_F32         :\n        case V_CMPSX_EQ_F32         :\n        case V_CMPSX_LE_F32         :\n        case V_CMPSX_GT_F32         :\n        case V_CMPSX_LG_F32         :\n        case V_CMPSX_GE_F32         :\n        case V_CMPSX_O_F32          :\n        case V_CMPSX_U_F32          :\n        case V_CMPSX_NGE_F32        :\n        case V_CMPSX_NLG_F32        :\n        case V_CMPSX_NGT_F32        :\n        case V_CMPSX_NLE_F32        :\n        case V_CMPSX_NEQ_F32        :\n        case V_CMPSX_NLT_F32        :\n        case V_CMPSX_TRU_F32        :\n        case V_CMPS_F_F64           :\n        case V_CMPS_LT_F64          :\n        case V_CMPS_EQ_F64          :\n        case V_CMPS_LE_F64          :\n        case V_CMPS_GT_F64          :\n        case V_CMPS_LG_F64          :\n        case V_CMPS_GE_F64          :\n        case V_CMPS_O_F64           :\n        case V_CMPS_U_F64           :\n        case V_CMPS_NGE_F64         :\n        case V_CMPS_NLG_F64         :\n        case V_CMPS_NGT_F64         :\n        case V_CMPS_NLE_F64         :\n        case V_CMPS_NEQ_F64         :\n        case V_CMPS_NLT_F64         :\n        case V_CMPS_TRU_F64         :\n        case V_CMPSX_F_F64          :\n        case V_CMPSX_LT_F64         :\n        case V_CMPSX_EQ_F64         :\n        case V_CMPSX_LE_F64         :\n        case V_CMPSX_GT_F64         :\n        case V_CMPSX_LG_F64         :\n        case V_CMPSX_GE_F64         :\n        case V_CMPSX_O_F64          :\n        case V_CMPSX_U_F64          :\n        case V_CMPSX_NGE_F64        :\n        case V_CMPSX_NLG_F64        :\n        case V_CMPSX_NGT_F64        :\n        case V_CMPSX_NLE_F64        :\n        case V_CMPSX_NEQ_F64        :\n        case V_CMPSX_NLT_F64        :\n        case V_CMPSX_TRU_F64        :\n        case V_CMP_F_I32            :\n        case V_CMP_LT_I32           :\n        case V_CMP_EQ_I32           :\n        case V_CMP_LE_I32           :\n        case V_CMP_GT_I32           :\n        case V_CMP_LG_I32           :\n        case V_CMP_GE_I32           :\n        case V_CMP_TRU_I32          :\n        case V_CMPX_F_I32           :\n        case V_CMPX_LT_I32          :\n        case V_CMPX_EQ_I32          :\n        case V_CMPX_LE_I32          :\n        case V_CMPX_GT_I32          :\n        case V_CMPX_LG_I32          :\n        case V_CMPX_GE_I32          :\n        case V_CMPX_TRU_I32         :\n        case V_CMP_F_I64            :\n        case V_CMP_LT_I64           :\n        case V_CMP_EQ_I64           :\n        case V_CMP_LE_I64           :\n        case V_CMP_GT_I64           :\n        case V_CMP_LG_I64           :\n        case V_CMP_GE_I64           :\n        case V_CMP_TRU_I64          :\n        case V_CMPX_F_I64           :\n        case V_CMPX_LT_I64          :\n        case V_CMPX_EQ_I64          :\n        case V_CMPX_LE_I64          :\n        case V_CMPX_GT_I64          :\n        case V_CMPX_LG_I64          :\n        case V_CMPX_GE_I64          :\n        case V_CMPX_TRU_I64         :\n        case V_CMP_F_U32            :\n        case V_CMP_LT_U32           :\n        case V_CMP_EQ_U32           :\n        case V_CMP_LE_U32           :\n        case V_CMP_GT_U32           :\n        case V_CMP_LG_U32           :\n        case V_CMP_GE_U32           :\n        case V_CMP_TRU_U32          :\n        case V_CMPX_F_U32           :\n        case V_CMPX_LT_U32          :\n        case V_CMPX_EQ_U32          :\n        case V_CMPX_LE_U32          :\n        case V_CMPX_GT_U32          :\n        case V_CMPX_LG_U32          :\n        case V_CMPX_GE_U32          :\n        case V_CMPX_TRU_U32         :\n        case V_CMP_F_U64            :\n        case V_CMP_LT_U64           :\n        case V_CMP_EQ_U64           :\n        case V_CMP_LE_U64           :\n        case V_CMP_GT_U64           :\n        case V_CMP_LG_U64           :\n        case V_CMP_GE_U64           :\n        case V_CMP_TRU_U64          :\n        case V_CMPx_F_U64           :\n        case V_CMPx_LT_U64          :\n        case V_CMPx_EQ_U64          :\n        case V_CMPx_LE_U64          :\n        case V_CMPx_GT_U64          :\n        case V_CMPx_LG_U64          :\n        case V_CMPx_GE_U64          :\n        case V_CMPx_TRU_U64         :\n        case V_CMP_CLASS_F32        :\n        case V_CMPX_CLASS_F32       :\n        case V_CMP_CLASS_F64        :\n        case V_CMPX_CLASS_F64       :\n\n        case V_CMP_F_F16         :\n        case V_CMP_LT_F16        :\n        case V_CMP_EQ_F16        :\n        case V_CMP_LE_F16        :\n        case V_CMP_GT_F16        :\n        case V_CMP_LG_F16        :\n        case V_CMP_GE_F16        :\n        case V_CMP_O_F16         :\n        case V_CMP_U_F16         :\n        case V_CMP_NGE_F16       :\n        case V_CMP_NLG_F16       :\n        case V_CMP_NGT_F16       :\n        case V_CMP_NLE_F16       :\n        case V_CMP_NEQ_F16       :\n        case V_CMP_NLT_F16       :\n        case V_CMP_TRU_F16       :\n        case V_CMPX_F_F16        :\n        case V_CMPX_LT_F16       :\n        case V_CMPX_EQ_F16       :\n        case V_CMPX_LE_F16       :\n        case V_CMPX_GT_F16       :\n        case V_CMPX_LG_F16       :\n        case V_CMPX_GE_F16       :\n        case V_CMPX_O_F16        :\n        case V_CMPX_U_F16        :\n        case V_CMPX_NGE_F16      :\n        case V_CMPX_NLG_F16      :\n        case V_CMPX_NGT_F16      :\n        case V_CMPX_NLE_F16      :\n        case V_CMPX_NEQ_F16      :\n        case V_CMPX_NLT_F16      :\n        case V_CMPX_TRU_F16      :\n        case V_CMP_F_U16         :\n        case V_CMP_LT_U16        :\n        case V_CMP_EQ_U16        :\n        case V_CMP_LE_U16        :\n        case V_CMP_GT_U16        :\n        case V_CMP_LG_U16        :\n        case V_CMP_GE_U16        :\n        case V_CMP_TRU_U16       :\n        case V_CMPx_F_U16        :\n        case V_CMPx_LT_U16       :\n        case V_CMPx_EQ_U16       :\n        case V_CMPx_LE_U16       :\n        case V_CMPx_GT_U16       :\n        case V_CMPx_LG_U16       :\n        case V_CMPx_GE_U16       :\n        case V_CMPx_TRU_U16      :\n        case V_CMP_F_I16         :\n        case V_CMP_LT_I16        :\n        case V_CMP_EQ_I16        :\n        case V_CMP_LE_I16        :\n        case V_CMP_GT_I16        :\n        case V_CMP_LG_I16        :\n        case V_CMP_GE_I16        :\n        case V_CMP_TRU_I16       :\n        case V_CMPx_F_I16        :\n        case V_CMPx_LT_I16       :\n        case V_CMPx_EQ_I16       :\n        case V_CMPx_LE_I16       :\n        case V_CMPx_GT_I16       :\n        case V_CMPx_LG_I16       :\n        case V_CMPx_GE_I16       :\n        case V_CMPx_TRU_I16      :\n        case V_CMP_CLASS_F16:\n        case V_CMPX_CLASS_F16:\n            return 2;\n\n        case V_MOV_B32                 :\n        case V_READFIRSTLANE_B32       :                                        \n        case V_CVT_I32_F64             :\n        case V_CVT_F64_I32             :\n        case V_CVT_F32_I32             :\n        case V_CVT_F32_U32             :\n        case V_CVT_U32_F32             :\n        case V_CVT_I32_F32             :\n        case V_MOV_FED_B32             :\n        case V_CVT_F16_F32             :\n        case V_CVT_F32_F16             :\n        case V_CVT_RPI_I32_F32         :\n        case V_CVT_FLR_I32_F32         :\n        case V_CVT_OFF_F32_I4          :\n        case V_CVT_F32_F64             :\n        case V_CVT_F64_F32             :\n        case V_CVT_F32_UBYTE0          :\n        case V_CVT_F32_UBYTE1          :\n        case V_CVT_F32_UBYTE2          :\n        case V_CVT_F32_UBYTE3          :\n        case V_CVT_U32_F64             :\n        case V_CVT_F64_U32             :\n        case V_TRUNC_F64               :\n        case V_CEIL_F64                :\n        case V_RNDNE_F64               :\n        case V_FLOOR_F64               :\n        case V_FRACT_F32               :\n        case V_TRUNC_F32               :\n        case V_CEIL_F32                :\n        case V_RNDNE_F32               :\n        case V_FLOOR_F32               :\n        case V_EXP_F32                 :\n        case V_LOG_CLAMP_F32           :\n        case V_LOG_F32                 :\n        case V_RCP_CLAMP_F32           :\n        case V_RCP_LEGACY_F32          :\n        case V_RCP_F32                 :\n        case V_RCP_IFLAG_F32           :\n        case V_RSQ_CLAMP_F32           :\n        case V_RSQ_LEGACY_F32          :\n        case V_RSQ_F32                 :\n        case V_RCP_F64                 :\n        case V_RCP_CLAMP_F64           :\n        case V_RSQ_F64                 :\n        case V_RSQ_CLAMP_F64           :\n        case V_SQRT_F32                :\n        case V_SQRT_F64                :\n        case V_SIN_F32                 :\n        case V_COS_F32                 :\n        case V_NOT_B32                 :\n        case V_BFREV_B32               :\n        case V_FFBH_U32                :\n        case V_FFBL_B32                :\n        case V_FFBH_I32                :\n        case V_FREXP_EXP_I32_F64       :\n        case V_FREXP_MANT_F64          :\n        case V_FRACT_F64               :\n        case V_FREXP_EXP_I32_F32       :                 \n        case V_FREXP_MANT_F32          :\n        case V_MOVRELD_B32             :\n        case V_MOVRELS_B32             :\n        case V_MOVRELSD_B32            :\n        case V_LOG_LEGACY_F32          :\n        case V_EXP_LEGACY_F32          :\n            return 1;\n\n        case V_MULLIT_F32       :   //  = D.f = S0.f * S1.f, replicate result into 4 components (0.0 * x = 0.0; special INF, NaN, overflow rules).\n        case V_LSHL_B64         :   //  = D = S0.u << S1.u[4:0].\n        case V_LSHR_B64         :   //  = D = S0.u >> S1.u[4:0].\n        case V_ASHR_I64         :   //  = D = S0.u >> S1.u[4:0].\n        case V_ADD_F64          :   //  = D.d = S0.d + S1.d.\n        case V_MUL_F64          :   //  = D.d = S0.d * S1.d.\n        case V_MIN_F64          :   //  = D.d = min(S0.d, S1.d).\n        case V_MAX_F64          :   //  = D.d = max(S0.d, S1.d).\n        case V_LDEXP_F64        :   //  = D.d = pow(S0.d, S1.i[31:0]).\n        case V_MUL_LO_U32       :   //  = D.u = S0.u * S1.u.\n        case V_MUL_HI_U32       :   //  = D.u = (S0.u * S1.u)>>32.\n        case V_MUL_LO_I32       :   //  = D.i = S0.i * S1.i.\n        case V_MUL_HI_I32       :   //  = D.i = (S0.i * S1.i)>>32.\n        case V_TRIG_PREOP_F64  : // = D.d = Look Up 2/PI (S0.d) with segment select  S1.u[4:0].\n            return 2;\n\n        case V_DIV_SCALE_F32    :    //  = D.f = Special case divide preop and flags(s0.f = Quotient,s1.f = Denominator, s2.f = Numerator) s0 must equal s1 or s2.\n        case V_DIV_SCALE_F64    :    //  = D.d = Special case divide preop and flags(s0.d = Quotient,s1.d = Denominator, s2.d = Numerator) s0 must equal s1 or s2.\n        case V_MAD_LEGACY_F32   :   //   = D.f = S0.f * S1.f + S2.f (DX9 rules, 0.0*x = 0.0).\n        case V_MAD_F32          :   //   = D.f = S0.f * S1.f + S2.f.\n        case V_MAD_I32_I24      :   //   = D.i = S0.i * S1.i + S2.iD.i = S0.i * S1.i + S2.i.\n        case V_MAD_U32_U24      :   //   = D.u = S0.u * S1.u + S2.u.\n        case V_CUBEID_F32       :   //   = Rm.w <- Rn,x, Rn,y, Rn.z.\n        case V_CUBESC_F32       :   //   = Rm.y <- Rn,x, Rn,y, Rn.z.\n        case V_CUBETC_F32       :   //   = Rm.x <- Rn,x, Rn,y, Rn.z.\n        case V_CUBEMA_F32       :   //   = Rm.z <- Rn,x, Rn,y, Rn.z\n        case V_BFE_U32          :   //   = D.u = (S0.u>>S1.u[4:0]) & ((1<<S2.u[4:0])-1); bitfield extract,S0=data, S1=field_offset, S2=field_width.\n        case V_BFE_I32          :   //   = D.i = (S0.i>>S1.u[4:0]) & ((1<<S2.u[4:0])-1); bitfield extract, S0=data, S1=field_offset, S2=field_width.\n        case V_BFI_B32          :   //   = D.u = (S0.u & S1.u) | (~S0.u & S2.u); bitfield insert.\n        case V_FMA_F32          :   //   = D.f = S0.f * S1.f + S2.f\n        case V_FMA_F64          :   //   = D.d = S0.d * S1.d + S2.d.\n        case V_LERP_U8          :   //  = D.u = ((S0.u[31:24] + S1.u[31:24] + S2.u[24]) >> 1) << 24 +\n        case V_ALIGNBIT_B32     :   //  = D.u = ({S0,S1} >> S2.u[4:0]) & 0xFFFFFFFF.\n        case V_ALIGNBYTE_B32    :   //  = D.u = ({S0,S1} >> (8*S2.u[4:0])) & 0xFFFFFFFF.\n        case V_MIN3_F32         :   //  = D.f = min(S0.f, S1.f, S2.f).\n        case V_MIN3_I32         :   //  = D.i = min(S0.i, S1.i, S2.i).\n        case V_MIN3_U32         :   //  = 0x153 D.u = min(S0.u, S1.u, S2.u).\n        case V_MAX3_F32         :   //  = D.f = max(S0.f, S1.f, S2.f).\n        case V_MAX3_I32         :   //  = D.i = max(S0.i, S1.i, S2.i).\n        case V_MAX3_U32         :   //  = D.u = max(S0.u, S1.u, S2.u).\n        case V_MED3_F32         :   //  = D.f = median(S0.f, S1.f, S2.f).\n        case V_MED3_I32         :   //  = D.i = median(S0.i, S1.i, S2.i).\n        case V_MED3_U32         :   //  = D.u = median(S0.u, S1.u, S2.u).\n        case V_SAD_U8           :   //  = D.u = Byte SAD with accum_lo(S0.u, S1.u, S2.u).\n        case V_SAD_HI_U8        :   //  = D.u = Byte SAD with accum_hi(S0.u, S1.u, S2.u).\n        case V_SAD_U16          :   //  = D.u = Word SAD with accum(S0.u, S1.u, S2.u).\n        case V_SAD_U32          :   //  = D.u = Dword SAD with accum(S0.u, S1.u, S2.u).\n        case V_CVT_PK_U8_F32    :   //  = f32->u8(s0.f), pack into byte(s1.u), of dword(s2).\n        case V_DIV_FIXUP_F32    :   //  = D.f = Special case divide fixup and flags(s0.f = Quotient,   s1.f = Denominator, s2.f = Numerator).\n        case V_DIV_FIXUP_F64    :   //  = D.d = Special case divide fixup and flags(s0.d = Quotient,  s1.d = Denominator, s2.d = Numerator).\n        case V_DIV_FMAS_F32     : // = D.f = Special case divide FMA with scale and flags(s0.f = Quotient, s1.f = Denominator, s2.f = Numerator).\n        case V_DIV_FMAS_F64     : // = D.d = Special case divide FMA with scale and flags(s0.d= Quotient, s1.d = Denominator, s2.d = Numerator).\n        case V_MSAD_U8          : // = D.u = Masked Byte SAD with accum_lo(S0.u, S1.u, S2.u).\n        case V_QSAD_U8          : // = D.u = Quad-Byte SAD with accum_lo/hiu(S0.u[63:0], S1.u[31:0], S2.u[63:0]).\n        case V_MQSAD_U8         : // = D.u = Masked Quad-Byte SAD with accum_lo/hi(S0.u[63:0],S1.u[31:0], S2.u[63:0]).       \n        case V_QSAD_PK_U16_U8   : // : D.u = Quad-Byte SAD with accum_lo/hiu(S0.u[63:0], S1.u[31:0], S2.u[63:0]).\n        case V_MQSAD_PK_U16_U8  : // = D.u = Masked Quad-Byte SAD with accum_lo/hi(S0.u[63:0], S1.u[31:0], S2.u[63:0]).\n        case V_MQSAD_U32_U8     :  // : D.u128 = Masked Quad-Byte SAD with 32-bit accum_lo/hi(S0.u[63:0], S1.u[31:0], S2.u[127:0]).\n        case V_MAD_U64_U32      :  // : {vcc_out,D.u64} = S0.u32 * S1.u32 + S2.u64.\n        case V_MAD_I64_I32      :  // : {vcc_out,D.i64} = S0.i32 * S1.i32 + S2.i64.\n            return 3;\n\n        case V_INTERP_P1_F32  :\n        case V_INTERP_P2_F32  :\n        case V_INTERP_MOV_F32 :\n        case V_INTERP_P1LL_F16:\n        case V_INTERP_P1LV_F16:\n        case V_INTERP_P2_F16  :\n            return 1;\n        }\n    }\n\n\n\n\n    uint GetResultWidthInDWORDs( VectorInstructions e )\n    {\n        switch( e )\n        {\n        default: return 0;\n        case V_ADD_U32:\n        case V_SUB_U32:\n        case V_SUBREV_U32:\n            return 1;\n\n        case V_LSHLREV_B64:\n        case V_LSHRREV_B64:\n        case V_ASHRREV_I64:\n            return 2;\n                \n        case V_MAD_F16           : \n        case V_MAD_U16           : \n        case V_MAD_I16           : \n        case V_PERM_B32          : \n        case V_FMA_F16           : \n        case V_DIV_FIXUP_F16     : \n        case V_ADD_F16          :   \n        case V_SUB_F16          :   \n        case V_SUBREV_F16       :   \n        case V_MUL_F16          :   \n        case V_MAC_F16          :   \n        case V_MADMK_F16        :   \n        case V_MADAK_F16        :   \n        case V_ADD_U16          :   \n        case V_SUB_U16          :   \n        case V_SUBREV_U16       :   \n        case V_MUL_LO_U16       :   \n        case V_LSHLREV_B16      :   \n        case V_LSHRREV_B16      :   \n        case V_ASHRREV_I16      :   \n        case V_MAX_F16          :   \n        case V_MIN_F16          :   \n        case V_MAX_U16          :   \n        case V_MAX_I16          :   \n        case V_MIN_U16          :   \n        case V_MIN_I16          :   \n        case V_LDEXP_F16        :   \n        case V_CVT_F16_U16            :\n        case V_CVT_F16_I16            :\n        case V_CVT_U16_F16            :\n        case V_CVT_I16_F16            :\n        case V_RCP_F16                :\n        case V_SQRT_F16               :\n        case V_RSQ_F16                :\n        case V_LOG_F16                :\n        case V_EXP_F16                :\n        case V_FREXP_MANT_F16         :\n        case V_FREXP_EXP_I16_F16      :\n        case V_FLOOR_F16              :\n        case V_CEIL_F16               :\n        case V_TRUNC_F16              :\n        case V_RNDNE_F16              :\n        case V_FRACT_F16              :\n        case V_SIN_F16                :\n        case V_COS_F16                :\n        case V_CNDMASK_B32              :\n        case V_READLANE_B32             :                          \n        case V_WRITELANE_B32            :\n        case V_ADD_F32                  :\n        case V_SUB_F32                  :\n        case V_SUBREV_F32               :\n        case V_MAC_LEGACY_F32           :\n        case V_MUL_LEGACY_F32           :\n        case V_MUL_F32                  :\n        case V_MUL_I32_I24              :\n        case V_MUL_HI_I32_I24           :\n        case V_MUL_U32_U24              :\n        case V_MUL_HI_U32_U24           :\n        case V_MIN_LEGACY_F32           :\n        case V_MAX_LEGACY_F32           :\n        case V_MIN_F32                  :\n        case V_MAX_F32                  :\n        case V_MIN_I32                  :\n        case V_MAX_I32                  :\n        case V_MIN_U32                  :\n        case V_MAX_U32                  :\n        case V_LSHR_B32                 :\n        case V_LSHRREV_B32              :\n        case V_ASHR_I32                 :\n        case V_ASHRREV_I32              :\n        case V_LSHL_B32                 :\n        case V_LSHLREV_B32              :\n        case V_AND_B32                  :\n        case V_OR_B32                   :\n        case V_XOR_B32                  :\n        case V_BFM_B32                  :\n        case V_MAC_F32                  :\n        case V_MADMK_F32                :\n        case V_MADAK_F32                :\n        case V_BCNT_U32_B32             :\n        case V_MBCNT_LO_U32_B32         :                                                          \n        case V_MBCNT_HI_U32_B32         :                    \n        case V_ADD_I32                  :\n        case V_SUB_I32                  :\n        case V_SUBREV_I32               :\n        case V_ADDC_U32                 :\n        case V_SUBB_U32                 :\n        case V_SUBBREV_U32              :\n        case V_LDEXP_F32                :\n        case V_CVT_PKACCUM_U8_F32       :\n        case V_CVT_PKNORM_I16_F32       :\n        case V_CVT_PKNORM_U16_F32       :\n        case V_CVT_PKRTZ_F16_F32        :\n        case V_CVT_PK_U16_U32           :\n        case V_CVT_PK_I16_I32           :\n            return 1;\n\n        case V_CMP_CLASS_F16:\n        case V_CMPX_CLASS_F16:\n        case V_CMP_F_F32            :\n        case V_CMP_LT_F32           :\n        case V_CMP_EQ_F32           :\n        case V_CMP_LE_F32           :\n        case V_CMP_GT_F32           :\n        case V_CMP_LG_F32           :\n        case V_CMP_GE_F32           :\n        case V_CMP_O_F32            :\n        case V_CMP_U_F32            :\n        case V_CMP_NGE_F32          :\n        case V_CMP_NLG_F32          :\n        case V_CMP_NGT_F32          :\n        case V_CMP_NLE_F32          :\n        case V_CMP_NEQ_F32          :\n        case V_CMP_NLT_F32          :\n        case V_CMP_TRU_F32          :\n        case V_CMPX_F_F32           :\n        case V_CMPX_LT_F32          :\n        case V_CMPX_EQ_F32          :\n        case V_CMPX_LE_F32          :\n        case V_CMPX_GT_F32          :\n        case V_CMPX_LG_F32          :\n        case V_CMPX_GE_F32          :\n        case V_CMPX_O_F32           :\n        case V_CMPX_U_F32           :\n        case V_CMPX_NGE_F32         :\n        case V_CMPX_NLG_F32         :\n        case V_CMPX_NGT_F32         :\n        case V_CMPX_NLE_F32         :\n        case V_CMPX_NEQ_F32         :\n        case V_CMPX_NLT_F32         :\n        case V_CMPX_TRU_F32         :\n        case V_CMP_F_F64            :\n        case V_CMP_LT_F64           :\n        case V_CMP_EQ_F64           :\n        case V_CMP_LE_F64           :\n        case V_CMP_GT_F64           :\n        case V_CMP_LG_F64           :\n        case V_CMP_GE_F64           :\n        case V_CMP_O_F64            :\n        case V_CMP_U_F64            :\n        case V_CMP_NGE_F64          :\n        case V_CMP_NLG_F64          :\n        case V_CMP_NGT_F64          :\n        case V_CMP_NLE_F64          :\n        case V_CMP_NEQ_F64          :\n        case V_CMP_NLT_F64          :\n        case V_CMP_TRU_F64          :\n        case V_CMPX_F_F64           :\n        case V_CMPX_LT_F64          :\n        case V_CMPX_EQ_F64          :\n        case V_CMPX_LE_F64          :\n        case V_CMPX_GT_F64          :\n        case V_CMPX_LG_F64          :\n        case V_CMPX_GE_F64          :\n        case V_CMPX_O_F64           :\n        case V_CMPX_U_F64           :\n        case V_CMPX_NGE_F64         :\n        case V_CMPX_NLG_F64         :\n        case V_CMPX_NGT_F64         :\n        case V_CMPX_NLE_F64         :\n        case V_CMPX_NEQ_F64         :\n        case V_CMPX_NLT_F64         :\n        case V_CMPX_TRU_F64         :\n        case V_CMPS_F_F32           :\n        case V_CMPS_LT_F32          :\n        case V_CMPS_EQ_F32          :\n        case V_CMPS_LE_F32          :\n        case V_CMPS_GT_F32          :\n        case V_CMPS_LG_F32          :\n        case V_CMPS_GE_F32          :\n        case V_CMPS_O_F32           :\n        case V_CMPS_U_F32           :\n        case V_CMPS_NGE_F32         :\n        case V_CMPS_NLG_F32         :\n        case V_CMPS_NGT_F32         :\n        case V_CMPS_NLE_F32         :\n        case V_CMPS_NEQ_F32         :\n        case V_CMPS_NLT_F32         :\n        case V_CMPS_TRU_F32         :\n        case V_CMPSX_F_F32          :\n        case V_CMPSX_LT_F32         :\n        case V_CMPSX_EQ_F32         :\n        case V_CMPSX_LE_F32         :\n        case V_CMPSX_GT_F32         :\n        case V_CMPSX_LG_F32         :\n        case V_CMPSX_GE_F32         :\n        case V_CMPSX_O_F32          :\n        case V_CMPSX_U_F32          :\n        case V_CMPSX_NGE_F32        :\n        case V_CMPSX_NLG_F32        :\n        case V_CMPSX_NGT_F32        :\n        case V_CMPSX_NLE_F32        :\n        case V_CMPSX_NEQ_F32        :\n        case V_CMPSX_NLT_F32        :\n        case V_CMPSX_TRU_F32        :\n        case V_CMPS_F_F64           :\n        case V_CMPS_LT_F64          :\n        case V_CMPS_EQ_F64          :\n        case V_CMPS_LE_F64          :\n        case V_CMPS_GT_F64          :\n        case V_CMPS_LG_F64          :\n        case V_CMPS_GE_F64          :\n        case V_CMPS_O_F64           :\n        case V_CMPS_U_F64           :\n        case V_CMPS_NGE_F64         :\n        case V_CMPS_NLG_F64         :\n        case V_CMPS_NGT_F64         :\n        case V_CMPS_NLE_F64         :\n        case V_CMPS_NEQ_F64         :\n        case V_CMPS_NLT_F64         :\n        case V_CMPS_TRU_F64         :\n        case V_CMPSX_F_F64          :\n        case V_CMPSX_LT_F64         :\n        case V_CMPSX_EQ_F64         :\n        case V_CMPSX_LE_F64         :\n        case V_CMPSX_GT_F64         :\n        case V_CMPSX_LG_F64         :\n        case V_CMPSX_GE_F64         :\n        case V_CMPSX_O_F64          :\n        case V_CMPSX_U_F64          :\n        case V_CMPSX_NGE_F64        :\n        case V_CMPSX_NLG_F64        :\n        case V_CMPSX_NGT_F64        :\n        case V_CMPSX_NLE_F64        :\n        case V_CMPSX_NEQ_F64        :\n        case V_CMPSX_NLT_F64        :\n        case V_CMPSX_TRU_F64        :\n        case V_CMP_F_I32            :\n        case V_CMP_LT_I32           :\n        case V_CMP_EQ_I32           :\n        case V_CMP_LE_I32           :\n        case V_CMP_GT_I32           :\n        case V_CMP_LG_I32           :\n        case V_CMP_GE_I32           :\n        case V_CMP_TRU_I32          :\n        case V_CMPX_F_I32           :\n        case V_CMPX_LT_I32          :\n        case V_CMPX_EQ_I32          :\n        case V_CMPX_LE_I32          :\n        case V_CMPX_GT_I32          :\n        case V_CMPX_LG_I32          :\n        case V_CMPX_GE_I32          :\n        case V_CMPX_TRU_I32         :\n        case V_CMP_F_I64            :\n        case V_CMP_LT_I64           :\n        case V_CMP_EQ_I64           :\n        case V_CMP_LE_I64           :\n        case V_CMP_GT_I64           :\n        case V_CMP_LG_I64           :\n        case V_CMP_GE_I64           :\n        case V_CMP_TRU_I64          :\n        case V_CMPX_F_I64           :\n        case V_CMPX_LT_I64          :\n        case V_CMPX_EQ_I64          :\n        case V_CMPX_LE_I64          :\n        case V_CMPX_GT_I64          :\n        case V_CMPX_LG_I64          :\n        case V_CMPX_GE_I64          :\n        case V_CMPX_TRU_I64         :\n        case V_CMP_F_U32            :\n        case V_CMP_LT_U32           :\n        case V_CMP_EQ_U32           :\n        case V_CMP_LE_U32           :\n        case V_CMP_GT_U32           :\n        case V_CMP_LG_U32           :\n        case V_CMP_GE_U32           :\n        case V_CMP_TRU_U32          :\n        case V_CMPX_F_U32           :\n        case V_CMPX_LT_U32          :\n        case V_CMPX_EQ_U32          :\n        case V_CMPX_LE_U32          :\n        case V_CMPX_GT_U32          :\n        case V_CMPX_LG_U32          :\n        case V_CMPX_GE_U32          :\n        case V_CMPX_TRU_U32         :\n        case V_CMP_F_U64            :\n        case V_CMP_LT_U64           :\n        case V_CMP_EQ_U64           :\n        case V_CMP_LE_U64           :\n        case V_CMP_GT_U64           :\n        case V_CMP_LG_U64           :\n        case V_CMP_GE_U64           :\n        case V_CMP_TRU_U64          :\n        case V_CMPx_F_U64           :\n        case V_CMPx_LT_U64          :\n        case V_CMPx_EQ_U64          :\n        case V_CMPx_LE_U64          :\n        case V_CMPx_GT_U64          :\n        case V_CMPx_LG_U64          :\n        case V_CMPx_GE_U64          :\n        case V_CMPx_TRU_U64         :\n        case V_CMP_CLASS_F32        :\n        case V_CMPX_CLASS_F32       :\n        case V_CMP_CLASS_F64        :\n        case V_CMPX_CLASS_F64       :\n        case V_CMP_F_F16       :\n        case V_CMP_LT_F16      :\n        case V_CMP_EQ_F16      :\n        case V_CMP_LE_F16      :\n        case V_CMP_GT_F16      :\n        case V_CMP_LG_F16      :\n        case V_CMP_GE_F16      :\n        case V_CMP_O_F16       :\n        case V_CMP_U_F16       :\n        case V_CMP_NGE_F16     :\n        case V_CMP_NLG_F16     :\n        case V_CMP_NGT_F16     :\n        case V_CMP_NLE_F16     :\n        case V_CMP_NEQ_F16     :\n        case V_CMP_NLT_F16     :\n        case V_CMP_TRU_F16     :\n        case V_CMPX_F_F16      :\n        case V_CMPX_LT_F16     :\n        case V_CMPX_EQ_F16     :\n        case V_CMPX_LE_F16     :\n        case V_CMPX_GT_F16     :\n        case V_CMPX_LG_F16     :\n        case V_CMPX_GE_F16     :\n        case V_CMPX_O_F16      :\n        case V_CMPX_U_F16      :\n        case V_CMPX_NGE_F16    :\n        case V_CMPX_NLG_F16    :\n        case V_CMPX_NGT_F16    :\n        case V_CMPX_NLE_F16    :\n        case V_CMPX_NEQ_F16    :\n        case V_CMPX_NLT_F16    :\n        case V_CMPX_TRU_F16    :\n        case V_CMP_F_U16       :\n        case V_CMP_LT_U16      :\n        case V_CMP_EQ_U16      :\n        case V_CMP_LE_U16      :\n        case V_CMP_GT_U16      :\n        case V_CMP_LG_U16      :\n        case V_CMP_GE_U16      :\n        case V_CMP_TRU_U16     :\n        case V_CMPx_F_U16      :\n        case V_CMPx_LT_U16     :\n        case V_CMPx_EQ_U16     :\n        case V_CMPx_LE_U16     :\n        case V_CMPx_GT_U16     :\n        case V_CMPx_LG_U16     :\n        case V_CMPx_GE_U16     :\n        case V_CMPx_TRU_U16    :\n        case V_CMP_F_I16       :\n        case V_CMP_LT_I16      :\n        case V_CMP_EQ_I16      :\n        case V_CMP_LE_I16      :\n        case V_CMP_GT_I16      :\n        case V_CMP_LG_I16      :\n        case V_CMP_GE_I16      :\n        case V_CMP_TRU_I16     :\n        case V_CMPx_F_I16      :\n        case V_CMPx_LT_I16     :\n        case V_CMPx_EQ_I16     :\n        case V_CMPx_LE_I16     :\n        case V_CMPx_GT_I16     :\n        case V_CMPx_LG_I16     :\n        case V_CMPx_GE_I16     :\n        case V_CMPx_TRU_I16    :\n            return 2;\n\n        case V_MOV_B32                 :\n        case V_READFIRSTLANE_B32       :                                        \n        case V_CVT_I32_F64             :\n        case V_CVT_F32_I32             :\n        case V_CVT_F32_U32             :\n        case V_CVT_U32_F32             :\n        case V_CVT_I32_F32             :\n        case V_MOV_FED_B32             :\n        case V_CVT_F16_F32             :\n        case V_CVT_F32_F16             :\n        case V_CVT_RPI_I32_F32         :\n        case V_CVT_FLR_I32_F32         :\n        case V_CVT_OFF_F32_I4          :\n        case V_CVT_F32_F64             :\n        case V_CVT_F32_UBYTE0          :\n        case V_CVT_F32_UBYTE1          :\n        case V_CVT_F32_UBYTE2          :\n        case V_CVT_F32_UBYTE3          :\n        case V_CVT_U32_F64             :\n        case V_FRACT_F32               :\n        case V_TRUNC_F32               :\n        case V_CEIL_F32                :\n        case V_RNDNE_F32               :\n        case V_FLOOR_F32               :\n        case V_EXP_F32                 :\n        case V_LOG_CLAMP_F32           :\n        case V_LOG_F32                 :\n        case V_RCP_CLAMP_F32           :\n        case V_RCP_LEGACY_F32          :\n        case V_RCP_F32                 :\n        case V_RCP_IFLAG_F32           :\n        case V_RSQ_CLAMP_F32           :\n        case V_RSQ_LEGACY_F32          :\n        case V_RSQ_F32                 :\n        case V_SQRT_F32                :\n        case V_SIN_F32                 :\n        case V_COS_F32                 :\n        case V_NOT_B32                 :\n        case V_BFREV_B32               :\n        case V_FFBH_U32                :\n        case V_FFBL_B32                :\n        case V_FFBH_I32                :\n        case V_FREXP_EXP_I32_F64       :\n        case V_FREXP_EXP_I32_F32       :                 \n        case V_FREXP_MANT_F32          :\n        case V_MOVRELD_B32             :\n        case V_MOVRELS_B32             :\n        case V_MOVRELSD_B32            :\n        case V_LOG_LEGACY_F32          :\n        case V_EXP_LEGACY_F32          :\n        case V_MULLIT_F32       :   //  = D.f = S0.f * S1.f, replicate result into 4 components (0.0 * x = 0.0; special INF, NaN, overflow rules).\n        case V_MUL_LO_U32       :   //  = D.u = S0.u * S1.u.\n        case V_MUL_HI_U32       :   //  = D.u = (S0.u * S1.u)>>32.\n        case V_MUL_LO_I32       :   //  = D.i = S0.i * S1.i.\n        case V_MUL_HI_I32       :   //  = D.i = (S0.i * S1.i)>>32.\n        case V_DIV_SCALE_F64    :    //  = D.d = Special case divide preop and flags(s0.d = Quotient,s1.d = Denominator, s2.d = Numerator) s0 must equal s1 or s2.\n        case V_MAD_LEGACY_F32   :   //   = D.f = S0.f * S1.f + S2.f (DX9 rules, 0.0*x = 0.0).\n        case V_MAD_F32          :   //   = D.f = S0.f * S1.f + S2.f.\n        case V_MAD_I32_I24      :   //   = D.i = S0.i * S1.i + S2.iD.i = S0.i * S1.i + S2.i.\n        case V_MAD_U32_U24      :   //   = D.u = S0.u * S1.u + S2.u.\n        case V_CUBEID_F32       :   //   = Rm.w <- Rn,x, Rn,y, Rn.z.\n        case V_CUBESC_F32       :   //   = Rm.y <- Rn,x, Rn,y, Rn.z.\n        case V_CUBETC_F32       :   //   = Rm.x <- Rn,x, Rn,y, Rn.z.\n        case V_CUBEMA_F32       :   //   = Rm.z <- Rn,x, Rn,y, Rn.z\n        case V_BFE_U32          :   //   = D.u = (S0.u>>S1.u[4:0]) & ((1<<S2.u[4:0])-1); bitfield extract,S0=data, S1=field_offset, S2=field_width.\n        case V_BFE_I32          :   //   = D.i = (S0.i>>S1.u[4:0]) & ((1<<S2.u[4:0])-1); bitfield extract, S0=data, S1=field_offset, S2=field_width.\n        case V_BFI_B32          :   //   = D.u = (S0.u & S1.u) | (~S0.u & S2.u); bitfield insert.\n        case V_FMA_F32          :   //   = D.f = S0.f * S1.f + S2.f\n             return 1;\n        \n        \n        case V_CVT_F64_I32             :\n        case V_CVT_F64_F32             :\n        case V_CVT_F64_U32             :\n        case V_TRUNC_F64               :\n        case V_CEIL_F64                :\n        case V_RNDNE_F64               :\n        case V_FLOOR_F64               :\n        case V_RCP_F64                 :\n        case V_RCP_CLAMP_F64           :\n        case V_RSQ_F64                 :\n        case V_RSQ_CLAMP_F64           :\n        case V_SQRT_F64                :\n        case V_FREXP_MANT_F64          :\n        case V_FRACT_F64               :\n        case V_LSHL_B64         :   //  = D = S0.u << S1.u[4:0].\n        case V_LSHR_B64         :   //  = D = S0.u >> S1.u[4:0].\n        case V_ASHR_I64         :   //  = D = S0.u >> S1.u[4:0].\n        case V_ADD_F64          :   //  = D.d = S0.d + S1.d.\n        case V_MUL_F64          :   //  = D.d = S0.d * S1.d.\n        case V_MIN_F64          :   //  = D.d = min(S0.d, S1.d).\n        case V_MAX_F64          :   //  = D.d = max(S0.d, S1.d).\n        case V_LDEXP_F64        :   //  = D.d = pow(S0.d, S1.i[31:0]).\n        case V_TRIG_PREOP_F64  : // = D.d = Look Up 2/PI (S0.d) with segment select  S1.u[4:0].\n        case V_FMA_F64          :   //   = D.d = S0.d * S1.d + S2.d.\n        case V_DIV_FIXUP_F64    :   //  = D.d = Special case divide fixup and flags(s0.d = Quotient,  s1.d = Denominator, s2.d = Numerator).\n        case V_DIV_FMAS_F64     : // = D.d = Special case divide FMA with scale and flags(s0.d= Quotient, s1.d = Denominator, s2.d = Numerator).\n            return 2;\n\n        case V_DIV_SCALE_F32    :    //  = D.f = Special case divide preop and flags(s0.f = Quotient,s1.f = Denominator, s2.f = Numerator) s0 must equal s1 or s2.\n        case V_LERP_U8          :   //  = D.u = ((S0.u[31:24] + S1.u[31:24] + S2.u[24]) >> 1) << 24 +\n        case V_ALIGNBIT_B32     :   //  = D.u = ({S0,S1} >> S2.u[4:0]) & 0xFFFFFFFF.\n        case V_ALIGNBYTE_B32    :   //  = D.u = ({S0,S1} >> (8*S2.u[4:0])) & 0xFFFFFFFF.\n        case V_MIN3_F32         :   //  = D.f = min(S0.f, S1.f, S2.f).\n        case V_MIN3_I32         :   //  = D.i = min(S0.i, S1.i, S2.i).\n        case V_MIN3_U32         :   //  = 0x153 D.u = min(S0.u, S1.u, S2.u).\n        case V_MAX3_F32         :   //  = D.f = max(S0.f, S1.f, S2.f).\n        case V_MAX3_I32         :   //  = D.i = max(S0.i, S1.i, S2.i).\n        case V_MAX3_U32         :   //  = D.u = max(S0.u, S1.u, S2.u).\n        case V_MED3_F32         :   //  = D.f = median(S0.f, S1.f, S2.f).\n        case V_MED3_I32         :   //  = D.i = median(S0.i, S1.i, S2.i).\n        case V_MED3_U32         :   //  = D.u = median(S0.u, S1.u, S2.u).\n        case V_SAD_U8           :   //  = D.u = Byte SAD with accum_lo(S0.u, S1.u, S2.u).\n        case V_SAD_HI_U8        :   //  = D.u = Byte SAD with accum_hi(S0.u, S1.u, S2.u).\n        case V_SAD_U16          :   //  = D.u = Word SAD with accum(S0.u, S1.u, S2.u).\n        case V_SAD_U32          :   //  = D.u = Dword SAD with accum(S0.u, S1.u, S2.u).\n        case V_CVT_PK_U8_F32    :   //  = f32->u8(s0.f), pack into byte(s1.u), of dword(s2).\n        case V_DIV_FIXUP_F32    :   //  = D.f = Special case divide fixup and flags(s0.f = Quotient,   s1.f = Denominator, s2.f = Numerator).\n        case V_DIV_FMAS_F32     : // = D.f = Special case divide FMA with scale and flags(s0.f = Quotient, s1.f = Denominator, s2.f = Numerator).\n        case V_MSAD_U8          : // = D.u = Masked Byte SAD with accum_lo(S0.u, S1.u, S2.u).\n        case V_QSAD_U8          : // = D.u = Quad-Byte SAD with accum_lo/hiu(S0.u[63:0], S1.u[31:0], S2.u[63:0]).\n        case V_MQSAD_U8         : // = D.u = Masked Quad-Byte SAD with accum_lo/hi(S0.u[63:0],S1.u[31:0], S2.u[63:0]).       \n        case V_QSAD_PK_U16_U8   : // : D.u = Quad-Byte SAD with accum_lo/hiu(S0.u[63:0], S1.u[31:0], S2.u[63:0]).\n        case V_MQSAD_PK_U16_U8  : // = D.u = Masked Quad-Byte SAD with accum_lo/hi(S0.u[63:0], S1.u[31:0], S2.u[63:0]).\n        case V_MQSAD_U32_U8     :  // : D.u128 = Masked Quad-Byte SAD with 32-bit accum_lo/hi(S0.u[63:0], S1.u[31:0], S2.u[127:0]).\n        case V_MAD_U64_U32      :  // : {vcc_out,D.u64} = S0.u32 * S1.u32 + S2.u64.\n        case V_MAD_I64_I32      :  // : {vcc_out,D.i64} = S0.i32 * S1.i32 + S2.i64.\n        case V_INTERP_P1_F32  :\n        case V_INTERP_P2_F32  :\n        case V_INTERP_MOV_F32 :\n        case V_INTERP_P1LL_F16:\n        case V_INTERP_P1LV_F16:\n        case V_INTERP_P2_F16  :\n            return 1;\n        }\n    }\n\n    uint GetSrc0WidthInDWORDs( VectorInstructions e )\n    {\n        switch( e )\n        {\n        default: return 0;\n        case V_ADD_U32:\n        case V_SUB_U32:\n        case V_SUBREV_U32:\n        case V_LSHLREV_B64 :\n        case V_LSHRREV_B64 :\n        case V_ASHRREV_I64 :\n            return 1;\n\n\n        case V_MAD_F16             :\n        case V_MAD_U16             :\n        case V_MAD_I16             :\n        case V_PERM_B32            :\n        case V_FMA_F16             :\n        case V_DIV_FIXUP_F16       :\n        case V_ADD_F16         :    \n        case V_SUB_F16         :    \n        case V_SUBREV_F16      :    \n        case V_MUL_F16         :    \n        case V_MAC_F16         :    \n        case V_MADMK_F16       :    \n        case V_MADAK_F16       :    \n        case V_ADD_U16         :    \n        case V_SUB_U16         :    \n        case V_SUBREV_U16      :    \n        case V_MUL_LO_U16      :    \n        case V_LSHLREV_B16     :    \n        case V_LSHRREV_B16     :    \n        case V_ASHRREV_I16     :    \n        case V_MAX_F16         :    \n        case V_MIN_F16         :    \n        case V_MAX_U16         :    \n        case V_MAX_I16         :    \n        case V_MIN_U16         :    \n        case V_MIN_I16         :    \n        case V_LDEXP_F16       :    \n        case V_CVT_F16_U16         :    \n        case V_CVT_F16_I16         :  \n        case V_CVT_U16_F16         :  \n        case V_CVT_I16_F16         :  \n        case V_RCP_F16             :  \n        case V_SQRT_F16            :  \n        case V_RSQ_F16             :  \n        case V_LOG_F16             :  \n        case V_EXP_F16             :  \n        case V_FREXP_MANT_F16      :  \n        case V_FREXP_EXP_I16_F16   :  \n        case V_FLOOR_F16           :  \n        case V_CEIL_F16            :  \n        case V_TRUNC_F16           :  \n        case V_RNDNE_F16           :  \n        case V_FRACT_F16           :  \n        case V_SIN_F16             :  \n        case V_COS_F16             :  \n        case V_CNDMASK_B32              :\n        case V_READLANE_B32             :                          \n        case V_WRITELANE_B32            :\n        case V_ADD_F32                  :\n        case V_SUB_F32                  :\n        case V_SUBREV_F32               :\n        case V_MAC_LEGACY_F32           :\n        case V_MUL_LEGACY_F32           :\n        case V_MUL_F32                  :\n        case V_MUL_I32_I24              :\n        case V_MUL_HI_I32_I24           :\n        case V_MUL_U32_U24              :\n        case V_MUL_HI_U32_U24           :\n        case V_MIN_LEGACY_F32           :\n        case V_MAX_LEGACY_F32           :\n        case V_MIN_F32                  :\n        case V_MAX_F32                  :\n        case V_MIN_I32                  :\n        case V_MAX_I32                  :\n        case V_MIN_U32                  :\n        case V_MAX_U32                  :\n        case V_LSHR_B32                 :\n        case V_LSHRREV_B32              :\n        case V_ASHR_I32                 :\n        case V_ASHRREV_I32              :\n        case V_LSHL_B32                 :\n        case V_LSHLREV_B32              :\n        case V_AND_B32                  :\n        case V_OR_B32                   :\n        case V_XOR_B32                  :\n        case V_BFM_B32                  :\n        case V_MAC_F32                  :\n        case V_MADMK_F32                :\n        case V_MADAK_F32                :\n        case V_BCNT_U32_B32             :\n        case V_MBCNT_LO_U32_B32         :                                                          \n        case V_MBCNT_HI_U32_B32         :                    \n        case V_ADD_I32                  :\n        case V_SUB_I32                  :\n        case V_SUBREV_I32               :\n        case V_ADDC_U32                 :\n        case V_SUBB_U32                 :\n        case V_SUBBREV_U32              :\n        case V_LDEXP_F32                :\n        case V_CVT_PKACCUM_U8_F32       :\n        case V_CVT_PKNORM_I16_F32       :\n        case V_CVT_PKNORM_U16_F32       :\n        case V_CVT_PKRTZ_F16_F32        :\n        case V_CVT_PK_U16_U32           :\n        case V_CVT_PK_I16_I32           :\n            return 1;\n\n        // VOPC\n        case V_CMP_CLASS_F16:\n        case V_CMPX_CLASS_F16:\n        case V_CMP_F_F16           :\n        case V_CMP_LT_F16          :\n        case V_CMP_EQ_F16          :\n        case V_CMP_LE_F16          :\n        case V_CMP_GT_F16          :\n        case V_CMP_LG_F16          :\n        case V_CMP_GE_F16          :\n        case V_CMP_O_F16           :\n        case V_CMP_U_F16           :\n        case V_CMP_NGE_F16         :\n        case V_CMP_NLG_F16         :\n        case V_CMP_NGT_F16         :\n        case V_CMP_NLE_F16         :\n        case V_CMP_NEQ_F16         :\n        case V_CMP_NLT_F16         :\n        case V_CMP_TRU_F16         :\n        case V_CMPX_F_F16          :\n        case V_CMPX_LT_F16         :\n        case V_CMPX_EQ_F16         :\n        case V_CMPX_LE_F16         :\n        case V_CMPX_GT_F16         :\n        case V_CMPX_LG_F16         :\n        case V_CMPX_GE_F16         :\n        case V_CMPX_O_F16          :\n        case V_CMPX_U_F16          :\n        case V_CMPX_NGE_F16        :\n        case V_CMPX_NLG_F16        :\n        case V_CMPX_NGT_F16        :\n        case V_CMPX_NLE_F16        :\n        case V_CMPX_NEQ_F16        :\n        case V_CMPX_NLT_F16        :\n        case V_CMPX_TRU_F16        :\n        case V_CMP_F_U16           :\n        case V_CMP_LT_U16          :\n        case V_CMP_EQ_U16          :\n        case V_CMP_LE_U16          :\n        case V_CMP_GT_U16          :\n        case V_CMP_LG_U16          :\n        case V_CMP_GE_U16          :\n        case V_CMP_TRU_U16         :\n        case V_CMPx_F_U16          :\n        case V_CMPx_LT_U16         :\n        case V_CMPx_EQ_U16         :\n        case V_CMPx_LE_U16         :\n        case V_CMPx_GT_U16         :\n        case V_CMPx_LG_U16         :\n        case V_CMPx_GE_U16         :\n        case V_CMPx_TRU_U16        :\n        case V_CMP_F_I16           :\n        case V_CMP_LT_I16          :\n        case V_CMP_EQ_I16          :\n        case V_CMP_LE_I16          :\n        case V_CMP_GT_I16          :\n        case V_CMP_LG_I16          :\n        case V_CMP_GE_I16          :\n        case V_CMP_TRU_I16         :\n        case V_CMPx_F_I16          :\n        case V_CMPx_LT_I16         :\n        case V_CMPx_EQ_I16         :\n        case V_CMPx_LE_I16         :\n        case V_CMPx_GT_I16         :\n        case V_CMPx_LG_I16         :\n        case V_CMPx_GE_I16         :\n        case V_CMPx_TRU_I16        :\n        case V_CMP_F_F32            :\n        case V_CMP_LT_F32           :\n        case V_CMP_EQ_F32           :\n        case V_CMP_LE_F32           :\n        case V_CMP_GT_F32           :\n        case V_CMP_LG_F32           :\n        case V_CMP_GE_F32           :\n        case V_CMP_O_F32            :\n        case V_CMP_U_F32            :\n        case V_CMP_NGE_F32          :\n        case V_CMP_NLG_F32          :\n        case V_CMP_NGT_F32          :\n        case V_CMP_NLE_F32          :\n        case V_CMP_NEQ_F32          :\n        case V_CMP_NLT_F32          :\n        case V_CMP_TRU_F32          :\n        case V_CMPX_F_F32           :\n        case V_CMPX_LT_F32          :\n        case V_CMPX_EQ_F32          :\n        case V_CMPX_LE_F32          :\n        case V_CMPX_GT_F32          :\n        case V_CMPX_LG_F32          :\n        case V_CMPX_GE_F32          :\n        case V_CMPX_O_F32           :\n        case V_CMPX_U_F32           :\n        case V_CMPX_NGE_F32         :\n        case V_CMPX_NLG_F32         :\n        case V_CMPX_NGT_F32         :\n        case V_CMPX_NLE_F32         :\n        case V_CMPX_NEQ_F32         :\n        case V_CMPX_NLT_F32         :\n        case V_CMPX_TRU_F32         :\n            return 1;\n        case V_CMP_F_F64            :\n        case V_CMP_LT_F64           :\n        case V_CMP_EQ_F64           :\n        case V_CMP_LE_F64           :\n        case V_CMP_GT_F64           :\n        case V_CMP_LG_F64           :\n        case V_CMP_GE_F64           :\n        case V_CMP_O_F64            :\n        case V_CMP_U_F64            :\n        case V_CMP_NGE_F64          :\n        case V_CMP_NLG_F64          :\n        case V_CMP_NGT_F64          :\n        case V_CMP_NLE_F64          :\n        case V_CMP_NEQ_F64          :\n        case V_CMP_NLT_F64          :\n        case V_CMP_TRU_F64          :\n        case V_CMPX_F_F64           :\n        case V_CMPX_LT_F64          :\n        case V_CMPX_EQ_F64          :\n        case V_CMPX_LE_F64          :\n        case V_CMPX_GT_F64          :\n        case V_CMPX_LG_F64          :\n        case V_CMPX_GE_F64          :\n        case V_CMPX_O_F64           :\n        case V_CMPX_U_F64           :\n        case V_CMPX_NGE_F64         :\n        case V_CMPX_NLG_F64         :\n        case V_CMPX_NGT_F64         :\n        case V_CMPX_NLE_F64         :\n        case V_CMPX_NEQ_F64         :\n        case V_CMPX_NLT_F64         :\n        case V_CMPX_TRU_F64         :\n            return 2;\n        case V_CMPS_F_F32           :\n        case V_CMPS_LT_F32          :\n        case V_CMPS_EQ_F32          :\n        case V_CMPS_LE_F32          :\n        case V_CMPS_GT_F32          :\n        case V_CMPS_LG_F32          :\n        case V_CMPS_GE_F32          :\n        case V_CMPS_O_F32           :\n        case V_CMPS_U_F32           :\n        case V_CMPS_NGE_F32         :\n        case V_CMPS_NLG_F32         :\n        case V_CMPS_NGT_F32         :\n        case V_CMPS_NLE_F32         :\n        case V_CMPS_NEQ_F32         :\n        case V_CMPS_NLT_F32         :\n        case V_CMPS_TRU_F32         :\n        case V_CMPSX_F_F32          :\n        case V_CMPSX_LT_F32         :\n        case V_CMPSX_EQ_F32         :\n        case V_CMPSX_LE_F32         :\n        case V_CMPSX_GT_F32         :\n        case V_CMPSX_LG_F32         :\n        case V_CMPSX_GE_F32         :\n        case V_CMPSX_O_F32          :\n        case V_CMPSX_U_F32          :\n        case V_CMPSX_NGE_F32        :\n        case V_CMPSX_NLG_F32        :\n        case V_CMPSX_NGT_F32        :\n        case V_CMPSX_NLE_F32        :\n        case V_CMPSX_NEQ_F32        :\n        case V_CMPSX_NLT_F32        :\n        case V_CMPSX_TRU_F32        :\n            return 1;\n        case V_CMPS_F_F64           :\n        case V_CMPS_LT_F64          :\n        case V_CMPS_EQ_F64          :\n        case V_CMPS_LE_F64          :\n        case V_CMPS_GT_F64          :\n        case V_CMPS_LG_F64          :\n        case V_CMPS_GE_F64          :\n        case V_CMPS_O_F64           :\n        case V_CMPS_U_F64           :\n        case V_CMPS_NGE_F64         :\n        case V_CMPS_NLG_F64         :\n        case V_CMPS_NGT_F64         :\n        case V_CMPS_NLE_F64         :\n        case V_CMPS_NEQ_F64         :\n        case V_CMPS_NLT_F64         :\n        case V_CMPS_TRU_F64         :\n        case V_CMPSX_F_F64          :\n        case V_CMPSX_LT_F64         :\n        case V_CMPSX_EQ_F64         :\n        case V_CMPSX_LE_F64         :\n        case V_CMPSX_GT_F64         :\n        case V_CMPSX_LG_F64         :\n        case V_CMPSX_GE_F64         :\n        case V_CMPSX_O_F64          :\n        case V_CMPSX_U_F64          :\n        case V_CMPSX_NGE_F64        :\n        case V_CMPSX_NLG_F64        :\n        case V_CMPSX_NGT_F64        :\n        case V_CMPSX_NLE_F64        :\n        case V_CMPSX_NEQ_F64        :\n        case V_CMPSX_NLT_F64        :\n        case V_CMPSX_TRU_F64        :\n            return 2;\n        case V_CMP_F_I32            :\n        case V_CMP_LT_I32           :\n        case V_CMP_EQ_I32           :\n        case V_CMP_LE_I32           :\n        case V_CMP_GT_I32           :\n        case V_CMP_LG_I32           :\n        case V_CMP_GE_I32           :\n        case V_CMP_TRU_I32          :\n        case V_CMPX_F_I32           :\n        case V_CMPX_LT_I32          :\n        case V_CMPX_EQ_I32          :\n        case V_CMPX_LE_I32          :\n        case V_CMPX_GT_I32          :\n        case V_CMPX_LG_I32          :\n        case V_CMPX_GE_I32          :\n        case V_CMPX_TRU_I32         :\n            return 1;\n        case V_CMP_F_I64            :\n        case V_CMP_LT_I64           :\n        case V_CMP_EQ_I64           :\n        case V_CMP_LE_I64           :\n        case V_CMP_GT_I64           :\n        case V_CMP_LG_I64           :\n        case V_CMP_GE_I64           :\n        case V_CMP_TRU_I64          :\n        case V_CMPX_F_I64           :\n        case V_CMPX_LT_I64          :\n        case V_CMPX_EQ_I64          :\n        case V_CMPX_LE_I64          :\n        case V_CMPX_GT_I64          :\n        case V_CMPX_LG_I64          :\n        case V_CMPX_GE_I64          :\n        case V_CMPX_TRU_I64         :\n            return 2;\n        case V_CMP_F_U32            :\n        case V_CMP_LT_U32           :\n        case V_CMP_EQ_U32           :\n        case V_CMP_LE_U32           :\n        case V_CMP_GT_U32           :\n        case V_CMP_LG_U32           :\n        case V_CMP_GE_U32           :\n        case V_CMP_TRU_U32          :\n        case V_CMPX_F_U32           :\n        case V_CMPX_LT_U32          :\n        case V_CMPX_EQ_U32          :\n        case V_CMPX_LE_U32          :\n        case V_CMPX_GT_U32          :\n        case V_CMPX_LG_U32          :\n        case V_CMPX_GE_U32          :\n        case V_CMPX_TRU_U32         :\n            return 1;\n        case V_CMP_F_U64            :\n        case V_CMP_LT_U64           :\n        case V_CMP_EQ_U64           :\n        case V_CMP_LE_U64           :\n        case V_CMP_GT_U64           :\n        case V_CMP_LG_U64           :\n        case V_CMP_GE_U64           :\n        case V_CMP_TRU_U64          :\n        case V_CMPx_F_U64           :\n        case V_CMPx_LT_U64          :\n        case V_CMPx_EQ_U64          :\n        case V_CMPx_LE_U64          :\n        case V_CMPx_GT_U64          :\n        case V_CMPx_LG_U64          :\n        case V_CMPx_GE_U64          :\n        case V_CMPx_TRU_U64         :\n        case V_CMP_CLASS_F64        :\n        case V_CMPX_CLASS_F64       :\n            return 2;\n        case V_CMP_CLASS_F32        :\n        case V_CMPX_CLASS_F32       :\n            return 1;\n\n        // VOP1\n        case V_CVT_F64_I32      :       \n        case V_CVT_F64_F32      :\n        case V_CVT_F64_U32      : \n        case V_MOV_B32           :      \n        case V_READFIRSTLANE_B32 :      \n        case V_CVT_F32_I32       :      \n        case V_CVT_F32_U32       :      \n        case V_CVT_U32_F32       :      \n        case V_CVT_I32_F32       :      \n        case V_MOV_FED_B32       :      \n        case V_CVT_F16_F32       :\n        case V_CVT_F32_F16       :      \n        case V_CVT_RPI_I32_F32   :      \n        case V_CVT_FLR_I32_F32   :      \n        case V_CVT_OFF_F32_I4    :\n        case V_CVT_F32_UBYTE0    :      \n        case V_CVT_F32_UBYTE1    :      \n        case V_CVT_F32_UBYTE2    :      \n        case V_CVT_F32_UBYTE3    :      \n        case V_FRACT_F32         :      \n        case V_TRUNC_F32         :      \n        case V_CEIL_F32          :      \n        case V_RNDNE_F32         :      \n        case V_FLOOR_F32         :      \n        case V_EXP_F32           :      \n        case V_LOG_CLAMP_F32     :      \n        case V_LOG_F32           :      \n        case V_RCP_CLAMP_F32     :      \n        case V_RCP_LEGACY_F32    :      \n        case V_RCP_F32           :      \n        case V_RCP_IFLAG_F32     :      \n        case V_RSQ_CLAMP_F32     :      \n        case V_RSQ_LEGACY_F32    :      \n        case V_RSQ_F32           :      \n        case V_SQRT_F32          :      \n        case V_SIN_F32           :      \n        case V_COS_F32           :      \n        case V_NOT_B32           :      \n        case V_BFREV_B32         :      \n        case V_FFBH_U32          :      \n        case V_FFBL_B32          :      \n        case V_FFBH_I32          :      \n        case V_FREXP_EXP_I32_F32 :                          \n        case V_FREXP_MANT_F32    :      \n        case V_MOVRELD_B32       :      \n        case V_MOVRELS_B32       :      \n        case V_MOVRELSD_B32      : \n        case V_LOG_LEGACY_F32    :      \n        case V_EXP_LEGACY_F32    :\n            return 1;\n        case V_TRUNC_F64        :       \n        case V_CEIL_F64         :       \n        case V_RNDNE_F64        :       \n        case V_FLOOR_F64        :    \n        case V_RCP_F64          :       \n        case V_RCP_CLAMP_F64    :       \n        case V_RSQ_F64          :       \n        case V_RSQ_CLAMP_F64    :       \n        case V_SQRT_F64         :       \n        case V_FREXP_MANT_F64   :       \n        case V_FRACT_F64        :    \n        case V_CVT_I32_F64       :      \n        case V_CVT_F32_F64       :      \n        case V_CVT_U32_F64       :      \n        case V_FREXP_EXP_I32_F64 :      \n            return 2;\n\n        case V_DIV_SCALE_F32    :    //  = D.f = Special case divide preop and flags(s0.f = Quotient,s1.f = Denominator, s2.f = Numerator) s0 must equal s1 or s2.\n        case V_MAD_LEGACY_F32   :   //   = D.f = S0.f * S1.f + S2.f (DX9 rules, 0.0*x = 0.0).\n        case V_MAD_F32          :   //   = D.f = S0.f * S1.f + S2.f.\n        case V_MAD_I32_I24      :   //   = D.i = S0.i * S1.i + S2.iD.i = S0.i * S1.i + S2.i.\n        case V_MAD_U32_U24      :   //   = D.u = S0.u * S1.u + S2.u.\n        case V_CUBEID_F32       :   //   = Rm.w <- Rn,x, Rn,y, Rn.z.\n        case V_CUBESC_F32       :   //   = Rm.y <- Rn,x, Rn,y, Rn.z.\n        case V_CUBETC_F32       :   //   = Rm.x <- Rn,x, Rn,y, Rn.z.\n        case V_CUBEMA_F32       :   //   = Rm.z <- Rn,x, Rn,y, Rn.z\n        case V_BFE_U32          :   //   = D.u = (S0.u>>S1.u[4:0]) & ((1<<S2.u[4:0])-1); bitfield extract,S0=data, S1=field_offset, S2=field_width.\n        case V_BFE_I32          :   //   = D.i = (S0.i>>S1.u[4:0]) & ((1<<S2.u[4:0])-1); bitfield extract, S0=data, S1=field_offset, S2=field_width.\n        case V_BFI_B32          :   //   = D.u = (S0.u & S1.u) | (~S0.u & S2.u); bitfield insert.\n        case V_FMA_F32          :   //   = D.f = S0.f * S1.f + S2.f\n        case V_LERP_U8          :   //  = D.u = ((S0.u[31:24] + S1.u[31:24] + S2.u[24]) >> 1) << 24 +\n        case V_ALIGNBIT_B32     :   //  = D.u = ({S0,S1} >> S2.u[4:0]) & 0xFFFFFFFF.\n        case V_ALIGNBYTE_B32    :   //  = D.u = ({S0,S1} >> (8*S2.u[4:0])) & 0xFFFFFFFF.\n        case V_MULLIT_F32       :   //  = D.f = S0.f * S1.f, replicate result into 4 components (0.0 * x = 0.0; special INF, NaN, overflow rules).\n        case V_MIN3_F32         :   //  = D.f = min(S0.f, S1.f, S2.f).\n        case V_MIN3_I32         :   //  = D.i = min(S0.i, S1.i, S2.i).\n        case V_MIN3_U32         :   //  = 0x153 D.u = min(S0.u, S1.u, S2.u).\n        case V_MAX3_F32         :   //  = D.f = max(S0.f, S1.f, S2.f).\n        case V_MAX3_I32         :   //  = D.i = max(S0.i, S1.i, S2.i).\n        case V_MAX3_U32         :   //  = D.u = max(S0.u, S1.u, S2.u).\n        case V_MED3_F32         :   //  = D.f = median(S0.f, S1.f, S2.f).\n        case V_MED3_I32         :   //  = D.i = median(S0.i, S1.i, S2.i).\n        case V_MED3_U32         :   //  = D.u = median(S0.u, S1.u, S2.u).\n        case V_SAD_U8           :   //  = D.u = Byte SAD with accum_lo(S0.u, S1.u, S2.u).\n        case V_SAD_HI_U8        :   //  = D.u = Byte SAD with accum_hi(S0.u, S1.u, S2.u).\n        case V_SAD_U16          :   //  = D.u = Word SAD with accum(S0.u, S1.u, S2.u).\n        case V_SAD_U32          :   //  = D.u = Dword SAD with accum(S0.u, S1.u, S2.u).\n        case V_CVT_PK_U8_F32    :   //  = f32->u8(s0.f), pack into byte(s1.u), of dword(s2).\n        case V_DIV_FIXUP_F32    :   //  = D.f = Special case divide fixup and flags(s0.f = Quotient,   s1.f = Denominator, s2.f = Numerator).\n            return 1;\n        case V_DIV_SCALE_F64    :    //  = D.d = Special case divide preop and flags(s0.d = Quotient,s1.d = Denominator, s2.d = Numerator) s0 must equal s1 or s2.\n        case V_DIV_FIXUP_F64    :   //  = D.d = Special case divide fixup and flags(s0.d = Quotient,  s1.d = Denominator, s2.d = Numerator).\n        case V_FMA_F64          :   //   = D.d = S0.d * S1.d + S2.d.\n        case V_LSHL_B64         :   //  = D = S0.u << S1.u[4:0].\n        case V_LSHR_B64         :   //  = D = S0.u >> S1.u[4:0].\n        case V_ASHR_I64         :   //  = D = S0.u >> S1.u[4:0].\n        case V_ADD_F64          :   //  = D.d = S0.d + S1.d.\n        case V_MUL_F64          :   //  = D.d = S0.d * S1.d.\n        case V_MIN_F64          :   //  = D.d = min(S0.d, S1.d).\n        case V_MAX_F64          :   //  = D.d = max(S0.d, S1.d).\n        case V_LDEXP_F64        :   //  = D.d = pow(S0.d, S1.i[31:0]).\n        case V_DIV_FMAS_F64    : // = D.d = Special case divide FMA with scale and flags(s0.d= Quotient, s1.d = Denominator, s2.d = Numerator).\n        case V_TRIG_PREOP_F64  : // = D.d = Look Up 2/PI (S0.d) with segment select  S1.u[4:0].\n            return 2;\n        case V_MUL_LO_U32       :   //  = D.u = S0.u * S1.u.\n        case V_MUL_HI_U32       :   //  = D.u = (S0.u * S1.u)>>32.\n        case V_MUL_LO_I32       :   //  = D.i = S0.i * S1.i.\n        case V_MUL_HI_I32       :   //  = D.i = (S0.i * S1.i)>>32.\n        case V_DIV_FMAS_F32    : // = D.f = Special case divide FMA with scale and flags(s0.f = Quotient, s1.f = Denominator, s2.f = Numerator).\n        case V_MSAD_U8         : // = D.u = Masked Byte SAD with accum_lo(S0.u, S1.u, S2.u).\n        case V_QSAD_U8         : // = D.u = Quad-Byte SAD with accum_lo/hiu(S0.u[63:0], S1.u[31:0], S2.u[63:0]).\n        case V_MQSAD_U8        : // = D.u = Masked Quad-Byte SAD with accum_lo/hi(S0.u[63:0],S1.u[31:0], S2.u[63:0]).       \n        case V_QSAD_PK_U16_U8  : // : D.u = Quad-Byte SAD with accum_lo/hiu(S0.u[63:0], S1.u[31:0], S2.u[63:0]).\n        case V_MQSAD_PK_U16_U8 : // = D.u = Masked Quad-Byte SAD with accum_lo/hi(S0.u[63:0], S1.u[31:0], S2.u[63:0]).\n        case V_MQSAD_U32_U8    :  // : D.u128 = Masked Quad-Byte SAD with 32-bit accum_lo/hi(S0.u[63:0], S1.u[31:0], S2.u[127:0]).\n        case V_MAD_U64_U32     :  // : {vcc_out,D.u64} = S0.u32 * S1.u32 + S2.u64.\n        case V_MAD_I64_I32     :  // : {vcc_out,D.i64} = S0.i32 * S1.i32 + S2.i64.\n            return 1;\n\n        case V_INTERP_P1_F32  :\n        case V_INTERP_P2_F32  :\n        case V_INTERP_MOV_F32 :\n        case V_INTERP_P1LL_F16:\n        case V_INTERP_P1LV_F16:\n        case V_INTERP_P2_F16  :\n            return 1;\n        }\n    }\n\n\n    uint GetSrc1WidthInDWORDs(VectorInstructions e) \n    {\n        switch(e)\n        {\n        default: return 0;\n            // VOP2\n        case V_ADD_U32:\n        case V_SUB_U32:\n        case V_SUBREV_U32:\n            return 1;\n        case V_LSHLREV_B64 :\n        case V_LSHRREV_B64 :\n        case V_ASHRREV_I64 :\n            return 2;\n        case V_MAD_F16            :\n        case V_MAD_U16            :\n        case V_MAD_I16            :\n        case V_PERM_B32           :\n        case V_FMA_F16            :\n        case V_DIV_FIXUP_F16      :\n        case V_ADD_F16            :  \n        case V_SUB_F16            :  \n        case V_SUBREV_F16         :  \n        case V_MUL_F16            :  \n        case V_MAC_F16            :  \n        case V_MADMK_F16          :  \n        case V_MADAK_F16          :  \n        case V_ADD_U16            :  \n        case V_SUB_U16            :  \n        case V_SUBREV_U16         :  \n        case V_MUL_LO_U16         :  \n        case V_LSHLREV_B16        :  \n        case V_LSHRREV_B16        :  \n        case V_ASHRREV_I16        :  \n        case V_MAX_F16            :  \n        case V_MIN_F16            :  \n        case V_MAX_U16            :  \n        case V_MAX_I16            :  \n        case V_MIN_U16            :  \n        case V_MIN_I16            :  \n        case V_LDEXP_F16          :  \n        case V_CNDMASK_B32        :      \n        case V_READLANE_B32             :                          \n        case V_WRITELANE_B32            :\n        case V_ADD_F32                  :\n        case V_SUB_F32                  :\n        case V_SUBREV_F32               :\n        case V_MAC_LEGACY_F32           :\n        case V_MUL_LEGACY_F32           :\n        case V_MUL_F32                  :\n        case V_MUL_I32_I24              :\n        case V_MUL_HI_I32_I24           :\n        case V_MUL_U32_U24              :\n        case V_MUL_HI_U32_U24           :\n        case V_MIN_LEGACY_F32           :\n        case V_MAX_LEGACY_F32           :\n        case V_MIN_F32                  :\n        case V_MAX_F32                  :\n        case V_MIN_I32                  :\n        case V_MAX_I32                  :\n        case V_MIN_U32                  :\n        case V_MAX_U32                  :\n        case V_LSHR_B32                 :\n        case V_LSHRREV_B32              :\n        case V_ASHR_I32                 :\n        case V_ASHRREV_I32              :\n        case V_LSHL_B32                 :\n        case V_LSHLREV_B32              :\n        case V_AND_B32                  :\n        case V_OR_B32                   :\n        case V_XOR_B32                  :\n        case V_BFM_B32                  :\n        case V_MAC_F32                  :\n        case V_MADMK_F32                :\n        case V_MADAK_F32                :\n        case V_BCNT_U32_B32             :\n        case V_MBCNT_LO_U32_B32         :                                                          \n        case V_MBCNT_HI_U32_B32         :                    \n        case V_ADD_I32                  :\n        case V_SUB_I32                  :\n        case V_SUBREV_I32               :\n        case V_ADDC_U32                 :\n        case V_SUBB_U32                 :\n        case V_SUBBREV_U32              :\n        case V_LDEXP_F32                :\n        case V_CVT_PKACCUM_U8_F32       :\n        case V_CVT_PKNORM_I16_F32       :\n        case V_CVT_PKNORM_U16_F32       :\n        case V_CVT_PKRTZ_F16_F32        :\n        case V_CVT_PK_U16_U32           :\n        case V_CVT_PK_I16_I32           :\n            return 1;\n\n        // VOPC\n        case V_CMP_CLASS_F16:\n        case V_CMPX_CLASS_F16:        \n        case V_CMP_F_F16          :\n        case V_CMP_LT_F16         :\n        case V_CMP_EQ_F16         :\n        case V_CMP_LE_F16         :\n        case V_CMP_GT_F16         :\n        case V_CMP_LG_F16         :\n        case V_CMP_GE_F16         :\n        case V_CMP_O_F16          :\n        case V_CMP_U_F16          :\n        case V_CMP_NGE_F16        :\n        case V_CMP_NLG_F16        :\n        case V_CMP_NGT_F16        :\n        case V_CMP_NLE_F16        :\n        case V_CMP_NEQ_F16        :\n        case V_CMP_NLT_F16        :\n        case V_CMP_TRU_F16        :\n        case V_CMPX_F_F16         :\n        case V_CMPX_LT_F16        :\n        case V_CMPX_EQ_F16        :\n        case V_CMPX_LE_F16        :\n        case V_CMPX_GT_F16        :\n        case V_CMPX_LG_F16        :\n        case V_CMPX_GE_F16        :\n        case V_CMPX_O_F16         :\n        case V_CMPX_U_F16         :\n        case V_CMPX_NGE_F16       :\n        case V_CMPX_NLG_F16       :\n        case V_CMPX_NGT_F16       :\n        case V_CMPX_NLE_F16       :\n        case V_CMPX_NEQ_F16       :\n        case V_CMPX_NLT_F16       :\n        case V_CMPX_TRU_F16       :\n        case V_CMP_F_U16          :\n        case V_CMP_LT_U16         :\n        case V_CMP_EQ_U16         :\n        case V_CMP_LE_U16         :\n        case V_CMP_GT_U16         :\n        case V_CMP_LG_U16         :\n        case V_CMP_GE_U16         :\n        case V_CMP_TRU_U16        :\n        case V_CMPx_F_U16         :\n        case V_CMPx_LT_U16        :\n        case V_CMPx_EQ_U16        :\n        case V_CMPx_LE_U16        :\n        case V_CMPx_GT_U16        :\n        case V_CMPx_LG_U16        :\n        case V_CMPx_GE_U16        :\n        case V_CMPx_TRU_U16       :\n        case V_CMP_F_I16          :\n        case V_CMP_LT_I16         :\n        case V_CMP_EQ_I16         :\n        case V_CMP_LE_I16         :\n        case V_CMP_GT_I16         :\n        case V_CMP_LG_I16         :\n        case V_CMP_GE_I16         :\n        case V_CMP_TRU_I16        :\n        case V_CMPx_F_I16         :\n        case V_CMPx_LT_I16        :\n        case V_CMPx_EQ_I16        :\n        case V_CMPx_LE_I16        :\n        case V_CMPx_GT_I16        :\n        case V_CMPx_LG_I16        :\n        case V_CMPx_GE_I16        :\n        case V_CMPx_TRU_I16       :\n        case V_CMP_F_F32            :\n        case V_CMP_LT_F32           :\n        case V_CMP_EQ_F32           :\n        case V_CMP_LE_F32           :\n        case V_CMP_GT_F32           :\n        case V_CMP_LG_F32           :\n        case V_CMP_GE_F32           :\n        case V_CMP_O_F32            :\n        case V_CMP_U_F32            :\n        case V_CMP_NGE_F32          :\n        case V_CMP_NLG_F32          :\n        case V_CMP_NGT_F32          :\n        case V_CMP_NLE_F32          :\n        case V_CMP_NEQ_F32          :\n        case V_CMP_NLT_F32          :\n        case V_CMP_TRU_F32          :\n        case V_CMPX_F_F32           :\n        case V_CMPX_LT_F32          :\n        case V_CMPX_EQ_F32          :\n        case V_CMPX_LE_F32          :\n        case V_CMPX_GT_F32          :\n        case V_CMPX_LG_F32          :\n        case V_CMPX_GE_F32          :\n        case V_CMPX_O_F32           :\n        case V_CMPX_U_F32           :\n        case V_CMPX_NGE_F32         :\n        case V_CMPX_NLG_F32         :\n        case V_CMPX_NGT_F32         :\n        case V_CMPX_NLE_F32         :\n        case V_CMPX_NEQ_F32         :\n        case V_CMPX_NLT_F32         :\n        case V_CMPX_TRU_F32         :\n            return 1;\n        case V_CMP_F_F64            :\n        case V_CMP_LT_F64           :\n        case V_CMP_EQ_F64           :\n        case V_CMP_LE_F64           :\n        case V_CMP_GT_F64           :\n        case V_CMP_LG_F64           :\n        case V_CMP_GE_F64           :\n        case V_CMP_O_F64            :\n        case V_CMP_U_F64            :\n        case V_CMP_NGE_F64          :\n        case V_CMP_NLG_F64          :\n        case V_CMP_NGT_F64          :\n        case V_CMP_NLE_F64          :\n        case V_CMP_NEQ_F64          :\n        case V_CMP_NLT_F64          :\n        case V_CMP_TRU_F64          :\n        case V_CMPX_F_F64           :\n        case V_CMPX_LT_F64          :\n        case V_CMPX_EQ_F64          :\n        case V_CMPX_LE_F64          :\n        case V_CMPX_GT_F64          :\n        case V_CMPX_LG_F64          :\n        case V_CMPX_GE_F64          :\n        case V_CMPX_O_F64           :\n        case V_CMPX_U_F64           :\n        case V_CMPX_NGE_F64         :\n        case V_CMPX_NLG_F64         :\n        case V_CMPX_NGT_F64         :\n        case V_CMPX_NLE_F64         :\n        case V_CMPX_NEQ_F64         :\n        case V_CMPX_NLT_F64         :\n        case V_CMPX_TRU_F64         :\n            return 2;\n        case V_CMPS_F_F32           :\n        case V_CMPS_LT_F32          :\n        case V_CMPS_EQ_F32          :\n        case V_CMPS_LE_F32          :\n        case V_CMPS_GT_F32          :\n        case V_CMPS_LG_F32          :\n        case V_CMPS_GE_F32          :\n        case V_CMPS_O_F32           :\n        case V_CMPS_U_F32           :\n        case V_CMPS_NGE_F32         :\n        case V_CMPS_NLG_F32         :\n        case V_CMPS_NGT_F32         :\n        case V_CMPS_NLE_F32         :\n        case V_CMPS_NEQ_F32         :\n        case V_CMPS_NLT_F32         :\n        case V_CMPS_TRU_F32         :\n        case V_CMPSX_F_F32          :\n        case V_CMPSX_LT_F32         :\n        case V_CMPSX_EQ_F32         :\n        case V_CMPSX_LE_F32         :\n        case V_CMPSX_GT_F32         :\n        case V_CMPSX_LG_F32         :\n        case V_CMPSX_GE_F32         :\n        case V_CMPSX_O_F32          :\n        case V_CMPSX_U_F32          :\n        case V_CMPSX_NGE_F32        :\n        case V_CMPSX_NLG_F32        :\n        case V_CMPSX_NGT_F32        :\n        case V_CMPSX_NLE_F32        :\n        case V_CMPSX_NEQ_F32        :\n        case V_CMPSX_NLT_F32        :\n        case V_CMPSX_TRU_F32        :\n            return 1;\n        case V_CMPS_F_F64           :\n        case V_CMPS_LT_F64          :\n        case V_CMPS_EQ_F64          :\n        case V_CMPS_LE_F64          :\n        case V_CMPS_GT_F64          :\n        case V_CMPS_LG_F64          :\n        case V_CMPS_GE_F64          :\n        case V_CMPS_O_F64           :\n        case V_CMPS_U_F64           :\n        case V_CMPS_NGE_F64         :\n        case V_CMPS_NLG_F64         :\n        case V_CMPS_NGT_F64         :\n        case V_CMPS_NLE_F64         :\n        case V_CMPS_NEQ_F64         :\n        case V_CMPS_NLT_F64         :\n        case V_CMPS_TRU_F64         :\n        case V_CMPSX_F_F64          :\n        case V_CMPSX_LT_F64         :\n        case V_CMPSX_EQ_F64         :\n        case V_CMPSX_LE_F64         :\n        case V_CMPSX_GT_F64         :\n        case V_CMPSX_LG_F64         :\n        case V_CMPSX_GE_F64         :\n        case V_CMPSX_O_F64          :\n        case V_CMPSX_U_F64          :\n        case V_CMPSX_NGE_F64        :\n        case V_CMPSX_NLG_F64        :\n        case V_CMPSX_NGT_F64        :\n        case V_CMPSX_NLE_F64        :\n        case V_CMPSX_NEQ_F64        :\n        case V_CMPSX_NLT_F64        :\n        case V_CMPSX_TRU_F64        :\n            return 2;\n        case V_CMP_F_I32            :\n        case V_CMP_LT_I32           :\n        case V_CMP_EQ_I32           :\n        case V_CMP_LE_I32           :\n        case V_CMP_GT_I32           :\n        case V_CMP_LG_I32           :\n        case V_CMP_GE_I32           :\n        case V_CMP_TRU_I32          :\n        case V_CMPX_F_I32           :\n        case V_CMPX_LT_I32          :\n        case V_CMPX_EQ_I32          :\n        case V_CMPX_LE_I32          :\n        case V_CMPX_GT_I32          :\n        case V_CMPX_LG_I32          :\n        case V_CMPX_GE_I32          :\n        case V_CMPX_TRU_I32         :\n            return 1;\n        case V_CMP_F_I64            :\n        case V_CMP_LT_I64           :\n        case V_CMP_EQ_I64           :\n        case V_CMP_LE_I64           :\n        case V_CMP_GT_I64           :\n        case V_CMP_LG_I64           :\n        case V_CMP_GE_I64           :\n        case V_CMP_TRU_I64          :\n        case V_CMPX_F_I64           :\n        case V_CMPX_LT_I64          :\n        case V_CMPX_EQ_I64          :\n        case V_CMPX_LE_I64          :\n        case V_CMPX_GT_I64          :\n        case V_CMPX_LG_I64          :\n        case V_CMPX_GE_I64          :\n        case V_CMPX_TRU_I64         :\n            return 2;\n        case V_CMP_F_U32            :\n        case V_CMP_LT_U32           :\n        case V_CMP_EQ_U32           :\n        case V_CMP_LE_U32           :\n        case V_CMP_GT_U32           :\n        case V_CMP_LG_U32           :\n        case V_CMP_GE_U32           :\n        case V_CMP_TRU_U32          :\n        case V_CMPX_F_U32           :\n        case V_CMPX_LT_U32          :\n        case V_CMPX_EQ_U32          :\n        case V_CMPX_LE_U32          :\n        case V_CMPX_GT_U32          :\n        case V_CMPX_LG_U32          :\n        case V_CMPX_GE_U32          :\n        case V_CMPX_TRU_U32         :\n            return 1;\n        case V_CMP_F_U64            :\n        case V_CMP_LT_U64           :\n        case V_CMP_EQ_U64           :\n        case V_CMP_LE_U64           :\n        case V_CMP_GT_U64           :\n        case V_CMP_LG_U64           :\n        case V_CMP_GE_U64           :\n        case V_CMP_TRU_U64          :\n        case V_CMPx_F_U64           :\n        case V_CMPx_LT_U64          :\n        case V_CMPx_EQ_U64          :\n        case V_CMPx_LE_U64          :\n        case V_CMPx_GT_U64          :\n        case V_CMPx_LG_U64          :\n        case V_CMPx_GE_U64          :\n        case V_CMPx_TRU_U64         :\n        case V_CMP_CLASS_F64        :\n        case V_CMPX_CLASS_F64       :\n            return 2;\n        case V_CMP_CLASS_F32        :\n        case V_CMPX_CLASS_F32       :\n            return 1;\n\n       \n        case V_DIV_SCALE_F32    :    //  = D.f = Special case divide preop and flags(s0.f = Quotient,s1.f = Denominator, s2.f = Numerator) s0 must equal s1 or s2.\n        case V_MAD_LEGACY_F32   :   //   = D.f = S0.f * S1.f + S2.f (DX9 rules, 0.0*x = 0.0).\n        case V_MAD_F32          :   //   = D.f = S0.f * S1.f + S2.f.\n        case V_MAD_I32_I24      :   //   = D.i = S0.i * S1.i + S2.iD.i = S0.i * S1.i + S2.i.\n        case V_MAD_U32_U24      :   //   = D.u = S0.u * S1.u + S2.u.\n        case V_CUBEID_F32       :   //   = Rm.w <- Rn,x, Rn,y, Rn.z.\n        case V_CUBESC_F32       :   //   = Rm.y <- Rn,x, Rn,y, Rn.z.\n        case V_CUBETC_F32       :   //   = Rm.x <- Rn,x, Rn,y, Rn.z.\n        case V_CUBEMA_F32       :   //   = Rm.z <- Rn,x, Rn,y, Rn.z\n        case V_BFE_U32          :   //   = D.u = (S0.u>>S1.u[4:0]) & ((1<<S2.u[4:0])-1); bitfield extract,S0=data, S1=field_offset, S2=field_width.\n        case V_BFE_I32          :   //   = D.i = (S0.i>>S1.u[4:0]) & ((1<<S2.u[4:0])-1); bitfield extract, S0=data, S1=field_offset, S2=field_width.\n        case V_BFI_B32          :   //   = D.u = (S0.u & S1.u) | (~S0.u & S2.u); bitfield insert.\n        case V_FMA_F32          :   //   = D.f = S0.f * S1.f + S2.f\n        case V_LERP_U8          :   //  = D.u = ((S0.u[31:24] + S1.u[31:24] + S2.u[24]) >> 1) << 24 +\n        case V_ALIGNBIT_B32     :   //  = D.u = ({S0,S1} >> S2.u[4:0]) & 0xFFFFFFFF.\n        case V_ALIGNBYTE_B32    :   //  = D.u = ({S0,S1} >> (8*S2.u[4:0])) & 0xFFFFFFFF.\n        case V_MULLIT_F32       :   //  = D.f = S0.f * S1.f, replicate result into 4 components (0.0 * x = 0.0; special INF, NaN, overflow rules).\n        case V_MIN3_F32         :   //  = D.f = min(S0.f, S1.f, S2.f).\n        case V_MIN3_I32         :   //  = D.i = min(S0.i, S1.i, S2.i).\n        case V_MIN3_U32         :   //  = 0x153 D.u = min(S0.u, S1.u, S2.u).\n        case V_MAX3_F32         :   //  = D.f = max(S0.f, S1.f, S2.f).\n        case V_MAX3_I32         :   //  = D.i = max(S0.i, S1.i, S2.i).\n        case V_MAX3_U32         :   //  = D.u = max(S0.u, S1.u, S2.u).\n        case V_MED3_F32         :   //  = D.f = median(S0.f, S1.f, S2.f).\n        case V_MED3_I32         :   //  = D.i = median(S0.i, S1.i, S2.i).\n        case V_MED3_U32         :   //  = D.u = median(S0.u, S1.u, S2.u).\n        case V_SAD_U8           :   //  = D.u = Byte SAD with accum_lo(S0.u, S1.u, S2.u).\n        case V_SAD_HI_U8        :   //  = D.u = Byte SAD with accum_hi(S0.u, S1.u, S2.u).\n        case V_SAD_U16          :   //  = D.u = Word SAD with accum(S0.u, S1.u, S2.u).\n        case V_SAD_U32          :   //  = D.u = Dword SAD with accum(S0.u, S1.u, S2.u).\n        case V_CVT_PK_U8_F32    :   //  = f32->u8(s0.f), pack into byte(s1.u), of dword(s2).\n        case V_DIV_FIXUP_F32    :   //  = D.f = Special case divide fixup and flags(s0.f = Quotient,   s1.f = Denominator, s2.f = Numerator).\n        case V_LSHL_B64         :   //  = D = S0.u << S1.u[4:0].\n        case V_LSHR_B64         :   //  = D = S0.u >> S1.u[4:0].\n        case V_ASHR_I64         :   //  = D = S0.u >> S1.u[4:0].\n        case V_LDEXP_F64        :   //  = D.d = pow(S0.d, S1.i[31:0]).\n            return 1;\n        case V_FMA_F64          :   //   = D.d = S0.d * S1.d + S2.d.\n        case V_DIV_SCALE_F64    :    //  = D.d = Special case divide preop and flags(s0.d = Quotient,s1.d = Denominator, s2.d = Numerator) s0 must equal s1 or s2.\n        case V_DIV_FIXUP_F64    :   //  = D.d = Special case divide fixup and flags(s0.d = Quotient,  s1.d = Denominator, s2.d = Numerator).\n        case V_ADD_F64          :   //  = D.d = S0.d + S1.d.\n        case V_MUL_F64          :   //  = D.d = S0.d * S1.d.\n        case V_MIN_F64          :   //  = D.d = min(S0.d, S1.d).\n        case V_MAX_F64          :   //  = D.d = max(S0.d, S1.d).\n        case V_DIV_FMAS_F64    : // = D.d = Special case divide FMA with scale and flags(s0.d= Quotient, s1.d = Denominator, s2.d = Numerator).\n        case V_TRIG_PREOP_F64  : // = D.d = Look Up 2/PI (S0.d) with segment select  S1.u[4:0].\n            return 2;\n        case V_MUL_LO_U32       :   //  = D.u = S0.u * S1.u.\n        case V_MUL_HI_U32       :   //  = D.u = (S0.u * S1.u)>>32.\n        case V_MUL_LO_I32       :   //  = D.i = S0.i * S1.i.\n        case V_MUL_HI_I32       :   //  = D.i = (S0.i * S1.i)>>32.\n        case V_DIV_FMAS_F32    : // = D.f = Special case divide FMA with scale and flags(s0.f = Quotient, s1.f = Denominator, s2.f = Numerator).\n        case V_MSAD_U8         : // = D.u = Masked Byte SAD with accum_lo(S0.u, S1.u, S2.u).\n        case V_QSAD_U8         : // = D.u = Quad-Byte SAD with accum_lo/hiu(S0.u[63:0], S1.u[31:0], S2.u[63:0]).\n        case V_MQSAD_U8        : // = D.u = Masked Quad-Byte SAD with accum_lo/hi(S0.u[63:0],S1.u[31:0], S2.u[63:0]).       \n        case V_QSAD_PK_U16_U8  : // : D.u = Quad-Byte SAD with accum_lo/hiu(S0.u[63:0], S1.u[31:0], S2.u[63:0]).\n        case V_MQSAD_PK_U16_U8 : // = D.u = Masked Quad-Byte SAD with accum_lo/hi(S0.u[63:0], S1.u[31:0], S2.u[63:0]).\n        case V_MQSAD_U32_U8    :  // : D.u128 = Masked Quad-Byte SAD with 32-bit accum_lo/hi(S0.u[63:0], S1.u[31:0], S2.u[127:0]).\n        case V_MAD_U64_U32     :  // : {vcc_out,D.u64} = S0.u32 * S1.u32 + S2.u64.\n        case V_MAD_I64_I32     :  // : {vcc_out,D.i64} = S0.i32 * S1.i32 + S2.i64.\n            return 1;\n\n        }\n    }\n\n\n    uint GetSrc2WidthInDWORDs( VectorInstructions e )\n    {\n        switch(e)\n        {\n        default: return 0;\n        case V_DIV_SCALE_F32    :    //  = D.f = Special case divide preop and flags(s0.f = Quotient,s1.f = Denominator, s2.f = Numerator) s0 must equal s1 or s2.\n        case V_MAD_LEGACY_F32   :   //   = D.f = S0.f * S1.f + S2.f (DX9 rules, 0.0*x = 0.0).\n        case V_MAD_F32          :   //   = D.f = S0.f * S1.f + S2.f.\n        case V_MAD_I32_I24      :   //   = D.i = S0.i * S1.i + S2.iD.i = S0.i * S1.i + S2.i.\n        case V_MAD_U32_U24      :   //   = D.u = S0.u * S1.u + S2.u.\n        case V_CUBEID_F32       :   //   = Rm.w <- Rn,x, Rn,y, Rn.z.\n        case V_CUBESC_F32       :   //   = Rm.y <- Rn,x, Rn,y, Rn.z.\n        case V_CUBETC_F32       :   //   = Rm.x <- Rn,x, Rn,y, Rn.z.\n        case V_CUBEMA_F32       :   //   = Rm.z <- Rn,x, Rn,y, Rn.z\n        case V_BFE_U32          :   //   = D.u = (S0.u>>S1.u[4:0]) & ((1<<S2.u[4:0])-1); bitfield extract,S0=data, S1=field_offset, S2=field_width.\n        case V_BFE_I32          :   //   = D.i = (S0.i>>S1.u[4:0]) & ((1<<S2.u[4:0])-1); bitfield extract, S0=data, S1=field_offset, S2=field_width.\n        case V_BFI_B32          :   //   = D.u = (S0.u & S1.u) | (~S0.u & S2.u); bitfield insert.\n        case V_FMA_F32          :   //   = D.f = S0.f * S1.f + S2.f\n        case V_LERP_U8          :   //  = D.u = ((S0.u[31:24] + S1.u[31:24] + S2.u[24]) >> 1) << 24 +\n        case V_ALIGNBIT_B32     :   //  = D.u = ({S0,S1} >> S2.u[4:0]) & 0xFFFFFFFF.\n        case V_ALIGNBYTE_B32    :   //  = D.u = ({S0,S1} >> (8*S2.u[4:0])) & 0xFFFFFFFF.\n        case V_MIN3_F32         :   //  = D.f = min(S0.f, S1.f, S2.f).\n        case V_MIN3_I32         :   //  = D.i = min(S0.i, S1.i, S2.i).\n        case V_MIN3_U32         :   //  = 0x153 D.u = min(S0.u, S1.u, S2.u).\n        case V_MAX3_F32         :   //  = D.f = max(S0.f, S1.f, S2.f).\n        case V_MAX3_I32         :   //  = D.i = max(S0.i, S1.i, S2.i).\n        case V_MAX3_U32         :   //  = D.u = max(S0.u, S1.u, S2.u).\n        case V_MED3_F32         :   //  = D.f = median(S0.f, S1.f, S2.f).\n        case V_MED3_I32         :   //  = D.i = median(S0.i, S1.i, S2.i).\n        case V_MED3_U32         :   //  = D.u = median(S0.u, S1.u, S2.u).\n        case V_SAD_U8           :   //  = D.u = Byte SAD with accum_lo(S0.u, S1.u, S2.u).\n        case V_SAD_HI_U8        :   //  = D.u = Byte SAD with accum_hi(S0.u, S1.u, S2.u).\n        case V_SAD_U16          :   //  = D.u = Word SAD with accum(S0.u, S1.u, S2.u).\n        case V_SAD_U32          :   //  = D.u = Dword SAD with accum(S0.u, S1.u, S2.u).\n        case V_CVT_PK_U8_F32    :   //  = f32->u8(s0.f), pack into byte(s1.u), of dword(s2).\n        case V_DIV_FIXUP_F32    :   //  = D.f = Special case divide fixup and flags(s0.f = Quotient,   s1.f = Denominator, s2.f = Numerator).\n            return 1;\n\n        case V_FMA_F64          :   //   = D.d = S0.d * S1.d + S2.d.\n        case V_DIV_SCALE_F64    :    //  = D.d = Special case divide preop and flags(s0.d = Quotient,s1.d = Denominator, s2.d = Numerator) s0 must equal s1 or s2.\n        case V_DIV_FIXUP_F64    :   //  = D.d = Special case divide fixup and flags(s0.d = Quotient,  s1.d = Denominator, s2.d = Numerator).\n        case V_DIV_FMAS_F64    : // = D.d = Special case divide FMA with scale and flags(s0.d= Quotient, s1.d = Denominator, s2.d = Numerator).\n        case V_TRIG_PREOP_F64  : // = D.d = Look Up 2/PI (S0.d) with segment select  S1.u[4:0].\n        case V_MAD_U64_U32     :  // : {vcc_out,D.u64} = S0.u32 * S1.u32 + S2.u64.\n        case V_MAD_I64_I32     :  // : {vcc_out,D.i64} = S0.i32 * S1.i32 + S2.i64.\n            return 2;\n        case V_MUL_LO_U32       :   //  = D.u = S0.u * S1.u.\n        case V_MUL_HI_U32       :   //  = D.u = (S0.u * S1.u)>>32.\n        case V_MUL_LO_I32       :   //  = D.i = S0.i * S1.i.\n        case V_MUL_HI_I32       :   //  = D.i = (S0.i * S1.i)>>32.\n        case V_DIV_FMAS_F32    : // = D.f = Special case divide FMA with scale and flags(s0.f = Quotient, s1.f = Denominator, s2.f = Numerator).\n        case V_MSAD_U8         : // = D.u = Masked Byte SAD with accum_lo(S0.u, S1.u, S2.u).\n        case V_QSAD_U8         : // = D.u = Quad-Byte SAD with accum_lo/hiu(S0.u[63:0], S1.u[31:0], S2.u[63:0]).\n        case V_MQSAD_U8        : // = D.u = Masked Quad-Byte SAD with accum_lo/hi(S0.u[63:0],S1.u[31:0], S2.u[63:0]).       \n        case V_QSAD_PK_U16_U8  : // : D.u = Quad-Byte SAD with accum_lo/hiu(S0.u[63:0], S1.u[31:0], S2.u[63:0]).\n        case V_MQSAD_PK_U16_U8 : // = D.u = Masked Quad-Byte SAD with accum_lo/hi(S0.u[63:0], S1.u[31:0], S2.u[63:0]).\n        case V_MQSAD_U32_U8    :  // : D.u128 = Masked Quad-Byte SAD with 32-bit accum_lo/hi(S0.u[63:0], S1.u[31:0], S2.u[127:0]).\n            return 1;\n        }\n    }\n\n\n    uint GetDataWidthInDWORDs( DSInstructions eOp )\n    {\n        switch( eOp )\n        {\n        default:\n            return 0;\n        case DS_PERMUTE_B32:\n        case DS_BPERMUTE_B32:\n        case DS_ADD_U32                   :\n        case DS_ADD_F32                   :\n        case DS_SUB_U32                   :\n        case DS_RSUB_U32                  :\n        case DS_INC_U32                   :\n        case DS_DEC_U32                   :\n        case DS_MIN_I32                   :\n        case DS_MAX_I32                   :\n        case DS_MIN_U32                   :\n        case DS_MAX_U32                   :\n        case DS_AND_B32                   :\n        case DS_OR_B32                    :\n        case DS_XOR_B32                   :\n        case DS_MSKOR_B32                 :\n        case DS_WRITE_B32                 :\n        case DS_WRITE2_B32                :\n        case DS_WRITE2ST64_B32            :\n        case DS_CMPST_B32                 :\n        case DS_CMPST_F32                 :\n        case DS_MIN_F32                   :\n        case DS_MAX_F32                   :\n        case DS_WRITE_B8                  :\n        case DS_WRITE_B16                 :\n        case DS_ADD_RTN_U32               :\n        case DS_SUB_RTN_U32               :\n        case DS_RSUB_RTN_U32              :\n        case DS_INC_RTN_U32               :\n        case DS_DEC_RTN_U32               :\n        case DS_MIN_RTN_I32               :\n        case DS_MAX_RTN_I32               :\n        case DS_MIN_RTN_U32               :\n        case DS_MAX_RTN_U32               :\n        case DS_AND_RTN_B32               :\n        case DS_OR_RTN_B32                :\n        case DS_XOR_RTN_B32               :\n        case DS_MSKOR_RTN_B32             :\n        case DS_WRXCHG_RTN_B32            :\n        case DS_WRXCHG2_RTN_B32           :\n        case DS_WRXCHG2ST64_RTN_B32       :\n        case DS_CMPST_RTN_B32             :\n        case DS_CMPST_RTN_F32             :\n        case DS_MIN_RTN_F32               :\n        case DS_MAX_RTN_F32               :\n        case DS_WRAP_RTN_B32              :\n        case DS_SWIZZLE_B32               :\n        case DS_READ_B32                  :\n        case DS_READ2_B32                 :\n        case DS_READ2ST64_B32             :\n        case DS_READ_I8                   :\n        case DS_READ_U8                   :\n        case DS_READ_I16                  :\n        case DS_READ_U16                  :\n        case DS_CONSUME                   :\n        case DS_APPEND                    :\n        case DS_ORDERED_COUNT             :\n            return 1;\n        \n        case DS_ADD_U64                  :\n        case DS_SUB_U64                  :\n        case DS_RSUB_U64                 :\n        case DS_INC_U64                  :\n        case DS_DEC_U64                  :\n        case DS_MIN_I64                  :\n        case DS_MAX_I64                  :\n        case DS_MIN_U64                  :\n        case DS_MAX_U64                  :\n        case DS_AND_B64                  :\n        case DS_OR_B64                   :\n        case DS_XOR_B64                  :\n        case DS_MSKOR_B64                :\n        case DS_WRITE_B64                :\n        case DS_WRITE2_B64               :\n        case DS_WRITE2ST64_B64           :\n        case DS_CMPST_B64                :\n        case DS_CMPST_F64                :\n        case DS_MIN_F64                  :\n        case DS_MAX_F64                  :\n        case DS_ADD_RTN_U64              :\n        case DS_SUB_RTN_U64              :\n        case DS_RSUB_RTN_U64             :\n        case DS_INC_RTN_U64              :\n        case DS_DEC_RTN_U64              :\n        case DS_MIN_RTN_I64              :\n        case DS_MAX_RTN_I64              :\n        case DS_MIN_RTN_U64              :\n        case DS_MAX_RTN_U64              :\n        case DS_AND_RTN_B64              :\n        case DS_OR_RTN_B64               :\n        case DS_XOR_RTN_B64              :\n        case DS_MSKOR_RTN_B64            :\n        case DS_WRXCHG_RTN_B64           :\n        case DS_WRXCHG2_RTN_B64          :\n        case DS_WRXCHG2ST64_RTN_B64      :\n        case DS_CMPST_RTN_B64            :\n        case DS_CMPST_RTN_F64            :\n        case DS_MIN_RTN_F64              :\n        case DS_MAX_RTN_F64              :\n        case DS_READ_B64                 :\n        case DS_READ2_B64                :\n        case DS_READ2ST64_B64            :\n        case DS_CONDXCHG32_RTN_B64       :\n            return 2;\n\n        case DS_ADD_SRC2_U32             :\n        case DS_SUB_SRC2_U32             :\n        case DS_RSUB_SRC2_U32            :\n        case DS_INC_SRC2_U32             :\n        case DS_DEC_SRC2_U32             :\n        case DS_MIN_SRC2_I32             :\n        case DS_MAX_SRC2_I32             :\n        case DS_MIN_SRC2_U32             :\n        case DS_MAX_SRC2_U32             :\n        case DS_AND_SRC2_B32             :\n        case DS_OR_SRC2_B32              :\n        case DS_XOR_SRC2_B32             :\n        case DS_WRITE_SRC2_B32           :\n        case DS_MIN_SRC2_F32             :\n        case DS_MAX_SRC2_F32             :\n            return 1;\n\n        case DS_ADD_SRC2_U64             :\n        case DS_SUB_SRC2_U64             :\n        case DS_RSUB_SRC2_U64            :\n        case DS_INC_SRC2_U64             :\n        case DS_DEC_SRC2_U64             :\n        case DS_MIN_SRC2_I64             :\n        case DS_MAX_SRC2_I64             :\n        case DS_MIN_SRC2_U64             :\n        case DS_MAX_SRC2_U64             :\n        case DS_AND_SRC2_B64             :\n        case DS_OR_SRC2_B64              :\n        case DS_XOR_SRC2_B64             :\n        case DS_WRITE_SRC2_B64           :\n        case DS_MIN_SRC2_F64             :\n        case DS_MAX_SRC2_F64             :\n            return 2;\n\n        case DS_WRITE_B96                :\n        case DS_READ_B96                 :\n            return 3;\n\n        case DS_WRITE_B128               :\n        case DS_CONDXCHG32_RTN_B128      :\n        case DS_READ_B128                :\n            return 4;\n        }\n    }\n\n\n\n    uint ScalarInstruction::GetResultWidthInDWORDs() const\n    {\n        switch( GetOpcode() )\n        {\n        default: return 0;\n        case S_ADD_U32            :   //: D.u = S0.u + S1.u. SCC = carry out.\n        case S_SUB_U32            :   //: D.u = S0.u - S1.u. SCC = carry out.\n        case S_ADD_I32            :   //: D.u = S0.i + S1.i. SCC = overflow.\n        case S_SUB_I32            :   //: D.u = S0.i - S1.i. SCC = overflow.\n        case S_ADDC_U32           :   //: D.u = S0.u + S1.u + SCC. SCC = carry-out.\n        case S_SUBB_U32           :   //: D.u = S0.u - S1.u - SCC. SCC = carry-out.\n        case S_MIN_I32            :   //: D.i = (S0.i < S1.i) ? S0.i : S1.i. SCC = 1 if S0 is min.\n        case S_MIN_U32            :   //: D.u = (S0.u < S1.u) ? S0.u : S1.u. SCC = 1 if S0 is min.\n        case S_MAX_I32            :   //: D.i = (S0.i > S1.i) ? S0.i : S1.i. SCC = 1 if S0 is max.\n        case S_MAX_U32            :   //: D.u = (S0.u > S1.u) ? S0.u : S1.u. SCC = 1 if S0 is max.\n        case S_CSELECT_B32        :   //: D.u = SCC ? S0.u : S1.u.\n        case S_AND_B32            :   //: D.u = S0.u & S1.u. SCC = 1 if result is non-zero.\n        case S_OR_B32             :   //: D.u = S0.u | S1.u. SCC = 1 if result is non-zero.\n        case S_XOR_B32            :   //: D.u = S0.u ^ S1.u. SCC = 1 if result is non-zero.\n        case S_ANDN2_B32          :   //: D.u = S0.u & ~S1.u. SCC = 1 if result is non-zero.\n        case S_ORN2_B32           :   //: D.u = S0.u | ~S1.u. SCC = 1 if result is non-zero.\n        case S_NAND_B32           :   //: D.u = ~(S0.u & S1.u). SCC = 1 if result is non-zero.\n        case S_NOR_B32            :   //: D.u = ~(S0.u | S1.u). SCC = 1 if result is non-zero.\n        case S_XNOR_B32           :   //: D.u = ~(S0.u ^ S1.u). SCC = 1 if result is non-zero.\n        case S_LSHL_B32           :   //: D.u = S0.u << S1.u[4:0]. SCC = 1 if result is non-zero.\n        case S_LSHR_B32           :   //: D.u = S0.u >> S1.u[4:0]. SCC = 1 if result is non-zero.\n        case S_ASHR_I32           :   //: D.i = signtext(S0.i) >> S1.i[4:0]. SCC = 1 if result is non-zero.\n        case S_BFM_B32            :   //: D.u = ((1 << S0.u[4:0]) - 1) << S1.u[4:0]; bitfield mask.\n        case S_MUL_I32            :   //: D.i = S0.i * S1.i.\n        case S_BFE_U32            :    // : Bit field extract. S0 is data, S1[4:0] is field offset, S1[22:16] is field width. D.u = (S0.u >> S1.u[4:0]) & ((1 << S1.u[22:16]) - 1). SCC = 1 if resultis non-zero.\n        case S_BFE_I32            :\n        case S_ABSDIFF_I32        :  //  D.i = abs(S0.i >> S1.i). SCC = 1 if result is non-zero.\n        case S_MOVK_I32           :  //: D.i = signext(SIMM16).\n        case S_CMOVK_I32          :  //: if (SCC) D.i = signext(SIMM16); else NOP.\n        case S_CMPK_EQ_I32        :  //: SCC = (D.i == signext(SIMM16).\n        case S_CMPK_LG_I32        :  //: SCC = (D.i != signext(SIMM16).\n        case S_CMPK_GT_I32        :  //: SCC = (D.i != signext(SIMM16)).\n        case S_CMPK_GE_I32        :  //: SCC = (D.i >= signext(SIMM16)).\n        case S_CMPK_LT_I32        :  //: SCC = (D.i < signext(SIMM16)).\n        case S_CMPK_LE_I32        :  //: SCC = (D.i <= signext(SIMM16)).\n        case S_CMPK_EQ_U32        :  //: SCC = (D.u == SIMM16).\n        case S_CMPK_LG_U32        :  //: SCC = (D.u != SIMM16).\n        case S_CMPK_GT_U32        :  //: SCC = (D.u > SIMM16).\n        case S_CMPK_GE_U32        :  //: SCC = (D.u >= SIMM16).\n        case S_CMPK_LT_U32        :  //: SCC = (D.u < SIMM16).\n        case S_CMPK_LE_U32        : //: D.u = SCC = (D.u <= SIMM16).\n        case S_ADDK_I32           : //: D.i = D.i + signext(SIMM16). SCC = overflow.\n        case S_MULK_I32           : //: D.i = D.i * signext(SIMM16). SCC = overflow.\n        case S_GETREG_B32         : // : D.u = hardware register. Read some or all of a hardware register\n        case S_MOV_B32             ://: D.u = S0.u.\n        case S_CMOV_B32            ://: if(SCC) D.u = S0.u; else NOP.\n        case S_NOT_B32             ://: D.u = ~S0.u SCC = 1 if result non-zero.\n        case S_WQM_B32             ://: D.u = WholeQuadMode(S0.u). SCC = 1 if result is non-zero.\n        case S_BREV_B32            ://: D.u = S0.u[0:31] (reverse bits).\n        case S_BCNT0_I32_B32       ://: D.i = CountZeroBits(S0.u). SCC = 1 if result is non-zero.\n        case S_BCNT0_I32_B64       ://: D.i = CountZeroBits(S0.u). SCC = 1 if result is non-zero.\n        case S_BCNT1_I32_B32       ://: D.i = CountOneBits(S0.u). SCC = 1 if result is non-zero.\n        case S_BCNT1_I32_B64       ://: D.i = CountOneBits(S0.u). SCC = 1 if result is non-zero.\n        case S_FF0_I32_B32         ://: D.i = FindFirstZero(S0.u) from LSB; if no zeros, return -1.\n        case S_FF0_I32_B64         ://: D.i = FindFirstZero(S0.u) from LSB; if no zeros, return -1.\n        case S_FF1_I32_B32         ://: D.i = FindFirstOne(S0.u) from LSB; if no ones, return -1.\n        case S_FF1_I32_B64         ://: D.i = FindFirstOne(S0.u) from LSB; if no ones, return -1.\n        case S_FLBIT_I32_B32       ://: D.i = FindFirstOne(S0.u) from MSB; if no ones, return -1.\n        case S_FLBIT_I32_B64       ://: D.i = FindFirstOne(S0.u) from MSB; if no ones, return -1.\n        case S_FLBIT_I32           ://: D.i = Find first bit opposite of sign bit from MSB. If S0 == -1, return -1.\n        case S_FLBIT_I32_I64       ://: D.i = Find first bit opposite of sign bit from MSB. If S0 == -1, return -1.\n        case S_SEXT_I32_I8         ://: D.i = signext(S0.i[7:0]).\n        case S_SEXT_I32_I16        ://: D.i = signext(S0.i[15:0]).\n        case S_BITSET0_B32         ://: D.u[S0.u[4:0]] = 0.\n        case S_BITSET1_B32         ://: D.u[S0.u[4:0]] = 1.\n        case S_QUADMASK_B32        ://: D.u = QuadMask(S0.u). D[0] = OR(S0[3:0]), D[1] = OR(S0[7:4]) .... SCC = 1 if result is non-zero.\n        case S_MOVRELS_B32         ://: SGPR[D.u] = SGPR[S0.u + M0.u].\n        case S_MOVRELD_B32         ://: SGPR[D.u + M0.u] = SGPR[S0.u].\n        case S_ABS_I32             :      //: D.i = abs(S0.i). SCC=1 if result is non-zero.\n        case S_MOV_FED_B32         :      //: D.u = S0.u, introduce edc double error upon write to dest sgpr.  \n        case S_CMP_EQ_I32          :     //: SCC = (S0.i == S1.i).\n        case S_CMP_LG_I32          :     //: SCC = (S0.i != S1.i).\n        case S_CMP_GT_I32          :     //: SCC = (S0.i > S1.i).\n        case S_CMP_GE_I32          :     //: SCC = (S0.i >= S1.i).\n        case S_CMP_LT_I32          :     //: SCC = (S0.i < S1.i).\n        case S_CMP_LE_I32          :     //: SCC = (S0.i <= S1.i).\n        case S_CMP_EQ_U32          :     //: SCC = (S0.u == S1.u).\n        case S_CMP_LG_U32          :     //: SCC = (S0.u != S1.u).\n        case S_CMP_GT_U32          :     //: SCC = (S0.u > S1.u).\n        case S_CMP_GE_U32          :     //: SCC = (S0.u >= S1.u).\n        case S_CMP_LT_U32          :     //: SCC = (S0.u < S1.u).\n        case S_CMP_LE_U32          :     //: SCC = (S0.u <= S1.u).\n        case S_BITCMP0_B32         :     //: SCC = (S0.u[S1.u[4:0]] == 0).\n        case S_BITCMP1_B32         :     //: SCC = (S0.u[S1.u[4:0]] == 1).\n        case S_BITCMP0_B64         :     //: SCC = (S0.u[S1.u[5:0]] == 0).\n        case S_BITCMP1_B64         :     //: SCC = (S0.u[S1.u[5:0]] == 1).\n        case S_SETVSKIP            :     //: VSKIP = S0.u[S1.u[4:0]].\n        case S_CMP_EQ_U64:\n        case S_CMP_NE_U64:\n            return 1;\n\n        case S_AND_B64               :   //: D.u = S0.u & S1.u. SCC = 1 if result is non-zero.\n        case S_OR_B64                :   //: D.u = S0.u | S1.u. SCC = 1 if result is non-zero.\n        case S_XOR_B64               :   //: D.u = S0.u ^ S1.u. SCC = 1 if result is non-zero.\n        case S_ANDN2_B64             :   //: D.u = S0.u & ~S1.u. SCC = 1 if result is non-zero.\n        case S_ORN2_B64              :   //: D.u = S0.u | ~S1.u. SCC = 1 if result is non-zero.\n        case S_NAND_B64              :   //: D.u = ~(S0.u & S1.u). SCC = 1 if result is non-zero.\n        case S_NOR_B64               :   //: D.u = ~(S0.u | S1.u). SCC = 1 if result is non-zero.\n        case S_XNOR_B64              :   //: D.u = ~(S0.u ^ S1.u). SCC = 1 if result is non-zero.\n        case S_LSHL_B64              :   //: D.u = S0.u << S1.u[5:0]. SCC = 1 if result is non-zero.\n        case S_LSHR_B64              :   //: D.u = S0.u >> S1.u[5:0]. SCC = 1 if result is non-zero.\n        case S_ASHR_I64              :   //: D.i = signtext(S0.i) >> S1.i[5:0]. SCC = 1 if result is non-zero.\n        case S_BFM_B64               :   //: D.u = ((1 << S0.u[5:0]) - 1) << S1.u[5:0]; bitfield mask.\n        case S_BFE_U64               :\n        case S_BFE_I64               :\n        case S_MOV_B64               ://: D/u = S0.u.\n        case S_CMOV_B64              ://: if(SCC) D.u = S0.u; else NOP.\n        case S_NOT_B64               ://: D.u = ~S0.u SCC = 1 if result non-zero.\n        case S_WQM_B64               ://: D.u = WholeQuadMode(S0.u). SCC = 1 if result is non-zero.\n        case S_BREV_B64              ://: D.u = S0.u[0:63] (reverse bits).\n        case S_BITSET0_B64           ://: D.u[S0.u[5:0]] = 0.\n        case S_BITSET1_B64           ://: D.u[S0.u[5:0]] = 1.\n        case S_GETPC_B64             ://: D.u = PC + 4; destination receives the byte address of the next instruction.\n        case S_SWAPPC_B64            ://: D.u = PC + 4; PC = S0.u.\n        case S_AND_SAVEEXEC_B64      ://: D.u = EXEC, EXEC = S0.u & EXEC. SCC = 1 if the new value of EXEC is non-zero.\n        case S_OR_SAVEEXEC_B64       ://: D.u = EXEC, EXEC = S0.u | EXEC. SCC = 1 if the newvalue of EXEC is non-zero.\n        case S_XOR_SAVEEXEC_B64      ://: D.u = EXEC, EXEC = S0.u ^ EXEC. SCC = 1 if the new value of EXEC is non-zero.\n        case S_ANDN2_SAVEEXEC_B64    ://: D.u = EXEC, EXEC = S0.u & ~EXEC. SCC =1 if the new value of EXEC is non-zero.\n        case S_ORN2_SAVEEXEC_B64     ://: D.u = EXEC, EXEC = S0.u | ~EXEC. SCC = 1 if the new value of EXEC is non-zero.\n        case S_NAND_SAVEEXEC_B64     ://: D.u = EXEC, EXEC = ~(S0.u & EXEC). SCC =1 if the new value of EXEC is non-zero.\n        case S_NOR_SAVEEXEC_B64      ://: D.u = EXEC, EXEC = ~(S0.u | EXEC). SCC = 1 if the new value of EXEC is non-zero.\n        case S_XNOR_SAVEEXEC_B64     ://: D.u = EXEC, EXEC = ~(S0.u ^ EXEC). SCC = 1 if the new value of EXEC is non-zero.\n        case S_QUADMASK_B64          ://: D.u = QuadMask(S0.u). D[0] = OR(S0[3:0]),D[1] = OR(S0[7:4]) .... SCC = 1 if result is non-zero\n        case S_CSELECT_B64           :   //: D.u = SCC ? S0.u : S1.u.\n            return 2;\n\n        case S_CBRANCH_G_FORK           : // Conditional branch using branch stack. Arg0 = compare mask (VCC or any SGPR), Arg1 = 64-bit byte address of target instruction.\n        case S_CBRANCH_I_FORK           : //: Conditional branch using branch-stack.\n        case S_SETREG_B32               : // : hardware register = D.u. Write some or all of the LSBs of D\n        case S_SETREG_IMM32_B32         : //: This instruction uses a 32-bit literal constant. Write\n        case S_RFE_B64                  ://: Return from Exception; PC = TTMP1,0.\n        case S_SETPC_B64                ://: PC = S0.u; S0.u is a byte address of the instruction to jump to.\n        case S_MOVRELS_B64              ://: SGPR[D.u] = SGPR[S0.u + M0.u].\n        case S_MOVRELD_B64              ://: SGPR[D.u + M0.u] = SGPR[S0.u].\n        case S_CBRANCH_JOIN             ://: Conditional branch join point. Arg0 = saved CSP value. No dest.\n        case S_NOP                      :  //: do nothing. Repeat NOP 1..8 times based on SIMM16[2:0]. 0 = 1 time, 7 = 8 times.\n        case S_ENDPGM                   :  //: end of program; terminate wavefront.\n        case S_BRANCH                   :  //: PC = PC + signext(SIMM16 * 4) + 4.\n        case S_CBRANCH_SCC0             :  //: if(SCC == 0) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n        case S_CBRANCH_SCC1             :  //: if(SCC == 1) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n        case S_CBRANCH_VCCZ             :  //: if(VCC == 0) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n        case S_CBRANCH_VCCNZ            :  //: if(VCC != 0) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n        case S_CBRANCH_EXECZ            :  //: if(EXEC == 0) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n        case S_CBRANCH_EXECNZ           :  //: if(EXEC != 0) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n        case S_BARRIER                  :  //: Sync waves within a thread group.                              \n        case S_WAITCNT                  :  //: Wait for count of outstanding lds, vector-memory and\n        case S_SETHALT                  :  //: set HALT bit to value of SIMM16[0]. 1=halt, 0=resume. Halt is ignored while priv=1.\n        case S_SLEEP                    :  //: Cause a wave to sleep for approximately 64*SIMM16[2:0] clocks.\n        case S_SETPRIO                  :  //: User settable wave priority. 0 = lowest, 3 = highest.\n        case S_SENDMSG                  :  //: Send a message.\n        case S_SENDMSGHALT              :  //: Send a message and then HALT.\n        case S_TRAP                     :  //: Enter the trap handler. TrapID = SIMM16[7:0]. Wait for all instructions to complete, \n        case S_ICACHE_INV               :  //: Invalidate entire L1 I cache.\n        case S_INCPERFLEVEL             :  //: Increment performance counter specified in SIMM16[3:0] by 1.\n        case S_DECPERFLEVEL             :  //: Decrement performance counter specified in SIMM16[3:0] by 1.\n        case S_TTRACEDATA               :  //: Send M0 as user data to thread-trace.\n        case S_CBRANCH_CDBGSYS          :  // : If (conditional_debug_system != 0) then PC = PC + signext(SIMM16 * 4) + 4; else NOP.\n        case S_CBRANCH_CDBGUSER         :  // : If (conditional_debug_user != 0) then PC = PC + signext(SIMM16 * 4) + 4; else NOP.\n        case S_CBRANCH_CDBGSYS_OR_USER  :  // : If (conditional_debug_system || conditional_debug_user) then PC = PC + signext(SIMM16 * 4) + 4; else NOP.\n        case S_CBRANCH_CDBGSYS_AND_USER :  // : If (conditional_debug_system && conditional_debug_user) then PC = PC + signext(SIMM16 * 4) + 4; else NOP.\n        case S_RFE_RESTORE_B64:\n            return 0;\n        }\n\n    }\n\n    uint ScalarInstruction::GetArg0WidthInDWORDs() const\n    {\n        switch( GetOpcode() )\n        {\n        default: return 0;\n        case S_ADD_U32            :   //: D.u = S0.u + S1.u. SCC = carry out.\n        case S_SUB_U32            :   //: D.u = S0.u - S1.u. SCC = carry out.\n        case S_ADD_I32            :   //: D.u = S0.i + S1.i. SCC = overflow.\n        case S_SUB_I32            :   //: D.u = S0.i - S1.i. SCC = overflow.\n        case S_ADDC_U32           :   //: D.u = S0.u + S1.u + SCC. SCC = carry-out.\n        case S_SUBB_U32           :   //: D.u = S0.u - S1.u - SCC. SCC = carry-out.\n        case S_MIN_I32            :   //: D.i = (S0.i < S1.i) ? S0.i : S1.i. SCC = 1 if S0 is min.\n        case S_MIN_U32            :   //: D.u = (S0.u < S1.u) ? S0.u : S1.u. SCC = 1 if S0 is min.\n        case S_MAX_I32            :   //: D.i = (S0.i > S1.i) ? S0.i : S1.i. SCC = 1 if S0 is max.\n        case S_MAX_U32            :   //: D.u = (S0.u > S1.u) ? S0.u : S1.u. SCC = 1 if S0 is max.\n        case S_CSELECT_B32        :   //: D.u = SCC ? S0.u : S1.u.\n        case S_AND_B32            :   //: D.u = S0.u & S1.u. SCC = 1 if result is non-zero.\n        case S_OR_B32             :   //: D.u = S0.u | S1.u. SCC = 1 if result is non-zero.\n        case S_XOR_B32            :   //: D.u = S0.u ^ S1.u. SCC = 1 if result is non-zero.\n        case S_ANDN2_B32          :   //: D.u = S0.u & ~S1.u. SCC = 1 if result is non-zero.\n        case S_ORN2_B32           :   //: D.u = S0.u | ~S1.u. SCC = 1 if result is non-zero.\n        case S_NAND_B32           :   //: D.u = ~(S0.u & S1.u). SCC = 1 if result is non-zero.\n        case S_NOR_B32            :   //: D.u = ~(S0.u | S1.u). SCC = 1 if result is non-zero.\n        case S_XNOR_B32           :   //: D.u = ~(S0.u ^ S1.u). SCC = 1 if result is non-zero.\n        case S_LSHL_B32           :   //: D.u = S0.u << S1.u[4:0]. SCC = 1 if result is non-zero.\n        case S_LSHR_B32           :   //: D.u = S0.u >> S1.u[4:0]. SCC = 1 if result is non-zero.\n        case S_ASHR_I32           :   //: D.i = signtext(S0.i) >> S1.i[4:0]. SCC = 1 if result is non-zero.\n        case S_BFM_B32            :   //: D.u = ((1 << S0.u[4:0]) - 1) << S1.u[4:0]; bitfield mask.\n        case S_MUL_I32            :   //: D.i = S0.i * S1.i.\n        case S_BFE_U32            :    // : Bit field extract. S0 is data, S1[4:0] is field offset, S1[22:16] is field width. D.u = (S0.u >> S1.u[4:0]) & ((1 << S1.u[22:16]) - 1). SCC = 1 if resultis non-zero.\n        case S_BFE_I32            :\n        case S_ABSDIFF_I32        :  //  D.i = abs(S0.i >> S1.i). SCC = 1 if result is non-zero.\n        case S_MOVK_I32           :  //: D.i = signext(SIMM16).\n        case S_CMOVK_I32          :  //: if (SCC) D.i = signext(SIMM16); else NOP.\n        case S_CMPK_EQ_I32        :  //: SCC = (D.i == signext(SIMM16).\n        case S_CMPK_LG_I32        :  //: SCC = (D.i != signext(SIMM16).\n        case S_CMPK_GT_I32        :  //: SCC = (D.i != signext(SIMM16)).\n        case S_CMPK_GE_I32        :  //: SCC = (D.i >= signext(SIMM16)).\n        case S_CMPK_LT_I32        :  //: SCC = (D.i < signext(SIMM16)).\n        case S_CMPK_LE_I32        :  //: SCC = (D.i <= signext(SIMM16)).\n        case S_CMPK_EQ_U32        :  //: SCC = (D.u == SIMM16).\n        case S_CMPK_LG_U32        :  //: SCC = (D.u != SIMM16).\n        case S_CMPK_GT_U32        :  //: SCC = (D.u > SIMM16).\n        case S_CMPK_GE_U32        :  //: SCC = (D.u >= SIMM16).\n        case S_CMPK_LT_U32        :  //: SCC = (D.u < SIMM16).\n        case S_CMPK_LE_U32        : //: D.u = SCC = (D.u <= SIMM16).\n        case S_ADDK_I32           : //: D.i = D.i + signext(SIMM16). SCC = overflow.\n        case S_MULK_I32           : //: D.i = D.i * signext(SIMM16). SCC = overflow.\n        case S_GETREG_B32         : // : D.u = hardware register. Read some or all of a hardware register\n        case S_MOV_B32             ://: D.u = S0.u.\n        case S_CMOV_B32            ://: if(SCC) D.u = S0.u; else NOP.\n        case S_NOT_B32             ://: D.u = ~S0.u SCC = 1 if result non-zero.\n        case S_WQM_B32             ://: D.u = WholeQuadMode(S0.u). SCC = 1 if result is non-zero.\n        case S_BREV_B32            ://: D.u = S0.u[0:31] (reverse bits).\n        case S_BCNT0_I32_B32       ://: D.i = CountZeroBits(S0.u). SCC = 1 if result is non-zero.\n        case S_BCNT1_I32_B32       ://: D.i = CountOneBits(S0.u). SCC = 1 if result is non-zero.\n        case S_FF0_I32_B32         ://: D.i = FindFirstZero(S0.u) from LSB; if no zeros, return -1.\n        case S_FF1_I32_B32         ://: D.i = FindFirstOne(S0.u) from LSB; if no ones, return -1.\n        case S_FLBIT_I32_B32       ://: D.i = FindFirstOne(S0.u) from MSB; if no ones, return -1.\n        case S_FLBIT_I32           ://: D.i = Find first bit opposite of sign bit from MSB. If S0 == -1, return -1.\n        case S_SEXT_I32_I8         ://: D.i = signext(S0.i[7:0]).\n        case S_SEXT_I32_I16        ://: D.i = signext(S0.i[15:0]).\n        case S_BITSET0_B32         ://: D.u[S0.u[4:0]] = 0.\n        case S_BITSET1_B32         ://: D.u[S0.u[4:0]] = 1.\n        case S_QUADMASK_B32        ://: D.u = QuadMask(S0.u). D[0] = OR(S0[3:0]), D[1] = OR(S0[7:4]) .... SCC = 1 if result is non-zero.\n        case S_MOVRELS_B32         ://: SGPR[D.u] = SGPR[S0.u + M0.u].\n        case S_MOVRELD_B32         ://: SGPR[D.u + M0.u] = SGPR[S0.u].\n        case S_ABS_I32             :      //: D.i = abs(S0.i). SCC=1 if result is non-zero.\n        case S_MOV_FED_B32         :      //: D.u = S0.u, introduce edc double error upon write to dest sgpr.  \n        case S_CMP_EQ_I32          :     //: SCC = (S0.i == S1.i).\n        case S_CMP_LG_I32          :     //: SCC = (S0.i != S1.i).\n        case S_CMP_GT_I32          :     //: SCC = (S0.i > S1.i).\n        case S_CMP_GE_I32          :     //: SCC = (S0.i >= S1.i).\n        case S_CMP_LT_I32          :     //: SCC = (S0.i < S1.i).\n        case S_CMP_LE_I32          :     //: SCC = (S0.i <= S1.i).\n        case S_CMP_EQ_U32          :     //: SCC = (S0.u == S1.u).\n        case S_CMP_LG_U32          :     //: SCC = (S0.u != S1.u).\n        case S_CMP_GT_U32          :     //: SCC = (S0.u > S1.u).\n        case S_CMP_GE_U32          :     //: SCC = (S0.u >= S1.u).\n        case S_CMP_LT_U32          :     //: SCC = (S0.u < S1.u).\n        case S_CMP_LE_U32          :     //: SCC = (S0.u <= S1.u).\n        case S_BITCMP0_B32         :     //: SCC = (S0.u[S1.u[4:0]] == 0).\n        case S_BITCMP1_B32         :     //: SCC = (S0.u[S1.u[4:0]] == 1).\n        case S_SETVSKIP            :     //: VSKIP = S0.u[S1.u[4:0]].\n        case S_SETREG_B32          : // : hardware register = D.u. Write some or all of the LSBs of D\n        case S_SETREG_IMM32_B32    : //: This instruction uses a 32-bit literal constant. Write\n        case S_SET_GPR_IDX_IDX     : \n        case S_SET_GPR_IDX_ON:\n            return 1;\n\n        case S_MOVRELS_B64         ://: SGPR[D.u] = SGPR[S0.u + M0.u].\n        case S_MOVRELD_B64         ://: SGPR[D.u + M0.u] = SGPR[S0.u].\n        case S_BITCMP0_B64         :     //: SCC = (S0.u[S1.u[5:0]] == 0).\n        case S_BITCMP1_B64         :     //: SCC = (S0.u[S1.u[5:0]] == 1).\n        case S_BCNT0_I32_B64       ://: D.i = CountZeroBits(S0.u). SCC = 1 if result is non-zero.\n        case S_BCNT1_I32_B64       ://: D.i = CountOneBits(S0.u). SCC = 1 if result is non-zero.\n        case S_FF0_I32_B64         ://: D.i = FindFirstZero(S0.u) from LSB; if no zeros, return -1.\n        case S_FF1_I32_B64         ://: D.i = FindFirstOne(S0.u) from LSB; if no ones, return -1.\n        case S_FLBIT_I32_B64       ://: D.i = FindFirstOne(S0.u) from MSB; if no ones, return -1.\n        case S_FLBIT_I32_I64       ://: D.i = Find first bit opposite of sign bit from MSB. If S0 == -1, return -1.\n        case S_AND_B64               :   //: D.u = S0.u & S1.u. SCC = 1 if result is non-zero.\n        case S_OR_B64                :   //: D.u = S0.u | S1.u. SCC = 1 if result is non-zero.\n        case S_XOR_B64               :   //: D.u = S0.u ^ S1.u. SCC = 1 if result is non-zero.\n        case S_ANDN2_B64             :   //: D.u = S0.u & ~S1.u. SCC = 1 if result is non-zero.\n        case S_ORN2_B64              :   //: D.u = S0.u | ~S1.u. SCC = 1 if result is non-zero.\n        case S_NAND_B64              :   //: D.u = ~(S0.u & S1.u). SCC = 1 if result is non-zero.\n        case S_NOR_B64               :   //: D.u = ~(S0.u | S1.u). SCC = 1 if result is non-zero.\n        case S_XNOR_B64              :   //: D.u = ~(S0.u ^ S1.u). SCC = 1 if result is non-zero.\n        case S_LSHL_B64              :   //: D.u = S0.u << S1.u[5:0]. SCC = 1 if result is non-zero.\n        case S_LSHR_B64              :   //: D.u = S0.u >> S1.u[5:0]. SCC = 1 if result is non-zero.\n        case S_ASHR_I64              :   //: D.i = signtext(S0.i) >> S1.i[5:0]. SCC = 1 if result is non-zero.\n        case S_BFM_B64               :   //: D.u = ((1 << S0.u[5:0]) - 1) << S1.u[5:0]; bitfield mask.\n        case S_BFE_U64               :\n        case S_BFE_I64               :\n        case S_MOV_B64               ://: D/u = S0.u.\n        case S_CMOV_B64              ://: if(SCC) D.u = S0.u; else NOP.\n        case S_NOT_B64               ://: D.u = ~S0.u SCC = 1 if result non-zero.\n        case S_WQM_B64               ://: D.u = WholeQuadMode(S0.u). SCC = 1 if result is non-zero.\n        case S_BREV_B64              ://: D.u = S0.u[0:63] (reverse bits).\n        case S_BITSET0_B64           ://: D.u[S0.u[5:0]] = 0.\n        case S_BITSET1_B64           ://: D.u[S0.u[5:0]] = 1.\n        case S_GETPC_B64             ://: D.u = PC + 4; destination receives the byte address of the next instruction.\n        case S_SWAPPC_B64            ://: D.u = PC + 4; PC = S0.u.\n        case S_AND_SAVEEXEC_B64      ://: D.u = EXEC, EXEC = S0.u & EXEC. SCC = 1 if the new value of EXEC is non-zero.\n        case S_OR_SAVEEXEC_B64       ://: D.u = EXEC, EXEC = S0.u | EXEC. SCC = 1 if the newvalue of EXEC is non-zero.\n        case S_XOR_SAVEEXEC_B64      ://: D.u = EXEC, EXEC = S0.u ^ EXEC. SCC = 1 if the new value of EXEC is non-zero.\n        case S_ANDN2_SAVEEXEC_B64    ://: D.u = EXEC, EXEC = S0.u & ~EXEC. SCC =1 if the new value of EXEC is non-zero.\n        case S_ORN2_SAVEEXEC_B64     ://: D.u = EXEC, EXEC = S0.u | ~EXEC. SCC = 1 if the new value of EXEC is non-zero.\n        case S_NAND_SAVEEXEC_B64     ://: D.u = EXEC, EXEC = ~(S0.u & EXEC). SCC =1 if the new value of EXEC is non-zero.\n        case S_NOR_SAVEEXEC_B64      ://: D.u = EXEC, EXEC = ~(S0.u | EXEC). SCC = 1 if the new value of EXEC is non-zero.\n        case S_XNOR_SAVEEXEC_B64     ://: D.u = EXEC, EXEC = ~(S0.u ^ EXEC). SCC = 1 if the new value of EXEC is non-zero.\n        case S_QUADMASK_B64          ://: D.u = QuadMask(S0.u). D[0] = OR(S0[3:0]),D[1] = OR(S0[7:4]) .... SCC = 1 if result is non-zero\n        case S_CSELECT_B64           :   //: D.u = SCC ? S0.u : S1.u.\n        case S_CBRANCH_G_FORK        : // Conditional branch using branch stack. Arg0 = compare mask (VCC or any SGPR), Arg1 = 64-bit byte address of target instruction.\n        case S_CBRANCH_I_FORK        : //: Conditional branch using branch-stack.\n        case S_CBRANCH_JOIN             ://: Conditional branch join point. Arg0 = saved CSP value. No dest.\n        case S_RFE_B64                  ://: Return from Exception; PC = TTMP1,0.\n        case S_SETPC_B64                ://: PC = S0.u; S0.u is a byte address of the instruction to jump to.\n        case S_RFE_RESTORE_B64     :\n        case S_CMP_EQ_U64:\n        case S_CMP_NE_U64:\n            return 2;\n\n        case S_NOP                      :  //: do nothing. Repeat NOP 1..8 times based on SIMM16[2:0]. 0 = 1 time, 7 = 8 times.\n        case S_ENDPGM                   :  //: end of program; terminate wavefront.\n        case S_BRANCH                   :  //: PC = PC + signext(SIMM16 * 4) + 4.\n        case S_CBRANCH_SCC0             :  //: if(SCC == 0) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n        case S_CBRANCH_SCC1             :  //: if(SCC == 1) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n        case S_CBRANCH_VCCZ             :  //: if(VCC == 0) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n        case S_CBRANCH_VCCNZ            :  //: if(VCC != 0) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n        case S_CBRANCH_EXECZ            :  //: if(EXEC == 0) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n        case S_CBRANCH_EXECNZ           :  //: if(EXEC != 0) then PC = PC + signext(SIMM16 * 4) + 4; else nop.\n        case S_BARRIER                  :  //: Sync waves within a thread group.                              \n        case S_WAITCNT                  :  //: Wait for count of outstanding lds, vector-memory and\n        case S_SETHALT                  :  //: set HALT bit to value of SIMM16[0]. 1=halt, 0=resume. Halt is ignored while priv=1.\n        case S_SLEEP                    :  //: Cause a wave to sleep for approximately 64*SIMM16[2:0] clocks.\n        case S_SETPRIO                  :  //: User settable wave priority. 0 = lowest, 3 = highest.\n        case S_SENDMSG                  :  //: Send a message.\n        case S_SENDMSGHALT              :  //: Send a message and then HALT.\n        case S_TRAP                     :  //: Enter the trap handler. TrapID = SIMM16[7:0]. Wait for all instructions to complete, \n        case S_ICACHE_INV               :  //: Invalidate entire L1 I cache.\n        case S_INCPERFLEVEL             :  //: Increment performance counter specified in SIMM16[3:0] by 1.\n        case S_DECPERFLEVEL             :  //: Decrement performance counter specified in SIMM16[3:0] by 1.\n        case S_TTRACEDATA               :  //: Send M0 as user data to thread-trace.\n        case S_CBRANCH_CDBGSYS          :  // : If (conditional_debug_system != 0) then PC = PC + signext(SIMM16 * 4) + 4; else NOP.\n        case S_CBRANCH_CDBGUSER         :  // : If (conditional_debug_user != 0) then PC = PC + signext(SIMM16 * 4) + 4; else NOP.\n        case S_CBRANCH_CDBGSYS_OR_USER  :  // : If (conditional_debug_system || conditional_debug_user) then PC = PC + signext(SIMM16 * 4) + 4; else NOP.\n        case S_CBRANCH_CDBGSYS_AND_USER :  // : If (conditional_debug_system && conditional_debug_user) then PC = PC + signext(SIMM16 * 4) + 4; else NOP.\n            return 0;\n        }\n    }\n\n    uint ScalarInstruction::GetArg1WidthInDWORDs() const\n    {\n        switch( GetOpcode() )\n        {\n        default:\n            return 0;\n        case S_ADD_U32               :  //: D.u = S0.u + S1.u. SCC = carry out.\n        case S_SUB_U32               :  //: D.u = S0.u - S1.u. SCC = carry out.\n        case S_ADD_I32               :  //: D.u = S0.i + S1.i. SCC = overflow.\n        case S_SUB_I32               :  //: D.u = S0.i - S1.i. SCC = overflow.\n        case S_ADDC_U32              :  //: D.u = S0.u + S1.u + SCC. SCC = carry-out.\n        case S_SUBB_U32              :  //: D.u = S0.u - S1.u - SCC. SCC = carry-out.\n        case S_MIN_I32               :  //: D.i = (S0.i < S1.i) ? S0.i : S1.i. SCC = 1 if S0 is min.\n        case S_MIN_U32               :  //: D.u = (S0.u < S1.u) ? S0.u : S1.u. SCC = 1 if S0 is min.\n        case S_MAX_I32               :  //: D.i = (S0.i > S1.i) ? S0.i : S1.i. SCC = 1 if S0 is max.\n        case S_MAX_U32               :  //: D.u = (S0.u > S1.u) ? S0.u : S1.u. SCC = 1 if S0 is max.\n        case S_AND_B32               :  //: D.u = S0.u & S1.u. SCC = 1 if result is non-zero.\n        case S_CSELECT_B32           :  //: D.u = SCC ? S0.u : S1.u.\n        case S_OR_B32                :  //: D.u = S0.u | S1.u. SCC = 1 if result is non-zero.\n        case S_XOR_B32               :  //: D.u = S0.u ^ S1.u. SCC = 1 if result is non-zero.\n        case S_ANDN2_B32             :  //: D.u = S0.u & ~S1.u. SCC = 1 if result is non-zero.\n        case S_ORN2_B32              :  //: D.u = S0.u | ~S1.u. SCC = 1 if result is non-zero.\n        case S_NAND_B32              :  //: D.u = ~(S0.u & S1.u). SCC = 1 if result is non-zero.\n        case S_NOR_B32               :  //: D.u = ~(S0.u | S1.u). SCC = 1 if result is non-zero.\n        case S_XNOR_B32              :  //: D.u = ~(S0.u ^ S1.u). SCC = 1 if result is non-zero.\n        case S_LSHL_B32              :  //: D.u = S0.u << S1.u[4:0]. SCC = 1 if result is non-zero.\n        case S_LSHR_B32              :  //: D.u = S0.u >> S1.u[4:0]. SCC = 1 if result is non-zero.\n        case S_ASHR_I32              :  //: D.i = signtext(S0.i) >> S1.i[4:0]. SCC = 1 if result is non-zero.\n        case S_BFM_B32               :  //: D.u = ((1 << S0.u[4:0]) - 1) << S1.u[4:0]; bitfield mask.\n        case S_LSHL_B64              :  //: D.u = S0.u << S1.u[5:0]. SCC = 1 if result is non-zero.\n        case S_LSHR_B64              :  //: D.u = S0.u >> S1.u[5:0]. SCC = 1 if result is non-zero.\n        case S_ASHR_I64              :  //: D.i = signtext(S0.i) >> S1.i[5:0]. SCC = 1 if result is non-zero.\n        case S_BFM_B64               :  //: D.u = ((1 << S0.u[5:0]) - 1) << S1.u[5:0]; bitfield mask.\n        case S_BFE_U32               :   // : Bit field extract. S0 is data, S1[4:0] is field offset, S1[22:16] is field width. D.u = (S0.u >> S1.u[4:0]) & ((1 << S1.u[22:16]) - 1). SCC = 1 if resultis non-zero.\n        case S_BFE_I32               :\n        case S_BFE_U64               :\n        case S_BFE_I64               :\n        case S_ABSDIFF_I32           : //  D.i = abs(S0.i >> S1.i). SCC = 1 if result is non-zero.\n        case S_MUL_I32               :  //: D.i = S0.i * S1.i.\n        case S_CMP_EQ_I32            :    //: SCC = (S0.i == S1.i).\n        case S_CMP_LG_I32            :    //: SCC = (S0.i != S1.i).\n        case S_CMP_GT_I32            :    //: SCC = (S0.i > S1.i).\n        case S_CMP_GE_I32            :    //: SCC = (S0.i >= S1.i).\n        case S_CMP_LT_I32            :    //: SCC = (S0.i < S1.i).\n        case S_CMP_LE_I32            :    //: SCC = (S0.i <= S1.i).\n        case S_CMP_EQ_U32            :    //: SCC = (S0.u == S1.u).\n        case S_CMP_LG_U32            :    //: SCC = (S0.u != S1.u).\n        case S_CMP_GT_U32            :    //: SCC = (S0.u > S1.u).\n        case S_CMP_GE_U32            :    //: SCC = (S0.u >= S1.u).\n        case S_CMP_LT_U32            :    //: SCC = (S0.u < S1.u).\n        case S_CMP_LE_U32            :    //: SCC = (S0.u <= S1.u).\n        case S_BITCMP0_B32           :    //: SCC = (S0.u[S1.u[4:0]] == 0).\n        case S_BITCMP1_B32           :    //: SCC = (S0.u[S1.u[4:0]] == 1).\n        case S_BITCMP0_B64           :    //: SCC = (S0.u[S1.u[5:0]] == 0).\n        case S_BITCMP1_B64           :    //: SCC = (S0.u[S1.u[5:0]] == 1).\n        case S_SETVSKIP              :    //: VSKIP = S0.u[S1.u[4:0]].\n        case S_RFE_RESTORE_B64:\n        case S_SET_GPR_IDX_ON:\n            return 1;\n             \n        case S_CSELECT_B64    :   //: D.u = SCC ? S0.u : S1.u.       \n        case S_AND_B64        :   //: D.u = S0.u & S1.u. SCC = 1 if result is non-zero.\n        case S_OR_B64         :   //: D.u = S0.u | S1.u. SCC = 1 if result is non-zero.\n        case S_XOR_B64        :   //: D.u = S0.u ^ S1.u. SCC = 1 if result is non-zero.\n        case S_ANDN2_B64      :   //: D.u = S0.u & ~S1.u. SCC = 1 if result is non-zero.\n        case S_ORN2_B64       :   //: D.u = S0.u | ~S1.u. SCC = 1 if result is non-zero.\n        case S_NAND_B64       :   //: D.u = ~(S0.u & S1.u). SCC = 1 if result is non-zero.\n        case S_NOR_B64        :   //: D.u = ~(S0.u | S1.u). SCC = 1 if result is non-zero.\n        case S_XNOR_B64       :   //: D.u = ~(S0.u ^ S1.u). SCC = 1 if result is non-zero.\n        case S_CBRANCH_G_FORK : // Conditional branch using branch stack. Arg0 = compare mask (VCC or any SGPR), Arg1 = 64-bit byte address of target instruction.\n        case S_CMP_EQ_U64:\n        case S_CMP_NE_U64:\n            return 2;\n        }\n    }\n\n\n\n    uint GetResultWidthInDWORDs(BufferInstructions e) \n    {\n        switch( e )\n        {\n        case BUFFER_LOAD_FORMAT_X            :\n        case BUFFER_STORE_FORMAT_X           :\n        case BUFFER_LOAD_UBYTE               :\n        case BUFFER_LOAD_SBYTE               :\n        case BUFFER_LOAD_USHORT              :\n        case BUFFER_LOAD_SSHORT              :\n        case BUFFER_LOAD_DWORD               :\n        case BUFFER_STORE_BYTE               :\n        case BUFFER_STORE_SHORT              :\n        case BUFFER_STORE_DWORD              :\n            return 1;\n\n        case BUFFER_STORE_FORMAT_XY          :\n        case BUFFER_LOAD_FORMAT_XY           :\n        case BUFFER_LOAD_DWORDX2             :\n        case BUFFER_STORE_DWORDX2            :\n            return 2;\n\n        case BUFFER_STORE_FORMAT_XYZ         :\n        case BUFFER_LOAD_FORMAT_XYZ          :\n        case BUFFER_LOAD_DWORDX3             :\n        case BUFFER_STORE_DWORDX3            :\n            return 3;\n        case BUFFER_STORE_FORMAT_XYZW        :\n        case BUFFER_LOAD_FORMAT_XYZW         :            \n        case BUFFER_LOAD_DWORDX4             :\n        case BUFFER_STORE_DWORDX4            :\n            return 4;\n\n        case BUFFER_ATOMIC_SWAP              :\n        case BUFFER_ATOMIC_CMPSWAP           :\n        case BUFFER_ATOMIC_ADD               :\n        case BUFFER_ATOMIC_SUB               :\n        case BUFFER_ATOMIC_RSUB              :\n        case BUFFER_ATOMIC_SMIN              :\n        case BUFFER_ATOMIC_UMIN              :\n        case BUFFER_ATOMIC_SMAX              :\n        case BUFFER_ATOMIC_UMAX              :\n        case BUFFER_ATOMIC_AND               :\n        case BUFFER_ATOMIC_OR                :\n        case BUFFER_ATOMIC_XOR               :\n        case BUFFER_ATOMIC_INC               :\n        case BUFFER_ATOMIC_DEC               :\n        case BUFFER_ATOMIC_FCMPSWAP          :\n        case BUFFER_ATOMIC_FMIN              :\n        case BUFFER_ATOMIC_FMAX              :\n            return 1;\n\n        case BUFFER_ATOMIC_SWAP_X2           :\n        case BUFFER_ATOMIC_CMPSWAP_X2        :\n        case BUFFER_ATOMIC_ADD_X2            :\n        case BUFFER_ATOMIC_SUB_X2            :\n        case BUFFER_ATOMIC_RSUB_X2           :\n        case BUFFER_ATOMIC_SMIN_X2           :\n        case BUFFER_ATOMIC_UMIN_X2           :\n        case BUFFER_ATOMIC_SMAX_X2           :\n        case BUFFER_ATOMIC_UMAX_X2           :\n        case BUFFER_ATOMIC_AND_X2            :\n        case BUFFER_ATOMIC_OR_X2             :\n        case BUFFER_ATOMIC_XOR_X2            :\n        case BUFFER_ATOMIC_INC_X2            :\n        case BUFFER_ATOMIC_DEC_X2            :\n        case BUFFER_ATOMIC_FCMPSWAP_X2       :\n        case BUFFER_ATOMIC_FMIN_X2           :\n        case BUFFER_ATOMIC_FMAX_X2           :\n            return 2;\n        case TBUFFER_LOAD_FORMAT_X      :\n        case TBUFFER_STORE_FORMAT_X     :\n        case TBUFFER_LOAD_FORMAT_D16_X  :    \n        case TBUFFER_STORE_FORMAT_D16_X :\n            return 1;\n        case TBUFFER_LOAD_FORMAT_XY     :\n        case TBUFFER_STORE_FORMAT_XY    :\n        case TBUFFER_LOAD_FORMAT_D16_XY :\n        case TBUFFER_STORE_FORMAT_D16_XY:  \n            return 2;\n        case TBUFFER_LOAD_FORMAT_XYZ    :\n        case TBUFFER_STORE_FORMAT_XYZ   :\n        case TBUFFER_LOAD_FORMAT_D16_XYZ :  \n        case TBUFFER_STORE_FORMAT_D16_XYZ:\n            return 3;\n        case TBUFFER_LOAD_FORMAT_XYZW   :\n        case TBUFFER_STORE_FORMAT_XYZW  :\n        case TBUFFER_LOAD_FORMAT_D16_XYZW :\n        case TBUFFER_STORE_FORMAT_D16_XYZW: \n            return 4;\n\n        case BUFFER_STORE_LDS_DWORD        :     \n        case BUFFER_LOAD_FORMAT_D16_X      : \n        case BUFFER_STORE_FORMAT_D16_X     : \n            return 1;\n        case BUFFER_LOAD_FORMAT_D16_XY     : \n        case BUFFER_STORE_FORMAT_D16_XY    : \n            return 2;\n        case BUFFER_LOAD_FORMAT_D16_XYZ    : \n        case BUFFER_STORE_FORMAT_D16_XYZ   : \n            return 3;\n        case BUFFER_LOAD_FORMAT_D16_XYZW   : \n        case BUFFER_STORE_FORMAT_D16_XYZW  : \n            return 4;\n\n        default:\n        case BUFFER_WBINVL1_VOL      :\n        case BUFFER_WBINVL1_SC               :\n        case BUFFER_WBINVL1                  :\n            return 0;\n        }\n    }\n\n\n    bool IsTBufferInstruction( BufferInstructions e )\n    {\n        switch(e)\n        {\n        case TBUFFER_LOAD_FORMAT_X      :\n        case TBUFFER_STORE_FORMAT_X     :\n        case TBUFFER_LOAD_FORMAT_XY     :\n        case TBUFFER_STORE_FORMAT_XY    :\n        case TBUFFER_LOAD_FORMAT_XYZ    :\n        case TBUFFER_STORE_FORMAT_XYZ   :\n        case TBUFFER_LOAD_FORMAT_XYZW   :\n        case TBUFFER_STORE_FORMAT_XYZW  :\n        case TBUFFER_LOAD_FORMAT_D16_X     :  \n        case TBUFFER_LOAD_FORMAT_D16_XY    :\n        case TBUFFER_LOAD_FORMAT_D16_XYZ   :\n        case TBUFFER_LOAD_FORMAT_D16_XYZW  :\n        case TBUFFER_STORE_FORMAT_D16_X    :\n        case TBUFFER_STORE_FORMAT_D16_XY   :\n        case TBUFFER_STORE_FORMAT_D16_XYZ  :\n        case TBUFFER_STORE_FORMAT_D16_XYZW :\n            return true;\n        default:\n            return false;\n        }\n    }\n\n\n\n    bool ScalarInstruction::IsControlFlowOp() const\n    {\n        switch( GetOpcode() )\n        {\n        case S_CBRANCH_G_FORK              :\n        case S_CBRANCH_I_FORK              :\n        case S_SETPC_B64                   :\n        case S_SWAPPC_B64                  :\n        case S_RFE_B64                     :\n        case S_CBRANCH_JOIN                :\n        case S_ENDPGM                      :\n        case S_BRANCH                      :\n        case S_CBRANCH_SCC0                :\n        case S_CBRANCH_SCC1                :\n        case S_CBRANCH_VCCZ                :\n        case S_CBRANCH_VCCNZ               :\n        case S_CBRANCH_EXECZ               :\n        case S_CBRANCH_EXECNZ              :\n        case S_BARRIER                     :\n        case S_SETHALT                     :\n        case S_SENDMSGHALT                 :\n        case S_TRAP                        :               \n        case S_CBRANCH_CDBGSYS             :\n        case S_CBRANCH_CDBGUSER            :\n        case S_CBRANCH_CDBGSYS_OR_USER     :\n        case S_CBRANCH_CDBGSYS_AND_USER    :\n        case S_RFE_RESTORE_B64:\n        case S_ENDPGM_SAVED:\n            return true;\n        default:\n            return false;\n        }\n    }\n\n    bool ScalarInstruction::IsConditionalJump() const\n    {\n        switch( GetOpcode() )\n        {\n        case S_CBRANCH_G_FORK              :\n        case S_CBRANCH_I_FORK              :\n        case S_CBRANCH_JOIN                :\n        case S_CBRANCH_SCC0                :\n        case S_CBRANCH_SCC1                :\n        case S_CBRANCH_VCCZ                :\n        case S_CBRANCH_VCCNZ               :\n        case S_CBRANCH_EXECZ               :\n        case S_CBRANCH_EXECNZ              :\n        case S_CBRANCH_CDBGSYS             :\n        case S_CBRANCH_CDBGUSER            :\n        case S_CBRANCH_CDBGSYS_OR_USER     :\n        case S_CBRANCH_CDBGSYS_AND_USER    :\n            return true;\n\n        default:\n            return false;\n        }\n    }\n\n    bool ScalarInstruction::IsUnconditionalJump() const\n    {\n        switch( GetOpcode() )\n        {\n        case S_SETPC_B64                   :\n        case S_SWAPPC_B64                  :\n        case S_RFE_B64                     :\n        case S_TRAP                        :               \n        case S_RFE_RESTORE_B64             :\n        case S_BRANCH                      :\n            return true;\n\n        default:\n            return false;\n        }\n    }\n\n    bool ScalarInstruction::IsWavefrontHalt() const\n    {\n        switch( GetOpcode() )\n        {\n        case S_ENDPGM                      :\n        case S_SETHALT                     :\n        case S_SENDMSGHALT                 :\n            return true;\n        default:\n            return false;\n        }\n    }\n\n\n    uint ScalarMemoryInstruction::GetResourceWidthInDWORDs() const\n    {\n        switch( GetOpcode() )\n        {\n        case S_LOAD_DWORD          : \n        case S_LOAD_DWORDX2        : \n        case S_LOAD_DWORDX4        : \n        case S_LOAD_DWORDX8        : \n        case S_LOAD_DWORDX16       : \n        case S_STORE_DWORD         : \n        case S_STORE_DWORDX2       : \n        case S_STORE_DWORDX4       : \n        case S_ATC_PROBE           : \n            return 2;\n        case S_BUFFER_LOAD_DWORD   : \n        case S_BUFFER_LOAD_DWORDX2 : \n        case S_BUFFER_LOAD_DWORDX4 : \n        case S_BUFFER_LOAD_DWORDX8 : \n        case S_BUFFER_LOAD_DWORDX16: \n        case S_BUFFER_STORE_DWORD  : \n        case S_BUFFER_STORE_DWORDX2: \n        case S_BUFFER_STORE_DWORDX4: \n        case S_ATC_PROBE_BUFFER    : \n            return 4;\n        default:\n            return 0;\n        }\n    }\n\n\n    uint ScalarMemoryInstruction::GetResultWidthInDWORDs() const\n    {\n        switch( GetOpcode() )\n        {\n            case S_LOAD_DWORD          :    return 1;\n            case S_LOAD_DWORDX2        :    return 2;\n            case S_LOAD_DWORDX4        :    return 4;\n            case S_LOAD_DWORDX8        :    return 8;\n            case S_LOAD_DWORDX16       :    return 16;\n            case S_BUFFER_LOAD_DWORD   :    return 1;\n            case S_BUFFER_LOAD_DWORDX2 :    return 2;\n            case S_BUFFER_LOAD_DWORDX4 :    return 4;\n            case S_BUFFER_LOAD_DWORDX8 :    return 8;\n            case S_BUFFER_LOAD_DWORDX16:    return 16;            \n            case S_MEMTIME             :    return 2;      \n            case S_STORE_DWORD         :    return 1;\n            case S_STORE_DWORDX2       :    return 2;\n            case S_STORE_DWORDX4       :    return 4;\n            case S_BUFFER_STORE_DWORD  :    return 1;\n            case S_BUFFER_STORE_DWORDX2:    return 2;\n            case S_BUFFER_STORE_DWORDX4:    return 4;\n            case S_MEMREALTIME         :    return 2;\n            case S_ATC_PROBE           :    \n            case S_ATC_PROBE_BUFFER    :    \n            case S_DCACHE_WB           :     \n            case S_DCACHE_WB_VOL       :     \n            case S_DCACHE_INV_VOL      : \n            case S_DCACHE_INV          :   \n            default:\n                return 0;\n        }\n    }\n\n   \n    uint GetSamplerWidthInDWORDs( ImageInstructions e )\n    {\n        switch( e )\n        {\n        case IMAGE_LOAD               :\n        case IMAGE_LOAD_MIP           :\n        case IMAGE_LOAD_PCK           :\n        case IMAGE_LOAD_PCK_SGN       :\n        case IMAGE_LOAD_MIP_PCK       :\n        case IMAGE_LOAD_MIP_PCK_SGN   :\n        case IMAGE_STORE              :\n        case IMAGE_STORE_MIP          :\n        case IMAGE_STORE_PCK          :\n        case IMAGE_STORE_MIP_PCK      :\n        case IMAGE_GET_RESINFO        :\n        case IMAGE_ATOMIC_SWAP        :\n        case IMAGE_ATOMIC_CMPSWAP     :\n        case IMAGE_ATOMIC_ADD         :\n        case IMAGE_ATOMIC_SUB         :\n        case IMAGE_ATOMIC_RSUB        :\n        case IMAGE_ATOMIC_SMIN        :\n        case IMAGE_ATOMIC_UMIN        :\n        case IMAGE_ATOMIC_SMAX        :\n        case IMAGE_ATOMIC_UMAX        :\n        case IMAGE_ATOMIC_AND         :\n        case IMAGE_ATOMIC_OR          :\n        case IMAGE_ATOMIC_XOR         :\n        case IMAGE_ATOMIC_INC         :\n        case IMAGE_ATOMIC_DEC         :\n        case IMAGE_ATOMIC_FCMPSWAP    :\n        case IMAGE_ATOMIC_FMIN        :\n        case IMAGE_ATOMIC_FMAX        :\n            return 0;\n        default:\n            return 4;\n        }\n    }\n\n    uint ImageInstruction::GetResultWidthInDWORDS() const\n    {\n        switch( GetOpcode() )\n        {\n            // Gathers always return four results, regardless of DMask\n            //  The ISA doc does not indicate this\n            //\n        case IMAGE_GATHER4           :\n        case IMAGE_GATHER4_CL        :\n        case IMAGE_GATHER4_L         :\n        case IMAGE_GATHER4_B         :\n        case IMAGE_GATHER4_B_CL      :\n        case IMAGE_GATHER4_LZ        :\n        case IMAGE_GATHER4_C         :\n        case IMAGE_GATHER4_C_CL      :\n        case IMAGE_GATHER4_C_L       :\n        case IMAGE_GATHER4_C_B       :\n        case IMAGE_GATHER4_C_B_CL    :\n        case IMAGE_GATHER4_C_LZ      :\n        case IMAGE_GATHER4_O         :\n        case IMAGE_GATHER4_CL_O      :\n        case IMAGE_GATHER4_L_O       :\n        case IMAGE_GATHER4_B_O       :\n        case IMAGE_GATHER4_B_CL_O    :\n        case IMAGE_GATHER4_LZ_O      :\n        case IMAGE_GATHER4_C_O       :\n        case IMAGE_GATHER4_C_CL_O    :\n        case IMAGE_GATHER4_C_L_O     :\n        case IMAGE_GATHER4_C_B_O     :\n        case IMAGE_GATHER4_C_B_CL_O  :\n        case IMAGE_GATHER4_C_LZ_O    : \n            return 4;\n        default:\n            {\n                // result width is the number of set bits in the dmask field\n                uint n = GetDMask(); \n                uint c=0;\n                while( n )\n                {\n                    c += (n&1);\n                    n>>=1;\n                }\n                return c;\n            }\n            break;\n\n        }\n    }\n\n\n    bool ImageInstruction::IsFilteredFetch( ) const\n    {\n        switch( GetOpcode() )\n        {\n        case IMAGE_SAMPLE          :   //: sample texture map.\n        case IMAGE_SAMPLE_CL       :   //: sample texture map, with LOD clamp specified in shader.\n        case IMAGE_SAMPLE_D        :   //: sample texture map, with user derivatives.\n        case IMAGE_SAMPLE_D_CL     :   //: sample texture map, with LOD clamp specified in shader, with user derivatives.\n        case IMAGE_SAMPLE_L        :   //: sample texture map, with user LOD.\n        case IMAGE_SAMPLE_B        :   //: sample texture map, with lod bias.\n        case IMAGE_SAMPLE_B_CL     :   //: sample texture map, with LOD clamp specified in shader, with lod bias.\n        case IMAGE_SAMPLE_LZ       :   //: sample texture map, from level 0.\n        case IMAGE_SAMPLE_C        :   //: sample texture map, with PCF.\n        case IMAGE_SAMPLE_C_CL     :   //: SAMPLE_C, with LOD clamp specified in shader.\n        case IMAGE_SAMPLE_C_D      :   //: SAMPLE_C, with user derivatives.\n        case IMAGE_SAMPLE_C_D_CL   :   //: SAMPLE_C, with LOD clamp specified in shader,with user derivatives.\n        case IMAGE_SAMPLE_C_L      :   //: SAMPLE_C, with user LOD.\n        case IMAGE_SAMPLE_C_B      :   //: SAMPLE_C, with lod bias.\n        case IMAGE_SAMPLE_C_B_CL   :   //: SAMPLE_C, with LOD clamp specified in shader, with lod bias.\n        case IMAGE_SAMPLE_C_LZ     : //     : SAMPLE_C, from level 0.\n        case IMAGE_SAMPLE_O        : // : sample texture map, with user offsets.\n        case IMAGE_SAMPLE_CL_O     : //     : SAMPLE_O with LOD clamp specified in shader.\n        case IMAGE_SAMPLE_D_O      : // : SAMPLE_O, with user derivatives.\n        case IMAGE_SAMPLE_D_CL_O   : //     : SAMPLE_O, with LOD clamp specified in shader,with user derivatives.\n        case IMAGE_SAMPLE_L_O      : // : SAMPLE_O, with user LOD.\n        case IMAGE_SAMPLE_B_O      : // : SAMPLE_O, with lod bias.\n        case IMAGE_SAMPLE_B_CL_O   : // : SAMPLE_O, with LOD clamp specified in shader,with lod bias.\n        case IMAGE_SAMPLE_LZ_O     : // : SAMPLE_O, from level 0.\n        case IMAGE_SAMPLE_C_O      : // : SAMPLE_C with user specified offsets.\n        case IMAGE_SAMPLE_C_CL_O   : // : SAMPLE_C_O, with LOD clamp specified in shader.\n        case IMAGE_SAMPLE_C_D_O    : // : SAMPLE_C_O, with user derivatives.\n        case IMAGE_SAMPLE_C_D_CL_O : // : SAMPLE_C_O, with LOD clamp specified in shader, with user derivatives.\n        case IMAGE_SAMPLE_C_L_O    : // : SAMPLE_C_O, with user LOD.\n        case IMAGE_SAMPLE_C_B_O    : // : SAMPLE_C_O, with lod bias.\n        case IMAGE_SAMPLE_C_B_CL_O : // : SAMPLE_C_O, with LOD clamp specified in shader, with lod bias.\n        case IMAGE_SAMPLE_C_LZ_O   : // : SAMPLE_C_O, from level 0.\n        case IMAGE_SAMPLE_CD        : // : sample texture map, with user derivatives (LOD per quad)\n        case IMAGE_SAMPLE_CD_CL     : // : sample texture map, with LOD clamp specified in  shader, with user derivatives (LOD per quad).\n        case IMAGE_SAMPLE_C_CD      : // : SAMPLE_C, with user derivatives (LOD per quad).\n        case IMAGE_SAMPLE_C_CD_CL   : // : SAMPLE_C, with LOD clamp specified in shader, with user derivatives (LOD per quad).\n        case IMAGE_SAMPLE_CD_O      : // : SAMPLE_O, with user derivatives (LOD per quad).\n        case IMAGE_SAMPLE_CD_CL_O   : // : SAMPLE_O, with LOD clamp specified in shader, with user derivatives (LOD per quad).\n        case IMAGE_SAMPLE_C_CD_O    : // : SAMPLE_C_O, with user derivatives (LOD per quad).\n        case IMAGE_SAMPLE_C_CD_CL_O : \n            return true;\n        default:\n            return false;\n        }\n    }\n\n\n    bool ImageInstruction::IsGradientFetch( ) const\n    {\n        switch( GetOpcode() )\n        {\n        case IMAGE_SAMPLE_D        :   //: sample texture map, with user derivatives.\n        case IMAGE_SAMPLE_D_CL     :   //: sample texture map, with LOD clamp specified in shader, with user derivatives.\n        case IMAGE_SAMPLE_C_D      :   //: SAMPLE_C, with user derivatives.\n        case IMAGE_SAMPLE_C_D_CL   :   //: SAMPLE_C, with LOD clamp specified in shader,with user derivatives.\n        case IMAGE_SAMPLE_D_O      : // : SAMPLE_O, with user derivatives.\n        case IMAGE_SAMPLE_D_CL_O   : //     : SAMPLE_O, with LOD clamp specified in shader,with user derivatives.\n        case IMAGE_SAMPLE_C_D_O    : // : SAMPLE_C_O, with user derivatives.\n        case IMAGE_SAMPLE_C_D_CL_O : // : SAMPLE_C_O, with LOD clamp specified in shader, with user derivatives.\n        case IMAGE_SAMPLE_CD        : // : sample texture map, with user derivatives (LOD per quad)\n        case IMAGE_SAMPLE_CD_CL     : // : sample texture map, with LOD clamp specified in  shader, with user derivatives (LOD per quad).\n        case IMAGE_SAMPLE_C_CD      : // : SAMPLE_C, with user derivatives (LOD per quad).\n        case IMAGE_SAMPLE_C_CD_CL   : // : SAMPLE_C, with LOD clamp specified in shader, with user derivatives (LOD per quad).\n        case IMAGE_SAMPLE_CD_O      : // : SAMPLE_O, with user derivatives (LOD per quad).\n        case IMAGE_SAMPLE_CD_CL_O   : // : SAMPLE_O, with LOD clamp specified in shader, with user derivatives (LOD per quad).\n        case IMAGE_SAMPLE_C_CD_O    : // : SAMPLE_C_O, with user derivatives (LOD per quad).\n        case IMAGE_SAMPLE_C_CD_CL_O : \n            return true;\n        default:\n            return false;\n        }\n    }\n\n    bool ImageInstruction::IsGather() const\n    {\n        switch( GetOpcode() )\n        {\n        case IMAGE_GATHER4         :// : gather 4 single component elements (2x2).\n        case IMAGE_GATHER4_CL      :// : gather 4 single component elements (2x2) with user LOD clamp.\n        case IMAGE_GATHER4_L       :// : gather 4 single component elements (2x2) with user LOD.\n        case IMAGE_GATHER4_B       :// : gather 4 single component elements (2x2) with user bias.\n        case IMAGE_GATHER4_B_CL    :// : gather 4 single component elements (2x2) with user bias and clamp.\n        case IMAGE_GATHER4_LZ      :// : gather 4 single component elements (2x2) at level 0.\n        case IMAGE_GATHER4_C       :// : gather 4 single component elements (2x2) with PCF.\n        case IMAGE_GATHER4_C_CL    :// : gather 4 single component elements (2x2) with user LOD clamp and PCF.\n        case IMAGE_GATHER4_C_L     :// : gather 4 single component elements (2x2) with user LOD and PCF.\n        case IMAGE_GATHER4_C_B     :// : gather 4 single component elements (2x2) with user bias and PCF.\n        case IMAGE_GATHER4_C_B_CL  :// : gather 4 single component elements (2x2) with user bias, clamp and PCF.\n        case IMAGE_GATHER4_C_LZ    :// : gather 4 single component elements (2x2) at level 0, with PCF.\n        case IMAGE_GATHER4_O       :// : GATHER4, with user offsets.\n        case IMAGE_GATHER4_CL_O    :// : GATHER4_CL, with user offsets.\n        case IMAGE_GATHER4_L_O     :// : GATHER4_L, with user offsets.\n        case IMAGE_GATHER4_B_O     :// : GATHER4_B, with user offsets.\n        case IMAGE_GATHER4_B_CL_O  :// : GATHER4_B_CL, with user offsets.\n        case IMAGE_GATHER4_LZ_O    :// : GATHER4_LZ, with user offsets.\n        case IMAGE_GATHER4_C_O     :// : GATHER4_C, with user offsets.\n        case IMAGE_GATHER4_C_CL_O  :// : GATHER4_C_CL, with user offsets.\n        case IMAGE_GATHER4_C_L_O   :// : GATHER4_C_L, with user offsets.\n        case IMAGE_GATHER4_C_B_O   :// : GATHER4_B, with user offsets.\n        case IMAGE_GATHER4_C_B_CL_O:// : GATHER4_B_CL, with user offsets.\n        case IMAGE_GATHER4_C_LZ_O  :// : GATHER4_C_LZ, with user offsets.\n            return true;\n        default:\n            return false;\n        }\n    }\n\n    bool ImageInstruction::IsUnfilteredLoadStore() const\n    {\n        switch( GetOpcode() )\n        {\n        case IMAGE_LOAD            :  // Image memory load with format conversion specified in T#. No sampler.\n        case IMAGE_LOAD_MIP        :  // Image memory load with user-supplied mip level. No sampler.\n        case IMAGE_LOAD_PCK        :  // Image memory load with no format conversion. No sampler.\n        case IMAGE_LOAD_PCK_SGN    :  // Image memory load with with no format conversion and sign extension. No sampler.\n        case IMAGE_LOAD_MIP_PCK    :  // Image memory load with user-supplied mip level, no format conversion. No sampler.\n        case IMAGE_LOAD_MIP_PCK_SGN:  // Image memory load with user-supplied mip level, no format conversion and with sign extension. No sampler.\n        case IMAGE_STORE           :  //: Image memory store with format conversion specified in T#. No sampler.\n        case IMAGE_STORE_MIP       :  //: Image memory store with format conversion specified in T# to user specified mip level. No sampler.\n        case IMAGE_STORE_PCK       :  //: Image memory store of packed data without format conversion. No sampler.\n        case IMAGE_STORE_MIP_PCK   : //: Image memory store of packed data without format conversion to user-supplied mip level. No sampler.\n            return true;\n        default:\n            return false;\n        }\n    }\n\n\n    bool ImageInstruction::IsMemoryWrite() const\n    {\n        switch( GetOpcode() )\n        {\n        case IMAGE_STORE          :   //: Image memory store with format conversion specified in T#. No sampler.\n        case IMAGE_STORE_MIP      :   //: Image memory store with format conversion specified in T# to user specified mip level. No sampler.\n        case IMAGE_STORE_PCK      :   //: Image memory store of packed data without format conversion. No sampler.\n        case IMAGE_STORE_MIP_PCK  :  //: Image memory store of packed data without format conversion to user-supplied mip level. No sampler.\n        case IMAGE_ATOMIC_SWAP    :   //: dst=src, returns previous value if glc==1.\n        case IMAGE_ATOMIC_CMPSWAP :   //: dst = (dst==cmp) ? src : dst. Returns previous value if glc==1.\n        case IMAGE_ATOMIC_ADD     :   //: dst += src. Returns previous value if glc==1.\n        case IMAGE_ATOMIC_SUB     :   //: dst -= src. Returns previous value if glc==1.\n        case IMAGE_ATOMIC_RSUB    :   //: dst = src-dst. Returns previous value if glc==1.  SI ONLY\n        case IMAGE_ATOMIC_SMIN    :   //: dst = (src < dst) ? src : dst (signed). Returns previous value if glc==1.\n        case IMAGE_ATOMIC_UMIN    :   //: dst = (src < dst) ? src : dst (unsigned). Returns previous value if glc==1.\n        case IMAGE_ATOMIC_SMAX    :   //: dst = (src > dst) ? src : dst (signed). Returns previous value if glc==1.\n        case IMAGE_ATOMIC_UMAX    :   //: dst = (src > dst) ? src : dst (unsigned). Returns previous value if glc==1.\n        case IMAGE_ATOMIC_AND     :   //: dst &= src. Returns previous value if glc==1.\n        case IMAGE_ATOMIC_OR      :   //: dst |= src. Returns previous value if glc==1.\n        case IMAGE_ATOMIC_XOR     :   //: dst ^= src. Returns previous value if glc==1.\n        case IMAGE_ATOMIC_INC     :   //: dst = (dst >= src) ? 0 : dst+1. Returns previous value if glc==1.\n        case IMAGE_ATOMIC_DEC     :   //: dst = ((dst==0 || (dst > src)) ? src : dst-1. Returns previous value if glc==1.\n        case IMAGE_ATOMIC_FCMPSWAP:   //: dst = (dst == cmp) ? src : dst, returns previous value of dst if glc==1 - double and float atomic compare swap. Obeys floating point compare rules for special values.\n        case IMAGE_ATOMIC_FMIN    :   //: dst = (src < dst) ? src : dst, returns previous value of dst if glc==1 - double and float atomic min (handles NaN/INF/denorm).\n        case IMAGE_ATOMIC_FMAX    :   //: dst = (src > dst) ? src : dst, returns previous value of dst if glc==1 - double and float atomic min (handles NaN/INF/denorm).\n            return true;\n        }\n        return false;\n    }\n\n    bool BufferInstruction::IsMemoryWrite() const\n    {\n        switch( GetOpcode() )\n        {\n        case BUFFER_STORE_FORMAT_X       :\n        case BUFFER_STORE_FORMAT_XY      :\n        case BUFFER_STORE_FORMAT_XYZ     :\n        case BUFFER_STORE_FORMAT_XYZW    :\n        case BUFFER_STORE_BYTE           :\n        case BUFFER_STORE_SHORT          :\n        case BUFFER_STORE_DWORD          :\n        case BUFFER_STORE_DWORDX2        :\n        case BUFFER_STORE_DWORDX4        :\n        case BUFFER_STORE_DWORDX3        :\n        case BUFFER_ATOMIC_SWAP          :\n        case BUFFER_ATOMIC_CMPSWAP       :\n        case BUFFER_ATOMIC_ADD           :\n        case BUFFER_ATOMIC_SUB           :\n        case BUFFER_ATOMIC_RSUB          :\n        case BUFFER_ATOMIC_SMIN          :\n        case BUFFER_ATOMIC_UMIN          :\n        case BUFFER_ATOMIC_SMAX          :\n        case BUFFER_ATOMIC_UMAX          :\n        case BUFFER_ATOMIC_AND           :\n        case BUFFER_ATOMIC_OR            :\n        case BUFFER_ATOMIC_XOR           :\n        case BUFFER_ATOMIC_INC           :\n        case BUFFER_ATOMIC_DEC           :\n        case BUFFER_ATOMIC_FCMPSWAP      :\n        case BUFFER_ATOMIC_FMIN          :\n        case BUFFER_ATOMIC_FMAX          :\n        case BUFFER_ATOMIC_SWAP_X2       :\n        case BUFFER_ATOMIC_CMPSWAP_X2    :\n        case BUFFER_ATOMIC_ADD_X2        :\n        case BUFFER_ATOMIC_SUB_X2        :\n        case BUFFER_ATOMIC_RSUB_X2       :\n        case BUFFER_ATOMIC_SMIN_X2       :\n        case BUFFER_ATOMIC_UMIN_X2       :\n        case BUFFER_ATOMIC_SMAX_X2       :\n        case BUFFER_ATOMIC_UMAX_X2       :\n        case BUFFER_ATOMIC_AND_X2        :\n        case BUFFER_ATOMIC_OR_X2         :\n        case BUFFER_ATOMIC_XOR_X2        :\n        case BUFFER_ATOMIC_INC_X2        :\n        case BUFFER_ATOMIC_DEC_X2        :\n        case BUFFER_ATOMIC_FCMPSWAP_X2   :\n        case BUFFER_ATOMIC_FMIN_X2       :\n        case BUFFER_ATOMIC_FMAX_X2       :\n        case BUFFER_STORE_LDS_DWORD      :   \n        case BUFFER_STORE_FORMAT_D16_X   :   \n        case BUFFER_STORE_FORMAT_D16_XY  :   \n        case BUFFER_STORE_FORMAT_D16_XYZ :   \n        case BUFFER_STORE_FORMAT_D16_XYZW:   \n        case TBUFFER_STORE_FORMAT_X            :\n        case TBUFFER_STORE_FORMAT_XY           :\n        case TBUFFER_STORE_FORMAT_XYZ          :\n        case TBUFFER_STORE_FORMAT_XYZW         :\n        case TBUFFER_STORE_FORMAT_D16_X        :\n        case TBUFFER_STORE_FORMAT_D16_XY       :\n        case TBUFFER_STORE_FORMAT_D16_XYZ      :\n        case TBUFFER_STORE_FORMAT_D16_XYZW     :\n            return true;\n        }\n        return false;\n    }\n\n}"
  },
  {
    "path": "src/Wrapper/GCNIsa.h",
    "content": "//\n//    ASIC-independent data structure for manipulating GCN instructions\n//\n//      Copyright 2015 Joshua Barczak, all rights reserved.\n//\n#ifndef _GCN_ISA_H_\n#define _GCN_ISA_H_\n#pragma once\n\n#include \"GCNEnums.h\"\n\nnamespace GCN\n{\n    typedef unsigned char  uint8;\n    typedef unsigned short uint16;\n    typedef unsigned int   uint32;\n    typedef unsigned int   uint;\n\n    typedef short int16;\n\n    static_assert( sizeof(uint8)  == 1, \"Fix typedefs\" );\n    static_assert( sizeof(int16)  == 2, \"Fix typedefs\" );\n    static_assert( sizeof(uint16) == 2, \"Fix typedefs\" );\n    static_assert( sizeof(uint32) == 4, \"Fix typedefs\" );\n\n    uint GetSourceCountForInstruction( VectorInstructions eOp );\n    uint GetSrc0WidthInDWORDs( VectorInstructions eOp );\n    uint GetSrc1WidthInDWORDs( VectorInstructions eOp );\n    uint GetSrc2WidthInDWORDs( VectorInstructions eOp );\n    uint GetResultWidthInDWORDs( VectorInstructions eOp );\n    uint GetDataWidthInDWORDs( DSInstructions eOp );\n    uint GetResultWidthInDWORDs( BufferInstructions eOp );\n    bool IsTBufferInstruction( BufferInstructions eOp );\n\n    uint GetSamplerWidthInDWORDs( ImageInstructions eOp );\n\n    /// The 'Instruction' base class contains all fields for all subclasses in a union\n    ///   This is done to allow Instructions to be used in containers without fear of slicing\n    ///\n    ///   Code that manipulates instructions should examine the class field and then static_cast to one \n    ///    of the concrete classes\n    ///\n    class Instruction\n    {\n    public:\n\n        Instruction( )\n        {\n        }\n\n     \n\n        InstructionClass GetClass() const { return m_eClass; }\n        \n    protected:\n\n        Instruction( InstructionClass eClass ) : m_eClass(eClass)\n        {\n            char* pFields = (char*) &Fields;\n            for( size_t i=0; i<sizeof(Fields); i++ )\n                pFields[i]=0;\n        }\n\n        friend class GCN1Decoder;\n        friend class GCN3Decoder;\n\n        InstructionClass m_eClass;\n        \n        union LiteralConstant\n        {\n            uint32 UInt;\n            float  Float;\n        };\n\n        union\n        {\n            struct \n            {\n                ScalarInstructions m_eOpcode;\n                uint8   m_nSourceCount;\n                int16   m_nSIMM16;\n                Sources m_Sources[2];\n                Dests   m_Dest;\n                const uint8*  m_pBranchTarget;\n                LiteralConstant m_Literal;\n            } Scalar;\n\n            struct\n            {\n                ScalarMemoryInstructions m_eOpcode;\n                uint m_nBaseReg;\n                uint m_nOffset;\n                Dests m_Dest;\n                bool m_bIsOffsetIMM; \n                bool m_bIsGLC;\n            } ScalarMem;\n\n            struct\n            {\n                VectorInstructions m_eOpcode;\n                uint8 m_nDestCount;\n                uint8 m_nSrcCount;\n                uint8 m_nOMOD;\n                uint8 m_nSourceAbs;\n                uint8 m_nSourceNegate;\n                uint8 m_nClamp;\n                Dests m_Dests[2];\n                Sources m_Sources[3];\n                LiteralConstant m_Literal;\n            } Vector;\n\n            struct\n            {\n                VectorInstructions m_eOpcode;\n                Sources m_VSrc;\n                Dests m_VDst;\n                uint8 m_nAttributeIndex;\n                uint8 m_nAttributeChannel;\n            } Interp;\n            struct\n            {\n                unsigned m_Done      : 1;\n                unsigned m_Compress  : 1;\n                unsigned m_ValidMask : 1;\n                unsigned m_ChannelMask : 4;\n                ExportTargets m_eTarget;\n                Sources m_Sources[4];\n            } Export;\n\n            struct \n            {\n                unsigned m_bGDS : 1;\n                unsigned m_nOffset0 : 8;  // Instructions can have one 16 bit offset field or two 8-bit offset fields\n                unsigned m_nOffset1 : 8;\n                uint16   m_nOffset16;\n                DSInstructions m_eOpcode;\n                Dests    m_Dest;\n                Sources  m_VAddr;\n                Sources  m_VData0;\n                Sources  m_VData1;\n            } DS;\n            \n            struct\n            {\n                unsigned m_bTFE       : 1;\n                unsigned m_bLDSDirect : 1;\n                unsigned m_bGLC : 1;\n                unsigned m_bSLC : 1;\n                unsigned m_bOffN : 1;\n                unsigned m_bIdxN : 1;\n                unsigned m_bAddr64 : 1;\n                uint16 m_nOffset;\n                TBufferNumberFormats m_eNumberFormat;\n                TBufferDataFormats m_eDataFormat;\n                Sources m_VData;\n                Sources m_VAddr;\n                Sources m_SResource;\n                Sources m_SOffset;\n                BufferInstructions m_eOpcode;\n            } Buffer;\n\n            struct\n            {\n                unsigned m_bTFE       : 1;\n                unsigned m_bGLC : 1;\n                unsigned m_bSLC : 1;\n                unsigned m_bArray : 1;\n                unsigned m_bUnnormalized : 1;\n                unsigned m_bLWE : 1;\n                unsigned m_bRes256 : 1;\n                unsigned m_bIsD16  : 1;\n                unsigned m_nDMask : 4;\n                Sources m_VData;\n                Sources m_VAddr;\n                Sources m_SResource;\n                Sources m_SSampler;\n                ImageInstructions m_eOpcode;\n            } Image;\n        \n        }Fields;\n\n    };\n\n\n    class ScalarInstruction : public Instruction\n    {\n    public:\n        ScalarInstruction()  : Instruction(IC_SCALAR){}\n        \n\n        bool IsConditionalJump() const;\n        bool IsUnconditionalJump() const;\n        bool IsWavefrontHalt() const;\n\n        /// Test for any instruction that alters control flow.  Includes branches, jumps, halts, and barriers\n        bool IsControlFlowOp() const;\n\n        const uint8* GetBranchTarget() const { return Fields.Scalar.m_pBranchTarget; }\n        int GetBranchOffset() const { return 4*(Fields.Scalar.m_nSIMM16+1); }\n\n        uint ReadSIMMBits( uint hi, uint lo ) const { return (Fields.Scalar.m_nSIMM16>>lo)&((1<<(1+hi-lo))-1); }\n        int16 GetSIMM16( ) const { return Fields.Scalar.m_nSIMM16; };\n        \n        uint GetResultWidthInDWORDs() const;\n        uint GetArg0WidthInDWORDs() const;\n        uint GetArg1WidthInDWORDs() const;\n\n        uint32 GetLiteralAsDWORD() const { return Fields.Scalar.m_Literal.UInt; }\n        \n        ScalarInstructions GetOpcode() const { return Fields.Scalar.m_eOpcode; }\n        uint GetSourceCount() const { return Fields.Scalar.m_nSourceCount; }\n        \n        Sources GetSource(uint i) const { return Fields.Scalar.m_Sources[i]; }\n        Dests GetDest() const { return Fields.Scalar.m_Dest; }\n\n        bool IsWait() const { return GetOpcode() == S_WAITCNT; };\n        uint GetVMwaitCount() const    { return ReadSIMMBits(3,0); }\n        uint GetEXPWaitCount() const   { return ReadSIMMBits(6,4); }\n        uint GetLCGMWaitCount() const  { return ReadSIMMBits(12,8); }\n\n        void EncodeWait( uint vmcnt, uint lcgmcount, uint expcount )\n        {\n            uint simm = vmcnt | (expcount<<4) | (lcgmcount<<8);\n            Fields.Scalar.m_nSIMM16 = simm;\n            Fields.Scalar.m_eOpcode = S_WAITCNT;\n        }\n\n        void EncodeSwapPC( )\n        {\n            Fields.Scalar.m_eOpcode = S_SWAPPC_B64;\n            Fields.Scalar.m_nSourceCount = 1;\n        }\n    };\n\n\n    class ScalarMemoryInstruction : public Instruction\n    {\n    public:\n        ScalarMemoryInstruction() : Instruction(IC_SCALAR_MEM){}\n\n        uint GetResultWidthInDWORDs() const;\n        uint GetResourceWidthInDWORDs() const ;\n        ScalarMemoryInstructions GetOpcode() const { return Fields.ScalarMem.m_eOpcode; }\n        bool  IsOffsetIMM() const { return Fields.ScalarMem.m_bIsOffsetIMM; }\n        bool  IsGLC() const     { return Fields.ScalarMem.m_bIsGLC; }\n        uint  GetOffset() const { return Fields.ScalarMem.m_nOffset; }\n        Dests GetDest() const { return Fields.ScalarMem.m_Dest; }\n        uint  GetBase() const { return Fields.ScalarMem.m_nBaseReg; }\n\n    };\n\n\n    class VectorInstruction : public Instruction\n    {\n    public:\n        VectorInstruction() : Instruction(IC_VECTOR){}\n\n          \n        VectorInstructions GetOpcode() const { return Fields.Vector.m_eOpcode; }\n        float GetLiteralAsFloat() const { return Fields.Vector.m_Literal.Float; }\n        uint32 GetLiteralAsDWORD() const { return Fields.Vector.m_Literal.UInt; }\n\n        uint GetSourceAbsMask() const { return Fields.Vector.m_nSourceAbs; }\n        uint GetSourceNegateMask() const { return Fields.Vector.m_nSourceNegate; }\n        uint GetOMod() const { return Fields.Vector.m_nOMOD; }\n        bool GetClamp() const { return Fields.Vector.m_nClamp != 0; }\n\n        uint GetDestCount() const { return Fields.Vector.m_nDestCount; }\n        uint GetSourceCount() const { return Fields.Vector.m_nSrcCount; }\n\n        Dests GetSDst() const { return Fields.Vector.m_Dests[1]; }; // VOP3b only\n        Dests GetVDst() const { return Fields.Vector.m_Dests[0]; }\n        Sources GetSrc0() const  { return Fields.Vector.m_Sources[0]; }\n        Sources GetVSrc1() const { return Fields.Vector.m_Sources[1]; }\n        Sources GetVSrc2() const { return Fields.Vector.m_Sources[2]; }\n\n        uint GetSrc0WidthInDWORDS()   const   { return GetSrc0WidthInDWORDs(GetOpcode()); }\n        uint GetSrc1WidthInDWORDS()   const   { return GetSrc1WidthInDWORDs(GetOpcode()); }\n        uint GetSrc2WidthInDWORDS()   const   { return GetSrc2WidthInDWORDs(GetOpcode()); }\n        uint GetResultWidthInDWORDS() const   { return GetResultWidthInDWORDs(GetOpcode()); }\n    };\n\n\n    class InterpolationInstruction : public Instruction\n    {\n    public:\n        InterpolationInstruction() : Instruction(IC_VECTOR_INTERP){}\n\n        VectorInstructions GetOpcode() const { return Fields.Interp.m_eOpcode; }\n        Sources GetVSrc() const { return Fields.Interp.m_VSrc; }\n        Dests GetVDst() const { return Fields.Interp.m_VDst; }\n        uint GetAttributeIndex() const { return Fields.Interp.m_nAttributeIndex; }\n        uint GetAttributeChannel() const { return Fields.Interp.m_nAttributeChannel; }\n    };\n\n    class ExportInstruction : public Instruction\n    {\n    public:\n        ExportInstruction() : Instruction(IC_EXPORT){}\n\n        bool GetCompressBit() const { return Fields.Export.m_Compress; }\n        bool GetDoneBit() const { return Fields.Export.m_Done; }\n        bool GetValidMaskBit() const { return Fields.Export.m_ValidMask; }\n        ExportTargets GetTarget() const { return Fields.Export.m_eTarget; }\n        uint GetExportMask() const { return Fields.Export.m_ChannelMask; }\n        Sources GetVSrc0() const { return Fields.Export.m_Sources[0]; }\n        Sources GetVSrc1() const { return Fields.Export.m_Sources[1]; }\n        Sources GetVSrc2() const { return Fields.Export.m_Sources[2]; }\n        Sources GetVSrc3() const { return Fields.Export.m_Sources[3]; }\n    };\n\n    class DataShareInstruction : public Instruction\n    {\n    public:\n        DataShareInstruction() : Instruction(IC_DS){}\n\n        DSInstructions GetOpcode() const { return Fields.DS.m_eOpcode; }\n        uint GetOffset0()  const   { return Fields.DS.m_nOffset0; }  // Instructions can have one 16 bit offset field or two 8-bit offset fields\n        uint GetOffset1()  const   { return Fields.DS.m_nOffset1; }\n        uint GetOffset16() const   { return Fields.DS.m_nOffset16; }\n        Dests   GetVDest()   const { return Fields.DS.m_Dest; }\n        Sources GetVData0()  const { return Fields.DS.m_VData0; }\n        Sources GetVData1()  const { return Fields.DS.m_VData1; }\n        Sources GetVAddr()   const { return Fields.DS.m_VAddr; }\n        bool IsGDS()       const   { return Fields.DS.m_bGDS!=0; }\n\n        uint GetDataWidthInDWORDS() const { return GetDataWidthInDWORDs( GetOpcode() ); }\n    };\n\n    class BufferInstruction : public Instruction\n    {\n    public:\n\n        BufferInstruction() : Instruction(IC_BUFFER){}\n\n        BufferInstructions GetOpcode() const { return Fields.Buffer.m_eOpcode; }\n        bool IsDirectToLDS() const { return Fields.Buffer.m_bLDSDirect; }\n        bool GetTFEBit() const { return Fields.Buffer.m_bTFE; }\n        bool GetGLCBit() const { return Fields.Buffer.m_bGLC; }\n        bool GetSLCBit() const { return Fields.Buffer.m_bSLC; }\n        bool IsTBuffer() const { return IsTBufferInstruction( GetOpcode()); }\n        bool IsOffN() const    { return Fields.Buffer.m_bOffN; }\n        bool IsIdxN() const    { return Fields.Buffer.m_bIdxN;}\n        bool IsAddr64() const  { return Fields.Buffer.m_bAddr64; }\n        uint GetOffset() const { return Fields.Buffer.m_nOffset; }\n        TBufferNumberFormats GetNumberFormat() const { return Fields.Buffer.m_eNumberFormat; }\n        TBufferDataFormats GetDataFormat() const { return Fields.Buffer.m_eDataFormat; }\n        Sources GetVData() const { return Fields.Buffer.m_VData; }\n        Sources GetVAddr() const { return Fields.Buffer.m_VAddr; }\n        Sources GetSResource() const { return Fields.Buffer.m_SResource; }\n        Sources GetSOffset() const { return Fields.Buffer.m_SOffset; }\n        uint GetResultWidthInDWORDS() const { return GetResultWidthInDWORDs(GetOpcode()); }\n\n        /// Test for a store or atomic store\n        bool IsMemoryWrite() const;\n\n        void SetOpcode( BufferInstructions eOp ) { Fields.Buffer.m_eOpcode = eOp; }\n        \n    };\n\n\n    \n    class ImageInstruction : public Instruction\n    {\n    public:\n        ImageInstruction() : Instruction(IC_IMAGE){}\n\n\n        ImageInstructions GetOpcode() const   { return Fields.Image.m_eOpcode; }\n        bool IsTFE() const                    { return Fields.Image.m_bTFE; }\n        bool IsGLC() const                    { return Fields.Image.m_bGLC; }\n        bool IsSLC() const                    { return Fields.Image.m_bSLC; }\n        bool IsArray() const                  { return Fields.Image.m_bArray; }\n        bool IsUnnormalized() const           { return Fields.Image.m_bUnnormalized; }\n        bool IsLWE() const                    { return Fields.Image.m_bLWE; }\n        bool IsD16() const                    { return Fields.Image.m_bIsD16; }\n        uint GetDMask() const                 { return Fields.Image.m_nDMask; }\n        Sources GetVData() const              { return Fields.Image.m_VData; }\n        Sources GetVAddr() const              { return Fields.Image.m_VAddr; }\n        Sources GetSResource() const          { return Fields.Image.m_SResource; }\n        Sources GetSSampler() const           { return Fields.Image.m_SSampler; }\n        uint GetSamplerWidthInDWORDS() const  { return GetSamplerWidthInDWORDs(GetOpcode()); }\n        uint GetResourceWidthInDWORDS() const { return Fields.Image.m_bRes256*4 + 4; }\n        uint GetResultWidthInDWORDS() const;\n        bool IsFilteredFetch() const;\n        bool IsGradientFetch() const;\n        bool IsUnfilteredLoadStore() const;\n        bool IsGather() const;\n\n        /// Test for a store or atomic store\n        bool IsMemoryWrite() const;\n    };\n\n};\n\n\n#endif"
  },
  {
    "path": "src/Wrapper/GCNSimulator.cpp",
    "content": "#pragma unmanaged\n#include \"GCNSimulator.h\"\n#include \"GCNIsa.h\"\n\n#include <string.h>\n#include <algorithm>\n#include <assert.h>\n#include <intrin.h>\n\nnamespace GCN{\nnamespace Simulator{\n\n    namespace _INTERNAL\n    {\n        enum\n        {\n            MAX_WAVES_PER_THREADGROUP    = 16,\n            NUM_SIMDS                    = 4,\n            MAX_WAVES_PER_SIMD           = 10,\n            MAX_WAVES_PER_CU             = NUM_SIMDS * MAX_WAVES_PER_SIMD,\n\n            MAX_LCGMCNT                  = 31,\n            MAX_VMCNT                    = 15,\n            MAX_EXPCNT                   = 7,\n\n            NUM_LDS_QUEUES               = 2\n        };\n\n     \n\n        struct ThreadGroupState;\n\n        struct WaveState\n        {\n            size_t nCurrentOp;\n            size_t nStartClock;\n            ThreadGroupState* pThreadGroup;\n            \n            uint8 nSIMD;\n            uint8 lkgmcnt;\n            uint8 vmcnt;\n            uint8 expcnt;\n\n            uint8 nWaveIDInGroup; ///< Index of this wave in its thread group\n        };\n\n        struct ThreadGroupState\n        {\n            uint16 nWaitMask;       ///< Bit-mask of waves presently waiting at a barrier\n            uint8 nWaves;           ///< Number of waves not yet launched\n            uint8 nLaunchedWaves;   ///< Number of running waves\n            uint8 nRetiredWaves;    ///< Number of waves that have run to completion\n        };\n\n\n        template< class T, int MAX >\n        class RingQueue\n        {\n        public:\n            RingQueue() : m_nFirst(0), m_nLast(0){}\n\n            bool empty() const { return m_nFirst == m_nLast; }\n\n            T& front() { return m_Items[(m_nFirst) % MAX]; }\n\n            void pop_front() { m_nFirst++; };\n\n            void push_back( const T& op )\n            {\n                size_t nLoc = m_nLast++;\n                m_Items[nLoc % MAX] = op;\n                assert( m_nLast - m_nFirst <= MAX );\n            }\n\n            size_t size() const { return m_nLast - m_nFirst; }\n\n            const T& at( size_t i ) const { return m_Items[ (m_nFirst+i)%MAX ]; }\n\n        private:\n\n            T m_Items[MAX];\n            size_t m_nFirst;\n            size_t m_nLast;\n        };\n\n      \n        struct SMemOp\n        {\n            size_t nDWORDsLeft;\n            WaveState* pWave;\n        };\n        struct VMemOp\n        {\n            size_t nClocksLeft;\n            bool bIsExport;\n            WaveState* pWave;\n        };\n        struct ExportOp\n        {\n            size_t nClocksLeft;\n            WaveState* pWave;\n        };\n        struct DSOp\n        {\n            size_t nClocksLeft;\n            WaveState* pWave;\n        };\n\n        // If your compiler lacks 'PopCount' then you can do something about it here\n        static unsigned int PopCount( unsigned int n )\n        {\n            return __popcnt((unsigned int)n);\n        }\n\n        static bool IsBarrier( const Instruction* pOp )\n        {\n            if( pOp->GetClass() == IC_SCALAR )\n            {\n                const ScalarInstruction* pScalar = static_cast<const ScalarInstruction*>(pOp);\n                if( pScalar->GetOpcode() == S_BARRIER )\n                    return true;\n            }\n            return false;\n        }\n\n        \n        /// Search for a threadgroup structure that isn't in use\n        static ThreadGroupState* FindAvailableThreadGroup( ThreadGroupState pGroups[MAX_WAVES_PER_CU], size_t nOccupancyLimit )\n        {\n            for( size_t i=0; i<nOccupancyLimit; i++ )\n            {\n                if( !pGroups[i].nWaves )\n                    return &pGroups[i];\n            }\n            return 0;\n        }\n\n        /// Search for a WaveState structure that isn't in use\n        static WaveState* FindAvailableWave( WaveState pWaves[MAX_WAVES_PER_CU] )\n        {\n            for( size_t i=0; i<MAX_WAVES_PER_CU; i++ )\n            {\n                if( !pWaves[i].pThreadGroup )\n                    return &pWaves[i];\n            }\n            return 0;\n        }\n\n        static WaveState* FindLDSToIssue( const SimOp* pOps, WaveState** ppWaves, size_t nWaves )\n        {\n            for( size_t i=0; i<nWaves; i++ )\n            {\n                // Throttle instruction issue of there are more scalars in flight\n                //  than we have counter bits for\n                //\n                // CLARIFICATION NEEDED:  Is this what HW does?\n                //\n                if( ppWaves[i]->lkgmcnt == MAX_LCGMCNT )\n                    continue;\n\n                const GCN::Instruction* pOp = pOps[ppWaves[i]->nCurrentOp].pInstruction;\n                if( pOp->GetClass() != GCN::IC_DS )\n                    continue;\n\n                const GCN::DataShareInstruction* pDS = static_cast<const GCN::DataShareInstruction*>(pOp);\n                if( pDS->IsGDS() )\n                    continue;\n\n                return ppWaves[i];\n            }\n\n            return 0;\n        }\n\n        /// Search list of waves for oldest one that wants to issue a scalar\n        static WaveState* FindScalarToIssue( const SimOp* pOps, WaveState** pWaves, size_t nWaves )\n        {\n            WaveState* pIssueWave=0;\n\n            // look for a wave which has a scalar op, where said scalar op is not\n            // one of the freebies\n            for( size_t i=0; i<nWaves; i++ )\n            {\n                const GCN::Instruction* pOp = pOps[pWaves[i]->nCurrentOp].pInstruction;\n                if( pOp->GetClass() != GCN::IC_SCALAR_MEM && pOp->GetClass() != GCN::IC_SCALAR )\n                    continue;\n\n                // Throttle instruction issue of there are more scalars in flight\n                //  than we have counter bits for\n                //\n                // CLARIFICATION NEEDED:  Is this what HW does?\n                //\n                if( pOp->GetClass() == GCN::IC_SCALAR_MEM && pWaves[i]->lkgmcnt == MAX_LCGMCNT )\n                    continue;\n\n                if( pOp->GetClass() == IC_SCALAR )\n                {\n                    const GCN::ScalarInstruction* pScalar = static_cast<const GCN::ScalarInstruction*>( pOp );\n                    switch( pScalar->GetOpcode() )\n                    {\n                    case S_NOP           :         \n                    case S_ENDPGM        :        \n                    case S_BARRIER       :        \n                    case S_SETHALT       :        \n                    case S_SLEEP         :        \n                    case S_SETPRIO       :        \n                    case S_ENDPGM_SAVED  : \n                    case S_WAITCNT       : \n                        continue;\n                    }\n                }\n\n                // We can issue this one.  \n                //  but give priority to older waves\n                if( !pIssueWave || pIssueWave->nStartClock > pWaves[i]->nStartClock )\n                    pIssueWave = pWaves[i];\n            }\n\n            return pIssueWave;\n        }\n\n        /// Search list of waves for oldest one that wants to issue a valu\n        static WaveState* FindVALUToIssue( const SimOp* pOps, WaveState** pWaves, size_t nWaves )\n        {\n            WaveState* pIssueWave=0;\n\n            // look for a wave which has a VALU op to issue\n            for( size_t i=0; i<nWaves; i++ )\n            {\n         \n                // CLARIFICATION NEEDED\n                //   Do VECTOR_INTERP instructions need any special handling?\n                //   They interact with the LDS, but does that have any extra cost?\n                const GCN::Instruction* pOp = pOps[pWaves[i]->nCurrentOp].pInstruction;\n                if( pOp->GetClass() != GCN::IC_VECTOR &&\n                    pOp->GetClass() != GCN::IC_VECTOR_INTERP)\n                    continue;\n\n                // We can issue this one.  \n                //  but give priority to older waves\n                if( !pIssueWave || pIssueWave->nStartClock > pWaves[i]->nStartClock )\n                    pIssueWave = pWaves[i];\n            }\n\n            return pIssueWave;\n        }\n\n        /// Is instruction a vector memory write?\n        static bool IsVMEMWrite( const GCN::Instruction* pOp )\n        {\n            switch( pOp->GetClass() )\n            {\n            default:\n                return false;\n\n            case GCN::IC_IMAGE:\n                {\n                    const GCN::ImageInstruction* pImg = static_cast<const GCN::ImageInstruction*>(pOp);\n                    return pImg->IsMemoryWrite();\n                }\n                break;\n                     \n            case GCN::IC_BUFFER:\n                {\n                    const GCN::BufferInstruction* pImg = static_cast<const GCN::BufferInstruction*>(pOp);\n                    return pImg->IsMemoryWrite();\n                }\n                break;\n            }\n        }\n\n        /// Search a list of waves for oldest one that wants to issue a vmem\n        static WaveState* FindVMEMToIssue( const SimOp* pOps, WaveState** pWaves, size_t nWaves )\n        {\n            WaveState* pIssueWave=0;\n\n            // look for a wave which has a VALU op to issue\n            for( size_t i=0; i<nWaves; i++ )\n            {\n                const GCN::Instruction* pOp = pOps[pWaves[i]->nCurrentOp].pInstruction;\n                if( pOp->GetClass() != GCN::IC_BUFFER &&\n                    pOp->GetClass() != GCN::IC_IMAGE )\n                    continue;\n\n                \n                // Throttle instruction issue of there are more OPS in flight\n                //  than we have counter bits for\n                //\n                // CLARIFICATION NEEDED:  Is this what HW does?\n                //\n                if( pWaves[i]->vmcnt == MAX_VMCNT ) \n                    continue;\n                if( IsVMEMWrite(pOp) && pWaves[i]->expcnt == MAX_EXPCNT )\n                    continue;\n\n                // We can issue this one.  \n                //  but give priority to older waves\n                if( !pIssueWave || pIssueWave->nStartClock > pWaves[i]->nStartClock )\n                    pIssueWave = pWaves[i];\n            }\n\n            return pIssueWave;\n        }\n\n        /// Search a list of waves for oldest one that wants to issue an export\n        static WaveState* FindExportToIssue( const SimOp* pOps, WaveState** pWaves, size_t nWaves )\n        {\n            WaveState* pIssueWave=0;\n\n            // look for a wave which has an export to issue\n            for( size_t i=0; i<nWaves; i++ )\n            {\n           \n                const GCN::Instruction* pOp = pOps[pWaves[i]->nCurrentOp].pInstruction;\n                if( pOp->GetClass() != GCN::IC_EXPORT )\n                    continue;\n\n                 \n                // Throttle instruction issue of there are more OPS in flight\n                //  than we have counter bits for\n                //\n                // CLARIFICATION NEEDED:  Is this what HW does?\n                //\n                if( pWaves[i]->expcnt == MAX_EXPCNT )\n                    continue;\n\n                // We can issue this one.  \n                //  but give priority to older waves\n                if( !pIssueWave || pIssueWave->nStartClock > pWaves[i]->nStartClock )\n                    pIssueWave = pWaves[i];\n            }\n\n            return pIssueWave;\n        }\n\n      \n\n        /// Determine the cost in cycles of a VMEM instruction,\n        ///  Taking format and filtering into account\n        static size_t GetVMEMCost( const SimOp* pSimOp )\n        {\n            const GCN::Instruction* pOp = pSimOp->pInstruction;\n            switch( pOp->GetClass() )\n            {\n            default:\n                return 4;\n\n            case GCN::IC_BUFFER:\n                {\n                    // 16 \"load store units\" --> 4 clocks/wave/dword\n                    const GCN::BufferInstruction* pBuff = static_cast<const GCN::BufferInstruction*>(pOp);\n                    return pBuff->GetResultWidthInDWORDS()*4;\n                }\n                break;\n\n            case GCN::IC_IMAGE:\n                {                    \n                    const GCN::ImageInstruction* pImg = static_cast<const GCN::ImageInstruction*>(pOp);\n                    if( pImg->IsFilteredFetch() )\n                    {\n                        \n                        size_t nBaseCost=0;\n\n                        // perf depends on format and filter type\n                        if( pSimOp->eFilter == FILT_POINT )\n                            nBaseCost = 16; // point sampling is 4 pix/clk for all formats\n                        else\n                        {\n                            // baseline for bilinear is 4 pixels/clk\n                            size_t nCost = 0;\n                            switch( pSimOp->eFormat )\n                            {\n                            case FMT_RGBA32F:\n                                nCost = 64; // 1/4 rate\n                                break;\n                            case FMT_RGBA16:\n                            case FMT_RGBA16F:\n                            case FMT_RG32F:\n                            case FMT_BC6:\n                                nCost = 32; // 1/2 rate\n                                break;\n                            default:\n                                nCost = 16;\n                                break;\n                            }\n\n                            // modify by filter type\n                            switch( pSimOp->eFilter )\n                            {\n                            case FILT_TRILINEAR:\n                            case FILT_ANISO_2X:\n                                nCost *= 2;\n                                break;\n                            case FILT_ANISO_4X:\n                                nCost *= 4;\n                                break;\n                            case FILT_ANISO_8X:\n                                nCost *= 8;\n                                break;\n                            }\n\n                            nBaseCost= nCost;\n                        }\n\n                        // APPROXIMATION: Gradient fetches are approximately 2x cost\n                        //\n                        //  It's actually full rate for 4 dwords/thread of input\n                        //     and an extra clock for each additional 4\n                        //\n                        //  This 2x assumes a 2D gradient fetch where derivatives\n                        //     can all go in one extra clock\n                        //  3D is more expensive, 1D possibly less\n                        //  Unfortunately ISA doesn't tell us \n                        //   what tx type we're dealing with\n                        //\n                        //  Not clear if a thread can overlap extra argument cost\n                        //    with expensive filtering and have these cancel out\n                        //\n                        if( pImg->IsGradientFetch() )\n                            nBaseCost *= 2;\n                        \n                        return nBaseCost;\n                    }\n                    else if( pImg->IsGather() )\n                    {\n                        // gather is just like a point-sampled fetch.  4x4 pix/clk\n                        return 16;\n                    }\n                    else\n                    {\n                        // AMD says that Image load/store gets capped at 4 pixels/clk\n                        //   due to more complicated addressing\n                        return 16;\n                    }\n                }\n                break;\n            }\n        }\n\n\n        /// Determine the cost in cycles of a vector instruction\n        static size_t GetVALUCost( const GCN::Instruction* pOp )\n        {\n            if( pOp->GetClass() == GCN::IC_VECTOR_INTERP )\n            {\n                // CLARIFICATION NEEDED:\n                //  Assuming that interps are as cheap as regular VALU.  Is this correct?\n                return 4; \n            }\n            else\n            {\n                const GCN::VectorInstruction* pVALU = static_cast<const GCN::VectorInstruction*>( pOp );\n\n                // Costs based on humus's presentation, here:\n                //    http://www.humus.name/Articles/Persson_LowlevelShaderOptimization.pdf\n                //\n                // CLARIFICAITON NEEDED:\n                //  What did I miss?\n                switch( pVALU->GetOpcode() )\n                {\n                    // anything not expressly called out below is 4 clocks\n                default:\n                    return 4;\n\n                // Int32 multiply:  1/4 rate\n                case V_MUL_LO_U32:   \n                case V_MUL_HI_U32:   \n                case V_MUL_LO_I32:   \n                case V_MUL_HI_I32:   \n                    return 16;\n\n                    // float transcendentals: 1/4 rate\n                case V_EXP_F32             :\n                case V_LOG_CLAMP_F32       :\n                case V_LOG_F32             :\n                case V_RCP_CLAMP_F32       :\n                case V_RCP_LEGACY_F32      :\n                case V_RCP_F32             :\n                case V_RCP_IFLAG_F32       :\n                case V_RSQ_CLAMP_F32       :\n                case V_RSQ_LEGACY_F32      :\n                case V_RSQ_F32             :\n                case V_SQRT_F32            :\n                case V_SIN_F32             :\n                case V_COS_F32             :\n                case V_LOG_LEGACY_F32      :\n                case V_EXP_LEGACY_F32      :\n                case V_RCP_F16             :\n                case V_SQRT_F16            :\n                case V_RSQ_F16             :\n                case V_LOG_F16             :\n                case V_EXP_F16             :\n                case V_SIN_F16             :\n                case V_COS_F16             :\n                case V_DIV_SCALE_F32       : \n                case V_DIV_FIXUP_F32       : // Clarification needed\n                case V_DIV_FMAS_F32        : //   Do these divs count as transcendentals? \n                    return 16;\n\n                // DP add:  \n                case V_ADD_F64 :\n                    return 8;\n\n                // DP mul/mad\n                case V_FMA_F64 :       \n                case V_MUL_F64 : \n                    return 16;\n\n                // CLARIFICATION NEEDED\n                //   Are DP transcendentals 1/2 float rate?  Can't find a source.\n                case V_RCP_F64          :\n                case V_RCP_CLAMP_F64    :\n                case V_RSQ_F64          :\n                case V_RSQ_CLAMP_F64    :\n                case V_SQRT_F64         :\n                case V_DIV_SCALE_F64    :\n                case V_DIV_FIXUP_F64    :\n                case V_DIV_FMAS_F64     :\n                    return 32;\n                }\n            }\n        }\n\n        static uint GetExportCost( const GCN::Instruction* pOp, uint nBaseCost )\n        {\n            const GCN::ExportInstruction* pExp = static_cast<const GCN::ExportInstruction*>( pOp );\n            if( pExp->GetCompressBit() )\n                return nBaseCost;\n            else\n                return nBaseCost*2;\n        }\n\n\n        /// Test whether a given wave can issue one of the \"free\" scalar operations\n        static bool CanIssueFreeScalarOp( const GCN::Instruction* pOp, WaveState* pWave )\n        {\n            if( pOp->GetClass() != GCN::IC_SCALAR )\n                return false;\n\n            const GCN::ScalarInstruction* pScalar = static_cast<const GCN::ScalarInstruction*>( pOp );\n            \n            switch( pScalar->GetOpcode() )\n            {\n            case S_NOP           :         \n            case S_SETHALT       :        \n            case S_SLEEP         :        \n            case S_SETPRIO       :\n                return true;\n\n                // don't move past a barrier until the wave's corresponding bit in the wait mask\n                //  has been cleared.  This happens during the barrier processing phase, which \n                //  comes before this point in the sim cycle\n            case S_BARRIER:\n                {\n                    size_t nWaveBit = 1 << pWave->nWaveIDInGroup;\n                    if( pWave->pThreadGroup->nWaitMask & nWaveBit )\n                        return false;\n                    \n                    return true;\n                }\n                break;\n\n                // don't issue endpgm until all the counters drop to zero\n            case S_ENDPGM        :        \n            case S_ENDPGM_SAVED  : \n                if( pWave->lkgmcnt == 0 &&\n                    pWave->expcnt == 0 &&\n                    pWave->vmcnt == 0 )\n                {\n                    return true;\n                }\n                break;\n            case S_WAITCNT       :        \n                {\n                    if( pWave->lkgmcnt <= pScalar->GetLCGMWaitCount() &&\n                        pWave->expcnt <= pScalar->GetEXPWaitCount() &&\n                        pWave->vmcnt <= pScalar->GetVMwaitCount() )\n                    {\n                        return true;\n                    }\n                }\n                break;\n            }\n\n            return false;\n        }\n    }\n\n    void Simulate( Results& rResults, const Settings& rSettings, SimOp* pOps, size_t nOps )\n    {\n        using namespace _INTERNAL;\n\n        size_t nClock        = 0;\n        size_t nRetiredWaves = 0;\n        size_t nIssuedWaves  = 0;\n        size_t nGroupsInFlight = 0;\n        size_t nWavesToExecute = rSettings.nWavesPerThreadGroup*rSettings.nGroupsToExecute;\n\n        ThreadGroupState pThreadGroups[MAX_WAVES_PER_CU] = {0};\n        WaveState pWaveFronts[MAX_WAVES_PER_CU] = {0};\n        WaveState* pWavesInFlight[NUM_SIMDS][MAX_WAVES_PER_SIMD] = {0};\n        uint8 pWaveCount[NUM_SIMDS] = {0};\n\n        ThreadGroupState* pIssuingThreadGroup=0;\n        WaveState* pWavesInVALU[NUM_SIMDS] = {0}; ///< Wave currently occupying each VALU\n        size_t pVALUCycles[NUM_SIMDS] = {0};      ///< Number of cycles remaining on each VALU op\n    \n        RingQueue<SMemOp,MAX_WAVES_PER_CU*32>   SMemQueue;\n        RingQueue<VMemOp,MAX_WAVES_PER_CU*16>   VMemQueue;\n        RingQueue<ExportOp,MAX_WAVES_PER_CU*16> EXPQueue;\n\n        // LDS/SIMD interface looks like this:\n        //\n        //   SIMD 0/1          SIMD 2/3\n        //    16 lanes         16 lanes\n        //\n        //  However, each \"lane\" is two dwords wide (so 32 dwords/wave)\n        //   At peak, two waves can read two DWORDS/thread over four clocks\n        //\n        RingQueue<DSOp,MAX_WAVES_PER_CU*32>     LDSQueue[NUM_LDS_QUEUES];\n\n        size_t nGroupDelay= rSettings.nGroupIssueRate; // Time in cycles since a threadgroup was started\n        \n\n        while(1)\n        {\n            // Issue new wavefront if its time\n            if( nIssuedWaves < nWavesToExecute )\n            {\n                if( !pIssuingThreadGroup  )\n                {\n                    if( nGroupDelay >= rSettings.nGroupIssueRate ) \n                    {\n                        // start issuing a new thread group after the specified time interval has elapsed\n                        //  This is to model the effect of fixed-function units (ACE, VGT, Rasterizer, etc)\n                        //   round-robining waves across available CUs\n                    \n                        pIssuingThreadGroup = FindAvailableThreadGroup(pThreadGroups,rSettings.nMaxGroupsPerCU);\n                        if( pIssuingThreadGroup )\n                        {\n                            pIssuingThreadGroup->nWaves = rSettings.nWavesPerThreadGroup;\n                            pIssuingThreadGroup->nLaunchedWaves = 0;\n                            pIssuingThreadGroup->nRetiredWaves = 0;\n                            pIssuingThreadGroup->nWaitMask = 0;\n                            nGroupsInFlight++;\n                        }\n                        nGroupDelay=0;\n                    }\n                    else\n                    {\n                        // count cycles until next group can start\n                        nGroupDelay++;\n                    }\n                }\n                \n                // If we have a thread group to issue waves from, then issue from it each and every cycle\n                //   Layla slides state that the ACE's an issue one wave per clock to the CUs.  We'll assume\n                //   that the scheduler shoots a wave to the current CU every clock until its done, then moves on ot the next one\n                if( pIssuingThreadGroup )\n                {\n                    WaveState* pWave = FindAvailableWave( pWaveFronts );\n                    if( !pWave )\n                    {\n                        // means that the CU is completely full.  Good for us.\n                        // TODO: Track this...?\n                    }\n                    else\n                    {\n                        // CLARIFICATION NEEDED:\n                        // I don't know precisely what the rules are for mapping newly issued waves to SIMDs\n                        //   let's assume simple round-robin until somebody tells us different\n                        size_t nSIMD = nIssuedWaves % NUM_SIMDS;\n                        if( pWaveCount[nSIMD] < rSettings.nMaxWavesPerSIMD )\n                        {\n                            pWavesInFlight[nSIMD][pWaveCount[nSIMD]++] = pWave;\n                            pWave->nSIMD       = nSIMD;\n                            pWave->nStartClock = nClock;\n                            pWave->nCurrentOp  = 0;\n                            pWave->pThreadGroup = pIssuingThreadGroup;\n                            pWave->nWaveIDInGroup = pIssuingThreadGroup->nLaunchedWaves;\n                            nIssuedWaves++;\n\n                            pIssuingThreadGroup->nLaunchedWaves++;\n                            if( pIssuingThreadGroup->nLaunchedWaves == pIssuingThreadGroup->nWaves )\n                                pIssuingThreadGroup = NULL;\n                            \n                        }\n                    }\n                }\n            }\n\n            // Tick the LDS pipe\n            \n            // Count as busy if either of the two Queues are running\n            for( size_t i=0; i<NUM_LDS_QUEUES; i++ )\n            {\n                if( !LDSQueue[i].empty() )\n                {\n                    DSOp& op = LDSQueue[i].front();\n                    op.nClocksLeft--;\n                    if( op.nClocksLeft == 0 )\n                    {\n                        op.pWave->lkgmcnt--;\n                        LDSQueue[i].pop_front();\n                    }\n\n                    rResults.nLDSBusy++;\n                }\n            }\n           \n\n            // tick the vmem pipe\n            if( !VMemQueue.empty() )\n            {\n                VMemOp& op = VMemQueue.front();\n                op.nClocksLeft--;\n                if( op.nClocksLeft == 0 )\n                {\n                    op.pWave->vmcnt--;\n                    if( op.bIsExport )\n                        op.pWave->expcnt--;\n\n                    VMemQueue.pop_front();\n                }\n\n                rResults.nVMemBusy++;\n            }\n\n            // Tick the SMem pipe\n            //    SMem rate is 4 dwords/CU/clk\n            //\n            // CLARIFICATION NEEDED:\n            //  For simplicity, assume here that we only retire one instruction per clock\n            //     but I don't know if the hardware is smarter than that.  They have 16 bytes/clk\n            //     of bandwidth, and they might be able to parcel it out to multiple waiting waves.\n            if( !SMemQueue.empty() )\n            {\n                SMemOp& op = SMemQueue.front();\n                if( op.nDWORDsLeft <= 4 )\n                {\n                    op.pWave->lkgmcnt--;\n                    SMemQueue.pop_front();\n                }\n                else\n                {\n                    op.nDWORDsLeft -= 4;\n                }\n\n                rResults.nSMemBusy++;\n            }\n\n            // Tick the EXP pipe\n            if( !EXPQueue.empty() )\n            {\n                ExportOp& exp = EXPQueue.front();\n                exp.nClocksLeft--;\n                if( exp.nClocksLeft == 0 )\n                {\n                    exp.pWave->expcnt--;\n                    EXPQueue.pop_front();\n                }\n\n                rResults.nExpBusy++;\n            }\n\n           \n            // tick all the VALUs\n            for( size_t i=0; i<NUM_SIMDS; i++ )\n            {\n                if( pVALUCycles[i] )\n                {\n                    rResults.nVALUBusy[i]++;\n                    pVALUCycles[i]--;\n                    if( pVALUCycles[i] == 0 )\n                    {\n                        pWavesInVALU[i]->nCurrentOp++;\n                        pWavesInVALU[i]=0;\n                    }\n                }\n            }\n\n            size_t nCurrentSIMD =  nClock % NUM_SIMDS;\n            WaveState** pSIMDWaves = pWavesInFlight[nCurrentSIMD];\n            size_t nWaves = pWaveCount[nCurrentSIMD];\n\n            // Try and issue an LDS\n            WaveState* pLDSWave = FindLDSToIssue( pOps, pSIMDWaves, nWaves );\n            if( pLDSWave )\n            {\n                // TODO: Assuming best-case latency of 4 clocks.  What abount Bank conflicts?  \n                //  How to model this in a way that's useful?\n                DSOp ds;\n                ds.nClocksLeft = 4;\n                ds.pWave = pLDSWave;\n                LDSQueue[nCurrentSIMD/2].push_back( ds );\n                pLDSWave->lkgmcnt++;\n            }\n\n            // Try and issue a scalar\n            WaveState* pScalarWave = FindScalarToIssue( pOps, pSIMDWaves, nWaves );\n            if( pScalarWave )\n            {\n                const SimOp* pOp = &pOps[pScalarWave->nCurrentOp];\n                const GCN::Instruction* pInst = pOp->pInstruction;\n                if( pInst->GetClass() == IC_SCALAR_MEM )\n                {\n                    // NOTE: Ignoring the possibility the the counters might overflow\n                    //    If that happens, the simulator will be unsable\n                    //    but I'm assuming I won't be asked to simulate incorrect code\n                    //\n                    pScalarWave->lkgmcnt++;\n\n                    const ScalarMemoryInstruction* pSMem = static_cast<const ScalarMemoryInstruction*>(pInst);\n                    SMemOp op;\n                    op.nDWORDsLeft = pSMem->GetResultWidthInDWORDs();\n                    op.pWave = pScalarWave;\n                    SMemQueue.push_back(op);\n                }\n                else\n                {\n                    // assume SALU is always free and finishes instantly\n                    rResults.nSALUBusy++;\n                }\n            }\n\n            // Try and issue a valu if the ALU is not busy\n            //  ALU can still be busy if it is stuck doing a long-latency op like an rsq\n            WaveState* pVALUWave = 0;\n            if( pWavesInVALU[nCurrentSIMD] == 0 )\n            {\n                pVALUWave    = FindVALUToIssue( pOps, pSIMDWaves, nWaves );\n                if( pVALUWave )\n                {\n                    size_t nCost = GetVALUCost( pOps[pVALUWave->nCurrentOp].pInstruction );\n                    pVALUCycles[nCurrentSIMD]   = nCost;\n                    pWavesInVALU[nCurrentSIMD]  = pVALUWave;\n                }\n            }\n\n            // Try and issue a vmem\n            WaveState* pVMemWave = FindVMEMToIssue( pOps, pSIMDWaves, nWaves );\n            if( pVMemWave )\n            {\n                VMemOp op;\n                op.nClocksLeft = GetVMEMCost( &pOps[pVMemWave->nCurrentOp] );\n                op.pWave = pVMemWave;\n                op.bIsExport = IsVMEMWrite( pOps[pVMemWave->nCurrentOp].pInstruction );\n\n                if( op.bIsExport )\n                    pVMemWave->expcnt++;\n               \n                pVMemWave->vmcnt++;\n                VMemQueue.push_back( op );\n            }\n\n            // Try and issue an export\n            WaveState* pExpWave = FindExportToIssue( pOps, pSIMDWaves, nWaves );\n            if( pExpWave )\n            {\n                ExportOp op;\n                op.nClocksLeft = GetExportCost( pOps[pExpWave->nCurrentOp].pInstruction, rSettings.nExportCost );\n                \n                op.pWave = pExpWave;\n                pExpWave->expcnt++;\n                EXPQueue.push_back(op);\n            }\n\n            // Barrier pre-processing\n            //    - Mark all waves on this SIMD which have reached a barrier instruction\n            //       When all threads reach the barrier, their IPs will be advanced\n            //         during the \"Free Scalar\" phase which follows\n            //\n            //     This scheme is safe, because a released thread on one SIMD will execute\n            //        at most one other instruction before all the remaining threads have been released\n            //\n            //      In the case of two S_BARRIER's back to back, the\n            //         use of bit-masks should ensure that we do the right thing\n            //         because each thread will advance only if ITs mask is cleared\n            //\n            for( size_t i=0; i<nWaves; i++ )\n            {\n                WaveState* pWave = pSIMDWaves[i];\n                ThreadGroupState* pGroup = pWave->pThreadGroup;\n                \n                const SimOp* pOp = &pOps[pWave->nCurrentOp];\n                if( IsBarrier(pOp->pInstruction) )\n                {\n                    // add this wave to the list of waiting waves\n                    size_t nWaitMask = pGroup->nWaitMask;\n                    nWaitMask |= (1<<pWave->nWaveIDInGroup);\n\n                    // release waiting waves once all waves' bits have been added to the mask\n                    size_t nGroupWaves = (pWave->pThreadGroup->nWaves - pWave->pThreadGroup->nRetiredWaves);\n                    if( PopCount(nWaitMask) == nGroupWaves )\n                        pGroup->nWaitMask=0;\n                    else\n                        pGroup->nWaitMask = (uint16)nWaitMask;\n                }\n            }\n            \n            // Issue \"helper\" instructions for all waves that can issue them\n            //    nop, sleep, wait, barrier, setprio, s_endpgm\n            size_t nFreeOps=0;\n            for( size_t i=0; i<nWaves; i++ )\n            {\n                WaveState* pWave = pSIMDWaves[i];\n                \n                const SimOp* pOp = &pOps[pWave->nCurrentOp];\n                if( CanIssueFreeScalarOp(pOp->pInstruction, pWave) )\n                {\n                    nFreeOps++;\n                    pWave->nCurrentOp++;\n                }\n            }\n\n\n\n            // retire any waves that have finished their trace\n            for( size_t i=0; i<MAX_WAVES_PER_CU; i++ )\n            {\n                if( pWaveFronts[i].pThreadGroup &&\n                    pWaveFronts[i].nCurrentOp == nOps )\n                {\n                    pWaveFronts[i].pThreadGroup->nRetiredWaves++;\n                    if( pWaveFronts[i].pThreadGroup->nRetiredWaves == pWaveFronts[i].pThreadGroup->nWaves )\n                    {\n                        // retire thread groups for which all waves are done\n                        memset(pWaveFronts[i].pThreadGroup, 0, sizeof(*(pWaveFronts[i].pThreadGroup)));\n                        nGroupsInFlight--;\n                    }\n\n                    pWaveFronts[i].pThreadGroup = 0;\n                    nRetiredWaves++;\n                }\n            }\n\n            // purge any retired waves from the in-flight lists\n            for( size_t i=0; i<NUM_SIMDS; i++ )\n            {\n                size_t nLive=0;\n                size_t nWaves=pWaveCount[i];\n                for( size_t w=0; w<nWaves; w++ )\n                    if( pWavesInFlight[i][w]->pThreadGroup )\n                        pWavesInFlight[i][nLive++] = pWavesInFlight[i][w];\n\n                pWaveCount[i] = nLive;\n            }\n\n            nClock++;\n\n            if( nRetiredWaves == nWavesToExecute )\n                break;\n\n            // track peak occupancy\n            size_t nWaveOcc=0;\n            for( size_t i=0; i<NUM_SIMDS; i++ )\n                nWaveOcc += pWaveCount[i];\n            if(nWaveOcc > rResults.nPeakWaveOccupancy)\n                rResults.nPeakWaveOccupancy = nWaveOcc;\n            if( nWaveOcc == 0 )\n                rResults.nStarveCycles++;\n\n            if( nGroupsInFlight > rResults.nPeakGroupOccupancy )\n                rResults.nPeakGroupOccupancy = nGroupsInFlight;\n\n            \n            if( pLDSWave )\n            {\n                rResults.nLDSIssued++;\n                pLDSWave->nCurrentOp++;\n            }\n\n            if( pScalarWave )\n            {\n                if( pOps[pScalarWave->nCurrentOp].pInstruction->GetClass() == IC_SCALAR_MEM )\n                    rResults.nSMEMIssued++;\n                else\n                    rResults.nSALUIssued++;\n\n                pScalarWave->nCurrentOp++;\n            }\n\n            // VALU waves don't get their IP incremented\n            //   until after the op completes.  This is done to ensure that the wave\n            //   blocks itself if it's doing a long-latency operation\n            if( pVALUWave )\n            {\n                rResults.nVALUIssued++;\n            }\n\n            if( pVMemWave )\n            {\n                pVMemWave->nCurrentOp++;\n                rResults.nVMemIssued++;\n            }\n            if( pExpWave )\n            {\n                pExpWave->nCurrentOp++;\n                rResults.nExpIssued++;\n            }\n\n            // check for clocks where nothing happens and track them\n            //  Don't count as a stall if VALU is occupied by a long-latency op\n            bool bVALUStarved = !pVALUWave && !pWavesInVALU[nCurrentSIMD];\n\n            if( !pScalarWave && bVALUStarved && !pVMemWave && !pExpWave && !pLDSWave && !nFreeOps && pWaveCount[nCurrentSIMD] ) \n            {\n                rResults.nStallCycles[nCurrentSIMD]++;\n\n                // find the set of distinct SimOps on which we're stalled\n                size_t pDistinctSimOps[MAX_WAVES_PER_SIMD];\n                size_t nDistinctSimOps=0;\n                for( size_t w=0; w<pWaveCount[nCurrentSIMD]; w++ )\n                    pDistinctSimOps[nDistinctSimOps++] = pSIMDWaves[w]->nCurrentOp;\n                \n                // de-duplicate, and increment stall count on each stalled SimOp\n                std::sort( pDistinctSimOps, pDistinctSimOps+nDistinctSimOps );\n                for( size_t i=0; i<nDistinctSimOps; )\n                {\n                    size_t i0 = i;\n                    rResults.pSimOpStallCounts[pDistinctSimOps[i0]];\n                    \n                    do\n                    {\n                        i++;\n                    } while( i<nDistinctSimOps && pDistinctSimOps[i] == pDistinctSimOps[i0] );\n                }\n\n                // do the same for instructions\n                size_t pStallInstructions[MAX_WAVES_PER_SIMD];\n                size_t nInstructions=0;\n                for( size_t i=0; i<nDistinctSimOps; i++ )\n                    pStallInstructions[nInstructions++] = pOps[pDistinctSimOps[i]].nInstructionID;\n\n                std::sort( pStallInstructions, pStallInstructions+nInstructions );\n                for( size_t i=0; i<nInstructions; )\n                {\n                    size_t i0 = i;\n                    rResults.pInstructionStallCounts[pStallInstructions[i0]]++;                    \n                    do\n                    {\n                        i++;\n                    } while( i<nOps && pStallInstructions[i] == pStallInstructions[i0] );\n                }\n            }\n        } \n\n        rResults.nCycles = nClock;\n    }\n\n}}"
  },
  {
    "path": "src/Wrapper/GCNSimulator.h",
    "content": "#ifndef _GCN_SIMULATOR_H_\r\n#define _GCN_SIMULATOR_H_\r\n\r\nnamespace GCN{\r\n    \r\n    class Instruction;\r\n\r\nnamespace Simulator{\r\n\r\n    struct Settings\r\n    {\r\n        size_t nWavesPerThreadGroup;    ///< This many wavefronts per thread group\r\n        size_t nGroupIssueRate;         ///< Issue one thread group every N clocks\r\n        size_t nGroupsToExecute;        ///< Execute this many groups before stopping\r\n        size_t nMaxWavesPerSIMD;        ///< Wave occupancy limit per SIMD\r\n        size_t nMaxGroupsPerCU;         ///< Group occupancy limit per CU\r\n        size_t nExportCost;             ///< How long an export should take\r\n                                        ///<  This is presumed to be a function of the number of CUs to a slice\r\n\r\n    };\r\n\r\n    struct Results\r\n    {\r\n        ///< Count the number of clocks where at least one wave was stalled on a given instruction\r\n        ///<  Indexed by the InstructionID field in the 'SimOp'\r\n        ///< Caller must allocate and zero before simulating\r\n        size_t* pInstructionStallCounts; \r\n\r\n        ///< Number of times that at least one wave was stalled on each SimOp\r\n        ///<   Index space is the same as the SimOp array passed to the simulator\r\n        ///< Each op's counter is Incremented once per stalled clock/stalled wave  \r\n        size_t* pSimOpStallCounts;\r\n\r\n        ///< Caller must zero all fields below before simulating\r\n\r\n        size_t nCycles;\r\n        size_t nSALUBusy;\r\n        size_t nVALUBusy[4];\r\n        size_t nVMemBusy;\r\n        size_t nExpBusy;\r\n        size_t nSMemBusy;\r\n        size_t nLDSBusy;    // NOTE: LDS is counted double, once for SIMD0/1, and once for SIMD2/3\r\n        \r\n        size_t nVALUIssued;\r\n        size_t nSALUIssued;\r\n        size_t nVMemIssued;\r\n        size_t nExpIssued;\r\n        size_t nSMEMIssued;\r\n        size_t nLDSIssued;\r\n\r\n        size_t nPeakWaveOccupancy;\r\n        size_t nPeakGroupOccupancy;\r\n\r\n        size_t nStallCycles[4];    ///< Number of times each SIMD was stalled\r\n        size_t nStarveCycles; ///< Number of clocks during which CU is completely empty\r\n    };\r\n\r\n\r\n    enum Format\r\n    {\r\n        FMT_R8,\r\n        FMT_RG8,\r\n        FMT_RGBA8,\r\n        FMT_R16,\r\n        FMT_RG16,\r\n        FMT_RGBA16,\r\n        FMT_R16F,\r\n        FMT_RG16F,\r\n        FMT_RGBA16F,\r\n        FMT_R32F,\r\n        FMT_RG32F,\r\n        FMT_RGBA32F,\r\n        FMT_BC1,\r\n        FMT_BC2,\r\n        FMT_BC3,\r\n        FMT_BC4,\r\n        FMT_BC5,\r\n        FMT_BC6,\r\n        FMT_BC7\r\n    };\r\n\r\n    enum Filter\r\n    {\r\n        FILT_POINT,\r\n        FILT_BILINEAR,\r\n        FILT_TRILINEAR,\r\n        FILT_ANISO_2X,\r\n        FILT_ANISO_4X,\r\n        FILT_ANISO_8X\r\n    };\r\n\r\n\r\n\r\n    struct SimOp\r\n    {\r\n        const GCN::Instruction* pInstruction;\r\n        size_t nInstructionID;  ///< Index of the instruction in the results.pInstructionStallCounts\r\n\r\n        // These are used only if 'pInstruction' is a corresponding image instruction\r\n        Format eFormat;\r\n        Filter eFilter;\r\n\r\n    };\r\n\r\n\r\n    /// Simulate wavefront execution on a single CU\r\n    /// \r\n    void Simulate( Results& rResults, const Settings& rSettings, SimOp* pOps, size_t nOps );\r\n\r\n}};\r\n\r\n\r\n#endif"
  },
  {
    "path": "src/Wrapper/GLSLOpt_Impl.cpp",
    "content": "\n#pragma unmanaged\n#include \"glsl-optimizer/src/glsl/glsl_optimizer.h\"\n#pragma managed\n\n#include \"GLSLOpt_Impl.h\"\n\nnamespace Pyramid{\nnamespace GLSLOptimizer{\n\n    Shader_Impl::Shader_Impl( glslopt_shader* pShader, Pyramid::GLSLOptimizer::IOptimizer^ owner ) \n    : m_pShader(pShader),\n      m_pLog(glslopt_get_log(pShader)),\n      m_pOutput(glslopt_get_output(pShader)),\n      m_pOutputRaw(glslopt_get_raw_output(pShader)),\n      m_bError(!glslopt_get_status(pShader)),\n      m_nFlow(0),\n      m_nMath(0),\n      m_nTexture(0),\n      m_Owner(owner)\n    {\n        int nMath;\n        int nTexture;\n        int nFlow;\n        m_Inputs = gcnew List<System::String^>();\n        if( !m_bError )\n        {\n            glslopt_shader_get_stats( pShader, &nMath, &nTexture, &nFlow );\n            m_nMath = nMath;\n            m_nTexture = nTexture;\n            m_nFlow = nFlow;\n\n            int nInputs = glslopt_shader_get_input_count( m_pShader );\n            for( int i=0; i<nInputs; i++ )\n            {\n                glslopt_basic_type baseType;\n                glslopt_precision precision;\n                int vecSize, arrSize, matSize, location;\n                const char* pName;\n                glslopt_shader_get_input_desc(m_pShader,i,&pName,&baseType, &precision, &vecSize, &matSize, &arrSize, &location );\n                m_Inputs->Add( MakeString(pName) );\n            }\n        }\n    }\n\n    Shader_Impl::~Shader_Impl()\n    {\n        glslopt_shader_delete(m_pShader);\n    }\n\n\n\n    Optimizer_Impl::Optimizer_Impl( Pyramid::GLSLOptimizer::Target eTarget )\n    {\n        switch( eTarget )\n        {\n        case Target::OPENGL:     m_pContext = glslopt_initialize( kGlslTargetOpenGL ); break;\n        case Target::OPENGL_ES2: m_pContext = glslopt_initialize( kGlslTargetOpenGLES20 ); break;\n        case Target::OPENGL_ES3: m_pContext = glslopt_initialize( kGlslTargetOpenGLES30 ); break;\n        }   \n    }\n\n    Optimizer_Impl::~Optimizer_Impl()\n    {\n        glslopt_cleanup(m_pContext);\n    }\n\n    IShader^ Optimizer_Impl::Optimize(System::String^ text, IOptions^ opts)\n    {\n        glslopt_shader_type eShaderType;\n        switch( opts->ShaderType )\n        {\n        default: return nullptr;\n        case ShaderType::VERTEX:   eShaderType = kGlslOptShaderVertex;   break;\n        case ShaderType::FRAGMENT: eShaderType = kGlslOptShaderFragment; break;\n        }\n\n        MarshalledString marshalledText(text);\n        glslopt_set_max_unroll_iterations( m_pContext, opts->MaxUnrollIterations );\n        glslopt_shader* pShader = glslopt_optimize( m_pContext, eShaderType, marshalledText, 0 );\n    \n        return gcnew Shader_Impl(pShader,this);\n    }\n\n}}"
  },
  {
    "path": "src/Wrapper/GLSLOpt_Impl.h",
    "content": "\n#include \"Utilities.h\"\n\nstruct glslopt_shader;\nstruct glslopt_ctx;\n\nusing namespace System::Collections::Generic;\nusing namespace System::Runtime::InteropServices;\n\nnamespace Pyramid{\nnamespace GLSLOptimizer{\n\n    ref class Optimizer_Impl : IOptimizer\n    {\n    public:\n           \n        Optimizer_Impl( Target eTarget );\n        ~Optimizer_Impl();\n        virtual IShader^ Optimize(System::String^ text, IOptions^ opts);\n \n    private:\n        glslopt_ctx* m_pContext;\n    };\n\n\n    ref class Shader_Impl : IShader\n    {\n    public:\n        Shader_Impl( glslopt_shader* pShader, IOptimizer^ owner );\n        ~Shader_Impl();\n\n        virtual property bool HadError { bool get() { return m_bError; }};\n        virtual property System::String^ Output { System::String^ get() { return MakeString(m_pOutput); }}\n        virtual property System::String^ RawOutput { System::String^ get() { return MakeString(m_pOutputRaw); }}\n        virtual property System::String^ Log { System::String^ get() { return MakeString(m_pLog); }}\n        virtual property IEnumerable<System::String^>^ Inputs { IEnumerable<System::String^>^ get(){ return m_Inputs; }}\n        virtual property int MathOps { int get() { return m_nMath; }}\n        virtual property int TextureOps { int get() { return m_nTexture; } }\n        virtual property int ControlFlowOps { int get() { return m_nFlow; } }\n\n    private:\n        glslopt_shader* m_pShader;\n        int m_nMath;\n        int m_nTexture;\n        int m_nFlow;\n        bool m_bError;\n        const char* m_pLog;\n        const char* m_pOutput;\n        const char* m_pOutputRaw;\n        List<System::String^>^ m_Inputs;\n        IOptimizer^ m_Owner; ///< Hold a reference in case .NET tries to destroy shader/optimizer out of order\n    };\n\n}}"
  },
  {
    "path": "src/Wrapper/GLSlang_Impl.cpp",
    "content": "\n#define _CRT_SECURE_NO_WARNINGS\n\n#pragma unmanaged\n#include \"GLSlang/glslang/Public/ShaderLang.h\"\n#include \"GLSlang/glslang/Include/ResourceLimits.h\"\n#include \"GLSlang/SPIRV/GlslangToSpv.h\"\n#include \"GLSlang/SPIRV/disassemble.h\"\n#include <sstream>\n#pragma managed\n\n#include \"Utilities.h\"\n#include \"GLSlang_Impl.h\"\n\n//\n// These are the default resources for TBuiltInResources, used for both\n//  - parsing this string for the case where the user didn't supply one\n//  - dumping out a template for user construction of a config file\n//\nconst char* DefaultConfig =\n    \"MaxLights 32\\n\"\n    \"MaxClipPlanes 6\\n\"\n    \"MaxTextureUnits 32\\n\"\n    \"MaxTextureCoords 32\\n\"\n    \"MaxVertexAttribs 64\\n\"\n    \"MaxVertexUniformComponents 4096\\n\"\n    \"MaxVaryingFloats 64\\n\"\n    \"MaxVertexTextureImageUnits 32\\n\"\n    \"MaxCombinedTextureImageUnits 80\\n\"\n    \"MaxTextureImageUnits 32\\n\"\n    \"MaxFragmentUniformComponents 4096\\n\"\n    \"MaxDrawBuffers 32\\n\"\n    \"MaxVertexUniformVectors 128\\n\"\n    \"MaxVaryingVectors 8\\n\"\n    \"MaxFragmentUniformVectors 16\\n\"\n    \"MaxVertexOutputVectors 16\\n\"\n    \"MaxFragmentInputVectors 15\\n\"\n    \"MinProgramTexelOffset -8\\n\"\n    \"MaxProgramTexelOffset 7\\n\"\n    \"MaxClipDistances 8\\n\"\n    \"MaxComputeWorkGroupCountX 65535\\n\"\n    \"MaxComputeWorkGroupCountY 65535\\n\"\n    \"MaxComputeWorkGroupCountZ 65535\\n\"\n    \"MaxComputeWorkGroupSizeX 1024\\n\"\n    \"MaxComputeWorkGroupSizeX 1024\\n\"\n    \"MaxComputeWorkGroupSizeZ 64\\n\"\n    \"MaxComputeUniformComponents 1024\\n\"\n    \"MaxComputeTextureImageUnits 16\\n\"\n    \"MaxComputeImageUniforms 8\\n\"\n    \"MaxComputeAtomicCounters 8\\n\"\n    \"MaxComputeAtomicCounterBuffers 1\\n\"\n    \"MaxVaryingComponents 60\\n\" \n    \"MaxVertexOutputComponents 64\\n\"\n    \"MaxGeometryInputComponents 64\\n\"\n    \"MaxGeometryOutputComponents 128\\n\"\n    \"MaxFragmentInputComponents 128\\n\"\n    \"MaxImageUnits 8\\n\"\n    \"MaxCombinedImageUnitsAndFragmentOutputs 8\\n\"\n    \"MaxImageSamples 0\\n\"\n    \"MaxVertexImageUniforms 0\\n\"\n    \"MaxTessControlImageUniforms 0\\n\"\n    \"MaxTessEvaluationImageUniforms 0\\n\"\n    \"MaxGeometryImageUniforms 0\\n\"\n    \"MaxFragmentImageUniforms 8\\n\"\n    \"MaxCombinedImageUniforms 8\\n\"\n    \"MaxGeometryTextureImageUnits 16\\n\"\n    \"MaxGeometryOutputVertices 256\\n\"\n    \"MaxGeometryTotalOutputComponents 1024\\n\"\n    \"MaxGeometryUniformComponents 1024\\n\"\n    \"MaxGeometryVaryingComponents 64\\n\"\n    \"MaxTessControlInputComponents 128\\n\"\n    \"MaxTessControlOutputComponents 128\\n\"\n    \"MaxTessControlTextureImageUnits 16\\n\"\n    \"MaxTessControlUniformComponents 1024\\n\"\n    \"MaxTessControlTotalOutputComponents 4096\\n\"\n    \"MaxTessEvaluationInputComponents 128\\n\"\n    \"MaxTessEvaluationOutputComponents 128\\n\"\n    \"MaxTessEvaluationTextureImageUnits 16\\n\"\n    \"MaxTessEvaluationUniformComponents 1024\\n\"\n    \"MaxTessPatchComponents 120\\n\"\n    \"MaxPatchVertices 32\\n\"\n    \"MaxTessGenLevel 64\\n\"\n    \"MaxViewports 16\\n\"\n    \"MaxVertexAtomicCounters 0\\n\"\n    \"MaxTessControlAtomicCounters 0\\n\"\n    \"MaxTessEvaluationAtomicCounters 0\\n\"\n    \"MaxGeometryAtomicCounters 0\\n\"\n    \"MaxFragmentAtomicCounters 8\\n\"\n    \"MaxCombinedAtomicCounters 8\\n\"\n    \"MaxAtomicCounterBindings 1\\n\"\n    \"MaxVertexAtomicCounterBuffers 0\\n\"\n    \"MaxTessControlAtomicCounterBuffers 0\\n\"\n    \"MaxTessEvaluationAtomicCounterBuffers 0\\n\"\n    \"MaxGeometryAtomicCounterBuffers 0\\n\"\n    \"MaxFragmentAtomicCounterBuffers 1\\n\"\n    \"MaxCombinedAtomicCounterBuffers 1\\n\"\n    \"MaxAtomicCounterBufferSize 16384\\n\"\n    \"MaxTransformFeedbackBuffers 4\\n\"\n    \"MaxTransformFeedbackInterleavedComponents 64\\n\"\n    \"nonInductiveForLoops 1\\n\"\n    \"whileLoops 1\\n\"\n    \"doWhileLoops 1\\n\"\n    \"generalUniformIndexing 1\\n\"\n    \"generalAttributeMatrixVectorIndexing 1\\n\"\n    \"generalVaryingIndexing 1\\n\"\n    \"generalSamplerIndexing 1\\n\"\n    \"generalVariableIndexing 1\\n\"\n    \"generalConstantMatrixVectorIndexing 1\\n\"\n    ;\n\n\n\n//\n// Parse either a .conf file provided by the user or the default string above.\n//\nvoid ProcessConfigFile( TBuiltInResource& Resources,  char* config )\n{    \n    const char* delims = \" \\t\\n\\r\";\n    const char* token = strtok(config, delims);\n    while (token) {\n        const char* valueStr = strtok(0, delims);\n        if (valueStr == 0 || ! (valueStr[0] == '-' || (valueStr[0] >= '0' && valueStr[0] <= '9'))) {\n            printf(\"Error: '%s' bad .conf file.  Each name must be followed by one number.\\n\", valueStr ? valueStr : \"\");\n            return;\n        }\n        int value = atoi(valueStr);\n\n        if (strcmp(token, \"MaxLights\") == 0)\n            Resources.maxLights = value;\n        else if (strcmp(token, \"MaxClipPlanes\") == 0)\n            Resources.maxClipPlanes = value;\n        else if (strcmp(token, \"MaxTextureUnits\") == 0)\n            Resources.maxTextureUnits = value;\n        else if (strcmp(token, \"MaxTextureCoords\") == 0)\n            Resources.maxTextureCoords = value;\n        else if (strcmp(token, \"MaxVertexAttribs\") == 0)\n            Resources.maxVertexAttribs = value;\n        else if (strcmp(token, \"MaxVertexUniformComponents\") == 0)\n            Resources.maxVertexUniformComponents = value;\n        else if (strcmp(token, \"MaxVaryingFloats\") == 0)\n            Resources.maxVaryingFloats = value;\n        else if (strcmp(token, \"MaxVertexTextureImageUnits\") == 0)\n            Resources.maxVertexTextureImageUnits = value;\n        else if (strcmp(token, \"MaxCombinedTextureImageUnits\") == 0)\n            Resources.maxCombinedTextureImageUnits = value;\n        else if (strcmp(token, \"MaxTextureImageUnits\") == 0)\n            Resources.maxTextureImageUnits = value;\n        else if (strcmp(token, \"MaxFragmentUniformComponents\") == 0)\n            Resources.maxFragmentUniformComponents = value;\n        else if (strcmp(token, \"MaxDrawBuffers\") == 0)\n            Resources.maxDrawBuffers = value;\n        else if (strcmp(token, \"MaxVertexUniformVectors\") == 0)\n            Resources.maxVertexUniformVectors = value;\n        else if (strcmp(token, \"MaxVaryingVectors\") == 0)\n            Resources.maxVaryingVectors = value;\n        else if (strcmp(token, \"MaxFragmentUniformVectors\") == 0)\n            Resources.maxFragmentUniformVectors = value;\n        else if (strcmp(token, \"MaxVertexOutputVectors\") == 0)\n            Resources.maxVertexOutputVectors = value;\n        else if (strcmp(token, \"MaxFragmentInputVectors\") == 0)\n            Resources.maxFragmentInputVectors = value;\n        else if (strcmp(token, \"MinProgramTexelOffset\") == 0)\n            Resources.minProgramTexelOffset = value;\n        else if (strcmp(token, \"MaxProgramTexelOffset\") == 0)\n            Resources.maxProgramTexelOffset = value;\n        else if (strcmp(token, \"MaxClipDistances\") == 0)\n            Resources.maxClipDistances = value;\n        else if (strcmp(token, \"MaxComputeWorkGroupCountX\") == 0)\n            Resources.maxComputeWorkGroupCountX = value;\n        else if (strcmp(token, \"MaxComputeWorkGroupCountY\") == 0)\n            Resources.maxComputeWorkGroupCountY = value;\n        else if (strcmp(token, \"MaxComputeWorkGroupCountZ\") == 0)\n            Resources.maxComputeWorkGroupCountZ = value;\n        else if (strcmp(token, \"MaxComputeWorkGroupSizeX\") == 0)\n            Resources.maxComputeWorkGroupSizeX = value;\n        else if (strcmp(token, \"MaxComputeWorkGroupSizeY\") == 0)\n            Resources.maxComputeWorkGroupSizeY = value;\n        else if (strcmp(token, \"MaxComputeWorkGroupSizeZ\") == 0)\n            Resources.maxComputeWorkGroupSizeZ = value;\n        else if (strcmp(token, \"MaxComputeUniformComponents\") == 0)\n            Resources.maxComputeUniformComponents = value;\n        else if (strcmp(token, \"MaxComputeTextureImageUnits\") == 0)\n            Resources.maxComputeTextureImageUnits = value;\n        else if (strcmp(token, \"MaxComputeImageUniforms\") == 0)\n            Resources.maxComputeImageUniforms = value;\n        else if (strcmp(token, \"MaxComputeAtomicCounters\") == 0)\n            Resources.maxComputeAtomicCounters = value;\n        else if (strcmp(token, \"MaxComputeAtomicCounterBuffers\") == 0)\n            Resources.maxComputeAtomicCounterBuffers = value;\n        else if (strcmp(token, \"MaxVaryingComponents\") == 0)\n            Resources.maxVaryingComponents = value;\n        else if (strcmp(token, \"MaxVertexOutputComponents\") == 0)\n            Resources.maxVertexOutputComponents = value;\n        else if (strcmp(token, \"MaxGeometryInputComponents\") == 0)\n            Resources.maxGeometryInputComponents = value;\n        else if (strcmp(token, \"MaxGeometryOutputComponents\") == 0)\n            Resources.maxGeometryOutputComponents = value;\n        else if (strcmp(token, \"MaxFragmentInputComponents\") == 0)\n            Resources.maxFragmentInputComponents = value;\n        else if (strcmp(token, \"MaxImageUnits\") == 0)\n            Resources.maxImageUnits = value;\n        else if (strcmp(token, \"MaxCombinedImageUnitsAndFragmentOutputs\") == 0)\n            Resources.maxCombinedImageUnitsAndFragmentOutputs = value;\n        else if (strcmp(token, \"MaxImageSamples\") == 0)\n            Resources.maxImageSamples = value;\n        else if (strcmp(token, \"MaxVertexImageUniforms\") == 0)\n            Resources.maxVertexImageUniforms = value;\n        else if (strcmp(token, \"MaxTessControlImageUniforms\") == 0)\n            Resources.maxTessControlImageUniforms = value;\n        else if (strcmp(token, \"MaxTessEvaluationImageUniforms\") == 0)\n            Resources.maxTessEvaluationImageUniforms = value;\n        else if (strcmp(token, \"MaxGeometryImageUniforms\") == 0)\n            Resources.maxGeometryImageUniforms = value;\n        else if (strcmp(token, \"MaxFragmentImageUniforms\") == 0)\n            Resources.maxFragmentImageUniforms = value;\n        else if (strcmp(token, \"MaxCombinedImageUniforms\") == 0)\n            Resources.maxCombinedImageUniforms = value;\n        else if (strcmp(token, \"MaxGeometryTextureImageUnits\") == 0)\n            Resources.maxGeometryTextureImageUnits = value;\n        else if (strcmp(token, \"MaxGeometryOutputVertices\") == 0)\n            Resources.maxGeometryOutputVertices = value;\n        else if (strcmp(token, \"MaxGeometryTotalOutputComponents\") == 0)\n            Resources.maxGeometryTotalOutputComponents = value;\n        else if (strcmp(token, \"MaxGeometryUniformComponents\") == 0)\n            Resources.maxGeometryUniformComponents = value;\n        else if (strcmp(token, \"MaxGeometryVaryingComponents\") == 0)\n            Resources.maxGeometryVaryingComponents = value;\n        else if (strcmp(token, \"MaxTessControlInputComponents\") == 0)\n            Resources.maxTessControlInputComponents = value;\n        else if (strcmp(token, \"MaxTessControlOutputComponents\") == 0)\n            Resources.maxTessControlOutputComponents = value;\n        else if (strcmp(token, \"MaxTessControlTextureImageUnits\") == 0)\n            Resources.maxTessControlTextureImageUnits = value;\n        else if (strcmp(token, \"MaxTessControlUniformComponents\") == 0)\n            Resources.maxTessControlUniformComponents = value;\n        else if (strcmp(token, \"MaxTessControlTotalOutputComponents\") == 0)\n            Resources.maxTessControlTotalOutputComponents = value;\n        else if (strcmp(token, \"MaxTessEvaluationInputComponents\") == 0)\n            Resources.maxTessEvaluationInputComponents = value;\n        else if (strcmp(token, \"MaxTessEvaluationOutputComponents\") == 0)\n            Resources.maxTessEvaluationOutputComponents = value;\n        else if (strcmp(token, \"MaxTessEvaluationTextureImageUnits\") == 0)\n            Resources.maxTessEvaluationTextureImageUnits = value;\n        else if (strcmp(token, \"MaxTessEvaluationUniformComponents\") == 0)\n            Resources.maxTessEvaluationUniformComponents = value;\n        else if (strcmp(token, \"MaxTessPatchComponents\") == 0)\n            Resources.maxTessPatchComponents = value;\n        else if (strcmp(token, \"MaxPatchVertices\") == 0)\n            Resources.maxPatchVertices = value;\n        else if (strcmp(token, \"MaxTessGenLevel\") == 0)\n            Resources.maxTessGenLevel = value;\n        else if (strcmp(token, \"MaxViewports\") == 0)\n            Resources.maxViewports = value;\n        else if (strcmp(token, \"MaxVertexAtomicCounters\") == 0)\n            Resources.maxVertexAtomicCounters = value;\n        else if (strcmp(token, \"MaxTessControlAtomicCounters\") == 0)\n            Resources.maxTessControlAtomicCounters = value;\n        else if (strcmp(token, \"MaxTessEvaluationAtomicCounters\") == 0)\n            Resources.maxTessEvaluationAtomicCounters = value;\n        else if (strcmp(token, \"MaxGeometryAtomicCounters\") == 0)\n            Resources.maxGeometryAtomicCounters = value;\n        else if (strcmp(token, \"MaxFragmentAtomicCounters\") == 0)\n            Resources.maxFragmentAtomicCounters = value;\n        else if (strcmp(token, \"MaxCombinedAtomicCounters\") == 0)\n            Resources.maxCombinedAtomicCounters = value;\n        else if (strcmp(token, \"MaxAtomicCounterBindings\") == 0)\n            Resources.maxAtomicCounterBindings = value;\n        else if (strcmp(token, \"MaxVertexAtomicCounterBuffers\") == 0)\n            Resources.maxVertexAtomicCounterBuffers = value;\n        else if (strcmp(token, \"MaxTessControlAtomicCounterBuffers\") == 0)\n            Resources.maxTessControlAtomicCounterBuffers = value;\n        else if (strcmp(token, \"MaxTessEvaluationAtomicCounterBuffers\") == 0)\n            Resources.maxTessEvaluationAtomicCounterBuffers = value;\n        else if (strcmp(token, \"MaxGeometryAtomicCounterBuffers\") == 0)\n            Resources.maxGeometryAtomicCounterBuffers = value;\n        else if (strcmp(token, \"MaxFragmentAtomicCounterBuffers\") == 0)\n            Resources.maxFragmentAtomicCounterBuffers = value;\n        else if (strcmp(token, \"MaxCombinedAtomicCounterBuffers\") == 0)\n            Resources.maxCombinedAtomicCounterBuffers = value;\n        else if (strcmp(token, \"MaxAtomicCounterBufferSize\") == 0)\n            Resources.maxAtomicCounterBufferSize = value;\n        else if (strcmp(token, \"MaxTransformFeedbackBuffers\") == 0)\n            Resources.maxTransformFeedbackBuffers = value;\n        else if (strcmp(token, \"MaxTransformFeedbackInterleavedComponents\") == 0)\n            Resources.maxTransformFeedbackInterleavedComponents = value;\n\n        else if (strcmp(token, \"nonInductiveForLoops\") == 0)\n            Resources.limits.nonInductiveForLoops = (value != 0);\n        else if (strcmp(token, \"whileLoops\") == 0)\n            Resources.limits.whileLoops = (value != 0);\n        else if (strcmp(token, \"doWhileLoops\") == 0)\n            Resources.limits.doWhileLoops = (value != 0);\n        else if (strcmp(token, \"generalUniformIndexing\") == 0)\n            Resources.limits.generalUniformIndexing = (value != 0);\n        else if (strcmp(token, \"generalAttributeMatrixVectorIndexing\") == 0)\n            Resources.limits.generalAttributeMatrixVectorIndexing = (value != 0);\n        else if (strcmp(token, \"generalVaryingIndexing\") == 0)\n            Resources.limits.generalVaryingIndexing = (value != 0);\n        else if (strcmp(token, \"generalSamplerIndexing\") == 0)\n            Resources.limits.generalSamplerIndexing = (value != 0);\n        else if (strcmp(token, \"generalVariableIndexing\") == 0)\n            Resources.limits.generalVariableIndexing = (value != 0);\n        else if (strcmp(token, \"generalConstantMatrixVectorIndexing\") == 0)\n            Resources.limits.generalConstantMatrixVectorIndexing = (value != 0);\n        else\n            printf(\"Warning: unrecognized limit (%s) in configuration file.\\n\", token);\n\n        token = strtok(0, delims);\n    }\n}\n\n\nclass PyramidIncluder : public glslang::TShader::Includer\n{\npublic:\n\n    PyramidIncluder( Pyramid::IIncludeHandler^ pmIncluder )\n        : m_pmInclude(pmIncluder)\n    {\n    }\n\n    glslang::TShader::Includer::IncludeResult* Do( Pyramid::IncludeType eType, const char* headerName, const char* includerPath )\n    {\n        Pyramid::IIncludeHandler^ pmInclude = m_pmInclude;\n        if( pmInclude == nullptr )\n            return nullptr;\n\n        Pyramid::IIncludeResult^ pmResult = m_pmInclude->OpenInclude( eType, MakeString(headerName), MakeString(includerPath) );\n        if( pmResult == nullptr )\n            return nullptr;\n\n        array<unsigned char>^ bytes = pmResult->Contents;\n        MarshalledString str( pmResult->FullPath );\n\n        size_t nLength = bytes->Length;\n        void* pData = malloc( nLength );\n        Marshal::Copy( bytes,0,  System::IntPtr(pData), bytes->Length );\n        return new glslang::TShader::Includer::IncludeResult( std::string((const char*)str), (const char*)pData, nLength, nullptr);\n    }\n\n    glslang::TShader::Includer::IncludeResult* DepthLimit()\n    {\n        static const char* DEPTH_LIMIT = \"Include depth limit reached\";\n        size_t len = strlen(DEPTH_LIMIT);\n        char* pAlloc = (char*)malloc(len+1);\n        strcpy(pAlloc,DEPTH_LIMIT);\n        glslang::TShader::Includer::IncludeResult* pResult;\n        return new glslang::TShader::Includer::IncludeResult( \"\", pAlloc, len, nullptr);\n    }\n\n\n\n\n    // For the \"system\" or <>-style includes; search the \"system\" paths.\n    virtual IncludeResult* includeSystem(const char* headerName,\n                                            const char* includerName,\n                                            size_t inclusionDepth) \n    { \n        if( inclusionDepth > 1024 )\n            return DepthLimit();\n        return Do( Pyramid::IncludeType::System, headerName, includerName );\n    }\n\n    // For the \"local\"-only aspect of a \"\" include. Should not search in the\n    // \"system\" paths, because on returning a failure, the parser will\n    // call includeSystem() to look in the \"system\" locations.\n    virtual IncludeResult* includeLocal(const char* headerName,\n                                        const char* includerName,\n                                        size_t inclusionDepth) \n    { \n        if( inclusionDepth > 1024 )\n            return DepthLimit();\n        return Do( Pyramid::IncludeType::System, headerName, includerName );\n    }\n\n    // Signals that the parser will no longer use the contents of the\n    // specified IncludeResult.\n    virtual void releaseInclude(IncludeResult* result) \n    {\n        if( !result )\n            return;\n\n        if( result->headerData )\n            free((void*) result->headerData);\n        delete result;\n    }\n\nprivate:\n\n    gcroot<Pyramid::IIncludeHandler^> m_pmInclude;\n};\n\n\nnamespace Pyramid{\nnamespace GLSlang{\n\n    // The authors of glslang have not seen fit to make\n    //  the TIntermediate of a TShader directly accessible\n    //  But we need it if we're going to generate SPIRV from it\n    //  Lucky for us, they made it public\n    #pragma unmanaged\n    class StubShader : public glslang::TShader\n    {\n    public:\n        StubShader( EShLanguage eType ) : TShader(eType){}\n        glslang::TIntermediate* GetIntermediate() { return this->intermediate; }\n    };\n\n    #pragma managed\n\n    ref class ConfigImpl : IConfig\n    {\n    public:\n        ConfigImpl( const char* pText )\n        {\n            m_Config = new TBuiltInResource(); // can't use unmanaged struct type in managed class.  Doh\n            char* pCopy = new char[strlen(pText)+1];\n            strcpy(pCopy,pText);\n            ProcessConfigFile( *m_Config, pCopy );\n            delete[] pCopy;\n        }\n        ~ConfigImpl()\n        {\n            delete m_Config;\n        }\n\n        TBuiltInResource* m_Config;\n    };\n\n\n\n    struct SPIRVBlob_Unmanaged\n    {\n        std::vector<unsigned int> m_SPIRV;\n    };\n\n    ref class SPIRVBlob : Pyramid::SPIRV::IProgram\n    {\n    public:\n\n        SPIRVBlob( SPIRVBlob_Unmanaged* pBlob ) : m_pBlob(pBlob)\n        {\n        }\n        ~SPIRVBlob()\n        {\n            delete m_pBlob;\n        }\n        \n        virtual System::String^ Disassemble()\n        {\n            std::stringstream stream;\n            spv::Disassemble( stream, m_pBlob->m_SPIRV );\n\n            System::String^ str = MakeString( stream.str().c_str() );\n            return str->Replace( \"\\n\", System::Environment::NewLine );\n        }\n\n        virtual array<unsigned int>^ GetTokens()\n        {\n            array<unsigned int>^ pmArray = gcnew array<unsigned int>(m_pBlob->m_SPIRV.size());\n            for( size_t i=0; i<m_pBlob->m_SPIRV.size(); i++ )\n                pmArray[i] = m_pBlob->m_SPIRV[i];\n            return pmArray;\n        }\n        \n        virtual array<unsigned char>^ GetBytes()\n        {\n            size_t nSize = m_pBlob->m_SPIRV.size()*sizeof(unsigned int);\n            array<unsigned char>^ pmArray = gcnew array<unsigned char>(nSize);\n            Marshal::Copy( System::IntPtr((void*)m_pBlob->m_SPIRV.data()), pmArray, 0, nSize );\n            return pmArray;\n        }\n\n        SPIRVBlob_Unmanaged* m_pBlob; \n    };\n\n    ref class ShaderImpl : IShader\n    {\n    public:\n        ShaderImpl( StubShader* pShader, System::String^ Info, System::String^ InfoDebug, GLSLShaderType eType)\n            : m_pShader(pShader),\n              m_InfoLog( Info ),\n              m_InfoDebugLog( InfoDebug ),\n              m_eType(eType)\n        {\n        }\n        ~ShaderImpl()\n        {\n            if(m_pShader)\n                delete m_pShader;\n            m_pShader=nullptr;\n        }\n        virtual property GLSLShaderType ShaderType { GLSLShaderType get() { return m_eType; } }\n        virtual property bool HasErrors { bool get() { return m_pShader == nullptr; } };\n        virtual property System::String^ InfoLog { System::String^ get() { return m_InfoLog; } }\n        virtual property System::String^ InfoDebugLog { System::String^ get() { return m_InfoDebugLog; } }\n\n        virtual Pyramid::SPIRV::IProgram^ CompileSPIRV()\n        {\n            if( !m_pShader )\n                return nullptr;\n\n            SPIRVBlob_Unmanaged* pBlob = new SPIRVBlob_Unmanaged();\n            glslang::GlslangToSpv( *m_pShader->GetIntermediate(), pBlob->m_SPIRV );\n\n            return gcnew SPIRVBlob(pBlob);\n        }\n\n    private:\n        System::String^ m_InfoLog;\n        System::String^ m_InfoDebugLog;\n        StubShader* m_pShader;\n        GLSLShaderType m_eType;\n    };\n\n\n    static volatile long m_nLock=0;\n    static long m_nInstanceCount=0;\n\n    Compiler_Impl::Compiler_Impl( Pyramid::IIncludeHandler^ pmIncluder )\n    {\n        while( _InterlockedExchange( &m_nLock, 1 ) != 0 )\n            ;\n\n        long n = ++m_nInstanceCount;\n        if( n == 1 )\n            glslang::InitializeProcess();\n\n        m_nLock = 0;\n        m_pmIncluder = pmIncluder;\n    }\n    Compiler_Impl::~Compiler_Impl()\n    {\n        while( _InterlockedExchange( &m_nLock, 1 ) != 0 )\n            ;\n\n        long n = --m_nInstanceCount;\n        if( n == 0 )\n            glslang::FinalizeProcess();\n\n        m_nLock=0;\n    }\n\n\n    IConfig^ Compiler_Impl::CreateConfig(System::String^ text)\n    {\n        MarshalledString str(text);\n        return gcnew ConfigImpl(str);\n    }\n     \n    IConfig^ Compiler_Impl::CreateDefaultConfig()\n    {\n        return gcnew ConfigImpl(DefaultConfig);\n    }\n\n    IShader^ Compiler_Impl::Compile( System::String^ text, GLSLShaderType eManagedShaderType, IConfig^ config, System::String^ path )\n    {\n        EShLanguage eShaderType; \n        switch( eManagedShaderType )\n        {\n        case GLSLShaderType::VERTEX:            eShaderType = EShLangVertex; break;\n        case GLSLShaderType::FRAGMENT:          eShaderType = EShLangFragment; break;\n        case GLSLShaderType::GEOMETRY:          eShaderType = EShLangGeometry; break;\n        case GLSLShaderType::TESS_CONTROL:      eShaderType = EShLangTessControl; break;\n        case GLSLShaderType::TESS_EVALUATION:   eShaderType = EShLangTessEvaluation; break;\n        case GLSLShaderType::COMPUTE:           eShaderType = EShLangCompute; break;\n        default: return nullptr;\n        }\n\n        ConfigImpl^ cfg = (ConfigImpl^)config;\n\n        MarshalledString marshalledText(text);\n        const char* p = marshalledText.GetString();\n        int len = strlen(p);\n        \n        MarshalledString marshalledPath(path);\n        const char* pnames = marshalledPath.GetString();\n\n        StubShader* shader = new StubShader(eShaderType);\n        shader->setStringsWithLengthsAndNames( &p, &len, &pnames, 1 );\n\n\n        PyramidIncluder includer(m_pmIncluder);\n\n        bool bResult = shader->parse( cfg->m_Config, 100, false, EShMsgDefault, includer );\n\n        System::String^ rInfoLog = MakeString( shader->getInfoLog() );\n        System::String^ rInfoDebugLog = MakeString( shader->getInfoDebugLog() );\n        if( !bResult )\n        {\n            delete shader;\n            shader = nullptr;\n        }\n\n        return gcnew ShaderImpl(shader, rInfoLog, rInfoDebugLog, eManagedShaderType );\n    }\n\n    IShader^ Compiler_Impl::CompileHLSL( System::String^ text, IHLSLOptions^ opts, IConfig^ config, System::String^ path )\n    {\n        System::String^ entrypoint = opts->EntryPoint;\n\n        GLSLShaderType eManagedType;\n        \n        System::String^ profile = opts->Target.ToString();\n        if (profile->StartsWith(\"vs\"))\n            eManagedType = GLSLShaderType::VERTEX;\n        else if (profile->StartsWith(\"ps\"))\n            eManagedType = GLSLShaderType::FRAGMENT;\n        else if (profile->StartsWith(\"gs\"))\n            eManagedType = GLSLShaderType::GEOMETRY;\n        else if (profile->StartsWith(\"hs\"))\n            eManagedType = GLSLShaderType::TESS_CONTROL;\n        else if (profile->StartsWith(\"ds\"))\n            eManagedType = GLSLShaderType::TESS_EVALUATION;\n        else if (profile->StartsWith(\"cs\"))\n            eManagedType = GLSLShaderType::COMPUTE;\n        else\n            return nullptr;\n            \n\n        EShLanguage eShaderType; \n        switch( eManagedType )\n        {\n        case GLSLShaderType::VERTEX:            eShaderType = EShLangVertex; break;\n        case GLSLShaderType::FRAGMENT:          eShaderType = EShLangFragment; break;\n        case GLSLShaderType::GEOMETRY:          eShaderType = EShLangGeometry; break;\n        case GLSLShaderType::TESS_CONTROL:      eShaderType = EShLangTessControl; break;\n        case GLSLShaderType::TESS_EVALUATION:   eShaderType = EShLangTessEvaluation; break;\n        case GLSLShaderType::COMPUTE:           eShaderType = EShLangCompute; break;\n        default: return nullptr;\n        }\n\n        ConfigImpl^ cfg = (ConfigImpl^)config;\n\n        MarshalledString marshalledText(text);\n        MarshalledString marshalledEntryPoint(entrypoint);\n        const char* p = marshalledText.GetString();\n        int len = strlen(p);\n\n        MarshalledString marshalledPath(path);\n        const char* pPath = marshalledPath.GetString();\n       \n        StubShader* shader = new StubShader(eShaderType);\n        shader->setStringsWithLengthsAndNames( &p, &len, &pPath, 1 );\n        shader->setEntryPoint( marshalledEntryPoint.GetString() );\n        shader->setHlslIoMapping(true);\n        shader->setAutoMapBindings(true);\n\n        PyramidIncluder includer(m_pmIncluder);\n\n        bool bResult = shader->parse( cfg->m_Config, 100, false, (EShMessages)(EShMsgDefault|EShMsgReadHlsl|EShMsgVulkanRules|EShMsgSpvRules), includer );\n\n        System::String^ rInfoLog = MakeString( shader->getInfoLog() );\n        System::String^ rInfoDebugLog = MakeString( shader->getInfoDebugLog() );\n        if( !bResult )\n        {\n            delete shader;\n            shader = nullptr;\n        }\n\n        return gcnew ShaderImpl(shader, rInfoLog, rInfoDebugLog, eManagedType );\n       \n    }\n\n}}\n"
  },
  {
    "path": "src/Wrapper/GLSlang_Impl.h",
    "content": "\n\n\nnamespace Pyramid{\nnamespace GLSlang{\n\n\n    ref class Compiler_Impl : ICompiler\n    {\n    public:\n        Compiler_Impl( Pyramid::IIncludeHandler^ pmInclude );\n        ~Compiler_Impl();\n        \n        virtual IShader^ Compile( System::String^ text, GLSLShaderType eManagedType, IConfig^ cfg, System::String^ filePath );\n        virtual IShader^ CompileHLSL( System::String^ text,  IHLSLOptions^ opts, IConfig^ cfg ,System::String^ filePath );\n        virtual IConfig^ CreateConfig(System::String^ text);\n        virtual IConfig^ CreateDefaultConfig();\n\n    private:\n        Pyramid::IIncludeHandler^ m_pmIncluder;\n    };\n\n\n}}"
  },
  {
    "path": "src/Wrapper/GLSlang_Stubs.cpp",
    "content": "\n// GLSLang in library mode needs this crap defined or it won't link.... Lame...\n\n#pragma unmanaged\n\n#include \"GLSlang/glslang/Include/Common.h\"\n#include \"GLSlang/glslang/Include/ShHandle.h\"\n#include \"GLSlang/glslang/MachineIndependent/Versions.h\"\n\n#if 0\n//\n// Here is where real machine specific high-level data would be defined.\n//\nclass TGenericCompiler : public TCompiler {\npublic:\n    TGenericCompiler(EShLanguage l, int dOptions) : TCompiler(l, infoSink), debugOptions(dOptions) { }\n    virtual bool compile(TIntermNode* root, int version = 0, EProfile profile = ENoProfile);\n    TInfoSink infoSink;\n    int debugOptions;\n};\n\n//\n// This function must be provided to create the actual\n// compile object used by higher level code.  It returns\n// a subclass of TCompiler.\n//\nTCompiler* ConstructCompiler(EShLanguage language, int debugOptions)\n{\n    return new TGenericCompiler(language, debugOptions);\n}\n\n//\n// Delete the compiler made by ConstructCompiler\n//\nvoid DeleteCompiler(TCompiler* compiler)\n{\n    delete compiler;\n}\n\n//\n//  Generate code from the given parse tree\n//\nbool TGenericCompiler::compile(TIntermNode *root, int version, EProfile profile)\n{\n    haveValidObjectCode = true;\n\n    return haveValidObjectCode;\n}\n\n\n//\n// Actual link object, derived from the shader handle base classes.\n//\nclass TGenericLinker : public TLinker {\npublic:\n    TGenericLinker(EShExecutable e, int dOptions) : TLinker(e, infoSink), debugOptions(dOptions) { }\n    bool link(TCompilerList&, TUniformMap*) { return true; }\n\tvoid getAttributeBindings(ShBindingTable const **t) const { }\n    TInfoSink infoSink;\n    int debugOptions;\n};\n\n//\n// The internal view of a uniform/float object exchanged with the driver.\n//\nclass TUniformLinkedMap : public TUniformMap {\npublic:\n    TUniformLinkedMap() { }\n    virtual int getLocation(const char* name) { return 0; }\n};\n\nTShHandleBase* ConstructLinker(EShExecutable executable, int debugOptions)\n{\n    return new TGenericLinker(executable, debugOptions);\n}\n\nvoid DeleteLinker(TShHandleBase* linker)\n{\n    delete linker;\n}\n\nTUniformMap* ConstructUniformMap()\n{\n    return new TUniformLinkedMap();\n}\n\nvoid DeleteUniformMap(TUniformMap* map)\n{\n    delete map;\n}\n\nTShHandleBase* ConstructBindings()\n{\n    return 0;\n}\n\nvoid DeleteBindingList(TShHandleBase* bindingList)\n{\n    delete bindingList;\n}\n#endif"
  },
  {
    "path": "src/Wrapper/Scrutinizer_GCN.cpp",
    "content": "#include \"AMDAsic_Impl.h\"\r\n#include \"AMDShader_Impl.h\"\r\n\r\n#include \"Scrutinizer_GCN.h\"\r\n#include \"Utilities.h\"\r\n\r\n#include \"D3DCompiler_Impl.h\"\r\n\r\n#pragma unmanaged\r\n#include \"GCNIsa.h\"\r\n#include \"GCNDecoder.h\"\r\n#include \"GCNDisassembler.h\"\r\n#include \"GCNBufferedPrinter.h\"\r\n#include \"GCNSimulator.h\"\r\n#include <vector>\r\n#include <unordered_map>\r\n#pragma managed\r\n\r\nusing namespace System;\r\nusing namespace System::Collections::Generic;\r\nusing namespace Pyramid::Scrutinizer;\r\n\r\n\r\nprivate ref class GCNInstruction : public IInstruction\r\n{\r\npublic:\r\n    GCNInstruction( const GCN::Instruction& inst )\r\n    {\r\n        m_pInstruction = new GCN::Instruction();\r\n        *m_pInstruction = inst;\r\n    }\r\n\r\n    virtual ~GCNInstruction() { \r\n        delete m_pInstruction; \r\n    }\r\n        \r\n    property BasicBlock^ Block\r\n    {\r\n        virtual BasicBlock^ get() { return m_pmBlock; } \r\n        virtual void set( BasicBlock^ bl ) { m_pmBlock = bl; }\r\n    }\r\n\r\n    property System::String^ Label\r\n    {\r\n        virtual System::String^ get() { return m_Label; }\r\n        virtual void set( System::String^ s ) { m_Label = s; }\r\n    }\r\n    property System::String^ SimNotes{\r\n        virtual System::String^ get() { return m_Notes; }\r\n        virtual void set( System::String^ s) { m_Notes = s; }\r\n    }\r\n\r\n    virtual System::String^ Disassemble()\r\n    {\r\n        GCN::Disassembler::BufferedPrinter printer;\r\n        GCN::Disassembler::Disassemble( printer, m_pInstruction, 0);\r\n        printer.m_Bytes.push_back(0);\r\n\r\n        System::String^ str = MakeString( printer.m_Bytes.data() );\r\n        return str->Replace( \"\\n\", System::Environment::NewLine );\r\n    }\r\n    virtual  System::String^ ToString() override\r\n    {\r\n        return Disassemble();\r\n    }\r\n    \r\n\r\ninternal:\r\n    GCN::Instruction* m_pInstruction;\r\n    BasicBlock^ m_pmBlock;\r\n    System::String^ m_Notes;\r\n    System::String^ m_Label;\r\n};\r\n\r\n    \r\nprivate ref class GCNJump : public GCNInstruction, public IJumpInstruction\r\n{\r\npublic:\r\n    GCNJump( const GCN::Instruction& inst ) : GCNInstruction(inst), m_Target(nullptr) {}\r\n        \r\n    property IInstruction^ Target{\r\n        virtual IInstruction^ get () { return m_Target; }\r\n    };\r\n\r\n    virtual System::String^ Disassemble() override\r\n    {\r\n        MarshalledString^ label = gcnew MarshalledString( m_Target->Label );\r\n\r\n        GCN::Disassembler::BufferedPrinter printer;\r\n        GCN::Disassembler::Disassemble( printer, m_pInstruction, label->GetString() );\r\n        printer.m_Bytes.push_back(0);\r\n\r\n        System::String^ str = MakeString( printer.m_Bytes.data() );\r\n        return str->Replace( \"\\n\", System::Environment::NewLine );\r\n    }\r\n\r\n \r\ninternal:\r\n    IInstruction^ m_Target;\r\n    \r\n};\r\n\r\nprivate ref class GCNBranch : public GCNInstruction, public IBranchInstruction\r\n{\r\npublic:\r\n    GCNBranch( const GCN::Instruction& inst ) : GCNInstruction(inst), m_IfTarget(nullptr), m_ElseTarget(nullptr){}\r\n        \r\n    property IInstruction^ IfTarget{\r\n        virtual IInstruction^ get () { return m_IfTarget; }\r\n    };\r\n        \r\n    property IInstruction^ ElseTarget{\r\n        virtual IInstruction^ get () { return m_ElseTarget; }\r\n    };\r\n\r\n    property BranchCategory Category{\r\n        virtual BranchCategory get() { return m_eCategory; }\r\n        virtual void set( BranchCategory e ) { m_eCategory = e; }\r\n    }\r\n\r\n    virtual System::String^ Disassemble() override\r\n    {\r\n        MarshalledString^ label = gcnew MarshalledString( m_IfTarget->Label );\r\n\r\n        GCN::Disassembler::BufferedPrinter printer;\r\n        GCN::Disassembler::Disassemble( printer, m_pInstruction, label->GetString() );\r\n        printer.m_Bytes.push_back(0);\r\n\r\n        System::String^ str = MakeString( printer.m_Bytes.data() );\r\n        return str->Replace( \"\\n\", System::Environment::NewLine );\r\n    }\r\n \r\ninternal:\r\n    IInstruction^ m_IfTarget;\r\n    IInstruction^ m_ElseTarget;\r\n    BranchCategory m_eCategory;\r\n\r\n};\r\n\r\nprivate ref class GCNSamplingOp : public GCNInstruction,  public ISamplingInstruction\r\n{\r\npublic:\r\n    GCNSamplingOp( const GCN::Instruction& inst ) : GCNInstruction(inst),\r\n        m_eFormat(TexelFormat::RGBA8),\r\n        m_eFilter(TextureFilter::TRILINEAR)\r\n    {\r\n    }\r\n\r\n    property TextureFilter Filter{\r\n        virtual TextureFilter get () { return m_eFilter; }\r\n        virtual void set( TextureFilter e ) { m_eFilter = e; }\r\n    };\r\n       \r\n    property TexelFormat Format{\r\n        virtual TexelFormat get () { return m_eFormat; }\r\n        virtual void set( TexelFormat e ) { m_eFormat = e; }\r\n    };\r\n        \r\ninternal:\r\n    TextureFilter m_eFilter;\r\n    TexelFormat m_eFormat;\r\n};\r\n\r\n\r\nprivate ref class GCNTBufferOp : public GCNInstruction, public ITextureInstruction\r\n{\r\npublic:\r\n    GCNTBufferOp( const GCN::Instruction& inst ) : GCNInstruction(inst), \r\n        m_eFormat(TexelFormat::RGBA32F)\r\n    {\r\n    }\r\n\r\n    property TexelFormat Format{\r\n        virtual TexelFormat get () { return m_eFormat; }\r\n        virtual void set( TexelFormat e ) { m_eFormat = e; }\r\n    };\r\n            \r\n\r\ninternal:\r\n    TexelFormat m_eFormat;\r\n    \r\n};\r\n\r\n   \r\n\r\n    \r\nList<IInstruction^>^ Scrutinizer_GCN_Base::BuildProgram(  )\r\n{\r\n    \r\n    MarshalledBlob^ bl = gcnew MarshalledBlob(m_pmShader->ReadISABytes());\r\n    unsigned char* pBytes = bl->GetBlob();\r\n    size_t nBytes = bl->GetLength();\r\n\r\n    GCN::IDecoder* pDecoder = m_pmAsic->m_pDecoder;\r\n\r\n        \r\n    //\r\n    // First pass:\r\n    //   1.  Validate\r\n    //   2.  Figure out how many instructions there are\r\n    //   3.  Identify branches and their targets\r\n    //\r\n    std::vector< const GCN::uint8* > Branches;\r\n    std::vector< const GCN::uint8* > Jumps;\r\n    std::unordered_map< const void*, size_t > IndexMap;\r\n     \r\n    List<IInstruction^>^ pmManagedInstructions = gcnew List<IInstruction^>();\r\n\r\n    size_t nOffs=0;\r\n    while( nOffs < nBytes )\r\n    {\r\n        unsigned char* pLocation = pBytes + nOffs;\r\n\r\n        // read instruction encoding\r\n        GCN::InstructionFormat eEncoding = pDecoder->ReadInstructionFormat( pBytes + nOffs );\r\n        if( eEncoding == GCN::IF_UNKNOWN )\r\n            throw gcnew System::Exception(\"Malformed GCN program\");\r\n            \r\n        // check instruction length\r\n        size_t nLength = pDecoder->DetermineInstructionLength(pLocation, eEncoding );\r\n        if( nLength == 0 || (nLength%4) != 0 )\r\n            throw gcnew System::Exception(\"Malformed GCN program\");\r\n            \r\n        // check for overrun of instruction buffer\r\n        nOffs += nLength;\r\n        if( nOffs > nBytes )\r\n            throw gcnew System::Exception(\"Malformed GCN program\");\r\n\r\n        // decode instruction and see if it's a scalar\r\n        GCN::Instruction inst;\r\n        pDecoder->Decode( &inst, pLocation, eEncoding);\r\n\r\n        if( inst.GetClass() == GCN::IC_SCALAR )\r\n        {\r\n            GCN::ScalarInstruction* pI = (GCN::ScalarInstruction*)&inst;\r\n            if( pI->GetBranchTarget() )\r\n            {\r\n                if( pI->IsConditionalJump() )\r\n                {\r\n                    Branches.push_back( pLocation );\r\n                    pmManagedInstructions->Add( gcnew GCNBranch(inst) );\r\n                }\r\n                else if( pI->IsUnconditionalJump() )\r\n                { \r\n                    Jumps.push_back( pLocation );\r\n                    pmManagedInstructions->Add( gcnew GCNJump(inst) );\r\n                }\r\n            }\r\n            else\r\n            {\r\n                pmManagedInstructions->Add( gcnew GCNInstruction(inst) );\r\n            }\r\n        }\r\n        else\r\n        {\r\n            switch( inst.GetClass() )\r\n            {\r\n            case GCN::IC_IMAGE:\r\n                {\r\n                    GCN::ImageInstruction* pInst = static_cast<GCN::ImageInstruction*>( &inst );\r\n                    if( pInst->IsFilteredFetch() )\r\n                        pmManagedInstructions->Add( gcnew GCNSamplingOp( *pInst ) );\r\n                    else if( pInst->IsUnfilteredLoadStore() )\r\n                        pmManagedInstructions->Add( gcnew GCNTBufferOp( *pInst ) );\r\n                    else\r\n                        pmManagedInstructions->Add( gcnew GCNInstruction( *pInst ) );\r\n                }\r\n                break;\r\n            case GCN::IC_BUFFER:\r\n                {\r\n                    GCN::BufferInstruction* pBuff = static_cast<GCN::BufferInstruction*>(&inst);\r\n                        \r\n                    // TBuffer means the instruction tells us the format\r\n                    // non-TBuffer means the descriptor tells us, and that is the one where\r\n                    // we need to create the special 'TexelLoad' subclass\r\n                    if( !pBuff->IsTBuffer() )\r\n                        pmManagedInstructions->Add( gcnew GCNTBufferOp( *pBuff ) );\r\n                    else\r\n                        pmManagedInstructions->Add( gcnew GCNInstruction( *pBuff ) );                        \r\n                }\r\n                break;\r\n            default:\r\n                pmManagedInstructions->Add( gcnew GCNInstruction(inst) );\r\n            }\r\n        }\r\n\r\n        IndexMap.insert( {pLocation, IndexMap.size()} );\r\n    }\r\n\r\n        \r\n    // Assign branch target instruction refs\r\n    for( size_t i=0; i<Branches.size(); i++ )\r\n    {\r\n        const unsigned char* pLocation = Branches[i];\r\n        GCN::InstructionFormat eEncoding = pDecoder->ReadInstructionFormat( pLocation );\r\n        size_t nLength = pDecoder->DetermineInstructionLength(pLocation, eEncoding );\r\n            \r\n        GCN::ScalarInstruction inst;\r\n        pDecoder->Decode( &inst, pLocation, eEncoding );\r\n\r\n        IInstruction^ ifTarget   = pmManagedInstructions[ IndexMap[inst.GetBranchTarget()] ];\r\n        IInstruction^ elseTarget = pmManagedInstructions[ IndexMap[pLocation+nLength] ];\r\n        GCNBranch^ branch = dynamic_cast<GCNBranch^>( pmManagedInstructions[ IndexMap[pLocation] ] );\r\n        branch->m_IfTarget = ifTarget;\r\n        branch->m_ElseTarget = elseTarget;\r\n    }\r\n\r\n    // assign jump instruction refs\r\n    for( size_t i=0; i<Jumps.size(); i++ )\r\n    {\r\n        const unsigned char* pLocation = Jumps[i];\r\n        GCN::InstructionFormat eEncoding = pDecoder->ReadInstructionFormat( pLocation );\r\n        size_t nLength = pDecoder->DetermineInstructionLength(pLocation, eEncoding );\r\n            \r\n        GCN::ScalarInstruction inst;\r\n        pDecoder->Decode( &inst, pLocation, eEncoding );\r\n\r\n        IInstruction^ target   = pmManagedInstructions[ IndexMap[inst.GetBranchTarget()] ];\r\n        GCNJump^ jump = dynamic_cast<GCNJump^>( pmManagedInstructions[ IndexMap[pLocation] ] );\r\n        jump->m_Target = target;\r\n    }\r\n\r\n    return pmManagedInstructions;\r\n}\r\n\r\nList<IInstruction^>^ Scrutinizer_GCN_Base::BuildDXFetchShader( Pyramid::IDXShaderReflection^ refl )\r\n{\r\n    DXShaderReflection_Impl^ reflImpl = dynamic_cast<DXShaderReflection_Impl^>(refl);\r\n    ID3D11ShaderReflection* pRefl = reflImpl->m_pRef;\r\n\r\n    List<IInstruction^>^ ops = gcnew List<IInstruction^>();\r\n\r\n    if( refl->GetShaderType() != Pyramid::HLSLShaderType::VERTEX )\r\n        return ops;\r\n\r\n    D3D11_SHADER_DESC sd;\r\n    pRefl->GetDesc(&sd);\r\n    \r\n    if( !sd.InputParameters )\r\n        return ops;\r\n\r\n    // first 'swappc' instruction that called the fetch shader\r\n    //   The second one, which returns, is the one that's at the beginning of the VS\r\n    GCN::ScalarInstruction swap;\r\n    swap.EncodeSwapPC();\r\n    ops->Add( gcnew GCNInstruction(swap));\r\n\r\n\r\n    for( size_t i=0; i<sd.InputParameters; i++ )\r\n    {\r\n        D3D11_SIGNATURE_PARAMETER_DESC param;\r\n        pRefl->GetInputParameterDesc(i,&param);\r\n       \r\n        // count how many elements we need to fetch\r\n        UINT nComps=0;\r\n        while( param.Mask )\r\n        {\r\n            nComps++;\r\n            param.Mask = param.Mask>>1;\r\n        }\r\n\r\n        if( !nComps )\r\n            continue; // strange...\r\n\r\n        GCN::BufferInstruction inst;\r\n        switch( nComps )\r\n        {\r\n        case 1: inst.SetOpcode( GCN::BUFFER_LOAD_FORMAT_X );    break;\r\n        case 2: inst.SetOpcode( GCN::BUFFER_LOAD_FORMAT_XY );   break;\r\n        case 3: inst.SetOpcode( GCN::BUFFER_LOAD_FORMAT_XYZ );  break;\r\n        case 4: inst.SetOpcode( GCN::BUFFER_LOAD_FORMAT_XYZW ); break;\r\n        }\r\n\r\n        GCNTBufferOp^ op = gcnew GCNTBufferOp( inst );\r\n        ops->Add(op);\r\n    }\r\n    \r\n    // do a wait if we fetched anything\r\n    GCN::ScalarInstruction wait;\r\n    wait.EncodeWait(0,31,7);\r\n    ops->Add( gcnew GCNInstruction(wait));\r\n    \r\n\r\n    return ops;\r\n}\r\n\r\n\r\n\r\nSystem::String^ Scrutinizer_GCN_Base::AnalyzeTrace( List<IInstruction^>^ ops, unsigned int nWaveIssueRate, \r\n                                                   unsigned int nWaveOccupancy, \r\n                                                   unsigned int nGroupOccupancy,\r\n                                                   unsigned int nCUs,\r\n                                                   unsigned int nWavesPerGroup )\r\n{\r\n    std::vector<GCN::Simulator::SimOp> pSimOps(ops->Count);\r\n\r\n    for( size_t i=0; i<ops->Count; i++ )\r\n    {\r\n        GCNInstruction^ gcnOp = safe_cast<GCNInstruction^>( ops[i] );\r\n        pSimOps[i].pInstruction = gcnOp->m_pInstruction;\r\n        pSimOps[i].eFilter = GCN::Simulator::FILT_POINT;\r\n        pSimOps[i].eFormat = GCN::Simulator::FMT_RGBA8;\r\n        \r\n        GCNSamplingOp^ sampling = dynamic_cast<GCNSamplingOp^>( ops[i] );\r\n        if( sampling != nullptr )\r\n        {\r\n           \r\n           // map Scrutinizer's enums onto the unmanaged simulator ones\r\n            switch( sampling->m_eFilter )\r\n            {\r\n            case TextureFilter::POINT:      pSimOps[i].eFilter = GCN::Simulator::FILT_POINT;      break;\r\n            case TextureFilter::BILINEAR:   pSimOps[i].eFilter = GCN::Simulator::FILT_BILINEAR;   break;\r\n            case TextureFilter::TRILINEAR:  pSimOps[i].eFilter = GCN::Simulator::FILT_TRILINEAR;  break;\r\n            case TextureFilter::ANISO_2X:   pSimOps[i].eFilter = GCN::Simulator::FILT_ANISO_2X;   break;\r\n            case TextureFilter::ANISO_4X:   pSimOps[i].eFilter = GCN::Simulator::FILT_ANISO_4X;   break;\r\n            case TextureFilter::ANISO_8X:   pSimOps[i].eFilter = GCN::Simulator::FILT_ANISO_8X;   break;\r\n            }\r\n\r\n            switch( sampling->m_eFormat )\r\n            {\r\n            case TexelFormat::R8     :  pSimOps[i].eFormat = GCN::Simulator::FMT_R8       ; break;\r\n            case TexelFormat::RG8    :  pSimOps[i].eFormat = GCN::Simulator::FMT_RG8      ; break;\r\n            case TexelFormat::RGBA8  :  pSimOps[i].eFormat = GCN::Simulator::FMT_RGBA8    ; break;\r\n            case TexelFormat::R16    :  pSimOps[i].eFormat = GCN::Simulator::FMT_R16      ; break;\r\n            case TexelFormat::RG16   :  pSimOps[i].eFormat = GCN::Simulator::FMT_RG16     ; break;\r\n            case TexelFormat::RGBA16 :  pSimOps[i].eFormat = GCN::Simulator::FMT_RGBA16   ; break;\r\n            case TexelFormat::R16F   :  pSimOps[i].eFormat = GCN::Simulator::FMT_R16F     ; break;\r\n            case TexelFormat::RG16F  :  pSimOps[i].eFormat = GCN::Simulator::FMT_RG16F    ; break;\r\n            case TexelFormat::RGBA16F:  pSimOps[i].eFormat = GCN::Simulator::FMT_RGBA16F  ; break;\r\n            case TexelFormat::R32F   :  pSimOps[i].eFormat = GCN::Simulator::FMT_R32F     ; break;\r\n            case TexelFormat::RG32F  :  pSimOps[i].eFormat = GCN::Simulator::FMT_RG32F    ; break;\r\n            case TexelFormat::RGBA32F:  pSimOps[i].eFormat = GCN::Simulator::FMT_RGBA32F  ; break;\r\n            case TexelFormat::BC1    :  pSimOps[i].eFormat = GCN::Simulator::FMT_BC1      ; break;\r\n            case TexelFormat::BC2    :  pSimOps[i].eFormat = GCN::Simulator::FMT_BC2      ; break;\r\n            case TexelFormat::BC3    :  pSimOps[i].eFormat = GCN::Simulator::FMT_BC3      ; break;\r\n            case TexelFormat::BC4    :  pSimOps[i].eFormat = GCN::Simulator::FMT_BC4      ; break;\r\n            case TexelFormat::BC5    :  pSimOps[i].eFormat = GCN::Simulator::FMT_BC5      ; break;\r\n            case TexelFormat::BC6    :  pSimOps[i].eFormat = GCN::Simulator::FMT_BC6      ; break;\r\n            case TexelFormat::BC7    :  pSimOps[i].eFormat = GCN::Simulator::FMT_BC7      ; break;\r\n            }\r\n        }\r\n    }\r\n\r\n    // assign an index to each distinct instruction in the trace\r\n    Dictionary<IInstruction^,size_t>^ pInstructionIDs = gcnew Dictionary<IInstruction^,size_t>();\r\n    List<IInstruction^>^ pDistinctInstructions = gcnew List<IInstruction^>();\r\n    for( size_t i=0; i<ops->Count; i++ )\r\n    {\r\n        if( !pInstructionIDs->ContainsKey( ops[i] ) )\r\n        {\r\n            pInstructionIDs->Add( ops[i], pDistinctInstructions->Count );\r\n            pDistinctInstructions->Add( ops[i] );\r\n        }\r\n\r\n        pSimOps[i].nInstructionID = pInstructionIDs[ops[i]];\r\n    }\r\n\r\n    // allocate and initialize per-instruction stall counters\r\n    std::vector<size_t> pInstructionStalls( pDistinctInstructions->Count, 0 );\r\n    std::vector<size_t> pSimOpStalls(ops->Count, 0 );\r\n\r\n    // setup the sim\r\n    GCN::Simulator::Settings settings;\r\n    settings.nExportCost          = nCUs*4;               \r\n    settings.nGroupIssueRate      = nWaveIssueRate;   \r\n    settings.nGroupsToExecute     = 500;\r\n    settings.nWavesPerThreadGroup = nWavesPerGroup;\r\n    settings.nMaxWavesPerSIMD     = nWaveOccupancy;\r\n    settings.nMaxGroupsPerCU      = nGroupOccupancy;\r\n\r\n    GCN::Simulator::Results results;\r\n    memset(&results,0,sizeof(results));\r\n    results.pInstructionStallCounts = pInstructionStalls.data();\r\n    results.pSimOpStallCounts = pSimOpStalls.data();\r\n\r\n    GCN::Simulator::Simulate( results, settings, pSimOps.data(), pSimOps.size() );\r\n\r\n    float fClocks = results.nCycles;\r\n    float fStallClocks = results.nStallCycles[0]+results.nStallCycles[1]+results.nStallCycles[2]+results.nStallCycles[3];\r\n\r\n    double fUnstarvedClocks = results.nCycles-results.nStarveCycles;\r\n    float fStallRate = fStallClocks/(fUnstarvedClocks);\r\n    float fVALUUtil =\r\n        (results.nVALUBusy[0]+results.nVALUBusy[1]+results.nVALUBusy[2]+results.nVALUBusy[3])/(4*fClocks);\r\n\r\n    float fVMemUtil   = (results.nVMemBusy)/fClocks;\r\n    float fExpUtil    = (results.nExpBusy) / fClocks;\r\n    float fScalarUtil = (results.nSALUBusy)/fClocks;\r\n    float fSMemUtil   = (results.nSMemBusy)/fClocks; \r\n    float fLDSUtil    = (results.nLDSBusy)/(2*fClocks);\r\n    float fStarveRate = results.nStarveCycles / fClocks;\r\n\r\n    double fWaveTime = fUnstarvedClocks / settings.nGroupsToExecute;\r\n \r\n    double fThroughput =  ((settings.nGroupsToExecute*64.0)/(fClocks))*1000000000.0;\r\n   \r\n\r\n    // annotate instructions with stall counts\r\n    for( size_t i=0; i<pInstructionStalls.size(); i++ )\r\n    {\r\n        if( pInstructionStalls[i] )\r\n        {\r\n            char buffer[64];\r\n            size_t nOpStalls = pInstructionStalls[i];\r\n            sprintf( buffer, \"Stalled here %.2f%%\", (100.0f*nOpStalls)/fUnstarvedClocks);\r\n            System::String^ notes = gcnew System::String( buffer );     \r\n\r\n            pDistinctInstructions[i]->SimNotes = notes;\r\n        }\r\n    }\r\n\r\n    double fIPC = (results.nSALUIssued + \r\n                   results.nSMEMIssued + \r\n                   results.nVALUIssued + \r\n                   results.nLDSIssued +\r\n                   results.nExpIssued +\r\n                   results.nVMemIssued) / fClocks;\r\n \r\n    char buffer[4096];\r\n    sprintf( buffer,\r\n            \"Clocks:  (%.2f clocks/wave)\\n\"\r\n            \"Throughput: (%.2f Mthreads/GHz/CU)\\n\"\r\n            \"VALU util:      %.2f%%\\n\"\r\n            \"VMem util:      %.2f%%\\n\"\r\n            \"Exp  util:      %.2f%%\\n\"\r\n            \"SALU util:      %.2f%%\\n\"\r\n            \"SMem util:      %.2f%%\\n\"\r\n            \"LDS  util:      %.2f%%\\n\"\r\n            \"Stall rate:     %.2f%%\\n\"\r\n            \"Starve rate:    %.2f%%\\n\"\r\n            \"Inst/Clk:       %.2f\\n\"\r\n            \"Peak Waves:     %u/%u\\n\"\r\n            \"Peak Groups:    %u/%u\\n\",\r\n            fWaveTime,\r\n            fThroughput / 1000000.0,\r\n            100.0f*fVALUUtil,\r\n            100.0f*fVMemUtil,\r\n            100.0f*fExpUtil,\r\n            100.0f*fScalarUtil,\r\n            100.0f*fSMemUtil,\r\n            100.0f*fLDSUtil,\r\n            100.0f*fStallRate,\r\n            100.0f*fStarveRate,\r\n            fIPC,\r\n            results.nPeakWaveOccupancy ,\r\n            settings.nMaxWavesPerSIMD*4 ,\r\n            results.nPeakGroupOccupancy,\r\n            settings.nMaxGroupsPerCU\r\n        );\r\n\r\n    System::String^ str = gcnew System::String(buffer);\r\n    return str->Replace(\"\\n\", System::Environment::NewLine );\r\n}\r\n\r\n\r\nScrutinizer_GCN_VS::Scrutinizer_GCN_VS( AMDAsic_Impl^ asic, AMDShader_Impl^ shader )\r\n    :Scrutinizer_GCN_Base(asic,shader)\r\n{\r\n    m_pmOccupancy = gcnew SimulationParameterInt(1,10,shader->GetWaveOccupancy(),\"Occupancy (Waves/SIMD)\");\r\n    m_pmCUCount   = gcnew SimulationParameterInt(1,10000,10,\"CU Count\");\r\n    m_pmACMR      = gcnew SimulationParameterDouble( 0.5,3.0, 0.7, \"Verts/Tri\");\r\n    m_pmParams->Add(m_pmOccupancy);\r\n    m_pmParams->Add(m_pmCUCount);\r\n    m_pmParams->Add(m_pmACMR);\r\n}\r\n\r\nSystem::String^ Scrutinizer_GCN_VS::AnalyzeExecutionTrace( List<IInstruction^>^ ops )\r\n{\r\n    unsigned int nCUs       = (unsigned int) m_pmCUCount->Value;\r\n    unsigned int nOccupancy = (unsigned int) m_pmOccupancy->Value;\r\n\r\n    // one VS wave every M clocks\r\n    //   round-robined amongst CUs\r\n    //\r\n    //      http://www.icodebot.com/Playstation%204%20GPU\r\n    //  States that VGT can handle 1 new vert/clk, and tests 3 indices/clk for reuse\r\n    //\r\n    //   If A = cache hit rate (verts/tri)\r\n    //    then we need on average 64/A triangles to produce a full wave\r\n    //    \r\n    //  It will take min(64, 64/A) clocks to gather that many \r\n    //\r\n    double fVertsPerTri   = m_pmACMR->Value;\r\n    double fTrisPerWave   = 64.0 / fVertsPerTri;\r\n    double fClocksPerWave = ( fTrisPerWave>64.0f) ? 64.0 : fTrisPerWave;\r\n    unsigned int nWaveIssueRate        = (unsigned int) (nCUs*fClocksPerWave);\r\n\r\n    return AnalyzeTrace(ops,nWaveIssueRate,nOccupancy,40,nCUs,1);\r\n}\r\n\r\n\r\nScrutinizer_GCN_PS::Scrutinizer_GCN_PS( AMDAsic_Impl^ asic, AMDShader_Impl^ shader )\r\n    :Scrutinizer_GCN_Base(asic,shader)\r\n{\r\n    m_pmOccupancy        = gcnew SimulationParameterInt(1,10,shader->GetWaveOccupancy(),\"Occupancy (Waves/SIMD)\");\r\n    m_pmCUCount          = gcnew SimulationParameterInt(1,10000,10,\"CU Count\");\r\n    m_pmPixelsPerTri     = gcnew SimulationParameterDouble( 0, 10000, 16, \"Pixels/Tri\");\r\n    m_pmParams->Add(m_pmOccupancy);\r\n    m_pmParams->Add(m_pmCUCount);\r\n    m_pmParams->Add(m_pmPixelsPerTri);\r\n}\r\n\r\nSystem::String^ Scrutinizer_GCN_PS::AnalyzeExecutionTrace(List<IInstruction^>^ ops)\r\n{\r\n    unsigned int nCUs       = (unsigned int) m_pmCUCount->Value;\r\n    unsigned int nOccupancy = (unsigned int) m_pmOccupancy->Value;\r\n\r\n    // Assume 16 pix/clk raster rate (4 quads/clk)\r\n    //    Assuming we can repack quads from multiple tris into a wave,\r\n    //     we end up with \r\n\r\n    double fQuadsPerTri   = m_pmPixelsPerTri->Value/4.0;\r\n    double fQuadsPerClock = Math::Min( 4.0, Math::Ceiling(fQuadsPerTri) );\r\n    fQuadsPerClock        = Math::Max(1.0,fQuadsPerClock);\r\n    double fClocksPerWave = Math::Ceiling( 16.0 / fQuadsPerClock );\r\n    unsigned int nWaveIssueRate = (unsigned int) (nCUs*fClocksPerWave);\r\n           \r\n    return AnalyzeTrace(ops,nWaveIssueRate,nOccupancy,40,nCUs,1);\r\n}\r\n\r\n  \r\nScrutinizer_GCN_CS::Scrutinizer_GCN_CS( AMDAsic_Impl^ asic, AMDShader_Impl^ shader )\r\n    :Scrutinizer_GCN_Base(asic,shader)\r\n{\r\n    m_nWavesPerGroup             = (shader->GetThreadsPerThreadGroup()+63)/64;\r\n    size_t nMinimumWaveOccupancy = (m_nWavesPerGroup+3)/4;\r\n    size_t nGroup = 40/m_nWavesPerGroup;\r\n    size_t nMaxGroups = shader->GetGroupOccupancy();\r\n\r\n    m_pmWaveOccupancy     = gcnew SimulationParameterInt(nMinimumWaveOccupancy,10,shader->GetWaveOccupancy(),\"Waves/SIMD\");\r\n    m_pmGroupOccupancy    = gcnew SimulationParameterInt(1,nMaxGroups,nMaxGroups,\"Groups/CU\");\r\n    m_pmCUCount           = gcnew SimulationParameterInt(1,10000,10,\"CU Count\");\r\n    m_pmParams->Add(m_pmWaveOccupancy);\r\n    m_pmParams->Add(m_pmCUCount);\r\n    m_pmParams->Add(m_pmGroupOccupancy);\r\n}\r\n\r\nSystem::String^ Scrutinizer_GCN_CS::AnalyzeExecutionTrace(List<IInstruction^>^ ops)\r\n{\r\n    unsigned int nCUs       = (unsigned int) m_pmCUCount->Value;\r\n    unsigned int nWaveOccupancy = (unsigned int) m_pmWaveOccupancy->Value;\r\n    unsigned int nGroupOccupancy = (unsigned int) m_pmGroupOccupancy->Value;\r\n\r\n    // GCN ACE can create a workgroup OR dispatch a wave every cycle\r\n    //  Time needed to dispatch a group of N waves is N+1 clocks\r\n    // Assume that our wave load is round-robined across CUs\r\n\r\n    unsigned int nGroupIssueRate = (m_nWavesPerGroup+1)*nCUs;\r\n\r\n    return AnalyzeTrace(ops,nGroupIssueRate,nWaveOccupancy,nGroupOccupancy,nCUs, m_nWavesPerGroup);\r\n}\r\n\r\n  "
  },
  {
    "path": "src/Wrapper/Scrutinizer_GCN.h",
    "content": "\nusing namespace System::Collections::Generic;\nusing namespace Pyramid::Scrutinizer;\n\nref class AMDAsic_Impl;\nref class AMDShader_Impl;\n\nref class Scrutinizer_GCN_Base abstract : public Pyramid::Scrutinizer::IScrutinizer\n{\npublic:\n\n    Scrutinizer_GCN_Base( AMDAsic_Impl^ asic, AMDShader_Impl^ shader )\n        : m_pmAsic(asic), m_pmShader(shader),\n          m_pmParams(gcnew List<ISimulationParameter^>())\n         \n    {\n    }\n \n    virtual List<IInstruction^>^ BuildProgram( );\n\n    virtual List<IInstruction^>^ BuildDXFetchShader( Pyramid::IDXShaderReflection^ refl );\n\n    property IEnumerable<ISimulationParameter^>^ SimulationParameters\n    {\n        virtual IEnumerable<ISimulationParameter^>^ get()\n        {\n            return m_pmParams;\n        }\n    }\n\n    virtual System::String^ AnalyzeExecutionTrace( List<IInstruction^>^ ops ) = 0;\n\n\nprotected:\n\n    System::String^ AnalyzeTrace( List<IInstruction^>^ ops, \n                                  unsigned int nWaveIssueRate, \n                                  unsigned int nWaveOccupancy,\n                                  unsigned int nGroupOccupancy,\n                                  unsigned int nCUCount,\n                                  unsigned int nWavesPerGroup );\n\n    AMDAsic_Impl^ m_pmAsic;\n    AMDShader_Impl^ m_pmShader;\n    List<ISimulationParameter^>^ m_pmParams;\n};\n\n\nref class Scrutinizer_GCN_VS : public Scrutinizer_GCN_Base\n{\npublic:\n     \n    Scrutinizer_GCN_VS( AMDAsic_Impl^ asic, AMDShader_Impl^ shader );\n  \n    virtual System::String^ AnalyzeExecutionTrace( List<IInstruction^>^ ops ) override;\n\n\nprivate:\n\n    SimulationParameterInt^ m_pmOccupancy;\n    SimulationParameterInt^ m_pmCUCount;\n    SimulationParameterDouble^ m_pmACMR;\n\n};\n\n\nref class Scrutinizer_GCN_PS : public Scrutinizer_GCN_Base\n{\npublic:\n\n    Scrutinizer_GCN_PS( AMDAsic_Impl^ asic, AMDShader_Impl^ shader );\n\n    virtual System::String^ AnalyzeExecutionTrace( List<IInstruction^>^ ops ) override;\n\nprivate:\n    \n    SimulationParameterInt^ m_pmOccupancy;\n    SimulationParameterInt^ m_pmCUCount;\n    SimulationParameterDouble^ m_pmPixelsPerTri;\n\n};\n\nref class Scrutinizer_GCN_CS : public Scrutinizer_GCN_Base\n{\npublic:\n\n    Scrutinizer_GCN_CS( AMDAsic_Impl^ asic, AMDShader_Impl^ shader );\n\n    virtual System::String^ AnalyzeExecutionTrace( List<IInstruction^>^ ops ) override;\n\nprivate:\n    \n    SimulationParameterInt^ m_pmWaveOccupancy;\n    SimulationParameterInt^ m_pmGroupOccupancy;\n    SimulationParameterInt^ m_pmCUCount;\n    unsigned int m_nWavesPerGroup;\n};"
  },
  {
    "path": "src/Wrapper/Utilities.h",
    "content": "\n#ifndef _UTILITIES_H_\n#define _UTILITIES_H_\n\n#include <vcclr.h>\n\n#pragma unmanaged\n#include <string.h>\n#include <malloc.h>\n#pragma managed\n\ntypedef unsigned int UINT;\n\nusing System::Runtime::InteropServices::Marshal;\n\nprivate ref class MarshalledString\n{\npublic:\n    MarshalledString( System::String^ str )\n        : m_Ptr( Marshal::StringToHGlobalAnsi(str) )\n    {\n    }\n\n    ~MarshalledString()\n    {\n        Marshal::FreeHGlobal(m_Ptr);\n    }\n\n    operator char* () { return GetString(); }\n\n    char* GetString() { return (char*)m_Ptr.ToPointer(); }\n    size_t Length()  { return strlen( GetString() ); }\nprivate:\n    System::IntPtr m_Ptr;\n};\n\nprivate ref class MarshalledStringW\n{\npublic:\n    MarshalledStringW( System::String^ str )\n        : m_Ptr( Marshal::StringToHGlobalUni( str ) )\n    {\n    }\n\n    ~MarshalledStringW()\n    {\n        Marshal::FreeHGlobal( m_Ptr );\n    }\n\n    operator wchar_t* () { return GetString(); }\n\n    wchar_t* GetString() { return (wchar_t*)m_Ptr.ToPointer(); }\n    size_t Length() { return wcslen( GetString() ); }\nprivate:\n    System::IntPtr m_Ptr;\n};\n\n\nprivate ref class MarshalledBlob\n{\npublic: \n    MarshalledBlob( array<unsigned char>^ blob ) : m_nLength(0), m_pBlob(0)\n    {\n        if( blob != nullptr && blob->Length > 0 )\n        {\n            void* pBlob = malloc(blob->Length);\n            if( !pBlob )\n                throw gcnew System::OutOfMemoryException();\n            Marshal::Copy( blob, 0, System::IntPtr(pBlob), blob->Length);\n            m_nLength = blob->Length;\n            m_pBlob   = (unsigned char*) pBlob;            \n        }\n    }\n\n    ~MarshalledBlob()\n    {\n        free(m_pBlob);\n    }\n\n    operator unsigned char*() { return GetBlob(); }\n    unsigned char* GetBlob() { return m_pBlob; }\n    size_t GetLength() { return m_nLength; }\nprivate:\n    size_t m_nLength;\n    unsigned char* m_pBlob;\n};\n\ninline System::String^ MakeString( const char* p ) { return Marshal::PtrToStringAnsi(System::IntPtr((char*)p));}\ninline System::String^ MakeString( const wchar_t* p ) { return Marshal::PtrToStringUni( System::IntPtr( (wchar_t*)p ) ); }\n\n#endif"
  },
  {
    "path": "src/Wrapper/Wrapper.cpp",
    "content": "\n#pragma unmanaged\n#include <d3dcompiler.h>\n#include <string.h>\n#pragma managed\n\n#include \"D3DCompiler_Impl.h\"\n#include \"DXILCompiler_Impl.h\"\n#include \"GLSLOpt_Impl.h\"\n#include \"GLSlang_Impl.h\"\n#include \"AMDDriver_Impl.h\"\n#include \"Utilities.h\"\n\nnamespace Pyramid\n{\n\n    public ref class Wrapper : Pyramid::IWrapper\n    {\n    public:\n        Wrapper() {};\n        virtual Pyramid::ID3DCompiler^ CreateD3DCompiler( System::String^ DLLPath, IIncludeHandler^ handler )\n        {\n            return gcnew D3DCompiler_Impl(DLLPath,handler);\n        }\n\n        virtual Pyramid::IDXILCompiler^ CreateDXILCompiler( System::String^ DLLPath,IIncludeHandler^ handler )\n        {\n            return gcnew DXILCompiler_Impl( DLLPath,handler );\n        }\n       \n        virtual Pyramid::GLSLOptimizer::IOptimizer^ CreateGLSLOptimizer( GLSLOptimizer::Target eTarget )\n        {\n            return gcnew GLSLOptimizer::Optimizer_Impl(eTarget);\n        }\n\n        virtual Pyramid::GLSlang::ICompiler^ CreateGLSlangCompiler( IIncludeHandler^ handler )\n        {\n            return gcnew GLSlang::Compiler_Impl(handler);\n        }\n\n        virtual Pyramid::IAMDDriver^ CreateAMDDriver( System::String^ DLLPath)\n        {\n            return gcnew AMDDriver_Impl(DLLPath);\n        }\n\n        \n    };\n\n\n}"
  },
  {
    "path": "src/Wrapper/Wrapper.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project DefaultTargets=\"Build\" ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup Label=\"ProjectConfigurations\">\n    <ProjectConfiguration Include=\"Debug|Win32\">\n      <Configuration>Debug</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|Win32\">\n      <Configuration>Release</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n  </ItemGroup>\n  <PropertyGroup Label=\"Globals\">\n    <ProjectGuid>{AECCEE3C-29C5-46DE-9AE2-AFB5DF6D110A}</ProjectGuid>\n    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>\n    <Keyword>ManagedCProj</Keyword>\n    <RootNamespace>Wrapper</RootNamespace>\n    <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <UseDebugLibraries>true</UseDebugLibraries>\n    <PlatformToolset>v141</PlatformToolset>\n    <CLRSupport>true</CLRSupport>\n    <CharacterSet>Unicode</CharacterSet>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <UseDebugLibraries>false</UseDebugLibraries>\n    <PlatformToolset>v141</PlatformToolset>\n    <CLRSupport>true</CLRSupport>\n    <CharacterSet>NotSet</CharacterSet>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n  <ImportGroup Label=\"ExtensionSettings\">\n  </ImportGroup>\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <PropertyGroup Label=\"UserMacros\" />\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\n    <LinkIncremental>true</LinkIncremental>\n    <OutDir>$(SolutionDir)\\bin\\$(Configuration)\\</OutDir>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\n    <LinkIncremental>false</LinkIncremental>\n    <OutDir>$(SolutionDir)\\bin\\$(Configuration)\\</OutDir>\n  </PropertyGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\n    <ClCompile>\n      <WarningLevel>Level3</WarningLevel>\n      <Optimization>Disabled</Optimization>\n      <PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\n      <AdditionalIncludeDirectories>.\\amd-codexl-analyzer\\Common\\Src\\DeviceInfo;.\\amd-codexl-analyzer\\CommonProjects\\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n    </ClCompile>\n    <Link>\n      <GenerateDebugInformation>true</GenerateDebugInformation>\n      <AdditionalDependencies>psapi.lib;%(AdditionalDependencies)</AdditionalDependencies>\n      <AdditionalLibraryDirectories>GLSlang\\lib\\2013\\x86\\Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\n    </Link>\n    <ProjectReference>\n      <UseLibraryDependencyInputs>true</UseLibraryDependencyInputs>\n    </ProjectReference>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\n    <ClCompile>\n      <WarningLevel>Level3</WarningLevel>\n      <PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <AdditionalIncludeDirectories>.\\amd-codexl-analyzer\\Common\\Src\\DeviceInfo;.\\amd-codexl-analyzer\\CommonProjects\\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n    </ClCompile>\n    <Link>\n      <GenerateDebugInformation>true</GenerateDebugInformation>\n      <AdditionalDependencies>psapi.lib;%(AdditionalDependencies)</AdditionalDependencies>\n      <AdditionalLibraryDirectories>GLSlang\\lib\\2013\\x86\\Release</AdditionalLibraryDirectories>\n    </Link>\n    <PostBuildEvent>\n      <Command>copy $(TargetPath) $(SolutionDir)\\..\\bin</Command>\n    </PostBuildEvent>\n  </ItemDefinitionGroup>\n  <ItemGroup>\n    <ClCompile Include=\"amd-codexl-analyzer\\Common\\Src\\DeviceInfo\\DeviceInfoUtils.cpp\" />\n    <ClCompile Include=\"AMDAsic_Impl.cpp\" />\n    <ClCompile Include=\"AMDDriver_Impl.cpp\" />\n    <ClCompile Include=\"AMDShader_Impl.cpp\" />\n    <ClCompile Include=\"D3DCompiler_Impl.cpp\" />\n    <ClCompile Include=\"DXILCompiler_Impl.cpp\" />\n    <ClCompile Include=\"GCN1Decoder.cpp\" />\n    <ClCompile Include=\"GCNDecoder.cpp\" />\n    <ClCompile Include=\"GCNDisassembler.cpp\">\n      <PreprocessToFile Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">false</PreprocessToFile>\n    </ClCompile>\n    <ClCompile Include=\"GCNEnums.cpp\" />\n    <ClCompile Include=\"GCNIsa.cpp\" />\n    <ClCompile Include=\"GCNSimulator.cpp\" />\n    <ClCompile Include=\"GLSlang_Impl.cpp\" />\n    <ClCompile Include=\"GLSlang_Stubs.cpp\" />\n    <ClCompile Include=\"GLSLOpt_Impl.cpp\" />\n    <ClCompile Include=\"GCN3Decoder.cpp\" />\n    <ClCompile Include=\"Scrutinizer_GCN.cpp\" />\n    <ClCompile Include=\"Wrapper.cpp\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"amd-codexl-analyzer\\CommonProjects\\AMDTBackend\\Include\\Common\\AmdDxGsaCompile.h\" />\n    <ClInclude Include=\"amd-codexl-analyzer\\CommonProjects\\AMDTBackend\\Include\\Common\\asic_reg\\atiid.h\" />\n    <ClInclude Include=\"amd-codexl-analyzer\\CommonProjects\\AMDTBackend\\Include\\Common\\asic_reg\\ci_id.h\" />\n    <ClInclude Include=\"amd-codexl-analyzer\\CommonProjects\\AMDTBackend\\Include\\Common\\asic_reg\\cz_id.h\" />\n    <ClInclude Include=\"amd-codexl-analyzer\\CommonProjects\\AMDTBackend\\Include\\Common\\asic_reg\\evergreen_id.h\" />\n    <ClInclude Include=\"amd-codexl-analyzer\\CommonProjects\\AMDTBackend\\Include\\Common\\asic_reg\\kv_id.h\" />\n    <ClInclude Include=\"amd-codexl-analyzer\\CommonProjects\\AMDTBackend\\Include\\Common\\asic_reg\\northernisland_id.h\" />\n    <ClInclude Include=\"amd-codexl-analyzer\\CommonProjects\\AMDTBackend\\Include\\Common\\asic_reg\\si_id.h\" />\n    <ClInclude Include=\"amd-codexl-analyzer\\CommonProjects\\AMDTBackend\\Include\\Common\\asic_reg\\sumo_id.h\" />\n    <ClInclude Include=\"amd-codexl-analyzer\\CommonProjects\\AMDTBackend\\Include\\Common\\asic_reg\\tn_id.h\" />\n    <ClInclude Include=\"amd-codexl-analyzer\\CommonProjects\\AMDTBackend\\Include\\Common\\asic_reg\\vi_id.h\" />\n    <ClInclude Include=\"amd-codexl-analyzer\\Common\\Src\\DeviceInfo\\DeviceInfo.h\" />\n    <ClInclude Include=\"amd-codexl-analyzer\\Common\\Src\\DeviceInfo\\DeviceInfoUtils.h\" />\n    <ClInclude Include=\"AMDAsic_Impl.h\" />\n    <ClInclude Include=\"AMDDriver_Impl.h\" />\n    <ClInclude Include=\"AMDShader_Impl.h\" />\n    <ClInclude Include=\"D3DCompiler_Impl.h\" />\n    <ClInclude Include=\"DXILCompiler_Impl.h\" />\n    <ClInclude Include=\"GCN1Decoder.h\" />\n    <ClInclude Include=\"GCN3Decoder.h\" />\n    <ClInclude Include=\"GCNBufferedPrinter.h\" />\n    <ClInclude Include=\"GCNDecoder.h\" />\n    <ClInclude Include=\"GCNDisassembler.h\" />\n    <ClInclude Include=\"GCNEnums.h\" />\n    <ClInclude Include=\"GCNIsa.h\" />\n    <ClInclude Include=\"GCNSimulator.h\" />\n    <ClInclude Include=\"GLSlang_Impl.h\" />\n    <ClInclude Include=\"GLSLOpt_Impl.h\" />\n    <ClInclude Include=\"Scrutinizer_GCN.h\" />\n    <ClInclude Include=\"Utilities.h\" />\n  </ItemGroup>\n  <ItemGroup>\n    <Reference Include=\"System\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ProjectReference Include=\"..\\PyramidTypes.csproj\">\n      <Project>{3d7db344-0267-4890-8186-9fc22b78b738}</Project>\n    </ProjectReference>\n    <ProjectReference Include=\"glsl-optimizer\\projects\\vs2013\\glsl_optimizer_lib_2013.vcxproj\">\n      <Project>{b475a403-9d9b-410d-8a93-ba49fc4dd811}</Project>\n    </ProjectReference>\n    <ProjectReference Include=\"GLSlang\\glslang_Pyramid.vcxproj\">\n      <Project>{3b146cc5-b2b8-4573-9d46-6139e2edfea3}</Project>\n    </ProjectReference>\n  </ItemGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n  <ImportGroup Label=\"ExtensionTargets\">\n  </ImportGroup>\n</Project>"
  },
  {
    "path": "src/Wrapper/Wrapper.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup>\n    <Filter Include=\"Source Files\">\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\n      <Extensions>\n      </Extensions>\n    </Filter>\n    <Filter Include=\"Source Files\\CodeXL\">\n      <UniqueIdentifier>{5412010c-a603-425f-827e-0233c9164358}</UniqueIdentifier>\n    </Filter>\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"D3DCompiler_Impl.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"Wrapper.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"GLSLOpt_Impl.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"GLSlang_Impl.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"GLSlang_Stubs.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"GCNIsa.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"GCNDisassembler.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"GCNEnums.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"AMDDriver_Impl.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"GCN1Decoder.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"GCN3Decoder.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"GCNDecoder.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"AMDAsic_Impl.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"GCNSimulator.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"AMDShader_Impl.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"Scrutinizer_GCN.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"amd-codexl-analyzer\\Common\\Src\\DeviceInfo\\DeviceInfoUtils.cpp\">\n      <Filter>Source Files\\CodeXL</Filter>\n    </ClCompile>\n    <ClCompile Include=\"DXILCompiler_Impl.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"Utilities.h\">\n      <Filter>Source Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"D3DCompiler_Impl.h\">\n      <Filter>Source Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"GLSLOpt_Impl.h\">\n      <Filter>Source Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"GLSlang_Impl.h\">\n      <Filter>Source Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"GCNEnums.h\">\n      <Filter>Source Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"GCNIsa.h\">\n      <Filter>Source Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"GCNDisassembler.h\">\n      <Filter>Source Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"AMDDriver_Impl.h\">\n      <Filter>Source Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"GCNDecoder.h\">\n      <Filter>Source Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"GCN3Decoder.h\">\n      <Filter>Source Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"GCN1Decoder.h\">\n      <Filter>Source Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"AMDAsic_Impl.h\">\n      <Filter>Source Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"GCNBufferedPrinter.h\">\n      <Filter>Source Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"GCNSimulator.h\">\n      <Filter>Source Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"AMDShader_Impl.h\">\n      <Filter>Source Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"Scrutinizer_GCN.h\">\n      <Filter>Source Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"amd-codexl-analyzer\\Common\\Src\\DeviceInfo\\DeviceInfo.h\">\n      <Filter>Source Files\\CodeXL</Filter>\n    </ClInclude>\n    <ClInclude Include=\"amd-codexl-analyzer\\Common\\Src\\DeviceInfo\\DeviceInfoUtils.h\">\n      <Filter>Source Files\\CodeXL</Filter>\n    </ClInclude>\n    <ClInclude Include=\"amd-codexl-analyzer\\CommonProjects\\AMDTBackend\\Include\\Common\\AmdDxGsaCompile.h\">\n      <Filter>Source Files\\CodeXL</Filter>\n    </ClInclude>\n    <ClInclude Include=\"amd-codexl-analyzer\\CommonProjects\\AMDTBackend\\Include\\Common\\asic_reg\\atiid.h\">\n      <Filter>Source Files\\CodeXL</Filter>\n    </ClInclude>\n    <ClInclude Include=\"amd-codexl-analyzer\\CommonProjects\\AMDTBackend\\Include\\Common\\asic_reg\\ci_id.h\">\n      <Filter>Source Files\\CodeXL</Filter>\n    </ClInclude>\n    <ClInclude Include=\"amd-codexl-analyzer\\CommonProjects\\AMDTBackend\\Include\\Common\\asic_reg\\cz_id.h\">\n      <Filter>Source Files\\CodeXL</Filter>\n    </ClInclude>\n    <ClInclude Include=\"amd-codexl-analyzer\\CommonProjects\\AMDTBackend\\Include\\Common\\asic_reg\\evergreen_id.h\">\n      <Filter>Source Files\\CodeXL</Filter>\n    </ClInclude>\n    <ClInclude Include=\"amd-codexl-analyzer\\CommonProjects\\AMDTBackend\\Include\\Common\\asic_reg\\kv_id.h\">\n      <Filter>Source Files\\CodeXL</Filter>\n    </ClInclude>\n    <ClInclude Include=\"amd-codexl-analyzer\\CommonProjects\\AMDTBackend\\Include\\Common\\asic_reg\\northernisland_id.h\">\n      <Filter>Source Files\\CodeXL</Filter>\n    </ClInclude>\n    <ClInclude Include=\"amd-codexl-analyzer\\CommonProjects\\AMDTBackend\\Include\\Common\\asic_reg\\si_id.h\">\n      <Filter>Source Files\\CodeXL</Filter>\n    </ClInclude>\n    <ClInclude Include=\"amd-codexl-analyzer\\CommonProjects\\AMDTBackend\\Include\\Common\\asic_reg\\sumo_id.h\">\n      <Filter>Source Files\\CodeXL</Filter>\n    </ClInclude>\n    <ClInclude Include=\"amd-codexl-analyzer\\CommonProjects\\AMDTBackend\\Include\\Common\\asic_reg\\tn_id.h\">\n      <Filter>Source Files\\CodeXL</Filter>\n    </ClInclude>\n    <ClInclude Include=\"amd-codexl-analyzer\\CommonProjects\\AMDTBackend\\Include\\Common\\asic_reg\\vi_id.h\">\n      <Filter>Source Files\\CodeXL</Filter>\n    </ClInclude>\n    <ClInclude Include=\"DXILCompiler_Impl.h\">\n      <Filter>Source Files</Filter>\n    </ClInclude>\n  </ItemGroup>\n</Project>"
  },
  {
    "path": "src/Wrapper/amd-codexl-analyzer/Common/Src/DeviceInfo/DeviceInfo.h",
    "content": "//=====================================================================\n// Copyright 2010-2016 (c), Advanced Micro Devices, Inc. All rights reserved.\n//\n/// \\author AMD Developer Tools Team\n/// \\file DeviceInfo.h \n/// \\brief  Device info table\n/// \n//=====================================================================\n#ifndef _DEVICE_INFO_H_\n#define _DEVICE_INFO_H_\n\n#ifndef _WIN32\n    #include <cstddef>      // Required by GCC size_t\n#endif\n\n#define DEVICE_INFO_NA 0xFFFFFFFF\n\nenum GDT_HW_ASIC_TYPE\n{\n    GDT_ASIC_TYPE_NONE = -1,  ///< undefined asic\n    GDT_TAHITI_PRO = 0,       ///< TAHITI GPU PRO\n    GDT_TAHITI_XT,            ///< TAHITI GPU XT\n    GDT_PITCAIRN_PRO,         ///< PITCAIRN GPU PRO\n    GDT_PITCAIRN_XT,          ///< PITCAIRN GPU XT\n    GDT_CAPEVERDE_PRO,        ///< CAPE VERDE PRO GPU\n    GDT_CAPEVERDE_XT,         ///< CAPE VERDE XT GPU\n    GDT_OLAND,                ///< OLAND GPU (mobile is MARS)\n    GDT_HAINAN,               ///< HAINAN GPU\n    GDT_BONAIRE,              ///< BONAIRE GPU (mobile is SATURN)\n    GDT_HAWAII,               ///< HAWAII GPU\n    GDT_KALINDI,              ///< KB APU\n    GDT_SPECTRE,              ///< KV APU SPECTRE\n    GDT_SPECTRE_SL,           ///< KV APU SPECTRE SL\n    GDT_SPECTRE_LITE,         ///< KV APU SPECTRE LITE\n    GDT_SPOOKY,               ///< KV APU SPOOKY\n    GDT_ICELAND,              ///< ICELAND GPU\n    GDT_TONGA,                ///< TONGA GPU\n    GDT_CARRIZO,              ///< CZ APU\n    GDT_CARRIZO_EMB,          ///< CZ APU EMBEDDED\n    GDT_FIJI,                 ///< FIJI GPU\n    GDT_STONEY,               ///< STONEY APU\n    GDT_LAST                  ///< last\n};\n\n//------------------------------------------------------------------------------------\n// This is used for counter set selection\n//------------------------------------------------------------------------------------\nenum GDT_HW_GENERATION\n{\n    GDT_HW_GENERATION_NONE,             ///< undefined hw generation\n    GDT_HW_GENERATION_NVIDIA,           ///< nvidia GPU\n    GDT_HW_GENERATION_SOUTHERNISLAND,   ///< GFX IP 6\n    GDT_HW_GENERATION_SEAISLAND,        ///< GFX IP 7\n    GDT_HW_GENERATION_VOLCANICISLAND,   ///< GFX IP 8\n    GDT_HW_GENERATION_LAST\n};\n\n//------------------------------------------------------------------------------------\n// Card info\n//------------------------------------------------------------------------------------\nstruct GDT_GfxCardInfo\n{\n    GDT_HW_ASIC_TYPE  m_asicType;          ///< ASIC type, which is also the index to gs_deviceInfo table\n    size_t            m_deviceID;          ///< numeric device id\n    size_t            m_revID;             ///< numeric revision id\n    GDT_HW_GENERATION m_generation;        ///< hardware generation\n    bool              m_bAPU;              ///< flag indicating whether or not the device is an APU\n    const char*       m_szCALName;         ///< CAL name\n    const char*       m_szMarketingName;   ///< marketing style device name\n};\n\n//------------------------------------------------------------------------------------\n// Device info\n//------------------------------------------------------------------------------------\nstruct GDT_DeviceInfo\n{\n    size_t m_nNumShaderEngines;  ///< Number of shader engines\n    size_t m_nMaxWavePerSIMD;    ///< Number of wave slots per SIMD\n    size_t m_suClocksPrim;       ///< Number of clocks it takes to process a primitive\n    size_t m_nNumSQMaxCounters;  ///< Max number of SQ counters\n    size_t m_nNumPrimPipes;      ///< Number of primitive pipes\n    size_t m_nWaveSize;          ///< Wavefront size\n    size_t m_nNumSHPerSE;        ///< Number of shader array per Shader Engine\n    size_t m_nNumCUPerSH;        ///< Number of compute unit per Shader Array\n    size_t m_nNumSIMDPerCU;      ///< Number of SIMDs per Compute unit\n\n    bool  m_deviceInfoValid;     ///< Flag indicating whether or not this device info is valid (as opposed to placeholder data)\n\n    /// Get total number of SIMDs\n    size_t numberSIMDs() const\n    {\n        return m_nNumSIMDPerCU * numberCUs();\n    }\n\n    /// Get total number of shader arrays\n    size_t numberSHs() const\n    {\n        return m_nNumSHPerSE * m_nNumShaderEngines;\n    }\n\n    /// Get total number of compute units\n    size_t numberCUs() const\n    {\n        return numberSHs() * m_nNumCUPerSH;\n    }\n};\n\n#endif // _DEVICE_INFO_H_\n"
  },
  {
    "path": "src/Wrapper/amd-codexl-analyzer/Common/Src/DeviceInfo/DeviceInfoUtils.cpp",
    "content": "//=====================================================================\n// Copyright 2016 (c), Advanced Micro Devices, Inc. All rights reserved.\n//\n/// \\author AMD Developer Tools Team\n/// \\file DeviceInfoUtils.cpp \n/// \\brief  Device info utils class\n/// \n//=====================================================================\n\n#ifdef _WIN32\n    #include <windows.h>\n#endif\n#ifdef _LINUX\n    #include <dlfcn.h>\n#endif\n\n#include \"DeviceInfoUtils.h\"\n\nusing namespace std;\n\nstatic GDT_GfxCardInfo gs_cardInfo[] =\n{\n    { GDT_TAHITI_XT,  0x6790, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Tahiti\", \"Not Used\" },\n    { GDT_TAHITI_PRO, 0x6792, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Tahiti\", \"Not Used\" },\n    { GDT_TAHITI_XT,  0x6798, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Tahiti\", \"AMD Radeon HD 7900 Series\" },\n    { GDT_TAHITI_XT,  0x6799, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Tahiti\", \"SI NEW ZEALAND\" },\n    { GDT_TAHITI_PRO, 0x679A, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Tahiti\", \"AMD Radeon HD 7900 Series\" },\n    { GDT_TAHITI_PRO, 0x679B, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Tahiti\", \"AMD Radeon HD 7900 Series\" },\n    { GDT_TAHITI_PRO, 0x679E, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Tahiti\", \"AMD Radeon HD 7800 Series\" },\n    { GDT_TAHITI_XT,  0x6780, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Tahiti\", \"AMD FirePro W9000\" },\n    { GDT_TAHITI_PRO, 0x6784, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Tahiti\", \"ATI FirePro V (FireGL V) Graphics Adapter\" },\n    { GDT_TAHITI_XT,  0x6788, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Tahiti\", \"ATI FirePro V (FireGL V) Graphics Adapter\" },\n    { GDT_TAHITI_PRO, 0x678A, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Tahiti\", \"AMD FirePro W8000\" },\n\n    { GDT_PITCAIRN_XT,  0x6818, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Pitcairn\", \"AMD Radeon HD 7800 Series\" },\n    { GDT_PITCAIRN_PRO, 0x6819, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Pitcairn\", \"AMD Radeon HD 7800 Series\" },\n    { GDT_PITCAIRN_XT,  0x6808, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Pitcairn\", \"AMD FirePro W7000\" },\n    { GDT_PITCAIRN_XT,  0x6809, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Pitcairn\", \"ATI FirePro W5000\" },\n    { GDT_PITCAIRN_XT,  0x684C, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Pitcairn\", \"ATI FirePro V(FireGL V) Graphics Adapter\" },\n    { GDT_PITCAIRN_XT,  0x6800, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Pitcairn\", \"AMD Radeon HD 7970M\" },\n    { GDT_PITCAIRN_PRO, 0x6801, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Pitcairn\", \"AMD Radeon(TM) HD8970M\" },\n    { GDT_PITCAIRN_XT,  0x6806, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Pitcairn\", \"NEPTUNE (6806)\" },\n    { GDT_PITCAIRN_XT,  0x6810, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Pitcairn\", \"AMD Radeon R9 200 Series\" },\n    { GDT_PITCAIRN_XT,  0x6810, 0x81, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Pitcairn\", \"AMD Radeon (TM) R9 370 Series\" },\n    { GDT_PITCAIRN_PRO, 0x6811, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Pitcairn\", \"AMD Radeon R9 200 Series\" },\n    { GDT_PITCAIRN_PRO, 0x6811, 0x81, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Pitcairn\", \"AMD Radeon (TM) R7 370 Series\" },\n\n    { GDT_CAPEVERDE_XT,  0x6820, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Capeverde\", \"AMD Radeon R9 M275X\" },\n    { GDT_CAPEVERDE_XT,  0x6820, 0x81, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Capeverde\", \"AMD Radeon (TM) R9 M375\" },\n    { GDT_CAPEVERDE_XT,  0x6820, 0x83, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Capeverde\", \"AMD Radeon (TM) R9 M375X\" },\n    { GDT_CAPEVERDE_XT,  0x6821, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Capeverde\", \"AMD Radeon R9 M200X Series\" },\n    { GDT_CAPEVERDE_XT,  0x6821, 0x83, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Capeverde\", \"AMD Radeon R9 (TM) M370X\" },\n    { GDT_CAPEVERDE_XT,  0x6821, 0x87, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Capeverde\", \"AMD Radeon (TM) R7 M380\" },\n    { GDT_CAPEVERDE_XT,  0x6821, 0x8B, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Capeverde\", \"DID:6821 RID:8B\" },\n    { GDT_CAPEVERDE_PRO, 0x6822, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Capeverde\", \"AMD Radeon E8860\" },\n    { GDT_CAPEVERDE_PRO, 0x6823, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Capeverde\", \"AMD Radeon HD 8800M Series\" },\n    { GDT_CAPEVERDE_PRO, 0x6824, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Capeverde\", \"Not Used\" },\n    { GDT_CAPEVERDE_XT,  0x6825, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Capeverde\", \"AMD Radeon HD 7800M Series\" },\n    { GDT_CAPEVERDE_PRO, 0x6826, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Capeverde\", \"AMD Radeon HD 7700M Series\" },\n    { GDT_CAPEVERDE_PRO, 0x6827, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Capeverde\", \"AMD Radeon HD 7800M Series\" },\n    { GDT_CAPEVERDE_PRO, 0x682A, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Capeverde\", \"VENUS PRO MCM (682A)\" },\n    { GDT_CAPEVERDE_XT,  0x682B, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Capeverde\", \"AMD Radeon HD 8800M Series\" },\n    { GDT_CAPEVERDE_XT,  0x682B, 0x87, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Capeverde\", \"AMD Radeon (TM) R9 M360\" },\n    { GDT_CAPEVERDE_XT,  0x682D, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Capeverde\", \"AMD Radeon HD 7700M Series\" },\n    { GDT_CAPEVERDE_PRO, 0x682F, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Capeverde\", \"AMD Radeon HD 7700M Series\" },\n\n    { GDT_CAPEVERDE_XT,  0x6828, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Capeverde\", \"AMD FirePro W600\" },\n    { GDT_CAPEVERDE_PRO, 0x682C, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Capeverde\", \"AMD FirePro W4100\" },\n    { GDT_CAPEVERDE_XT,  0x6830, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Capeverde\", \"AMD Radeon 7800M Series\" },\n    { GDT_CAPEVERDE_XT,  0x6831, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Capeverde\", \"AMD Radeon 7700M Series\" },\n    { GDT_CAPEVERDE_PRO, 0x6835, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Capeverde\", \"AMD Radeon R7 Series / HD 9000 Series\" },\n    { GDT_CAPEVERDE_XT,  0x6837, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Capeverde\", \"AMD Radeon HD7700 Series\" },\n    { GDT_CAPEVERDE_XT,  0x6838, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Capeverde\", \"Not Used\" },\n    { GDT_CAPEVERDE_XT,  0x6839, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Capeverde\", \"Not Used\" },\n    { GDT_CAPEVERDE_PRO, 0x683B, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Capeverde\", \"Not Used\" },\n    { GDT_CAPEVERDE_XT,  0x683D, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Capeverde\", \"AMD Radeon HD 7700 Series\" },\n    { GDT_CAPEVERDE_PRO, 0x683F, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Capeverde\", \"AMD Radeon HD 7700 Series\" },\n\n    // Oland\n    { GDT_OLAND, 0x6608, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Oland\", \"AMD FirePro W2100\" },\n    { GDT_OLAND, 0x6610, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Oland\", \"AMD Radeon R7 200 Series\" },\n    { GDT_OLAND, 0x6610, 0x83, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Oland\", \"AMD Radeon (TM) R5 340\" },\n    { GDT_OLAND, 0x6610, 0x81, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Oland\", \"AMD Radeon (TM) R7 350\" },\n    { GDT_OLAND, 0x6611, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Oland\", \"AMD Radeon R7 200 Series\" },\n    { GDT_OLAND, 0x6613, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Oland\", \"AMD Radeon R7 200 Series\" },\n    { GDT_OLAND, 0x6617, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Oland\", \"AMD Radeon R7 240 Series\" },\n    { GDT_OLAND, 0x6617, 0xC7, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Oland\", \"AMD Radeon R7 240 Series\" },\n    { GDT_OLAND, 0x6631, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Oland\", \"OLAND (6631)\" },\n\n    // Mars (Mobile Oland)\n    { GDT_OLAND, 0x6600, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Oland\", \"AMD Radeon HD 8600/8700M\" },\n    { GDT_OLAND, 0x6600, 0x81, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Oland\", \"AMD Radeon (TM) R7 M370\" },\n    { GDT_OLAND, 0x6601, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Oland\", \"AMD Radeon (TM) HD 8500M/8700M\" },\n    { GDT_OLAND, 0x6602, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Oland\", \"MARS (6602)\" },\n    { GDT_OLAND, 0x6603, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Oland\", \"MARS (6603)\" },\n    { GDT_OLAND, 0x6604, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Oland\", \"AMD Radeon R7 M265 Series\" },\n    { GDT_OLAND, 0x6604, 0x81, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Oland\", \"AMD Radeon (TM) R7 M350\" },\n    { GDT_OLAND, 0x6605, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Oland\", \"AMD Radeon R7 M260 Series\" },\n    { GDT_OLAND, 0x6605, 0x81, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Oland\", \"AMD Radeon (TM) R7 M340\" },\n    { GDT_OLAND, 0x6606, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Oland\", \"AMD Radeon HD 8790M\" },\n    { GDT_OLAND, 0x6607, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Oland\", \"AMD Radeon R5 M240\" },\n    { GDT_OLAND, 0x6620, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Oland\", \"MARS (6620)\" },\n    { GDT_OLAND, 0x6621, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Oland\", \"MARS (6621)\" },\n    { GDT_OLAND, 0x6623, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Oland\", \"MARS (6623)\" },\n\n    // Hainan\n    { GDT_HAINAN, 0x6660, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Hainan\", \"AMD Radeon HD 8600M Series\" },\n    { GDT_HAINAN, 0x6660, 0x83, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Hainan\", \"AMD Radeon (TM) R5 M330\" },\n    { GDT_HAINAN, 0x6660, 0x81, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Hainan\", \"AMD Radeon (TM) R5 M335\" },\n    { GDT_HAINAN, 0x6663, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Hainan\", \"AMD Radeon HD 8500M Series\" },\n    { GDT_HAINAN, 0x6663, 0x83, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Hainan\", \"AMD Radeon (TM) R5 M320\" },\n    { GDT_HAINAN, 0x6664, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Hainan\", \"AMD Radeon R5 M200 Series\" },\n    { GDT_HAINAN, 0x6665, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Hainan\", \"AMD Radeon R5 M230 Series\" },\n    { GDT_HAINAN, 0x6665, 0x83, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Hainan\", \"AMD Radeon (TM) R5 M320\" },\n    { GDT_HAINAN, 0x6665, 0xC3, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Hainan\", \"AMD Radeon R5 M435 Series\" },\n    { GDT_HAINAN, 0x6666, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Hainan\", \"AMD Radeon R5 M200 Series\" },\n    { GDT_HAINAN, 0x6667, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Hainan\", \"AMD Radeon R5 M200 Series\" },\n    { GDT_HAINAN, 0x6667, 0x83, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Hainan\", \"EXO ULP (6667)\" },\n    { GDT_HAINAN, 0x666F, 0x00, GDT_HW_GENERATION_SOUTHERNISLAND, false, \"Hainan\", \"AMD Radeon HD 8500M\" },\n\n    // Bonaire\n    { GDT_BONAIRE, 0x6649, 0x00, GDT_HW_GENERATION_SEAISLAND, false, \"Bonaire\", \"AMD FirePro W5100\" },\n    { GDT_BONAIRE, 0x6650, 0x00, GDT_HW_GENERATION_SEAISLAND, false, \"Bonaire\", \"BONAIRE (6650)\" },\n    { GDT_BONAIRE, 0x6651, 0x00, GDT_HW_GENERATION_SEAISLAND, false, \"Bonaire\", \"BONAIRE (6651)\" },\n    { GDT_BONAIRE, 0x6658, 0x00, GDT_HW_GENERATION_SEAISLAND, false, \"Bonaire\", \"AMD Radeon R7 200 Series\" },\n    { GDT_BONAIRE, 0x665C, 0x00, GDT_HW_GENERATION_SEAISLAND, false, \"Bonaire\", \"AMD Radeon HD 7700 Series\" },\n    { GDT_BONAIRE, 0x665D, 0x00, GDT_HW_GENERATION_SEAISLAND, false, \"Bonaire\", \"AMD Radeon R7 200 Series\" },\n    { GDT_BONAIRE, 0x665F, 0x81, GDT_HW_GENERATION_SEAISLAND, false, \"Bonaire\", \"AMD Radeon (TM) R7 360 Series\" },\n    { GDT_BONAIRE, 0x665F, 0x00, GDT_HW_GENERATION_SEAISLAND, false, \"Bonaire\", \"DID:665F RID:00\" },\n    { GDT_BONAIRE, 0x665F, 0x81, GDT_HW_GENERATION_SEAISLAND, false, \"Bonaire\", \"AMD Radeon (TM) R7 360 Series\" },\n\n    // Saturn (mobile Bonaire)\n    { GDT_BONAIRE, 0x6640, 0x00, GDT_HW_GENERATION_SEAISLAND, false, \"Bonaire\", \"AMD Radeon HD 8950\" },\n    { GDT_BONAIRE, 0x6640, 0x80, GDT_HW_GENERATION_SEAISLAND, false, \"Bonaire\", \"AMD Radeon (TM) R9 M380\" },\n    { GDT_BONAIRE, 0x6641, 0x00, GDT_HW_GENERATION_SEAISLAND, false, \"Bonaire\", \"SATURN (6641)\" },\n    { GDT_BONAIRE, 0x6646, 0x00, GDT_HW_GENERATION_SEAISLAND, false, \"Bonaire\", \"AMD Radeon R9 M280X\" },\n    { GDT_BONAIRE, 0x6646, 0x80, GDT_HW_GENERATION_SEAISLAND, false, \"Bonaire\", \"AMD Radeon (TM) R9 M385\" },\n    { GDT_BONAIRE, 0x6647, 0x00, GDT_HW_GENERATION_SEAISLAND, false, \"Bonaire\", \"AMD Radeon R9 M200X Series\" },\n    { GDT_BONAIRE, 0x6647, 0x80, GDT_HW_GENERATION_SEAISLAND, false, \"Bonaire\", \"AMD Radeon (TM) R9 M380\" },\n\n    // Hawaii\n    { GDT_HAWAII, 0x66A0, 0x00, GDT_HW_GENERATION_SEAISLAND, false, \"Hawaii\", \"HAWAII XTGL (67A0)\" },\n    { GDT_HAWAII, 0x67A0, 0x00, GDT_HW_GENERATION_SEAISLAND, false, \"Hawaii\", \"AMD FirePro W9100\" },\n    { GDT_HAWAII, 0x67A1, 0x00, GDT_HW_GENERATION_SEAISLAND, false, \"Hawaii\", \"AMD FirePro W8100\" },\n    { GDT_HAWAII, 0x67A2, 0x00, GDT_HW_GENERATION_SEAISLAND, false, \"Hawaii\", \"HAWAII GL Gemini (67A2)\" },\n    { GDT_HAWAII, 0x67A8, 0x00, GDT_HW_GENERATION_SEAISLAND, false, \"Hawaii\", \"\" },\n    { GDT_HAWAII, 0x67A9, 0x00, GDT_HW_GENERATION_SEAISLAND, false, \"Hawaii\", \"\" },\n    { GDT_HAWAII, 0x67AA, 0x00, GDT_HW_GENERATION_SEAISLAND, false, \"Hawaii\", \"\" },\n    { GDT_HAWAII, 0x67B0, 0x00, GDT_HW_GENERATION_SEAISLAND, false, \"Hawaii\", \"AMD Radeon R9 200 Series\" },\n    { GDT_HAWAII, 0x67B0, 0x80, GDT_HW_GENERATION_SEAISLAND, false, \"Hawaii\", \"AMD Radeon (TM) R9 390 Series\" },\n    { GDT_HAWAII, 0x67B1, 0x00, GDT_HW_GENERATION_SEAISLAND, false, \"Hawaii\", \"AMD Radeon R9 200 Series\" },\n    { GDT_HAWAII, 0x67B1, 0x80, GDT_HW_GENERATION_SEAISLAND, false, \"Hawaii\", \"AMD Radeon (TM) R9 390 Series\" },\n    { GDT_HAWAII, 0x67B8, 0x00, GDT_HW_GENERATION_SEAISLAND, false, \"Hawaii\", \"Not used\" },\n    { GDT_HAWAII, 0x67B9, 0x00, GDT_HW_GENERATION_SEAISLAND, false, \"Hawaii\", \"AMD Radeon R9 200 Series\" },\n    { GDT_HAWAII, 0x67BA, 0x00, GDT_HW_GENERATION_SEAISLAND, false, \"Hawaii\", \"Not used\" },\n    { GDT_HAWAII, 0x67BE, 0x00, GDT_HW_GENERATION_SEAISLAND, false, \"Hawaii\", \"HAWAII LE (67BE)\" },\n\n    // Kaveri -- will probably need multiple entries in g_deviceInfo for these\n    { GDT_SPECTRE,      0x1304, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Spectre\", \"KV SPECTRE MOBILE 35W (1304)\" },\n    { GDT_SPECTRE,      0x1305, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Spectre\", \"KV SPECTRE DESKTOP 95W (1305)\" },\n    { GDT_SPECTRE_SL,   0x1306, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Spectre\", \"KV SPECTRE SL MOBILE 35W (1306)\" },\n    { GDT_SPECTRE_SL,   0x1307, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Spectre\", \"KV SPECTRE SL DESKTOP 95W (1307)\" },\n    { GDT_SPECTRE_LITE, 0x1309, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Spectre\", \"AMD Radeon(TM) R7 Graphics\" },\n    { GDT_SPECTRE_LITE, 0x130A, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Spectre\", \"AMD Radeon(TM) R6 Graphics\" },\n    { GDT_SPECTRE,      0x130C, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Spectre\", \"AMD Radeon(TM) R7 Graphics\" },\n    { GDT_SPECTRE_LITE, 0x130D, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Spectre\", \"AMD Radeon(TM) R6 Graphics\" },\n    { GDT_SPECTRE_SL,   0x130E, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Spectre\", \"AMD Radeon(TM) R5 Graphics\" },\n    { GDT_SPECTRE,      0x130F, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Spectre\", \"AMD Radeon(TM) R7 Graphics\" },\n    { GDT_SPECTRE,      0x130F, 0xD4, GDT_HW_GENERATION_SEAISLAND, true, \"Spectre\", \"AMD Radeon(TM) R7 Graphics\" },\n    { GDT_SPECTRE,      0x130F, 0xD5, GDT_HW_GENERATION_SEAISLAND, true, \"Spectre\", \"AMD Radeon(TM) R7 Graphics\" },\n    { GDT_SPECTRE,      0x130F, 0xD6, GDT_HW_GENERATION_SEAISLAND, true, \"Spectre\", \"AMD Radeon(TM) R7 Graphics\" },\n    { GDT_SPECTRE,      0x130F, 0xD7, GDT_HW_GENERATION_SEAISLAND, true, \"Spectre\", \"AMD Radeon(TM) R7 Graphics\" },\n    { GDT_SPECTRE,      0x1310, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Spectre\", \"KV SPECTRE WORKSTATION 65W (1310)\" },\n    { GDT_SPECTRE,      0x1311, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Spectre\", \"KV SPECTRE WORKSTATION 95W (1311)\" },\n    { GDT_SPECTRE_LITE, 0x1313, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Spectre\", \"AMD Radeon(TM) R7 Graphics\" },\n    { GDT_SPECTRE_LITE, 0x1313, 0xD4, GDT_HW_GENERATION_SEAISLAND, true, \"Spectre\", \"AMD Radeon(TM) R7 Graphics\" },\n    { GDT_SPECTRE_LITE, 0x1313, 0xD5, GDT_HW_GENERATION_SEAISLAND, true, \"Spectre\", \"AMD Radeon(TM) R7 Graphics\" },\n    { GDT_SPECTRE_LITE, 0x1313, 0xD6, GDT_HW_GENERATION_SEAISLAND, true, \"Spectre\", \"AMD Radeon(TM) R7 Graphics\" },\n    { GDT_SPECTRE_SL,   0x1315, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Spectre\", \"AMD Radeon(TM) R5 Graphics\" },\n    { GDT_SPECTRE_SL,   0x1315, 0xD4, GDT_HW_GENERATION_SEAISLAND, true, \"Spectre\", \"AMD Radeon(TM) R5 Graphics\" },\n    { GDT_SPECTRE_SL,   0x1315, 0xD5, GDT_HW_GENERATION_SEAISLAND, true, \"Spectre\", \"AMD Radeon(TM) R5 Graphics\" },\n    { GDT_SPECTRE_SL,   0x1315, 0xD6, GDT_HW_GENERATION_SEAISLAND, true, \"Spectre\", \"AMD Radeon(TM) R5 Graphics\" },\n    { GDT_SPECTRE_SL,   0x1315, 0xD7, GDT_HW_GENERATION_SEAISLAND, true, \"Spectre\", \"AMD Radeon(TM) R5 Graphics\" },\n    { GDT_SPECTRE_SL,   0x1318, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Spectre\", \"AMD Radeon(TM) R5 Graphics\" },\n    { GDT_SPECTRE,      0x131C, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Spectre\", \"AMD Radeon(TM) R7 Graphics\" },\n    { GDT_SPECTRE_LITE, 0x131D, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Spectre\", \"AMD Radeon(TM) R6 Graphics\" },\n    { GDT_SPOOKY,       0x130B, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Spectre\", \"AMD Radeon(TM) R4 Graphics\" },\n    { GDT_SPOOKY,       0x1312, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Spooky\", \"KV SPOOKY DESKTOP 95W (1312)\" },\n    { GDT_SPOOKY,       0x1316, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Spooky\", \"AMD Radeon(TM) R5 Graphics\" },\n    { GDT_SPOOKY,       0x1317, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Spooky\", \"KV SPOOKY MOBILE 35W (1317)\" },\n    { GDT_SPOOKY,       0x131B, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Spectre\", \"AMD Radeon(TM) R4 Graphics\" },\n\n    // Kabini\n    { GDT_KALINDI, 0x9830, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Kalindi\", \"AMD Radeon HD 8400 / R3 Series\" },\n    { GDT_KALINDI, 0x9831, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Kalindi\", \"AMD Radeon(TM) HD 8400E\" },\n    { GDT_KALINDI, 0x9832, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Kalindi\", \"AMD Radeon HD 8330\" },\n    { GDT_KALINDI, 0x9833, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Kalindi\", \"AMD Radeon(TM) HD 8330E\" },\n    { GDT_KALINDI, 0x9834, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Kalindi\", \"AMD Radeon HD 8210\" },\n    { GDT_KALINDI, 0x9835, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Kalindi\", \"AMD Radeon(TM) HD 8210E\" },\n    { GDT_KALINDI, 0x9836, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Kalindi\", \"AMD Radeon HD 8200 / R3 Series\" },\n    { GDT_KALINDI, 0x9837, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Kalindi\", \"AMD Radeon(TM) HD 8280E\" },\n    { GDT_KALINDI, 0x9838, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Kalindi\", \"AMD Radeon HD 8200 / R3 series\" },\n\n    // Temash\n    { GDT_KALINDI, 0x9839, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Kalindi\", \"AMD Radeon HD 8180\" },\n    { GDT_KALINDI, 0x983A, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Kalindi\", \"Not Used\" },\n    { GDT_KALINDI, 0x983B, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Kalindi\", \"Not Used\" },\n    { GDT_KALINDI, 0x983C, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Kalindi\", \"Not Used\" },\n    { GDT_KALINDI, 0x983D, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Kalindi\", \"AMD Radeon HD 8250\" },\n    { GDT_KALINDI, 0x983E, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Kalindi\", \"Not Used\" },\n    { GDT_KALINDI, 0x983F, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Kalindi\", \"Not Used\" },\n\n    // Beema\n    { GDT_KALINDI, 0x9850, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"AMD Radeon(TM) R3 Graphics\" },\n    { GDT_KALINDI, 0x9850, 0x03, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"AMD Radeon(TM) R3 Graphics\" },\n    { GDT_KALINDI, 0x9850, 0x40, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"AMD Radeon(TM) R2 Graphics\" },\n    { GDT_KALINDI, 0x9850, 0x45, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"AMD Radeon(TM) R3 Graphics\" },\n    { GDT_KALINDI, 0x9851, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"AMD Radeon(TM) R4 Graphics\" },\n    { GDT_KALINDI, 0x9851, 0x01, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"AMD Radeon(TM) R5E Graphics\" },\n    { GDT_KALINDI, 0x9851, 0x05, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"AMD Radeon(TM) R5 Graphics\" },\n    { GDT_KALINDI, 0x9851, 0x06, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"AMD Radeon(TM) R5E Graphics\" },\n    { GDT_KALINDI, 0x9851, 0x40, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"AMD Radeon(TM) R4 Graphics\" },\n    { GDT_KALINDI, 0x9851, 0x45, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"AMD Radeon(TM) R5 Graphics\" },\n    { GDT_KALINDI, 0x9852, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"AMD Radeon(TM) R2 Graphics\" },\n    { GDT_KALINDI, 0x9852, 0x40, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"AMD Radeon(TM) E1 Graphics\" },\n    { GDT_KALINDI, 0x9853, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"AMD Radeon(TM) R2 Graphics\" },\n    { GDT_KALINDI, 0x9853, 0x01, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"AMD Radeon(TM) R4E Graphics\" },\n    { GDT_KALINDI, 0x9853, 0x03, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"AMD Radeon(TM) R2 Graphics\" },\n    { GDT_KALINDI, 0x9853, 0x05, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"AMD Radeon(TM) R1E Graphics\" },\n    { GDT_KALINDI, 0x9853, 0x06, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"AMD Radeon(TM) R1E Graphics\" },\n    { GDT_KALINDI, 0x9853, 0x40, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"AMD Radeon(TM) R2 Graphics\" },\n\n    // Mullins\n    { GDT_KALINDI, 0x9854, 0x02, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"AMD Radeon(TM) R3 Graphics\" },\n    { GDT_KALINDI, 0x9854, 0x07, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"AMD Radeon(TM) R3 Graphics\" },\n    { GDT_KALINDI, 0x9854, 0x05, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"AMD Radeon(TM) R2 Graphics\" },\n    { GDT_KALINDI, 0x9854, 0x06, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"AMD Radeon(TM) R3 Graphics\" },\n    { GDT_KALINDI, 0x9854, 0x01, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"AMD Radeon(TM) R3E Graphics\" },\n    { GDT_KALINDI, 0x9854, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"AMD Radeon(TM) R3 Graphics\" },\n    { GDT_KALINDI, 0x9855, 0x05, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"AMD Radeon(TM) R4 Graphics\" },\n    { GDT_KALINDI, 0x9855, 0x02, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"AMD Radeon(TM) R6 Graphics\" },\n    { GDT_KALINDI, 0x9856, 0x07, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"AMD Radeon(TM) R1E Graphics\" },\n    { GDT_KALINDI, 0x9856, 0x01, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"AMD Radeon(TM) R2E Graphics\" },\n    { GDT_KALINDI, 0x9856, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"AMD Radeon(TM) R2 Graphics\" },\n    { GDT_KALINDI, 0x9856, 0x06, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"AMD Radeon(TM) R2 Graphics\" },\n    { GDT_KALINDI, 0x9856, 0x05, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"AMD Radeon(TM) R1E Graphics\" },\n    { GDT_KALINDI, 0x9856, 0x02, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"AMD Radeon(TM) R2 Graphics\" },\n    { GDT_KALINDI, 0x9857, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"MULLINS (9857)\" },\n    { GDT_KALINDI, 0x9858, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"MULLINS (9858)\" },\n    { GDT_KALINDI, 0x9859, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"MULLINS (9859)\" },\n    { GDT_KALINDI, 0x985A, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"MULLINS (985A)\" },\n    { GDT_KALINDI, 0x985B, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"MULLINS (985B)\" },\n    { GDT_KALINDI, 0x985C, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"MULLINS (985C)\" },\n    { GDT_KALINDI, 0x985D, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"MULLINS (985D)\" },\n    { GDT_KALINDI, 0x985E, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"MULLINS (985E)\" },\n    { GDT_KALINDI, 0x985F, 0x00, GDT_HW_GENERATION_SEAISLAND, true, \"Mullins\", \"MULLINS (985F)\" },\n\n    // Iceland/Topaz\n    { GDT_ICELAND, 0x6900, 0x00, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Iceland\", \"AMD Radeon R7 M260\" },\n    { GDT_ICELAND, 0x6900, 0x81, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Iceland\", \"AMD Radeon (TM) R7 M360\" },\n    { GDT_ICELAND, 0x6900, 0x83, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Iceland\", \"AMD Radeon (TM) R7 M340\" },\n    { GDT_ICELAND, 0x6900, 0x87, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Iceland\", \"MESO UL (6900)\" },\n    { GDT_ICELAND, 0x6900, 0xC1, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Iceland\", \"AMD Radeon R5 M465 Series\" },\n    { GDT_ICELAND, 0x6900, 0xC3, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Iceland\", \"AMD Radeon R5 M445 Series\" },\n    { GDT_ICELAND, 0x6901, 0x00, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Iceland\", \"AMD Radeon R5 M255\" },\n    { GDT_ICELAND, 0x6902, 0x00, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Iceland\", \"AMD Radeon Series\" },\n    { GDT_ICELAND, 0x6903, 0x00, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Iceland\", \"Not Used\" },\n    { GDT_ICELAND, 0x6907, 0x00, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Iceland\", \"AMD Radeon R5 M255\" },\n    { GDT_ICELAND, 0x6907, 0x87, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Iceland\", \"AMD Radeon (TM) R5 M315\" },\n\n    // Tonga\n    { GDT_TONGA, 0x6920, 0x00, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Tonga\", \"AMD RADEON R9 M395X\" },\n    { GDT_TONGA, 0x6920, 0x01, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Tonga\", \"AMD RADEON R9 M390X\" },\n    { GDT_TONGA, 0x6921, 0x00, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Tonga\", \"AMD Radeon (TM) R9 M390X\" },\n    //{ GDT_TONGA, 0x6928, 0x00, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Tonga\", \"\" },\n    { GDT_TONGA, 0x6929, 0x00, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Tonga\", \"AMD FirePro S7150\" },\n    { GDT_TONGA, 0x6929, 0x01, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Tonga\", \"AMD FirePro S7100\" },\n    { GDT_TONGA, 0x692B, 0x00, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Tonga\", \"AMD FirePro W7100\" },\n    { GDT_TONGA, 0x692F, 0x00, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Tonga\", \"AMD FirePro S7150VF\" },\n    { GDT_TONGA, 0x6930, 0xF0, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Tonga\", \"DID:6930 RID:F0\" },\n    { GDT_TONGA, 0x6930, 0xF1, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Tonga\", \"DID:6930 RID:F1\" },\n    { GDT_TONGA, 0x6930, 0xFF, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Tonga\", \"DID:6930 RID:FF\" },\n    { GDT_TONGA, 0x6938, 0x00, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Tonga\", \"AMD Radeon R9 200 Series\" },\n    { GDT_TONGA, 0x6938, 0xF1, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Tonga\", \"AMD Radeon (TM) R9 380 Series\" },\n    { GDT_TONGA, 0x6938, 0xF0, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Tonga\", \"AMD Radeon R9 200 Series\" },\n    { GDT_TONGA, 0x6939, 0x00, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Tonga\", \"AMD Radeon R9 200 Series\" },\n    { GDT_TONGA, 0x6939, 0xF0, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Tonga\", \"AMD Radeon R9 200 Series\" },\n    { GDT_TONGA, 0x6939, 0xF1, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Tonga\", \"AMD Radeon (TM) R9 380 Series\" },\n\n    // Carrizo\n    { GDT_CARRIZO, 0x9870, 0x00, GDT_HW_GENERATION_VOLCANICISLAND, true, \"Carrizo\", \"CARRIZO 9870\" },\n    { GDT_CARRIZO, 0x9874, 0x00, GDT_HW_GENERATION_VOLCANICISLAND, true, \"Carrizo\", \"CARRIZO 9874\" },\n    { GDT_CARRIZO, 0x9874, 0xC4, GDT_HW_GENERATION_VOLCANICISLAND, true, \"Carrizo\", \"AMD Radeon R7 Graphics\" },\n    { GDT_CARRIZO, 0x9874, 0xC5, GDT_HW_GENERATION_VOLCANICISLAND, true, \"Carrizo\", \"AMD Radeon R6 Graphics\" },\n    { GDT_CARRIZO, 0x9874, 0xC6, GDT_HW_GENERATION_VOLCANICISLAND, true, \"Carrizo\", \"AMD Radeon R6 Graphics\" },\n    { GDT_CARRIZO, 0x9874, 0xC7, GDT_HW_GENERATION_VOLCANICISLAND, true, \"Carrizo\", \"AMD Radeon R5 Graphics\" },\n    { GDT_CARRIZO_EMB, 0x9874, 0x84, GDT_HW_GENERATION_VOLCANICISLAND, true, \"Carrizo\", \"AMD Radeon R7 Graphics\" },\n    { GDT_CARRIZO_EMB, 0x9874, 0x85, GDT_HW_GENERATION_VOLCANICISLAND, true, \"Carrizo\", \"AMD Radeon R6 Graphics\" },\n    { GDT_CARRIZO_EMB, 0x9874, 0x87, GDT_HW_GENERATION_VOLCANICISLAND, true, \"Carrizo\", \"AMD Radeon R5 Graphics\" },\n    { GDT_CARRIZO_EMB, 0x9874, 0x81, GDT_HW_GENERATION_VOLCANICISLAND, true, \"Carrizo\", \"AMD Radeon R6 Graphics\" },\n    { GDT_CARRIZO_EMB, 0x9874, 0x88, GDT_HW_GENERATION_VOLCANICISLAND, true, \"Carrizo\", \"AMD Radeon R7E Graphics\" },\n    { GDT_CARRIZO_EMB, 0x9874, 0x89, GDT_HW_GENERATION_VOLCANICISLAND, true, \"Carrizo\", \"AMD Radeon R6E Graphics\" },\n    { GDT_CARRIZO, 0x9874, 0xC8, GDT_HW_GENERATION_VOLCANICISLAND, true, \"Carrizo\", \"AMD Radeon(TM) R7 Graphics\" },\n    { GDT_CARRIZO, 0x9874, 0xC9, GDT_HW_GENERATION_VOLCANICISLAND, true, \"Carrizo\", \"AMD Radeon(TM) R6 Graphics\" },\n    { GDT_CARRIZO, 0x9874, 0xCA, GDT_HW_GENERATION_VOLCANICISLAND, true, \"Carrizo\", \"AMD Radeon(TM) R6 Graphics\" },\n    { GDT_CARRIZO, 0x9874, 0xCB, GDT_HW_GENERATION_VOLCANICISLAND, true, \"Carrizo\", \"AMD Radeon(TM) R5 Graphics\" },\n    { GDT_CARRIZO, 0x9874, 0xCC, GDT_HW_GENERATION_VOLCANICISLAND, true, \"Carrizo\", \"AMD Radeon(TM) R7 Graphics\" },\n    { GDT_CARRIZO, 0x9874, 0xCD, GDT_HW_GENERATION_VOLCANICISLAND, true, \"Carrizo\", \"AMD Radeon(TM) R6 Graphics\" },\n    { GDT_CARRIZO, 0x9874, 0xCE, GDT_HW_GENERATION_VOLCANICISLAND, true, \"Carrizo\", \"AMD Radeon(TM) R6 Graphics\" },\n    { GDT_CARRIZO, 0x9874, 0xE1, GDT_HW_GENERATION_VOLCANICISLAND, true, \"Carrizo\", \"AMD Radeon(TM) R7 Graphics\" },\n    { GDT_CARRIZO, 0x9874, 0xE2, GDT_HW_GENERATION_VOLCANICISLAND, true, \"Carrizo\", \"AMD Radeon(TM) R6 Graphics\" },\n    { GDT_CARRIZO, 0x9874, 0xE3, GDT_HW_GENERATION_VOLCANICISLAND, true, \"Carrizo\", \"AMD Radeon(TM) R7 Graphics\" },\n    { GDT_CARRIZO, 0x9874, 0xE4, GDT_HW_GENERATION_VOLCANICISLAND, true, \"Carrizo\", \"AMD Radeon(TM) R6 Graphics\" },\n    { GDT_CARRIZO, 0x9874, 0xE5, GDT_HW_GENERATION_VOLCANICISLAND, true, \"Carrizo\", \"AMD Radeon(TM) R5 Graphics\" },\n\n    { GDT_CARRIZO, 0x9875, 0x00, GDT_HW_GENERATION_VOLCANICISLAND, true, \"Carrizo\", \"CARRIZO 9875\" },\n    { GDT_CARRIZO, 0x9876, 0x00, GDT_HW_GENERATION_VOLCANICISLAND, true, \"Carrizo\", \"CARRIZO 9876\" },\n    { GDT_CARRIZO, 0x9877, 0x00, GDT_HW_GENERATION_VOLCANICISLAND, true, \"Carrizo\", \"CARRIZO 9877\" },\n\n    // Fiji\n    { GDT_FIJI, 0x7300, 0x00, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Fiji\", \"AMD Radeon (TM) Graphics Processor\" },\n    { GDT_FIJI, 0x7300, 0xC1, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Fiji\", \"AMD FirePro Processor\" },\n    { GDT_FIJI, 0x7300, 0xC8, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Fiji\", \"AMD Radeon (TM) R9 Fury Series\" },\n    { GDT_FIJI, 0x7300, 0xCB, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Fiji\", \"AMD Radeon (TM) R9 Fury Series\" },\n    { GDT_FIJI, 0x7300, 0xC9, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Fiji\", \"AMD Radeon (TM) Graphics Processor\" },\n    { GDT_FIJI, 0x7300, 0xC0, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Fiji\", \"AMD Radeon Graphics Processor\" },\n    { GDT_FIJI, 0x7300, 0xCA, GDT_HW_GENERATION_VOLCANICISLAND, false, \"Fiji\", \"AMD Radeon (TM) R9 Fury Series\" },\n};\n\n/// NOTE: Don't update the table below, it's generated from the csv file.\n/// How to update this table:\n/// 1. Update device info in the CSV file\n/// 2. Run deviceinfogen.exe\n/// 3. Replace GDT_DeviceInfo gs_deviceInfo[] in DeviceInfo.cpp with the content of generated file device_info_table.txt\nstatic GDT_DeviceInfo gs_deviceInfo[] =\n{\n    { 2, 10, 1, 8, 2, 64, 2, 7, 4, true }, // GDT_TAHITI_PRO\n    { 2, 10, 1, 8, 2, 64, 2, 8, 4, true }, // GDT_TAHITI_XT\n    { 2, 10, 1, 8, 2, 64, 2, 4, 4, true }, // GDT_PITCAIRN_PRO\n    { 2, 10, 1, 8, 2, 64, 2, 5, 4, true }, // GDT_PITCAIRN_XT\n    { 1, 10, 1, 8, 1, 64, 2, 4, 4, true }, // GDT_CAPEVERDE_PRO\n    { 1, 10, 1, 8, 1, 64, 2, 5, 4, true }, // GDT_CAPEVERDE_XT\n    { 1, 10, 1, 8, 1, 64, 1, 6, 4, true }, // GDT_OLAND\n    { 1, 10, 1, 8, 1, 64, 1, 5, 4, true }, // GDT_HAINAN\n    { 2, 10, 1, 8, 2, 64, 1, 7, 4, true }, // GDT_BONAIRE\n    { 4, 10, 1, 8, 4, 64, 1, 11, 4, true }, // GDT_HAWAII\n    { 1, 10, 1, 8, 1, 64, 1, 2, 4, true }, // GDT_KALINDI\n    { 1, 10, 1, 8, 1, 64, 1, 8, 4, true }, // GDT_SPECTRE\n    { 1, 10, 1, 8, 1, 64, 1, 4, 4, true }, // GDT_SPECTRE_SL\n    { 1, 10, 1, 8, 1, 64, 1, 6, 4, true }, // GDT_SPECTRE_LITE\n    { 1, 10, 1, 8, 1, 64, 1, 3, 4, true }, // GDT_SPOOKY\n    { 1, 10, 1, 8, 1, 64, 1, 6, 4, true }, // GDT_ICELAND\n    { 4, 10, 1, 8, 4, 64, 1, 8, 4, true }, // GDT_TONGA\n    { 1, 10, 1, 8, 1, 64, 1, 8, 4, true }, // GDT_CARRIZO\n    { 1, 10, 1, 8, 1, 64, 1, 3, 4, true }, // GDT_CARRIZO_EM\n    { 4, 10, 1, 8, 4, 64, 1, 16, 4, true }, // GDT_FIJI\n    { 0, 0, 0, 0, 0, 0, 0, 0, 0, false }, // GDT_STONEY placeholder\n};\n\nstatic size_t gs_cardInfoSize = sizeof(gs_cardInfo) / sizeof(GDT_GfxCardInfo);\nstatic size_t gs_deviceInfoSize = sizeof(gs_deviceInfo) / sizeof(GDT_DeviceInfo);\n\nAMDTDeviceInfoManager::AMDTDeviceInfoManager()\n{\n    AMDTDeviceInfoUtils* pDeviceInfoUtils = AMDTDeviceInfoUtils::Instance();\n\n    for (size_t i = 0; i < gs_cardInfoSize; ++i)\n    {\n        pDeviceInfoUtils->AddDevice(gs_cardInfo[i]);\n    }\n\n    for (size_t i = 0; i < gs_deviceInfoSize; ++i)\n    {\n        pDeviceInfoUtils->AddDeviceInfo(static_cast<GDT_HW_ASIC_TYPE>(i), gs_deviceInfo[i]);\n    }\n\n    CallInitInternalDeviceInfo();\n}\n\nAMDTDeviceInfoManager::~AMDTDeviceInfoManager()\n{}\n\n#ifdef _WIN32\n    extern \"C\" IMAGE_DOS_HEADER __ImageBase;\n    #define HINST_THISCOMPONENT ((HINSTANCE)&__ImageBase)\n#endif\n\nvoid AMDTDeviceInfoManager::CallInitInternalDeviceInfo() const\n{\n    static const char* initFuncName = \"InitInternalDeviceInfo\";\n    static bool initFuncCalled = false;\n    if (!initFuncCalled)\n    {\n        typedef void(*DeviceInfoUtilsReadyFunc)();\n        DeviceInfoUtilsReadyFunc func = nullptr;\n#ifdef _WIN32\n        func = (DeviceInfoUtilsReadyFunc)GetProcAddress(HINST_THISCOMPONENT, initFuncName);\n#endif\n#ifdef _LINUX\n        func = (DeviceInfoUtilsReadyFunc)dlsym(nullptr, initFuncName);\n#endif\n        if (nullptr != func)\n        {\n            func();\n            initFuncCalled = true;\n        }\n    }\n}\n\nbool AMDTDeviceInfoUtils::GetDeviceInfo(size_t deviceID, size_t revisionID, GDT_DeviceInfo& deviceInfo) const\n{\n    bool found = false;\n\n    for (auto it = m_deviceIDMap.find(deviceID); it != m_deviceIDMap.end() && !found; ++it)\n    {\n        size_t thisRevId = (*it).second.m_revID;\n\n        if (thisRevId == revisionID)\n        {\n            for (auto itr = m_asicTypeDeviceInfoMap.find((*it).second.m_asicType); itr != m_asicTypeDeviceInfoMap.end() && !found; ++itr)\n            {\n                deviceInfo = itr->second;\n\n                if (deviceInfo.m_deviceInfoValid)\n                {\n                    found = true;\n                }\n            }\n        }\n    }\n\n    return found;\n}\n\n/// NOTE: this might not return the correct GDT_DeviceInfo instance, since some devices with the same CAL name might have different GDT_DeviceInfo instances\nbool AMDTDeviceInfoUtils::GetDeviceInfo(const char* szCALDeviceName, GDT_DeviceInfo& deviceInfo) const\n{\n    std::string strDeviceName = TranslateDeviceName(szCALDeviceName);\n\n    auto it = m_deviceNameMap.find(strDeviceName.c_str());\n\n    if (it != m_deviceNameMap.end())\n    {\n        auto deviceIt = m_asicTypeDeviceInfoMap.find(it->second.m_asicType);\n\n        if (m_asicTypeDeviceInfoMap.end() != deviceIt)\n        {\n            deviceInfo = deviceIt->second;\n\n            if (deviceInfo.m_deviceInfoValid)\n            {\n                return true;\n            }\n        }\n    }\n\n    return false;\n}\n\nbool AMDTDeviceInfoUtils::GetDeviceInfo(size_t deviceID, size_t revisionID, GDT_GfxCardInfo& cardInfo) const\n{\n    bool found = false;\n\n    for (auto it = m_deviceIDMap.find(deviceID); it != m_deviceIDMap.end() && !found; ++it)\n    {\n        size_t thisRevId = (*it).second.m_revID;\n\n        if (thisRevId == revisionID)\n        {\n            cardInfo = (*it).second;\n            found = true;\n        }\n    }\n\n    return found;\n}\n\nbool AMDTDeviceInfoUtils::GetDeviceInfo(const char* szCalName, vector<GDT_GfxCardInfo>& cardList) const\n{\n    std::string strDeviceName = TranslateDeviceName(szCalName);\n\n    cardList.clear();\n    pair<DeviceNameMap::const_iterator, DeviceNameMap::const_iterator> matches;\n    matches = m_deviceNameMap.equal_range(strDeviceName.c_str());\n\n    for (auto it = matches.first; it != matches.second; ++it)\n    {\n        cardList.push_back((*it).second);\n    }\n\n    return !cardList.empty();\n}\n\nbool AMDTDeviceInfoUtils::GetDeviceInfoMarketingName(const char* szMarketingName, vector<GDT_GfxCardInfo>& cardList) const\n{\n    cardList.clear();\n    pair<DeviceNameMap::const_iterator, DeviceNameMap::const_iterator> matches;\n    matches = m_deviceMarketingNameMap.equal_range(szMarketingName);\n\n    for (auto it = matches.first; it != matches.second; ++it)\n    {\n        cardList.push_back((*it).second);\n    }\n\n    return !cardList.empty();\n}\n\nbool AMDTDeviceInfoUtils::IsAPU(const char* szCALDeviceName, bool& bIsAPU) const\n{\n    std::string strDeviceName = TranslateDeviceName(szCALDeviceName);\n\n    auto it = m_deviceNameMap.find(strDeviceName.c_str());\n\n    if (it != m_deviceNameMap.end())\n    {\n        bIsAPU = it->second.m_bAPU;\n        return true;\n    }\n    else\n    {\n        return false;\n    }\n}\n\nbool AMDTDeviceInfoUtils::GetHardwareGeneration(size_t deviceID, GDT_HW_GENERATION& gen) const\n{\n    // revId not needed here, since all revs will have the same hardware family\n    auto it = m_deviceIDMap.find(deviceID);\n\n    if (it != m_deviceIDMap.end())\n    {\n        gen = it->second.m_generation;\n        return true;\n    }\n    else\n    {\n        return false;\n    }\n}\n\nbool AMDTDeviceInfoUtils::GetHardwareGeneration(const char* szName, GDT_HW_GENERATION& gen) const\n{\n    std::string strDeviceName = TranslateDeviceName(szName);\n\n    auto it = m_deviceNameMap.find(strDeviceName.c_str());\n\n    if (it != m_deviceNameMap.end())\n    {\n        gen = it->second.m_generation;\n        return true;\n    }\n    else\n    {\n        return false;\n    }\n}\n\nbool AMDTDeviceInfoUtils::GetAllCardsInHardwareGeneration(GDT_HW_GENERATION gen, std::vector<GDT_GfxCardInfo>& cardList) const\n{\n    cardList.clear();\n    pair<DeviceHWGenerationMap::const_iterator, DeviceHWGenerationMap::const_iterator> matches;\n    matches = m_deviceHwGenerationMap.equal_range(gen);\n\n    for (auto it = matches.first; it != matches.second; ++it)\n    {\n        cardList.push_back((*it).second);\n    }\n\n    return !cardList.empty();\n}\n\nbool AMDTDeviceInfoUtils::GetAllCardsWithDeviceId(size_t deviceID, std::vector<GDT_GfxCardInfo>& cardList) const\n{\n    cardList.clear();\n    pair<DeviceIDMap::const_iterator, DeviceIDMap::const_iterator> matches;\n    matches = m_deviceIDMap.equal_range(deviceID);\n\n    for (auto it = matches.first; it != matches.second; ++it)\n    {\n        cardList.push_back((*it).second);\n    }\n\n    return !cardList.empty();\n}\n\nbool AMDTDeviceInfoUtils::GetHardwareGenerationDisplayName(GDT_HW_GENERATION gen, std::string& strGenerationDisplayName) const\n{\n    static const std::string s_SI_FAMILY_NAME = \"Graphics IP v6\";\n    static const std::string s_CI_FAMILY_NAME = \"Graphics IP v7\";\n    static const std::string s_VI_FAMILY_NAME = \"Graphics IP v8\";\n\n    bool retVal = true;\n\n    switch (gen)\n    {\n        case GDT_HW_GENERATION_SOUTHERNISLAND:\n            strGenerationDisplayName = s_SI_FAMILY_NAME;\n            break;\n\n        case GDT_HW_GENERATION_SEAISLAND:\n            strGenerationDisplayName = s_CI_FAMILY_NAME;\n            break;\n\n        case GDT_HW_GENERATION_VOLCANICISLAND:\n            strGenerationDisplayName = s_VI_FAMILY_NAME;\n            break;\n\n        default:\n            strGenerationDisplayName.clear();\n            retVal = false;\n            break;\n    }\n\n    return retVal;\n}\n\nstd::string AMDTDeviceInfoUtils::TranslateDeviceName(const char* strDeviceName) const\n{\n    std::string retVal(strDeviceName);\n\n    if (nullptr != m_pDeviceNameTranslatorFunction)\n    {\n        retVal = m_pDeviceNameTranslatorFunction(strDeviceName);\n    }\n\n    return retVal;\n}\n\nAMDTDeviceInfoUtils* AMDTDeviceInfoUtils::ms_pInstance = nullptr;\nAMDTDeviceInfoManager AMDTDeviceInfoManager::ms_instance;\n\nvoid AMDTDeviceInfoUtils::AddDeviceInfo(GDT_HW_ASIC_TYPE asicType, const GDT_DeviceInfo& deviceInfo)\n{\n    if (m_asicTypeDeviceInfoMap.end() == m_asicTypeDeviceInfoMap.find(asicType))\n    {\n        m_asicTypeDeviceInfoMap.insert(ASICTypeDeviceInfoMapPair(asicType, deviceInfo));\n    }\n    else\n    {\n        m_asicTypeDeviceInfoMap[asicType] = deviceInfo;\n    }\n}\n\nvoid AMDTDeviceInfoUtils::AddDevice(const GDT_GfxCardInfo& cardInfo)\n{\n    m_deviceIDMap.insert(DeviceIDMapPair(cardInfo.m_deviceID, cardInfo));\n    m_deviceNameMap.insert(DeviceNameMapPair(cardInfo.m_szCALName, cardInfo));\n    m_deviceMarketingNameMap.insert(DeviceNameMapPair(cardInfo.m_szMarketingName, cardInfo));\n    m_deviceHwGenerationMap.insert(DeviceHWGenerationMapPair(cardInfo.m_generation, cardInfo));\n}\n\nvoid AMDTDeviceInfoUtils::SetDeviceNameTranslator(DeviceNameTranslatorFunction deviceNametranslatorFunction)\n{\n    m_pDeviceNameTranslatorFunction = deviceNametranslatorFunction;\n}\n"
  },
  {
    "path": "src/Wrapper/amd-codexl-analyzer/Common/Src/DeviceInfo/DeviceInfoUtils.h",
    "content": "//=====================================================================\n// Copyright 2010-2016 (c), Advanced Micro Devices, Inc. All rights reserved.\n//\n/// \\author AMD Developer Tools Team\n/// \\file DeviceInfoUtils.h \n/// \\brief  Device info utils class\n/// \n//=====================================================================\n#ifndef _DEVICE_INFO_UTILS_H_\n#define _DEVICE_INFO_UTILS_H_\n\n#include <string>\n#include <cstring>\n#include <map>\n#include <vector>\n#include <DeviceInfo.h>\n\n//------------------------------------------------------------------------------------\n/// Device info utils\n//------------------------------------------------------------------------------------\nclass AMDTDeviceInfoUtils\n{\npublic:\n\n    /// Get AMDTDeviceInfoUtils instance\n    /// \\return the dynamically created AMDTDeviceInfoUtils instance\n    static AMDTDeviceInfoUtils* Instance()\n    {\n        if (nullptr == ms_pInstance)\n        {\n            ms_pInstance = new AMDTDeviceInfoUtils();\n        }\n\n        return ms_pInstance;\n    }\n\n    /// Deletes the AMDTDeviceInfoUtils instance\n    static void DeleteInstance()\n    {\n        delete ms_pInstance;\n        ms_pInstance = nullptr;\n    }\n\n    /// Adds the specified device info\n    /// \\param asicType the asic type of the device info being added\n    /// \\param deviceInfo the device info being added\n    void AddDeviceInfo(GDT_HW_ASIC_TYPE asicType, const GDT_DeviceInfo& deviceInfo);\n\n    /// Adds the specified card info\n    /// \\param cardInfo the card being added\n    void AddDevice(const GDT_GfxCardInfo& cardInfo);\n\n    /// Function pointer type for a function that will translate device names\n    typedef std::string(*DeviceNameTranslatorFunction)(const char* strDeviceName);\n\n    /// Sets the Device name translator function\n    /// \\param deviceNametranslatorFunction the function to use to translate device names\n    void SetDeviceNameTranslator(DeviceNameTranslatorFunction deviceNametranslatorFunction);\n\n    /// Get device info from device ID\n    /// \\param[in] deviceID Device ID - usually queried from ADL\n    /// \\param[in] revisionID RevisionID - usually queried from ADL\n    /// \\param[out] deviceInfo Output device info if device id is found.\n    /// \\return True if device info is found\n    bool GetDeviceInfo(size_t deviceID, size_t revisionID, GDT_DeviceInfo& deviceInfo) const;\n\n    /// Get device info from CAL name string\n    /// NOTE: this might not return the correct GDT_DeviceInfo instance, since some devices with the same CAL name might have different GDT_DeviceInfo instances\n    /// \\param[in] szCALDeviceName CAL device name string\n    /// \\param[out] deviceInfo Output device info if device id is found.\n    /// \\return True if device info is found\n    bool GetDeviceInfo(const char* szCALDeviceName, GDT_DeviceInfo& deviceInfo) const;\n\n    /// Get Graphics Card Info.\n    /// \\param[in] deviceID Device ID - usually queried from ADL\n    /// \\param[in] revisionID Revision ID - usually queried from ADL\n    /// \\param[out] cardInfo Output graphics card info if device id is found.\n    /// \\return True if info for deviceID is found\n    bool GetDeviceInfo(size_t deviceID, size_t revisionID, GDT_GfxCardInfo& cardInfo) const;\n\n    /// Get a vector of Graphics Card Info.\n    /// \\param[in] szCALDeviceName CAL device name string\n    /// \\param[out] cardList Output vector of graphics card info.\n    /// \\return True if any graphics card info is found for CAL device name.\n    bool GetDeviceInfo(const char* szCALDeviceName, std::vector<GDT_GfxCardInfo>& cardList) const;\n\n    /// Get a vector of Graphics Card Info.\n    /// \\param[in]  szMarketingDeviceName Marketing device name string\n    /// \\param[out] cardList Output vector of graphics card info.\n    /// \\return True if any graphics card info is found for Marketing device name.\n    bool GetDeviceInfoMarketingName(const char* szMarketingDeviceName, std::vector<GDT_GfxCardInfo>& cardList) const;\n\n    /// Query whether or not input device is APU or not\n    /// \\param[in] szCALDeviceName CAL device name string\n    /// \\param[out] bIsAPU flag indicating whether or not the specified device is an APU\n    /// \\return True if device info is found\n    bool IsAPU(const char* szCALDeviceName, bool& bIsAPU) const;\n\n    /// Get hardware generation from device ID\n    /// \\param[in] deviceID Device id\n    /// \\param[out] gen Hardware generation\n    /// \\return True if device info is found\n    bool GetHardwareGeneration(size_t deviceID, GDT_HW_GENERATION& gen) const;\n\n    /// Get hardware generation from device name\n    /// \\param[in] szCALDeviceName Device name\n    /// \\param[out] gen Hardware generation\n    /// \\return True if device info is found\n    bool GetHardwareGeneration(const char* szCALDeviceName, GDT_HW_GENERATION& gen) const;\n\n    /// Get all cards from the specified hardware generation\n    /// \\param[in] gen Hardware generation\n    /// \\param[out] cardList Output vector of graphics card info.\n    /// \\return true if successful, false otherwise\n    bool GetAllCardsInHardwareGeneration(GDT_HW_GENERATION gen, std::vector<GDT_GfxCardInfo>& cardList) const;\n\n    /// Get all cards with the specified device id\n    /// \\param[in] deviceId DeviceId\n    /// \\param[out] cardList Output vector of graphics card info.\n    /// \\return true if successful, false otherwise\n    bool GetAllCardsWithDeviceId(size_t deviceID, std::vector<GDT_GfxCardInfo>& cardList) const;\n\n    /// Get hardware generation display name\n    /// \\param[in] gen Hardware generation\n    /// \\param[out] strGenerationDisplayName the display name for the specified hardware generation\n    /// \\return true if successful, false otherwise\n    bool GetHardwareGenerationDisplayName(GDT_HW_GENERATION gen, std::string& strGenerationDisplayName) const;\n\n    /// Determine if the specified device is a member of the specified family\n    /// \\param[in] szCALDeviceName CAL device name\n    /// \\param[in] generation Generation enum\n    /// \\param[out] bRes Set to true if input device name is a specified family card\n    /// \\return false if device name is not found\n    bool IsXFamily(const char* szCALDeviceName, GDT_HW_GENERATION generation, bool& bRes) const\n    {\n        GDT_HW_GENERATION gen = GDT_HW_GENERATION_NONE;\n\n        if (GetHardwareGeneration(szCALDeviceName, gen))\n        {\n            bRes = gen == generation;\n            return true;\n        }\n        else\n        {\n            return false;\n        }\n    }\n\n    /// Determine if the specified device is a member of the VI family\n    /// \\param[in] szCALDeviceName CAL device name\n    /// \\param[out] bIsVI Set to true if input device name is a member of the VI family\n    /// \\return false if device name is not found\n    bool IsVIFamily(const char* szCALDeviceName, bool& bIsVI) const\n    {\n        return IsXFamily(szCALDeviceName, GDT_HW_GENERATION_VOLCANICISLAND, bIsVI);\n    }\n\n    /// Determine if the specified device is a member of the CI family\n    /// \\param[in] szCALDeviceName CAL device name\n    /// \\param[out] bIsCI Set to true if input device name is a member of the CI family\n    /// \\return false if device name is not found\n    bool IsCIFamily(const char* szCALDeviceName, bool& bIsCI) const\n    {\n        return IsXFamily(szCALDeviceName, GDT_HW_GENERATION_SEAISLAND, bIsCI);\n    }\n\n    /// Determine if the specified device is a member of the SI family\n    /// \\param[in] szCALDeviceName CAL device name\n    /// \\param[out] bIsSI Set to true if input device name is a member of the SI family\n    /// \\return false if device name is not found\n    bool IsSIFamily(const char* szCALDeviceName, bool& bIsSI) const\n    {\n        return IsXFamily(szCALDeviceName, GDT_HW_GENERATION_SOUTHERNISLAND, bIsSI);\n    }\n\n    /// Determine if the specified device is based on GCN architecture.\n    /// \\param[in] szCALDeviceName CAL device name\n    /// \\param[out] bIsGCN Set to true if input device name is based on GCN architecture.\n    /// \\return false if device name is not found\n    bool IsGCN(const char* szCALDeviceName, bool& bIsGCN) const\n    {\n        bIsGCN = false;\n        bool bRet = IsVIFamily(szCALDeviceName, bIsGCN);\n\n        if (!bIsGCN)\n        {\n            bRet = IsCIFamily(szCALDeviceName, bIsGCN);\n        }\n\n        if (!bIsGCN)\n        {\n            bRet = IsSIFamily(szCALDeviceName, bIsGCN);\n        }\n\n        return bRet;\n    }\n\n    /// Gets the number of SX blocks in a specific piece of hardware. This is used to override the device base info\n    /// \\param pDeviceInfo The device info\n    /// \\param generation The hardware generation\n    /// \\return The number of SX blocks\n    size_t GetNumSX(const GDT_DeviceInfo* pDeviceInfo, GDT_HW_GENERATION generation)\n    {\n        // We need to figure out how many SX (pixel shader cross bars) there are\n        size_t numSX = 0;\n\n        if (generation == GDT_HW_GENERATION_SEAISLAND)\n        {\n            numSX = pDeviceInfo->m_nNumShaderEngines * pDeviceInfo->m_nNumSHPerSE;\n        }\n        else\n        {\n            // All other HW uses the following:\n            numSX = pDeviceInfo->m_nNumShaderEngines * 2;\n        }\n\n        return numSX;\n    }\n\n    /// Translates the reported device name to the true device name exposed in the DeviceInfo table.\n    /// \\param strDeviceName the device name reported by the runtime.\n    /// \\return the true device name as exposed by the device info table.\n    std::string TranslateDeviceName(const char* strDeviceName) const;\n\nprivate:\n    /// private constructor\n    AMDTDeviceInfoUtils() : m_pDeviceNameTranslatorFunction(nullptr) {}\n\n    /// private destructor\n    virtual ~AMDTDeviceInfoUtils() {}\n\n    //------------------------------------------------------------------------------------\n    /// const char* comparer used in the DeviceNameMap below\n    //------------------------------------------------------------------------------------\n    struct cmp_str\n    {\n        /// Operator () overload function\n        /// \\param a left operand\n        /// \\param b right operand\n        /// \\return true if a is less than b\n        bool operator()(const char* a, const char* b) const\n        {\n            return std::strcmp(a, b) < 0;\n        }\n    };\n\n    typedef std::multimap<size_t, GDT_GfxCardInfo> DeviceIDMap;                        ///< typedef for map from device id to card info\n    typedef std::pair<size_t, GDT_GfxCardInfo> DeviceIDMapPair;                        ///< typedef for device id / card info pair\n\n    typedef std::multimap<const char*, GDT_GfxCardInfo, cmp_str> DeviceNameMap;        ///< typedef for map from CAL device name to card info (with custom comparer)\n    typedef std::pair<const char*, GDT_GfxCardInfo> DeviceNameMapPair;                 ///< typedef for device name / card info pair\n\n    typedef std::multimap<GDT_HW_GENERATION, GDT_GfxCardInfo> DeviceHWGenerationMap;   ///< typedef for map from hardware generation to card info\n    typedef std::pair<GDT_HW_GENERATION, GDT_GfxCardInfo> DeviceHWGenerationMapPair;   ///< typedef for hardware generation / card info pair\n\n    typedef std::map<GDT_HW_ASIC_TYPE, GDT_DeviceInfo> ASICTypeDeviceInfoMap;          ///< typedef for map from asic type to device info\n    typedef std::pair<GDT_HW_ASIC_TYPE, GDT_DeviceInfo> ASICTypeDeviceInfoMapPair;     ///< typedef for asic type / device info pair\n\n    DeviceIDMap           m_deviceIDMap;            ///< device ID to card info map.\n    DeviceNameMap         m_deviceNameMap;          ///< cal device name to card info map.\n    DeviceNameMap         m_deviceMarketingNameMap; ///< marketing device name to card info map.\n    DeviceHWGenerationMap m_deviceHwGenerationMap;  ///< hardware generation to card info map.\n    ASICTypeDeviceInfoMap m_asicTypeDeviceInfoMap;  ///< ASIC type to device info map.\n\n    DeviceNameTranslatorFunction m_pDeviceNameTranslatorFunction; /// the function to call to translate device names\n\n    static AMDTDeviceInfoUtils* ms_pInstance;\n};\n\n//------------------------------------------------------------------------------------\n/// Device info manager\n//------------------------------------------------------------------------------------\nclass AMDTDeviceInfoManager\n{\n    /// Get singleton AMDTDeviceInfoManager instance\n    /// \\return the singleton AMDTDeviceInfoManager instance\n    static AMDTDeviceInfoManager* Instance()\n    {\n        return &ms_instance;\n    }\n\nprivate:\n\n    /// Constructor\n    AMDTDeviceInfoManager();\n\n    /// Destructor\n    ~AMDTDeviceInfoManager();\n\n    /// Locates and calls the device info utils function to initialize internal device info.\n    /// This allows internal versions of the tools to expose hardware not exposed in the public\n    /// versions of the tools (i.e. unreleased hardware)\n    void CallInitInternalDeviceInfo() const;\n\n    static AMDTDeviceInfoManager ms_instance; ///< the singleton AMDTDeviceInfoManager instance\n};\n\n#endif // _DEVICE_INFO_UTILS_H_\n"
  },
  {
    "path": "src/Wrapper/amd-codexl-analyzer/CommonProjects/AMDTBackend/Include/Common/AmdDxGsaCompile.h",
    "content": "//==============================================================================\n// Copyright 2012-2016 (c), Advanced Micro Devices, Inc. All rights reserved.\n//\n/// \\author AMD Developer Tools Team\n/// \\file \n/// \\brief Backdoor GSA compile extension include file.\n//==============================================================================\n\n#ifndef _AMDDXGSACOMPILE_H_\n#define _AMDDXGSACOMPILE_H_\n\n#include <windows.h>\n\n#if defined(__cplusplus)\nextern \"C\"\n{\n#endif\n\n\n/**\n***************************************************************************************************\n* @brief Identifies compile options to be modified in AmdDxGsaCompileShader() call.\n***************************************************************************************************\n*/\ntypedef enum _AmdDxGsaCompileOptionEnum\n{\n    AmdDxGsaBiasScheduleToMinimizeRegs,\n    AmdDxGsaNoIfConversion,\n    AmdDxGsaIfConversionGuarantee,\n    AmdDxGsaIfConversionHeuristic,\n    AmdDxGsaIfConversionHeuristicOgl,\n    AmdDxGsaIfConversionAlways,\n    AmdDxGsaCompileOptionLast\n} AmdDxGsaCompileOptionEnum;\n\n/**\n***************************************************************************************************\n* @brief Compiler settings/value pair specified in AmdDxGsaCompileShader() calls.\n***************************************************************************************************\n*/\ntypedef struct _AmdDxGsaCompileOption\n{\n    AmdDxGsaCompileOptionEnum setting;\n    INT                       value;\n} AmdDxGsaCompileOption;\n\n/**\n***************************************************************************************************\n* @brief Stats about the compiled shader. This structure will be stored in the .stats ELF section\n***************************************************************************************************\n*/\ntypedef struct _AmdDxGsaCompileStats\n{\n    UINT numSgprsUsed;\n    UINT availableSgprs;\n    UINT numVgprsUsed;\n    UINT availableVgprs;\n    UINT usedLdsBytes;\n    UINT availableLdsBytes;\n    UINT usedScratchBytes;\n    UINT numAluInst;         ///< Number of ALU instructions in the shader\n    UINT numControlFlowInst; ///< Number of control flow instructions in the shader\n    UINT numTfetchInst;      ///< Number of HW TFETCHinstructions / Tx Units used\n    UINT reserved[6];\n} AmdDxGsaCompileStats;\n\n/**\n***************************************************************************************************\n* @brief AmdDxGsaCompileShader() input structure.\n***************************************************************************************************\n*/\ntypedef struct _AmdDxGsaCompileShaderInput\n{\n    /// Target GPU chip family (defined in atiid.h, e.g. FAMILY_SI).  Only FAMILY_SI and later are\n    /// currently supported.\n    UINT chipFamily;\n\n    /// Target GPU chip revision (defined in hardware-specific chip headers, e.g. si_id.h).\n    UINT chipRevision;\n\n    /// Pointer to DXASM bytecode to be compiled.\n    const VOID* pShaderByteCode;\n\n    /// Length of pShaderByteCode in bytes.\n    SIZE_T      byteCodeLength;\n\n    /// An array of setting/value pairs to control compilation options.  NULL is valid, if all\n    /// default options are desired.\n    const AmdDxGsaCompileOption* pCompileOptions;\n\n    /// Length of pCompileOptions array.\n    UINT                         numCompileOptions;\n\n    /// Reserved entry must be set to all 0s.\n    unsigned int reserved[7];\n} AmdDxGsaCompileShaderInput;\n\n/**\n***************************************************************************************************\n* @brief AmdDxGsaCompileShader() output structure.\n***************************************************************************************************\n*/\ntypedef struct _AmdDxGsaCompileShaderOutput\n{\n    /// Must be set to sizeof(AmdDxGsaCompileShaderOutput).\n    SIZE_T size;\n\n    /// Output ELF object. Contains .amdil (IL), .text (ISA), and .stats (AmdDxGsaCompileStats)\n    VOID*  pShaderBinary;\n\n    /// Size of the ELF object in bytes.\n    SIZE_T shaderBinarySize;\n} AmdDxGsaCompileShaderOutput;\n\nHRESULT __cdecl AmdDxGsaCompileShader(const AmdDxGsaCompileShaderInput* pIn,\n                                      AmdDxGsaCompileShaderOutput*      pOut);\ntypedef HRESULT(__cdecl* PfnAmdDxGsaCompileShader)(const AmdDxGsaCompileShaderInput*,\n                                                   AmdDxGsaCompileShaderOutput*);\n\nVOID __cdecl AmdDxGsaFreeCompiledShader(VOID* pShaderBinary);\ntypedef VOID (__cdecl* PfnAmdDxGsaFreeCompiledShader)(VOID*);\n\n#if defined(__cplusplus)\n}\n#endif\n\n#endif // _AMDDXGSACOMPILE_H_\n\n"
  },
  {
    "path": "src/Wrapper/amd-codexl-analyzer/CommonProjects/AMDTBackend/Include/Common/asic_reg/atiid.h",
    "content": "//=====================================================================\n// Copyright 2016 (c), Advanced Micro Devices, Inc. All rights reserved.\n//\n/// \\author AMD Developer Tools Team\n/// \\file \n/// \n//=====================================================================\n/*****************************************************************************\\\n*\n*  Module Name    atiid.h\n*  Project        R128/M3/R6 WindowsNT\n*  Device         R128/M3/R6\n*\n*  Description    Common Family ID file for R128/M3/R6 driver\n*\n\\*****************************************************************************/\n\n#ifndef _ATIID_H\n#define _ATIID_H\n\n\n//\n// Define Asic Family IDs for different asic family.\n//\n//[espiritu - 06/21/00]\n//TO DO: change enumeration of all asic families including RageProDerivatives, as\n//these are in conflict (used especially in TVOut).\n\n#define FAMILY_UNKNOWN                  0\n#define FAMILY_RAGE_128                 1\n#define FAMILY_RAGE_128_4X              2\n#define FAMILY_RAGE_128_PRO             3\n#define FAMILY_M3                       4\n#define FAMILY_RAGE_6                   5\n#define FAMILY_RADEON100                FAMILY_RAGE_6\n#define FAMILY_RAGE_6LITE               6\n#define FAMILY_M6                       7\n#define FAMILY_RADEON200                8\n#define FAMILY_RAGE_128_PROII          21 /*EPR#40430 temporary only, in conflict with LTPro asic in TVOut.*/\n\n#define FAMILY_U1                      22  // CABO family; including A3, A4 and U1\n#define FAMILY_RS200                   23  // including RS250, RS250M\n#define FAMILY_RS200M                  24\n#define FAMILY_RS300                   25  // including Device ID: RS300,RS300VE,RS300M,RS300ML\n#define FAMILY_RS400                   26  // including Device ID: RS400,RS400M\n#define FAMILY_RS480                   27  // including Device ID: RS480,RS480M\n#define FAMILY_RC410                   28  // including Device ID: RC410,RC410M\n#define FAMILY_RS600                   29  // including Device ID: RS600,RS600M\n//Integrated ASICs continued from 65\n\n//\n// *** CHIP FAMILIES ***\n//  from rprod.h plus 30\n// Chip family - sorted by growing capability of the chip.\n//\n//#define FAMILY_UNKNOWN               30\n//#define FAMILY_VTB,                  31       // ATI-264VT3 family\n//#define FAMILY_VTB_PLUS,             32       // ATI-264VT3 UMC family\n//#define FAMILY_VTB_VT4,              33       // ATI-264VT4 family\n//#define FAMILY_GTB,                  34       // 3D RAGE II family\n//#define FAMILY_LTG,                  35       // 3D RAGE LT-G family\n//#define FAMILY_GTB_PLUS,             36       // 3D RAGE II+ family\n//#define FAMILY_GTB_IIC,              37       // 3D RAGE IIC family\n//#define FAMILY_GTC,                  38       // 3D RAGE PRO family\n//#define FAMILY_LT_PRO,               39       // 3D RAGE LT PRO family\n//#define FAMILY_RAGE_XL,              40       // 3D RAGE XL\n//#define FAMILY_RAGE_XC               41       // 3D RAGE XC\n//\n// Define Vendor ID.\n//\n\n#define FAMILY_MORPHEUS                 42\n#define FAMILY_RV200                    FAMILY_MORPHEUS\n#define FAMILY_M7                       43\n\n#define FAMILY_KHAN                     44\n#define FAMILY_R300                     FAMILY_KHAN\n#define FAMILY_RV350                    45\n#define FAMILY_M10                      46\n\n#define FAMILY_IRIS                     47\n#define FAMILY_RV250                    FAMILY_IRIS\n#define FAMILY_M9                       48\n\n#define FAMILY_ARGUS                    49\n#define FAMILY_RV280                    FAMILY_ARGUS\n\n#define FAMILY_R400                     50\n\n#define FAMILY_M9PLUS                   51\n\n#define FAMILY_R350                     52\n\n#define FAMILY_R360                     53\n\n#define FAMILY_RV380                    54\n#define FAMILY_M24                      55\n\n#define FAMILY_LOKI                     56\n#define FAMILY_R420                     FAMILY_LOKI // R423 shares the same family id with LOKI\n\n#define FAMILY_M18                      57          // M28 shares the same family id with M18\n\n#define FAMILY_ALTO                     58\n#define FAMILY_RV410                    FAMILY_ALTO\n\n#define FAMILY_M26                      59\n\n\n#define FAMILY_R520                     60\n\n#define FAMILY_M58                      61          // mobile version of R520\n\n#define FAMILY_RV5XX                    62          // RV530, RV535, RV515\n\n#define FAMILY_MV5X                     63          // mobile version of RV5xx\n\n//Integrated ASICS\n#define FAMILY_RS690                    65          // including Device ID: RS690,RS690C,RS690M,RS690MC,RS690T; RS740, RS740M\n\n#define FAMILY_R600                     70          // Pele\n\n#define FAMILY_RV6XX                    71          // RV6xx\n\n#define FAMILY_MV6X                     72          // Mobile version of RV6xx\n\n//R600 based integrated ASICs Family ID start from 75\n#define FAMILY_RS780                    75          //RS780/RS780M Functionality level will be defined by revision ID.\n\n\n#define FAMILY_R700                     80          //FAMILY_RV7XX    // FAMILY_R700 will be removed later\n\n#define FAMILY_RV7XX                    81          // WEKIVA/RV7xx\n\n#define FAMILY_MV7X                     82          // Mobile version of RV7xx\n\n#define FAMILY_KONG                     85          // Fusion Roadrunner project - SwiftGPU100/200/300\n\n#define FAMILY_EVERGREEN                90          // EVERGREEN\n#define FAMILY_RV8XX                    90          // Deprecated\n\n#define FAMILY_MANHATTAN                91          // MANHATTAN\n#define FAMILY_MV8X                     91          // Deprecated\n\n#define FAMILY_SUMO                     95          // Fusion Llano/Ontario project - SuperSumo/Sumo/Wrestler variants\n\n#define FAMILY_NI                      100          // Northern Islands: Ibiza, Cozumel, Kauai\n#define FAMILY_NORTHERNISLAND          FAMILY_NI    // Keeping the original name for backward compatibility.  FAMILY_NI follows the new naming convention\n\n#define FAMILY_SI                      110          // Southern Islands: Tahiti (P), Pitcairn (PM), Cape Verde (M), Bali (V)\n\n#define FAMILY_TN                      105          // Fusion Trinity: Devastator - DVST (M), Scrapper (V)\n\n#define FAMILY_CI                      120          // Sea Islands: Hawaii (P), Maui (P), Bonaire (M)\n\n#define FAMILY_KV                      125          // Fusion Kaveri: Spectre, Spooky; Fusion Kabini: Kalindi\n\n#define FAMILY_VI                      130          // Volcanic Islands: Iceland (V), Tonga (M)\n\n#define FAMILY_CZ                      135          // Carrizo, Nolan, Amur\n\n#define FAMILY_PI                      140          // Pirate Islands\n\n#define ATI_VENDOR_ID                   0x1002\n\n\n#endif  // _ATIID_H\n"
  },
  {
    "path": "src/Wrapper/amd-codexl-analyzer/CommonProjects/AMDTBackend/Include/Common/asic_reg/ci_id.h",
    "content": "//=====================================================================\n// Copyright 2011-2016 (c), Advanced Micro Devices, Inc. All rights reserved.\n//\n/// \\author AMD Developer Tools Team\n/// \\file \n/// \n//=====================================================================\n/*****************************************************************************\n*\n*  Module Name    ci_id.h\n*  Project        SEA ISLANDS\n*  Devices        SEA ISLANDS\n*\n*  Description    Defining Device IDs, ASIC revision IDs for SEA ISLANDS\n*\n*****************************************************************************/\n\n#ifndef _CI_ID_H\n#define _CI_ID_H\n\nenum\n{\n    CI_TIRAN_P_A0   = 1,  // Tiran is obsolete, please do not use\n\n    CI_BONAIRE_M_A0 = 20,\n    CI_BONAIRE_M_A1 = 21,\n\n    CI_HAWAII_P_A0  = 40,\n\n    CI_MAUI_P_A0    = 60,\n\n    CI_UNKNOWN      = 0xFF\n};\n\n#define ASICREV_IS_TIRAN_P(eChipRev)    (eChipRev < CI_BONAIRE_M_A0)\n#define ASICREV_IS_BONAIRE_M(eChipRev)  ((eChipRev >= CI_BONAIRE_M_A0) && (eChipRev < CI_HAWAII_P_A0))\n#define ASICREV_IS_HAWAII_P(eChipRev)   ((eChipRev >= CI_HAWAII_P_A0) && (eChipRev < CI_MAUI_P_A0))\n#define ASICREV_IS_MAUI_P(eChipRev)     (eChipRev >= CI_MAUI_P_A0)\n\n\n//\n// TIRAN/TIRAN MOBILE device IDs (Performance segment)\n//\n#define DEVICE_ID_CI_TIRAN_P_6600               0x6600  // unfused\n\n// TIRAN ASIC internal revision number\n#define INTERNAL_REV_CI_TIRAN_P_A0              0x00    // First spin of Tiran\n\n#define DEVICE_ID_CI_TIRAN_P_PALLADIUM          0x37    // Palladium ID\n#define DEVICE_ID_CI_TIRAN_P_LITE_PALLADIUM     0x40    // Palladium ID\n\n\n//\n// BONAIRE/SATURN/EMERALD/STRATO device IDs (Performance to Mainstream segment)\n//\n#define DEVICE_ID_CI_BONAIRE_M_6640             0x6640  // Saturn XT \n#define DEVICE_ID_CI_BONAIRE_M_6641             0x6641  // Saturn  PRO\n#define DEVICE_ID_CI_BONAIRE_M_6646             0x6646  // Emerald XT; Strato XT\n#define DEVICE_ID_CI_BONAIRE_M_6647             0x6647  // Emerald PRO; Strato Pro\n#define DEVICE_ID_CI_BONAIRE_M_6649             0x6649  // Bonaire  GL Pro \n#define DEVICE_ID_CI_BONAIRE_M_664E             0x664E  // Strato PRO \n#define DEVICE_ID_CI_BONAIRE_M_6650             0x6650  // Bonaire XT\n#define DEVICE_ID_CI_BONAIRE_M_6651             0x6651  // Bonaire Pro \n#define DEVICE_ID_CI_BONAIRE_M_6658             0x6658  // Bonaire XTX \n#define DEVICE_ID_CI_BONAIRE_M_665C             0x665C  // Bonaire XT\n#define DEVICE_ID_CI_BONAIRE_M_665D             0x665D  // Bonaire Pro \n\n// STRATO PCI Reivsion IDs\n#define PRID_CI_BONAIRE_STRATO_80               0x80      // 0x6646: Strato XT; 0x6647: Strato Pro\n\n#define ASICID_IS_STRATO(wDID, bRID)            ((bRID == PRID_CI_BONAIRE_STRATO_80) && \\\n                                                 ((wDID == DEVICE_ID_CI_BONAIRE_M_6646) || (wDID == DEVICE_ID_CI_BONAIRE_M_6647)))\n\n#define DEVICE_ID_CI_BONAIRE_M_PALLADIUM        0x45    // Palladium ID\n#define DEVICE_ID_CI_BONAIRE_M_LITE_PALLADIUM   0x46    // Palladium ID\n\n// BONAIRE ASIC internal revision number\n#define INTERNAL_REV_CI_BONAIRE_M_A0            0x00    // First spin of Bonaire\n#define INTERNAL_REV_CI_BONAIRE_M_A1            0x01    // Second spin of Bonaire\n\n//\n// HAWAII device IDs (Performance segment)\n//\n#define DEVICE_ID_CI_HAWAII_P_66A0              0x66A0  // Obsolete\n#define DEVICE_ID_CI_HAWAII_P_67A0              0x67A0  // Hawaii GL44\n#define DEVICE_ID_CI_HAWAII_P_67A1              0x67A1  // Hawaii GL40\n#define DEVICE_ID_CI_HAWAII_P_67A2              0x67A2  // Hawaii GL Gemini\n#define DEVICE_ID_CI_HAWAII_P_67A8              0x67A8  // Hawaii GL XT\n#define DEVICE_ID_CI_HAWAII_P_67A9              0x67A9  // Hawaii GL Gemini\n#define DEVICE_ID_CI_HAWAII_P_67AA              0x67AA  // Hawaii GL Pro\n#define DEVICE_ID_CI_HAWAII_P_67B0              0x67B0  // Hawaii XT\n#define DEVICE_ID_CI_HAWAII_P_67B1              0x67B1  // Hawaii Pro\n#define DEVICE_ID_CI_HAWAII_P_67B8              0x67B8  // Obsolete\n#define DEVICE_ID_CI_HAWAII_P_67B9              0x67B9  // Hawaii Gemini\n#define DEVICE_ID_CI_HAWAII_P_67BA              0x67BA  // Obsolete\n#define DEVICE_ID_CI_HAWAII_P_67BE              0x67BE  // Hawaii LE\n\n#define DEVICE_ID_CI_HAWAII_P_PALLADIUM         0x00    // Palladium ID\n#define DEVICE_ID_CI_HAWAII_P_LITE_PALLADIUM    0x0052  // Palladium ID\n\n// HAWAII ASIC internal revision number\n#define INTERNAL_REV_CI_HAWAII_P_A0             0x00    // First spin of Hawaii\n\n\n//\n// MAUI device IDs (Performance segment)\n//\n#define DEVICE_ID_CI_MAUI_P_66E0                0x66E0  // unfused\n\n#define DEVICE_ID_CI_MAUI_P_PALLADIUM           0x00    // Palladium ID\n#define DEVICE_ID_CI_MAUI_P_LITE_PALLADIUM      0x00    // Palladium ID\n\n// HAWAII ASIC internal revision number\n#define INTERNAL_REV_CI_MAUI_P_A0               0x00    // First spin of Maui\n\n#endif  // _CI_ID_H\n"
  },
  {
    "path": "src/Wrapper/amd-codexl-analyzer/CommonProjects/AMDTBackend/Include/Common/asic_reg/cz_id.h",
    "content": "//=====================================================================\n// Copyright 2013-2016 (c), Advanced Micro Devices, Inc. All rights reserved.\n//\n/// \\author AMD Developer Tools Team\n/// \\file \n/// \n//=====================================================================\n\n/*****************************************************************************\\\n*\n*  Module Name    cz_id.h\n*  Project        CARRIZO\n*  Devices        CARRIZO\n*\n*  Description    Defining Device IDs, ASIC revision IDs for CARRIZO\n*\n\\*****************************************************************************/\n\n#ifndef _CZ_ID_H\n#define _CZ_ID_H\n\nenum\n{\n    CARRIZO_A0      = 0x01,\n    CARRIZO_A1      = 0x02,\n    NOLAN_A0        = 0x21,\n    AMUR_A0         = 0x41,\n    STONEY_A0       = 0x61,\n    CZ_UNKNOWN      = 0xFF\n};\n\n\n#define ASICREV_IS_CARRIZO(eChipRev)            ( (eChipRev >= CARRIZO_A0) && (eChipRev < NOLAN_A0) )\n#define ASICREV_IS_NOLAN(eChipRev)              ( (eChipRev >= NOLAN_A0) && (eChipRev < AMUR_A0) )\n#define ASICREV_IS_AMUR(eChipRev)               ( (eChipRev >= AMUR_A0) && (eChipRev < STONEY_A0) )\n#define ASICREV_IS_STONEY(eChipRev)             ( (eChipRev >= STONEY_A0) && (eChipRev < CZ_UNKNOWN) )\n\n\n//\n// Carrizo device IDs\n//\n#define DEVICE_ID_CZ_9870                   0x9870  // Palladium  \n\n#define DEVICE_ID_CZ_9874                   0x9874\n#define DEVICE_ID_CZ_9875                   0x9875\n#define DEVICE_ID_CZ_9876                   0x9876\n#define DEVICE_ID_CZ_9877                   0x9877\n\n// CARRIZO ASIC internal revision number\n#define INTERNAL_REV_CARRIZO_A0             0x00    // First spin of CARRIZO\n#define INTERNAL_REV_CARRIZO_A1             0x01    // Second spin of CARRIZO\n\n// CARRIZO PCI Reivsion IDs\n#define PRID_CZ_C4                          0xC4  // Client B10\n#define PRID_CZ_C5                          0xC5  // Client B8\n#define PRID_CZ_C6                          0xC6  // Client B6\n#define PRID_CZ_C7                          0xC7  // Client B4\n\n//\n// Nolan embedded device IDs\n//\n#define DEVICE_ID_NL_98C0                   0x98C0 // Nolan embedded internal GFX\n#define DEVICE_ID_NL_98CC                   0x98CC // Nolan Emb iTemp Prime 4C\n#define DEVICE_ID_NL_98CD                   0x98CD // Nolan Emb iTemp Prime 2C\n\n#define PRID_NOLAN_80                       0x80    // Embedded 15W 4CU\n#define PRID_NOLAN_81                       0x81    // Embedded 4W 4CU\n#define PRID_NOLAN_82                       0x82    // Embedded 5W 2CU\n#define PRID_NOLAN_83                       0x83    // Embedded 5W no CU\n\n// NOLAN ASIC internal revision number\n#define INTERNAL_REV_NOLAN_A0               0x00    // First spin of NOLAN\n\n\n//\n// Amur device IDs\n//\n#define DEVICE_ID_AM_9890                   0x9890\n\n// AMUR ASIC internal revision number\n#define INTERNAL_REV_AMUR_A0                0x00    // First spin of AMUR\n\n//\n// Stoney device IDs\n//\n#define DEVICE_ID_ST_98E4                   0x98E4\n\n// STONEY ASIC internal revision number\n#define INTERNAL_REV_STONEY_A0              0x00    // First spin of STONEY\n\n// STONEY PCI Revision IDs\n#define PRID_ST_C0                          0xC0    // 15W 2C N FT4 98E4\n#define PRID_ST_C1                          0xC1    // 15W 2C N FP4 98E4\n#define PRID_ST_C8                          0xC8    // 10W 2C N-4 FT4 98E4\n#define PRID_ST_C9                          0xC9    // 10W 2C N-4 FP4 98E4\n#define PRID_ST_D1                          0xD1    // 15W 2C N-1 FP4 98E4\n#define PRID_ST_D8                          0xD8    // 4.5W 2C N-1 FT4 98E4\n#define PRID_ST_E0                          0xE0    // 15W 2C N-2 FT4 98E4\n#define PRID_ST_E1                          0xE1    // 15W 2C N-2 FP4 98E4\n#define PRID_ST_F1                          0xF1    // 15W 2C N-3 FP4 98E4\n\n#endif // _CZ_ID_H\n\n"
  },
  {
    "path": "src/Wrapper/amd-codexl-analyzer/CommonProjects/AMDTBackend/Include/Common/asic_reg/evergreen_id.h",
    "content": "//=====================================================================\n// Copyright 2008-2016 (c), Advanced Micro Devices, Inc. All rights reserved.\n//\n/// \\author AMD Developer Tools Team\n/// \\file \n/// \n//=====================================================================/*****************************************************************************\\\n//*\n//*  Module Name    evergreen_id.h\n//*  Project        EVERGREEN\n//*  Devices        EVERGREEN\n//*\n//*  Description    Defining Device IDs, ASIC revision IDs for EVERGREEN\n//*\n//*\n//*  (c) 2008 Advanced Micro Devices, Inc. (unpublished)\n//*\n//*  All rights reserved.  This notice is intended as a precaution against\n//*  inadvertent publication and does not imply publication or any waiver\n//*  of confidentiality.  The year included in the foregoing notice is the\n//*  year of creation of the work.\n//*\n//*  LOG OF CHANGES\n//*\n//*  1.0    08/29/2008 - initial revision\n//*\n//\\*****************************************************************************/\n\n#ifndef _EVERGREEN_ID_H\n#define _EVERGREEN_ID_H\n\nenum\n{\n    CYPRESS_A11          = 1,\n    CYPRESS_A12          = 2,\n\n    JUNIPER_A11          = 20,\n    JUNIPER_A12          = 21,\n\n    REDWOOD_A11          = 40,\n    REDWOOD_A12          = 41,\n\n    CEDAR_A11            = 60,\n    CEDAR_A12            = 61,\n\n    EVERGREEN_UNKNOWN    = 0xFF\n};\n\n#define ASICREV_IS_CYPRESS(eChipRev) (eChipRev < JUNIPER_A11)\n#define ASICREV_IS_JUNIPER(eChipRev) ((eChipRev >= JUNIPER_A11) && (eChipRev < REDWOOD_A11))\n#define ASICREV_IS_REDWOOD(eChipRev) ((eChipRev >= REDWOOD_A11) && (eChipRev < CEDAR_A11))\n#define ASICREV_IS_CEDAR(eChipRev)   (eChipRev >= CEDAR_A11)\n\n\n//\n// CYPRESS/LEXINGTON device IDs\n//\n#define DEVICE_ID_CYPRESS_6888              0x6888    // CYPRESS GL XT\n#define DEVICE_ID_CYPRESS_6889              0x6889    // CYPRESS GL Pro\n#define DEVICE_ID_CYPRESS_688A              0x688A    // CYPRESS GL XT\n#define DEVICE_ID_CYPRESS_688C              0x688C    // CYPRESS - FS (Osprey)\n#define DEVICE_ID_CYPRESS_688D              0x688D    // CYPRESS - FS (Kestrel)\n#define DEVICE_ID_CYPRESS_6898              0x6898    // CYPRESS XT\n#define DEVICE_ID_CYPRESS_6899              0x6899    // CYPRESS PRO\n#define DEVICE_ID_CYPRESS_689B              0x689B    // CYPRESS PRO (Rebranch)\n#define DEVICE_ID_CYPRESS_689C              0x689C    // HEMLOCK XT      - CYPRESS Gemini\n#define DEVICE_ID_CYPRESS_689D              0x689D    // HEMLOCK PRO     - CYPRESS Gemini\n#define DEVICE_ID_CYPRESS_689E              0x689E    // CYPRESS LE\n\n#define DEVICE_ID_CYPRESS_6880              0x6880    // LEXINGTON GL XT - CYPRESS Mobile\n#define DEVICE_ID_CYPRESS_6890              0x6890    // LEXINGTON XT    - CYPRESS Mobile\n\n#define DEVICE_ID_CYPRESS_PALLADIUM         0x0010    // Palladium ID\n#define DEVICE_ID_CYPRESS_LITE_PALLADIUM    0x0012    // Palladium ID\n\n// CYPRESS ASIC internal revision number\n#define INTERNAL_REV_CYPRESS_A11            0x00      // First spin of CYPRESS ASIC\n#define INTERNAL_REV_CYPRESS_A12            0x01      // Second spin of CYPRESS ASIC\n\n//\n// JUNIPER/BROADWAY device IDs\n//\n#define DEVICE_ID_JUNIPER_68A9              0x68A9    // JUNIPER GL Pro\n#define DEVICE_ID_JUNIPER_68B8              0x68B8    // JUNIPER XT\n#define DEVICE_ID_JUNIPER_68B9              0x68B9    // JUNIPER PRO\n#define DEVICE_ID_JUNIPER_68BA              0x68BA    // JUNIPER XT (BD3D)\n#define DEVICE_ID_JUNIPER_68BE              0x68BE    // JUNIPER LE\n#define DEVICE_ID_JUNIPER_68BF              0x68BF    // JUNIPER LE (BD3D)\n\n#define DEVICE_ID_JUNIPER_68A0              0x68A0    // BROADWAY XGL       - JUNIPER Mobile\n#define DEVICE_ID_JUNIPER_68A1              0x68A1    // BROADWAY GL Pro/LP - JUNIPER Mobile\n#define DEVICE_ID_JUNIPER_68A8              0x68A8    // BROADWAY PRO & LP  - JUNIPER Mobile\n#define DEVICE_ID_JUNIPER_68B0              0x68B0    // BROADWAY XT        - JUNIPER Mobile\n#define DEVICE_ID_JUNIPER_68B1              0x68B1    // BROADWAY PRO & LP  - JUNIPER Mobile\n\n#define DEVICE_ID_JUNIPER_PALLADIUM         0x0011    // Palladium ID\n\n// JUNIPER ASIC internal revision number\n#define INTERNAL_REV_JUNIPER_A11            0x00      // First spin of JUNIPER ASIC\n#define INTERNAL_REV_JUNIPER_A12            0x01      // Second spin of JUNIPER ASIC\n\n\n//\n// REDWOOD/PINEWOOD/MADISON device IDs\n//\n#define DEVICE_ID_REDWOOD_68C8              0x68C8    // Redwood XT GL\n#define DEVICE_ID_REDWOOD_68C9              0x68C9    // Redwood PRO GL\n#define DEVICE_ID_REDWOOD_68D8              0x68D8    // Redwood XT\n#define DEVICE_ID_REDWOOD_68D9              0x68D9    // Redwood PRO\n#define DEVICE_ID_REDWOOD_68DA              0x68DA    // Redwood PRO2\n#define DEVICE_ID_REDWOOD_68DE              0x68DE    // Redwood LE\n#define DEVICE_ID_REDWOOD_68C7              0x68C7    // Pinewood\n\n#define DEVICE_ID_REDWOOD_68C0              0x68C0    // Madison XT GL\n#define DEVICE_ID_REDWOOD_68C1              0x68C1    // Madison PRO & LP GL\n#define DEVICE_ID_REDWOOD_68D0              0x68D0    // Madison XT\n#define DEVICE_ID_REDWOOD_68D1              0x68D1    // Madison PRO & LP\n\n#define DEVICE_ID_REDWOOD_PALLADIUM         0x0013    // Palladium ID\n\n// REDWOOD ASIC internal revision number\n#define INTERNAL_REV_REDWOOD_A11            0x00      // First spin of REDWOOD\n#define INTERNAL_REV_REDWOOD_A12            0x01      // Second spin of REDWOOD\n\n\n//\n// CEDAR/PARK/ROBSON device IDs\n//\n#define DEVICE_ID_CEDAR_68E8                0x68E8    // Cedar XT GL\n#define DEVICE_ID_CEDAR_68E9                0x68E9    // Cedar PRO GL\n#define DEVICE_ID_CEDAR_68F2                0x68F2    // Cedar Prowl\n#define DEVICE_ID_CEDAR_68F8                0x68F8    // Cedar XT\n#define DEVICE_ID_CEDAR_68F9                0x68F9    // Cedar PRO\n#define DEVICE_ID_CEDAR_68FA                0x68FA    // Cedar PRO2\n#define DEVICE_ID_CEDAR_68FE                0x68FE    // Cedar LE\n\n#define DEVICE_ID_CEDAR_68E0                0x68E0    // Park  PRO & XT GL\n#define DEVICE_ID_CEDAR_68E1                0x68E1    // Park LP GL\n#define DEVICE_ID_CEDAR_68E4                0x68E4    // Robson CE\n#define DEVICE_ID_CEDAR_68E5                0x68E5    // Robson LE\n#define DEVICE_ID_CEDAR_68F0                0x68F0    // Park PRO & XT\n#define DEVICE_ID_CEDAR_68F1                0x68F1    // Park LP\n\n#define DEVICE_ID_CEDAR_PALLADIUM           0x0014    // Palladium ID\n\n// CEDAR ASIC internal revision number\n#define INTERNAL_REV_CEDAR_A11              0x00      // First spin of CEDAR\n#define INTERNAL_REV_CEDAR_A12              0x01      // Second spin of CEDAR\n\n\n#endif  // _EVERGREEN_ID_H\n"
  },
  {
    "path": "src/Wrapper/amd-codexl-analyzer/CommonProjects/AMDTBackend/Include/Common/asic_reg/kv_id.h",
    "content": "//=====================================================================\n// Copyright 2011-2016 (c), Advanced Micro Devices, Inc. All rights reserved.\n//\n/// \\author AMD Developer Tools Team\n/// \\file \n/// \n//=====================================================================\n/*****************************************************************************\\\n*\n*  Module Name    kv_id.h\n*  Project        Kaveri Family\n*  Device         Spectre, Spooky, KALINDI\n*\n*  Description    Identifier file for Kaveri and Kabini driver\n*  LOG OF CHANGES\n*\n*  0.1    07/27/11 - initial revision\n*\n\\*****************************************************************************/\n\n#ifndef KV_ID_H\n#define KV_ID_H\n\n// SW revision section\nenum\n{\n    KV_SPECTRE_A0      = 0x01,       // KV1 with Spectre GFX core, 8-8-1-2 (CU-Pix-Primitive-RB)\n    KV_SPOOKY_A0       = 0x41,       // KV2 with Spooky GFX core, including downgraded from Spectre core, 3-4-1-1 (CU-Pix-Primitive-RB)\n    KB_KALINDI_A0      = 0x81,       // KB with Kalindi GFX core, 2-4-1-1 (CU-Pix-Primitive-RB)\n    KB_KALINDI_A1      = 0x82,       // KB with Kalindi GFX core, 2-4-1-1 (CU-Pix-Primitive-RB)\n    BV_KALINDI_A2      = 0x85,       // BV with Kalindi GFX core, 2-4-1-1 (CU-Pix-Primitive-RB)\n    ML_GODAVARI_A0     = 0xa1,      // ML with Godavari GFX core, 2-4-1-1 (CU-Pix-Primitive-RB)\n    ML_GODAVARI_A1     = 0xa2,      // ML with Godavari GFX core, 2-4-1-1 (CU-Pix-Primitive-RB)\n    KV_UNKNOWN = 0xFF\n};\n\n#define ASICREV_IS_SPECTRE(eChipRev) ((eChipRev >= KV_SPECTRE_A0) && (eChipRev < KV_SPOOKY_A0))         // identify all versions of SPRECTRE and supported features set\n#define ASICREV_IS_SPOOKY(eChipRev) ((eChipRev >= KV_SPOOKY_A0) && (eChipRev < KB_KALINDI_A0))          // identify all versions of SPOOKY and supported features set\n#define ASICREV_IS_KALINDI(eChipRev) ((eChipRev >= KB_KALINDI_A0) && (eChipRev < KV_UNKNOWN))           // identify all versions of KALINDI and supported features set\n\n// Following macros are subset of ASICREV_IS_KALINDI macro\n#define ASICREV_IS_KALINDI_BHAVANI(eChipRev) ((eChipRev >= BV_KALINDI_A2) && (eChipRev < ML_GODAVARI_A0))   // identify all versions of BHAVANI and supported features set\n#define ASICREV_IS_KALINDI_GODAVARI(eChipRev) ((eChipRev >= ML_GODAVARI_A0) && (eChipRev < KV_UNKNOWN)) // identify all versions of GODAVARI and supported features set\n\n//\n// Define Chip ID's for Kaveri family\n//\n#define DEVICE_ID_SPECTRE_MOBILE                  0x1304     // OBSOLETE - TO BE REMOVED    //FP3   soldered, 8-8-1-2 (CU-Pix-Primitive-RB)\n#define DEVICE_ID_SPECTRE_MOBILE_1304             0x1304     // FP3   soldered, 8-8-1-2 (CU-Pix-Primitive-RB)\n#define DEVICE_ID_SPECTRE_DESKTOP                 0x1305     // OBSOLETE - TO BE REMOVED    //FM2r2 socket,   8-8-1-2 (CU-Pix-Primitive-RB)\n#define DEVICE_ID_SPECTRE_DESKTOP_1305            0x1305     // FM2r2 socket,   8-8-1-2 (CU-Pix-Primitive-RB)\n#define DEVICE_ID_SPOOKY_MOBILE                   0x1306     // OBSOLETE - TO BE REMOVED    //FS2 socket, 3-4-1-1 (CU-Pix-Primitive-RB)\n#define DEVICE_ID_SPECTRE_SL_MOBILE_1306          0x1306     // FP3   soldered, 4-4-1-1 (CU-Pix-Primitive-RB)\n#define DEVICE_ID_SPOOKY_DESKTOP                  0x1307     // OBSOLETE - TO BE REMOVED    //FM3 socket,3-4-1-1 (CU-Pix-Primitive-RB) \n#define DEVICE_ID_SPECTRE_SL_DESKTOP_1307         0x1307     // FM2r2 socket,   4-4-1-1 (CU-Pix-Primitive-RB)\n#define DEVICE_ID_SPECTRE_LITE_MOBILE_1309        0x1309     // FP3   soldered, 6-8-1-2 (CU-Pix-Primitive-RB)\n#define DEVICE_ID_SPECTRE_LITE_MOBILE_130A        0x130A     // FP3   soldered, 6-8-1-2 (CU-Pix-Primitive-RB)\n#define DEVICE_ID_SPECTRE_SL_MOBILE_130B          0x130B     // FP3   soldered, 4-4-1-1 (CU-Pix-Primitive-RB)\n#define DEVICE_ID_SPECTRE_MOBILE_130C             0x130C     // FP3   soldered, 8-8-1-2 (CU-Pix-Primitive-RB)\n#define DEVICE_ID_SPECTRE_LITE_MOBILE_130D        0x130D     // FP3   soldered, 6-8-1-2 (CU-Pix-Primitive-RB)\n#define DEVICE_ID_SPECTRE_SL_MOBILE_130E          0x130E     // FP3   soldered, 4-4-1-1 (CU-Pix-Primitive-RB)\n#define DEVICE_ID_SPECTRE_DESKTOP_130F            0x130F     // FM2r2 socket,   8-8-1-2 (CU-Pix-Primitive-RB)\n#define DEVICE_ID_SPECTRE_WORKSTATION_1310        0x1310     // FM2r2 socket,   8-8-1-2 (CU-Pix-Primitive-RB)\n#define DEVICE_ID_SPECTRE_WORKSTATION_1311        0x1311     // FM2r2 socket,   8-8-1-2 (CU-Pix-Primitive-RB)\n#define DEVICE_ID_SPOOKY_DESKTOP_1312             0x1312     // FM2r2,          3-4-1-1 (CU-Pix-Primitive-RB)\n#define DEVICE_ID_SPECTRE_LITE_DESKTOP_1313       0x1313     // FM2r2 socket,   6-8-1-2 (CU-Pix-Primitive-RB)\n#define DEVICE_ID_SPECTRE_SL_DESKTOP_1315         0x1315     // FM2r2 socket,   4-4-1-1 (CU-Pix-Primitive-RB)\n#define DEVICE_ID_SPOOKY_DESKTOP_1316             0x1316     // FM2r2 socket,   3-4-1-1 (CU-Pix-Primitive-RB)\n#define DEVICE_ID_SPOOKY_MOBILE_1317              0x1317     // FP3,            3-4-1-1 (CU-Pix-Primitive-RB) \n#define DEVICE_ID_SPECTRE_SL_MOBILE_1318          0x1318     // FP3,            4-4-1-1 (CU-Pix-Primitive-RB), ACP disabled in SW\n#define DEVICE_ID_SPECTRE_SL_EMBEDDED_131B        0x131B     // FP3 soldered,   4-4-1-1 (CU-Pix-Primitive-RB), ACP disabled in SW\n#define DEVICE_ID_SPECTRE_EMBEDDED_131C           0x131C     // FP3 soldered,   8-8-1-2 (CU-Pix-Primitive-RB)\n#define DEVICE_ID_SPECTRE_LITE_EMBEDDED_131D      0x131D     // FP3,            6-8-1-2 (CU-Pix-Primitive-RB)\n\n// Define AMD's internal revision numbers.\n#define INTERNAL_REV_SPECTRE_A0       0x00       // The First revision of SPECTRE GFX.\n\n// Define AMD's external revision numbers.\n#define EXTERNAL_REV_SPECTRE         0x00\n\n\n//\n// Define Chip ID's for Kabini\n//\n#define DEVICE_ID_KALINDI__9830         0x9830      // FT3 socket and FS1b socket\n#define DEVICE_ID_KALINDI__9831         0x9831      // FT3 socket,  \n#define DEVICE_ID_KALINDI__9832         0x9832      // FT3 socket,  \n#define DEVICE_ID_KALINDI__9833         0x9833      // FT3 socket, \n#define DEVICE_ID_KALINDI__9834         0x9834      // FT3 socket,  \n#define DEVICE_ID_KALINDI__9835         0x9835      // FT3 socket,  \n#define DEVICE_ID_KALINDI__9836         0x9836      // FT3 socket and FS1b socket \n#define DEVICE_ID_KALINDI__9837         0x9837      // FT3 socket,  \n#define DEVICE_ID_KALINDI__9838         0x9838      // FT3 socket and FS1b socket  \n\n\n\n//\n// Define Chip ID's for Temash\n//\n#define DEVICE_ID_TEMASH__9839          0x9839      // FT3 socket,  \n#define DEVICE_ID_TEMASH__983a          0x983a      // FT3 socket,  \n#define DEVICE_ID_TEMASH__983b          0x983b      // FT3 socket,  \n#define DEVICE_ID_TEMASH__983c          0x983c      // FT3 socket,  \n#define DEVICE_ID_TEMASH__983d          0x983d      // FT3 socket,  \n#define DEVICE_ID_TEMASH__983e          0x983e      // FT3 socket,  \n#define DEVICE_ID_TEMASH__983f          0x983f      // FT3 socket,  \n\n//\n// Define Chip ID's for Bhavani Desktop\n// PLEASE DO NOT USE THESE DID! BV DOESN'T SUPPORT THEM!\n//\n#define DEVICE_ID_BHAVANI__98b0         0x98b0      // OBSOLETE - don't use \n#define DEVICE_ID_BHAVANI__98b1         0x98b1      // OBSOLETE - don't use \n\n\n// Define AMD's internal revision numbers.\n#define INTERNAL_REV_KALINDI_A0       0x00       // The First revision of KALINDI GFX.\n#define INTERNAL_REV_KALINDI_A1       0x01       // The Second revision of KALINDI GFX.\n#define INTERNAL_REV_KALINDI_A2       0x02       // GF version of KALINDI GFX which is BHAVANI.\n\n// Define AMD's external revision numbers.\n#define EXTERNAL_REV_KALINDI         0x00\n\n//\n// Define Chip ID's for Godavari\n//\n\n// Mobile\n#define DEVICE_ID_GODAVARI__9850         0x9850      // FT3 socket,  \n#define DEVICE_ID_GODAVARI__9851         0x9851      // FT3 socket,  \n#define DEVICE_ID_GODAVARI__9852         0x9852      // FT3 socket,  \n#define DEVICE_ID_GODAVARI__9853         0x9853      // FT3 socket,  \n#define DEVICE_ID_GODAVARI__9854         0x9854      // FT3 socket,  \n#define DEVICE_ID_GODAVARI__9855         0x9855      // FT3 socket,  \n#define DEVICE_ID_GODAVARI__9856         0x9856      // FT3 socket,  \n#define DEVICE_ID_GODAVARI__9857         0x9857      // FT3 socket,  \n#define DEVICE_ID_GODAVARI__9858         0x9858      // FT3 socket,  \n#define DEVICE_ID_GODAVARI__9859         0x9859      // FT3 socket,  \n#define DEVICE_ID_GODAVARI__985a         0x985a      // FT3 socket,  \n#define DEVICE_ID_GODAVARI__985b         0x985b      // FT3 socket,  \n#define DEVICE_ID_GODAVARI__985c         0x985c      // FT3 socket,  \n#define DEVICE_ID_GODAVARI__985d         0x985d      // FT3 socket,  \n#define DEVICE_ID_GODAVARI__985e         0x985e      // FT3 socket,  \n#define DEVICE_ID_GODAVARI__985f         0x985f      // FT3 socket,  \n\n// Define AMD's internal revision numbers.\n#define INTERNAL_REV_GODAVARI_A0      0x00       // The First revision of GODAVARI GFX.\n#define INTERNAL_REV_GODAVARI_A1      0x01       // The Second revision of GODAVARI GFX.\n\n// Define AMD's external revision numbers.\n#define EXTERNAL_REV_GODAVARI         0x00\n\n\n\n// This macro will be remove later on (keep it for now for for capability purpose)\n#define ASICREV_IS_GODAVARI(eChipRev) ((eChipRev >= ML_GODAVARI_A0) && (eChipRev < KV_UNKNOWN))       // identify all versions of KALINDI and supported features set\n\n\n\n#endif  // KV_ID_H\n"
  },
  {
    "path": "src/Wrapper/amd-codexl-analyzer/CommonProjects/AMDTBackend/Include/Common/asic_reg/northernisland_id.h",
    "content": "//=====================================================================\n// Copyright 2016 (c), Advanced Micro Devices, Inc. All rights reserved.\n//\n/// \\author AMD Developer Tools Team\n/// \\file \n/// \n//=====================================================================/*****************************************************************************\\\n*\n*  Module Name    northernisland_id.h\n*  Project        NORTHERNISLANDS\n*  Devices        NORTHERNISLANDS\n*\n*  Description    Defining Device IDs, ASIC revision IDs for NORTHERNISLANDS\n*\n*\n*  (c) 2009 Advanced Micro Devices, Inc. (unpublished)\n*\n*  All rights reserved.  This notice is intended as a precaution against\n*  inadvertent publication and does not imply publication or any waiver\n*  of confidentiality.  The year included in the foregoing notice is the\n*  year of creation of the work.\n*\n*  LOG OF CHANGES\n*\n\\*****************************************************************************/\n\n#ifndef _NORTHERNISLAND_ID_H\n#define _NORTHERNISLAND_ID_H\n\nenum\n{\n    NI_CAYMAN_P_A11           = 1,\n\n    NI_BARTS_PM_A11           = 20,\n\n    NI_TURKS_M_A11            = 40,\n    NI_TURKS_LOMBOK_M_A11     = 50,\n\n    NI_CAICOS_V_A11           = 60,\n    NI_CAICOS_V_A12           = 61,\n\n    KAUAI_A11                 = 80,    // not a production part\n\n    NORTHERNISLAND_UNKNOWN    = 0xFF\n};\n\n\n#define ASICREV_IS_CAYMAN_P(eChipRev)       (eChipRev < NI_BARTS_PM_A11)\n#define ASICREV_IS_BARTS_PM(eChipRev)       ((eChipRev >= NI_BARTS_PM_A11) && (eChipRev < NI_TURKS_M_A11))\n#define ASICREV_IS_TURKS_M(eChipRev)        ((eChipRev >= NI_TURKS_M_A11) && (eChipRev < NI_CAICOS_V_A11))\n#define ASICREV_IS_TURKS_LOMBOK_M(eChipRev) ((eChipRev >= NI_TURKS_LOMBOK_M_A11) && (eChipRev < NI_CAICOS_V_A11))  // this change is intentional.  ASICREV_IS_TURKS_LOMBOK_M is a subset of ASICREV_IS_TURKS_M\n#define ASICREV_IS_CAICOS_V(eChipRev)       ((eChipRev >= NI_CAICOS_V_A11) && (eChipRev < KAUAI_A11))\n#define ASICREV_IS_KAUAI(eChipRev)          (eChipRev >= KAUAI_A11)\n\n\n//\n// CAYMAN/GRANVILLE ISLAND device IDs\n//\n#define DEVICE_ID_NI_CAYMAN_P_6700          0x6700    //Cayman GL XT (Cliffhanger)\n#define DEVICE_ID_NI_CAYMAN_P_6701          0x6701    //Cayman GL XT (Moonracer)\n#define DEVICE_ID_NI_CAYMAN_P_6702          0x6702    //Cayman GL XT (Spellbreaker)\n#define DEVICE_ID_NI_CAYMAN_P_6703          0x6703    //Cayman GL XT\n#define DEVICE_ID_NI_CAYMAN_P_6704          0x6704    //Cayman GL PRO (Starsaber)\n#define DEVICE_ID_NI_CAYMAN_P_6705          0x6705    //Cayman GL PRO\n#define DEVICE_ID_NI_CAYMAN_P_6706          0x6706    //Cayman GL (Doubleheader)\n#define DEVICE_ID_NI_CAYMAN_P_6707          0x6707    //Cayman GL LE (Jetstorm)\n#define DEVICE_ID_NI_CAYMAN_P_6708          0x6708    //Cayman GL\n#define DEVICE_ID_NI_CAYMAN_P_6709          0x6709    //Cayman GL\n#define DEVICE_ID_NI_CAYMAN_P_6718          0x6718    //Cayman XT\n#define DEVICE_ID_NI_CAYMAN_P_6719          0x6719    //Cayman Pro\n#define DEVICE_ID_NI_CAYMAN_P_671C          0x671C    //Antilles Pro\n#define DEVICE_ID_NI_CAYMAN_P_671D          0x671D    //Antilles XT\n#define DEVICE_ID_NI_CAYMAN_P_671F          0x671F    //Cayman CE\n\n// CAYMAN ASIC internal revision number\n#define INTERNAL_REV_NI_CAYMAN_P_A11        0x00      // First spin of Cayman\n\n\n#define DEVICE_ID_CAYMAN_PALLADIUM          0x0031    // Palladium ID\n#define DEVICE_ID_CAYMAN_LITE_PALLADIUM     0x0032    // Palladium ID\n\n\n//\n// BARTS/BLACKCOMB device IDs\n//\n#define DEVICE_ID_NI_BARTS_PM_6722          0x6722    //Barts GL2\n#define DEVICE_ID_NI_BARTS_PM_6723          0x6723    //Barts GL3\n#define DEVICE_ID_NI_BARTS_PM_6726          0x6726    //Barts GL6\n#define DEVICE_ID_NI_BARTS_PM_6727          0x6727    //Barts GL7\n#define DEVICE_ID_NI_BARTS_PM_6728          0x6728    //Barts GL XT\n#define DEVICE_ID_NI_BARTS_PM_6729          0x6729    //Barts GL PRO\n#define DEVICE_ID_NI_BARTS_PM_6738          0x6738    //Barts XT\n#define DEVICE_ID_NI_BARTS_PM_6739          0x6739    //Barts PRO\n#define DEVICE_ID_NI_BARTS_PM_673E          0x673E    //Barts LE\n\n#define DEVICE_ID_NI_BARTS_PM_6720          0x6720    //Blackcomb XT/PRO and GL XT/PRO\n#define DEVICE_ID_NI_BARTS_PM_6721          0x6721    //Blackcomb LP and GL LP\n#define DEVICE_ID_NI_BARTS_PM_6724          0x6724    //Blackcomb XT/PRO Gemini and XT GL/PRO Gemini\n#define DEVICE_ID_NI_BARTS_PM_6725          0x6725    //Blackcomb LP Gemini and GL LP Gemini\n#define DEVICE_ID_NI_BARTS_PM_6730          0x6730    //Victoria - Blackcomb for desktop all-in-one\n\n// BARTS ASIC internal revision number\n#define INTERNAL_REV_NI_BARTS_PM_A11        0x00      // First spin of Barts\n\n\n//\n// TURKS/WHISTLER device IDs\n//\n#define DEVICE_ID_NI_TURKS_M_6746           0x6746    // Turks GL6\n#define DEVICE_ID_NI_TURKS_M_6747           0x6747    // Turks GL7\n#define DEVICE_ID_NI_TURKS_M_6748           0x6748    // Turks GL8\n#define DEVICE_ID_NI_TURKS_M_6749           0x6749    // Turks GL9\n#define DEVICE_ID_NI_TURKS_M_674A           0x674A    // Turks GL\n#define DEVICE_ID_NI_TURKS_M_6750           0x6750    // Onega\n#define DEVICE_ID_NI_TURKS_M_6751           0x6751    // Onega2\n#define DEVICE_ID_NI_TURKS_M_6758           0x6758    // Turks XT\n#define DEVICE_ID_NI_TURKS_M_6759           0x6759    // Turks Pro\n#define DEVICE_ID_NI_TURKS_M_675B           0x675B    // Turks XT2\n#define DEVICE_ID_NI_TURKS_M_675D           0x675D    // Turks Pro2\n#define DEVICE_ID_NI_TURKS_M_675F           0x675F    // Turks LE\n\n#define DEVICE_ID_NI_TURKS_M_6740           0x6740    // Whistler XT/GL XT\n#define DEVICE_ID_NI_TURKS_M_6741           0x6741    // Whistler Pro/LP/GL Pro/GL LP\n#define DEVICE_ID_NI_TURKS_M_6742           0x6742    // Whistler LE\n#define DEVICE_ID_NI_TURKS_M_6743           0x6743    // WhistlerCSP Pro\n#define DEVICE_ID_NI_TURKS_M_6744           0x6744    // Whistler XT/PRO Gemini and GL XT/PRO Gemini\n#define DEVICE_ID_NI_TURKS_M_6745           0x6745    // Whistler LP 256 G5\n#define DEVICE_ID_NI_TURKS_M_6843           0x6843    // Whistler XTX\n\n// TURKS ASIC internal revision number\n#define INTERNAL_REV_NI_TURKS_M_A11         0x00      // First spin of Turks\n\n\n//\n// LOMBOK/THAMES MOBILE device IDs\n//\n\n#define DEVICE_ID_NI_LOMBOK_M_6849              0x6849    // Lombok XT GL\n#define DEVICE_ID_NI_LOMBOK_M_6850              0x6850    // Lombok AIO\n#define DEVICE_ID_NI_LOMBOK_M_6858              0x6858    // Lombok XT\n#define DEVICE_ID_NI_LOMBOK_M_6859              0x6859    // Lombok Pro\n\n#define DEVICE_ID_NI_LOMBOK_M_6840              0x6840    // Thames XT/GL\n#define DEVICE_ID_NI_LOMBOK_M_6841              0x6841    // Thames Pro\n#define DEVICE_ID_NI_LOMBOK_M_6842              0x6842    // Thames LE\n\n// Lombok ASIC internal revision number\n#define INTERNAL_REV_NI_LOMBOK_M_A11            0x00      // First spin of Lombok\n\n\n//\n// CAICOS/SEYMOUR device IDs\n//\n#define DEVICE_ID_NI_CAICOS_V_6762          0x6762    // Caicos GL2\n#define DEVICE_ID_NI_CAICOS_V_6763          0x6763    // Caicos CSP512 G5\n#define DEVICE_ID_NI_CAICOS_V_6766          0x6766    // Caicos GL6\n#define DEVICE_ID_NI_CAICOS_V_6767          0x6767    // Caicos GL7\n#define DEVICE_ID_NI_CAICOS_V_6768          0x6768    // Caicos GL PRO\n#define DEVICE_ID_NI_CAICOS_V_6770          0x6770    // Caspian PRO (Caicos AiO)\n#define DEVICE_ID_NI_CAICOS_V_6771          0x6771    // Caicos XTX\n#define DEVICE_ID_NI_CAICOS_V_6772          0x6772    // Caspian PRO2 (Caicos AiO)\n#define DEVICE_ID_NI_CAICOS_V_6778          0x6778    // Caicos XT\n#define DEVICE_ID_NI_CAICOS_V_6779          0x6779    // Caicos PRO\n#define DEVICE_ID_NI_CAICOS_V_677B          0x677B    // Caicos PRO2\n\n#define DEVICE_ID_NI_CAICOS_V_6760          0x6760    // Seymour XT/PRO and XT/PRO GL\n#define DEVICE_ID_NI_CAICOS_V_6761          0x6761    // Seymour LP and LP GL\n#define DEVICE_ID_NI_CAICOS_V_6764          0x6764    // Seymour XT/PRO GL and GL XT/PRO Gemini\n#define DEVICE_ID_NI_CAICOS_V_6765          0x6765    // Seymour LP and GL LP Gemini\n\n// CAICOS ASIC internal revision number\n#define INTERNAL_REV_NI_CAICOS_V_A11        0x00      // First spin of Caicos\n#define INTERNAL_REV_NI_CAICOS_V_A12        0x01      // A12 spin of Caicos\n\n#define DEVICE_ID_CAICOS_PALLADIUM          0x0030    // Palladium ID\n\n\n//\n// KAUAI device IDs - Kauai is not a production part.\n//\n\n#define DEVICE_ID_KAUAI_PALLADIUM           0x0018    // Palladium ID\n\n// KAUAI ASIC internal revision number\n#define INTERNAL_REV_KAUAI_A11              0x00      // First spin of KAUAI\n\n\n// The follow definitions are defined for backward compatibility\n// when the new naming convention is followed.\n// Please use the new names instead of these\n#define CAYMAN_A11                   NI_CAYMAN_P_A11\n#define BARTS_A11                    NI_BARTS_PM_A11\n#define TURKS_A11                    NI_TURKS_M_A11\n#define CAICOS_A11                   NI_CAICOS_V_A11\n#define ASICREV_IS_CAYMAN(eChipRev)  ASICREV_IS_CAYMAN_P(eChipRev)\n#define ASICREV_IS_BARTS(eChipRev)   ASICREV_IS_BARTS_PM(eChipRev)\n#define ASICREV_IS_TURKS(eChipRev)   ASICREV_IS_TURKS_M(eChipRev)\n#define ASICREV_IS_CAICOS(eChipRev)  ASICREV_IS_CAICOS_V(eChipRev)\n#define INTERNAL_REV_CAYMAN_A11      INTERNAL_REV_NI_CAYMAN_P_A11\n#define INTERNAL_REV_BARTS_A11       INTERNAL_REV_NI_BARTS_PM_A11\n#define INTERNAL_REV_TURKS_A11       INTERNAL_REV_NI_TURKS_M_A11\n#define INTERNAL_REV_CAICOS_A11      INTERNAL_REV_NI_CAICOS_V_A11\n#define DEVICE_ID_CAICOS_6768        DEVICE_ID_NI_CAICOS_V_6768\n#define DEVICE_ID_CAICOS_6770        DEVICE_ID_NI_CAICOS_V_6770\n#define DEVICE_ID_CAICOS_6779        DEVICE_ID_NI_CAICOS_V_6779\n#define DEVICE_ID_CAICOS_6760        DEVICE_ID_NI_CAICOS_V_6760\n#define DEVICE_ID_CAICOS_6761        DEVICE_ID_NI_CAICOS_V_6761\n\n\n\n// the below definitions are obsolete and will be removed at appropriate time.\n// Please don't use them.\n\n#define IBIZA_A11                    NI_CAYMAN_P_A11\n#define COZUMEL_A11                  NI_BARTS_PM_A11\n#define ASICREV_IS_IBIZA(eChipRev)   (eChipRev < NI_BARTS_PM_A11)\n#define ASICREV_IS_COZUMEL(eChipRev) ((eChipRev >= NI_BARTS_PM_A11) && (eChipRev < NI_TURKS_M_A11))\n\n\n//\n// IBIZA/IBIZA mobile device IDs\n//\n\n#define DEVICE_ID_IBIZA_PALLADIUM           0x0016    // Palladium ID\n#define DEVICE_ID_IBIZA_LITE_PALLADIUM      0x0020    // Palladium ID\n\n// IBIZA ASIC internal revision number\n#define INTERNAL_REV_IBIZA_A11              0x00      // First spin of IBIZA\n\n\n//\n// COZUMEL/COZUMEL mobile device IDs\n//\n\n#define DEVICE_ID_COZUMEL_PALLADIUM         0x0017    // Palladium ID\n\n// COZUMEL ASIC internal revision number\n#define INTERNAL_REV_COZUMEL_A11            0x00      // First spin of COZUMEL\n\n\n#endif  // _NORTHERNISLAND_ID_H\n"
  },
  {
    "path": "src/Wrapper/amd-codexl-analyzer/CommonProjects/AMDTBackend/Include/Common/asic_reg/si_id.h",
    "content": "//=====================================================================\n// Copyright 2009-2016 (c), Advanced Micro Devices, Inc. All rights reserved.\n//\n/// \\author AMD Developer Tools Team\n/// \\file \n/// \n//=====================================================================\n/*****************************************************************************\\\n*\n*  Module Name    si_id.h\n*  Project        SOUTHERN ISLANDS\n*  Devices        SOUTHERN ISLANDS\n*\n*  Description    Defining Device IDs, ASIC revision IDs for SOUTHERN ISLANDS\n*\n\\*****************************************************************************/\n\n#ifndef _SI_ID_H\n#define _SI_ID_H\n\nenum\n{\n    SI_TAHITI_P_A11      = 1,\n    SI_TAHITI_P_A0       = SI_TAHITI_P_A11,      //A0 is alias of A11\n    SI_TAHITI_P_A21      = 5,\n    SI_TAHITI_P_B0       = SI_TAHITI_P_A21,      //B0 is alias of A21\n    SI_TAHITI_P_A22      = 6,\n    SI_TAHITI_P_B1       = SI_TAHITI_P_A22,      //B1 is alias of A22\n\n    SI_PITCAIRN_PM_A11   = 20,\n    SI_PITCAIRN_PM_A0    = SI_PITCAIRN_PM_A11,   //A0 is alias of A11\n    SI_PITCAIRN_PM_A12   = 21,\n    SI_PITCAIRN_PM_A1    = SI_PITCAIRN_PM_A12,   //A1 is alias of A12\n\n    SI_CAPEVERDE_M_A11   = 40,\n    SI_CAPEVERDE_M_A0    = SI_CAPEVERDE_M_A11,   //A0 is alias of A11\n    SI_CAPEVERDE_M_A12   = 41,\n    SI_CAPEVERDE_M_A1    = SI_CAPEVERDE_M_A12,   //A1 is alias of A12\n\n    SI_OLAND_M_A0        = 60,\n\n    SI_HAINAN_V_A0       = 70,\n\n    SI_UNKNOWN           = 0xFF\n};\n\n\n#define ASICREV_IS_TAHITI_P(eChipRev)     (eChipRev < SI_PITCAIRN_PM_A11)\n#define ASICREV_IS_PITCAIRN_PM(eChipRev)  ((eChipRev >= SI_PITCAIRN_PM_A11) && (eChipRev < SI_CAPEVERDE_M_A11))\n#define ASICREV_IS_CAPEVERDE_M(eChipRev)  ((eChipRev >= SI_CAPEVERDE_M_A11) && (eChipRev < SI_OLAND_M_A0))\n#define ASICREV_IS_OLAND_M(eChipRev)      ((eChipRev >= SI_OLAND_M_A0) && (eChipRev < SI_HAINAN_V_A0))\n#define ASICREV_IS_HAINAN_V(eChipRev)     (eChipRev >= SI_HAINAN_V_A0)\n\n\n//\n// TAHITI ISLAND device IDs (Performance segment)\n//\n#define DEVICE_ID_SI_TAHITI_P_6780              0x6780    //Tahiti XT GL\n#define DEVICE_ID_SI_TAHITI_P_6784              0x6784    //obsolete\n#define DEVICE_ID_SI_TAHITI_P_6788              0x6788    //Tahiti XT GL (FirePro)\n#define DEVICE_ID_SI_TAHITI_P_678A              0x678A    //Tahiti PRO GL\n#define DEVICE_ID_SI_TAHITI_P_6790              0x6790    //Aruba XT\n#define DEVICE_ID_SI_TAHITI_P_6791              0x6791    //Malta\n#define DEVICE_ID_SI_TAHITI_P_6792              0x6792    //Aruba PRO\n#define DEVICE_ID_SI_TAHITI_P_6798              0x6798    //Tahiti XT\n#define DEVICE_ID_SI_TAHITI_P_6799              0x6799    //New Zeland\n#define DEVICE_ID_SI_TAHITI_P_679A              0x679A    //Tahiti PRO\n#define DEVICE_ID_SI_TAHITI_P_679B              0x679B    //Malta\n#define DEVICE_ID_SI_TAHITI_P_679E              0x679E    //Tahiti LE\n#define DEVICE_ID_SI_TAHITI_P_679F              0x679F    //Aruba Pro\n\n// TAHITI ASIC internal revision number\n#define INTERNAL_REV_SI_TAHITI_P_A11            0x00      // First spin of Tahiti\n#define INTERNAL_REV_SI_TAHITI_P_A0             INTERNAL_REV_SI_TAHITI_P_A11\n#define INTERNAL_REV_SI_TAHITI_P_A21            0x01      // Second spin of Tahiti\n#define INTERNAL_REV_SI_TAHITI_P_B0             INTERNAL_REV_SI_TAHITI_P_A21\n#define INTERNAL_REV_SI_TAHITI_P_A22            0x02      // Third spin of Tahiti\n#define INTERNAL_REV_SI_TAHITI_P_B1             INTERNAL_REV_SI_TAHITI_P_A22\n\n#define DEVICE_ID_SI_TAHITI_P_LITE_PALLADIUM    0x0022    // Palladium ID\n\n\n//\n// PITCAIRN/WIMBLEDON device IDs (Performance to Mainstream segment)\n//\n#define DEVICE_ID_SI_PITCAIRN_PM_6808           0x6808    //Pitcairn GL1\n#define DEVICE_ID_SI_PITCAIRN_PM_6809           0x6809    //Pitcairn GL2\n#define DEVICE_ID_SI_PITCAIRN_PM_6810           0x6810    //Curacao XT; Trinidad XT\n#define DEVICE_ID_SI_PITCAIRN_PM_6811           0x6811    //Curacao Pro; Trinidad Pro\n#define DEVICE_ID_SI_PITCAIRN_PM_6816           0x6816    //Curacao XT\n#define DEVICE_ID_SI_PITCAIRN_PM_6817           0x6817    //Curacao PRO\n#define DEVICE_ID_SI_PITCAIRN_PM_6818           0x6818    //Pitcairn XT\n#define DEVICE_ID_SI_PITCAIRN_PM_6819           0x6819    //Pitcairn PRO\n#define DEVICE_ID_SI_PITCAIRN_PM_684C           0x684C    //Pitcairn GL\n\n#define DEVICE_ID_SI_PITCAIRN_PM_6800           0x6800    //Wimbledon XT\n#define DEVICE_ID_SI_PITCAIRN_PM_6801           0x6801    //Wimbledon PRO/LP\n#define DEVICE_ID_SI_PITCAIRN_PM_6802           0x6802    //Wimbledon GL\n#define DEVICE_ID_SI_PITCAIRN_PM_6806           0x6806    //Neptune XT\n\n// TRINIDAD PCI Reivsion IDs\n#define PRID_SI_PITCAIRN_TRINIDAD_81            0x81      // 0x6810: Trinidad XT; 0x6811: Trinidad Pro\n\n#define ASICDID_IS_NEPTUNE(wDID)                ((wDID == DEVICE_ID_SI_PITCAIRN_PM_6806))\n\n#define ASICID_IS_TRINIDAD(wDID, bRID)          ((bRID == PRID_SI_PITCAIRN_TRINIDAD_81) && \\\n                                                 ((wDID == DEVICE_ID_SI_PITCAIRN_PM_6810) || (wDID == DEVICE_ID_SI_PITCAIRN_PM_6811)))\n\n// PITCAIRN ASIC internal revision number\n#define INTERNAL_REV_SI_PITCAIRN_PM_A11         0x00      // First spin of Pitcairn\n#define INTERNAL_REV_SI_PITCAIRN_PM_A0          INTERNAL_REV_SI_PITCAIRN_PM_A11\n#define INTERNAL_REV_SI_PITCAIRN_PM_A12         0x01      // Second spin of Pitcairn\n#define INTERNAL_REV_SI_PITCAIRN_PM_A1          INTERNAL_REV_SI_PITCAIRN_PM_A12\n\n\n//\n// CAPE VERDE/HEATHROW/CHELSEA/VENUS/TROPO device IDs (Mainstream segment)\n//\n#define DEVICE_ID_SI_CAPEVERDE_M_6828           0x6828    //Cape Verde GL XT\n#define DEVICE_ID_SI_CAPEVERDE_M_6829           0x6829    //unused\n#define DEVICE_ID_SI_CAPEVERDE_M_682C           0x682C    //Cape Verde GL PRO\n#define DEVICE_ID_SI_CAPEVERDE_M_6830           0x6830    //Summer Palace XT AIO\n#define DEVICE_ID_SI_CAPEVERDE_M_6831           0x6831    //AIO Great Wall XT\n#define DEVICE_ID_SI_CAPEVERDE_M_6835           0x6835    //Cape Verde PRX\n#define DEVICE_ID_SI_CAPEVERDE_M_6837           0x6837    //Cape Verde LE\n#define DEVICE_ID_SI_CAPEVERDE_M_6838           0x6838    //Cape Verde XTX\n#define DEVICE_ID_SI_CAPEVERDE_M_6839           0x6839    //Cape Verde XT\n#define DEVICE_ID_SI_CAPEVERDE_M_683B           0x683B    //Cape Verde PRO\n#define DEVICE_ID_SI_CAPEVERDE_M_683D           0x683D    //Cape Verde XT\n#define DEVICE_ID_SI_CAPEVERDE_M_683F           0x683F    //Cape Verde PRO\n\n#define DEVICE_ID_SI_CAPEVERDE_M_6820           0x6820    //Venus XTX; Tropo XTX/XT\n#define DEVICE_ID_SI_CAPEVERDE_M_6821           0x6821    //Venus XT; Tropo PRO\n#define DEVICE_ID_SI_CAPEVERDE_M_6822           0x6822    //Venus Pro MCM\n#define DEVICE_ID_SI_CAPEVERDE_M_6823           0x6823    //Venus PRO; Tropo UL\n#define DEVICE_ID_SI_CAPEVERDE_M_6824           0x6824    //Chelsea PROA\n#define DEVICE_ID_SI_CAPEVERDE_M_6825           0x6825    //Heathrow XT\n#define DEVICE_ID_SI_CAPEVERDE_M_6826           0x6826    //Chelsea LP\n#define DEVICE_ID_SI_CAPEVERDE_M_6827           0x6827    //Heathrow PRO\n#define DEVICE_ID_SI_CAPEVERDE_M_682A           0x682A    //Venus Pro MCM\n#define DEVICE_ID_SI_CAPEVERDE_M_682B           0x682B    //Venus LE; Tropo PROL\n#define DEVICE_ID_SI_CAPEVERDE_M_682D           0x682D    //Chelsea XT\n#define DEVICE_ID_SI_CAPEVERDE_M_682F           0x682F    //Chelsea PRO\n\n// TROPO PCI Reivsion IDs\n#define PRID_SI_CAPEVERDE_TROPO_81                0x81      // 0x6820: Tropo XTX\n#define PRID_SI_CAPEVERDE_TROPO_83                0x83      // 0x6820: Tropo XT; 0x6821: Tropo PRO; 0x6823: Tropo UL; 0x682B: Tropo PROL\n\n#define ASICDID_IS_VENUS(wDID)                  ((wDID == DEVICE_ID_SI_CAPEVERDE_M_6820) || \\\n                                                 (wDID == DEVICE_ID_SI_CAPEVERDE_M_6821) || \\\n                                                 (wDID == DEVICE_ID_SI_CAPEVERDE_M_6822) || \\\n                                                 (wDID == DEVICE_ID_SI_CAPEVERDE_M_6823) || \\\n                                                 (wDID == DEVICE_ID_SI_CAPEVERDE_M_682A) || \\\n                                                 (wDID == DEVICE_ID_SI_CAPEVERDE_M_682B))\n\n#define ASICID_IS_TROPO(wDID, bRID)             (((wDID == DEVICE_ID_SI_CAPEVERDE_M_6820) && ((bRID == PRID_SI_CAPEVERDE_TROPO_81) || (bRID == PRID_SI_CAPEVERDE_TROPO_83))) || \\\n                                                 (((wDID == DEVICE_ID_SI_CAPEVERDE_M_6821) || (wDID == DEVICE_ID_SI_CAPEVERDE_M_6823) || (wDID == DEVICE_ID_SI_CAPEVERDE_M_682B)) && (bRID == PRID_SI_CAPEVERDE_TROPO_83)))\n\n// CAPE VERDE ASIC internal revision number\n#define INTERNAL_REV_SI_CAPEVERDE_M_A11         0x00      // First spin of Cape Verde\n#define INTERNAL_REV_SI_CAPEVERDE_M_A0          INTERNAL_REV_SI_CAPEVERDE_M_A11\n#define INTERNAL_REV_SI_CAPEVERDE_M_A12         0x01      // Second spin of Cape Verde\n#define INTERNAL_REV_SI_CAPEVERDE_M_A1          INTERNAL_REV_SI_CAPEVERDE_M_A12\n\n#define DEVICE_ID_SI_CAPEVERDE_M_LITE_PALLADIUM 0x0026    // Palladium ID\n\n\n//\n// OLAND/MARS/OPAL/LITHO device IDs\n//\n#define DEVICE_ID_SI_OLAND_M_6608               0x6608    // Oland PRO GL\n#define DEVICE_ID_SI_OLAND_M_6610               0x6610    // Oland 128 XT\n#define DEVICE_ID_SI_OLAND_M_6611               0x6611    // Oland 128 PRO (6CU)\n#define DEVICE_ID_SI_OLAND_M_6613               0x6613    // Oland 128 PRO (5CU)\n#define DEVICE_ID_SI_OLAND_M_6631               0x6631    // Oland 64 LE\n\n#define DEVICE_ID_SI_OLAND_M_6600               0x6600    // Mars 128/64 XT; Litho XT\n#define DEVICE_ID_SI_OLAND_M_6601               0x6601    // Mars 128/64 PRO, Mars 128 LP\n#define DEVICE_ID_SI_OLAND_M_6602               0x6602    // Mars 128 XTX\n#define DEVICE_ID_SI_OLAND_M_6603               0x6603    // obsolete\n#define DEVICE_ID_SI_OLAND_M_6604               0x6604    // Opal 128 XT; Litho Pro\n#define DEVICE_ID_SI_OLAND_M_6605               0x6605    // Opal 128 PRO; Litho UL\n#define DEVICE_ID_SI_OLAND_M_6606               0x6606    // Mars 128 XTX (Generic)\n#define DEVICE_ID_SI_OLAND_M_6607               0x6607    // Mars LE\n#define DEVICE_ID_SI_OLAND_M_6620               0x6620    // obsolete\n#define DEVICE_ID_SI_OLAND_M_6621               0x6621    // Mars 64 PRO\n#define DEVICE_ID_SI_OLAND_M_6623               0x6623    // Mars 64 LE\n\n// LITHO PCI Reivsion IDs\n#define PRID_SI_OLAND_LITHO_80                    0x80      // \n#define PRID_SI_OLAND_LITHO_81                    0x81      // 0x6600: Litho XT; 0x6604: Litho Pro; 0x6605: Litho UL\n\n#define ASICDID_IS_MARS(wDID)                   ((wDID == DEVICE_ID_SI_OLAND_M_6600) || \\\n                                                 (wDID == DEVICE_ID_SI_OLAND_M_6601) || \\\n                                                 (wDID == DEVICE_ID_SI_OLAND_M_6602) || \\\n                                                 (wDID == DEVICE_ID_SI_OLAND_M_6606) || \\\n                                                 (wDID == DEVICE_ID_SI_OLAND_M_6607) || \\\n                                                 (wDID == DEVICE_ID_SI_OLAND_M_6621) || \\\n                                                 (wDID == DEVICE_ID_SI_OLAND_M_6623))\n\n#define ASICDID_IS_OPAL(wDID)                   ((wDID == DEVICE_ID_SI_OLAND_M_6604) || \\\n                                                 (wDID == DEVICE_ID_SI_OLAND_M_6605))\n\n#define ASICID_IS_LITHO(wDID, bRID)             (((wDID == DEVICE_ID_SI_OLAND_M_6600) || (wDID == DEVICE_ID_SI_OLAND_M_6604) || (wDID == DEVICE_ID_SI_OLAND_M_6605)) && \\\n                                                 (bRID == PRID_SI_OLAND_LITHO_81))\n\n// OLAND ASIC internal revision number\n#define INTERNAL_REV_SI_OLAND_M_A0              0x00      // First spin of Oland\n\n//\n// HAINAN/SUN/EXO device IDs\n//\n#define DEVICE_ID_SI_HAINAN_V_6660              0x6660    //Sun XT; Exo XT/PRO\n#define DEVICE_ID_SI_HAINAN_V_6663              0x6663    //Sun PRO; Exo ULT\n#define DEVICE_ID_SI_HAINAN_V_6664              0x6664    //Jet XT\n#define DEVICE_ID_SI_HAINAN_V_6665              0x6665    //Jet PRO; Exo UL\n#define DEVICE_ID_SI_HAINAN_V_6667              0x6667    //Jet ULT; Exo ULP\n#define DEVICE_ID_SI_HAINAN_V_666F              0x666F    //Sun LE\n\n// EXO PCI Reivsion IDs\n#define PRID_SI_HAINAN_EXO_81                     0x81      // 0x6660: Exo XT\n#define PRID_SI_HAINAN_EXO_83                     0x83      // 0x6660: Exo Pro; 0x6663: Exo ULT; 0x6665: Exo UL; 0x6667: Exo ULP\n\n#define ASICDID_IS_JET(wDID)                    ((wDID == DEVICE_ID_SI_HAINAN_V_6664) || \\\n                                                 (wDID == DEVICE_ID_SI_HAINAN_V_6665) || \\\n                                                 (wDID == DEVICE_ID_SI_HAINAN_V_6667))\n\n#define ASICID_IS_EXO(wDID, bRID)               (((wDID == DEVICE_ID_SI_HAINAN_V_6660) && ((bRID == PRID_SI_HAINAN_EXO_81) || (bRID == PRID_SI_HAINAN_EXO_83))) || \\\n                                                 (((wDID == DEVICE_ID_SI_HAINAN_V_6663) || (wDID == DEVICE_ID_SI_HAINAN_V_6665) || (wDID == DEVICE_ID_SI_HAINAN_V_6667)) && (bRID == PRID_SI_HAINAN_EXO_83)))\n\n// HAINAN ASIC internal revision number\n#define INTERNAL_REV_SI_HAINAN_V_A0             0x00      // First spin of Hainan\n\n#endif  // _SI_ID_H\n"
  },
  {
    "path": "src/Wrapper/amd-codexl-analyzer/CommonProjects/AMDTBackend/Include/Common/asic_reg/sumo_id.h",
    "content": "//=====================================================================\n// Copyright 2016 (c), Advanced Micro Devices, Inc. All rights reserved.\n//\n/// \\author AMD Developer Tools Team\n/// \\file \n/// \n//=====================================================================/*****************************************************************************\\\n*\n*  Module Name    Sumo_id.h\n*  Project        Llano/Ontario definitions (SuperSumo, Sumo , Wrestler)\n*  Device         Sumo, Wrestler\n*\n*  Description    Identifier file for SUMO driver\n*\n*\n*  (c) 2009 AMD (unpublished)\n*\n*  All rights reserved.  This notice is intended as a precaution against\n*  inadvertent publication and does not imply publication or any waiver\n*  of confidentiality.  The year included in the foregoing notice is the\n*  year of creation of the work.\n*\n*  LOG OF CHANGES\n*\n*  1.0    07/09/09 [ilitchma] - initial revision\n*  1.1    01/20/10 [jamesmar] - add Wrestler ID 0x9802 for Ontario.\n*\n\\*****************************************************************************/\n\n#ifndef _SUMO_ID_H\n#define _SUMO_ID_H\n\n//SUMO section\n\nenum\n{\n    SUPERSUMO_A0    = 0x01,     //Sumo 4-5-5-2\n    SUPERSUMO_B0    = 0x02,\n    SUMO_A0         = 0x11,     //Sumo 4-2-2-1\n    SUMO_B0         = 0x12,\n    WRESTLER_A0     = 0x21,     //Sumo-lite 2-2-2-1\n    WRESTLER_A1     = 0x22,     //Sumo-lite 2-2-2-1\n    WRESTLER_B0     = 0x23,     //Sumo-lite 2-2-2-1\n    WRESTLER_C0     = 0x24,     //Sumo-lite 2-2-2-1\n    BHEEM_A0        = 0x41,     //Sumo-lite 2-2-2-1\n    SUMO_UNKNOWN = 0xFF\n};\n\n#define ASICREV_IS_SUPERSUMO(eChipRev)    ((eChipRev >= SUPERSUMO_A0) && (eChipRev < SUMO_A0))\n#define ASICREV_IS_SUMO(eChipRev)         ((eChipRev >= SUMO_A0) && (eChipRev < WRESTLER_A0))\n#define ASICREV_IS_WRESTLER(eChipRev)     ((eChipRev >= WRESTLER_A0) && (eChipRev < BHEEM_A0))\n#define ASICREV_IS_WRESTLER_Cx(eChipRev) ((eChipRev >= WRESTLER_C0) && (eChipRev < BHEEM_A0))\n#define ASICREV_IS_BHEEM(eChipRev)        ((eChipRev >= BHEEM_A0) && (eChipRev < SUMO_UNKNOWN))\n\n#define ASIC_IS_SSTRIPPED_SUMO(ChipID)   ( (ChipID == DEVICE_ID_SUMO_SSTRIPPED_DESKTOP) ||  \\\n                                           (ChipID == DEVICE_ID_SUMO_SSTRIPPED_MOBILE) )\n\n#define ASICREV_IS_SUMO_B0_OR_NEWER(eChipRev) ( ((eChipRev & 0x0f) >= SUPERSUMO_B0) && (eChipRev < WRESTLER_A0) )  // Low 4 bits to identify ASIC Rev, \n// high 4 bits to identify SuperSumo/Sumo/Wrestler.\n\n\n//\n// Define Chip ID's for SUMO family\n//\n#define DEVICE_ID_SUMO_SUPER_DESKTOP        0x9640      //FM1 socket,4-5-5-2 (QP-SIMD-TP-RB)\n#define DEVICE_ID_SUMO_SUPER_MOBILE         0x9641      //FS1 4-5-5-2\n#define DEVICE_ID_SUMO_SSTRIPPED_DESKTOP    0x9642      //FM1 socket,4-2-2-1, Same die as SuperSumo fused to Sumo GFX configuration\n#define DEVICE_ID_SUMO_SSTRIPPED_MOBILE     0x9643      //FS1 4-2-2-1, Same die as SuperSumo fused to Sumo GFX configuration\n#define DEVICE_ID_SUMO_DESKTOP              0x9644      //FM1 socket,4-2-2-1\n#define DEVICE_ID_SUMO_MOBILE               0x9645      //To be removed later.\n#define DEVICE_ID_SUMO_DESKTOP_9645         0x9645      //FM1 socket,4-2-2-1\n#define DEVICE_ID_SUMO_SUPER_MOBILE_9647    0x9647      //FS1 4-4-4-2\n#define DEVICE_ID_SUMO_MOBILE_9648          0x9648      //To be removed later.\n#define DEVICE_ID_SUMO_SUPER_MOBILE_9648    0x9648      //FS1 4-3-3-2\n#define DEVICE_ID_SUMO_MOBILE_9649          0x9649      //FS1 4-2-2-1\n#define DEVICE_ID_SUMO_SUPER_DESKTOP_964A   0x964A      //FM1 socket,4-4-4-2 (QP-SIMD-TP-RB)\n#define DEVICE_ID_SUMO_SUPER_MOBILE_964E    0x964E      //FP1F 4-5-5-2\n#define DEVICE_ID_SUMO_SUPER_MOBILE_964F    0x964F      //FP1F 4-5-5-2\n\n\n#define DEVICE_ID_WRESTLER                  0x9802      //FT1 2-2-2-1\n#define DEVICE_ID_WRESTLER_9803             0x9803      //FT1 2-2-2-1\n#define DEVICE_ID_WRESTLER_9804             0x9804      //FT1 2-2-2-1\n#define DEVICE_ID_WRESTLER_9805             0x9805      //FT1 2-2-2-1\n#define DEVICE_ID_WRESTLER_9806             0x9806      //FT1 2-2-2-1\n#define DEVICE_ID_WRESTLER_9807             0x9807      //FT1 2-2-2-1\n#define DEVICE_ID_WRESTLER_9808             0x9808      //FT1 2-2-2-1\n#define DEVICE_ID_WRESTLER_9809             0x9809      //FT1 2-2-2-1\n#define DEVICE_ID_WRESTLER_980A             0x980A      //FT1 2-2-2-1\n\n#define DEVICE_ID_BHEEM                     0x1300      //FT1 2-2-2-1\n#define DEVICE_ID_BHEEM_1301                0x1301      //FT1 2-2-2-1\n#define DEVICE_ID_BHEEM_1302                0x1302      //FT1 2-2-2-1\n\n//\n// Define AMD's internal revision numbers.\n//\n#define INTERNAL_REV_SUMO_A11       0x00  // The First revision of SUMO ASIC.\n#define INTERNAL_REV_SUMO_A0        0x00  // The First revision of SUMO ASIC.\n#define INTERNAL_REV_SUMO_A1        0x01  // The Second revision of SUMO ASIC.\n#define INTERNAL_REV_SUMO_B0        0x02  // The Third revision of SUMO ASIC.\n\n//\n// Define AMD's external revision numbers.\n//\n#define EXTERNAL_REV_SUMO       0x00\n//\n// Define AMD's Wrestler internal revision numbers.\n//\n#define INTERNAL_REV_WRESTLER_A0    0x00  // The First revision of Wrestler ASIC.\n#define INTERNAL_REV_WRESTLER_A1    0x01  // The Second revision of Wrestler ASIC.\n#define INTERNAL_REV_WRESTLER_B0    0x02  // The Third  revision of Wrestler ASIC.\n#define INTERNAL_REV_WRESTLER_C0    0x03  // The Fourth  revision of Wrestler ASIC.\n\n//\n// Define AMD's Wrestler external revision numbers.\n//\n#define EXTERNAL_REV_WRESTLER   0x00\n\n// Define AMD's Bheem internal revision numbers.\n//\n#define INTERNAL_REV_BHEEM_A0    0x00  // The First revision of Bheem ASIC.\n\n//\n// Define AMD's Bheem external revision numbers.\n//\n#define EXTERNAL_REV_BHEEM   0x00\n\n#endif  // _SUMO_ID_H\n"
  },
  {
    "path": "src/Wrapper/amd-codexl-analyzer/CommonProjects/AMDTBackend/Include/Common/asic_reg/tn_id.h",
    "content": "//=====================================================================\n// Copyright 2016 (c), Advanced Micro Devices, Inc. All rights reserved.\n//\n/// \\author AMD Developer Tools Team\n/// \\file \n/// \n//=====================================================================/*****************************************************************************\\\n*\n*  Module Name    tn_id.h\n*  Project        Trinity Family\n*  Device         Devastator, Scrapper\n*\n*  Description    Identifier file for Trinity driver\n*\n*\n*  (c) 2010 AMD (unpublished)\n*\n*  All rights reserved.  This notice is intended as a precaution against\n*  inadvertent publication and does not imply publication or any waiver\n*  of confidentiality.  The year included in the foregoing notice is the\n*  year of creation of the work.\n*\n*  LOG OF CHANGES\n*\n*  1.0    10/21/10 [ilitchma] - initial revision\n*  1.1    02/24/11 [ilitchma] - updated IDs based on marketing request\n*  1.2    10/01/11 [ilitchma] - Add A1 spin definitions\n*  1.3    11/10/11 [ilitchma] - Add TN1 production DIDs\n*  1.4    07/12/12 [rdass] - Add RL (Richland - TN refresh) production DIDs\n*\n\\*****************************************************************************/\n\n#ifndef TN_ID_H\n#define TN_ID_H\n\n//DEVASTATOR section\n\nenum\n{\n    TN_DEVASTATOR_M_A0          = 0x01,       //Devastator 4-6-6-2\n    TN_DEVASTATOR_M_A1          = 0x02,       //Devastator 4-6-6-2\n\n    TN_DEVASTATOR_W_A0          = 0x11,       //Devastator Workstation 4-6-6-2\n    TN_DEVASTATOR_W_A1          = 0x12,       //Devastator Workstation 4-6-6-2\n\n    TN_DEVASTATOR_LITE_MV_A0    = 0x21,       //Devastator Lite 4-4-4-2\n    TN_DEVASTATOR_LITE_MV_A1    = 0x22,       //Devastator Lite 4-4-4-2\n\n    TN_DEVASTATOR_V_A0          = 0x41,       //Devastator 4-6-6-2 downconfigured to 4-3-3-1 same as scrapper\n    TN_DEVASTATOR_V_A1          = 0x42,       //Devastator 4-6-6-2 downconfigured to 4-3-3-1 same as scrapper\n    //DEVASTATOR_V IDs are depricated do not use\n\n    TN_SCRAPPER_V_A0            = 0x41,       //Scrapper  4-3-3-1\n    TN_SCRAPPER_V_A1            = 0x42,       //Scrapper  4-3-3-1\n\n    TN_DVST_DUO_V_A0            = 0x61,       //Scrapper  4-2-2-1\n\n    TN_SCRAPPER_LV_A0           = 0x61,       //Scrapper Lite  4-2-2-1\n    TN_SCRAPPER_LV_A1           = 0x62,       //Scrapper Lite  4-2-2-1\n\n    TN_UNKNOWN = 0xFF\n};\n\n#define ASICREV_IS_DEVASTATOR_M(eChipRev)    ((eChipRev >= TN_DEVASTATOR_M_A0) && (eChipRev < TN_DEVASTATOR_LITE_MV_A0))\n//ASICREV_IS_DEVASTATOR_M should be used to identify DEVASTATOR full version features and configuration\n\n#define ASICREV_IS_DEVASTATOR_W(eChipRev)    ((eChipRev >= TN_DEVASTATOR_W_A0) && (eChipRev < TN_DEVASTATOR_LITE_MV_A0))\n//ASICREV_IS_DEVASTATOR_W should be used to identify DEVASTATOR Workstation version features and configuration\n\n#define ASICREV_IS_DEVASTATOR_M_MV(eChipRev)    ((eChipRev >= TN_DEVASTATOR_M_A0) && (eChipRev < TN_DEVASTATOR_V_A0))\n//ASICREV_IS_DEVASTATOR_M_MV should be used to identify DEVASTATOR 4-6-2 + 4-4-2 features and configuration\n\n#define ASICREV_IS_DEVASTATOR_LITE_MV(eChipRev)    ((eChipRev >= TN_DEVASTATOR_LITE_MV_A0) && (eChipRev < TN_DEVASTATOR_V_A0))\n//TN_DEVASTATOR_LITE_MV should be used to identify DEVASTATOR LITE features and configuration\n\n#define ASICREV_IS_DEVASTATOR(eChipRev)    ((eChipRev >= TN_DEVASTATOR_M_A0) && (eChipRev < TN_SCRAPPER_V_A0))\n//ASICREV_IS_DEVASTATOR used to identify silicon type including downconfigured parts\n\n//DEVASTATOR_V IDs are depricated do not use\n#define ASICREV_IS_DEVASTATOR_V(eChipRev)    ((eChipRev >= TN_DEVASTATOR_V_A0) && (eChipRev < TN_SCRAPPER_V_A0))\n//ASICREV_IS_DEVASTATOR_V should be used to identify DEVASTATOR downconfigured to Scrapper\n\n#define ASICREV_IS_TN_V(eChipRev)     ((eChipRev >= TN_DEVASTATOR_V_A0) && (eChipRev < TN_UNKNOWN))\n//ASICREV_IS_SCRAPPER_WIDE should be used to identify Scrapper features and configuration\n\n#define ASICREV_IS_SCRAPPER(eChipRev)     ((eChipRev >= TN_SCRAPPER_V_A0) && (eChipRev < TN_UNKNOWN))\n//ASICREV_IS_SCRAPPER should be used to identify Scrapper variant\n\n#define ASICREV_IS_SCRAPPER_V(eChipRev)     ((eChipRev >= TN_SCRAPPER_V_A0) && (eChipRev < TN_SCRAPPER_LV_A0))\n//ASICREV_IS_SCRAPPERV should be used to identify Scrapper 4-3-3-1 variant\n\n#define ASICREV_IS_SCRAPPER_LITE_LV(eChipRev)     ((eChipRev >= TN_SCRAPPER_LV_A0) && (eChipRev < TN_UNKNOWN))\n//ASICREV_IS_SCRAPPER should be used to identify Scrapper Lite 4-2-2-1 variant\n\n\n\n#define ASIC_IS_TN_A0(eChipRev) ((eChipRev & 0xF) == 0x1)\n// ASIC is Trinity A0\n#define ASIC_IS_TN_A1(eChipRev) ((eChipRev & 0xF) == 0x2)\n// ASIC is Trinity A1\n\n//\n// Define Chip ID's for Trinity family\n//\n#define DEVICE_ID_DEVASTATOR_MOBILE             0x9900     //FP2,FS1r2 socket,4-6-6-2 (QP-SIMD-TP-RB)\n#define DEVICE_ID_DEVASTATOR_DESKTOP            0x9901     //FM2 socket,4-6-6-2 (QP-SIMD-TP-RB)\n#define DEVICE_ID_DEVASTATOR_LITE_MOBILE        0x9903     //FP2,FS1r2 socket,4-4-4-2 (QP-SIMD-TP-RB)\n#define DEVICE_ID_DEVASTATOR_LITE_DESKTOP       0x9904     //FM2 socket,4-4-4-2 (QP-SIMD-TP-RB)\n#define DEVICE_ID_DEVASTATOR_WS_9905            0x9905     //Trinity/DVST - workstation FM2 socket,4-6-6-2 (QP-SIMD-TP-RB)\n#define DEVICE_ID_DEVASTATOR_WS_9906            0x9906     //Trinity/DVST - workstation FM2 socket,4-6-6-2 (QP-SIMD-TP-RB)\n#define DEVICE_ID_DEVASTATOR_MOBILE_FP2_9907    0x9907     //Trinity/DVST - mobile FP2 25W, 4-6-6-2 (QP-SIMD-TP-RB)\n#define DEVICE_ID_DEVASTATOR_MOBILE_FP2_9908    0x9908     //Trinity/DVST - mobile FP2 19W, 4-6-6-2 (QP-SIMD-TP-RB)\n#define DEVICE_ID_DEVASTATOR_MOBILE_FP2_9909    0x9909     //Trinity/DVST - mobile FP2 17W, 4-6-6-2 (QP-SIMD-TP-RB)\n#define DEVICE_ID_DEVASTATOR_LITE_MOBILE_FP2_990A   0x990A     //FP2 17W, 4-4-4-2 (QP-SIMD-TP-RB)\n\n\n#define DEVICE_ID_RL_DEVASTATOR_MOBILE          0x990B     //FP2,FS1r2 socket,4-6-6-2 (QP-SIMD-TP-RB) (Richland)\n#define DEVICE_ID_RL_DEVASTATOR_DESKTOP         0x990C     //FM2 socket,4-6-6-2 (QP-SIMD-TP-RB) (Richland)\n#define DEVICE_ID_RL_DEVASTATOR_LITE_MOBILE     0x990D     //FP2,FS1r2 socket,4-4-4-2 (QP-SIMD-TP-RB) (Richland)\n#define DEVICE_ID_RL_DEVASTATOR_LITE_DESKTOP    0x990E     //FM2 socket,4-4-4-2 (QP-SIMD-TP-RB) (Richland)\n#define DEVICE_ID_RL_DEVASTATOR_MOBILE_FP2_990F 0x990F     //FP2 25W, 4-6-6-2 (QP-SIMD-TP-RB) (Richland)\n\n#define DEVICE_ID_DEVASTATOR_MOBILE_EMBEDDED        0x9910  //FS1r2 socket,4-6-6-2 (QP-SIMD-TP-RB)\n#define DEVICE_ID_DEVASTATOR_LITE_MOBILE_EMBEDDED   0x9913  //FS1r2 socket,4-4-4-2 (QP-SIMD-TP-RB)\n#define DEVICE_ID_DEVASTATOR_FP2_EMBEDDED_9917  0x9917  //FP2 25W,  4-6-6-2 (QP-SIMD-TP-RB)\n#define DEVICE_ID_DEVASTATOR_FP2_EMBEDDED_9918  0x9918  //FP2 19W, 4-6-6-6 (QP-SIMD-TP-RB)\n#define DEVICE_ID_DEVASTATOR_LITE_FP2_EMBEDDED  0x9919  //FP2 17W, 4-4-4-2 (QP-SIMD-TP-RB)\n\n#define DEVICE_ID_SCRAPPER_MOBILE               0x9990     //FP2, FS1r2 socket,4-3-3-1(QP-SIMD-TP-RB)\n#define DEVICE_ID_SCRAPPER_DESKTOP              0x9991     //FM2 socket,4-3-3-1 (QP-SIMD-TP-RB)\n#define DEVICE_ID_SCRAPPER_LITE_MOBILE          0x9992     //FS1r2 socket,4-2-2-1(QP-SIMD-TP-RB)\n#define DEVICE_ID_SCRAPPER_LITE_DESKTOP         0x9993     //FM2 socket,4-2-2-1(QP-SIMD-TP-RB)\n#define DEVICE_ID_SCRAPPER_MOBILE_FP2           0x9994     //FP2, FS1r2 socket,4-3-3-1(QP-SIMD-TP-RB)\n\n#define DEVICE_ID_RL_SCRAPPER_MOBILE            0x9995     //FP2, FS1r2 socket,4-3-3-1(QP-SIMD-TP-RB) (Richland)\n#define DEVICE_ID_RL_SCRAPPER_DESKTOP           0x9996     //FM2 socket,4-3-3-1 (QP-SIMD-TP-RB) (Richland)\n#define DEVICE_ID_RL_SCRAPPER_LITE_MOBILE       0x9997     //FS1r2 socket,4-2-2-1(QP-SIMD-TP-RB) (Richland)\n#define DEVICE_ID_RL_SCRAPPER_LITE_DESKTOP      0x9998     //FM2 socket,4-2-2-1(QP-SIMD-TP-RB) (Richland)\n#define DEVICE_ID_RL_DEVASTATOR_MOBILE_FP2_9999 0x9999     //FP2 17W, 4-6-6-2 (QP-SIMD-TP-RB) (Richland)\n\n#define DEVICE_ID_RL_SCRAPPER_MOBILE_FP2_999A       0x999A  //FP2 17W, 4-3-3-1 (QP-SIMD-TP-RB) (Richland)\n#define DEVICE_ID_RL_SCRAPPER_LITE_MOBILE_FP2_999B  0x999B  //FP2 17W, 4-2-2-1 (QP-SIMD-TP-RB) (Richland)\n\n#define DEVICE_ID_RL_DEVASTATOR_DESKTOP_999C        0x999C  //FM2 45W,4-6-6-2 (QP-SIMD-TP-RB) (Richland)\n#define DEVICE_ID_RL_DEVASTATOR_LITE_DESKTOP_999D   0x999D  //FM2 45W,4-4-4-2 (QP-SIMD-TP-RB) (Richland)\n\n#define DEVICE_ID_SCRAPPER_MOBILE_EMBEDDED          0x99A0  //FS1r2 socket,4-3-3-1(QP-SIMD-TP-RB)\n#define DEVICE_ID_SCRAPPER_LITE_MOBILE_EMBEDDED     0x99A2  //FS1r2 socket,4-2-2-1(QP-SIMD-TP-RB)\n#define DEVICE_ID_SCRAPPER_FP2_EMBEDDED         0x99A4  //FP2, 4-3-3-1(QP-SIMD-TP-RB)\n\n#define DEVICE_ID_DEVASTATOR_DUO            0x990F     //FM2,FP2,FS1r2 socket,4-2-2-1 (QP-SIMD-TP-RB) Non production part\n//DEVASTATOR_DUO is depricated do not use\n\n//\n// Define AMD's internal revision numbers.\n//\n#define INTERNAL_REV_DEVASTATOR_A0       0x00  // The First revision of Trinity TN1 GFX.\n#define INTERNAL_REV_DEVASTATOR_A1       0x01  // The Second revision of Trinity TN1 GFX.\n#define INTERNAL_REV_SCRAPPER_TN2_A0     0x02  // The First revision of Trinity TN2 GFX.\n\n//\n// Define AMD's external revision numbers.\n//\n#define EXTERNAL_REV_DEVASTATOR       0x00\n\n\n#endif  // TN_ID_H\n"
  },
  {
    "path": "src/Wrapper/amd-codexl-analyzer/CommonProjects/AMDTBackend/Include/Common/asic_reg/vi_id.h",
    "content": "//=====================================================================\n// Copyright 2012-2016 (c), Advanced Micro Devices, Inc. All rights reserved.\n//\n/// \\author AMD Developer Tools Team\n/// \\file \n/// \n//=====================================================================\n/*****************************************************************************\\\n*\n*  Module Name    vi_id.h\n*  Project        VOLCANIC ISLANDS\n*  Devices        VOLCANIC ISLANDS\n*\n*  Description    Defining Device IDs, ASIC revision IDs for VOLCANIC ISLANDS\n*\n\\*****************************************************************************/\n\n#ifndef _VI_ID_H\n#define _VI_ID_H\n\nenum\n{\n    VI_ICELAND_M_A0   = 1,\n\n    VI_TONGA_P_A0     = 20,\n    VI_TONGA_P_A1     = 21,\n\n    VI_BERMUDA_P_A0   = 40,\n\n    VI_FIJI_P_A0      = 60,\n\n    VI_UNKNOWN        = 0xFF\n};\n\n\n#define ASICREV_IS_ICELAND_M(eChipRev)  (eChipRev < VI_TONGA_P_A0)\n#define ASICREV_IS_TONGA_P(eChipRev)    ((eChipRev >= VI_TONGA_P_A0) && (eChipRev < VI_BERMUDA_P_A0))\n#define ASICREV_IS_BERMUDA_P(eChipRev)  ((eChipRev >= VI_BERMUDA_P_A0) && (eChipRev < VI_FIJI_P_A0))\n#define ASICREV_IS_FIJI_P(eChipRev)     (eChipRev >= VI_FIJI_P_A0)\n\n//\n// TONGA/AMETHYST device IDs (performance segment)\n//\n#define DEVICE_ID_VI_TONGA_P_6920               0x6920  // unfused\n#define DEVICE_ID_VI_TONGA_P_6921               0x6921  // Amethyst XT\n#define DEVICE_ID_VI_TONGA_P_6928               0x6928  // Tonga GL XT\n#define DEVICE_ID_VI_TONGA_P_692B               0x692B  // Tonga GL PRO\n#define DEVICE_ID_VI_TONGA_P_692F               0x692F  // Tonga GL PRO VF\n#define DEVICE_ID_VI_TONGA_P_6938               0x6938  // Tonga XT\n#define DEVICE_ID_VI_TONGA_P_6939               0x6939  // Tonga PRO\n\n#define DEVICE_ID_VI_TONGA_P_PALLADIUM          0x00    // Palladium ID\n#define DEVICE_ID_VI_TONGA_P_LITE_PALLADIUM     0x48    // Palladium ID\n\n// TONGA ASIC internal revision number\n#define INTERNAL_REV_VI_TONGA_P_A0              0x00    // First spin of Tonga\n#define INTERNAL_REV_VI_TONGA_P_A1              0x01    // Second spin of Tonga\n\n//\n// ICELAND/TOPAZ/MESO device IDs (mainstream segment)\n//\n#define DEVICE_ID_VI_ICELAND_M_6900             0x6900  // Topaz XT; Meso XT\n#define DEVICE_ID_VI_ICELAND_M_6901             0x6901  // Topaz Pro\n#define DEVICE_ID_VI_ICELAND_M_6902             0x6902  // Topaz XTL\n#define DEVICE_ID_VI_ICELAND_M_6903             0x6903  // Unused - Previous Topaz LE\n#define DEVICE_ID_VI_ICELAND_M_6907             0x6907  // Topaz LE\n\n// MESO PCI Reivsion IDs\n#define PRID_VI_ICELAND_MESO_81                   0x81  // 0x6900: MESO XT\n\n#define ASICID_IS_MESO(wDID, bRID)              ((wDID == DEVICE_ID_VI_ICELAND_M_6900) && (bRID == PRID_VI_ICELAND_MESO_81))\n\n#define DEVICE_ID_VI_ICELAND_M_PALLADIUM        0x47    // Palladium ID\n#define DEVICE_ID_VI_ICELAND_M_LITE_PALLADIUM   0x00    // Palladium ID\n\n// ICELAND ASIC internal revision number\n#define INTERNAL_REV_VI_ICELAND_M_A0            0x00    // First spin of ICELAND\n\n//\n// Bermuda device IDs (performance segment)\n//\n\n#define DEVICE_ID_VI_BERMUDA_P_PALLADIUM        0x49    // Palladium ID\n#define DEVICE_ID_VI_BERMUDA_P_LITE_PALLADIUM   0x00    // Palladium ID\n\n// BERMUDA ASIC internal revision number\n#define INTERNAL_REV_VI_BERMUDA_P_A0            0x00    // First spin of Bermuda\n\n\n//\n// Fiji device IDs (performance segment)\n//\n\n#define DEVICE_ID_VI_FIJI_P_LITE_PALLADIUM      0x4A    // Palladium ID\n\n// FIJI ASIC internal revision number\n#define INTERNAL_REV_VI_FIJI_P_A0               0x00    // First spin of Fiji\n\n#endif  // _VI_ID_H\n"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/DXIL.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// DXIL.h                                                                    //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Main public header for DXIL.                                              //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n#include \"dxc/HLSL/DxilConstants.h\"\n#include \"dxc/HLSL/DxilShaderModel.h\"\n#include \"dxc/HLSL/DxilCompType.h\"\n#include \"dxc/HLSL/DxilInterpolationMode.h\"\n#include \"dxc/HLSL/DxilSemantic.h\"\n#include \"dxc/HLSL/DxilSignatureElement.h\"\n#include \"dxc/HLSL/DxilCBuffer.h\"\n#include \"dxc/HLSL/DxilResource.h\"\n#include \"dxc/HLSL/DxilSampler.h\"\n#include \"dxc/HLSL/DxilOperations.h\"\n#include \"dxc/HLSL/DxilRootSignature.h\"\n#include \"dxc/HLSL/DxilModule.h\"\n"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/DxilCBuffer.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// DxilCBuffer.h                                                             //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Representation of HLSL constant buffer (cbuffer).                         //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n#include \"dxc/HLSL/DxilResourceBase.h\"\n\n\nnamespace hlsl {\n\n/// Use this class to represent HLSL cbuffer.\nclass DxilCBuffer : public DxilResourceBase {\npublic:\n  DxilCBuffer();\n  virtual ~DxilCBuffer();\n\n  unsigned GetSize() const;\n\n  void SetSize(unsigned InstanceSizeInBytes);\n\nprivate:\n  unsigned m_SizeInBytes;   // Cbuffer instance size in bytes.\n};\n\n} // namespace hlsl\n"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/DxilCompType.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// DxilCompType.h                                                            //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Represenation of HLSL component type.                                     //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n#include \"DxilConstants.h\"\n\nnamespace llvm {\nclass Type;\nclass PointerType;\nclass LLVMContext;\n}\n\n\nnamespace hlsl {\n\n/// Use this class to represent HLSL component/element types.\nclass CompType {\npublic:\n  using Kind = DXIL::ComponentType;\n\n  CompType();\n  CompType(Kind K);\n  CompType(unsigned int K);\n\n  bool operator==(const CompType &o) const;\n\n  Kind GetKind() const;\n\n  static CompType getInvalid();\n  static CompType getF16();\n  static CompType getF32();\n  static CompType getF64();\n  static CompType getI16();\n  static CompType getI32();\n  static CompType getI64();\n  static CompType getU16();\n  static CompType getU32();\n  static CompType getU64();\n  static CompType getI1();\n  static CompType getSNormF16();\n  static CompType getUNormF16();\n  static CompType getSNormF32();\n  static CompType getUNormF32();\n  static CompType getSNormF64();\n  static CompType getUNormF64();\n\n  bool IsInvalid() const;\n  bool IsFloatTy() const;\n  bool IsIntTy() const;\n  bool IsSIntTy() const;\n  bool IsUIntTy() const;\n  bool IsBoolTy() const;\n\n  bool IsSNorm() const;\n  bool IsUNorm() const;\n  bool Is64Bit() const;\n\n  /// For min-precision types, returns upconverted (base) type.\n  CompType GetBaseCompType() const;\n  bool HasMinPrec() const;\n  llvm::Type *GetLLVMType(llvm::LLVMContext &Ctx) const;\n  llvm::PointerType *GetLLVMPtrType(llvm::LLVMContext &Ctx, const unsigned AddrSpace = 0) const;\n  llvm::Type *GetLLVMBaseType(llvm::LLVMContext &Ctx) const;\n\n  /// Get the component type for a given llvm type.\n  ///\n  /// LLVM types do not hold sign information so there is no 1-1\n  /// correspondence between llvm types and component types. \n  /// This method returns the signed version for all integer\n  /// types.\n  /// \n  /// TODO: decide if we should distinguish between signed\n  ///       and unsigned types in this api.\n  static CompType GetCompType(llvm::Type * type);\n\n  const char *GetName() const;\n  const char *GetHLSLName() const;\n\nprivate:\n  Kind m_Kind;\n};\n\n} // namespace hlsl\n"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/DxilConstants.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// DxilConstants.h                                                           //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Essential DXIL constants.                                                 //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n#include <stdint.h>\n\nnamespace hlsl {\n\n/* <py>\nimport hctdb_instrhelp\n</py> */\n\n// TODO:\n//   2. get rid of DXIL namespace.\n//   3. use class enum for shader flags.\n//   4. use class enum for address spaces.\n\nnamespace DXIL {\n  // DXIL version.\n  const unsigned kDxilMajor = 1;\n  const unsigned kDxilMinor = 0;\n\n  inline unsigned MakeDxilVersion(unsigned DxilMajor, unsigned DxilMinor) {\n    return 0 | (DxilMajor << 8) | (DxilMinor);\n  }\n  inline unsigned GetCurrentDxilVersion() { return MakeDxilVersion(kDxilMajor, kDxilMinor); }\n  inline unsigned GetDxilVersionMajor(unsigned DxilVersion) { return (DxilVersion >> 8) & 0xFF; }\n  inline unsigned GetDxilVersionMinor(unsigned DxilVersion) { return DxilVersion & 0xFF; }\n\n  // Shader flags.\n  const unsigned kDisableOptimizations          = 0x00000001; // D3D11_1_SB_GLOBAL_FLAG_SKIP_OPTIMIZATION\n  const unsigned kDisableMathRefactoring        = 0x00000002; //~D3D10_SB_GLOBAL_FLAG_REFACTORING_ALLOWED\n  const unsigned kEnableDoublePrecision         = 0x00000004; // D3D11_SB_GLOBAL_FLAG_ENABLE_DOUBLE_PRECISION_FLOAT_OPS\n  const unsigned kForceEarlyDepthStencil        = 0x00000008; // D3D11_SB_GLOBAL_FLAG_FORCE_EARLY_DEPTH_STENCIL\n  const unsigned kEnableRawAndStructuredBuffers = 0x00000010; // D3D11_SB_GLOBAL_FLAG_ENABLE_RAW_AND_STRUCTURED_BUFFERS\n  const unsigned kEnableMinPrecision            = 0x00000020; // D3D11_1_SB_GLOBAL_FLAG_ENABLE_MINIMUM_PRECISION\n  const unsigned kEnableDoubleExtensions        = 0x00000040; // D3D11_1_SB_GLOBAL_FLAG_ENABLE_DOUBLE_EXTENSIONS\n  const unsigned kEnableMSAD                    = 0x00000080; // D3D11_1_SB_GLOBAL_FLAG_ENABLE_SHADER_EXTENSIONS\n  const unsigned kAllResourcesBound             = 0x00000100; // D3D12_SB_GLOBAL_FLAG_ALL_RESOURCES_BOUND\n\n  const unsigned kNumOutputStreams = 4;\n  const unsigned kNumClipPlanes = 6;\n\n  // TODO: move these to appropriate places (ShaderModel.cpp?)\n  const unsigned kMaxTempRegCount = 4096;         // DXBC only\n  const unsigned kMaxCBufferSize = 4096;\n  const unsigned kMaxStructBufferStride = 2048;\n  const unsigned kMaxHSOutputControlPointsTotalScalars = 3968;\n  const unsigned kMaxHSOutputPatchConstantTotalScalars = 32*4;\n  const unsigned kMaxOutputTotalScalars = 32*4;\n  const unsigned kMaxInputTotalScalars = 32*4;\n  const unsigned kMaxClipOrCullDistanceElementCount = 2;\n  const unsigned kMaxClipOrCullDistanceCount = 2 * 4;\n  const unsigned kMaxGSOutputVertexCount = 1024;\n  const unsigned kMaxGSInstanceCount = 32;\n  const unsigned kMaxIAPatchControlPointCount = 32;\n  const float kHSMaxTessFactorLowerBound = 1.0f;\n  const float kHSMaxTessFactorUpperBound = 64.0f;\n  const unsigned kMaxCSThreadsPerGroup = 1024;\n  const unsigned kMaxCSThreadGroupX\t= 1024;\n  const unsigned kMaxCSThreadGroupY\t= 1024;\n  const unsigned kMaxCSThreadGroupZ = 64;\n  const unsigned kMinCSThreadGroupX = 1;\n  const unsigned kMinCSThreadGroupY = 1;\n  const unsigned kMinCSThreadGroupZ = 1;\n  const unsigned kMaxCS4XThreadsPerGroup = 768;\n  const unsigned kMaxCS4XThreadGroupX\t= 768;\n  const unsigned kMaxCS4XThreadGroupY\t= 768;\n  const unsigned kMaxTGSMSize = 8192*4;\n  const unsigned kMaxGSOutputTotalScalars = 1024;\n\n  const float kMaxMipLodBias = 15.99f;\n  const float kMinMipLodBias = -16.0f;\n\n  enum class ComponentType : uint8_t { \n    Invalid = 0,\n    I1, I16, U16, I32, U32, I64, U64,\n    F16, F32, F64,\n    SNormF16, UNormF16, SNormF32, UNormF32, SNormF64, UNormF64,\n    LastEntry };\n\n  enum class InterpolationMode : uint8_t {\n    Undefined                   = 0,\n    Constant                    = 1,\n    Linear                      = 2,\n    LinearCentroid              = 3,\n    LinearNoperspective         = 4,\n    LinearNoperspectiveCentroid = 5,\n    LinearSample                = 6,\n    LinearNoperspectiveSample   = 7,\n    Invalid                     = 8\n  };\n\n  enum class SignatureKind {\n    Invalid = 0,\n    Input,\n    Output,\n    PatchConstant,\n  };\n\n  enum class ShaderKind {\n    Pixel = 0,\n    Vertex,\n    Geometry,\n    Hull,\n    Domain,\n    Compute,\n    Invalid,\n  };\n\n  /* <py::lines('SemanticKind-ENUM')>hctdb_instrhelp.get_enum_decl(\"SemanticKind\", hide_val=True, sort_val=False)</py>*/\n  // SemanticKind-ENUM:BEGIN\n  // Semantic kind; Arbitrary or specific system value.\n  enum class SemanticKind : unsigned {\n    Arbitrary,\n    VertexID,\n    InstanceID,\n    Position,\n    RenderTargetArrayIndex,\n    ViewPortArrayIndex,\n    ClipDistance,\n    CullDistance,\n    OutputControlPointID,\n    DomainLocation,\n    PrimitiveID,\n    GSInstanceID,\n    SampleIndex,\n    IsFrontFace,\n    Coverage,\n    InnerCoverage,\n    Target,\n    Depth,\n    DepthLessEqual,\n    DepthGreaterEqual,\n    StencilRef,\n    DispatchThreadID,\n    GroupID,\n    GroupIndex,\n    GroupThreadID,\n    TessFactor,\n    InsideTessFactor,\n    Invalid,\n  };\n  // SemanticKind-ENUM:END\n\n  /* <py::lines('SigPointKind-ENUM')>hctdb_instrhelp.get_enum_decl(\"SigPointKind\", hide_val=True, sort_val=False)</py>*/\n  // SigPointKind-ENUM:BEGIN\n  // Signature Point is more specific than shader stage or signature as it is unique in both stage and item dimensionality or frequency.\n  enum class SigPointKind : unsigned {\n    VSIn, // Ordinary Vertex Shader input from Input Assembler\n    VSOut, // Ordinary Vertex Shader output that may feed Rasterizer\n    PCIn, // Patch Constant function non-patch inputs\n    HSIn, // Hull Shader function non-patch inputs\n    HSCPIn, // Hull Shader patch inputs - Control Points\n    HSCPOut, // Hull Shader function output - Control Point\n    PCOut, // Patch Constant function output - Patch Constant data passed to Domain Shader\n    DSIn, // Domain Shader regular input - Patch Constant data plus system values\n    DSCPIn, // Domain Shader patch input - Control Points\n    DSOut, // Domain Shader output - vertex data that may feed Rasterizer\n    GSVIn, // Geometry Shader vertex input - qualified with primitive type\n    GSIn, // Geometry Shader non-vertex inputs (system values)\n    GSOut, // Geometry Shader output - vertex data that may feed Rasterizer\n    PSIn, // Pixel Shader input\n    PSOut, // Pixel Shader output\n    CSIn, // Compute Shader input\n    Invalid,\n  };\n  // SigPointKind-ENUM:END\n\n  /* <py::lines('SemanticInterpretationKind-ENUM')>hctdb_instrhelp.get_enum_decl(\"SemanticInterpretationKind\", hide_val=True, sort_val=False)</py>*/\n  // SemanticInterpretationKind-ENUM:BEGIN\n  // Defines how a semantic is interpreted at a particular SignaturePoint\n  enum class SemanticInterpretationKind : unsigned {\n    NA, // Not Available\n    SV, // Normal System Value\n    SGV, // System Generated Value (sorted last)\n    Arb, // Treated as Arbitrary\n    NotInSig, // Not included in signature (intrinsic access)\n    NotPacked, // Included in signature, but does not contribute to packing\n    Target, // Special handling for SV_Target\n    TessFactor, // Special handling for tessellation factors\n    Shadow, // Shadow element must be added to a signature for compatibility\n    Invalid,\n  };\n  // SemanticInterpretationKind-ENUM:END\n\n  /* <py::lines('PackingKind-ENUM')>hctdb_instrhelp.get_enum_decl(\"PackingKind\", hide_val=True, sort_val=False)</py>*/\n  // PackingKind-ENUM:BEGIN\n  // Kind of signature point\n  enum class PackingKind : unsigned {\n    None, // No packing should be performed\n    InputAssembler, // Vertex Shader input from Input Assembler\n    Vertex, // Vertex that may feed the Rasterizer\n    PatchConstant, // Patch constant signature\n    Target, // Render Target (Pixel Shader Output)\n    Invalid,\n  };\n  // PackingKind-ENUM:END\n\n  enum class PackingStrategy : unsigned {\n    Default = 0, // Choose default packing algorithm based on target (currently PrefixStable)\n    PrefixStable, // Maintain assumption that all elements are packed in order and stable as new elements are added.\n    Optimized, // Optimize packing of all elements together (all elements must be present, in the same order, for identical placement of any individual element)\n    Invalid,\n  };\n\n  enum class SamplerKind : unsigned {\n    Default = 0,\n    Comparison,\n    Mono,\n    Invalid,\n  };\n\n  enum class ResourceClass {\n    SRV = 0,\n    UAV,\n    CBuffer,\n    Sampler,\n    Invalid\n  };\n\n  enum class ResourceKind : unsigned {\n    Invalid = 0,\n    Texture1D,\n    Texture2D,\n    Texture2DMS,\n    Texture3D,\n    TextureCube,\n    Texture1DArray,\n    Texture2DArray,\n    Texture2DMSArray,\n    TextureCubeArray,\n    TypedBuffer,\n    RawBuffer,\n    StructuredBuffer,\n    CBuffer,\n    Sampler,\n    TBuffer,\n    NumEntries,\n  };\n\n  // TODO: change opcodes.\n  /* <py::lines('OPCODE-ENUM')>hctdb_instrhelp.get_enum_decl(\"OpCode\")</py>*/\n  // OPCODE-ENUM:BEGIN\n  // Enumeration for operations specified by DXIL\n  enum class OpCode : unsigned {\n    // Binary float\n    FMax = 35, // returns a if a >= b, else b\n    FMin = 36, // returns a if a < b, else b\n  \n    // Binary int with two outputs\n    IMul = 41, // returns the IMul of the input values\n    UDiv = 43, // returns the UDiv of the input values\n    UMul = 42, // returns the UMul of the input values\n  \n    // Binary int\n    IMax = 37, // returns the IMax of the input values\n    IMin = 38, // returns the IMin of the input values\n    UMax = 39, // returns the UMax of the input values\n    UMin = 40, // returns the UMin of the input values\n  \n    // Binary uint with carry or borrow\n    UAddc = 44, // returns the UAddc of the input values\n    USubb = 45, // returns the USubb of the input values\n  \n    // Bitcasts with different sizes\n    BitcastF16toI16 = 125, // bitcast between different sizes\n    BitcastF32toI32 = 127, // bitcast between different sizes\n    BitcastF64toI64 = 129, // bitcast between different sizes\n    BitcastI16toF16 = 124, // bitcast between different sizes\n    BitcastI32toF32 = 126, // bitcast between different sizes\n    BitcastI64toF64 = 128, // bitcast between different sizes\n  \n    // Compute shader\n    FlattenedThreadIdInGroup = 96, // provides a flattened index for a given thread within a given group (SV_GroupIndex)\n    GroupId = 94, // reads the group ID (SV_GroupID)\n    ThreadId = 93, // reads the thread ID\n    ThreadIdInGroup = 95, // reads the thread ID within the group (SV_GroupThreadID)\n  \n    // Domain and hull shader\n    LoadOutputControlPoint = 103, // LoadOutputControlPoint\n    LoadPatchConstant = 104, // LoadPatchConstant\n  \n    // Domain shader\n    DomainLocation = 105, // DomainLocation\n  \n    // Dot\n    Dot2 = 54, // two-dimensional vector dot-product\n    Dot3 = 55, // three-dimensional vector dot-product\n    Dot4 = 56, // four-dimensional vector dot-product\n  \n    // Double precision\n    LegacyDoubleToFloat = 132, // legacy fuction to convert double to float\n    LegacyDoubleToSInt32 = 133, // legacy fuction to convert double to int32\n    LegacyDoubleToUInt32 = 134, // legacy fuction to convert double to uint32\n    MakeDouble = 101, // creates a double value\n    SplitDouble = 102, // splits a double into low and high parts\n  \n    // Geometry shader\n    CutStream = 98, // completes the current primitive topology at the specified stream\n    EmitStream = 97, // emits a vertex to a given stream\n    EmitThenCutStream = 99, // equivalent to an EmitStream followed by a CutStream\n    GSInstanceID = 100, // GSInstanceID\n  \n    // Hull shader\n    OutputControlPointID = 107, // OutputControlPointID\n    PrimitiveID = 108, // PrimitiveID\n    StorePatchConstant = 106, // StorePatchConstant\n  \n    // Legacy floating-point\n    LegacyF16ToF32 = 131, // legacy fuction to convert half (f16) to float (f32) (this is not related to min-precision)\n    LegacyF32ToF16 = 130, // legacy fuction to convert float (f32) to half (f16) (this is not related to min-precision)\n  \n    // Other\n    CycleCounterLegacy = 109, // CycleCounterLegacy\n  \n    // Pixel shader\n    CalculateLOD = 81, // calculates the level of detail\n    Coverage = 91, // returns the coverage mask input in a pixel shader\n    DerivCoarseX = 83, // computes the rate of change of components per stamp\n    DerivCoarseY = 84, // computes the rate of change of components per stamp\n    DerivFineX = 85, // computes the rate of change of components per pixel\n    DerivFineY = 86, // computes the rate of change of components per pixel\n    Discard = 82, // discard the current pixel\n    EvalCentroid = 89, // evaluates an input attribute at pixel center\n    EvalSampleIndex = 88, // evaluates an input attribute at a sample location\n    EvalSnapped = 87, // evaluates an input attribute at pixel center with an offset\n    InnerCoverage = 92, // returns underestimated coverage input from conservative rasterization in a pixel shader\n    SampleIndex = 90, // returns the sample index in a sample-frequency pixel shader\n  \n    // Quaternary\n    Bfi = 53, // given a bit range from the LSB of a number, places that number of bits in another number at any offset\n  \n    // Resources - gather\n    TextureGather = 73, // gathers the four texels that would be used in a bi-linear filtering operation\n    TextureGatherCmp = 74, // same as TextureGather, except this instrution performs comparison on texels, similar to SampleCmp\n  \n    // Resources - sample\n    RenderTargetGetSampleCount = 77, // gets the number of samples for a render target\n    RenderTargetGetSamplePosition = 76, // gets the position of the specified sample\n    Sample = 60, // samples a texture\n    SampleBias = 61, // samples a texture after applying the input bias to the mipmap level\n    SampleCmp = 64, // samples a texture and compares a single component against the specified comparison value\n    SampleCmpLevelZero = 65, // samples a texture and compares a single component against the specified comparison value\n    SampleGrad = 63, // samples a texture using a gradient to influence the way the sample location is calculated\n    SampleLevel = 62, // samples a texture using a mipmap-level offset\n    Texture2DMSGetSamplePosition = 75, // gets the position of the specified sample\n  \n    // Resources\n    BufferLoad = 68, // reads from a TypedBuffer\n    BufferStore = 69, // writes to a RWTypedBuffer\n    BufferUpdateCounter = 70, // atomically increments/decrements the hidden 32-bit counter stored with a Count or Append UAV\n    CBufferLoad = 58, // loads a value from a constant buffer resource\n    CBufferLoadLegacy = 59, // loads a value from a constant buffer resource\n    CheckAccessFullyMapped = 71, // determines whether all values from a Sample, Gather, or Load operation accessed mapped tiles in a tiled resource\n    CreateHandle = 57, // creates the handle to a resource\n    GetDimensions = 72, // gets texture size information\n    TextureLoad = 66, // reads texel data without any filtering or sampling\n    TextureStore = 67, // reads texel data without any filtering or sampling\n  \n    // Synchronization\n    AtomicBinOp = 78, // performs an atomic operation on two operands\n    AtomicCompareExchange = 79, // atomic compare and exchange to memory\n    Barrier = 80, // inserts a memory barrier in the shader\n  \n    // Temporary, indexable, input, output registers\n    LoadInput = 4, // loads the value from shader input\n    MinPrecXRegLoad = 2, // helper load operation for minprecision\n    MinPrecXRegStore = 3, // helper store operation for minprecision\n    StoreOutput = 5, // stores the value to shader output\n    TempRegLoad = 0, // helper load operation\n    TempRegStore = 1, // helper store operation\n  \n    // Tertiary float\n    FMad = 46, // performs a fused multiply add (FMA) of the form a * b + c\n    Fma = 47, // performs a fused multiply add (FMA) of the form a * b + c\n  \n    // Tertiary int\n    IMad = 48, // performs an integral IMad\n    Ibfe = 51, // performs an integral Ibfe\n    Msad = 50, // performs an integral Msad\n    UMad = 49, // performs an integral UMad\n    Ubfe = 52, // performs an integral Ubfe\n  \n    // Unary float - rounding\n    Round_ne = 26, // returns the Round_ne\n    Round_ni = 27, // returns the Round_ni\n    Round_pi = 28, // returns the Round_pi\n    Round_z = 29, // returns the Round_z\n  \n    // Unary float\n    Acos = 15, // returns the Acos\n    Asin = 16, // returns the Asin\n    Atan = 17, // returns the Atan\n    Cos = 12, // returns cosine(theta) for theta in radians.\n    Exp = 21, // returns the Exp\n    FAbs = 6, // returns the absolute value of the input value.\n    Frc = 22, // returns the Frc\n    Hcos = 18, // returns the Hcos\n    Hsin = 19, // returns the Hsin\n    Htan = 20, // returns the Htan\n    IsFinite = 10, // returns the IsFinite\n    IsInf = 9, // returns the IsInf\n    IsNaN = 8, // returns the IsNaN\n    IsNormal = 11, // returns the IsNormal\n    Log = 23, // returns the Log\n    Rsqrt = 25, // returns the Rsqrt\n    Saturate = 7, // clamps the result of a single or double precision floating point value to [0.0f...1.0f]\n    Sin = 13, // returns the Sin\n    Sqrt = 24, // returns the Sqrt\n    Tan = 14, // returns the Tan\n  \n    // Unary int\n    Bfrev = 30, // returns the reverse bit pattern of the input value\n    Countbits = 31, // returns the Countbits\n    FirstbitHi = 33, // returns src != 0? (BitWidth-1 - FirstbitHi) : -1\n    FirstbitLo = 32, // returns the FirstbitLo\n    FirstbitSHi = 34, // returns src != 0? (BitWidth-1 - FirstbitSHi) : -1\n  \n    // Wave\n    QuadOp = 123, // returns the result of a quad-level operation\n    QuadReadLaneAt = 122, // reads from a lane in the quad\n    WaveActiveAllEqual = 115, // returns 1 if all the lanes have the same value\n    WaveActiveBallot = 116, // returns a struct with a bit set for each lane where the condition is true\n    WaveActiveBit = 120, // returns the result of the operation across all lanes\n    WaveActiveOp = 119, // returns the result the operation across waves\n    WaveAllBitCount = 135, // returns the count of bits set to 1 across the wave\n    WaveAllTrue = 114, // returns 1 if all the lanes evaluate the value to true\n    WaveAnyTrue = 113, // returns 1 if any of the lane evaluates the value to true\n    WaveGetLaneCount = 112, // returns the number of lanes in the wave\n    WaveGetLaneIndex = 111, // returns the index of the current lane in the wave\n    WaveIsFirstLane = 110, // returns 1 for the first lane in the wave\n    WavePrefixBitCount = 136, // returns the count of bits set to 1 on prior lanes\n    WavePrefixOp = 121, // returns the result of the operation on prior lanes\n    WaveReadLaneAt = 117, // returns the value from the specified lane\n    WaveReadLaneFirst = 118, // returns the value from the first lane\n  \n    NumOpCodes = 137 // exclusive last value of enumeration\n  };\n  // OPCODE-ENUM:END\n\n  /* <py::lines('OPCODECLASS-ENUM')>hctdb_instrhelp.get_enum_decl(\"OpCodeClass\")</py>*/\n  // OPCODECLASS-ENUM:BEGIN\n  // Groups for DXIL operations with equivalent function templates\n  enum class OpCodeClass : unsigned {\n    // Binary int with two outputs\n    BinaryWithTwoOuts,\n  \n    // Binary int\n    Binary,\n  \n    // Binary uint with carry or borrow\n    BinaryWithCarryOrBorrow,\n  \n    // Bitcasts with different sizes\n    BitcastF16toI16,\n    BitcastF32toI32,\n    BitcastF64toI64,\n    BitcastI16toF16,\n    BitcastI32toF32,\n    BitcastI64toF64,\n  \n    // Compute shader\n    FlattenedThreadIdInGroup,\n    GroupId,\n    ThreadId,\n    ThreadIdInGroup,\n  \n    // Domain and hull shader\n    LoadOutputControlPoint,\n    LoadPatchConstant,\n  \n    // Domain shader\n    DomainLocation,\n  \n    // Dot\n    Dot2,\n    Dot3,\n    Dot4,\n  \n    // Double precision\n    LegacyDoubleToFloat,\n    LegacyDoubleToSInt32,\n    LegacyDoubleToUInt32,\n    MakeDouble,\n    SplitDouble,\n  \n    // Geometry shader\n    CutStream,\n    EmitStream,\n    EmitThenCutStream,\n    GSInstanceID,\n  \n    // Hull shader\n    OutputControlPointID,\n    PrimitiveID,\n    StorePatchConstant,\n  \n    // LLVM Instructions\n    LlvmInst,\n  \n    // Legacy floating-point\n    LegacyF16ToF32,\n    LegacyF32ToF16,\n  \n    // Other\n    CycleCounterLegacy,\n  \n    // Pixel shader\n    CalculateLOD,\n    Coverage,\n    Discard,\n    EvalCentroid,\n    EvalSampleIndex,\n    EvalSnapped,\n    InnerCoverage,\n    SampleIndex,\n    Unary,\n  \n    // Quaternary\n    Quaternary,\n  \n    // Resources - gather\n    TextureGather,\n    TextureGatherCmp,\n  \n    // Resources - sample\n    RenderTargetGetSampleCount,\n    RenderTargetGetSamplePosition,\n    Sample,\n    SampleBias,\n    SampleCmp,\n    SampleCmpLevelZero,\n    SampleGrad,\n    SampleLevel,\n    Texture2DMSGetSamplePosition,\n  \n    // Resources\n    BufferLoad,\n    BufferStore,\n    BufferUpdateCounter,\n    CBufferLoad,\n    CBufferLoadLegacy,\n    CheckAccessFullyMapped,\n    CreateHandle,\n    GetDimensions,\n    TextureLoad,\n    TextureStore,\n  \n    // Synchronization\n    AtomicBinOp,\n    AtomicCompareExchange,\n    Barrier,\n  \n    // Temporary, indexable, input, output registers\n    LoadInput,\n    MinPrecXRegLoad,\n    MinPrecXRegStore,\n    StoreOutput,\n    TempRegLoad,\n    TempRegStore,\n  \n    // Tertiary int\n    Tertiary,\n  \n    // Unary float\n    IsSpecialFloat,\n  \n    // Unary int\n    UnaryBits,\n  \n    // Wave\n    QuadOp,\n    QuadReadLaneAt,\n    WaveActiveAllEqual,\n    WaveActiveBallot,\n    WaveActiveBit,\n    WaveActiveOp,\n    WaveAllOp,\n    WaveAllTrue,\n    WaveAnyTrue,\n    WaveGetLaneCount,\n    WaveGetLaneIndex,\n    WaveIsFirstLane,\n    WavePrefixOp,\n    WaveReadLaneAt,\n    WaveReadLaneFirst,\n  \n    NumOpClasses = 93 // exclusive last value of enumeration\n  };\n  // OPCODECLASS-ENUM:END\n\n  // Operand Index for every OpCodeClass.\n  namespace OperandIndex {\n    // Opcode is always operand 0.\n    const unsigned kOpcodeIdx = 0;\n\n    // Unary operators.\n    const unsigned kUnarySrc0OpIdx = 1;\n\n    // Binary operators.\n    const unsigned kBinarySrc0OpIdx = 1;\n    const unsigned kBinarySrc1OpIdx = 2;\n\n    // Trinary operators.\n    const unsigned kTrinarySrc0OpIdx = 1;\n    const unsigned kTrinarySrc1OpIdx = 2;\n    const unsigned kTrinarySrc2OpIdx = 3;\n\n    // LoadInput.\n    const unsigned kLoadInputIDOpIdx = 1;\n    const unsigned kLoadInputRowOpIdx = 2;\n    const unsigned kLoadInputColOpIdx = 3;\n    const unsigned kLoadInputVertexIDOpIdx = 4;\n\n    // StoreOutput.\n    const unsigned kStoreOutputIDOpIdx = 1;\n    const unsigned kStoreOutputRowOpIdx = 2;\n    const unsigned kStoreOutputColOpIdx = 3;\n    const unsigned kStoreOutputValOpIdx = 4;\n\n    // DomainLocation.\n    const unsigned kDomainLocationColOpIdx = 1;\n\n    // BufferLoad.\n    const unsigned kBufferLoadHandleOpIdx = 1;\n    const unsigned kBufferLoadCoord0OpIdx = 2;\n    const unsigned kBufferLoadCoord1OpIdx = 3;\n\n    // BufferStore.\n    const unsigned kBufferStoreHandleOpIdx = 1;\n    const unsigned kBufferStoreCoord0OpIdx = 2;\n    const unsigned kBufferStoreCoord1OpIdx = 3;\n    const unsigned kBufferStoreVal0OpIdx = 4;\n    const unsigned kBufferStoreVal1OpIdx = 5;\n    const unsigned kBufferStoreVal2OpIdx = 6;\n    const unsigned kBufferStoreVal3OpIdx = 7;\n    const unsigned kBufferStoreMaskOpIdx = 8;\n\n    // TextureStore.\n    const unsigned kTextureStoreHandleOpIdx = 1;\n    const unsigned kTextureStoreCoord0OpIdx = 2;\n    const unsigned kTextureStoreCoord1OpIdx = 3;\n    const unsigned kTextureStoreCoord2OpIdx = 4;\n    const unsigned kTextureStoreVal0OpIdx = 5;\n    const unsigned kTextureStoreVal1OpIdx = 6;\n    const unsigned kTextureStoreVal2OpIdx = 7;\n    const unsigned kTextureStoreVal3OpIdx = 8;\n    const unsigned kTextureStoreMaskOpIdx = 9;\n\n    // TextureGather.\n    const unsigned kTextureGatherTexHandleOpIdx = 1;\n    const unsigned kTextureGatherSamplerHandleOpIdx = 2;\n    const unsigned kTextureGatherCoord0OpIdx = 3;\n    const unsigned kTextureGatherCoord1OpIdx = 4;\n    const unsigned kTextureGatherCoord2OpIdx = 5;\n    const unsigned kTextureGatherCoord3OpIdx = 6;\n    const unsigned kTextureGatherOffset0OpIdx = 7;\n    const unsigned kTextureGatherOffset1OpIdx = 8;\n    const unsigned kTextureGatherOffset2OpIdx = 9;\n    const unsigned kTextureGatherChannelOpIdx = 10;\n    // TextureGatherCmp.\n    const unsigned kTextureGatherCmpCmpValOpIdx = 11;\n\n    // TextureSample.\n    const unsigned kTextureSampleTexHandleOpIdx = 1;\n    const unsigned kTextureSampleSamplerHandleOpIdx = 2;\n    const unsigned kTextureSampleCoord0OpIdx = 3;\n    const unsigned kTextureSampleCoord1OpIdx = 4;\n    const unsigned kTextureSampleCoord2OpIdx = 5;\n    const unsigned kTextureSampleCoord3OpIdx = 6;\n    const unsigned kTextureSampleOffset0OpIdx = 7;\n    const unsigned kTextureSampleOffset1OpIdx = 8;\n    const unsigned kTextureSampleOffset2OpIdx = 9;\n    const unsigned kTextureSampleClampOpIdx = 10;\n\n    // AtomicBinOp.\n    const unsigned kAtomicBinOpCoord0OpIdx = 3;\n    const unsigned kAtomicBinOpCoord1OpIdx = 4;\n    const unsigned kAtomicBinOpCoord2OpIdx = 5;\n\n    // AtomicCmpExchange.\n    const unsigned kAtomicCmpExchangeCoord0OpIdx = 2;\n    const unsigned kAtomicCmpExchangeCoord1OpIdx = 3;\n    const unsigned kAtomicCmpExchangeCoord2OpIdx = 4;\n\n    // CreateHandle\n    const unsigned kCreateHandleResClassOpIdx = 1;\n    const unsigned kCreateHandleResIDOpIdx = 2;\n    const unsigned kCreateHandleResIndexOpIdx = 3;\n    const unsigned kCreateHandleIsUniformOpIdx = 4;\n\n    // Emit/Cut\n    const unsigned kStreamEmitCutIDOpIdx = 1;\n    // TODO: add operand index for all the OpCodeClass.\n  }\n\n  // Atomic binary operation kind.\n  enum class AtomicBinOpCode : unsigned {\n    Add,\n    And,\n    Or,\n    Xor,\n    IMin,\n    IMax,\n    UMin,\n    UMax,\n    Exchange,\n    Invalid           // Must be last.\n  };\n\n  // Barrier/fence modes.\n  enum class BarrierMode : unsigned {\n    SyncThreadGroup       = 0x00000001,\n    UAVFenceGlobal        = 0x00000002,\n    UAVFenceThreadGroup   = 0x00000004,\n    TGSMFence             = 0x00000008,\n  };\n\n  // Address space.\n  const unsigned kDefaultAddrSpace = 0;\n  const unsigned kDeviceMemoryAddrSpace = 1;\n  const unsigned kCBufferAddrSpace = 2;\n  const unsigned kTGSMAddrSpace = 3;\n  const unsigned kGenericPointerAddrSpace = 4;\n  const unsigned kImmediateCBufferAddrSpace = 5;\n\n  // Input primitive.\n  enum class InputPrimitive : unsigned {\n    Undefined = 0,\n    Point = 1,\n    Line = 2,\n    Triangle = 3,\n    Reserved4 = 4,\n    Reserved5 = 5,\n    LineWithAdjacency = 6,\n    TriangleWithAdjacency = 7,\n    ControlPointPatch1 = 8,\n    ControlPointPatch2 = 9,\n    ControlPointPatch3 = 10,\n    ControlPointPatch4 = 11,\n    ControlPointPatch5 = 12,\n    ControlPointPatch6 = 13,\n    ControlPointPatch7 = 14,\n    ControlPointPatch8 = 15,\n    ControlPointPatch9 = 16,\n    ControlPointPatch10 = 17,\n    ControlPointPatch11 = 18,\n    ControlPointPatch12 = 19,\n    ControlPointPatch13 = 20,\n    ControlPointPatch14 = 21,\n    ControlPointPatch15 = 22,\n    ControlPointPatch16 = 23,\n    ControlPointPatch17 = 24,\n    ControlPointPatch18 = 25,\n    ControlPointPatch19 = 26,\n    ControlPointPatch20 = 27,\n    ControlPointPatch21 = 28,\n    ControlPointPatch22 = 29,\n    ControlPointPatch23 = 30,\n    ControlPointPatch24 = 31,\n    ControlPointPatch25 = 32,\n    ControlPointPatch26 = 33,\n    ControlPointPatch27 = 34,\n    ControlPointPatch28 = 35,\n    ControlPointPatch29 = 36,\n    ControlPointPatch30 = 37,\n    ControlPointPatch31 = 38,\n    ControlPointPatch32 = 39,\n\n    LastEntry,\n  };\n\n  // Primitive topology.\n  enum class PrimitiveTopology : unsigned {\n    Undefined = 0,\n    PointList = 1,\n    LineList = 2,\n    LineStrip = 3,\n    TriangleList = 4,\n    TriangleStrip = 5,\n\n    LastEntry,\n  };\n\n  enum class TessellatorDomain\n  {\n    Undefined = 0,\n    IsoLine = 1,\n    Tri = 2,\n    Quad = 3,\n\n    LastEntry,\n  };\n\n  enum class TessellatorOutputPrimitive\n  {\n    Undefined = 0,\n    Point = 1,\n    Line = 2,\n    TriangleCW = 3,\n    TriangleCCW = 4,\n\n    LastEntry,\n  };\n\n  // Tessellator partitioning.\n  enum class TessellatorPartitioning : unsigned {\n    Undefined = 0,\n    Integer,\n    Pow2,\n    FractionalOdd,\n    FractionalEven,\n\n    LastEntry,\n  };\n\n  // Kind of quad-level operation\n  enum class QuadOpKind {\n    ReadAcrossX = 0, // returns the value from the other lane in the quad in the horizontal direction\n    ReadAcrossY = 1, // returns the value from the other lane in the quad in the vertical direction\n    ReadAcrossDiagonal = 2, // returns the value from the lane across the quad in horizontal and vertical direction\n  };\n\n  /* <py::lines('WAVEBITOPKIND-ENUM')>hctdb_instrhelp.get_enum_decl(\"WaveBitOpKind\")</py>*/\n  // WAVEBITOPKIND-ENUM:BEGIN\n  // Kind of bitwise cross-lane operation\n  enum class WaveBitOpKind : unsigned {\n    And = 0, // bitwise and of values\n    Or = 1, // bitwise or of values\n    Xor = 2, // bitwise xor of values\n  };\n  // WAVEBITOPKIND-ENUM:END\n\n  /* <py::lines('WAVEOPKIND-ENUM')>hctdb_instrhelp.get_enum_decl(\"WaveOpKind\")</py>*/\n  // WAVEOPKIND-ENUM:BEGIN\n  // Kind of cross-lane operation\n  enum class WaveOpKind : unsigned {\n    Max = 3, // maximum value\n    Min = 2, // minimum value\n    Product = 1, // product of values\n    Sum = 0, // sum of values\n  };\n  // WAVEOPKIND-ENUM:END\n\n  /* <py::lines('SIGNEDOPKIND-ENUM')>hctdb_instrhelp.get_enum_decl(\"SignedOpKind\")</py>*/\n  // SIGNEDOPKIND-ENUM:BEGIN\n  // Sign vs. unsigned operands for operation\n  enum class SignedOpKind : unsigned {\n    Signed = 0, // signed integer or floating-point operands\n    Unsigned = 1, // unsigned integer operands\n  };\n  // SIGNEDOPKIND-ENUM:END\n\n  // Kind of control flow hint\n  enum class ControlFlowHint : unsigned {\n    Undefined = 0,\n    Branch = 1,\n    Flatten = 2,\n    FastOpt = 3,\n    AllowUavCondition = 4,\n    ForceCase = 5,\n    Call = 6,\n    // Loop and Unroll is using llvm.loop.unroll Metadata.\n\n    LastEntry,\n  };\n\n  // XYZW component mask.\n  const uint8_t kCompMask_X     = 0x1;\n  const uint8_t kCompMask_Y     = 0x2;\n  const uint8_t kCompMask_Z     = 0x4;\n  const uint8_t kCompMask_W     = 0x8;\n  const uint8_t kCompMask_All   = 0xF;\n\n} // namespace DXIL\n\n} // namespace hlsl\n"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/DxilContainer.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// DxilContainer.h                                                           //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Provides declarations for the DXIL container format.                      //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n#ifndef __DXC_CONTAINER__\n#define __DXC_CONTAINER__\n\n#include <stdint.h>\n#include <iterator>\n#include <functional>\n#include \"dxc/HLSL/DxilConstants.h\"\n\nstruct IDxcContainerReflection;\nnamespace llvm { class Module; }\n\nnamespace hlsl {\n\nclass AbstractMemoryStream;\nclass RootSignatureHandle;\nclass DxilModule;\n\n#pragma pack(push, 1)\n\nstatic const size_t DxilContainerHashSize = 16;\nstatic const uint16_t DxilContainerVersionMajor = 1;  // Current major version\nstatic const uint16_t DxilContainerVersionMinor = 0;  // Current minor version\nstatic const uint32_t DxilContainerMaxSize = 0x80000000; // Max size for container.\n\n/// Use this type to represent the hash for the full container.\nstruct DxilContainerHash {\n  uint8_t Digest[DxilContainerHashSize];\n};\n\nstruct DxilContainerVersion {\n  uint16_t Major;\n  uint16_t Minor;\n};\n\n/// Use this type to describe a DXIL container of parts.\nstruct DxilContainerHeader {\n  uint32_t              HeaderFourCC;\n  DxilContainerHash     Hash;\n  DxilContainerVersion  Version;\n  uint32_t              ContainerSizeInBytes; // From start of this header\n  uint32_t              PartCount;\n  // Structure is followed by uint32_t PartOffset[PartCount];\n  // The offset is to a DxilPartHeader.\n};\n\n/// Use this type to describe the size and type of a DXIL container part.\nstruct DxilPartHeader {\n  uint32_t  PartFourCC; // Four char code for part type.\n  uint32_t  PartSize;   // Byte count for PartData.\n  // Structure is followed by uint8_t PartData[PartSize].\n};\n\n#define DXIL_FOURCC(ch0, ch1, ch2, ch3) (                            \\\n  (uint32_t)(uint8_t)(ch0)        | (uint32_t)(uint8_t)(ch1) << 8  | \\\n  (uint32_t)(uint8_t)(ch2) << 16  | (uint32_t)(uint8_t)(ch3) << 24   \\\n  )\n\nenum DxilFourCC {\n  DFCC_Container                = DXIL_FOURCC('D', 'X', 'B', 'C'), // for back-compat with tools that look for DXBC containers\n  DFCC_ResourceDef              = DXIL_FOURCC('R', 'D', 'E', 'F'),\n  DFCC_InputSignature           = DXIL_FOURCC('I', 'S', 'G', '1'),\n  DFCC_OutputSignature          = DXIL_FOURCC('O', 'S', 'G', '1'),\n  DFCC_PatchConstantSignature   = DXIL_FOURCC('P', 'S', 'G', '1'),\n  DFCC_ShaderStatistics         = DXIL_FOURCC('S', 'T', 'A', 'T'),\n  DFCC_ShaderDebugInfoDXIL      = DXIL_FOURCC('I', 'L', 'D', 'B'),\n  DFCC_FeatureInfo              = DXIL_FOURCC('S', 'F', 'I', '0'),\n  DFCC_PrivateData              = DXIL_FOURCC('P', 'R', 'I', 'V'),\n  DFCC_RootSignature            = DXIL_FOURCC('R', 'T', 'S', '0'),\n  DFCC_DXIL                     = DXIL_FOURCC('D', 'X', 'I', 'L'),\n  DFCC_PipelineStateValidation  = DXIL_FOURCC('P', 'S', 'V', '0'),\n};\n\n#undef DXIL_FOURCC\n\n// DFCC_FeatureInfo is a uint64_t value with these flags.\nstatic const uint64_t ShaderFeatureInfo_Doubles = 0x0001;\nstatic const uint64_t ShaderFeatureInfo_ComputeShadersPlusRawAndStructuredBuffersViaShader4X = 0x0002;\nstatic const uint64_t ShaderFeatureInfo_UAVsAtEveryStage = 0x0004;\nstatic const uint64_t ShaderFeatureInfo_64UAVs = 0x0008;\nstatic const uint64_t ShaderFeatureInfo_MininumPrecision = 0x0010;\nstatic const uint64_t ShaderFeatureInfo_11_1_DoubleExtensions = 0x0020;\nstatic const uint64_t ShaderFeatureInfo_11_1_ShaderExtensions = 0x0040;\nstatic const uint64_t ShaderFeatureInfo_LEVEL9ComparisonFiltering = 0x0080;\nstatic const uint64_t ShaderFeatureInfo_TiledResources = 0x0100;\nstatic const uint64_t ShaderFeatureInfo_StencilRef = 0x0200;\nstatic const uint64_t ShaderFeatureInfo_InnerCoverage = 0x0400;\nstatic const uint64_t ShaderFeatureInfo_TypedUAVLoadAdditionalFormats = 0x0800;\nstatic const uint64_t ShaderFeatureInfo_ROVs = 0x1000;\nstatic const uint64_t ShaderFeatureInfo_ViewportAndRTArrayIndexFromAnyShaderFeedingRasterizer = 0x2000;\nstatic const uint64_t ShaderFeatureInfo_WaveOps = 0x4000;\nstatic const uint64_t ShaderFeatureInfo_Int64Ops = 0x8000;\n\nstatic const unsigned ShaderFeatureInfoCount = 16;\n\nstruct DxilShaderFeatureInfo\n{\n    uint64_t FeatureFlags;\n};\n\n// DXIL program information.\nstruct DxilBitcodeHeader {\n  uint32_t DxilMagic;       // ACSII \"DXIL\".\n  uint32_t DxilVersion;     // DXIL version.\n  uint32_t BitcodeOffset;   // Offset to LLVM bitcode (from start of header).\n  uint32_t BitcodeSize;     // Size of LLVM bitcode.\n};\nstatic const uint32_t DxilMagicValue = 0x4C495844; // 'DXIL'\n\nstruct DxilProgramHeader {\n  uint32_t          ProgramVersion;   /// Major and minor version, including type.\n  uint32_t          SizeInUint32;     /// Size in uint32_t units including this header.\n  DxilBitcodeHeader BitcodeHeader;    /// Bitcode-specific header.\n  // Followed by uint8_t[BitcodeHeader.BitcodeOffset]\n};\n\nstruct DxilProgramSignature {\n  uint32_t ParamCount;\n  uint32_t ParamOffset;\n};\n\nenum class DxilProgramSigMinPrecision : uint32_t {\n  Default = 0,\n  Float16 = 1,\n  Float2_8 = 2,\n  Reserved = 3,\n  SInt16 = 4,\n  UInt16 = 5,\n  Any16 = 0xf0,\n  Any10 = 0xf1\n};\n\nenum class DxilProgramSigSemantic : uint32_t {\n  Undefined = 0,\n  Position = 1,\n  ClipDistance = 2,\n  CullDistance = 3,\n  RenderTargetArrayIndex = 4,\n  ViewPortArrayIndex = 5,\n  VertexID = 6,\n  PrimitiveID = 7,\n  InstanceID = 8,\n  IsFrontFace = 9,\n  SampleIndex = 10,\n  FinalQuadEdgeTessfactor = 11,\n  FinalQuadInsideTessfactor = 12,\n  FinalTriEdgeTessfactor = 13,\n  FinalTriInsideTessfactor = 14,\n  FinalLineDetailTessfactor = 15,\n  FinalLineDensityTessfactor = 16,\n  Target = 64,\n  Depth = 65,\n  Coverage = 66,\n  DepthGE = 67,\n  DepthLE = 68,\n  StencilRef = 69,\n  InnerCoverage = 70\n};\n\nenum class DxilProgramSigCompType : uint32_t {\n  Unknown = 0,\n  UInt32 = 1,\n  SInt32 = 2,\n  Float32 = 3,\n  UInt16 = 4,\n  SInt16 = 5,\n  Float16 = 6,\n  UInt64 = 7,\n  SInt64 = 8,\n  Float64 = 9,\n};\n\nstatic const uint8_t DxilProgramSigMaskX = 1;\nstatic const uint8_t DxilProgramSigMaskY = 2;\nstatic const uint8_t DxilProgramSigMaskZ = 4;\nstatic const uint8_t DxilProgramSigMaskW = 8;\n\nstruct DxilProgramSignatureElement {\n  uint32_t Stream;                    // Stream index (parameters must appear in non-decreasing stream order)\n  uint32_t SemanticName;              // Offset to LPCSTR from start of DxilProgramSignature.\n  uint32_t SemanticIndex;             // Semantic Index\n  DxilProgramSigSemantic SystemValue; // Semantic type. Similar to DxilSemantic::Kind, but a serialized rather than processing rep.\n  DxilProgramSigCompType CompType;    // Type of bits.\n  uint32_t Register;                  // Register Index (row index)\n  uint8_t Mask;                       // Mask (column allocation)\n  union                         // Unconditional cases useful for validation of shader linkage.\n  {\n    uint8_t NeverWrites_Mask;   // For an output signature, the shader the signature belongs to never\n                                // writes the masked components of the output register.\n    uint8_t AlwaysReads_Mask;   // For an input signature, the shader the signature belongs to always\n                                // reads the masked components of the input register.\n  };\n  uint16_t Pad;\n  DxilProgramSigMinPrecision MinPrecision; // Minimum precision of input/output data\n};\n\n// Easy to get this wrong. Earlier assertions can help determine\nstatic_assert(sizeof(DxilProgramSignatureElement) == 0x20, \"else DxilProgramSignatureElement is misaligned\");\n\n#pragma pack(pop)\n\n/// Gets a part header by index.\ninline const DxilPartHeader *\nGetDxilContainerPart(const DxilContainerHeader *pHeader, uint32_t index) {\n  const uint8_t *pLinearContainer = reinterpret_cast<const uint8_t *>(pHeader);\n  const uint32_t *pPartOffsetTable =\n      reinterpret_cast<const uint32_t *>(pHeader + 1);\n  return reinterpret_cast<const DxilPartHeader *>(\n      pLinearContainer + pPartOffsetTable[index]);\n}\n\n/// Gets a part header by index.\ninline DxilPartHeader *GetDxilContainerPart(DxilContainerHeader *pHeader,\n                                            uint32_t index) {\n  return const_cast<DxilPartHeader *>(GetDxilContainerPart(\n      reinterpret_cast<const DxilContainerHeader *>(pHeader), index));\n}\n\n/// Gets the part data from the header.\ninline const char *GetDxilPartData(const DxilPartHeader *pPart) {\n  return reinterpret_cast<const char *>(pPart + 1);\n}\n\n/// Gets the part data from the header.\ninline char *GetDxilPartData(DxilPartHeader *pPart) {\n  return reinterpret_cast<char *>(pPart + 1);\n}\n/// Gets a part header by fourCC\nDxilPartHeader *GetDxilPartByType(DxilContainerHeader *pHeader,\n                                           DxilFourCC fourCC);\n/// Gets a part header by fourCC \nconst DxilPartHeader *\nGetDxilPartByType(const DxilContainerHeader *pHeader,\n                           DxilFourCC fourCC);\n\n/// Returns valid DxilProgramHeader. nullptr if does not exist.\nDxilProgramHeader *GetDxilProgramHeader(DxilContainerHeader *pHeader, DxilFourCC fourCC);\n\n/// Returns valid DxilProgramHeader. nullptr if does not exist.\nconst DxilProgramHeader *\nGetDxilProgramHeader(const DxilContainerHeader *pHeader, DxilFourCC fourCC);\n\n/// Initializes container with the specified values.\nvoid InitDxilContainer(_Out_ DxilContainerHeader *pHeader, uint32_t partCount,\n                       uint32_t containerSizeInBytes);\n\n/// Checks whether pHeader claims by signature to be a DXIL container.\nconst DxilContainerHeader *IsDxilContainerLike(const void *ptr, size_t length);\n\n/// Checks whether the DXIL container is valid and in-bounds.\nbool IsValidDxilContainer(const DxilContainerHeader *pHeader, size_t length);\n\n/// Use this type as a unary predicate functor.\nstruct DxilPartIsType {\n  uint32_t IsFourCC;\n  DxilPartIsType(uint32_t FourCC) : IsFourCC(FourCC) { }\n  bool operator()(const DxilPartHeader *pPart) const {\n    return pPart->PartFourCC == IsFourCC;\n  }\n};\n\n/// Use this type as an iterator over the part headers.\nstruct DxilPartIterator : public std::iterator<std::input_iterator_tag,\n                                               const DxilContainerHeader *> {\n  const DxilContainerHeader *pHeader;\n  uint32_t index;\n\n  DxilPartIterator(const DxilContainerHeader *h, uint32_t i)\n      : pHeader(h), index(i) {}\n\n  // increment\n  DxilPartIterator &operator++() {\n    ++index;\n    return *this;\n  }\n  DxilPartIterator operator++(int) {\n    DxilPartIterator result(pHeader, index);\n    ++index;\n    return result;\n  }\n\n  // input iterator - compare and deref\n  bool operator==(const DxilPartIterator &other) const {\n    return index == other.index && pHeader == other.pHeader;\n  }\n  bool operator!=(const DxilPartIterator &other) const {\n    return index != other.index || pHeader != other.pHeader;\n  }\n  const DxilPartHeader *operator*() const {\n    return GetDxilContainerPart(pHeader, index);\n  }\n};\n\nDxilPartIterator begin(const DxilContainerHeader *pHeader);\nDxilPartIterator end(const DxilContainerHeader *pHeader);\n\ninline bool IsValidDxilBitcodeHeader(const DxilBitcodeHeader *pHeader,\n                                     uint32_t length) {\n  return length > sizeof(DxilBitcodeHeader) &&\n         pHeader->BitcodeOffset + pHeader->BitcodeSize >\n             pHeader->BitcodeOffset &&\n         length >= pHeader->BitcodeOffset + pHeader->BitcodeSize &&\n         pHeader->DxilMagic == DxilMagicValue;\n}\n\ninline void InitBitcodeHeader(DxilBitcodeHeader &header,\n  uint32_t bitcodeSize) {\n  header.DxilMagic = DxilMagicValue;\n  header.DxilVersion = DXIL::GetCurrentDxilVersion();\n  header.BitcodeOffset = sizeof(DxilBitcodeHeader);\n  header.BitcodeSize = bitcodeSize;\n}\n\ninline void GetDxilProgramBitcode(const DxilProgramHeader *pHeader,\n                                  const char **pBitcode,\n                                  uint32_t *pBitcodeLength) {\n  *pBitcode = reinterpret_cast<const char *>(&pHeader->BitcodeHeader) +\n              pHeader->BitcodeHeader.BitcodeOffset;\n  *pBitcodeLength = pHeader->BitcodeHeader.BitcodeSize;\n}\n\ninline bool IsValidDxilProgramHeader(const DxilProgramHeader *pHeader,\n  uint32_t length) {\n  return length >= sizeof(DxilProgramHeader) &&\n    length >= (pHeader->SizeInUint32 * sizeof(uint32_t)) &&\n    IsValidDxilBitcodeHeader(\n      &pHeader->BitcodeHeader,\n      length - offsetof(DxilProgramHeader, BitcodeHeader));\n}\n\ninline void InitProgramHeader(DxilProgramHeader &header, uint32_t version,\n                              uint32_t bitcodeSize) {\n  header.ProgramVersion = version;\n  header.SizeInUint32 =\n    sizeof(DxilProgramHeader) / sizeof(uint32_t) +\n    bitcodeSize / sizeof(uint32_t) + ((bitcodeSize % 4) ? 1 : 0);\n  InitBitcodeHeader(header.BitcodeHeader, bitcodeSize);\n}\n\ninline const char *GetDxilBitcodeData(const DxilProgramHeader *pHeader) {\n  const DxilBitcodeHeader *pBCHdr = &(pHeader->BitcodeHeader);\n  return (const char *)pBCHdr + pBCHdr->BitcodeOffset;\n}\n\ninline uint32_t GetDxilBitcodeSize(const DxilProgramHeader *pHeader) {\n  return pHeader->BitcodeHeader.BitcodeSize;\n}\n\n/// Extract the shader type from the program version value.\ninline DXIL::ShaderKind GetVersionShaderType(uint32_t programVersion) {\n  return (DXIL::ShaderKind)((programVersion & 0xffff0000) >> 16);\n}\ninline uint32_t GetVersionMajor(uint32_t programVersion) {\n  return (programVersion & 0xf0) >> 4;\n}\ninline uint32_t GetVersionMinor(uint32_t programVersion) {\n  return (programVersion & 0xf);\n}\ninline uint32_t EncodeVersion(DXIL::ShaderKind shaderType, uint32_t major,\n  uint32_t minor) {\n  return ((unsigned)shaderType << 16) | (major << 4) | minor;\n}\n\nclass DxilPartWriter {\npublic:\n  virtual uint32_t size() const = 0;\n  virtual void write(AbstractMemoryStream *pStream) = 0;\n};\n\nDxilPartWriter *NewProgramSignatureWriter(const DxilModule &M, DXIL::SignatureKind Kind);\nDxilPartWriter *NewRootSignatureWriter(const RootSignatureHandle &S);\nDxilPartWriter *NewFeatureInfoWriter(const DxilModule &M);\nDxilPartWriter *NewPSVWriter(const DxilModule &M);\n\nclass DxilContainerWriter : public DxilPartWriter  {\npublic:\n  typedef std::function<void(AbstractMemoryStream*)> WriteFn;\n  virtual void AddPart(uint32_t FourCC, uint32_t Size, WriteFn Write) = 0;\n};\n\nDxilContainerWriter *NewDxilContainerWriter();\n\nvoid SerializeDxilContainerForModule(hlsl::DxilModule *pModule,\n                                     AbstractMemoryStream *pModuleBitcode,\n                                     AbstractMemoryStream *pStream);\nvoid SerializeDxilContainerForRootSignature(hlsl::RootSignatureHandle *pRootSigHandle,\n                                     AbstractMemoryStream *pStream);\n\nvoid CreateDxcContainerReflection(IDxcContainerReflection **ppResult);\n\n// Converts uint32_t partKind to char array object.\ninline char * PartKindToCharArray(uint32_t partKind, _Out_writes_(5) char* pText) {\n  pText[0] = (char)((partKind & 0x000000FF) >> 0);\n  pText[1] = (char)((partKind & 0x0000FF00) >> 8);\n  pText[2] = (char)((partKind & 0x00FF0000) >> 16);\n  pText[3] = (char)((partKind & 0xFF000000) >> 24);\n  pText[4] = '\\0';\n  return pText;\n}\n\ninline size_t GetOffsetTableSize(uint32_t partCount) {\n  return sizeof(uint32_t) * partCount;\n}\n// Compute total size of the dxil container from parts information\ninline size_t GetDxilContainerSizeFromParts(uint32_t partCount, uint32_t partsSize) {\n  return partsSize + (uint32_t)sizeof(DxilContainerHeader) +\n         GetOffsetTableSize(partCount) +\n         (uint32_t)sizeof(DxilPartHeader) * partCount;\n}\n\n} // namespace hlsl\n\n#endif // __DXC_CONTAINER__\n"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/DxilGenerationPass.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// DxilGenerationPass.h                                                      //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// This file provides a DXIL Generation pass.                                //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\nnamespace llvm {\nclass Module;\nclass ModulePass;\nclass Function;\nclass FunctionPass;\nclass Instruction;\nclass PassRegistry;\n}\n\nnamespace hlsl {\nclass DxilResourceBase;\nclass WaveSensitivityAnalysis {\npublic:\n  static WaveSensitivityAnalysis* create();\n  virtual ~WaveSensitivityAnalysis() { }\n  virtual void Analyze(llvm::Function *F) = 0;\n  virtual bool IsWaveSensitive(llvm::Instruction *op) = 0;\n};\n\nclass HLSLExtensionsCodegenHelper;\n}\n\nnamespace llvm {\n\n/// \\brief Create and return a pass that tranform the module into a DXIL module\n/// Note that this pass is designed for use with the legacy pass manager.\nModulePass *createDxilCondenseResourcesPass();\nModulePass *createDxilGenerationPass(bool NotOptimized, hlsl::HLSLExtensionsCodegenHelper *extensionsHelper);\nModulePass *createHLEmitMetadataPass();\nModulePass *createHLEnsureMetadataPass();\nModulePass *createDxilEmitMetadataPass();\nModulePass *createDxilPrecisePropagatePass();\nFunctionPass *createDxilLegalizeSampleOffsetPass();\nFunctionPass *createSimplifyInstPass();\n\nvoid initializeDxilCondenseResourcesPass(llvm::PassRegistry&);\nvoid initializeDxilGenerationPassPass(llvm::PassRegistry&);\nvoid initializeHLEnsureMetadataPass(llvm::PassRegistry&);\nvoid initializeHLEmitMetadataPass(llvm::PassRegistry&);\nvoid initializeDxilEmitMetadataPass(llvm::PassRegistry&);\nvoid initializeDxilPrecisePropagatePassPass(llvm::PassRegistry&);\nvoid initializeDxilLegalizeSampleOffsetPassPass(llvm::PassRegistry&);\nvoid initializeSimplifyInstPass(llvm::PassRegistry&);\n\nbool AreDxilResourcesDense(llvm::Module *M, hlsl::DxilResourceBase **ppNonDense);\n\n}\n"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/DxilInstructions.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// DxilInstructions.h                                                        //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// This file provides a library of instruction helper classes.               //\n// MUCH WORK YET TO BE DONE - EXPECT THIS WILL CHANGE - GENERATED FILE       //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n#include \"llvm/IR/Constants.h\"\n#include \"llvm/IR/Instruction.h\"\n#include \"llvm/IR/Instructions.h\"\n\n// TODO: add correct include directives\n// TODO: add accessors with values\n// TODO: add validation support code, including calling into right fn\n// TODO: add type hierarchy\nnamespace hlsl {\n/* <py>\nimport hctdb_instrhelp\n</py> */\n/* <py::lines('INSTR-HELPER')>hctdb_instrhelp.get_instrhelper()</py>*/\n// INSTR-HELPER:BEGIN\n/// This instruction returns a value (possibly void), from a function.\nstruct LlvmInst_Ret {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_Ret(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::Ret;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction branches (conditional or unconditional)\nstruct LlvmInst_Br {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_Br(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::Br;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction performs a multiway switch\nstruct LlvmInst_Switch {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_Switch(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::Switch;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction branches indirectly\nstruct LlvmInst_IndirectBr {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_IndirectBr(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::IndirectBr;\n  }\n  // Validation support\n  bool isAllowed() const { return false; }\n};\n\n/// This instruction invokes function with normal and exceptional returns\nstruct LlvmInst_Invoke {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_Invoke(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::Invoke;\n  }\n  // Validation support\n  bool isAllowed() const { return false; }\n};\n\n/// This instruction resumes the propagation of an exception\nstruct LlvmInst_Resume {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_Resume(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::Resume;\n  }\n  // Validation support\n  bool isAllowed() const { return false; }\n};\n\n/// This instruction is unreachable\nstruct LlvmInst_Unreachable {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_Unreachable(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::Unreachable;\n  }\n  // Validation support\n  bool isAllowed() const { return false; }\n};\n\n/// This instruction returns the sum of its two operands\nstruct LlvmInst_Add {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_Add(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::Add;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction returns the sum of its two operands\nstruct LlvmInst_FAdd {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_FAdd(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::FAdd;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction returns the difference of its two operands\nstruct LlvmInst_Sub {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_Sub(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::Sub;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction returns the difference of its two operands\nstruct LlvmInst_FSub {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_FSub(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::FSub;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction returns the product of its two operands\nstruct LlvmInst_Mul {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_Mul(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::Mul;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction returns the product of its two operands\nstruct LlvmInst_FMul {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_FMul(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::FMul;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction returns the quotient of its two unsigned operands\nstruct LlvmInst_UDiv {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_UDiv(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::UDiv;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction returns the quotient of its two signed operands\nstruct LlvmInst_SDiv {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_SDiv(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::SDiv;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction returns the quotient of its two operands\nstruct LlvmInst_FDiv {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_FDiv(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::FDiv;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction returns the remainder from the unsigned division of its two operands\nstruct LlvmInst_URem {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_URem(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::URem;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction returns the remainder from the signed division of its two operands\nstruct LlvmInst_SRem {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_SRem(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::SRem;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction returns the remainder from the division of its two operands\nstruct LlvmInst_FRem {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_FRem(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::FRem;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction shifts left (logical)\nstruct LlvmInst_Shl {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_Shl(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::Shl;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction shifts right (logical), with zero bit fill\nstruct LlvmInst_LShr {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_LShr(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::LShr;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction shifts right (arithmetic), with 'a' operand sign bit fill\nstruct LlvmInst_AShr {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_AShr(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::AShr;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction returns a  bitwise logical and of its two operands\nstruct LlvmInst_And {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_And(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::And;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction returns a bitwise logical or of its two operands\nstruct LlvmInst_Or {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_Or(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::Or;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction returns a bitwise logical xor of its two operands\nstruct LlvmInst_Xor {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_Xor(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::Xor;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction allocates memory on the stack frame of the currently executing function\nstruct LlvmInst_Alloca {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_Alloca(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::Alloca;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction reads from memory\nstruct LlvmInst_Load {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_Load(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::Load;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction writes to memory\nstruct LlvmInst_Store {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_Store(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::Store;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction gets the address of a subelement of an aggregate value\nstruct LlvmInst_GetElementPtr {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_GetElementPtr(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::GetElementPtr;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction introduces happens-before edges between operations\nstruct LlvmInst_Fence {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_Fence(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::Fence;\n  }\n  // Validation support\n  bool isAllowed() const { return false; }\n};\n\n/// This instruction atomically modifies memory\nstruct LlvmInst_AtomicCmpXchg {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_AtomicCmpXchg(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::AtomicCmpXchg;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction atomically modifies memory\nstruct LlvmInst_AtomicRMW {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_AtomicRMW(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::AtomicRMW;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction truncates an integer\nstruct LlvmInst_Trunc {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_Trunc(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::Trunc;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction zero extends an integer\nstruct LlvmInst_ZExt {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_ZExt(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::ZExt;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction sign extends an integer\nstruct LlvmInst_SExt {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_SExt(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::SExt;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction converts a floating point to UInt\nstruct LlvmInst_FPToUI {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_FPToUI(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::FPToUI;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction converts a floating point to SInt\nstruct LlvmInst_FPToSI {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_FPToSI(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::FPToSI;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction converts a UInt to floating point\nstruct LlvmInst_UIToFP {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_UIToFP(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::UIToFP;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction converts a SInt to floating point\nstruct LlvmInst_SIToFP {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_SIToFP(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::SIToFP;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction truncates a floating point\nstruct LlvmInst_FPTrunc {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_FPTrunc(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::FPTrunc;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction extends a floating point\nstruct LlvmInst_FPExt {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_FPExt(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::FPExt;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction converts a pointer to integer\nstruct LlvmInst_PtrToInt {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_PtrToInt(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::PtrToInt;\n  }\n  // Validation support\n  bool isAllowed() const { return false; }\n};\n\n/// This instruction converts an integer to Pointer\nstruct LlvmInst_IntToPtr {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_IntToPtr(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::IntToPtr;\n  }\n  // Validation support\n  bool isAllowed() const { return false; }\n};\n\n/// This instruction performs a bit-preserving type cast\nstruct LlvmInst_BitCast {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_BitCast(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::BitCast;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction casts a value addrspace\nstruct LlvmInst_AddrSpaceCast {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_AddrSpaceCast(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::AddrSpaceCast;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction compares integers\nstruct LlvmInst_ICmp {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_ICmp(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::ICmp;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction compares floating points\nstruct LlvmInst_FCmp {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_FCmp(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::FCmp;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction is a PHI node instruction\nstruct LlvmInst_PHI {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_PHI(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::PHI;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction calls a function\nstruct LlvmInst_Call {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_Call(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::Call;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction selects an instruction\nstruct LlvmInst_Select {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_Select(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::Select;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction may be used internally in a pass\nstruct LlvmInst_UserOp1 {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_UserOp1(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::UserOp1;\n  }\n  // Validation support\n  bool isAllowed() const { return false; }\n};\n\n/// This instruction internal to passes only\nstruct LlvmInst_UserOp2 {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_UserOp2(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::UserOp2;\n  }\n  // Validation support\n  bool isAllowed() const { return false; }\n};\n\n/// This instruction vaarg instruction\nstruct LlvmInst_VAArg {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_VAArg(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::VAArg;\n  }\n  // Validation support\n  bool isAllowed() const { return false; }\n};\n\n/// This instruction extracts from aggregate\nstruct LlvmInst_ExtractValue {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_ExtractValue(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::ExtractValue;\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n};\n\n/// This instruction represents a landing pad\nstruct LlvmInst_LandingPad {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  LlvmInst_LandingPad(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return Instr->getOpcode() == llvm::Instruction::LandingPad;\n  }\n  // Validation support\n  bool isAllowed() const { return false; }\n};\n\n/// This instruction helper load operation\nstruct DxilInst_TempRegLoad {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_TempRegLoad(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::TempRegLoad);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_index() const { return Instr->getOperand(1); }\n};\n\n/// This instruction helper store operation\nstruct DxilInst_TempRegStore {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_TempRegStore(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::TempRegStore);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_index() const { return Instr->getOperand(1); }\n  llvm::Value *get_value() const { return Instr->getOperand(2); }\n};\n\n/// This instruction helper load operation for minprecision\nstruct DxilInst_MinPrecXRegLoad {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_MinPrecXRegLoad(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::MinPrecXRegLoad);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (4 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_regIndex() const { return Instr->getOperand(1); }\n  llvm::Value *get_index() const { return Instr->getOperand(2); }\n  llvm::Value *get_component() const { return Instr->getOperand(3); }\n};\n\n/// This instruction helper store operation for minprecision\nstruct DxilInst_MinPrecXRegStore {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_MinPrecXRegStore(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::MinPrecXRegStore);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (5 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_regIndex() const { return Instr->getOperand(1); }\n  llvm::Value *get_index() const { return Instr->getOperand(2); }\n  llvm::Value *get_component() const { return Instr->getOperand(3); }\n  llvm::Value *get_value() const { return Instr->getOperand(4); }\n};\n\n/// This instruction loads the value from shader input\nstruct DxilInst_LoadInput {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_LoadInput(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::LoadInput);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (5 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_inputSigId() const { return Instr->getOperand(1); }\n  llvm::Value *get_rowIndex() const { return Instr->getOperand(2); }\n  llvm::Value *get_colIndex() const { return Instr->getOperand(3); }\n  llvm::Value *get_gsVertexAxis() const { return Instr->getOperand(4); }\n};\n\n/// This instruction stores the value to shader output\nstruct DxilInst_StoreOutput {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_StoreOutput(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::StoreOutput);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (5 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_outputtSigId() const { return Instr->getOperand(1); }\n  llvm::Value *get_rowIndex() const { return Instr->getOperand(2); }\n  llvm::Value *get_colIndex() const { return Instr->getOperand(3); }\n  llvm::Value *get_value() const { return Instr->getOperand(4); }\n};\n\n/// This instruction returns the absolute value of the input value.\nstruct DxilInst_FAbs {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_FAbs(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::FAbs);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction clamps the result of a single or double precision floating point value to [0.0f...1.0f]\nstruct DxilInst_Saturate {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Saturate(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Saturate);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns the IsNaN\nstruct DxilInst_IsNaN {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_IsNaN(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::IsNaN);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns the IsInf\nstruct DxilInst_IsInf {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_IsInf(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::IsInf);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns the IsFinite\nstruct DxilInst_IsFinite {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_IsFinite(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::IsFinite);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns the IsNormal\nstruct DxilInst_IsNormal {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_IsNormal(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::IsNormal);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns cosine(theta) for theta in radians.\nstruct DxilInst_Cos {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Cos(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Cos);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns the Sin\nstruct DxilInst_Sin {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Sin(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Sin);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns the Tan\nstruct DxilInst_Tan {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Tan(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Tan);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns the Acos\nstruct DxilInst_Acos {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Acos(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Acos);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns the Asin\nstruct DxilInst_Asin {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Asin(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Asin);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns the Atan\nstruct DxilInst_Atan {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Atan(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Atan);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns the Hcos\nstruct DxilInst_Hcos {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Hcos(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Hcos);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns the Hsin\nstruct DxilInst_Hsin {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Hsin(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Hsin);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns the Htan\nstruct DxilInst_Htan {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Htan(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Htan);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns the Exp\nstruct DxilInst_Exp {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Exp(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Exp);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns the Frc\nstruct DxilInst_Frc {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Frc(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Frc);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns the Log\nstruct DxilInst_Log {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Log(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Log);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns the Sqrt\nstruct DxilInst_Sqrt {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Sqrt(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Sqrt);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns the Rsqrt\nstruct DxilInst_Rsqrt {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Rsqrt(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Rsqrt);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns the Round_ne\nstruct DxilInst_Round_ne {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Round_ne(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Round_ne);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns the Round_ni\nstruct DxilInst_Round_ni {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Round_ni(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Round_ni);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns the Round_pi\nstruct DxilInst_Round_pi {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Round_pi(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Round_pi);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns the Round_z\nstruct DxilInst_Round_z {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Round_z(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Round_z);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns the reverse bit pattern of the input value\nstruct DxilInst_Bfrev {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Bfrev(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Bfrev);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns the Countbits\nstruct DxilInst_Countbits {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Countbits(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Countbits);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns the FirstbitLo\nstruct DxilInst_FirstbitLo {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_FirstbitLo(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::FirstbitLo);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns src != 0? (BitWidth-1 - FirstbitHi) : -1\nstruct DxilInst_FirstbitHi {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_FirstbitHi(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::FirstbitHi);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns src != 0? (BitWidth-1 - FirstbitSHi) : -1\nstruct DxilInst_FirstbitSHi {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_FirstbitSHi(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::FirstbitSHi);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns a if a >= b, else b\nstruct DxilInst_FMax {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_FMax(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::FMax);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_a() const { return Instr->getOperand(1); }\n  llvm::Value *get_b() const { return Instr->getOperand(2); }\n};\n\n/// This instruction returns a if a < b, else b\nstruct DxilInst_FMin {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_FMin(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::FMin);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_a() const { return Instr->getOperand(1); }\n  llvm::Value *get_b() const { return Instr->getOperand(2); }\n};\n\n/// This instruction returns the IMax of the input values\nstruct DxilInst_IMax {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_IMax(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::IMax);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_a() const { return Instr->getOperand(1); }\n  llvm::Value *get_b() const { return Instr->getOperand(2); }\n};\n\n/// This instruction returns the IMin of the input values\nstruct DxilInst_IMin {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_IMin(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::IMin);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_a() const { return Instr->getOperand(1); }\n  llvm::Value *get_b() const { return Instr->getOperand(2); }\n};\n\n/// This instruction returns the UMax of the input values\nstruct DxilInst_UMax {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_UMax(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::UMax);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_a() const { return Instr->getOperand(1); }\n  llvm::Value *get_b() const { return Instr->getOperand(2); }\n};\n\n/// This instruction returns the UMin of the input values\nstruct DxilInst_UMin {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_UMin(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::UMin);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_a() const { return Instr->getOperand(1); }\n  llvm::Value *get_b() const { return Instr->getOperand(2); }\n};\n\n/// This instruction returns the IMul of the input values\nstruct DxilInst_IMul {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_IMul(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::IMul);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_a() const { return Instr->getOperand(1); }\n  llvm::Value *get_b() const { return Instr->getOperand(2); }\n};\n\n/// This instruction returns the UMul of the input values\nstruct DxilInst_UMul {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_UMul(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::UMul);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_a() const { return Instr->getOperand(1); }\n  llvm::Value *get_b() const { return Instr->getOperand(2); }\n};\n\n/// This instruction returns the UDiv of the input values\nstruct DxilInst_UDiv {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_UDiv(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::UDiv);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_a() const { return Instr->getOperand(1); }\n  llvm::Value *get_b() const { return Instr->getOperand(2); }\n};\n\n/// This instruction returns the UAddc of the input values\nstruct DxilInst_UAddc {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_UAddc(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::UAddc);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_a() const { return Instr->getOperand(1); }\n  llvm::Value *get_b() const { return Instr->getOperand(2); }\n};\n\n/// This instruction returns the USubb of the input values\nstruct DxilInst_USubb {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_USubb(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::USubb);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_a() const { return Instr->getOperand(1); }\n  llvm::Value *get_b() const { return Instr->getOperand(2); }\n};\n\n/// This instruction performs a fused multiply add (FMA) of the form a * b + c\nstruct DxilInst_FMad {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_FMad(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::FMad);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (4 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_a() const { return Instr->getOperand(1); }\n  llvm::Value *get_b() const { return Instr->getOperand(2); }\n  llvm::Value *get_c() const { return Instr->getOperand(3); }\n};\n\n/// This instruction performs a fused multiply add (FMA) of the form a * b + c\nstruct DxilInst_Fma {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Fma(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Fma);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (4 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_a() const { return Instr->getOperand(1); }\n  llvm::Value *get_b() const { return Instr->getOperand(2); }\n  llvm::Value *get_c() const { return Instr->getOperand(3); }\n};\n\n/// This instruction performs an integral IMad\nstruct DxilInst_IMad {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_IMad(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::IMad);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (4 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_a() const { return Instr->getOperand(1); }\n  llvm::Value *get_b() const { return Instr->getOperand(2); }\n  llvm::Value *get_c() const { return Instr->getOperand(3); }\n};\n\n/// This instruction performs an integral UMad\nstruct DxilInst_UMad {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_UMad(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::UMad);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (4 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_a() const { return Instr->getOperand(1); }\n  llvm::Value *get_b() const { return Instr->getOperand(2); }\n  llvm::Value *get_c() const { return Instr->getOperand(3); }\n};\n\n/// This instruction performs an integral Msad\nstruct DxilInst_Msad {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Msad(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Msad);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (4 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_a() const { return Instr->getOperand(1); }\n  llvm::Value *get_b() const { return Instr->getOperand(2); }\n  llvm::Value *get_c() const { return Instr->getOperand(3); }\n};\n\n/// This instruction performs an integral Ibfe\nstruct DxilInst_Ibfe {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Ibfe(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Ibfe);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (4 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_a() const { return Instr->getOperand(1); }\n  llvm::Value *get_b() const { return Instr->getOperand(2); }\n  llvm::Value *get_c() const { return Instr->getOperand(3); }\n};\n\n/// This instruction performs an integral Ubfe\nstruct DxilInst_Ubfe {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Ubfe(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Ubfe);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (4 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_a() const { return Instr->getOperand(1); }\n  llvm::Value *get_b() const { return Instr->getOperand(2); }\n  llvm::Value *get_c() const { return Instr->getOperand(3); }\n};\n\n/// This instruction given a bit range from the LSB of a number, places that number of bits in another number at any offset\nstruct DxilInst_Bfi {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Bfi(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Bfi);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (5 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_width() const { return Instr->getOperand(1); }\n  llvm::Value *get_offset() const { return Instr->getOperand(2); }\n  llvm::Value *get_value() const { return Instr->getOperand(3); }\n  llvm::Value *get_replaceCount() const { return Instr->getOperand(4); }\n};\n\n/// This instruction two-dimensional vector dot-product\nstruct DxilInst_Dot2 {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Dot2(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Dot2);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (5 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_ax() const { return Instr->getOperand(1); }\n  llvm::Value *get_ay() const { return Instr->getOperand(2); }\n  llvm::Value *get_bx() const { return Instr->getOperand(3); }\n  llvm::Value *get_by() const { return Instr->getOperand(4); }\n};\n\n/// This instruction three-dimensional vector dot-product\nstruct DxilInst_Dot3 {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Dot3(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Dot3);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (7 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_ax() const { return Instr->getOperand(1); }\n  llvm::Value *get_ay() const { return Instr->getOperand(2); }\n  llvm::Value *get_az() const { return Instr->getOperand(3); }\n  llvm::Value *get_bx() const { return Instr->getOperand(4); }\n  llvm::Value *get_by() const { return Instr->getOperand(5); }\n  llvm::Value *get_bz() const { return Instr->getOperand(6); }\n};\n\n/// This instruction four-dimensional vector dot-product\nstruct DxilInst_Dot4 {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Dot4(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Dot4);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (9 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_ax() const { return Instr->getOperand(1); }\n  llvm::Value *get_ay() const { return Instr->getOperand(2); }\n  llvm::Value *get_az() const { return Instr->getOperand(3); }\n  llvm::Value *get_aw() const { return Instr->getOperand(4); }\n  llvm::Value *get_bx() const { return Instr->getOperand(5); }\n  llvm::Value *get_by() const { return Instr->getOperand(6); }\n  llvm::Value *get_bz() const { return Instr->getOperand(7); }\n  llvm::Value *get_bw() const { return Instr->getOperand(8); }\n};\n\n/// This instruction creates the handle to a resource\nstruct DxilInst_CreateHandle {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_CreateHandle(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CreateHandle);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (5 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_resourceClass() const { return Instr->getOperand(1); }\n  int8_t get_resourceClass_val() const { return (int8_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(1))->getZExtValue()); }\n  llvm::Value *get_rangeId() const { return Instr->getOperand(2); }\n  llvm::Value *get_index() const { return Instr->getOperand(3); }\n  llvm::Value *get_nonUniformIndex() const { return Instr->getOperand(4); }\n  bool get_nonUniformIndex_val() const { return (bool)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(4))->getZExtValue()); }\n};\n\n/// This instruction loads a value from a constant buffer resource\nstruct DxilInst_CBufferLoad {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_CBufferLoad(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CBufferLoad);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (4 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_handle() const { return Instr->getOperand(1); }\n  llvm::Value *get_byteOffset() const { return Instr->getOperand(2); }\n  llvm::Value *get_alignment() const { return Instr->getOperand(3); }\n  uint32_t get_alignment_val() const { return (uint32_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(3))->getZExtValue()); }\n};\n\n/// This instruction loads a value from a constant buffer resource\nstruct DxilInst_CBufferLoadLegacy {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_CBufferLoadLegacy(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CBufferLoadLegacy);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_handle() const { return Instr->getOperand(1); }\n  llvm::Value *get_regIndex() const { return Instr->getOperand(2); }\n};\n\n/// This instruction samples a texture\nstruct DxilInst_Sample {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Sample(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Sample);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (11 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_srv() const { return Instr->getOperand(1); }\n  llvm::Value *get_sampler() const { return Instr->getOperand(2); }\n  llvm::Value *get_coord0() const { return Instr->getOperand(3); }\n  llvm::Value *get_coord1() const { return Instr->getOperand(4); }\n  llvm::Value *get_coord2() const { return Instr->getOperand(5); }\n  llvm::Value *get_coord3() const { return Instr->getOperand(6); }\n  llvm::Value *get_offset0() const { return Instr->getOperand(7); }\n  llvm::Value *get_offset1() const { return Instr->getOperand(8); }\n  llvm::Value *get_offset2() const { return Instr->getOperand(9); }\n  llvm::Value *get_clamp() const { return Instr->getOperand(10); }\n};\n\n/// This instruction samples a texture after applying the input bias to the mipmap level\nstruct DxilInst_SampleBias {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_SampleBias(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::SampleBias);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (12 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_srv() const { return Instr->getOperand(1); }\n  llvm::Value *get_sampler() const { return Instr->getOperand(2); }\n  llvm::Value *get_coord0() const { return Instr->getOperand(3); }\n  llvm::Value *get_coord1() const { return Instr->getOperand(4); }\n  llvm::Value *get_coord2() const { return Instr->getOperand(5); }\n  llvm::Value *get_coord3() const { return Instr->getOperand(6); }\n  llvm::Value *get_offset0() const { return Instr->getOperand(7); }\n  llvm::Value *get_offset1() const { return Instr->getOperand(8); }\n  llvm::Value *get_offset2() const { return Instr->getOperand(9); }\n  llvm::Value *get_bias() const { return Instr->getOperand(10); }\n  llvm::Value *get_clamp() const { return Instr->getOperand(11); }\n};\n\n/// This instruction samples a texture using a mipmap-level offset\nstruct DxilInst_SampleLevel {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_SampleLevel(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::SampleLevel);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (11 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_srv() const { return Instr->getOperand(1); }\n  llvm::Value *get_sampler() const { return Instr->getOperand(2); }\n  llvm::Value *get_coord0() const { return Instr->getOperand(3); }\n  llvm::Value *get_coord1() const { return Instr->getOperand(4); }\n  llvm::Value *get_coord2() const { return Instr->getOperand(5); }\n  llvm::Value *get_coord3() const { return Instr->getOperand(6); }\n  llvm::Value *get_offset0() const { return Instr->getOperand(7); }\n  llvm::Value *get_offset1() const { return Instr->getOperand(8); }\n  llvm::Value *get_offset2() const { return Instr->getOperand(9); }\n  llvm::Value *get_LOD() const { return Instr->getOperand(10); }\n};\n\n/// This instruction samples a texture using a gradient to influence the way the sample location is calculated\nstruct DxilInst_SampleGrad {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_SampleGrad(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::SampleGrad);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (17 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_srv() const { return Instr->getOperand(1); }\n  llvm::Value *get_sampler() const { return Instr->getOperand(2); }\n  llvm::Value *get_coord0() const { return Instr->getOperand(3); }\n  llvm::Value *get_coord1() const { return Instr->getOperand(4); }\n  llvm::Value *get_coord2() const { return Instr->getOperand(5); }\n  llvm::Value *get_coord3() const { return Instr->getOperand(6); }\n  llvm::Value *get_offset0() const { return Instr->getOperand(7); }\n  llvm::Value *get_offset1() const { return Instr->getOperand(8); }\n  llvm::Value *get_offset2() const { return Instr->getOperand(9); }\n  llvm::Value *get_ddx0() const { return Instr->getOperand(10); }\n  llvm::Value *get_ddx1() const { return Instr->getOperand(11); }\n  llvm::Value *get_ddx2() const { return Instr->getOperand(12); }\n  llvm::Value *get_ddy0() const { return Instr->getOperand(13); }\n  llvm::Value *get_ddy1() const { return Instr->getOperand(14); }\n  llvm::Value *get_ddy2() const { return Instr->getOperand(15); }\n  llvm::Value *get_clamp() const { return Instr->getOperand(16); }\n};\n\n/// This instruction samples a texture and compares a single component against the specified comparison value\nstruct DxilInst_SampleCmp {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_SampleCmp(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::SampleCmp);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (12 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_srv() const { return Instr->getOperand(1); }\n  llvm::Value *get_sampler() const { return Instr->getOperand(2); }\n  llvm::Value *get_coord0() const { return Instr->getOperand(3); }\n  llvm::Value *get_coord1() const { return Instr->getOperand(4); }\n  llvm::Value *get_coord2() const { return Instr->getOperand(5); }\n  llvm::Value *get_coord3() const { return Instr->getOperand(6); }\n  llvm::Value *get_offset0() const { return Instr->getOperand(7); }\n  llvm::Value *get_offset1() const { return Instr->getOperand(8); }\n  llvm::Value *get_offset2() const { return Instr->getOperand(9); }\n  llvm::Value *get_compareValue() const { return Instr->getOperand(10); }\n  llvm::Value *get_clamp() const { return Instr->getOperand(11); }\n};\n\n/// This instruction samples a texture and compares a single component against the specified comparison value\nstruct DxilInst_SampleCmpLevelZero {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_SampleCmpLevelZero(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::SampleCmpLevelZero);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (11 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_srv() const { return Instr->getOperand(1); }\n  llvm::Value *get_sampler() const { return Instr->getOperand(2); }\n  llvm::Value *get_coord0() const { return Instr->getOperand(3); }\n  llvm::Value *get_coord1() const { return Instr->getOperand(4); }\n  llvm::Value *get_coord2() const { return Instr->getOperand(5); }\n  llvm::Value *get_coord3() const { return Instr->getOperand(6); }\n  llvm::Value *get_offset0() const { return Instr->getOperand(7); }\n  llvm::Value *get_offset1() const { return Instr->getOperand(8); }\n  llvm::Value *get_offset2() const { return Instr->getOperand(9); }\n  llvm::Value *get_compareValue() const { return Instr->getOperand(10); }\n};\n\n/// This instruction reads texel data without any filtering or sampling\nstruct DxilInst_TextureLoad {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_TextureLoad(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::TextureLoad);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (9 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_srv() const { return Instr->getOperand(1); }\n  llvm::Value *get_mipLevelOrSampleCount() const { return Instr->getOperand(2); }\n  llvm::Value *get_coord0() const { return Instr->getOperand(3); }\n  llvm::Value *get_coord1() const { return Instr->getOperand(4); }\n  llvm::Value *get_coord2() const { return Instr->getOperand(5); }\n  llvm::Value *get_offset0() const { return Instr->getOperand(6); }\n  llvm::Value *get_offset1() const { return Instr->getOperand(7); }\n  llvm::Value *get_offset2() const { return Instr->getOperand(8); }\n};\n\n/// This instruction reads texel data without any filtering or sampling\nstruct DxilInst_TextureStore {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_TextureStore(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::TextureStore);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (10 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_srv() const { return Instr->getOperand(1); }\n  llvm::Value *get_coord0() const { return Instr->getOperand(2); }\n  llvm::Value *get_coord1() const { return Instr->getOperand(3); }\n  llvm::Value *get_coord2() const { return Instr->getOperand(4); }\n  llvm::Value *get_value0() const { return Instr->getOperand(5); }\n  llvm::Value *get_value1() const { return Instr->getOperand(6); }\n  llvm::Value *get_value2() const { return Instr->getOperand(7); }\n  llvm::Value *get_value3() const { return Instr->getOperand(8); }\n  llvm::Value *get_mask() const { return Instr->getOperand(9); }\n};\n\n/// This instruction reads from a TypedBuffer\nstruct DxilInst_BufferLoad {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_BufferLoad(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BufferLoad);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (4 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_srv() const { return Instr->getOperand(1); }\n  llvm::Value *get_index() const { return Instr->getOperand(2); }\n  llvm::Value *get_wot() const { return Instr->getOperand(3); }\n};\n\n/// This instruction writes to a RWTypedBuffer\nstruct DxilInst_BufferStore {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_BufferStore(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BufferStore);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (9 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_uav() const { return Instr->getOperand(1); }\n  llvm::Value *get_coord0() const { return Instr->getOperand(2); }\n  llvm::Value *get_coord1() const { return Instr->getOperand(3); }\n  llvm::Value *get_value0() const { return Instr->getOperand(4); }\n  llvm::Value *get_value1() const { return Instr->getOperand(5); }\n  llvm::Value *get_value2() const { return Instr->getOperand(6); }\n  llvm::Value *get_value3() const { return Instr->getOperand(7); }\n  llvm::Value *get_mask() const { return Instr->getOperand(8); }\n};\n\n/// This instruction atomically increments/decrements the hidden 32-bit counter stored with a Count or Append UAV\nstruct DxilInst_BufferUpdateCounter {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_BufferUpdateCounter(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BufferUpdateCounter);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_uav() const { return Instr->getOperand(1); }\n  llvm::Value *get_inc() const { return Instr->getOperand(2); }\n};\n\n/// This instruction determines whether all values from a Sample, Gather, or Load operation accessed mapped tiles in a tiled resource\nstruct DxilInst_CheckAccessFullyMapped {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_CheckAccessFullyMapped(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CheckAccessFullyMapped);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_status() const { return Instr->getOperand(1); }\n};\n\n/// This instruction gets texture size information\nstruct DxilInst_GetDimensions {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_GetDimensions(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::GetDimensions);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_handle() const { return Instr->getOperand(1); }\n  llvm::Value *get_mipLevel() const { return Instr->getOperand(2); }\n};\n\n/// This instruction gathers the four texels that would be used in a bi-linear filtering operation\nstruct DxilInst_TextureGather {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_TextureGather(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::TextureGather);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (10 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_srv() const { return Instr->getOperand(1); }\n  llvm::Value *get_sampler() const { return Instr->getOperand(2); }\n  llvm::Value *get_coord0() const { return Instr->getOperand(3); }\n  llvm::Value *get_coord1() const { return Instr->getOperand(4); }\n  llvm::Value *get_coord2() const { return Instr->getOperand(5); }\n  llvm::Value *get_coord3() const { return Instr->getOperand(6); }\n  llvm::Value *get_offset0() const { return Instr->getOperand(7); }\n  llvm::Value *get_offset1() const { return Instr->getOperand(8); }\n  llvm::Value *get_channel() const { return Instr->getOperand(9); }\n};\n\n/// This instruction same as TextureGather, except this instrution performs comparison on texels, similar to SampleCmp\nstruct DxilInst_TextureGatherCmp {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_TextureGatherCmp(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::TextureGatherCmp);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (11 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_srv() const { return Instr->getOperand(1); }\n  llvm::Value *get_sampler() const { return Instr->getOperand(2); }\n  llvm::Value *get_coord0() const { return Instr->getOperand(3); }\n  llvm::Value *get_coord1() const { return Instr->getOperand(4); }\n  llvm::Value *get_coord2() const { return Instr->getOperand(5); }\n  llvm::Value *get_coord3() const { return Instr->getOperand(6); }\n  llvm::Value *get_offset0() const { return Instr->getOperand(7); }\n  llvm::Value *get_offset1() const { return Instr->getOperand(8); }\n  llvm::Value *get_channel() const { return Instr->getOperand(9); }\n  llvm::Value *get_compareVale() const { return Instr->getOperand(10); }\n};\n\n/// This instruction gets the position of the specified sample\nstruct DxilInst_Texture2DMSGetSamplePosition {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Texture2DMSGetSamplePosition(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Texture2DMSGetSamplePosition);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_srv() const { return Instr->getOperand(1); }\n  llvm::Value *get_index() const { return Instr->getOperand(2); }\n};\n\n/// This instruction gets the position of the specified sample\nstruct DxilInst_RenderTargetGetSamplePosition {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_RenderTargetGetSamplePosition(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RenderTargetGetSamplePosition);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_index() const { return Instr->getOperand(1); }\n};\n\n/// This instruction gets the number of samples for a render target\nstruct DxilInst_RenderTargetGetSampleCount {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_RenderTargetGetSampleCount(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::RenderTargetGetSampleCount);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (1 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n};\n\n/// This instruction performs an atomic operation on two operands\nstruct DxilInst_AtomicBinOp {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_AtomicBinOp(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::AtomicBinOp);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (7 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_handle() const { return Instr->getOperand(1); }\n  llvm::Value *get_atomicOp() const { return Instr->getOperand(2); }\n  llvm::Value *get_offset0() const { return Instr->getOperand(3); }\n  llvm::Value *get_offset1() const { return Instr->getOperand(4); }\n  llvm::Value *get_offset2() const { return Instr->getOperand(5); }\n  llvm::Value *get_newValue() const { return Instr->getOperand(6); }\n};\n\n/// This instruction atomic compare and exchange to memory\nstruct DxilInst_AtomicCompareExchange {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_AtomicCompareExchange(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::AtomicCompareExchange);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (7 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_handle() const { return Instr->getOperand(1); }\n  llvm::Value *get_offset0() const { return Instr->getOperand(2); }\n  llvm::Value *get_offset1() const { return Instr->getOperand(3); }\n  llvm::Value *get_offset2() const { return Instr->getOperand(4); }\n  llvm::Value *get_compareValue() const { return Instr->getOperand(5); }\n  llvm::Value *get_newValue() const { return Instr->getOperand(6); }\n};\n\n/// This instruction inserts a memory barrier in the shader\nstruct DxilInst_Barrier {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Barrier(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Barrier);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_barrierMode() const { return Instr->getOperand(1); }\n  int32_t get_barrierMode_val() const { return (int32_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(1))->getZExtValue()); }\n};\n\n/// This instruction calculates the level of detail\nstruct DxilInst_CalculateLOD {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_CalculateLOD(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CalculateLOD);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (7 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_handle() const { return Instr->getOperand(1); }\n  llvm::Value *get_sampler() const { return Instr->getOperand(2); }\n  llvm::Value *get_coord0() const { return Instr->getOperand(3); }\n  llvm::Value *get_coord1() const { return Instr->getOperand(4); }\n  llvm::Value *get_coord2() const { return Instr->getOperand(5); }\n  llvm::Value *get_clamped() const { return Instr->getOperand(6); }\n};\n\n/// This instruction discard the current pixel\nstruct DxilInst_Discard {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Discard(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Discard);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_condition() const { return Instr->getOperand(1); }\n};\n\n/// This instruction computes the rate of change of components per stamp\nstruct DxilInst_DerivCoarseX {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_DerivCoarseX(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::DerivCoarseX);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction computes the rate of change of components per stamp\nstruct DxilInst_DerivCoarseY {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_DerivCoarseY(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::DerivCoarseY);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction computes the rate of change of components per pixel\nstruct DxilInst_DerivFineX {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_DerivFineX(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::DerivFineX);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction computes the rate of change of components per pixel\nstruct DxilInst_DerivFineY {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_DerivFineY(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::DerivFineY);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction evaluates an input attribute at pixel center with an offset\nstruct DxilInst_EvalSnapped {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_EvalSnapped(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::EvalSnapped);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (6 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_inputSigId() const { return Instr->getOperand(1); }\n  llvm::Value *get_inputRowIndex() const { return Instr->getOperand(2); }\n  llvm::Value *get_inputColIndex() const { return Instr->getOperand(3); }\n  llvm::Value *get_offsetX() const { return Instr->getOperand(4); }\n  llvm::Value *get_offsetY() const { return Instr->getOperand(5); }\n};\n\n/// This instruction evaluates an input attribute at a sample location\nstruct DxilInst_EvalSampleIndex {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_EvalSampleIndex(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::EvalSampleIndex);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (5 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_inputSigId() const { return Instr->getOperand(1); }\n  llvm::Value *get_inputRowIndex() const { return Instr->getOperand(2); }\n  llvm::Value *get_inputColIndex() const { return Instr->getOperand(3); }\n  llvm::Value *get_sampleIndex() const { return Instr->getOperand(4); }\n};\n\n/// This instruction evaluates an input attribute at pixel center\nstruct DxilInst_EvalCentroid {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_EvalCentroid(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::EvalCentroid);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (4 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_inputSigId() const { return Instr->getOperand(1); }\n  llvm::Value *get_inputRowIndex() const { return Instr->getOperand(2); }\n  llvm::Value *get_inputColIndex() const { return Instr->getOperand(3); }\n};\n\n/// This instruction returns the sample index in a sample-frequency pixel shader\nstruct DxilInst_SampleIndex {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_SampleIndex(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::SampleIndex);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (1 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n};\n\n/// This instruction returns the coverage mask input in a pixel shader\nstruct DxilInst_Coverage {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_Coverage(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::Coverage);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (1 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n};\n\n/// This instruction returns underestimated coverage input from conservative rasterization in a pixel shader\nstruct DxilInst_InnerCoverage {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_InnerCoverage(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::InnerCoverage);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (1 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n};\n\n/// This instruction reads the thread ID\nstruct DxilInst_ThreadId {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_ThreadId(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::ThreadId);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_component() const { return Instr->getOperand(1); }\n};\n\n/// This instruction reads the group ID (SV_GroupID)\nstruct DxilInst_GroupId {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_GroupId(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::GroupId);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_component() const { return Instr->getOperand(1); }\n};\n\n/// This instruction reads the thread ID within the group (SV_GroupThreadID)\nstruct DxilInst_ThreadIdInGroup {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_ThreadIdInGroup(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::ThreadIdInGroup);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_component() const { return Instr->getOperand(1); }\n};\n\n/// This instruction provides a flattened index for a given thread within a given group (SV_GroupIndex)\nstruct DxilInst_FlattenedThreadIdInGroup {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_FlattenedThreadIdInGroup(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::FlattenedThreadIdInGroup);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (1 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n};\n\n/// This instruction emits a vertex to a given stream\nstruct DxilInst_EmitStream {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_EmitStream(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::EmitStream);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_streamId() const { return Instr->getOperand(1); }\n};\n\n/// This instruction completes the current primitive topology at the specified stream\nstruct DxilInst_CutStream {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_CutStream(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CutStream);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_streamId() const { return Instr->getOperand(1); }\n};\n\n/// This instruction equivalent to an EmitStream followed by a CutStream\nstruct DxilInst_EmitThenCutStream {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_EmitThenCutStream(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::EmitThenCutStream);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_streamId() const { return Instr->getOperand(1); }\n};\n\n/// This instruction GSInstanceID\nstruct DxilInst_GSInstanceID {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_GSInstanceID(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::GSInstanceID);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (1 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n};\n\n/// This instruction creates a double value\nstruct DxilInst_MakeDouble {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_MakeDouble(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::MakeDouble);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_lo() const { return Instr->getOperand(1); }\n  llvm::Value *get_hi() const { return Instr->getOperand(2); }\n};\n\n/// This instruction splits a double into low and high parts\nstruct DxilInst_SplitDouble {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_SplitDouble(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::SplitDouble);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction LoadOutputControlPoint\nstruct DxilInst_LoadOutputControlPoint {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_LoadOutputControlPoint(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::LoadOutputControlPoint);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (5 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_inputSigId() const { return Instr->getOperand(1); }\n  llvm::Value *get_row() const { return Instr->getOperand(2); }\n  llvm::Value *get_col() const { return Instr->getOperand(3); }\n  llvm::Value *get_index() const { return Instr->getOperand(4); }\n};\n\n/// This instruction LoadPatchConstant\nstruct DxilInst_LoadPatchConstant {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_LoadPatchConstant(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::LoadPatchConstant);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (4 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_inputSigId() const { return Instr->getOperand(1); }\n  llvm::Value *get_row() const { return Instr->getOperand(2); }\n  llvm::Value *get_col() const { return Instr->getOperand(3); }\n};\n\n/// This instruction DomainLocation\nstruct DxilInst_DomainLocation {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_DomainLocation(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::DomainLocation);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_component() const { return Instr->getOperand(1); }\n  int8_t get_component_val() const { return (int8_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(1))->getZExtValue()); }\n};\n\n/// This instruction StorePatchConstant\nstruct DxilInst_StorePatchConstant {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_StorePatchConstant(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::StorePatchConstant);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (5 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_outputSigID() const { return Instr->getOperand(1); }\n  llvm::Value *get_row() const { return Instr->getOperand(2); }\n  llvm::Value *get_col() const { return Instr->getOperand(3); }\n  llvm::Value *get_value() const { return Instr->getOperand(4); }\n};\n\n/// This instruction OutputControlPointID\nstruct DxilInst_OutputControlPointID {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_OutputControlPointID(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::OutputControlPointID);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (1 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n};\n\n/// This instruction PrimitiveID\nstruct DxilInst_PrimitiveID {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_PrimitiveID(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::PrimitiveID);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (1 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n};\n\n/// This instruction CycleCounterLegacy\nstruct DxilInst_CycleCounterLegacy {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_CycleCounterLegacy(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CycleCounterLegacy);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (1 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n};\n\n/// This instruction returns 1 for the first lane in the wave\nstruct DxilInst_WaveIsFirstLane {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_WaveIsFirstLane(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveIsFirstLane);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (1 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n};\n\n/// This instruction returns the index of the current lane in the wave\nstruct DxilInst_WaveGetLaneIndex {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_WaveGetLaneIndex(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveGetLaneIndex);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (1 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n};\n\n/// This instruction returns the number of lanes in the wave\nstruct DxilInst_WaveGetLaneCount {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_WaveGetLaneCount(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveGetLaneCount);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (1 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n};\n\n/// This instruction returns 1 if any of the lane evaluates the value to true\nstruct DxilInst_WaveAnyTrue {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_WaveAnyTrue(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveAnyTrue);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_cond() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns 1 if all the lanes evaluate the value to true\nstruct DxilInst_WaveAllTrue {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_WaveAllTrue(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveAllTrue);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_cond() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns 1 if all the lanes have the same value\nstruct DxilInst_WaveActiveAllEqual {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_WaveActiveAllEqual(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveActiveAllEqual);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns a struct with a bit set for each lane where the condition is true\nstruct DxilInst_WaveActiveBallot {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_WaveActiveBallot(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveActiveBallot);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_cond() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns the value from the specified lane\nstruct DxilInst_WaveReadLaneAt {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_WaveReadLaneAt(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveReadLaneAt);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n  llvm::Value *get_lane() const { return Instr->getOperand(2); }\n};\n\n/// This instruction returns the value from the first lane\nstruct DxilInst_WaveReadLaneFirst {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_WaveReadLaneFirst(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveReadLaneFirst);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns the result the operation across waves\nstruct DxilInst_WaveActiveOp {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_WaveActiveOp(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveActiveOp);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (4 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n  llvm::Value *get_op() const { return Instr->getOperand(2); }\n  int8_t get_op_val() const { return (int8_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(2))->getZExtValue()); }\n  llvm::Value *get_sop() const { return Instr->getOperand(3); }\n  int8_t get_sop_val() const { return (int8_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(3))->getZExtValue()); }\n};\n\n/// This instruction returns the result of the operation across all lanes\nstruct DxilInst_WaveActiveBit {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_WaveActiveBit(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveActiveBit);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n  llvm::Value *get_op() const { return Instr->getOperand(2); }\n  int8_t get_op_val() const { return (int8_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(2))->getZExtValue()); }\n};\n\n/// This instruction returns the result of the operation on prior lanes\nstruct DxilInst_WavePrefixOp {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_WavePrefixOp(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WavePrefixOp);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (4 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n  llvm::Value *get_op() const { return Instr->getOperand(2); }\n  int8_t get_op_val() const { return (int8_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(2))->getZExtValue()); }\n  llvm::Value *get_sop() const { return Instr->getOperand(3); }\n  int8_t get_sop_val() const { return (int8_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(3))->getZExtValue()); }\n};\n\n/// This instruction reads from a lane in the quad\nstruct DxilInst_QuadReadLaneAt {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_QuadReadLaneAt(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::QuadReadLaneAt);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n  llvm::Value *get_quadLane() const { return Instr->getOperand(2); }\n  uint32_t get_quadLane_val() const { return (uint32_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(2))->getZExtValue()); }\n};\n\n/// This instruction returns the result of a quad-level operation\nstruct DxilInst_QuadOp {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_QuadOp(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::QuadOp);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n  llvm::Value *get_op() const { return Instr->getOperand(2); }\n  int8_t get_op_val() const { return (int8_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(2))->getZExtValue()); }\n};\n\n/// This instruction bitcast between different sizes\nstruct DxilInst_BitcastI16toF16 {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_BitcastI16toF16(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BitcastI16toF16);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction bitcast between different sizes\nstruct DxilInst_BitcastF16toI16 {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_BitcastF16toI16(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BitcastF16toI16);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction bitcast between different sizes\nstruct DxilInst_BitcastI32toF32 {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_BitcastI32toF32(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BitcastI32toF32);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction bitcast between different sizes\nstruct DxilInst_BitcastF32toI32 {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_BitcastF32toI32(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BitcastF32toI32);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction bitcast between different sizes\nstruct DxilInst_BitcastI64toF64 {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_BitcastI64toF64(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BitcastI64toF64);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction bitcast between different sizes\nstruct DxilInst_BitcastF64toI64 {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_BitcastF64toI64(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::BitcastF64toI64);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction legacy fuction to convert float (f32) to half (f16) (this is not related to min-precision)\nstruct DxilInst_LegacyF32ToF16 {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_LegacyF32ToF16(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::LegacyF32ToF16);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction legacy fuction to convert half (f16) to float (f32) (this is not related to min-precision)\nstruct DxilInst_LegacyF16ToF32 {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_LegacyF16ToF32(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::LegacyF16ToF32);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction legacy fuction to convert double to float\nstruct DxilInst_LegacyDoubleToFloat {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_LegacyDoubleToFloat(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::LegacyDoubleToFloat);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction legacy fuction to convert double to int32\nstruct DxilInst_LegacyDoubleToSInt32 {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_LegacyDoubleToSInt32(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::LegacyDoubleToSInt32);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction legacy fuction to convert double to uint32\nstruct DxilInst_LegacyDoubleToUInt32 {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_LegacyDoubleToUInt32(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::LegacyDoubleToUInt32);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns the count of bits set to 1 across the wave\nstruct DxilInst_WaveAllBitCount {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_WaveAllBitCount(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WaveAllBitCount);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n\n/// This instruction returns the count of bits set to 1 on prior lanes\nstruct DxilInst_WavePrefixBitCount {\n  const llvm::Instruction *Instr;\n  // Construction and identification\n  DxilInst_WavePrefixBitCount(llvm::Instruction *pInstr) : Instr(pInstr) {}\n  operator bool() const {\n    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::WavePrefixBitCount);\n  }\n  // Validation support\n  bool isAllowed() const { return true; }\n  bool isArgumentListValid() const {\n    if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;\n    return true;\n  }\n  // Accessors\n  llvm::Value *get_value() const { return Instr->getOperand(1); }\n};\n// INSTR-HELPER:END\n} // namespace hlsl\n"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/DxilInterpolationMode.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// DxilInterpolationMode.h                                                   //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Representation of HLSL interpolation mode.                                //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n#include \"DxilConstants.h\"\n\nnamespace hlsl {\n\n\n/// Use this class to represent signature element interpolation mode.\nclass InterpolationMode {\npublic:\n  using Kind = DXIL::InterpolationMode;\n\n  InterpolationMode();\n  InterpolationMode(Kind Kind);\n  InterpolationMode(unsigned long long Kind);\n  InterpolationMode(bool bNoInterpolation, bool bLinear, bool bNoperspective, bool bCentroid, bool bSample);\n  InterpolationMode &operator=(const InterpolationMode &o);\n  bool operator==(const InterpolationMode &o) const;\n\n  bool IsValid() const                        { return m_Kind >= Kind::Undefined && m_Kind < Kind::Invalid; }\n  bool IsUndefined() const                    { return m_Kind == Kind::Undefined; }\n  bool IsConstant() const                     { return m_Kind == Kind::Constant; }\n  bool IsLinear() const                       { return m_Kind == Kind::Linear; }\n  bool IsLinearCentroid() const               { return m_Kind == Kind::LinearCentroid; }\n  bool IsLinearNoperspective() const          { return m_Kind == Kind::LinearNoperspective; }\n  bool IsLinearNoperspectiveCentroid() const  { return m_Kind == Kind::LinearNoperspectiveCentroid; }\n  bool IsLinearSample() const                 { return m_Kind == Kind::LinearSample; }\n  bool IsLinearNoperspectiveSample() const    { return m_Kind == Kind::LinearNoperspectiveSample; }\n\n  bool IsAnyLinear() const;\n  bool IsAnyNoPerspective() const;\n  bool IsAnyCentroid() const;\n  bool IsAnySample() const;\n\n  Kind GetKind() const                        { return m_Kind; }\n  const char *GetName() const;\n\nprivate:\n  Kind m_Kind;\n};\n\n} // namespace hlsl\n"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/DxilMetadataHelper.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// DxilMetadataHelper.h                                                      //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Helper to serialize/desialize metadata for DxilModule.                    //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n#include \"dxc/HLSL/DxilConstants.h\"\n#include <memory>\n#include <string>\n#include <vector>\n\nnamespace llvm {\nclass LLVMContext;\nclass Module;\nclass Function;\nclass Value;\nclass MDOperand;\nclass Metadata;\nclass ConstantAsMetadata;\nclass MDTuple;\nclass MDNode;\nclass NamedMDNode;\nclass GlobalVariable;\n};\n\nnamespace hlsl {\n\nclass ShaderModel;\nclass DxilSignature;\nclass DxilSignatureElement;\nclass DxilModule;\nclass DxilResourceBase;\nclass DxilCBuffer;\nclass DxilResource;\nclass DxilSampler;\nclass DxilTypeSystem;\nclass DxilStructAnnotation;\nclass DxilFieldAnnotation;\nclass DxilFunctionAnnotation;\nclass DxilParameterAnnotation;\nclass RootSignatureHandle;\n\n\n/// Use this class to manipulate DXIL-spcific metadata.\n// In our code, only DxilModule and HLModule should use this class.\nclass DxilMDHelper {\npublic:\n  //\n  // Constants for metadata names and field positions.\n  //\n\n  // Dxil version.\n  static const char kDxilVersionMDName[];\n  static const unsigned kDxilVersionNumFields = 2;\n  static const unsigned kDxilVersionMajorIdx  = 0;  // DXIL version major.\n  static const unsigned kDxilVersionMinorIdx  = 1;  // DXIL version minor.\n\n  // Shader model.\n  static const char kDxilShaderModelMDName[];\n  static const unsigned kDxilShaderModelNumFields = 3;\n  static const unsigned kDxilShaderModelTypeIdx   = 0;  // Shader type (vs,ps,cs,gs,ds,hs).\n  static const unsigned kDxilShaderModelMajorIdx  = 1;  // Shader model major.\n  static const unsigned kDxilShaderModelMinorIdx  = 2;  // Shader model minor.\n\n  // Entry points.\n  static const char kDxilEntryPointsMDName[];\n\n  // Root Signature, for intermediate use, not valid in final DXIL module.\n  static const char kDxilRootSignatureMDName[];\n\n  static const unsigned kDxilEntryPointNumFields  = 5;\n  static const unsigned kDxilEntryPointFunction   = 0;  // Entry point function symbol.\n  static const unsigned kDxilEntryPointName       = 1;  // Entry point unmangled name.\n  static const unsigned kDxilEntryPointSignatures = 2;  // Entry point signature tuple.\n  static const unsigned kDxilEntryPointResources  = 3;  // Entry point resource tuple.\n  static const unsigned kDxilEntryPointProperties = 4;  // Entry point properties tuple.\n\n  // Signatures.\n  static const unsigned kDxilNumSignatureFields     = 3;\n  static const unsigned kDxilInputSignature         = 0;  // Shader input signature.\n  static const unsigned kDxilOutputSignature        = 1;  // Shader output signature.\n  static const unsigned kDxilPatchConstantSignature = 2;  // Shader patch constant (PC) signature.\n\n  // Signature Element.\n  static const unsigned kDxilSignatureElementNumFields      = 11;\n  static const unsigned kDxilSignatureElementID             = 0;  // Unique element ID.\n  static const unsigned kDxilSignatureElementName           = 1;  // Element name.\n  static const unsigned kDxilSignatureElementType           = 2;  // Element type.\n  static const unsigned kDxilSignatureElementSystemValue    = 3;  // Effective system value.\n  static const unsigned kDxilSignatureElementIndexVector    = 4;  // Semantic index vector.\n  static const unsigned kDxilSignatureElementInterpMode     = 5;  // Interpolation mode.\n  static const unsigned kDxilSignatureElementRows           = 6;  // Number of rows.\n  static const unsigned kDxilSignatureElementCols           = 7;  // Number of columns.\n  static const unsigned kDxilSignatureElementStartRow       = 8;  // Element packing start row.\n  static const unsigned kDxilSignatureElementStartCol       = 9;  // Element packing start column.\n  static const unsigned kDxilSignatureElementNameValueList  = 10;  // Name-value list for extended properties.\n\n  // Signature Element Extended Properties.\n  static const unsigned kDxilSignatureElementOutputStreamTag = 0;\n  static const unsigned kHLSignatureElementGlobalSymbolTag   = 1;\n\n  // Resources.\n  static const char kDxilResourcesMDName[];\n  static const unsigned kDxilNumResourceFields              = 4;\n  static const unsigned kDxilResourceSRVs                   = 0;\n  static const unsigned kDxilResourceUAVs                   = 1;\n  static const unsigned kDxilResourceCBuffers               = 2;\n  static const unsigned kDxilResourceSamplers               = 3;\n\n  // ResourceBase.\n  static const unsigned kDxilResourceBaseNumFields          = 6;\n  static const unsigned kDxilResourceBaseID                 = 0;  // Unique (per type) resource ID.\n  static const unsigned kDxilResourceBaseVariable           = 1;  // Resource global variable.\n  static const unsigned kDxilResourceBaseName               = 2;  // Original (HLSL) name of the resource.\n  static const unsigned kDxilResourceBaseSpaceID            = 3;  // Resource range space ID.\n  static const unsigned kDxilResourceBaseLowerBound         = 4;  // Resource range lower bound.\n  static const unsigned kDxilResourceBaseRangeSize          = 5;  // Resource range size.\n\n  // SRV-specific.\n  static const unsigned kDxilSRVNumFields                   = 9;\n  static const unsigned kDxilSRVShape                       = 6;  // SRV shape.\n  static const unsigned kDxilSRVSampleCount                 = 7;  // SRV sample count.\n  static const unsigned kDxilSRVNameValueList               = 8;  // Name-value list for extended properties.\n\n  // UAV-specific.\n  static const unsigned kDxilUAVNumFields                   = 11;\n  static const unsigned kDxilUAVShape                       = 6;  // UAV shape.\n  static const unsigned kDxilUAVGloballyCoherent            = 7;  // Globally-coherent UAV.\n  static const unsigned kDxilUAVCounter                     = 8;  // UAV with a counter.\n  static const unsigned kDxilUAVRasterizerOrderedView       = 9;  // UAV that is a ROV.\n  static const unsigned kDxilUAVNameValueList               = 10; // Name-value list for extended properties.\n\n  // CBuffer-specific.\n  static const unsigned kDxilCBufferNumFields               = 8;\n  static const unsigned kDxilCBufferSizeInBytes             = 6;  // CBuffer size in bytes.\n  static const unsigned kDxilCBufferNameValueList           = 7;  // Name-value list for extended properties.\n\n  // CBuffer extended properties\n  static const unsigned kHLCBufferIsTBufferTag              = 0;  // CBuffer is actually TBuffer, not yet converted to SRV.\n\n  // Sampler-specific.\n  static const unsigned kDxilSamplerNumFields               = 8;\n  static const unsigned kDxilSamplerType                    = 6;  // Sampler type.\n  static const unsigned kDxilSamplerNameValueList           = 7;  // Name-value list for extended properties.\n\n  // Resource extended property tags.\n  static const unsigned kDxilTypedBufferElementTypeTag            = 0;\n  static const unsigned kDxilStructuredBufferElementStrideTag     = 1;\n\n  // Type system.\n  static const char kDxilTypeSystemMDName[];\n  static const char kDxilTypeSystemHelperVariablePrefix[];\n  static const unsigned kDxilTypeSystemStructTag                  = 0;\n  static const unsigned kDxilTypeSystemFunctionTag                = 1;\n  static const unsigned kDxilFieldAnnotationSNormTag              = 0;\n  static const unsigned kDxilFieldAnnotationUNormTag              = 1;\n  static const unsigned kDxilFieldAnnotationMatrixTag             = 2;\n  static const unsigned kDxilFieldAnnotationCBufferOffsetTag      = 3;\n  static const unsigned kDxilFieldAnnotationSemanticStringTag     = 4;\n  static const unsigned kDxilFieldAnnotationInterpolationModeTag  = 5;\n  static const unsigned kDxilFieldAnnotationFieldNameTag          = 6;\n  static const unsigned kDxilFieldAnnotationCompTypeTag           = 7;\n  static const unsigned kDxilFieldAnnotationPreciseTag            = 8;\n\n  // Control flow hint.\n  static const char kDxilControlFlowHintMDName[];\n\n  // Precise attribute.\n  static const char kDxilPreciseAttributeMDName[];\n\n  // Validator version.\n  static const char kDxilValidatorVersionMDName[];\n\n  // Extended shader property tags.\n  static const unsigned kDxilShaderFlagsTag     = 0;\n  static const unsigned kDxilGSStateTag         = 1;\n  static const unsigned kDxilDSStateTag         = 2;\n  static const unsigned kDxilHSStateTag         = 3;\n  static const unsigned kDxilNumThreadsTag      = 4;\n\n  // GSState.\n  static const unsigned kDxilGSStateNumFields               = 5;\n  static const unsigned kDxilGSStateInputPrimitive          = 0;\n  static const unsigned kDxilGSStateMaxVertexCount          = 1;\n  static const unsigned kDxilGSStateActiveStreamMask        = 2;\n  static const unsigned kDxilGSStateOutputStreamTopology    = 3;\n  static const unsigned kDxilGSStateGSInstanceCount         = 4;\n\n  // DSState.\n  static const unsigned kDxilDSStateNumFields               = 2;\n  static const unsigned kDxilDSStateTessellatorDomain       = 0;\n  static const unsigned kDxilDSStateInputControlPointCount  = 1;\n\n  // HSState.\n  static const unsigned kDxilHSStateNumFields                 = 7;\n  static const unsigned kDxilHSStatePatchConstantFunction     = 0;\n  static const unsigned kDxilHSStateInputControlPointCount    = 1;\n  static const unsigned kDxilHSStateOutputControlPointCount   = 2;\n  static const unsigned kDxilHSStateTessellatorDomain         = 3;\n  static const unsigned kDxilHSStateTessellatorPartitioning   = 4;\n  static const unsigned kDxilHSStateTessellatorOutputPrimitive= 5;\n  static const unsigned kDxilHSStateMaxTessellationFactor     = 6;\n\npublic:\n  /// Use this class to manipulate metadata of DXIL or high-level DX IR specific fields in the record.\n  class ExtraPropertyHelper {\n  public:\n    ExtraPropertyHelper(llvm::Module *pModule);\n\n    virtual void EmitSRVProperties(const DxilResource &SRV, std::vector<llvm::Metadata *> &MDVals) = 0;\n    virtual void LoadSRVProperties(const llvm::MDOperand &MDO, DxilResource &SRV) = 0;\n\n    virtual void EmitUAVProperties(const DxilResource &UAV, std::vector<llvm::Metadata *> &MDVals) = 0;\n    virtual void LoadUAVProperties(const llvm::MDOperand &MDO, DxilResource &UAV) = 0;\n\n    virtual void EmitCBufferProperties(const DxilCBuffer &CB, std::vector<llvm::Metadata *> &MDVals) = 0;\n    virtual void LoadCBufferProperties(const llvm::MDOperand &MDO, DxilCBuffer &CB) = 0;\n\n    virtual void EmitSamplerProperties(const DxilSampler &S, std::vector<llvm::Metadata *> &MDVals) = 0;\n    virtual void LoadSamplerProperties(const llvm::MDOperand &MDO, DxilSampler &S) = 0;\n\n    virtual void EmitSignatureElementProperties(const DxilSignatureElement &SE, std::vector<llvm::Metadata *> &MDVals) = 0;\n    virtual void LoadSignatureElementProperties(const llvm::MDOperand &MDO, DxilSignatureElement &SE) = 0;\n\n  protected:\n    llvm::LLVMContext &m_Ctx;\n    llvm::Module *m_pModule;\n  };\n\npublic:\n  DxilMDHelper(llvm::Module *pModule, std::unique_ptr<ExtraPropertyHelper> EPH);\n  ~DxilMDHelper();\n\n  void SetShaderModel(const ShaderModel *pSM);\n  const ShaderModel *GetShaderModel() const;\n\n  // Dxil version.\n  void EmitDxilVersion(unsigned Major, unsigned Minor);\n  void LoadDxilVersion(unsigned &Major, unsigned &Minor);\n\n  // Shader model.\n  void EmitDxilShaderModel(const ShaderModel *pSM);\n  void LoadDxilShaderModel(const ShaderModel *&pSM);\n\n  // Entry points.\n  void EmitDxilEntryPoints(std::vector<llvm::MDNode *> &MDEntries);\n  const llvm::NamedMDNode *GetDxilEntryPoints();\n  llvm::MDTuple *EmitDxilEntryPointTuple(llvm::Function *pFunc, const std::string &Name, llvm::MDTuple *pSignatures,\n                                         llvm::MDTuple *pResources, llvm::MDTuple *pProperties);\n  void GetDxilEntryPoint(const llvm::MDNode *MDO, llvm::Function *&pFunc, std::string &Name,\n                         const llvm::MDOperand *&pSignatures, const llvm::MDOperand *&pResources,\n                         const llvm::MDOperand *&pProperties);\n\n  // Signatures.\n  llvm::MDTuple *EmitDxilSignatures(const DxilSignature &InputSig, const DxilSignature &OutputSig, const DxilSignature &PCSig);\n  void LoadDxilSignatures(const llvm::MDOperand &MDO, DxilSignature &InputSig, \n                          DxilSignature &OutputSig, DxilSignature &PCSig);\n  llvm::MDTuple *EmitSignatureMetadata(const DxilSignature &Sig);\n  void EmitRootSignature(RootSignatureHandle &RootSig);\n  void LoadSignatureMetadata(const llvm::MDOperand &MDO, DxilSignature &Sig);\n  llvm::MDTuple *EmitSignatureElement(const DxilSignatureElement &SE);\n  void LoadSignatureElement(const llvm::MDOperand &MDO, DxilSignatureElement &SE);\n  void LoadRootSignature(RootSignatureHandle &RootSig);\n\n  // Resources.\n  llvm::MDTuple *EmitDxilResourceTuple(llvm::MDTuple *pSRVs, llvm::MDTuple *pUAVs, \n                                       llvm::MDTuple *pCBuffers, llvm::MDTuple *pSamplers);\n  void GetDxilResources(const llvm::MDOperand &MDO, const llvm::MDTuple *&pSRVs, const llvm::MDTuple *&pUAVs, \n                        const llvm::MDTuple *&pCBuffers, const llvm::MDTuple *&pSamplers);\n  void EmitDxilResourceBase(const DxilResourceBase &R, llvm::Metadata *ppMDVals[]);\n  void LoadDxilResourceBase(const llvm::MDOperand &MDO, DxilResourceBase &R);\n  llvm::MDTuple *EmitDxilSRV(const DxilResource &SRV);\n  void LoadDxilSRV(const llvm::MDOperand &MDO, DxilResource &SRV);\n  llvm::MDTuple *EmitDxilUAV(const DxilResource &UAV);\n  void LoadDxilUAV(const llvm::MDOperand &MDO, DxilResource &UAV);\n  llvm::MDTuple *EmitDxilCBuffer(const DxilCBuffer &CB);\n  void LoadDxilCBuffer(const llvm::MDOperand &MDO, DxilCBuffer &CB);\n  llvm::MDTuple *EmitDxilSampler(const DxilSampler &S);\n  void LoadDxilSampler(const llvm::MDOperand &MDO, DxilSampler &S);\n\n  // Type system.\n  void EmitDxilTypeSystem(DxilTypeSystem &TypeSystem, std::vector<llvm::GlobalVariable *> &LLVMUsed);\n  void LoadDxilTypeSystemNode(const llvm::MDTuple &MDT, DxilTypeSystem &TypeSystem);\n  void LoadDxilTypeSystem(DxilTypeSystem &TypeSystem);\n  llvm::Metadata *EmitDxilStructAnnotation(const DxilStructAnnotation &SA);\n  void LoadDxilStructAnnotation(const llvm::MDOperand &MDO, DxilStructAnnotation &SA);\n  llvm::Metadata *EmitDxilFieldAnnotation(const DxilFieldAnnotation &FA);\n  void LoadDxilFieldAnnotation(const llvm::MDOperand &MDO, DxilFieldAnnotation &FA);\n  llvm::Metadata *EmitDxilFunctionAnnotation(const DxilFunctionAnnotation &FA);\n  void LoadDxilFunctionAnnotation(const llvm::MDOperand &MDO, DxilFunctionAnnotation &FA);\n  llvm::Metadata *EmitDxilParamAnnotation(const DxilParameterAnnotation &PA);\n  void LoadDxilParamAnnotation(const llvm::MDOperand &MDO, DxilParameterAnnotation &PA);\n\n  // Control flow hints.\n  static llvm::MDNode *EmitControlFlowHints(llvm::LLVMContext &Ctx, std::vector<DXIL::ControlFlowHint> &hints);\n\n\n  // Shader specific.\n  llvm::MDTuple *EmitDxilGSState(DXIL::InputPrimitive Primitive, unsigned MaxVertexCount, \n                                 unsigned ActiveStreamMask, DXIL::PrimitiveTopology StreamPrimitiveTopology,\n                                 unsigned GSInstanceCount);\n  void LoadDxilGSState(const llvm::MDOperand &MDO, DXIL::InputPrimitive &Primitive, unsigned &MaxVertexCount, \n                       unsigned &ActiveStreamMask, DXIL::PrimitiveTopology &StreamPrimitiveTopology,\n                       unsigned &GSInstanceCount);\n\n  llvm::MDTuple *EmitDxilDSState(DXIL::TessellatorDomain Domain, unsigned InputControlPointCount);\n  void LoadDxilDSState(const llvm::MDOperand &MDO, DXIL::TessellatorDomain &Domain, unsigned &InputControlPointCount);\n\n  llvm::MDTuple *EmitDxilHSState(llvm::Function *pPatchConstantFunction,\n                                 unsigned InputControlPointCount,\n                                 unsigned OutputControlPointCount,\n                                 DXIL::TessellatorDomain TessDomain,\n                                 DXIL::TessellatorPartitioning TessPartitioning,\n                                 DXIL::TessellatorOutputPrimitive TessOutputPrimitive,\n                                 float MaxTessFactor);\n  void LoadDxilHSState(const llvm::MDOperand &MDO,\n                       llvm::Function *&pPatchConstantFunction,\n                       unsigned &InputControlPointCount,\n                       unsigned &OutputControlPointCount,\n                       DXIL::TessellatorDomain &TessDomain,\n                       DXIL::TessellatorPartitioning &TessPartitioning,\n                       DXIL::TessellatorOutputPrimitive &TessOutputPrimitive,\n                       float &MaxTessFactor);\n\n  // Utility functions.\n  static bool IsKnownNamedMetaData(llvm::NamedMDNode &Node);\n  static llvm::ConstantAsMetadata *Int32ToConstMD(int32_t v, llvm::LLVMContext &Ctx);\n  llvm::ConstantAsMetadata *Int32ToConstMD(int32_t v);\n  static llvm::ConstantAsMetadata *Uint32ToConstMD(unsigned v, llvm::LLVMContext &Ctx);\n  llvm::ConstantAsMetadata *Uint32ToConstMD(unsigned v);\n  static llvm::ConstantAsMetadata *Uint64ToConstMD(uint64_t v, llvm::LLVMContext &Ctx);\n  llvm::ConstantAsMetadata *Uint64ToConstMD(uint64_t v);\n  llvm::ConstantAsMetadata *Int8ToConstMD(int8_t v);\n  llvm::ConstantAsMetadata *Uint8ToConstMD(uint8_t v);\n  static llvm::ConstantAsMetadata *BoolToConstMD(bool v, llvm::LLVMContext &Ctx);\n  llvm::ConstantAsMetadata *BoolToConstMD(bool v);\n  llvm::ConstantAsMetadata *FloatToConstMD(float v);\n  static int32_t ConstMDToInt32(const llvm::MDOperand &MDO);\n  static unsigned ConstMDToUint32(const llvm::MDOperand &MDO);\n  static uint64_t ConstMDToUint64(const llvm::MDOperand &MDO);\n  static int8_t ConstMDToInt8(const llvm::MDOperand &MDO);\n  static uint8_t ConstMDToUint8(const llvm::MDOperand &MDO);\n  static bool ConstMDToBool(const llvm::MDOperand &MDO);\n  static float ConstMDToFloat(const llvm::MDOperand &MDO);\n  static std::string StringMDToString(const llvm::MDOperand &MDO);\n  static llvm::Value *ValueMDToValue(const llvm::MDOperand &MDO);\n  llvm::MDTuple *Uint32VectorToConstMDTuple(const std::vector<unsigned> &Vec);\n  void ConstMDTupleToUint32Vector(llvm::MDTuple *pTupleMD, std::vector<unsigned> &Vec);\n\nprivate:\n  llvm::LLVMContext &m_Ctx;\n  llvm::Module *m_pModule;\n  const ShaderModel *m_pSM;\n  std::unique_ptr<ExtraPropertyHelper> m_ExtraPropertyHelper;\n};\n\n\n/// Use this class to manipulate metadata of extra metadata record properties that are specific to DXIL.\nclass DxilExtraPropertyHelper : public DxilMDHelper::ExtraPropertyHelper {\npublic:\n  DxilExtraPropertyHelper(llvm::Module *pModule);\n\n  virtual void EmitSRVProperties(const DxilResource &SRV, std::vector<llvm::Metadata *> &MDVals);\n  virtual void LoadSRVProperties(const llvm::MDOperand &MDO, DxilResource &SRV);\n\n  virtual void EmitUAVProperties(const DxilResource &UAV, std::vector<llvm::Metadata *> &MDVals);\n  virtual void LoadUAVProperties(const llvm::MDOperand &MDO, DxilResource &UAV);\n\n  virtual void EmitCBufferProperties(const DxilCBuffer &CB, std::vector<llvm::Metadata *> &MDVals);\n  virtual void LoadCBufferProperties(const llvm::MDOperand &MDO, DxilCBuffer &CB);\n\n  virtual void EmitSamplerProperties(const DxilSampler &S, std::vector<llvm::Metadata *> &MDVals);\n  virtual void LoadSamplerProperties(const llvm::MDOperand &MDO, DxilSampler &S);\n\n  virtual void EmitSignatureElementProperties(const DxilSignatureElement &SE, std::vector<llvm::Metadata *> &MDVals);\n  virtual void LoadSignatureElementProperties(const llvm::MDOperand &MDO, DxilSignatureElement &SE);\n};\n\n} // namespace hlsl\n"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/DxilModule.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// DxilModule.h                                                              //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// The main class to work with DXIL, similar to LLVM module.                 //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n#include \"dxc/HLSL/DxilMetadataHelper.h\"\n#include \"dxc/HLSL/DxilCBuffer.h\"\n#include \"dxc/HLSL/DxilResource.h\"\n#include \"dxc/HLSL/DxilSampler.h\"\n#include \"dxc/HLSL/DxilSignature.h\"\n#include \"dxc/HLSL/DxilConstants.h\"\n#include \"dxc/HLSL/DxilTypeSystem.h\"\n#include <memory>\n#include <string>\n#include <vector>\n\nnamespace llvm {\nclass LLVMContext;\nclass Module;\nclass Function;\nclass MDTuple;\nclass MDOperand;\nclass DebugInfoFinder;\n};\n\nnamespace hlsl {\n\nclass ShaderModel;\nclass OP;\nclass RootSignatureHandle;\n\n/// Use this class to manipulate DXIL of a shader.\nclass DxilModule {\npublic:\n  DxilModule(llvm::Module *pModule);\n  ~DxilModule();\n\n  // Subsystems.\n  llvm::LLVMContext &GetCtx() const;\n  llvm::Module *GetModule() const;\n  OP *GetOP() const;\n  void SetShaderModel(const ShaderModel *pSM);\n  const ShaderModel *GetShaderModel() const;\n\n  // Entry functions.\n  llvm::Function *GetEntryFunction();\n  const llvm::Function *GetEntryFunction() const;\n  void SetEntryFunction(llvm::Function *pEntryFunc);\n  const std::string &GetEntryFunctionName() const;\n  void SetEntryFunctionName(const std::string &name);\n  llvm::Function *GetPatchConstantFunction();\n  const llvm::Function *GetPatchConstantFunction() const;\n  void SetPatchConstantFunction(llvm::Function *pFunc);\n\n  // Flags.\n  unsigned GetGlobalFlags() const;\n  // TODO: move out of DxilModule as a util.\n  void CollectShaderFlags();\n\n  // Resources.\n  unsigned AddCBuffer(std::unique_ptr<DxilCBuffer> pCB);\n  DxilCBuffer &GetCBuffer(unsigned idx);\n  const DxilCBuffer &GetCBuffer(unsigned idx) const;\n  const std::vector<std::unique_ptr<DxilCBuffer> > &GetCBuffers() const;\n\n  unsigned AddSampler(std::unique_ptr<DxilSampler> pSampler);\n  DxilSampler &GetSampler(unsigned idx);\n  const DxilSampler &GetSampler(unsigned idx) const;\n  const std::vector<std::unique_ptr<DxilSampler> > &GetSamplers() const;\n\n  unsigned AddSRV(std::unique_ptr<DxilResource> pSRV);\n  DxilResource &GetSRV(unsigned idx);\n  const DxilResource &GetSRV(unsigned idx) const;\n  const std::vector<std::unique_ptr<DxilResource> > &GetSRVs() const;\n\n  unsigned AddUAV(std::unique_ptr<DxilResource> pUAV);\n  DxilResource &GetUAV(unsigned idx);\n  const DxilResource &GetUAV(unsigned idx) const;\n  const std::vector<std::unique_ptr<DxilResource> > &GetUAVs() const;\n\n  void RemoveUnusedResources();\n  void RemoveFunction(llvm::Function *F);\n\n  // Signatures.\n  DxilSignature &GetInputSignature();\n  const DxilSignature &GetInputSignature() const;\n  DxilSignature &GetOutputSignature();\n  const DxilSignature &GetOutputSignature() const;\n  DxilSignature &GetPatchConstantSignature();\n  const DxilSignature &GetPatchConstantSignature() const;\n  const RootSignatureHandle &GetRootSignature() const;\n\n  // Remove Root Signature from module metadata\n  void StripRootSignatureFromMetadata();\n\n  // DXIL type system.\n  DxilTypeSystem &GetTypeSystem();\n\n  /// Emit llvm.used array to make sure that optimizations do not remove unreferenced globals.\n  void EmitLLVMUsed();\n  std::vector<llvm::GlobalVariable* > &GetLLVMUsed();\n\n  // DXIL metadata manipulation.\n  /// Serialize DXIL in-memory form to metadata form.\n  void EmitDxilMetadata();\n  /// Deserialize DXIL metadata form into in-memory form.\n  void LoadDxilMetadata();\n  /// Check if a Named meta data node is known by dxil module.\n  static bool IsKnownNamedMetaData(llvm::NamedMDNode &Node);\n\n  // Reset functions used to transfer ownership.\n  void ResetInputSignature(DxilSignature *pValue);\n  void ResetOutputSignature(DxilSignature *pValue);\n  void ResetPatchConstantSignature(DxilSignature *pValue);\n  void ResetRootSignature(RootSignatureHandle *pValue);\n  void ResetTypeSystem(DxilTypeSystem *pValue);\n  void ResetOP(hlsl::OP *hlslOP);\n\n  void StripDebugRelatedCode();\n  llvm::DebugInfoFinder &GetOrCreateDebugInfoFinder();\n\n  static DxilModule *TryGetDxilModule(llvm::Module *pModule);\n\npublic:\n  // Shader properties.\n  class ShaderFlags {\n  public:\n    ShaderFlags();\n\n    unsigned GetGlobalFlags() const;\n    void SetDisableOptimizations(bool flag) { m_bDisableOptimizations = flag; }\n    void SetDisableMathRefactoring(bool flag) { m_bDisableMathRefactoring = flag; }\n    void SetEnableDoublePrecision(bool flag) { m_bEnableDoublePrecision = flag; }\n    void SetForceEarlyDepthStencil(bool flag) { m_bForceEarlyDepthStencil = flag; }\n    void SetEnableRawAndStructuredBuffers(bool flag) { m_bEnableRawAndStructuredBuffers = flag; }\n    void SetEnableMinPrecision(bool flag) { m_bEnableMinPrecision = flag; }\n    void SetEnableDoubleExtensions(bool flag) { m_bEnableDoubleExtensions = flag; }\n    void SetEnableMSAD(bool flag) { m_bEnableMSAD = flag; }\n    void SetAllResourcesBound(bool flag) { m_bAllResourcesBound = flag; }\n\n    uint64_t GetFeatureInfo() const;\n    bool GetWaveOps() const { return m_bWaveOps; }\n    void SetCSRawAndStructuredViaShader4X(bool flag) { m_bCSRawAndStructuredViaShader4X = flag; }\n    void SetROVs(bool flag) { m_bROVS = flag; }\n    void SetWaveOps(bool flag) { m_bWaveOps = flag; }\n    void SetInt64Ops(bool flag) { m_bInt64Ops = flag; }\n    void SetTiledResources(bool flag) { m_bTiledResources = flag; }\n    void SetStencilRef(bool flag) { m_bStencilRef = flag; }\n    void SetInnerCoverage(bool flag) { m_bInnerCoverage = flag; }\n    void SetViewportAndRTArrayIndex(bool flag) { m_bViewportAndRTArrayIndex = flag; }\n    void SetUAVLoadAdditionalFormats(bool flag) { m_bUAVLoadAdditionalFormats = flag; }\n    void SetLevel9ComparisonFiltering(bool flag) { m_bLevel9ComparisonFiltering = flag; }\n    void Set64UAVs(bool flag) { m_b64UAVs = flag; }\n    void SetUAVsAtEveryStage(bool flag) { m_UAVsAtEveryStage = flag; }\n\n    static uint64_t GetShaderFlagsRawForCollection(); // some flags are collected (eg use 64-bit), some provided (eg allow refactoring)\n    uint64_t GetShaderFlagsRaw() const;\n    void SetShaderFlagsRaw(uint64_t data);\n\n  private:\n    unsigned m_bDisableOptimizations :1;   // D3D11_1_SB_GLOBAL_FLAG_SKIP_OPTIMIZATION\n    unsigned m_bDisableMathRefactoring :1; //~D3D10_SB_GLOBAL_FLAG_REFACTORING_ALLOWED\n    unsigned m_bEnableDoublePrecision :1; // D3D11_SB_GLOBAL_FLAG_ENABLE_DOUBLE_PRECISION_FLOAT_OPS\n    unsigned m_bForceEarlyDepthStencil :1; // D3D11_SB_GLOBAL_FLAG_FORCE_EARLY_DEPTH_STENCIL\n    unsigned m_bEnableRawAndStructuredBuffers :1; // D3D11_SB_GLOBAL_FLAG_ENABLE_RAW_AND_STRUCTURED_BUFFERS\n    unsigned m_bEnableMinPrecision :1; // D3D11_1_SB_GLOBAL_FLAG_ENABLE_MINIMUM_PRECISION\n    unsigned m_bEnableDoubleExtensions :1; // D3D11_1_SB_GLOBAL_FLAG_ENABLE_DOUBLE_EXTENSIONS\n    unsigned m_bEnableMSAD :1;        // D3D11_1_SB_GLOBAL_FLAG_ENABLE_SHADER_EXTENSIONS\n    unsigned m_bAllResourcesBound :1; // D3D12_SB_GLOBAL_FLAG_ALL_RESOURCES_BOUND\n\n    unsigned m_bViewportAndRTArrayIndex :1;   // SHADER_FEATURE_VIEWPORT_AND_RT_ARRAY_INDEX_FROM_ANY_SHADER_FEEDING_RASTERIZER\n    unsigned m_bInnerCoverage :1;             // SHADER_FEATURE_INNER_COVERAGE\n    unsigned m_bStencilRef  :1;               // SHADER_FEATURE_STENCIL_REF\n    unsigned m_bTiledResources  :1;           // SHADER_FEATURE_TILED_RESOURCES\n    unsigned m_bUAVLoadAdditionalFormats :1;  // SHADER_FEATURE_TYPED_UAV_LOAD_ADDITIONAL_FORMATS\n    unsigned m_bLevel9ComparisonFiltering :1; // SHADER_FEATURE_LEVEL_9_COMPARISON_FILTERING\n                                              // SHADER_FEATURE_11_1_SHADER_EXTENSIONS shared with EnableMSAD\n    unsigned m_b64UAVs :1;                    // SHADER_FEATURE_64_UAVS\n    unsigned m_UAVsAtEveryStage :1;           // SHADER_FEATURE_UAVS_AT_EVERY_STAGE\n    unsigned m_bCSRawAndStructuredViaShader4X : 1; // SHADER_FEATURE_COMPUTE_SHADERS_PLUS_RAW_AND_STRUCTURED_BUFFERS_VIA_SHADER_4_X\n    \n    // SHADER_FEATURE_COMPUTE_SHADERS_PLUS_RAW_AND_STRUCTURED_BUFFERS_VIA_SHADER_4_X is specifically\n    // about shader model 4.x.\n\n    unsigned m_bROVS :1;              // SHADER_FEATURE_ROVS\n    unsigned m_bWaveOps :1;           // SHADER_FEATURE_WAVE_OPS\n    unsigned m_bInt64Ops :1;          // SHADER_FEATURE_INT64_OPS\n    unsigned m_align0 :11;        // align to 32 bit.\n    uint32_t m_align1;            // align to 64 bit.\n  };\n\n  ShaderFlags m_ShaderFlags;\n  void CollectShaderFlags(ShaderFlags &Flags);\n\n  // Compute shader.\n  unsigned m_NumThreads[3];\n\n  // Geometry shader.\n  DXIL::InputPrimitive GetInputPrimitive() const;\n  void SetInputPrimitive(DXIL::InputPrimitive IP);\n  unsigned GetMaxVertexCount() const;\n  void SetMaxVertexCount(unsigned Count);\n  DXIL::PrimitiveTopology GetStreamPrimitiveTopology() const;\n  void SetStreamPrimitiveTopology(DXIL::PrimitiveTopology Topology);\n  bool HasMultipleOutputStreams() const;\n  unsigned GetOutputStream() const;\n  unsigned GetGSInstanceCount() const;\n  void SetGSInstanceCount(unsigned Count);\n  bool IsStreamActive(unsigned Stream) const;\n  void SetStreamActive(unsigned Stream, bool bActive);\n  void SetActiveStreamMask(unsigned Mask);\n  unsigned GetActiveStreamMask() const;\n\n  // Hull and Domain shaders.\n  unsigned GetInputControlPointCount() const;\n  void SetInputControlPointCount(unsigned NumICPs);\n  DXIL::TessellatorDomain GetTessellatorDomain() const;\n  void SetTessellatorDomain(DXIL::TessellatorDomain TessDomain);\n\n  // Hull shader.\n  unsigned GetOutputControlPointCount() const;\n  void SetOutputControlPointCount(unsigned NumOCPs);\n  DXIL::TessellatorPartitioning GetTessellatorPartitioning() const;\n  void SetTessellatorPartitioning(DXIL::TessellatorPartitioning TessPartitioning);\n  DXIL::TessellatorOutputPrimitive GetTessellatorOutputPrimitive() const;\n  void SetTessellatorOutputPrimitive(DXIL::TessellatorOutputPrimitive TessOutputPrimitive);\n  float GetMaxTessellationFactor() const;\n  void SetMaxTessellationFactor(float MaxTessellationFactor);\n\nprivate:\n  // Signatures.\n  std::unique_ptr<DxilSignature> m_InputSignature;\n  std::unique_ptr<DxilSignature> m_OutputSignature;\n  std::unique_ptr<DxilSignature> m_PatchConstantSignature;\n  std::unique_ptr<RootSignatureHandle> m_RootSignature;\n\n  // Shader resources.\n  std::vector<std::unique_ptr<DxilResource> > m_SRVs;\n  std::vector<std::unique_ptr<DxilResource> > m_UAVs;\n  std::vector<std::unique_ptr<DxilCBuffer> > m_CBuffers;\n  std::vector<std::unique_ptr<DxilSampler> > m_Samplers;\n\n  // Geometry shader.\n  DXIL::InputPrimitive m_InputPrimitive;\n  unsigned m_MaxVertexCount;\n  DXIL::PrimitiveTopology m_StreamPrimitiveTopology;\n  unsigned m_ActiveStreamMask;\n  unsigned m_NumGSInstances;\n\n  // Hull and Domain shaders.\n  unsigned m_InputControlPointCount;\n  DXIL::TessellatorDomain m_TessellatorDomain;\n\n  // Hull shader.\n  unsigned m_OutputControlPointCount;\n  DXIL::TessellatorPartitioning m_TessellatorPartitioning;\n  DXIL::TessellatorOutputPrimitive m_TessellatorOutputPrimitive;\n  float m_MaxTessellationFactor;\n\nprivate:\n  llvm::LLVMContext &m_Ctx;\n  llvm::Module *m_pModule;\n  llvm::Function *m_pEntryFunc;\n  llvm::Function *m_pPatchConstantFunc;\n  std::string m_EntryName;\n  std::unique_ptr<DxilMDHelper> m_pMDHelper;\n  std::unique_ptr<llvm::DebugInfoFinder> m_pDebugInfoFinder;\n  const ShaderModel *m_pSM;\n  unsigned m_DxilMajor;\n  unsigned m_DxilMinor;\n\n  std::unique_ptr<OP> m_pOP;\n  size_t m_pUnused;\n\n  // LLVM used.\n  std::vector<llvm::GlobalVariable*> m_LLVMUsed;\n\n  // Type annotations.\n  std::unique_ptr<DxilTypeSystem> m_pTypeSystem;\n\n  // DXIL metadata serialization/deserialization.\n  llvm::MDTuple *EmitDxilResources();\n  void LoadDxilResources(const llvm::MDOperand &MDO);\n  llvm::MDTuple *EmitDxilShaderProperties();\n  void LoadDxilShaderProperties(const llvm::MDOperand &MDO);\n\n  // Helpers.\n  template<typename T> unsigned AddResource(std::vector<std::unique_ptr<T> > &Vec, std::unique_ptr<T> pRes);\n  void LoadDxilSignature(const llvm::MDTuple *pSigTuple, DxilSignature &Sig, bool bInput);\n};\n\n} // namespace hlsl\n"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/DxilOperations.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// DxilOperations.h                                                          //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Implementation of DXIL operation tables.                                  //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\nnamespace llvm {\nclass LLVMContext;\nclass Module;\nclass Type;\nclass Function;\nclass Constant;\nclass Value;\nclass Instruction;\n};\n#include \"llvm/IR/Attributes.h\"\n\n#include \"DxilConstants.h\"\n#include <unordered_map>\n\nnamespace hlsl {\n\n/// Use this utility class to interact with DXIL operations.\nclass OP {\npublic:\n  using OpCode = DXIL::OpCode;\n  using OpCodeClass = DXIL::OpCodeClass;\n\npublic:\n  OP() = delete;\n  OP(llvm::LLVMContext &Ctx, llvm::Module *pModule);\n\n  llvm::Function *GetOpFunc(OpCode OpCode, llvm::Type *pOverloadType);\n  llvm::ArrayRef<llvm::Function *> GetOpFuncList(OpCode OpCode) const;\n  void RemoveFunction(llvm::Function *F);\n  llvm::Type *GetOverloadType(OpCode OpCode, llvm::Function *F);\n  llvm::LLVMContext &GetCtx() { return m_Ctx; }\n  llvm::Type *GetHandleType() const;\n  llvm::Type *GetDimensionsType() const;\n  llvm::Type *GetSamplePosType() const;\n  llvm::Type *GetBinaryWithCarryType() const;\n  llvm::Type *GetBinaryWithTwoOutputsType() const;\n  llvm::Type *GetSplitDoubleType() const;\n  llvm::Type *GetInt4Type() const;\n\n  llvm::Type *GetResRetType(llvm::Type *pOverloadType);\n  llvm::Type *GetCBufferRetType(llvm::Type *pOverloadType);\n\n  // LLVM helpers. Perhaps, move to a separate utility class.\n  llvm::Constant *GetI1Const(bool v);\n  llvm::Constant *GetI8Const(char v);\n  llvm::Constant *GetU8Const(unsigned char v);\n  llvm::Constant *GetI16Const(int v);\n  llvm::Constant *GetU16Const(unsigned v);\n  llvm::Constant *GetI32Const(int v);\n  llvm::Constant *GetU32Const(unsigned v);\n  llvm::Constant *GetU64Const(unsigned long long v);\n  llvm::Constant *GetFloatConst(float v);\n  llvm::Constant *GetDoubleConst(double v);\n\n  static OpCode GetDxilOpFuncCallInst(const llvm::Instruction *I);\n  static const char *GetOpCodeName(OpCode OpCode);\n  static const char *GetAtomicOpName(DXIL::AtomicBinOpCode OpCode);\n  static const OpCodeClass GetOpCodeClass(OpCode OpCode);\n  static const char *GetOpCodeClassName(OpCode OpCode);\n  static bool IsOverloadLegal(OpCode OpCode, llvm::Type *pType);\n  static bool CheckOpCodeTable();\n  static bool IsDxilOpFunc(const llvm::Function *F);\n  static bool IsDxilOpFuncCallInst(const llvm::Instruction *I);\n  static bool IsDxilOpFuncCallInst(const llvm::Instruction *I, OpCode opcode);\n  static bool IsDxilOpWave(OpCode C);\n  static bool IsDxilOpGradient(OpCode C);\n\nprivate:\n  // Per-module properties.\n  llvm::LLVMContext &m_Ctx;\n  llvm::Module *m_pModule;\n\n  llvm::Type *m_pHandleType;\n  llvm::Type *m_pDimensionsType;\n  llvm::Type *m_pSamplePosType;\n  llvm::Type *m_pBinaryWithCarryType;\n  llvm::Type *m_pBinaryWithTwoOutputsType;\n  llvm::Type *m_pSplitDoubleType;\n  llvm::Type *m_pInt4Type;\n\n  static const unsigned kNumTypeOverloads = 9;\n\n  llvm::Type *m_pResRetType[kNumTypeOverloads];\n  llvm::Type *m_pCBufferRetType[kNumTypeOverloads];\n\n  struct OpCodeCacheItem {\n    llvm::Function *pOverloads[kNumTypeOverloads];\n  };\n  OpCodeCacheItem m_OpCodeClassCache[(unsigned)OpCodeClass::NumOpClasses];\n  std::unordered_map<llvm::Function *, OpCodeClass> m_FunctionToOpClass;\n  void RefreshCache(llvm::Module *pModule);\nprivate:\n  // Static properties.\n  struct OpCodeProperty {\n    OpCode OpCode;\n    const char *pOpCodeName;\n    OpCodeClass OpCodeClass;\n    const char *pOpCodeClassName;\n    bool bAllowOverload[kNumTypeOverloads];   // void, h,f,d, i1, i8,i16,i32,i64\n    llvm::Attribute::AttrKind FuncAttr;\n  };\n  static const OpCodeProperty m_OpCodeProps[(unsigned)OpCode::NumOpCodes];\n\n  static const char *m_OverloadTypeName[kNumTypeOverloads];\n  static const char *m_NamePrefix;\n  static unsigned GetTypeSlot(llvm::Type *pType);\n  static const char *GetOverloadTypeName(unsigned TypeSlot);\n};\n\n} // namespace hlsl\n"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/DxilPipelineStateValidation.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// DxilPipelineStateValidation.h                                             //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Defines data used by the D3D runtime for PSO validation.                  //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#ifndef __DXIL_PIPELINE_STATE_VALIDATION__H__\n#define __DXIL_PIPELINE_STATE_VALIDATION__H__\n\n#include <stdint.h>\n#include <string.h>\n\n// Versioning is additive and based on size\nstruct PSVRuntimeInfo0\n{\n  union {\n    struct VSInfo {\n      char OutputPositionPresent;\n    } VS;\n    struct HSInfo {\n      uint32_t InputControlPointCount;      // max control points == 32\n      uint32_t OutputControlPointCount;     // max control points == 32\n      uint32_t TessellatorDomain;           // hlsl::DXIL::TessellatorDomain/D3D11_SB_TESSELLATOR_DOMAIN\n      uint32_t TessellatorOutputPrimitive;  // hlsl::DXIL::TessellatorOutputPrimitive/D3D11_SB_TESSELLATOR_OUTPUT_PRIMITIVE\n    } HS;\n    struct DSInfo {\n      uint32_t InputControlPointCount;      // max control points == 32\n      char OutputPositionPresent;\n      uint32_t TessellatorDomain;           // hlsl::DXIL::TessellatorDomain/D3D11_SB_TESSELLATOR_DOMAIN\n    } DS;\n    struct GSInfo {\n      uint32_t InputPrimitive;              // hlsl::DXIL::InputPrimitive/D3D10_SB_PRIMITIVE\n      uint32_t OutputTopology;              // hlsl::DXIL::PrimitiveTopology/D3D10_SB_PRIMITIVE_TOPOLOGY\n      uint32_t OutputStreamMask;            // max streams == 4\n      char OutputPositionPresent;\n    } GS;\n    struct PSInfo {\n      char DepthOutput;\n      char SampleFrequency;\n    } PS;\n  };\n  uint32_t MinimumExpectedWaveLaneCount;  // minimum lane count required, 0 if unused\n  uint32_t MaximumExpectedWaveLaneCount;  // maximum lane count required, 0xffffffff if unused\n};\n// PSVRuntimeInfo1 would derive and extend\n\nenum class PSVResourceType\n{\n  Invalid = 0,\n\n  Sampler,\n  CBV,\n  SRVTyped,\n  SRVRaw,\n  SRVStructured,\n  UAVTyped,\n  UAVRaw,\n  UAVStructured,\n  UAVStructuredWithCounter,\n\n  NumEntries\n};\n\n// Versioning is additive and based on size\nstruct PSVResourceBindInfo0\n{\n  uint32_t ResType;     // PSVResourceType\n  uint32_t Space;\n  uint32_t LowerBound;\n  uint32_t UpperBound;\n};\n// PSVResourceBindInfo1 would derive and extend\n\nclass DxilPipelineStateValidation\n{\n  uint32_t m_uPSVRuntimeInfoSize;\n  PSVRuntimeInfo0* m_pPSVRuntimeInfo0;\n  uint32_t m_uResourceCount;\n  uint32_t m_uPSVResourceBindInfoSize;\n  void* m_pPSVResourceBindInfo;\n  uint32_t m_uSize;\n\npublic:\n  DxilPipelineStateValidation() : \n    m_uPSVRuntimeInfoSize(0),\n    m_pPSVRuntimeInfo0(nullptr),\n    m_uResourceCount(0),\n    m_uPSVResourceBindInfoSize(0),\n    m_pPSVResourceBindInfo(nullptr)\n  {\n  }\n\n  // Init() from PSV0 blob part that looks like:\n  // uint32_t PSVRuntimeInfo_size\n  // { PSVRuntimeInfoN structure }\n  // uint32_t ResourceCount\n  // ---  end of blob if ResourceCount == 0  ---\n  // uint32_t PSVResourceBindInfo_size\n  // { PSVResourceBindInfoN structure } * ResourceCount\n  // returns true if no errors occurred.\n  bool InitFromPSV0(const void* pBits, uint32_t size) {\n    if(!(pBits != nullptr)) return false;\n    const uint8_t* pCurBits = (uint8_t*)pBits;\n    uint32_t minsize = sizeof(PSVRuntimeInfo0) + sizeof(uint32_t) * 2;\n    if(!(size >= minsize)) return false;\n    m_uPSVRuntimeInfoSize = *((const uint32_t*)pCurBits);\n    if(!(m_uPSVRuntimeInfoSize >= sizeof(PSVRuntimeInfo0))) return false;\n    pCurBits += sizeof(uint32_t);\n    minsize = m_uPSVRuntimeInfoSize + sizeof(uint32_t) * 2;\n    if(!(size >= minsize)) return false;\n    m_pPSVRuntimeInfo0 = const_cast<PSVRuntimeInfo0*>((const PSVRuntimeInfo0*)pCurBits);\n    pCurBits += m_uPSVRuntimeInfoSize;\n    m_uResourceCount = *(const uint32_t*)pCurBits;\n    pCurBits += sizeof(uint32_t);\n    if (m_uResourceCount > 0) {\n      minsize += sizeof(uint32_t);\n      if(!(size >= minsize)) return false;\n      m_uPSVResourceBindInfoSize = *(const uint32_t*)pCurBits;\n      pCurBits += sizeof(uint32_t);\n      minsize += m_uPSVResourceBindInfoSize * m_uResourceCount;\n      if(!(m_uPSVResourceBindInfoSize >= sizeof(PSVResourceBindInfo0))) return false;\n      if(!(size >= minsize)) return false;\n      m_pPSVResourceBindInfo = static_cast<void*>(const_cast<uint8_t*>(pCurBits));\n    }\n    return true;\n  }\n\n  // Initialize a new buffer\n  // call with null pBuffer to get required size\n  bool InitNew(uint32_t ResourceCount, void *pBuffer, uint32_t *pSize) {\n    if(!(pSize)) return false;\n    uint32_t size = sizeof(PSVRuntimeInfo0) + sizeof(uint32_t) * 2;\n    if (ResourceCount) {\n      size += sizeof(uint32_t) + (sizeof(PSVResourceBindInfo0) * ResourceCount);\n    }\n    if (pBuffer) {\n      if(!(*pSize >= size)) return false;\n    } else {\n      *pSize = size;\n      return true;\n    }\n    memset(pBuffer, 0, size);\n    m_uPSVRuntimeInfoSize = sizeof(PSVRuntimeInfo0);\n    uint8_t* pCurBits = (uint8_t*)pBuffer;\n    *(uint32_t*)pCurBits = sizeof(PSVRuntimeInfo0);\n    pCurBits += sizeof(uint32_t);\n    m_pPSVRuntimeInfo0 = (PSVRuntimeInfo0*)pCurBits;\n    pCurBits += sizeof(PSVRuntimeInfo0);\n\n    // Set resource info:\n    m_uResourceCount = ResourceCount;\n    *(uint32_t*)pCurBits = ResourceCount;\n    pCurBits += sizeof(uint32_t);\n    if (ResourceCount > 0) {\n      m_uPSVResourceBindInfoSize = sizeof(PSVResourceBindInfo0);\n      *(uint32_t*)pCurBits = m_uPSVResourceBindInfoSize;\n      pCurBits += sizeof(uint32_t);\n      m_pPSVResourceBindInfo = pCurBits;\n    }\n    return true;\n  }\n\n  PSVRuntimeInfo0* GetPSVRuntimeInfo0() {\n    return m_pPSVRuntimeInfo0;\n  }\n\n  uint32_t GetBindCount() const {\n    return m_uResourceCount;\n  }\n\n  PSVResourceBindInfo0* GetPSVResourceBindInfo0(uint32_t index) {\n    if (index < m_uResourceCount && m_pPSVResourceBindInfo &&\n        sizeof(PSVResourceBindInfo0) <= m_uPSVResourceBindInfoSize) {\n      return (PSVResourceBindInfo0*)((uint8_t*)m_pPSVResourceBindInfo +\n        (index * m_uPSVResourceBindInfoSize));\n    }\n    return nullptr;\n  }\n};\n\n\n#endif  // __DXIL_PIPELINE_STATE_VALIDATION__H__\n"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/DxilResource.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// DxilResource.h                                                            //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Representation of HLSL SRVs and UAVs.                                     //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n#include \"DxilConstants.h\"\n#include \"dxc/HLSL/DxilResourceBase.h\"\n#include \"dxc/HLSL/DxilCompType.h\"\n\n\nnamespace hlsl {\n\n/// Use this class to represent an HLSL resource (SRV/UAV).\nclass DxilResource : public DxilResourceBase {\npublic:\n  /// Total number of coordinates necessary to access resource.\n  static unsigned GetNumCoords(Kind ResourceKind);\n  /// Total number of resource dimensions (Only width and height for cube).\n  static unsigned GetNumDimensions(Kind ResourceKind);\n  /// Total number of resource dimensions for CalcLOD (no array).\n  static unsigned GetNumDimensionsForCalcLOD(Kind ResourceKind);\n  /// Total number of offsets (in [-8,7]) necessary to access resource.\n  static unsigned GetNumOffsets(Kind ResourceKind);\n\n  DxilResource();\n\n  CompType GetCompType() const;\n  void SetCompType(const CompType CT);\n\n  llvm::Type *GetRetType() const;\n\n  unsigned GetSampleCount() const;\n  void SetSampleCount(unsigned SampleCount);\n\n  unsigned GetElementStride() const;\n  void SetElementStride(unsigned ElemStride);\n\n  bool IsGloballyCoherent() const;\n  void SetGloballyCoherent(bool b);\n  bool HasCounter() const;\n  void SetHasCounter(bool b);\n\n  bool IsRO() const;\n  bool IsRW() const;\n  void SetRW(bool bRW);\n  bool IsROV() const;\n  void SetROV(bool bROV);\n\n  bool IsAnyTexture() const;\n  bool IsStructuredBuffer() const;\n  bool IsTypedBuffer() const;\n  bool IsRawBuffer() const;\n  bool IsTBuffer() const;\n\nprivate:\n  unsigned m_SampleCount;\n  unsigned m_ElementStride; // in bytes\n  CompType m_CompType;\n  bool m_bGloballyCoherent;\n  bool m_bHasCounter;\n  bool m_bROV;\n};\n\n} // namespace hlsl\n"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/DxilResourceBase.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// DxilResourceBase.h                                                        //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Base class to represent DXIL SRVs, UAVs, CBuffers, and Samplers.          //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n#include <string>\n\n#include \"DxilConstants.h\"\n\nnamespace llvm {\nclass Value;\nclass Constant;\n};\n\n\nnamespace hlsl {\n\n/// Base class to represent HLSL SRVs, UAVs, CBuffers, and Samplers.\nclass DxilResourceBase {\npublic:\n  using Class = DXIL::ResourceClass;\n  using Kind = DXIL::ResourceKind;\n\npublic:\n  DxilResourceBase(Class C);\n  virtual ~DxilResourceBase() {}\n\n  Class GetClass() const;\n  DxilResourceBase::Kind GetKind() const;\n  unsigned GetID() const;\n  unsigned GetSpaceID() const;\n  unsigned GetLowerBound() const;\n  unsigned GetUpperBound() const;\n  unsigned GetRangeSize() const;\n  llvm::Constant *GetGlobalSymbol() const;\n  const std::string &GetGlobalName() const;\n  llvm::Value *GetHandle() const;\n  bool IsAllocated() const;\n  bool IsUnbounded() const;\n\n  void SetKind(DxilResourceBase::Kind ResourceKind);\n  void SetSpaceID(unsigned SpaceID);\n  void SetLowerBound(unsigned LB);\n  void SetRangeSize(unsigned RangeSize);\n  void SetGlobalSymbol(llvm::Constant *pGV);\n  void SetGlobalName(const std::string &Name);\n  void SetHandle(llvm::Value *pHandle);\n\n  // TODO: check whether we can make this a protected method.\n  void SetID(unsigned ID);\n\n  const char *DxilResourceBase::GetResClassName() const;\n  const char *DxilResourceBase::GetResDimName() const;\n  const char *DxilResourceBase::GetResIDPrefix() const;\n  const char *DxilResourceBase::GetResBindPrefix() const;\n\nprotected:\n  void SetClass(Class C);\n\nprivate:\n  Class m_Class;                  // Resource class (SRV, UAV, CBuffer, Sampler).\n  Kind m_Kind;                    // Detail resource kind( texture2D...).\n  unsigned m_ID;                  // Unique ID within the class.\n  unsigned m_SpaceID;             // Root signature space.\n  unsigned m_LowerBound;          // Range lower bound.\n  unsigned m_RangeSize;           // Range size in entries.\n  llvm::Constant *m_pSymbol;      // Global variable.\n  std::string m_Name;             // Unmangled name of the global variable.\n  llvm::Value *m_pHandle;         // Cached resource handle for SM5.0- (and maybe SM5.1).\n};\n\n} // namespace hlsl\n"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/DxilRootSignature.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// DxilRootSignature.h                                                       //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// HLSL root signature parsing.                                              //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n#ifndef __DXC_ROOTSIGNATURE__\n#define __DXC_ROOTSIGNATURE__\n\n#include <stdint.h>\n\nstruct IDxcBlob;\nstruct IDxcBlobEncoding;\n\nnamespace llvm {\n  class raw_ostream;\n}\n\nnamespace hlsl {\n\n// Forward declarations.\nstruct DxilDescriptorRange;\nstruct DxilDescriptorRange1;\nstruct DxilRootConstants;\nstruct DxilRootDescriptor;\nstruct DxilRootDescriptor1;\nstruct DxilRootDescriptorTable;\nstruct DxilRootDescriptorTable1;\nstruct DxilRootParameter;\nstruct DxilRootParameter1;\nstruct DxilRootSignatureDesc;\nstruct DxilRootSignatureDesc1;\nstruct DxilStaticSamplerDesc;\nstruct DxilVersionedRootSignatureDesc;\n\n// Constant values.\nstatic const uint32_t DxilDescriptorRangeOffsetAppend = 0xffffffff;\nstatic const uint32_t DxilSystemReservedRegisterSpaceValuesStart = 0xfffffff0;\nstatic const uint32_t DxilSystemReservedRegisterSpaceValuesEnd = 0xffffffff;\n#define DxilMipLodBiaxMax ( 15.99f )\n#define DxilMipLodBiaxMin ( -16.0f )\n#define DxilFloat32Max ( 3.402823466e+38f )\nstatic const uint32_t DxilMipLodFractionalBitCount = 8;\nstatic const uint32_t DxilMapAnisotropy = 16;\n\n// Enumerations and flags.\nenum class DxilComparisonFunc : unsigned{\n  Never = 1,\n  Less = 2,\n  Equal = 3,\n  LessEqual = 4,\n  Greater = 5,\n  NotEqual = 6,\n  GreaterEqual = 7,\n  Always = 8\n};\nenum class DxilDescriptorRangeFlags : unsigned {\n  None = 0,\n  DescriptorsVolatile = 0x1,\n  DataVolatile = 0x2,\n  DataStaticWhileSetAtExecute = 0x4,\n  DataStatic = 0x8,\n  ValidFlags = 0xf,\n  ValidSamplerFlags = DescriptorsVolatile\n};\nenum class DxilDescriptorRangeType : unsigned {\n  SRV = 0,\n  UAV = 1,\n  CBV = 2,\n  Sampler = 3\n};\nenum class DxilRootDescriptorFlags : unsigned {\n  None = 0,\n  DataVolatile = 0x2,\n  DataStaticWhileSetAtExecute = 0x4,\n  DataStatic = 0x8,\n  ValidFlags = 0xe\n};\nenum class DxilRootSignatureVersion {\n  Version_1 = 1,\n  Version_1_0 = 1,\n  Version_1_1 = 2\n};\nenum class DxilRootSignatureFlags : uint32_t {\n  None = 0,\n  AllowInputAssemblerInputLayout = 0x1,\n  DenyVertexShaderRootAccess = 0x2,\n  DenyHullShaderRootAccess = 0x4,\n  DenyDomainShaderRootAccess = 0x8,\n  DenyGeometryShaderRootAccess = 0x10,\n  DenyPixelShaderRootAccess = 0x20,\n  AllowStreamOutput = 0x40,\n  AllowLowTierReservedHwCbLimit = 0x80000000,\n  ValidFlags = 0x8000007f\n};\nenum class DxilRootParameterType {\n  DescriptorTable = 0,\n  Constants32Bit = 1,\n  CBV = 2,\n  SRV = 3,\n  UAV = 4\n};\nenum class DxilFilter {\n  // TODO: make these names consistent with code convention\n  MIN_MAG_MIP_POINT = 0,\n  MIN_MAG_POINT_MIP_LINEAR = 0x1,\n  MIN_POINT_MAG_LINEAR_MIP_POINT = 0x4,\n  MIN_POINT_MAG_MIP_LINEAR = 0x5,\n  MIN_LINEAR_MAG_MIP_POINT = 0x10,\n  MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x11,\n  MIN_MAG_LINEAR_MIP_POINT = 0x14,\n  MIN_MAG_MIP_LINEAR = 0x15,\n  ANISOTROPIC = 0x55,\n  COMPARISON_MIN_MAG_MIP_POINT = 0x80,\n  COMPARISON_MIN_MAG_POINT_MIP_LINEAR = 0x81,\n  COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x84,\n  COMPARISON_MIN_POINT_MAG_MIP_LINEAR = 0x85,\n  COMPARISON_MIN_LINEAR_MAG_MIP_POINT = 0x90,\n  COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x91,\n  COMPARISON_MIN_MAG_LINEAR_MIP_POINT = 0x94,\n  COMPARISON_MIN_MAG_MIP_LINEAR = 0x95,\n  COMPARISON_ANISOTROPIC = 0xd5,\n  MINIMUM_MIN_MAG_MIP_POINT = 0x100,\n  MINIMUM_MIN_MAG_POINT_MIP_LINEAR = 0x101,\n  MINIMUM_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x104,\n  MINIMUM_MIN_POINT_MAG_MIP_LINEAR = 0x105,\n  MINIMUM_MIN_LINEAR_MAG_MIP_POINT = 0x110,\n  MINIMUM_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x111,\n  MINIMUM_MIN_MAG_LINEAR_MIP_POINT = 0x114,\n  MINIMUM_MIN_MAG_MIP_LINEAR = 0x115,\n  MINIMUM_ANISOTROPIC = 0x155,\n  MAXIMUM_MIN_MAG_MIP_POINT = 0x180,\n  MAXIMUM_MIN_MAG_POINT_MIP_LINEAR = 0x181,\n  MAXIMUM_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x184,\n  MAXIMUM_MIN_POINT_MAG_MIP_LINEAR = 0x185,\n  MAXIMUM_MIN_LINEAR_MAG_MIP_POINT = 0x190,\n  MAXIMUM_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x191,\n  MAXIMUM_MIN_MAG_LINEAR_MIP_POINT = 0x194,\n  MAXIMUM_MIN_MAG_MIP_LINEAR = 0x195,\n  MAXIMUM_ANISOTROPIC = 0x1d5\n};\nenum class DxilShaderVisibility {\n  All = 0,\n  Vertex = 1,\n  Hull = 2,\n  Domain = 3,\n  Geometry = 4,\n  Pixel = 5\n};\nenum class DxilStaticBorderColor {\n  TransparentBlack = 0,\n  OpaqueBlack = 1,\n  OpaqueWhite = 2\n};\nenum class DxilTextureAddressMode {\n  Wrap = 1,\n  Mirror = 2,\n  Clamp = 3,\n  Border = 4,\n  MirrorOnce = 5\n};\n\n// Structure definitions for serialized structures.\n#pragma pack(push, 1)\nstruct DxilContainerRootDescriptor1\n{\n  uint32_t ShaderRegister;\n  uint32_t RegisterSpace;\n  uint32_t Flags;\n};\nstruct DxilContainerDescriptorRange\n{\n  uint32_t RangeType;\n  uint32_t NumDescriptors;\n  uint32_t BaseShaderRegister;\n  uint32_t RegisterSpace;\n  uint32_t OffsetInDescriptorsFromTableStart;\n};\nstruct DxilContainerDescriptorRange1\n{\n  uint32_t RangeType;\n  uint32_t NumDescriptors;\n  uint32_t BaseShaderRegister;\n  uint32_t RegisterSpace;\n  uint32_t Flags;\n  uint32_t OffsetInDescriptorsFromTableStart;\n};\nstruct DxilContainerRootDescriptorTable\n{\n  uint32_t NumDescriptorRanges;\n  uint32_t DescriptorRangesOffset;\n};\nstruct DxilContainerRootParameter\n{\n  uint32_t ParameterType;\n  uint32_t ShaderVisibility;\n  uint32_t PayloadOffset;\n};\nstruct DxilContainerRootSignatureDesc\n{\n  uint32_t Version;\n  uint32_t NumParameters;\n  uint32_t RootParametersOffset;\n  uint32_t NumStaticSamplers;\n  uint32_t StaticSamplersOffset;\n  uint32_t Flags;\n};\n#pragma pack(pop)\n\n// Structure definitions for in-memory structures.\nstruct DxilDescriptorRange {\n  DxilDescriptorRangeType RangeType;\n  uint32_t NumDescriptors;\n  uint32_t BaseShaderRegister;\n  uint32_t RegisterSpace;\n  uint32_t OffsetInDescriptorsFromTableStart;\n};\nstruct DxilRootDescriptorTable {\n  uint32_t NumDescriptorRanges;\n  _Field_size_full_(NumDescriptorRanges)  const DxilDescriptorRange *pDescriptorRanges;\n};\nstruct DxilRootConstants {\n  uint32_t ShaderRegister;\n  uint32_t RegisterSpace;\n  uint32_t Num32BitValues;\n};\nstruct DxilRootDescriptor {\n  uint32_t ShaderRegister;\n  uint32_t RegisterSpace;\n};\nstruct DxilRootDescriptor1 {\n  uint32_t ShaderRegister;\n  uint32_t RegisterSpace;\n  DxilRootDescriptorFlags Flags;\n};\nstruct DxilRootParameter {\n  DxilRootParameterType ParameterType;\n  union {\n    DxilRootDescriptorTable DescriptorTable;\n    DxilRootConstants Constants;\n    DxilRootDescriptor Descriptor;\n  };\n  DxilShaderVisibility ShaderVisibility;\n};\nstruct DxilDescriptorRange1 {\n  DxilDescriptorRangeType RangeType;\n  uint32_t NumDescriptors;\n  uint32_t BaseShaderRegister;\n  uint32_t RegisterSpace;\n  DxilDescriptorRangeFlags Flags;\n  uint32_t OffsetInDescriptorsFromTableStart;\n};\nstruct DxilRootDescriptorTable1 {\n  uint32_t NumDescriptorRanges;\n  _Field_size_full_(NumDescriptorRanges)  const DxilDescriptorRange1 *pDescriptorRanges;\n};\nstruct DxilRootParameter1 {\n  DxilRootParameterType ParameterType;\n  union {\n    DxilRootDescriptorTable1 DescriptorTable;\n    DxilRootConstants Constants;\n    DxilRootDescriptor1 Descriptor;\n  };\n  DxilShaderVisibility ShaderVisibility;\n};\nstruct DxilRootSignatureDesc {\n  uint32_t NumParameters;\n  _Field_size_full_(NumParameters) const DxilRootParameter *pParameters;\n  uint32_t NumStaticSamplers;\n  _Field_size_full_(NumStaticSamplers) const DxilStaticSamplerDesc *pStaticSamplers;\n  DxilRootSignatureFlags Flags;\n};\nstruct DxilStaticSamplerDesc {\n  DxilFilter Filter;\n  DxilTextureAddressMode AddressU;\n  DxilTextureAddressMode AddressV;\n  DxilTextureAddressMode AddressW;\n  float MipLODBias;\n  uint32_t MaxAnisotropy;\n  DxilComparisonFunc ComparisonFunc;\n  DxilStaticBorderColor BorderColor;\n  float MinLOD;\n  float MaxLOD;\n  uint32_t ShaderRegister;\n  uint32_t RegisterSpace;\n  DxilShaderVisibility ShaderVisibility;\n};\nstruct DxilRootSignatureDesc1 {\n  uint32_t NumParameters;\n  _Field_size_full_(NumParameters) const DxilRootParameter1 *pParameters;\n  uint32_t NumStaticSamplers;\n  _Field_size_full_(NumStaticSamplers) const DxilStaticSamplerDesc *pStaticSamplers;\n  DxilRootSignatureFlags Flags;\n};\nstruct DxilVersionedRootSignatureDesc {\n  DxilRootSignatureVersion Version;\n  union {\n    DxilRootSignatureDesc Desc_1_0;\n    DxilRootSignatureDesc1 Desc_1_1;\n  };\n};\n\n// Use this class to represent a root signature that may be in memory or serialized.\n// There is just enough API surface to help callers not take a dependency on Windows headers.\nclass RootSignatureHandle {\nprivate:\n  const DxilVersionedRootSignatureDesc *m_pDesc;\n  IDxcBlob *m_pSerialized;\npublic:\n  RootSignatureHandle() : m_pDesc(nullptr), m_pSerialized(nullptr) {}\n  RootSignatureHandle(const RootSignatureHandle &) = delete;\n  RootSignatureHandle(RootSignatureHandle &&other);\n  ~RootSignatureHandle() { Clear(); }\n\n  bool IsEmpty() const {\n    return m_pDesc == nullptr && m_pSerialized == nullptr;\n  }\n  IDxcBlob *GetSerialized() const { return m_pSerialized; }\n  const uint8_t *GetSerializedBytes() const;\n  unsigned GetSerializedSize() const;\n\n  void Assign(const DxilVersionedRootSignatureDesc *pDesc, IDxcBlob *pSerialized);\n  void Clear();\n  void LoadSerialized(const uint8_t *pData, uint32_t length);\n  void EnsureSerializedAvailable();\n  void Deserialize();\n\n  const DxilVersionedRootSignatureDesc *GetDesc() const { return m_pDesc; }\n};\n\nvoid DeleteRootSignature(const DxilVersionedRootSignatureDesc *pRootSignature);  \n\n// Careful to delete: returns the original root signature, if conversion is not required.  \nvoid ConvertRootSignature(const DxilVersionedRootSignatureDesc* pRootSignatureIn,\n                          DxilRootSignatureVersion RootSignatureVersionOut,  \n                          const DxilVersionedRootSignatureDesc ** ppRootSignatureOut);\n\nvoid SerializeRootSignature(const DxilVersionedRootSignatureDesc *pRootSignature,\n                            _Outptr_ IDxcBlob **ppBlob, _Outptr_ IDxcBlobEncoding **ppErrorBlob,\n                            bool bAllowReservedRegisterSpace);\n\nvoid DeserializeRootSignature(__in_bcount(SrcDataSizeInBytes) const void *pSrcData,\n                              __in uint32_t SrcDataSizeInBytes,\n                              __out const DxilVersionedRootSignatureDesc **ppRootSignature);\n\n// Takes PSV - pipeline state validation data, not shader container.\nbool VerifyRootSignatureWithShaderPSV(__in const DxilVersionedRootSignatureDesc *pDesc,\n                                      __in DXIL::ShaderKind ShaderKind,\n                                      _In_reads_bytes_(PSVSize) const void *pPSVData,\n                                      __in uint32_t PSVSize,\n                                      __in llvm::raw_ostream &DiagStream);\n\n} // namespace hlsl\n\n#endif // __DXC_ROOTSIGNATURE__\n"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/DxilSampler.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// DxilSampler.h                                                             //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Representation of HLSL sampler state.                                     //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n#include \"dxc/HLSL/DxilResourceBase.h\"\n\nnamespace hlsl {\n\n/// Use this class to represent HLSL sampler state.\nclass DxilSampler : public DxilResourceBase {\npublic:\n  using SamplerKind = DXIL::SamplerKind;\n\n  DxilSampler();\n\n  SamplerKind GetSamplerKind() const;\n  bool IsCompSampler() const;\n\n  void SetSamplerKind(SamplerKind K);\n\nprivate:\n  SamplerKind m_SamplerKind;      // Sampler mode.\n};\n\n} // namespace hlsl\n"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/DxilSemantic.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// DxilSemantic.h                                                            //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Representation of HLSL parameter semantics.                               //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n#include \"llvm/ADT/StringRef.h\"\n\n#include \"DxilConstants.h\"\n#include \"DxilShaderModel.h\"\n\nnamespace hlsl {\n\n/// Use this class to represent HLSL parameter semantic.\nclass Semantic {\npublic:\n  using Kind = DXIL::SemanticKind;\n\n  static const int kUndefinedRow = -1;\n  static const int kUndefinedCol = -1;\n\n  static const Semantic *GetByName(llvm::StringRef name);\n  static const Semantic *GetByName(llvm::StringRef Name, DXIL::SigPointKind sigPointKind,\n    unsigned MajorVersion = ShaderModel::kHighestMajor, unsigned MinorVersion = ShaderModel::kHighestMinor);\n  static const Semantic *Get(Kind kind);\n  static const Semantic *Get(Kind kind, DXIL::SigPointKind sigPointKind,\n    unsigned MajorVersion = ShaderModel::kHighestMajor, unsigned MinorVersion = ShaderModel::kHighestMinor);\n  static const Semantic *GetInvalid();\n  static const Semantic *GetArbitrary();\n  static bool Semantic::HasSVPrefix(llvm::StringRef Name);\n  static void DecomposeNameAndIndex(llvm::StringRef FullName, llvm::StringRef *pName, unsigned *pIndex);\n\n  Kind GetKind() const;\n  const char *GetName() const;\n  bool IsArbitrary() const;\n  bool IsInvalid() const;\n\nprivate:\n  Kind m_Kind;                   // Semantic kind.\n  const char *m_pszName;              // Canonical name (for system semantics).\n\n  Semantic() = delete;\n  Semantic(Kind Kind, const char *pszName);\n\n  // Table of all semantic properties.\n  static const unsigned kNumSemanticRecords = (unsigned)Kind::Invalid + 1;\n  static const Semantic ms_SemanticTable[kNumSemanticRecords];\n\n  friend class ShaderModel;\n  friend class SignatureElement;\n};\n\n} // namespace hlsl\n"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/DxilShaderModel.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// DxilShaderModel.h                                                         //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Representation of HLSL shader models.                                     //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n#include \"dxc/HLSL/DXILConstants.h\"\n#include <string>\n\n\nnamespace hlsl {\n\nclass Semantic;\n\n\n/// <summary>\n/// Use this class to represent HLSL shader model.\n/// </summary>\nclass ShaderModel {\npublic:\n  using Kind = DXIL::ShaderKind;\n\n  // Major/Minor version of highest shader model\n  static const unsigned kHighestMajor = 6;\n  static const unsigned kHighestMinor = 0;\n\n  bool IsPS() const     { return m_Kind == Kind::Pixel; }\n  bool IsVS() const     { return m_Kind == Kind::Vertex; }\n  bool IsGS() const     { return m_Kind == Kind::Geometry; }\n  bool IsHS() const     { return m_Kind == Kind::Hull; }\n  bool IsDS() const     { return m_Kind == Kind::Domain; }\n  bool IsCS() const     { return m_Kind == Kind::Compute; }\n  bool IsValid() const;\n\n  Kind GetKind() const      { return m_Kind; }\n  unsigned GetMajor() const { return m_Major; }\n  unsigned GetMinor() const { return m_Minor; }\n  bool IsSM50Plus() const   { return m_Major >= 5; }\n  bool IsSM51Plus() const   { return m_Major > 5 || (m_Major == 5 && m_Minor >= 1); }\n  const char *GetName() const { return m_pszName; }\n  std::string GetKindName() const;\n  unsigned GetNumTempRegs() const { return DXIL::kMaxTempRegCount; }\n  unsigned GetNumInputRegs() const { return m_NumInputRegs; }\n  unsigned GetNumOutputRegs() const { return m_NumOutputRegs; }\n  unsigned GetCBufferSize() const { return DXIL::kMaxCBufferSize; }\n  unsigned SupportsUAV() const { return m_bUAVs; }\n  unsigned SupportsTypedUAVs() const { return m_bTypedUavs; }\n  unsigned GetUAVRegLimit() const { return m_NumUAVRegs; }\n  DXIL::PackingStrategy GetDefaultPackingStrategy() const { return DXIL::PackingStrategy::PrefixStable; }\n\n  static unsigned Count() { return kNumShaderModels - 1; }\n  static const ShaderModel *Get(unsigned Idx);\n  static const ShaderModel *Get(Kind Kind, unsigned Major, unsigned Minor);\n  static const ShaderModel *GetByName(const char *pszName);\n\nprivate:\n  Kind m_Kind;\n  unsigned m_Major;\n  unsigned m_Minor;\n  const char *m_pszName;\n  unsigned m_NumInputRegs;\n  unsigned m_NumOutputRegs;\n  bool     m_bUAVs;\n  bool     m_bTypedUavs;\n  unsigned m_NumUAVRegs;\n\n  ShaderModel() = delete;\n  ShaderModel(Kind Kind, unsigned Major, unsigned Minor, const char *pszName,\n              unsigned m_NumInputRegs, unsigned m_NumOutputRegs,\n              bool m_bUAVs, bool m_bTypedUavs, unsigned m_UAVRegsLim);\n\n  static const unsigned kNumShaderModels = 27;\n  static const ShaderModel ms_ShaderModels[kNumShaderModels];\n\n  static const ShaderModel *GetInvalid();\n};\n\n} // namespace hlsl\n"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/DxilSigPoint.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// DxilSigPoint.h                                                            //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Representation of HLSL signature points.                                  //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n#include \"llvm/ADT/StringRef.h\"\n#include \"DxilConstants.h\"\n\nnamespace hlsl {\n\nstruct VersionedSemanticInterpretation {\n  VersionedSemanticInterpretation(DXIL::SemanticInterpretationKind k, unsigned MajorVersion=0, unsigned MinorVersion=0) :\n    Kind(k), Major((unsigned short)MajorVersion), Minor((unsigned short)MinorVersion)\n  {}\n  DXIL::SemanticInterpretationKind Kind;\n  unsigned short Major, Minor;\n};\n\n/// Use this class to describe an HLSL signature point.\n/// A signature point is a set of signature parameters at a particular shader stage,\n/// grouped by input/output/patch constant and value frequency.\nclass SigPoint {\npublic:\n  using Kind = DXIL::SigPointKind;\n\n  SigPoint(DXIL::SigPointKind spk, const char *name, DXIL::SigPointKind rspk, DXIL::ShaderKind shk, DXIL::SignatureKind sigk, DXIL::PackingKind pk);\n\n  bool IsInput() const { return m_SignatureKind == DXIL::SignatureKind::Input; }\n  bool IsOutput() const { return m_SignatureKind == DXIL::SignatureKind::Output; }\n  bool IsPatchConstant() const { return m_SignatureKind == DXIL::SignatureKind::PatchConstant; }\n\n  Kind GetKind() const { return m_Kind; }\n  const char *GetName() const { return m_pszName; }\n  DXIL::ShaderKind GetShaderKind() const { return m_ShaderKind; }\n  Kind GetRelatedKind() const { return m_RelatedKind; }\n  DXIL::SignatureKind GetSignatureKind() const { return m_SignatureKind; }\n  DXIL::SignatureKind GetSignatureKindWithFallback() const;\n  DXIL::PackingKind GetPackingKind() const { return m_PackingKind; }\n  bool NeedsInterpMode() const { return m_PackingKind == DXIL::PackingKind::Vertex; }\n\n  static const SigPoint* GetSigPoint(Kind K);\n\n  // isSpecialInput selects a signature point outside the normal input/output/patch constant signatures.\n  // These are used for a few system values that should not be included as part of the regular input\n  // structure because they do not have the same dimensionality as other inputs, such as\n  // SV_PrimitiveID for Geometry, Hull, and Patch Constant Functions.\n  static DXIL::SigPointKind GetKind(DXIL::ShaderKind shaderKind, DXIL::SignatureKind sigKind, bool isPatchConstantFunction, bool isSpecialInput);\n\n  // Interpretations are how system values are intrepeted at a particular signature point.\n  static DXIL::SemanticInterpretationKind GetInterpretation(DXIL::SemanticKind SK, Kind K, unsigned MajorVersion, unsigned MinorVersion);\n\n  // For Shadow elements, recover original SigPointKind\n  static Kind RecoverKind(DXIL::SemanticKind SK, Kind K);\n\nprivate:\n  static const unsigned kNumSigPointRecords = (unsigned)Kind::Invalid + 1;\n  static const SigPoint ms_SigPoints[kNumSigPointRecords];\n  static const VersionedSemanticInterpretation ms_SemanticInterpretationTable[(unsigned)DXIL::SemanticKind::Invalid][(unsigned)Kind::Invalid];\n\n  Kind m_Kind;\n  Kind m_RelatedKind;\n  DXIL::ShaderKind m_ShaderKind;\n  DXIL::SignatureKind m_SignatureKind;\n  const char *m_pszName;\n  DXIL::PackingKind m_PackingKind;\n};\n\n} // namespace hlsl\n"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/DxilSignature.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// DxilSignature.h                                                           //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Representation of HLSL shader signature.                                  //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n#include \"dxc/HLSL/DxilSignatureElement.h\"\n#include <memory>\n#include <string>\n#include <vector>\n\n\nnamespace hlsl {\n\n/// Use this class to represent HLSL signature.\nclass DxilSignature {\npublic:\n  using Kind = DXIL::SignatureKind;\n\n  DxilSignature(DXIL::ShaderKind shaderKind, DXIL::SignatureKind sigKind);\n  DxilSignature(DXIL::SigPointKind sigPointKind);\n  virtual ~DxilSignature();\n\n  bool IsInput() const;\n  bool IsOutput() const;\n\n  virtual std::unique_ptr<DxilSignatureElement> CreateElement();\n\n  unsigned AppendElement(std::unique_ptr<DxilSignatureElement> pSE, bool bSetID = true);\n\n  DxilSignatureElement &GetElement(unsigned idx);\n  const DxilSignatureElement &GetElement(unsigned idx) const;\n  const std::vector<std::unique_ptr<DxilSignatureElement> > &GetElements() const;\n\n  // Packs the signature elements per DXIL constraints and returns the number of rows used for the signature\n  unsigned PackElements(DXIL::PackingStrategy packing);\n\n  // Returns true if all signature elements that should be allocated are allocated\n  bool IsFullyAllocated();\n\nprivate:\n  DXIL::SigPointKind m_sigPointKind;\n  std::vector<std::unique_ptr<DxilSignatureElement> > m_Elements;\n};\n\n} // namespace hlsl\n"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/DxilSignatureAllocator.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// DxilSignatureAllocation.h                                                 //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Classes used for allocating signature elements.                           //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n#include \"dxc/HLSL/DxilSignature.h\"\n\nnamespace hlsl {\n\nclass DxilSignatureAllocator {\npublic:\n  // index flags\n  static const uint8_t kIndexedUp = 1 << 0;     // Indexing continues upwards\n  static const uint8_t kIndexedDown = 1 << 1;   // Indexing continues downwards\n  static uint8_t GetIndexFlags(unsigned row, unsigned rows) {\n    return ((row > 0) ? kIndexedUp : 0) | ((row < rows - 1) ? kIndexedDown : 0);\n  }\n  // element flags\n  static const uint8_t kEFOccupied = 1 << 0;\n  static const uint8_t kEFArbitrary = 1 << 1;\n  static const uint8_t kEFSGV = 1 << 2;\n  static const uint8_t kEFSV = 1 << 3;\n  static const uint8_t kEFTessFactor = 1 << 4;\n  static const uint8_t kEFConflictsWithIndexed = kEFSGV | kEFSV;\n  static uint8_t GetElementFlags(const DxilSignatureElement *SE);\n\n  // The following two functions enforce the rules of component ordering when packing different\n  // kinds of elements into the same register.\n\n  // given element flags, return element flags that conflict when placed to the left of the element\n  static uint8_t GetConflictFlagsLeft(uint8_t flags);\n  // given element flags, return element flags that conflict when placed to the right of the element\n  static uint8_t GetConflictFlagsRight(uint8_t flags);\n\n  enum ConflictType {\n    kNoConflict = 0,\n    kConflictsWithIndexed,\n    kConflictsWithIndexedTessFactor,\n    kConflictsWithInterpolationMode,\n    kInsufficientFreeComponents,\n    kOverlapElement,\n    kIllegalComponentOrder,\n    kConflictFit,\n  };\n\n  struct PackedRegister {\n    // Flags:\n    // - for occupied components, they signify element flags\n    // - for unoccupied components, they signify conflict flags\n    uint8_t Flags[4];\n    DXIL::InterpolationMode Interp : 4;\n    uint8_t IndexFlags : 2;\n    uint8_t IndexingFixed : 1;\n\n    PackedRegister();\n    ConflictType DetectRowConflict(uint8_t flags, uint8_t indexFlags, DXIL::InterpolationMode interp, unsigned width);\n    ConflictType DetectColConflict(uint8_t flags, unsigned col, unsigned width);\n    void PlaceElement(uint8_t flags, uint8_t indexFlags, DXIL::InterpolationMode interp, unsigned col, unsigned width);\n  };\n\n  std::vector<PackedRegister> Registers;\n\n  DxilSignatureAllocator(unsigned numRegisters);\n\n  ConflictType DetectRowConflict(const DxilSignatureElement *SE, unsigned row);\n  ConflictType DetectColConflict(const DxilSignatureElement *SE, unsigned row, unsigned col);\n  void PlaceElement(const DxilSignatureElement *SE, unsigned row, unsigned col);\n\n  unsigned PackNext(DxilSignatureElement* SE, unsigned startRow, unsigned numRows, unsigned startCol = 0);\n\n  // Simple greedy in-order packer used by PackOptimized\n  unsigned PackGreedy(std::vector<DxilSignatureElement*> elements, unsigned startRow, unsigned numRows, unsigned startCol = 0);\n\n  // Optimized packing algorithm - appended elements may affect positions of prior elements.\n  unsigned PackOptimized(std::vector<DxilSignatureElement*> elements, unsigned startRow, unsigned numRows);\n\n  // Pack in a prefix-stable way - appended elements do not affect positions of prior elements.\n  unsigned PackPrefixStable(std::vector<DxilSignatureElement*> elements, unsigned startRow, unsigned numRows);\n\n};\n\n\n} // namespace hlsl\n"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/DxilSignatureElement.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// DxilSignatureElement.h                                                    //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Representation of HLSL signature element.                                 //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n#include \"llvm/ADT/StringRef.h\"\n#include \"dxc/HLSL/DxilSemantic.h\"\n#include \"dxc/HLSL/DxilInterpolationMode.h\"\n#include \"dxc/HLSL/DxilCompType.h\"\n#include <string>\n#include <vector>\n\n\nnamespace hlsl {\n\nclass ShaderModel;\n\n/// Use this class to represent HLSL signature elements.\nclass DxilSignatureElement {\n  friend class DxilSignature;\n\npublic:\n  using Kind = DXIL::SigPointKind;\n\n  static const unsigned kUndefinedID = UINT_MAX;\n\n  DxilSignatureElement(Kind K);\n  virtual ~DxilSignatureElement();\n\n  void Initialize(llvm::StringRef Name, const CompType &ElementType, const InterpolationMode &InterpMode, \n                  unsigned Rows, unsigned Cols, \n                  int StartRow = Semantic::kUndefinedRow, int StartCol = Semantic::kUndefinedCol,\n                  unsigned ID = kUndefinedID, const std::vector<unsigned> &IndexVector = std::vector<unsigned>());\n\n  unsigned GetID() const;\n  void SetID(unsigned ID);\n\n  DXIL::ShaderKind GetShaderKind() const;\n\n  DXIL::SigPointKind GetSigPointKind() const;\n  void SetSigPointKind(DXIL::SigPointKind K);\n\n  bool IsInput() const;\n  bool IsOutput() const;\n  bool IsPatchConstant() const;\n  const char *GetName() const;\n  unsigned GetRows() const;\n  void SetRows(unsigned Rows);\n  unsigned GetCols() const;\n  void SetCols(unsigned Cols);\n  const InterpolationMode *GetInterpolationMode() const;\n  CompType GetCompType() const;\n  unsigned GetOutputStream() const;\n  void SetOutputStream(unsigned Stream);\n\n  // Semantic properties.\n  const Semantic *GetSemantic() const;\n  void SetKind(Semantic::Kind kind);\n  Semantic::Kind GetKind() const;\n  bool IsArbitrary() const;\n  bool IsDepth() const;\n  bool IsDepthLE() const;\n  bool IsDepthGE() const;\n  bool IsAnyDepth() const;\n  DXIL::SemanticInterpretationKind GetInterpretation() const;\n\n  llvm::StringRef GetSemanticName() const;\n  unsigned GetSemanticStartIndex() const;\n\n  // Low-level properties.\n  int GetStartRow() const;\n  void SetStartRow(int StartRow);\n  int GetStartCol() const;\n  void SetStartCol(int Component);\n  const std::vector<unsigned> &GetSemanticIndexVec() const;\n  void SetSemanticIndexVec(const std::vector<unsigned> &Vec);\n  void AppendSemanticIndex(unsigned SemIdx);\n  void SetCompType(CompType CT);\n  uint8_t GetColsAsMask() const;\n  bool IsAllocated() const;\n\nprotected:\n  DXIL::SigPointKind m_sigPointKind;\n  const Semantic *m_pSemantic;\n  unsigned m_ID;\n  std::string m_Name;\n  llvm::StringRef m_SemanticName;\n  unsigned m_SemanticStartIndex;\n  CompType m_CompType;\n  InterpolationMode m_InterpMode;\n  std::vector<unsigned> m_SemanticIndex;\n  unsigned m_Rows;\n  unsigned m_Cols;\n  int m_StartRow;\n  int m_StartCol;\n  unsigned m_OutputStream;\n};\n\n} // namespace hlsl\n"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/DxilSpanAllocator.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// DxilSpanAllocator.h                                                       //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Allocator for resources or other things that span a range of space        //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n#include \"dxc/Support/Global.h\"\n#include <set>\n#include <map>\n\nnamespace hlsl {\n\ntemplate<typename T_index, typename T_element>\nclass SpanAllocator {\npublic:\n  struct Span {\n    Span(const T_element *element, T_index start, T_index end)\n      : element(element), start(start), end(end) {\n      DXASSERT_NOMSG(!(end < start));\n    }\n    const T_element *element;\n    T_index start, end;  // inclusive\n    bool operator<(const Span &other) const { return end < other.start; }\n  };\n  typedef std::set<Span> SpanSet;\n\npublic:\n  SpanAllocator(T_index Min, T_index Max)\n    : m_Min(Min), m_Max(Max), m_FirstFree(Min),\n      m_Unbounded(nullptr), m_AllocationFull(false) {\n    DXASSERT_NOMSG(Min <= Max);\n  }\n  T_index GetMin() { return m_Min; }\n  T_index GetMax() { return m_Max; }\n  T_index GetFirstFree() { return m_FirstFree; }\n  bool IsFull() { return m_AllocationFull; }\n  void SetUnbounded(const T_element *element) { m_Unbounded = element; }\n  const T_element *GetUnbounded() const { return m_Unbounded; }\n  const SpanSet &GetSpans() const { return m_Spans; }\n\n  // Find size gap starting at pos, updating pos, and returning true if successful\n  bool Find(T_index size, T_index &pos, T_index align = 1) {\n    DXASSERT_NOMSG(size);\n    if (size - 1 > m_Max - m_Min)\n      return false;\n    if (pos < m_FirstFree)\n      pos = m_FirstFree;\n    if (!UpdatePos(pos, size, align))\n      return false;\n    T_index end = pos + (size - 1);\n    auto next = m_Spans.lower_bound(Span(nullptr, pos, end));\n    if (next == m_Spans.end() || end < next->start)\n      return true;  // it fits here\n    return Find(size, result.first, pos, align);\n  }\n\n  // allocate element size in first available space, returns false on failure\n  bool Allocate(const T_element *element, T_index size, T_index &pos, T_index align = 1) {\n    DXASSERT_NOMSG(size);\n    if (size - 1 > m_Max - m_Min)\n      return false;\n    if (m_AllocationFull)\n      return false;\n    pos = m_FirstFree;\n    if (!UpdatePos(pos, size, align))\n      return false;\n    auto result = m_Spans.emplace(element, pos, pos + (size - 1));\n    if (result.second) {\n      AdvanceFirstFree(result.first);\n      return true;\n    }\n    // Collision, find a gap from iterator\n    if (!Find(size, result.first, pos, align))\n      return false;\n    result = m_Spans.emplace(element, pos, pos + (size - 1));\n    return result.second;\n  }\n\n  bool AllocateUnbounded(const T_element *element, T_index &pos, T_index align = 1) {\n    if (m_AllocationFull)\n      return false;\n    if (m_Spans.empty()) {\n      pos = m_Min;\n      if (!UpdatePos(pos, /*size*/1, align))\n        return false;\n    } else {\n      // This will allocate after the last span\n      auto it = m_Spans.end();  --it;   // find last span\n      DXASSERT_NOMSG(it != m_Spans.end());\n      pos = it->end;\n      if (!IncPos(pos, /*inc*/1, /*size*/1, align))\n        return false;\n    }\n    const T_element *conflict = Insert(element, pos, m_Max);\n    DXASSERT_NOMSG(!conflict);\n    if (!conflict)\n      SetUnbounded(element);\n    return !conflict;\n  }\n\n  // Insert at specific location, returning conflicting element on collision\n  const T_element *Insert(const T_element *element, T_index start, T_index end) {\n    DXASSERT_NOMSG(m_Min <= start && start <= end && end <= m_Max);\n    auto result = m_Spans.emplace(element, start, end);\n    if (!result.second)\n      return result.first->element;\n    AdvanceFirstFree(result.first);\n    return nullptr;\n  }\n\nprivate:\n  // Find size gap starting at iterator, updating pos, and returning true if successful\n  bool Find(T_index size, typename SpanSet::const_iterator it, T_index &pos, T_index align = 1) {\n    pos = it->end;\n    if (!IncPos(pos, /*inc*/1, size, align))\n      return false;\n    for (++it; it != m_Spans.end() && (it->start < pos || it->start - pos < size); ++it) {\n      pos = it->end;\n      if (!IncPos(pos, /*inc*/1, size, align))\n        return false;\n    }\n    return true;\n  }\n\n  // Advance m_FirstFree if it's in span\n  void AdvanceFirstFree(typename SpanSet::const_iterator it) {\n    if (it->start <= m_FirstFree && m_FirstFree <= it->end) {\n      for (; it != m_Spans.end(); ) {\n        if (it->end >= m_Max) {\n          m_AllocationFull = true;\n          break;\n        }\n        m_FirstFree = it->end + 1;\n        ++it;\n        if (it != m_Spans.end() && m_FirstFree < it->start)\n          break;\n      }\n    }\n  }\n\n  T_index Align(T_index pos, T_index align) {\n    T_index rem = (1 < align) ? pos % align : 0;\n    return rem ? pos + (align - rem) : pos;\n  }\n\n  bool IncPos(T_index &pos, T_index inc = 1, T_index size = 1, T_index align = 1) {\n    DXASSERT_NOMSG(inc > 0);\n    if (pos + inc < pos)\n      return false; // overflow\n    pos += inc;\n    return UpdatePos(pos, size, align);\n  }\n  bool UpdatePos(T_index &pos, T_index size = 1, T_index align = 1) {\n    if ((size - 1) > m_Max - m_Min || pos < m_Min || pos > m_Max - (size - 1))\n      return false;\n    T_index aligned = Align(pos, align);\n    if (aligned < pos || aligned > m_Max - (size - 1))\n      return false; // overflow on alignment, or won't fit\n    pos = aligned;\n    return true;\n  }\n\nprivate:\n  SpanSet m_Spans;\n  T_index m_Min, m_Max, m_FirstFree;\n  const T_element *m_Unbounded;\n  bool m_AllocationFull;\n};\n\ntemplate<typename T_index, typename T_element>\nclass SpacesAllocator {\npublic:\n  typedef SpanAllocator<T_index, T_element> Allocator;\n  typedef std::map<T_index, Allocator > AllocatorMap;\n\n  Allocator &Get(T_index SpaceID) {\n    auto it = m_Allocators.find(SpaceID);\n    if (it != m_Allocators.end())\n      return it->second;\n    auto result = m_Allocators.emplace(SpaceID, Allocator(0, UINT_MAX));\n    DXASSERT(result.second, \"Failed to allocate new Allocator\");\n    return result.first->second;\n  }\n\nprivate:\n  AllocatorMap m_Allocators;\n};\n\n}\n"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/DxilTypeSystem.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// DxilTypeSystem.h                                                          //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// DXIL extension to LLVM type system.                                       //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n#include \"llvm/ADT/StringRef.h\"\n#include \"llvm/ADT/MapVector.h\"\n#include \"dxc/HLSL/DxilCompType.h\"\n#include \"dxc/HLSL/DxilInterpolationMode.h\"\n\n#include <memory>\n#include <string>\n#include <vector>\n\nnamespace llvm {\nclass LLVMContext;\nclass Module;\nclass Function;\nclass Type;\nclass StructType;\nclass StringRef;\n};\n\n\nnamespace hlsl {\n\nenum class MatrixOrientation { Undefined = 0, RowMajor, ColumnMajor, LastEntry };\n\nstruct DxilMatrixAnnotation {\n  unsigned Rows;\n  unsigned Cols;\n  MatrixOrientation Orientation;\n\n  DxilMatrixAnnotation();\n};\n\n/// Use this class to represent type annotation for structure field.\nclass DxilFieldAnnotation {\npublic:\n  DxilFieldAnnotation();\n  \n  bool IsPrecise() const;\n  void SetPrecise(bool b = true);\n\n  bool HasMatrixAnnotation() const;\n  const DxilMatrixAnnotation &GetMatrixAnnotation() const;\n  void SetMatrixAnnotation(const DxilMatrixAnnotation &MA);\n\n  bool HasCBufferOffset() const;\n  unsigned GetCBufferOffset() const;\n  void SetCBufferOffset(unsigned Offset);\n\n  bool HasCompType() const;\n  const CompType &GetCompType() const;\n  void SetCompType(CompType::Kind kind);\n\n  bool HasSemanticString() const;\n  const std::string &GetSemanticString() const;\n  llvm::StringRef GetSemanticStringRef() const;\n  void SetSemanticString(const std::string &SemString);\n\n  bool HasInterpolationMode() const;\n  const InterpolationMode &GetInterpolationMode() const;\n  void SetInterpolationMode(const InterpolationMode &IM);\n\n  bool HasFieldName() const;\n  const std::string &GetFieldName() const;\n  void SetFieldName(const std::string &FieldName);\n\nprivate:\n  bool m_bPrecise;\n  CompType m_CompType;\n  DxilMatrixAnnotation m_Matrix;\n  unsigned m_CBufferOffset;\n  std::string m_Semantic;\n  InterpolationMode m_InterpMode;\n  std::string m_FieldName;\n};\n\n\n/// Use this class to represent LLVM structure annotation.\nclass DxilStructAnnotation {\n  friend class DxilTypeSystem;\n\npublic:\n  unsigned GetNumFields() const;\n  DxilFieldAnnotation &GetFieldAnnotation(unsigned FieldIdx);\n  const DxilFieldAnnotation &GetFieldAnnotation(unsigned FieldIdx) const;\n  const llvm::StructType *GetStructType() const;\n  unsigned GetCBufferSize() const;\n  void SetCBufferSize(unsigned size);\n  void MarkEmptyStruct();\n  bool IsEmptyStruct();\nprivate:\n  const llvm::StructType *m_pStructType;\n  std::vector<DxilFieldAnnotation> m_FieldAnnotations;\n  unsigned m_CBufferSize;  // The size of struct if inside constant buffer.\n};\n\n\nenum class DxilParamInputQual {\n  In,\n  Out,\n  Inout,\n  InputPatch,\n  OutputPatch,\n  OutStream0,\n  OutStream1,\n  OutStream2,\n  OutStream3,\n  InputPrimitive,\n};\n\n/// Use this class to represent type annotation for function parameter.\nclass DxilParameterAnnotation : public DxilFieldAnnotation {\npublic:\n  DxilParameterAnnotation();\n  const DxilParamInputQual GetParamInputQual() const;\n  void SetParamInputQual(DxilParamInputQual qual);\n  const std::vector<unsigned> &GetSemanticIndexVec() const;\n  void SetSemanticIndexVec(const std::vector<unsigned> &Vec);\n  void AppendSemanticIndex(unsigned SemIdx);\nprivate:\n  DxilParamInputQual m_inputQual;\n  std::vector<unsigned> m_semanticIndex;\n};\n\n/// Use this class to represent LLVM function annotation.\nclass DxilFunctionAnnotation {\n  friend class DxilTypeSystem;\n\npublic:\n  unsigned GetNumParameters() const;\n  DxilParameterAnnotation &GetParameterAnnotation(unsigned ParamIdx);\n  const DxilParameterAnnotation &GetParameterAnnotation(unsigned ParamIdx) const;\n  const llvm::Function *GetFunction() const;\n  DxilParameterAnnotation &GetRetTypeAnnotation();\n  const DxilParameterAnnotation &GetRetTypeAnnotation() const;\nprivate:\n  const llvm::Function *m_pFunction;\n  std::vector<DxilParameterAnnotation> m_parameterAnnotations;\n  DxilParameterAnnotation m_retTypeAnnotation;\n};\n\n/// Use this class to represent structure type annotations in HL and DXIL.\nclass DxilTypeSystem {\npublic:\n  using StructAnnotationMap = llvm::MapVector<const llvm::StructType *, std::unique_ptr<DxilStructAnnotation> >;\n  using FunctionAnnotationMap = llvm::MapVector<const llvm::Function *, std::unique_ptr<DxilFunctionAnnotation> >;\n\n  DxilTypeSystem(llvm::Module *pModule);\n\n  DxilStructAnnotation *AddStructAnnotation(const llvm::StructType *pStructType);\n  DxilStructAnnotation *GetStructAnnotation(const llvm::StructType *pStructType);\n  void EraseStructAnnotation(const llvm::StructType *pStructType);\n\n  StructAnnotationMap &GetStructAnnotationMap();\n\n  DxilFunctionAnnotation *AddFunctionAnnotation(const llvm::Function *pFunction);\n  DxilFunctionAnnotation *GetFunctionAnnotation(const llvm::Function *pFunction);\n  void EraseFunctionAnnotation(const llvm::Function *pFunction);\n\n  FunctionAnnotationMap &GetFunctionAnnotationMap();\n\n  // Utility methods to create stand-alone SNORM and UNORM.\n  // We may want to move them to a more centralized place for most utilities.\n  llvm::StructType *GetSNormF32Type(unsigned NumComps);\n  llvm::StructType *GetUNormF32Type(unsigned NumComps);\n\nprivate:\n  llvm::Module *m_pModule;\n  StructAnnotationMap m_StructAnnotations;\n  FunctionAnnotationMap m_FunctionAnnotations;\n\n  llvm::StructType *GetNormFloatType(CompType CT, unsigned NumComps);\n};\n\nDXIL::SigPointKind SigPointFromInputQual(DxilParamInputQual Q, DXIL::ShaderKind SK, bool isPC);\n\n} // namespace hlsl\n"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/DxilValidation.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// DxilValidation.h                                                          //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// This file provides support for validating DXIL shaders.                   //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n#include <memory>\n#include \"dxc/Support/Global.h\"\n#include \"dxc/HLSL/DxilConstants.h\"\n\nnamespace llvm {\nclass Module;\nclass LLVMContext;\nclass raw_ostream;\n}\n\nnamespace hlsl {\n\n/* <py::lines('VALRULE-ENUM')>hctdb_instrhelp.get_valrule_enum()</py>*/\n// VALRULE-ENUM:BEGIN\n// Known validation rules\nenum class ValidationRule : unsigned {\n  // Bitcode\n  BitcodeValid, // TODO - Module must be bitcode-valid\n\n  // Container\n  ContainerPartInvalid, // DXIL Container must not contain unknown parts\n  ContainerPartMatches, // DXIL Container Parts must match Module\n  ContainerPartMissing, // DXIL Container requires certain parts, corresponding to module\n  ContainerPartRepeated, // DXIL Container must have only one of each part type\n  ContainerRootSignatureIncompatible, // Root Signature in DXIL Container must be compatible with shader\n\n  // Declaration\n  DeclDxilFnExtern, // External function must be a DXIL function\n  DeclDxilNsReserved, // The DXIL reserved prefixes must only be used by built-in functions and types\n  DeclFnFlattenParam, // Function parameters must not use struct types\n  DeclFnIsCalled, // Functions can only be used by call instructions\n  DeclNotUsedExternal, // External declaration should not be used\n  DeclUsedExternalFunction, // External function must be used\n  DeclUsedInternal, // Internal declaration must be used\n\n  // Instruction\n  InstrAllowed, // Instructions must be of an allowed type\n  InstrBarrierModeForNonCS, // sync in a non-Compute Shader must only sync UAV (sync_uglobal)\n  InstrBarrierModeNoMemory, // sync must include some form of memory barrier - _u (UAV) and/or _g (Thread Group Shared Memory).  Only _t (thread group sync) is optional. \n  InstrBarrierModeUselessUGroup, // sync can't specify both _ugroup and _uglobal. If both are needed, just specify _uglobal.\n  InstrBufferUpdateCounterOnUAV, // BufferUpdateCounter valid only on UAV\n  InstrCBufferClassForCBufferHandle, // Expect Cbuffer for CBufferLoad handle\n  InstrCBufferOutOfBound, // Cbuffer access out of bound\n  InstrCallOload, // Call to DXIL intrinsic must match overload signature\n  InstrCannotPullPosition, // pull-model evaluation of position disallowed\n  InstrCoordinateCountForRawTypedBuf, // raw/typed buffer don't need 2 coordinates\n  InstrCoordinateCountForStructBuf, // structured buffer require 2 coordinates\n  InstrDxilStructUser, // Dxil struct types should only used by ExtractValue\n  InstrDxilStructUserOutOfBound, // Index out of bound when extract value from dxil struct types\n  InstrEvalInterpolationMode, // Interpolation mode on %0 used with eval_* instruction must be linear, linear_centroid, linear_noperspective, linear_noperspective_centroid, linear_sample or linear_noperspective_sample\n  InstrExtractValue, // ExtractValue should only be used on dxil struct types and cmpxchg\n  InstrFailToResloveTGSMPointer, // TGSM pointers must originate from an unambiguous TGSM global variable.\n  InstrHandleNotFromCreateHandle, // Resource handle should returned by createHandle\n  InstrImmBiasForSampleB, // bias amount for sample_b must be in the range [%0,%1], but %2 was specified as an immediate\n  InstrInBoundsAccess, // Access to out-of-bounds memory is disallowed\n  InstrMinPrecisionNotPrecise, // Instructions marked precise may not refer to minprecision values\n  InstrMinPrecisonBitCast, // Bitcast on minprecison types is not allowed\n  InstrMipLevelForGetDimension, // Use mip level on buffer when GetDimensions\n  InstrMipOnUAVLoad, // uav load don't support mipLevel/sampleIndex\n  InstrNoGenericPtrAddrSpaceCast, // Address space cast between pointer types must have one part to be generic address space\n  InstrNoIDivByZero, // No signed integer division by zero\n  InstrNoIndefiniteAcos, // No indefinite arccosine\n  InstrNoIndefiniteAsin, // No indefinite arcsine\n  InstrNoIndefiniteDsxy, // No indefinite derivative calculation\n  InstrNoIndefiniteLog, // No indefinite logarithm\n  InstrNoReadingUninitialized, // Instructions should not read uninitialized value\n  InstrNoUDivByZero, // No unsigned integer division by zero\n  InstrOffsetOnUAVLoad, // uav load don't support offset\n  InstrOload, // DXIL intrinsic overload must be valid\n  InstrOnlyOneAllocConsume, // RWStructuredBuffers may increment or decrement their counters, but not both.\n  InstrOpCodeReserved, // Instructions must not reference reserved opcodes\n  InstrOpConst, // DXIL intrinsic requires an immediate constant operand\n  InstrOpConstRange, // Constant values must be in-range for operation\n  InstrOperandRange, // DXIL intrinsic operand must be within defined range\n  InstrPtrBitCast, // Pointer type bitcast must be have same size\n  InstrResourceClassForLoad, // load can only run on UAV/SRV resource\n  InstrResourceClassForSamplerGather, // sample, lod and gather should on srv resource.\n  InstrResourceClassForUAVStore, // store should on uav resource.\n  InstrResourceCoordinateMiss, // coord uninitialized\n  InstrResourceCoordinateTooMany, // out of bound coord must be undef\n  InstrResourceKindForBufferLoadStore, // buffer load/store only works on Raw/Typed/StructuredBuffer\n  InstrResourceKindForCalcLOD, // lod requires resource declared as texture1D/2D/3D/Cube/CubeArray/1DArray/2DArray\n  InstrResourceKindForGather, // gather requires resource declared as texture/2D/Cube/2DArray/CubeArray\n  InstrResourceKindForGetDim, // Invalid resource kind on GetDimensions\n  InstrResourceKindForSample, // sample/_l/_d requires resource declared as texture1D/2D/3D/Cube/1DArray/2DArray/CubeArray\n  InstrResourceKindForSampleC, // samplec requires resource declared as texture1D/2D/Cube/1DArray/2DArray/CubeArray\n  InstrResourceKindForTextureLoad, // texture load only works on Texture1D/1DArray/2D/2DArray/3D/MS2D/MS2DArray\n  InstrResourceKindForTextureStore, // texture store only works on Texture1D/1DArray/2D/2DArray/3D\n  InstrResourceOffsetMiss, // offset uninitialized\n  InstrResourceOffsetTooMany, // out of bound offset must be undef\n  InstrSampleCompType, // sample_* instructions require resource to be declared to return UNORM, SNORM or FLOAT.\n  InstrSampleIndexForLoad2DMS, // load on Texture2DMS/2DMSArray require sampleIndex\n  InstrSamplerModeForLOD, // lod instruction requires sampler declared in default mode\n  InstrSamplerModeForSample, // sample/_l/_d/_cl_s/gather instruction requires sampler declared in default mode\n  InstrSamplerModeForSampleC, // sample_c_*/gather_c instructions require sampler declared in comparison mode\n  InstrStructBitCast, // Bitcast on struct types is not allowed\n  InstrTGSMRaceCond, // Race condition writing to shared memory detected, consider making this write conditional\n  InstrTextureOffset, // offset texture instructions must take offset which can resolve to integer literal in the range -8 to 7\n  InstrUndefResultForGetDimension, // GetDimensions used undef dimension %0 on %1\n  InstrWriteMaskForTypedUAVStore, // store on typed uav must write to all four components of the UAV\n  InstrWriteMaskMatchValueForUAVStore, // uav store write mask must match store value mask, write mask is %0 and store value mask is %1\n\n  // Metadata\n  MetaBranchFlatten, // Can't use branch and flatten attributes together\n  MetaClipCullMaxComponents, // Combined elements of SV_ClipDistance and SV_CullDistance must fit in 8 components\n  MetaClipCullMaxRows, // Combined elements of SV_ClipDistance and SV_CullDistance must fit in two rows.\n  MetaControlFlowHintNotOnControlFlow, // Control flow hint only works on control flow inst\n  MetaDenseResIDs, // Resource identifiers must be zero-based and dense\n  MetaDuplicateSysValue, // System value may only appear once in signature\n  MetaEntryFunction, // entrypoint not found\n  MetaFlagsUsage, // Flags must match usage\n  MetaForceCaseOnSwitch, // Attribute forcecase only works for switch\n  MetaFunctionAnnotation, // Cannot find function annotation for %0\n  MetaGlcNotOnAppendConsume, // globallycoherent cannot be used with append/consume buffers\n  MetaIntegerInterpMode, // Interpolation mode on integer must be Constant\n  MetaInterpModeInOneRow, // Interpolation mode must be identical for all elements packed into the same row.\n  MetaInterpModeValid, // Interpolation mode must be valid\n  MetaInvalidControlFlowHint, // Invalid control flow hint\n  MetaKnown, // Named metadata should be known\n  MetaMaxTessFactor, // Hull Shader MaxTessFactor must be [%0..%1].  %2 specified\n  MetaNoSemanticOverlap, // Semantics must not overlap\n  MetaRequired, // TODO - Required metadata missing\n  MetaSemaKindMatchesName, // Semantic name must match system value, when defined.\n  MetaSemaKindValid, // Semantic kind must be valid\n  MetaSemanticCompType, // %0 must be %1\n  MetaSemanticIndexMax, // System value semantics have a maximum valid semantic index\n  MetaSemanticLen, // Semantic length must be at least 1 and at most 64\n  MetaSemanticShouldBeAllocated, // Semantic should have a valid packing location\n  MetaSemanticShouldNotBeAllocated, // Semantic should have a packing location of -1\n  MetaSignatureCompType, // signature %0 specifies unrecognized or invalid component type\n  MetaSignatureIllegalComponentOrder, // Component ordering for packed elements must be: arbitrary < system value < system generated value\n  MetaSignatureIndexConflict, // Only elements with compatible indexing rules may be packed together\n  MetaSignatureOutOfRange, // Signature elements must fit within maximum signature size\n  MetaSignatureOverlap, // Signature elements may not overlap in packing location.\n  MetaStructBufAlignment, // StructuredBuffer stride not aligned\n  MetaStructBufAlignmentOutOfBound, // StructuredBuffer stride out of bounds\n  MetaSystemValueRows, // System value may only have 1 row\n  MetaTarget, // Target triple must be 'dxil-ms-dx'\n  MetaTessellatorOutputPrimitive, // Invalid Tessellator Output Primitive specified. Must be point, line, triangleCW or triangleCCW.\n  MetaTessellatorPartition, // Invalid Tessellator Partitioning specified. Must be integer, pow2, fractional_odd or fractional_even.\n  MetaTextureType, // elements of typed buffers and textures must fit in four 32-bit quantities\n  MetaUsed, // All metadata must be used by dxil\n  MetaValidSamplerMode, // Invalid sampler mode on sampler \n  MetaValueRange, // Metadata value must be within range\n  MetaWellFormed, // TODO - Metadata must be well-formed in operand count and types\n\n  // Program flow\n  FlowDeadLoop, // Loop must have break\n  FlowFunctionCall, // Function with parameter is not permitted\n  FlowNoRecusion, // Recursion is not permitted\n  FlowReducible, // Execution flow must be reducible\n\n  // Shader model\n  SmAppendAndConsumeOnSameUAV, // BufferUpdateCounter inc and dec on a given UAV (%d) cannot both be in the same shader for shader model less than 5.1.\n  SmCBufferElementOverflow, // CBuffer elements must not overflow\n  SmCBufferOffsetOverlap, // CBuffer offsets must not overlap\n  SmCBufferTemplateTypeMustBeStruct, // D3D12 constant/texture buffer template element can only be a struct\n  SmCSNoReturn, // Compute shaders can't return values, outputs must be written in writable resources (UAVs).\n  SmCompletePosition, // Not all elements of SV_Position were written\n  SmCounterOnlyOnStructBuf, // BufferUpdateCounter valid only on structured buffers\n  SmDSInputControlPointCountRange, // DS input control point count must be [0..%0].  %1 specified\n  SmDomainLocationIdxOOB, // DomainLocation component index out of bounds for the domain.\n  SmGSInstanceCountRange, // GS instance count must be [1..%0].  %1 specified\n  SmGSOutputVertexCountRange, // GS output vertex count must be [0..%0].  %1 specified\n  SmGSTotalOutputVertexDataRange, // Declared output vertex count (%0) multiplied by the total number of declared scalar components of output data (%1) equals %2.  This value cannot be greater than %3\n  SmGSValidInputPrimitive, // GS input primitive unrecognized\n  SmGSValidOutputPrimitiveTopology, // GS output primitive topology unrecognized\n  SmHSInputControlPointCountRange, // HS input control point count must be [0..%0].  %1 specified\n  SmHullPassThruControlPointCountMatch, // For pass thru hull shader, input control point count must match output control point count\n  SmInsideTessFactorSizeMatchDomain, // InsideTessFactor rows, columns (%0, %1) invalid for domain %2.  Expected %3 rows and 1 column.\n  SmInvalidResourceCompType, // Invalid resource return type\n  SmInvalidResourceKind, // Invalid resources kind\n  SmInvalidTextureKindOnUAV, // Texture2DMS[Array] or TextureCube[Array] resources are not supported with UAVs\n  SmIsoLineOutputPrimitiveMismatch, // Hull Shader declared with IsoLine Domain must specify output primitive point or line. Triangle_cw or triangle_ccw output are not compatible with the IsoLine Domain.\n  SmMaxTGSMSize, // Total Thread Group Shared Memory storage is %0, exceeded %1\n  SmMaxTheadGroup, // Declared Thread Group Count %0 (X*Y*Z) is beyond the valid maximum of %1\n  SmMultiStreamMustBePoint, // When multiple GS output streams are used they must be pointlists\n  SmName, // Target shader model name must be known\n  SmNoInterpMode, // Interpolation mode must be undefined for VS input/PS output/patch constant.\n  SmNoPSOutputIdx, // Pixel shader output registers are not indexable.\n  SmOpcode, // Opcode must be defined in target shader model\n  SmOpcodeInInvalidFunction, // Invalid DXIL opcode usage like StorePatchConstant in patch constant function\n  SmOperand, // Operand must be defined in target shader model\n  SmOutputControlPointCountRange, // output control point count must be [0..%0].  %1 specified\n  SmOutputControlPointsTotalScalars, // Total number of scalars across all HS output control points must not exceed \n  SmPSConsistentInterp, // Interpolation mode for PS input position must be linear_noperspective_centroid or linear_noperspective_sample when outputting oDepthGE or oDepthLE and not running at sample frequency (which is forced by inputting SV_SampleIndex or declaring an input linear_sample or linear_noperspective_sample)\n  SmPSCoverageAndInnerCoverage, // InnerCoverage and Coverage are mutually exclusive.\n  SmPSMultipleDepthSemantic, // Pixel Shader only allows one type of depth semantic to be declared\n  SmPSOutputSemantic, // Pixel Shader allows output semantics to be SV_Target, SV_Depth, SV_DepthGreaterEqual, SV_DepthLessEqual, SV_Coverage or SV_StencilRef, %0 found\n  SmPSTargetCol0, // SV_Target packed location must start at column 0\n  SmPSTargetIndexMatchesRow, // SV_Target semantic index must match packed row location\n  SmPatchConstantOnlyForHSDS, // patch constant signature only valid in HS and DS\n  SmROVOnlyInPS, // RasterizerOrdered objects are only allowed in 5.0+ pixel shaders\n  SmResourceRangeOverlap, // Resource ranges must not overlap\n  SmSampleCountOnlyOn2DMS, // Only Texture2DMS/2DMSArray could has sample count\n  SmSemantic, // Semantic must be defined in target shader model\n  SmStreamIndexRange, // Stream index (%0) must between 0 and %1\n  SmTessFactorForDomain, // Required TessFactor for domain not found declared anywhere in Patch Constant data\n  SmTessFactorSizeMatchDomain, // TessFactor rows, columns (%0, %1) invalid for domain %2.  Expected %3 rows and 1 column.\n  SmThreadGroupChannelRange, // Declared Thread Group %0 size %1 outside valid range [%2..%3]\n  SmTriOutputPrimitiveMismatch, // Hull Shader declared with Tri Domain must specify output primitive point, triangle_cw or triangle_ccw. Line output is not compatible with the Tri domain\n  SmUndefinedOutput, // Not all elements of output %0 were written\n  SmValidDomain, // Invalid Tessellator Domain specified. Must be isoline, tri or quad\n  SmZeroHSInputControlPointWithInput, // When HS input control point count is 0, no input signature should exist\n\n  // Type system\n  TypesDefined, // Type must be defined based on DXIL primitives\n  TypesI8, // I8 can only used as immediate value for intrinsic\n  TypesIntWidth, // Int type must be of valid width\n  TypesNoMultiDim, // Only one dimension allowed for array type\n  TypesNoVector, // Vector types must not be present\n\n  // Uniform analysis\n  UniNoWaveSensitiveGradient, // Gradient operations are not affected by wave-sensitive data or control flow.\n};\n// VALRULE-ENUM:END\n\nconst char *GetValidationRuleText(ValidationRule value);\nvoid GetValidationVersion(_Out_ unsigned *pMajor, _Out_ unsigned *pMinor);\nHRESULT ValidateDxilModule(_In_ llvm::Module *pModule,\n                           _In_opt_ llvm::Module *pDebugModule);\n\n// DXIL Container Verification Functions (return false on failure)\n\nbool VerifySignatureMatches(_In_ llvm::Module *pModule,\n                            hlsl::DXIL::SignatureKind SigKind,\n                            _In_reads_bytes_(SigSize) const void *pSigData,\n                            _In_ uint32_t SigSize);\n\n// PSV = data for Pipeline State Validation\nbool VerifyPSVMatches(_In_ llvm::Module *pModule,\n                      _In_reads_bytes_(PSVSize) const void *pPSVData,\n                      _In_ uint32_t PSVSize);\n\nbool VerifyFeatureInfoMatches(_In_ llvm::Module *pModule,\n                              _In_reads_bytes_(FeatureInfoSize) const void *pFeatureInfoData,\n                              _In_ uint32_t FeatureInfoSize);\n\n// Validate the container parts, assuming supplied module is valid, loaded from the container provided\nstruct DxilContainerHeader;\nHRESULT ValidateDxilContainerParts(_In_ llvm::Module *pModule,\n                                   _In_opt_ llvm::Module *pDebugModule,\n                                   _In_reads_bytes_(ContainerSize) const DxilContainerHeader *pContainer,\n                                   _In_ uint32_t ContainerSize);\n\n// Loads module, validating load, but not module.\nHRESULT ValidateLoadModule(_In_reads_bytes_(ILLength) const char *pIL,\n                           _In_ uint32_t ILLength,\n                           _In_ std::unique_ptr<llvm::Module> &pModule,\n                           _In_ llvm::LLVMContext &Ctx,\n                           _In_ llvm::raw_ostream &DiagStream);\n\n// Load and validate Dxil module from bitcode.\nHRESULT ValidateDxilBitcode(_In_reads_bytes_(ILLength) const char *pIL,\n                            _In_ uint32_t ILLength,\n                            _In_ llvm::raw_ostream &DiagStream);\n\n// Full container validation, including ValidateDxilModule\nHRESULT ValidateDxilContainer(_In_reads_bytes_(ContainerSize) const void *pContainer,\n                              _In_ uint32_t ContainerSize,\n                              _In_ llvm::raw_ostream &DiagStream);\n\n}\n"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/HLMatrixLowerHelper.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// HLMatrixLowerHelper.h                                                     //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// This file provides helper functions to lower high level matrix.           //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n#include \"llvm/IR/IRBuilder.h\"\n\nnamespace llvm {\n  class Type;\n  class Value;\n  template<typename T>\n  class ArrayRef;\n}\n\nnamespace hlsl {\n\nnamespace HLMatrixLower {\n// TODO: use type annotation.\nbool IsMatrixType(llvm::Type *Ty);\n// Translate matrix type to vector type.\nllvm::Type *LowerMatrixType(llvm::Type *Ty);\n// TODO: use type annotation.\nllvm::Type *GetMatrixInfo(llvm::Type *Ty, unsigned &col, unsigned &row);\n// TODO: use type annotation.\nbool IsMatrixArrayPointer(llvm::Type *Ty);\n// Translate matrix array pointer type to vector array pointer type.\nllvm::Type *LowerMatrixArrayPointer(llvm::Type *Ty);\n\nllvm::Value *BuildMatrix(llvm::Type *EltTy, unsigned col, unsigned row,\n                   bool colMajor, llvm::ArrayRef<llvm::Value *> elts,\n                   llvm::IRBuilder<> &Builder);\n\n} // namespace HLMatrixLower\n\n} // namespace hlsl"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/HLMatrixLowerPass.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// HLMatrixLowerPass.h                                                       //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// This file provides a high level matrix lower pass.                        //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\nnamespace llvm {\nclass ModulePass;\nclass PassRegistry;\n\n/// \\brief Create and return a pass that lower high level matrix.\n/// Note that this pass is designed for use with the legacy pass manager.\nModulePass *createHLMatrixLowerPass();\nvoid initializeHLMatrixLowerPassPass(llvm::PassRegistry&);\n\n}\n"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/HLModule.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// HLModule.h                                                                //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// HighLevel DX IR module.                                                   //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n#include \"dxc/Support/Global.h\"\n#include \"dxc/HLSL/DxilMetadataHelper.h\"\n#include \"dxc/HLSL/DxilConstants.h\"\n#include \"dxc/HLSL/HLResource.h\"\n#include \"dxc/HLSL/HLOperations.h\"\n#include \"dxc/HLSL/DxilSampler.h\"\n#include \"dxc/HLSL/DxilShaderModel.h\"\n#include \"dxc/HLSL/DxilSignature.h\"\n#include <memory>\n#include <string>\n#include <vector>\n#include <unordered_map>\n\nnamespace llvm {\nclass LLVMContext;\nclass Module;\nclass Function;\nclass Instruction;\nclass MDTuple;\nclass MDNode;\nclass GlobalVariable;\nclass DIGlobalVariable;\nclass DebugInfoFinder;\n};\n\n\nnamespace hlsl {\n\nclass ShaderModel;\nclass OP;\nclass RootSignatureHandle;\n\nstruct HLFunctionProps {\n  union {\n    // TODO: not every function need this union.\n    // Compute shader.\n    struct {\n      unsigned numThreads[3];\n    } CS;\n    // Geometry shader.\n    struct {\n      DXIL::InputPrimitive inputPrimitive;\n      unsigned maxVertexCount;\n      unsigned instanceCount;\n      DXIL::PrimitiveTopology streamPrimitiveTopologies[DXIL::kNumOutputStreams];\n    } GS;\n    // Hull shader.\n    struct {\n      llvm::Function *patchConstantFunc;\n      DXIL::TessellatorDomain domain;\n      DXIL::TessellatorPartitioning partition;\n      DXIL::TessellatorOutputPrimitive outputPrimitive;\n      unsigned inputControlPoints;\n      unsigned outputControlPoints;\n      float    maxTessFactor;\n    } HS;\n    // Domain shader.\n    struct {\n      DXIL::TessellatorDomain domain;\n      unsigned inputControlPoints;\n    } DS;\n    // Vertex shader.\n    struct {\n      llvm::Constant *clipPlanes[DXIL::kNumClipPlanes];\n    } VS;\n    // Pixel shader.\n    struct {\n      bool EarlyDepthStencil;\n    } PS;\n  } ShaderProps;\n  DXIL::ShaderKind shaderKind;\n};\n\nstruct HLOptions {\n  HLOptions()\n      : bDefaultRowMajor(false), bIEEEStrict(false), bDisableOptimizations(false),\n        bLegacyCBufferLoad(false), PackingStrategy(0), unused(0) {\n  }\n  uint32_t GetHLOptionsRaw() const;\n  void SetHLOptionsRaw(uint32_t data);\n  unsigned bDefaultRowMajor        : 1;\n  unsigned bIEEEStrict             : 1;\n  unsigned bAllResourcesBound      : 1;\n  unsigned bDisableOptimizations   : 1;\n  unsigned bLegacyCBufferLoad      : 1;\n  unsigned PackingStrategy         : 2;\n  static_assert((unsigned)DXIL::PackingStrategy::Invalid < 4, \"otherwise 2 bits is not enough to store PackingStrategy\");\n  unsigned unused                  : 25;\n};\n\n/// Use this class to manipulate HLDXIR of a shader.\nclass HLModule {\npublic:\n  HLModule(llvm::Module *pModule);\n  ~HLModule();\n  using Domain = DXIL::TessellatorDomain;\n  // Subsystems.\n  llvm::LLVMContext &GetCtx() const;\n  llvm::Module *GetModule() const;\n  OP *GetOP() const;\n  void SetShaderModel(const ShaderModel *pSM);\n  const ShaderModel *GetShaderModel() const;\n\n  // HLOptions\n  void SetHLOptions(HLOptions &opts);\n  const HLOptions &GetHLOptions() const;\n\n  // Entry function.\n  llvm::Function *GetEntryFunction() const;\n  void SetEntryFunction(llvm::Function *pEntryFunc);\n  const std::string &GetEntryFunctionName() const;\n  void SetEntryFunctionName(const std::string &name);\n\n  // Resources.\n  unsigned AddCBuffer(std::unique_ptr<DxilCBuffer> pCB);\n  DxilCBuffer &GetCBuffer(unsigned idx);\n  const DxilCBuffer &GetCBuffer(unsigned idx) const;\n  const std::vector<std::unique_ptr<DxilCBuffer> > &GetCBuffers() const;\n\n  unsigned AddSampler(std::unique_ptr<DxilSampler> pSampler);\n  DxilSampler &GetSampler(unsigned idx);\n  const DxilSampler &GetSampler(unsigned idx) const;\n  const std::vector<std::unique_ptr<DxilSampler> > &GetSamplers() const;\n\n  unsigned AddSRV(std::unique_ptr<HLResource> pSRV);\n  HLResource &GetSRV(unsigned idx);\n  const HLResource &GetSRV(unsigned idx) const;\n  const std::vector<std::unique_ptr<HLResource> > &GetSRVs() const;\n\n  unsigned AddUAV(std::unique_ptr<HLResource> pUAV);\n  HLResource &GetUAV(unsigned idx);\n  const HLResource &GetUAV(unsigned idx) const;\n  const std::vector<std::unique_ptr<HLResource> > &GetUAVs() const;\n\n  void RemoveGlobal(llvm::GlobalVariable *GV);\n  void RemoveFunction(llvm::Function *F);\n  void RemoveResources(llvm::GlobalVariable **ppVariables, unsigned count);\n\n  // ThreadGroupSharedMemory.\n  typedef std::vector<llvm::GlobalVariable*>::iterator tgsm_iterator;\n  tgsm_iterator tgsm_begin();\n  tgsm_iterator tgsm_end();\n  void AddGroupSharedVariable(llvm::GlobalVariable *GV);\n\n  // Signatures.\n  DxilSignature &GetInputSignature();\n  DxilSignature &GetOutputSignature();\n  DxilSignature &GetPatchConstantSignature();\n  RootSignatureHandle &GetRootSignature();\n\n  // HLFunctionProps.\n  bool HasHLFunctionProps(llvm::Function *F);\n  HLFunctionProps &GetHLFunctionProps(llvm::Function *F);\n  void AddHLFunctionProps(llvm::Function *F, std::unique_ptr<HLFunctionProps> &info);\n\n  DxilFunctionAnnotation *GetFunctionAnnotation(llvm::Function *F);\n  DxilFunctionAnnotation *AddFunctionAnnotation(llvm::Function *F);\n\n  void AddResourceTypeAnnotation(llvm::Type *Ty, DXIL::ResourceClass resClass,\n                                 DXIL::ResourceKind kind);\n  DXIL::ResourceClass GetResourceClass(llvm::Type *Ty);\n  DXIL::ResourceKind  GetResourceKind(llvm::Type *Ty);\n\n  // HLDXIR metadata manipulation.\n  /// Serialize HLDXIR in-memory form to metadata form.\n  void EmitHLMetadata();\n  /// Deserialize HLDXIR metadata form into in-memory form.\n  void LoadHLMetadata();\n  /// Delete any HLDXIR from the specified module.\n  static void ClearHLMetadata(llvm::Module &M);\n\n  // Type related methods.\n  static bool IsStreamOutputPtrType(llvm::Type *Ty);\n  static bool IsStreamOutputType(llvm::Type *Ty);\n  static bool IsHLSLObjectType(llvm::Type *Ty);\n  static unsigned\n  GetLegacyCBufferFieldElementSize(DxilFieldAnnotation &fieldAnnotation,\n                                   llvm::Type *Ty, DxilTypeSystem &typeSys);\n\n  static bool IsStaticGlobal(llvm::GlobalVariable *GV);\n  static bool IsSharedMemoryGlobal(llvm::GlobalVariable *GV);\n  static void GetParameterRowsAndCols(llvm::Type *Ty, unsigned &rows, unsigned &cols,\n                                      DxilParameterAnnotation &paramAnnotation);\n  static const char *GetLegacyDataLayoutDesc();\n\n  // HL code gen.\n  template<class BuilderTy>\n  static llvm::Value *EmitHLOperationCall(BuilderTy &Builder,\n                                          HLOpcodeGroup group, unsigned opcode,\n                                          llvm::Type *RetType,\n                                          llvm::ArrayRef<llvm::Value *> paramList,\n                                          llvm::Module &M);\n\n  static unsigned FindCastOp(bool fromUnsigned, bool toUnsigned,\n                             llvm::Type *SrcTy, llvm::Type *DstTy);\n\n  // Precise attribute.\n  // Note: Precise will be marked on alloca inst with metadata in code gen.\n  //       But mem2reg will remove alloca inst, so need mark precise with\n  //       function call before mem2reg.\n  static bool HasPreciseAttributeWithMetadata(llvm::Instruction *I);\n  static void MarkPreciseAttributeWithMetadata(llvm::Instruction *I);\n  static void ClearPreciseAttributeWithMetadata(llvm::Instruction *I);\n  static void MarkPreciseAttributeOnPtrWithFunctionCall(llvm::Value *Ptr,\n                                                        llvm::Module &M);\n  static bool HasPreciseAttribute(llvm::Function *F);\n\n  // DXIL type system.\n  DxilTypeSystem &GetTypeSystem();\n\n  /// Emit llvm.used array to make sure that optimizations do not remove unreferenced globals.\n  void EmitLLVMUsed();\n  std::vector<llvm::GlobalVariable* > &GetLLVMUsed();\n\n  // Release functions used to transfer ownership.\n  DxilSignature *ReleaseInputSignature();\n  DxilSignature *ReleaseOutputSignature();\n  DxilSignature *ReleasePatchConstantSignature();\n  DxilTypeSystem *ReleaseTypeSystem();\n  OP *ReleaseOP();\n  RootSignatureHandle *ReleaseRootSignature();\n\n  llvm::DebugInfoFinder &GetOrCreateDebugInfoFinder();\n  static llvm::DIGlobalVariable *\n  FindGlobalVariableDebugInfo(llvm::GlobalVariable *GV,\n                              llvm::DebugInfoFinder &DbgInfoFinder);\n  // Create global variable debug info for element global variable based on the\n  // whole global variable.\n  static void CreateElementGlobalVariableDebugInfo(\n      llvm::GlobalVariable *GV, llvm::DebugInfoFinder &DbgInfoFinder,\n      llvm::GlobalVariable *EltGV, unsigned sizeInBits, unsigned alignInBits,\n      unsigned offsetInBits, llvm::StringRef eltName);\n  // Replace GV with NewGV in GlobalVariable debug info.\n  static void\n  UpdateGlobalVariableDebugInfo(llvm::GlobalVariable *GV,\n                                llvm::DebugInfoFinder &DbgInfoFinder,\n                                llvm::GlobalVariable *NewGV);\n\nprivate:\n  // Signatures.\n  std::unique_ptr<DxilSignature> m_InputSignature;\n  std::unique_ptr<DxilSignature> m_OutputSignature;\n  std::unique_ptr<DxilSignature> m_PatchConstantSignature;\n  std::unique_ptr<RootSignatureHandle> m_RootSignature;\n\n  // Shader resources.\n  std::vector<std::unique_ptr<HLResource> > m_SRVs;\n  std::vector<std::unique_ptr<HLResource> > m_UAVs;\n  std::vector<std::unique_ptr<DxilCBuffer> > m_CBuffers;\n  std::vector<std::unique_ptr<DxilSampler> > m_Samplers;\n\n  // ThreadGroupSharedMemory.\n  std::vector<llvm::GlobalVariable*>  m_TGSMVariables;\n\n  // High level function info.\n  std::unordered_map<llvm::Function *, std::unique_ptr<HLFunctionProps>>  m_HLFunctionPropsMap;\n\n  // Resource type annotation.\n  std::unordered_map<llvm::Type *, std::pair<DXIL::ResourceClass, DXIL::ResourceKind>> m_ResTypeAnnotation;\n\nprivate:\n  llvm::LLVMContext &m_Ctx;\n  llvm::Module *m_pModule;\n  llvm::Function *m_pEntryFunc;\n  std::string m_EntryName;\n  std::unique_ptr<DxilMDHelper> m_pMDHelper;\n  std::unique_ptr<llvm::DebugInfoFinder> m_pDebugInfoFinder;\n  const ShaderModel *m_pSM;\n  unsigned m_DxilMajor;\n  unsigned m_DxilMinor;\n  HLOptions m_Options;\n  std::unique_ptr<OP> m_pOP;\n  size_t m_pUnused;\n\n  // DXIL metadata serialization/deserialization.\n  llvm::MDTuple *EmitHLResources();\n  void LoadHLResources(const llvm::MDOperand &MDO);\n  llvm::MDTuple *EmitHLShaderProperties();\n  void LoadHLShaderProperties(const llvm::MDOperand &MDO);\n  llvm::MDTuple *EmitDxilShaderProperties();\n  llvm::MDTuple *EmitResTyAnnotations();\n  void LoadResTyAnnotations(const llvm::MDOperand &MDO);\n  // LLVM used.\n  std::vector<llvm::GlobalVariable*> m_LLVMUsed;\n\n  // Type annotations.\n  std::unique_ptr<DxilTypeSystem> m_pTypeSystem;\n\n  // Helpers.\n  template<typename T> unsigned AddResource(std::vector<std::unique_ptr<T> > &Vec, std::unique_ptr<T> pRes);\n};\n\n\n/// Use this class to manipulate metadata of extra metadata record properties that are specific to high-level DX IR.\nclass HLExtraPropertyHelper : public DxilExtraPropertyHelper {\npublic:\n  HLExtraPropertyHelper(llvm::Module *pModule);\n\n  virtual void EmitSignatureElementProperties(const DxilSignatureElement &SE, std::vector<llvm::Metadata *> &MDVals);\n  virtual void LoadSignatureElementProperties(const llvm::MDOperand &MDO, DxilSignatureElement &SE);\n};\n\n} // namespace hlsl\n"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/HLOperationLower.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// HLOperationLower.h                                                        //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Lower functions to lower HL operations to DXIL operations.                //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\nnamespace llvm {\nclass Instruction;\nclass Value;\nclass Function;\n}\n\nnamespace hlsl {\nclass HLModule;\nclass DxilResourceBase;\nclass HLSLExtensionsCodegenHelper;\n\nvoid TranslateBuiltinOperations(\n    HLModule &HLM,\n    std::unordered_map<llvm::Instruction *, llvm::Value *> &handleMap,\n    HLSLExtensionsCodegenHelper *extCodegenHelper);\n}"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/HLOperationLowerExtension.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// HLOperationLowerExtension.h                                                //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Functions to lower HL operations coming from HLSL extensions to DXIL      //\n// operations.                                                               //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n#pragma once\n\n#include \"dxc/HLSL/HLSLExtensionsCodegenHelper.h\"\n#include \"llvm/ADT/StringRef.h\"\n#include <string>\n#include <unordered_map>\n\nnamespace llvm {\n  class Value;\n  class CallInst;\n  class Function;\n  class StringRef;\n  class Instruction;\n}\n\nnamespace hlsl {\n  class OP;\n\n  // Lowers HLSL extensions from HL operation to DXIL operation.\n  class ExtensionLowering {\n  public:\n    // Strategy used for lowering extensions.\n    enum class Strategy {\n      Unknown,        // Do not know how to lower. This is an error condition.\n      NoTranslation,  // Propagate the call arguments as is down to dxil.\n      Replicate,      // Scalarize the vector arguments and replicate the call.\n      Pack,           // Convert the vector arguments into structs.\n      Resource,       // Convert return value to resource return and explode vectors.\n    };\n\n    typedef std::unordered_map<llvm::Instruction *, llvm::Value *> HandleMap;\n\n    // Create the lowering using the given strategy and custom codegen helper.\n    ExtensionLowering(llvm::StringRef strategy, HLSLExtensionsCodegenHelper *helper, const HandleMap &handleMap, OP& hlslOp);\n    ExtensionLowering(Strategy strategy, HLSLExtensionsCodegenHelper *helper, const HandleMap &handleMap, OP& hlslOp);\n\n    // Translate the HL op call to a DXIL op call.\n    // Returns a new value if translation was successful.\n    // Returns nullptr if translation failed or made no changes.\n    llvm::Value *Translate(llvm::CallInst *CI);\n    \n    // Translate the strategy string to an enum. The strategy string is\n    // added as a custom attribute on the high level extension function.\n    // It is translated as follows:\n    //  \"r\" -> Replicate\n    //  \"n\" -> NoTranslation\n    //  \"c\" -> Custom\n    static Strategy GetStrategy(llvm::StringRef strategy);\n\n    // Translate the strategy enum into a name. This is the inverse of the\n    // GetStrategy() function.\n    static llvm::StringRef GetStrategyName(Strategy strategy);\n\n    // Get the name that will be used for the extension function call after\n    // lowering.\n    std::string GetExtensionName(llvm::CallInst *CI);\n\n  private:\n    Strategy m_strategy;\n    HLSLExtensionsCodegenHelper *m_helper;\n    const HandleMap &m_handleMap;\n    OP &m_hlslOp;\n\n    llvm::Value *Unknown(llvm::CallInst *CI);\n    llvm::Value *NoTranslation(llvm::CallInst *CI);\n    llvm::Value *Replicate(llvm::CallInst *CI);\n    llvm::Value *Pack(llvm::CallInst *CI);\n    llvm::Value *Resource(llvm::CallInst *CI);\n  };\n}"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/HLOperations.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// HLOperations.h                                                            //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Implentation of High Level DXIL operations.                               //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n#include <string>\n\nnamespace llvm {\nclass Module;\nclass Function;\nclass CallInst;\nclass Argument;\nclass StringRef;\nclass FunctionType;\n}\n\nnamespace hlsl {\n\nenum class HLOpcodeGroup {\n  NotHL,\n  HLExtIntrinsic,\n  HLIntrinsic,\n  HLCast,\n  HLInit,\n  HLBinOp,\n  HLUnOp,\n  HLSubscript,\n  HLMatLoadStore,\n  HLSelect,\n  NumOfHLOps\n};\n\nenum class HLBinaryOpcode {\n  Invalid,\n  Mul,\n  Div,\n  Rem,\n  Add,\n  Sub,\n  Shl,\n  Shr,\n  LT,\n  GT,\n  LE,\n  GE,\n  EQ,\n  NE,\n  And,\n  Xor,\n  Or,\n  LAnd,\n  LOr,\n  UDiv,\n  URem,\n  UShr,\n  ULT,\n  UGT,\n  ULE,\n  UGE,\n  NumOfBO,\n};\n\nenum class HLUnaryOpcode {\n  Invalid,\n  PostInc,\n  PostDec,\n  PreInc,\n  PreDec,\n  Plus,\n  Minus,\n  Not,\n  LNot,\n  NumOfUO,\n};\n\nenum class HLSubscriptOpcode {\n  DefaultSubscript,\n  ColMatSubscript,\n  RowMatSubscript,\n  ColMatElement,\n  RowMatElement,\n  DoubleSubscript,\n  CBufferSubscript,\n  VectorSubscript,   // Only for bool vector, other vector type will use GEP directly.\n};\n\nenum class HLCastOpcode {\n  DefaultCast,\n  UnsignedUnsignedCast,\n  FromUnsignedCast,\n  ToUnsignedCast,\n  ColMatrixToVecCast,\n  RowMatrixToVecCast,\n};\n\nenum class HLMatLoadStoreOpcode {\n  ColMatLoad,\n  ColMatStore,\n  RowMatLoad,\n  RowMatStore,\n};\n\nextern const char * const HLPrefix;\n\nHLOpcodeGroup GetHLOpcodeGroup(llvm::Function *F);\nHLOpcodeGroup GetHLOpcodeGroupByName(llvm::Function *F);\nllvm::StringRef GetHLOpcodeGroupNameByAttr(llvm::Function *F);\nllvm::StringRef GetHLLowerStrategy(llvm::Function *F);\nunsigned  GetHLOpcode(llvm::CallInst *CI);\nunsigned  GetRowMajorOpcode(HLOpcodeGroup group, unsigned opcode);\nvoid SetHLLowerStrategy(llvm::Function *F, llvm::StringRef S);\n\n// For intrinsic opcode.\nbool HasUnsignedOpcode(unsigned opcode);\nunsigned GetUnsignedOpcode(unsigned opcode);\n// For HLBinaryOpcode.\nbool HasUnsignedOpcode(HLBinaryOpcode opcode);\nHLBinaryOpcode GetUnsignedOpcode(HLBinaryOpcode opcode);\n\nllvm::StringRef GetHLOpcodeGroupName(HLOpcodeGroup op);\n\nnamespace HLOperandIndex {\n// Opcode parameter.\nconst unsigned kOpcodeIdx = 0;\n\n// Matrix store.\nconst unsigned kMatStoreDstPtrOpIdx = 1;\nconst unsigned kMatStoreValOpIdx = 2;\n\n// Matrix load.\nconst unsigned kMatLoadPtrOpIdx = 1;\n\n// Normal subscipts.\nconst unsigned kSubscriptObjectOpIdx = 1;\nconst unsigned kSubscriptIndexOpIdx = 2;\n\n// Double subscripts.\nconst unsigned kDoubleSubscriptMipLevelOpIdx = 3;\n\n// Matrix subscripts.\nconst unsigned kMatSubscriptMatOpIdx = 1;\nconst unsigned kMatSubscriptSubOpIdx = 2;\n\n// Matrix init.\nconst unsigned kMatArrayInitMatOpIdx = 1;\nconst unsigned kMatArrayInitFirstArgOpIdx = 2;\n\n// Array Init.\nconst unsigned kArrayInitPtrOpIdx = 1;\nconst unsigned kArrayInitFirstArgOpIdx = 2;\n\n// Normal Init.\nconst unsigned kInitFirstArgOpIdx = 1;\n\n// Unary operators.\nconst unsigned kUnaryOpSrc0Idx = 1;\n\n// Binary operators.\nconst unsigned kBinaryOpSrc0Idx = 1;\nconst unsigned kBinaryOpSrc1Idx = 2;\n\n// Trinary operators.\nconst unsigned kTrinaryOpSrc0Idx = 1;\nconst unsigned kTrinaryOpSrc1Idx = 2;\nconst unsigned kTrinaryOpSrc2Idx = 3;\n\n// Interlocked.\nconst unsigned kInterlockedDestOpIndex = 1;\nconst unsigned kInterlockedValueOpIndex = 2;\nconst unsigned kInterlockedOriginalValueOpIndex = 3;\n\n// InterlockedCompareExchange.\nconst unsigned kInterlockedCmpDestOpIndex = 1;\nconst unsigned kInterlockedCmpCompareValueOpIndex = 2;\nconst unsigned kInterlockedCmpValueOpIndex = 3;\nconst unsigned kInterlockedCmpOriginalValueOpIndex = 4;\n\n// Lerp.\nconst unsigned kLerpOpXIdx = 1;\nconst unsigned kLerpOpYIdx = 2;\nconst unsigned kLerpOpSIdx = 3;\n\n// ProcessTessFactorIsoline.\nconst unsigned kProcessTessFactorRawDetailFactor = 1;\nconst unsigned kProcessTessFactorRawDensityFactor = 2;\nconst unsigned kProcessTessFactorRoundedDetailFactor = 3;\nconst unsigned kProcessTessFactorRoundedDensityFactor = 4;\n\n// ProcessTessFactor.\nconst unsigned kProcessTessFactorRawEdgeFactor = 1;\nconst unsigned kProcessTessFactorInsideScale = 2;\nconst unsigned kProcessTessFactorRoundedEdgeFactor = 3;\nconst unsigned kProcessTessFactorRoundedInsideFactor = 4;\nconst unsigned kProcessTessFactorUnRoundedInsideFactor = 5;\n\n// Reflect.\nconst unsigned kReflectOpIIdx = 1;\nconst unsigned kReflectOpNIdx = 2;\n\n// Refract\nconst unsigned kRefractOpIIdx = 1;\nconst unsigned kRefractOpNIdx = 2;\nconst unsigned kRefractOpEtaIdx = 3;\n\n// SmoothStep.\nconst unsigned kSmoothStepOpMinIdx = 1;\nconst unsigned kSmoothStepOpMaxIdx = 2;\nconst unsigned kSmoothStepOpXIdx = 3;\n\n// Clamp\nconst unsigned kClampOpXIdx = 1;\nconst unsigned kClampOpMinIdx = 2;\nconst unsigned kClampOpMaxIdx = 3;\n\n\n// Object functions.\nconst unsigned kHandleOpIdx = 1;\n// Store.\nconst unsigned kStoreOffsetOpIdx = 2;\nconst unsigned kStoreValOpIdx = 3;\n// Load.\nconst unsigned kBufLoadAddrOpIdx = 2;\nconst unsigned kBufLoadStatusOpIdx = 3;\nconst unsigned kRWTexLoadStatusOpIdx = 3;\nconst unsigned kTexLoadOffsetOpIdx = 3;\nconst unsigned kTexLoadStatusOpIdx = 4;\n// Load for Texture2DMS\nconst unsigned kTex2DMSLoadSampleIdxOpIdx = 3;\nconst unsigned kTex2DMSLoadOffsetOpIdx = 4;\nconst unsigned kTex2DMSLoadStatusOpIdx = 5;\n// mips.Operator.\nconst unsigned kMipLoadAddrOpIdx = 3;\nconst unsigned kMipLoadOffsetOpIdx = 4;\nconst unsigned kMipLoadStatusOpIdx = 5;\n\n// Sample.\nconst unsigned kSampleSamplerArgIndex = 2;\nconst unsigned kSampleCoordArgIndex = 3;\nconst unsigned kSampleOffsetArgIndex = 4;\nconst unsigned kSampleClampArgIndex = 5;\nconst unsigned kSampleStatusArgIndex = 6;\n\n// SampleG.\nconst unsigned kSampleGDDXArgIndex = 4;\nconst unsigned kSampleGDDYArgIndex = 5;\nconst unsigned kSampleGOffsetArgIndex = 6;\nconst unsigned kSampleGClampArgIndex = 7;\nconst unsigned kSampleGStatusArgIndex = 8;\n\n// SampleCmp.\nconst unsigned kSampleCmpCmpValArgIndex = 4;\nconst unsigned kSampleCmpOffsetArgIndex = 5;\nconst unsigned kSampleCmpClampArgIndex = 6;\nconst unsigned kSampleCmpStatusArgIndex = 7;\n\n// SampleBias.\nconst unsigned kSampleBBiasArgIndex = 4;\nconst unsigned kSampleBOffsetArgIndex = 5;\nconst unsigned kSampleBClampArgIndex = 6;\nconst unsigned kSampleBStatusArgIndex = 7;\n\n// SampleLevel.\nconst unsigned kSampleLLevelArgIndex = 4;\nconst unsigned kSampleLOffsetArgIndex = 5;\nconst unsigned kSampleLStatusArgIndex = 6;\n\n// SampleCmpLevelZero.\nconst unsigned kSampleCmpLZCmpValArgIndex = 4;\nconst unsigned kSampleCmpLZOffsetArgIndex = 5;\nconst unsigned kSampleCmpLZStatusArgIndex = 6;\n\n// Gather.\nconst unsigned kGatherSamplerArgIndex = 2;\nconst unsigned kGatherCoordArgIndex = 3;\nconst unsigned kGatherOffsetArgIndex = 4;\nconst unsigned kGatherStatusArgIndex = 5;\nconst unsigned kGatherSampleOffsetArgIndex = 5;\nconst unsigned kGatherStatusWithSampleOffsetArgIndex = 8;\n\n// GatherCmp.\nconst unsigned kGatherCmpCmpValArgIndex = 4;\nconst unsigned kGatherCmpOffsetArgIndex = 5;\nconst unsigned kGatherCmpStatusArgIndex = 6;\nconst unsigned kGatherCmpSampleOffsetArgIndex = 6;\nconst unsigned kGatherCmpStatusWithSampleOffsetArgIndex = 9;\n\n// StreamAppend.\nconst unsigned kStreamAppendStreamOpIndex = 1;\nconst unsigned kStreamAppendDataOpIndex = 2;\n\n// Append.\nconst unsigned kAppendValOpIndex = 2;\n\n// Interlocked.\nconst unsigned kObjectInterlockedDestOpIndex = 2;\nconst unsigned kObjectInterlockedValueOpIndex = 3;\nconst unsigned kObjectInterlockedOriginalValueOpIndex = 4;\n\n// InterlockedCompareExchange.\nconst unsigned kObjectInterlockedCmpDestOpIndex = 2;\nconst unsigned kObjectInterlockedCmpCompareValueOpIndex = 3;\nconst unsigned kObjectInterlockedCmpValueOpIndex = 4;\nconst unsigned kObjectInterlockedCmpOriginalValueOpIndex = 5;\n\n// GetSamplePosition.\nconst unsigned kGetSamplePositionSampleIdxOpIndex = 2;\n\n// GetDimensions.\nconst unsigned kGetDimensionsMipLevelOpIndex = 2;\nconst unsigned kGetDimensionsMipWidthOpIndex = 3;\nconst unsigned kGetDimensionsNoMipWidthOpIndex = 2;\n\n// WaveAllEqual.\nconst unsigned kWaveAllEqualValueOpIdx = 1;\n\n} // namespace HLOperandIndex\n\nllvm::Function *GetOrCreateHLFunction(llvm::Module &M,\n                                      llvm::FunctionType *funcTy,\n                                      HLOpcodeGroup group, unsigned opcode);\nllvm::Function *GetOrCreateHLFunction(llvm::Module &M,\n                                      llvm::FunctionType *funcTy,\n                                      HLOpcodeGroup group,\n                                      llvm::StringRef *groupName,\n                                      llvm::StringRef *fnName,\n                                      unsigned opcode);\n\nllvm::Function *GetOrCreateHLFunctionWithBody(llvm::Module &M,\n                                              llvm::FunctionType *funcTy,\n                                              HLOpcodeGroup group,\n                                              unsigned opcode,\n                                              llvm::StringRef name);\n} // namespace hlsl"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/HLResource.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// HLResource.h                                                              //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Representation of HLSL SRVs and UAVs in high-level DX IR.                 //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n#include \"dxc/HLSL/DxilResource.h\"\n\n\nnamespace hlsl {\n\n/// Use this class to represent an HLSL resource (SRV/UAV) in HLDXIR.\nclass HLResource : public DxilResource {\npublic:\n  //QQQ\n  // TODO: this does not belong here. QQQ\n  //static Kind KeywordToKind(const std::string &keyword);\n  \n  HLResource();\n};\n\n} // namespace hlsl\n"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/HLSLExtensionsCodegenHelper.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// HLSLExtensionsCodegenHelper.h                                             //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Codegen support for hlsl extensions.                                      //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n#include <vector>\n#include <string>\n\nnamespace llvm {\nclass CallInst;\nclass Value;\nclass Module;\n}\n\nnamespace hlsl {\n\n// Provide DXIL codegen support for private HLSL extensions.\n// The HLSL extension mechanism has hooks for two cases:\n//\n//  1. You can mark certain defines as \"semantic\" defines which\n//     will be preserved as metadata in the final DXIL.\n//  2. You can add new HLSL intrinsic functions.\n//  3. You can read a root signature from a custom define.\n//\n// This class provides an interface for generating the DXIL bitcode\n// needed for the types of extensions above.\n//  \nclass HLSLExtensionsCodegenHelper {\npublic:\n  // Used to indicate a semantic define was used incorrectly.\n  // Since semantic defines have semantic meaning it is possible\n  // that a programmer can use them incorrectly. This class provides\n  // a way to signal the error to the programmer. Semantic define\n  // errors will be propagated as errors to the clang frontend.\n  class SemanticDefineError {\n  public:\n    enum class Level { Warning, Error };\n    SemanticDefineError(unsigned location, Level level, const std::string &message)\n    :  m_location(location)\n    ,  m_level(level)\n    ,  m_message(message)\n    { }\n\n    unsigned Location() const { return m_location; }\n    bool IsWarning() const { return m_level == Level::Warning; }\n    const std::string &Message() const { return m_message; }\n\n  private:\n    unsigned m_location; // Use an encoded clang::SourceLocation to avoid a clang include dependency.\n    Level m_level;\n    std::string m_message;\n  };\n  typedef std::vector<SemanticDefineError> SemanticDefineErrorList;\n\n  // Write semantic defines as metadata in the module.\n  virtual SemanticDefineErrorList WriteSemanticDefines(llvm::Module *M) = 0;\n\n  // Get the name to use for the dxil intrinsic function.\n  virtual std::string GetIntrinsicName(unsigned opcode) = 0;\n\n  // Struct to hold a root signature that is read from a define.\n  struct CustomRootSignature {\n    std::string RootSignature;\n    unsigned  EncodedSourceLocation;\n    enum Status { NOT_FOUND = 0, FOUND };\n  };\n\n  // Get custom defined root signature.\n  virtual CustomRootSignature::Status GetCustomRootSignature(CustomRootSignature *out) = 0;\n\n  // Virtual destructor.\n  virtual ~HLSLExtensionsCodegenHelper() {};\n};\n}\n"
  },
  {
    "path": "src/Wrapper/dxc/HLSL/ReducibilityAnalysis.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// ReducibilityAnalysis.h                                                    //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Implements reducibility analysis pass.                                    //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n\nnamespace llvm {\nclass Module;\nclass Function;\nclass PassRegistry;\nclass FunctionPass;\n\nenum class IrreducibilityAction {\n  ThrowException,\n  PrintLog,\n  Ignore,\n};\n\nextern char &ReducibilityAnalysisID;\n\nllvm::FunctionPass *createReducibilityAnalysisPass(IrreducibilityAction Action = IrreducibilityAction::ThrowException);\n\nvoid initializeReducibilityAnalysisPass(llvm::PassRegistry&);\n\nbool IsReducible(const llvm::Module &M, IrreducibilityAction Action = IrreducibilityAction::ThrowException);\nbool IsReducible(const llvm::Function &F, IrreducibilityAction Action = IrreducibilityAction::ThrowException);\n\n}\n"
  },
  {
    "path": "src/Wrapper/dxc/HlslIntrinsicOp.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// HlslIntrinsicOp.h                                                         //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Enumeration for HLSL intrinsics operations.                               //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\nnamespace hlsl\n{\n\nenum class IntrinsicOp\n{\n/* <py>\nimport hctdb_instrhelp\n</py> */\n\n/* <py::lines('HLSL-INTRINSICS')>hctdb_instrhelp.enum_hlsl_intrinsics()</py>*/\n// HLSL-INTRINSICS:BEGIN\n  IOP_AddUint64,\n  IOP_AllMemoryBarrier,\n  IOP_AllMemoryBarrierWithGroupSync,\n  IOP_CheckAccessFullyMapped,\n  IOP_D3DCOLORtoUBYTE4,\n  IOP_DeviceMemoryBarrier,\n  IOP_DeviceMemoryBarrierWithGroupSync,\n  IOP_EvaluateAttributeAtSample,\n  IOP_EvaluateAttributeCentroid,\n  IOP_EvaluateAttributeSnapped,\n  IOP_GetAttributeAtVertex,\n  IOP_GetRenderTargetSampleCount,\n  IOP_GetRenderTargetSamplePosition,\n  IOP_GroupMemoryBarrier,\n  IOP_GroupMemoryBarrierWithGroupSync,\n  IOP_InterlockedAdd,\n  IOP_InterlockedAnd,\n  IOP_InterlockedCompareExchange,\n  IOP_InterlockedCompareStore,\n  IOP_InterlockedExchange,\n  IOP_InterlockedMax,\n  IOP_InterlockedMin,\n  IOP_InterlockedOr,\n  IOP_InterlockedXor,\n  IOP_NonUniformResourceIndex,\n  IOP_Process2DQuadTessFactorsAvg,\n  IOP_Process2DQuadTessFactorsMax,\n  IOP_Process2DQuadTessFactorsMin,\n  IOP_ProcessIsolineTessFactors,\n  IOP_ProcessQuadTessFactorsAvg,\n  IOP_ProcessQuadTessFactorsMax,\n  IOP_ProcessQuadTessFactorsMin,\n  IOP_ProcessTriTessFactorsAvg,\n  IOP_ProcessTriTessFactorsMax,\n  IOP_ProcessTriTessFactorsMin,\n  IOP_QuadReadAcrossDiagonal,\n  IOP_QuadReadAcrossX,\n  IOP_QuadReadAcrossY,\n  IOP_QuadReadLaneAt,\n  IOP_WaveActiveAllEqual,\n  IOP_WaveActiveAllTrue,\n  IOP_WaveActiveAnyTrue,\n  IOP_WaveActiveBallot,\n  IOP_WaveActiveBitAnd,\n  IOP_WaveActiveBitOr,\n  IOP_WaveActiveBitXor,\n  IOP_WaveActiveCountBits,\n  IOP_WaveActiveMax,\n  IOP_WaveActiveMin,\n  IOP_WaveActiveProduct,\n  IOP_WaveActiveSum,\n  IOP_WaveGetLaneCount,\n  IOP_WaveGetLaneIndex,\n  IOP_WaveIsFirstLane,\n  IOP_WavePrefixCountBits,\n  IOP_WavePrefixProduct,\n  IOP_WavePrefixSum,\n  IOP_WaveReadLaneAt,\n  IOP_WaveReadLaneFirst,\n  IOP_abort,\n  IOP_abs,\n  IOP_acos,\n  IOP_all,\n  IOP_any,\n  IOP_asdouble,\n  IOP_asfloat,\n  IOP_asin,\n  IOP_asint,\n  IOP_asuint,\n  IOP_atan,\n  IOP_atan2,\n  IOP_ceil,\n  IOP_clamp,\n  IOP_clip,\n  IOP_cos,\n  IOP_cosh,\n  IOP_countbits,\n  IOP_cross,\n  IOP_ddx,\n  IOP_ddx_coarse,\n  IOP_ddx_fine,\n  IOP_ddy,\n  IOP_ddy_coarse,\n  IOP_ddy_fine,\n  IOP_degrees,\n  IOP_determinant,\n  IOP_distance,\n  IOP_dot,\n  IOP_dst,\n  IOP_exp,\n  IOP_exp2,\n  IOP_f16tof32,\n  IOP_f32tof16,\n  IOP_faceforward,\n  IOP_firstbithigh,\n  IOP_firstbitlow,\n  IOP_floor,\n  IOP_fma,\n  IOP_fmod,\n  IOP_frac,\n  IOP_frexp,\n  IOP_fwidth,\n  IOP_isfinite,\n  IOP_isinf,\n  IOP_isnan,\n  IOP_ldexp,\n  IOP_length,\n  IOP_lerp,\n  IOP_lit,\n  IOP_log,\n  IOP_log10,\n  IOP_log2,\n  IOP_mad,\n  IOP_max,\n  IOP_min,\n  IOP_modf,\n  IOP_msad4,\n  IOP_mul,\n  IOP_normalize,\n  IOP_pow,\n  IOP_radians,\n  IOP_rcp,\n  IOP_reflect,\n  IOP_refract,\n  IOP_reversebits,\n  IOP_round,\n  IOP_rsqrt,\n  IOP_saturate,\n  IOP_sign,\n  IOP_sin,\n  IOP_sincos,\n  IOP_sinh,\n  IOP_smoothstep,\n  IOP_source_mark,\n  IOP_sqrt,\n  IOP_step,\n  IOP_tan,\n  IOP_tanh,\n  IOP_tex1D,\n  IOP_tex1Dbias,\n  IOP_tex1Dgrad,\n  IOP_tex1Dlod,\n  IOP_tex1Dproj,\n  IOP_tex2D,\n  IOP_tex2Dbias,\n  IOP_tex2Dgrad,\n  IOP_tex2Dlod,\n  IOP_tex2Dproj,\n  IOP_tex3D,\n  IOP_tex3Dbias,\n  IOP_tex3Dgrad,\n  IOP_tex3Dlod,\n  IOP_tex3Dproj,\n  IOP_texCUBE,\n  IOP_texCUBEbias,\n  IOP_texCUBEgrad,\n  IOP_texCUBElod,\n  IOP_texCUBEproj,\n  IOP_transpose,\n  IOP_trunc,\n  MOP_Append,\n  MOP_RestartStrip,\n  MOP_CalculateLevelOfDetail,\n  MOP_CalculateLevelOfDetailUnclamped,\n  MOP_GetDimensions,\n  MOP_Load,\n  MOP_Sample,\n  MOP_SampleBias,\n  MOP_SampleCmp,\n  MOP_SampleCmpLevelZero,\n  MOP_SampleGrad,\n  MOP_SampleLevel,\n  MOP_Gather,\n  MOP_GatherAlpha,\n  MOP_GatherBlue,\n  MOP_GatherCmp,\n  MOP_GatherCmpAlpha,\n  MOP_GatherCmpBlue,\n  MOP_GatherCmpGreen,\n  MOP_GatherCmpRed,\n  MOP_GatherGreen,\n  MOP_GatherRed,\n  MOP_GetSamplePosition,\n  MOP_Load2,\n  MOP_Load3,\n  MOP_Load4,\n  MOP_InterlockedAdd,\n  MOP_InterlockedAnd,\n  MOP_InterlockedCompareExchange,\n  MOP_InterlockedCompareStore,\n  MOP_InterlockedExchange,\n  MOP_InterlockedMax,\n  MOP_InterlockedMin,\n  MOP_InterlockedOr,\n  MOP_InterlockedXor,\n  MOP_Store,\n  MOP_Store2,\n  MOP_Store3,\n  MOP_Store4,\n  MOP_DecrementCounter,\n  MOP_IncrementCounter,\n  MOP_Consume,\n  // unsigned\n  IOP_InterlockedUMax,\n  IOP_InterlockedUMin,\n  IOP_WaveActiveUMax,\n  IOP_WaveActiveUMin,\n  IOP_WaveActiveUProduct,\n  IOP_WaveActiveUSum,\n  IOP_WavePrefixUProduct,\n  IOP_WavePrefixUSum,\n  IOP_uclamp,\n  IOP_ufirstbithigh,\n  IOP_umad,\n  IOP_umax,\n  IOP_umin,\n  IOP_umul,\n  MOP_InterlockedUMax,\n  MOP_InterlockedUMin,\n  Num_Intrinsics,\n// HLSL-INTRINSICS:END\n};\n\ninline bool HasUnsignedIntrinsicOpcode(IntrinsicOp opcode) {\n  switch (opcode) {\n/* <py>\nimport hctdb_instrhelp\n</py> */\n\n/* <py::lines('HLSL-HAS-UNSIGNED-INTRINSICS')>hctdb_instrhelp.has_unsigned_hlsl_intrinsics()</py>*/\n// HLSL-HAS-UNSIGNED-INTRINSICS:BEGIN\n  case IntrinsicOp::IOP_InterlockedMax:\n  case IntrinsicOp::IOP_InterlockedMin:\n  case IntrinsicOp::IOP_WaveActiveMax:\n  case IntrinsicOp::IOP_WaveActiveMin:\n  case IntrinsicOp::IOP_WaveActiveProduct:\n  case IntrinsicOp::IOP_WaveActiveSum:\n  case IntrinsicOp::IOP_WavePrefixProduct:\n  case IntrinsicOp::IOP_WavePrefixSum:\n  case IntrinsicOp::IOP_clamp:\n  case IntrinsicOp::IOP_firstbithigh:\n  case IntrinsicOp::IOP_mad:\n  case IntrinsicOp::IOP_max:\n  case IntrinsicOp::IOP_min:\n  case IntrinsicOp::IOP_mul:\n  case IntrinsicOp::MOP_InterlockedMax:\n  case IntrinsicOp::MOP_InterlockedMin:\n// HLSL-HAS-UNSIGNED-INTRINSICS:END\n    return true;\n  default:\n    return false;\n  }\n}\n\ninline unsigned GetUnsignedIntrinsicOpcode(IntrinsicOp opcode) {\n  switch (opcode) {\n/* <py>\nimport hctdb_instrhelp\n</py> */\n\n/* <py::lines('HLSL-GET-UNSIGNED-INTRINSICS')>hctdb_instrhelp.get_unsigned_hlsl_intrinsics()</py>*/\n// HLSL-GET-UNSIGNED-INTRINSICS:BEGIN\n  case IntrinsicOp::IOP_InterlockedMax:\n    return static_cast<unsigned>(IntrinsicOp::IOP_InterlockedUMax);\n  case IntrinsicOp::IOP_InterlockedMin:\n    return static_cast<unsigned>(IntrinsicOp::IOP_InterlockedUMin);\n  case IntrinsicOp::IOP_WaveActiveMax:\n    return static_cast<unsigned>(IntrinsicOp::IOP_WaveActiveUMax);\n  case IntrinsicOp::IOP_WaveActiveMin:\n    return static_cast<unsigned>(IntrinsicOp::IOP_WaveActiveUMin);\n  case IntrinsicOp::IOP_WaveActiveProduct:\n    return static_cast<unsigned>(IntrinsicOp::IOP_WaveActiveUProduct);\n  case IntrinsicOp::IOP_WaveActiveSum:\n    return static_cast<unsigned>(IntrinsicOp::IOP_WaveActiveUSum);\n  case IntrinsicOp::IOP_WavePrefixProduct:\n    return static_cast<unsigned>(IntrinsicOp::IOP_WavePrefixUProduct);\n  case IntrinsicOp::IOP_WavePrefixSum:\n    return static_cast<unsigned>(IntrinsicOp::IOP_WavePrefixUSum);\n  case IntrinsicOp::IOP_clamp:\n    return static_cast<unsigned>(IntrinsicOp::IOP_uclamp);\n  case IntrinsicOp::IOP_firstbithigh:\n    return static_cast<unsigned>(IntrinsicOp::IOP_ufirstbithigh);\n  case IntrinsicOp::IOP_mad:\n    return static_cast<unsigned>(IntrinsicOp::IOP_umad);\n  case IntrinsicOp::IOP_max:\n    return static_cast<unsigned>(IntrinsicOp::IOP_umax);\n  case IntrinsicOp::IOP_min:\n    return static_cast<unsigned>(IntrinsicOp::IOP_umin);\n  case IntrinsicOp::IOP_mul:\n    return static_cast<unsigned>(IntrinsicOp::IOP_umul);\n  case IntrinsicOp::MOP_InterlockedMax:\n    return static_cast<unsigned>(IntrinsicOp::MOP_InterlockedUMax);\n  case IntrinsicOp::MOP_InterlockedMin:\n    return static_cast<unsigned>(IntrinsicOp::MOP_InterlockedUMin);\n// HLSL-GET-UNSIGNED-INTRINSICS:END\n  default:\n    return static_cast<unsigned>(opcode);\n  }\n}\n\n}\n"
  },
  {
    "path": "src/Wrapper/dxc/Support/CMakeLists.txt",
    "content": "# Copyright (C) Microsoft Corporation. All rights reserved.\n# This file is distributed under the University of Illinois Open Source License. See LICENSE.TXT for details.\n# TableGen HLSL options.\nset(LLVM_TARGET_DEFINITIONS HLSLOptions.td)\ntablegen(LLVM HLSLOptions.inc -gen-opt-parser-defs)\nadd_public_tablegen_target(TablegenHLSLOptions)\n"
  },
  {
    "path": "src/Wrapper/dxc/Support/DxcLangExtensionsHelper.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// DxcLangExtensionsHelper.h                                                 //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Provides a helper class to implement language extensions to HLSL.         //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#ifndef __DXCLANGEXTENSIONSHELPER_H__\n#define __DXCLANGEXTENSIONSHELPER_H__\n\n#include \"dxc/Support/Unicode.h\"\n#include \"dxc/Support/FileIOHelper.h\"\n#include <vector>\n\nnamespace llvm {\nclass raw_string_ostream;\nclass CallInst;\nclass Value;\n}\nnamespace clang {\nclass CompilerInstance;\n}\n\nnamespace hlsl {\n\nclass DxcLangExtensionsHelper : public DxcLangExtensionsHelperApply {\nprivate:\n  llvm::SmallVector<std::string, 2> m_semanticDefines;\n  llvm::SmallVector<std::string, 2> m_semanticDefineExclusions;\n  llvm::SmallVector<std::string, 2> m_defines;\n  llvm::SmallVector<CComPtr<IDxcIntrinsicTable>, 2> m_intrinsicTables;\n  CComPtr<IDxcSemanticDefineValidator> m_semanticDefineValidator;\n  std::string m_semanticDefineMetaDataName;\n\n  HRESULT STDMETHODCALLTYPE RegisterIntoVector(LPCWSTR name, llvm::SmallVector<std::string, 2>& here)\n  {\n    try {\n      IFTPTR(name);\n      std::string s;\n      if (!Unicode::UTF16ToUTF8String(name, &s)) {\n        throw ::hlsl::Exception(E_INVALIDARG);\n      }\n      here.push_back(s);\n      return S_OK;\n    }\n    CATCH_CPP_RETURN_HRESULT();\n  }\n\npublic:\n  const llvm::SmallVector<std::string, 2>& GetSemanticDefines() const { return m_semanticDefines; }\n  const llvm::SmallVector<std::string, 2>& GetSemanticDefineExclusions() const { return m_semanticDefineExclusions; }\n  const llvm::SmallVector<std::string, 2>& GetDefines() const { return m_defines; }\n  llvm::SmallVector<CComPtr<IDxcIntrinsicTable>, 2>& GetIntrinsicTables(){ return m_intrinsicTables; }\n  const std::string &GetSemanticDefineMetadataName() { return m_semanticDefineMetaDataName; }\n\n  HRESULT STDMETHODCALLTYPE RegisterSemanticDefine(LPCWSTR name)\n  {\n    return RegisterIntoVector(name, m_semanticDefines);\n  }\n\n  HRESULT STDMETHODCALLTYPE RegisterSemanticDefineExclusion(LPCWSTR name)\n  {\n    return RegisterIntoVector(name, m_semanticDefineExclusions);\n  }\n\n  HRESULT STDMETHODCALLTYPE RegisterDefine(LPCWSTR name)\n  {\n    return RegisterIntoVector(name, m_defines);\n  }\n\n  HRESULT STDMETHODCALLTYPE RegisterIntrinsicTable(_In_ IDxcIntrinsicTable* pTable)\n  {\n    try {\n      IFTPTR(pTable);\n      LPCSTR tableName = nullptr;\n      IFT(pTable->GetTableName(&tableName));\n      IFTPTR(tableName);\n      IFTARG(strcmp(tableName, \"op\") != 0);   // \"op\" is reserved for builtin intrinsics\n      for (auto &&table : m_intrinsicTables) {\n        LPCSTR otherTableName = nullptr;\n        IFT(table->GetTableName(&otherTableName));\n        IFTPTR(otherTableName);\n        IFTARG(strcmp(tableName, otherTableName) != 0); // Added a duplicate table name\n      }\n      m_intrinsicTables.push_back(pTable);\n      return S_OK;\n    }\n    CATCH_CPP_RETURN_HRESULT();\n  }\n\n  // Set the validator used to validate semantic defines.\n  // Only one validator stored and used to run validation.\n  HRESULT STDMETHODCALLTYPE SetSemanticDefineValidator(_In_ IDxcSemanticDefineValidator* pValidator) {\n    if (pValidator == nullptr)\n      return E_POINTER;\n\n    m_semanticDefineValidator = pValidator;\n    return S_OK;\n  }\n\n  HRESULT STDMETHODCALLTYPE SetSemanticDefineMetaDataName(LPCSTR name) {\n    try {\n      m_semanticDefineMetaDataName = name;\n      return S_OK;\n    }\n    CATCH_CPP_RETURN_HRESULT();\n  }\n\n  // Get the name of the dxil intrinsic function.\n  std::string GetIntrinsicName(UINT opcode) {\n    LPCSTR pName = \"\";\n    for (IDxcIntrinsicTable *table : m_intrinsicTables) {\n      if (SUCCEEDED(table->GetIntrinsicName(opcode, &pName))) {\n        return pName;\n      }\n    }\n\n      return \"\";\n  }\n\n  // Result of validating a semantic define.\n  // Stores any warning or error messages produced by the validator.\n  // Successful validation means that there are no warning or error messages.\n  struct SemanticDefineValidationResult {\n    std::string Warning;\n    std::string Error;\n\n    bool HasError() { return Error.size() > 0; }\n    bool HasWarning() { return Warning.size() > 0; }\n\n    static SemanticDefineValidationResult Success() {\n      return SemanticDefineValidationResult();\n    }\n  };\n\n  // Use the contained semantice define validator to validate the given semantic define.\n  SemanticDefineValidationResult ValidateSemanticDefine(const std::string &name, const std::string &value) {\n    if (!m_semanticDefineValidator)\n      return SemanticDefineValidationResult::Success();\n\n    // Blobs for getting restul from validator. Strings for returning results to caller.\n    CComPtr<IDxcBlobEncoding> pError;\n    CComPtr<IDxcBlobEncoding> pWarning;\n    std::string error;\n    std::string warning;\n\n    // Run semantic define validator.\n    HRESULT result = m_semanticDefineValidator->GetSemanticDefineWarningsAndErrors(name.c_str(), value.c_str(), &pWarning, &pError);\n\n\n    if (FAILED(result)) {\n      // Failure indicates it was not able to even run validation so\n      // we cannot say whether the define is invalid or not. Return a\n      // generic error message about failure to run the valiadator.\n      error = \"failed to run semantic define validator for: \";\n      error.append(name); error.append(\"=\"); error.append(value);\n      return SemanticDefineValidationResult{ warning, error };\n    }\n\n    // Define a  little function to convert encoded blob into a string.\n    auto GetErrorAsString = [&name](const CComPtr<IDxcBlobEncoding> &pBlobString) -> std::string {\n      CComPtr<IDxcBlobEncoding> pUTF8BlobStr;\n      if (SUCCEEDED(hlsl::DxcGetBlobAsUtf8(pBlobString, &pUTF8BlobStr)))\n        return std::string(static_cast<char*>(pUTF8BlobStr->GetBufferPointer()), pUTF8BlobStr->GetBufferSize());\n      else\n        return std::string(\"invalid semantic define \" + name);\n    };\n\n    // Check to see if any warnings or errors were produced.\n    if (pError && pError->GetBufferSize()) {\n      error = GetErrorAsString(pError);\n    }\n    if (pWarning && pWarning->GetBufferSize()) {\n      warning = GetErrorAsString(pWarning);\n    }\n\n    return SemanticDefineValidationResult{ warning, error };\n  }\n\n  __override void SetupSema(clang::Sema &S) {\n    clang::ExternalASTSource *astSource = S.getASTContext().getExternalSource();\n    if (clang::ExternalSemaSource *externalSema =\n            llvm::dyn_cast_or_null<clang::ExternalSemaSource>(astSource)) {\n      for (auto &&table : m_intrinsicTables) {\n        hlsl::RegisterIntrinsicTable(externalSema, table);\n      }\n    }\n  }\n\n  __override void SetupPreprocessorOptions(clang::PreprocessorOptions &PPOpts) {\n    for (const auto & define : m_defines) {\n      PPOpts.addMacroDef(llvm::StringRef(define.c_str()));\n    }\n  }\n\n  __override DxcLangExtensionsHelper *GetDxcLangExtensionsHelper() {\n    return this;\n  }\n \n  DxcLangExtensionsHelper()\n  : m_semanticDefineMetaDataName(\"hlsl.semdefs\")\n  {}\n};\n\n// Use this macro to embed an implementation that will delegate to a field.\n// Note that QueryInterface still needs to return the vtable.\n#define DXC_LANGEXTENSIONS_HELPER_IMPL(_helper_field_) \\\n  __override HRESULT STDMETHODCALLTYPE RegisterIntrinsicTable(_In_ IDxcIntrinsicTable *pTable) { \\\n    return (_helper_field_).RegisterIntrinsicTable(pTable); \\\n  } \\\n  __override HRESULT STDMETHODCALLTYPE RegisterSemanticDefine(LPCWSTR name) { \\\n    return (_helper_field_).RegisterSemanticDefine(name); \\\n  } \\\n  __override HRESULT STDMETHODCALLTYPE RegisterSemanticDefineExclusion(LPCWSTR name) { \\\n    return (_helper_field_).RegisterSemanticDefineExclusion(name); \\\n  } \\\n  __override HRESULT STDMETHODCALLTYPE RegisterDefine(LPCWSTR name) { \\\n    return (_helper_field_).RegisterDefine(name); \\\n  } \\\n  __override HRESULT STDMETHODCALLTYPE SetSemanticDefineValidator(_In_ IDxcSemanticDefineValidator* pValidator) { \\\n    return (_helper_field_).SetSemanticDefineValidator(pValidator); \\\n  } \\\n  __override HRESULT STDMETHODCALLTYPE SetSemanticDefineMetaDataName(LPCSTR name) { \\\n    return (_helper_field_).SetSemanticDefineMetaDataName(name); \\\n  } \\\n\n// A parsed semantic define is a semantic define that has actually been\n// parsed by the compiler. It has a name (required), a value (could be\n// the empty string), and a location. We use an encoded clang::SourceLocation\n// for the location to avoid a clang include dependency.\nstruct ParsedSemanticDefine{\n  std::string Name;\n  std::string Value;\n  unsigned Location;\n};\ntypedef std::vector<ParsedSemanticDefine> ParsedSemanticDefineList;\n\n// Return the collection of semantic defines parsed by the compiler instance.\nParsedSemanticDefineList\n  CollectSemanticDefinesParsedByCompiler(clang::CompilerInstance &compiler,\n                                         _In_ DxcLangExtensionsHelper *helper);\n\n} // namespace hlsl\n\n#endif\n"
  },
  {
    "path": "src/Wrapper/dxc/Support/ErrorCodes.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// ErrorCodes.h                                                              //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Provides error code values for the DirectX compiler and tools.            //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n\n// Redeclare some macros to not depend on winerror.h\n#define DXC_SEVERITY_ERROR      1\n#define DXC_MAKE_HRESULT(sev,fac,code) \\\n    ((HRESULT) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) )\n\n#define HRESULT_IS_WIN32ERR(hr) ((hr & 0xFFFF0000) == MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, 0))\n#define HRESULT_AS_WIN32ERR(hr) (HRESULT_CODE(hr))\n\n// Error codes from C libraries (0n150) - 0x8096xxxx\n#define FACILITY_ERRNO          (0x96)\n#define HRESULT_FROM_ERRNO(x)   MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_ERRNO,(x))\n\n// Error codes from DXC libraries (0n170) - 0x8013xxxx\n#define FACILITY_DXC             (0xAA)\n\n// 0x00000000 - The operation succeeded.\n#define DXC_S_OK                        0 // _HRESULT_TYPEDEF_(0x00000000L)\n\n// 0x80AA0001 - The operation failed because overlapping semantics were found.\n#define DXC_E_OVERLAPPING_SEMANTICS                   DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0001))\n\n// 0x80AA0002 - The operation failed because multiple depth semantics were found.\n#define DXC_E_MULTIPLE_DEPTH_SEMANTICS                DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0002))\n\n// 0x80AA0003 - Input file is too large.\n#define DXC_E_INPUT_FILE_TOO_LARGE                    DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0003))\n\n// 0x80AA0004 - Error parsing DXBC container.\n#define DXC_E_INCORRECT_DXBC                          DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0004))\n\n// 0x80AA0005 - Error parsing DXBC bytecode.\n#define DXC_E_ERROR_PARSING_DXBC_BYTECODE             DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0005))\n\n// 0x80AA0006 - Data is too large.\n#define DXC_E_DATA_TOO_LARGE                          DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0006))\n\n// 0x80AA0007 - Incompatible converter options.\n#define DXC_E_INCOMPATIBLE_CONVERTER_OPTIONS          DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0007))\n\n// 0x80AA0008 - Irreducible control flow graph.\n#define DXC_E_IRREDUCIBLE_CFG                         DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0008))\n\n// 0x80AA0009 - IR verification error.\n#define DXC_E_IR_VERIFICATION_FAILED                  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0009))\n\n// 0x80AA000A - Scope-nested control flow recovery failed.\n#define DXC_E_SCOPE_NESTED_FAILED                     DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x000A))\n\n// 0x80AA000B - Operation is not supported.\n#define DXC_E_NOT_SUPPORTED                           DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x000B))\n\n// 0x80AA000C - Unable to encode string.\n#define DXC_E_STRING_ENCODING_FAILED                  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x000C))\n\n// 0x80AA000D - DXIL container is invalid.\n#define DXC_E_CONTAINER_INVALID                       DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x000D))\n\n// 0x80AA000E - DXIL container is missing the DXIL part.\n#define DXC_E_CONTAINER_MISSING_DXIL                  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x000E))\n\n// 0x80AA000F - Unable to parse DxilModule metadata.\n#define DXC_E_INCORRECT_DXIL_METADATA                 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x000F))\n\n// 0x80AA0010 - Error parsing DDI signature.\n#define DXC_E_INCORRECT_DDI_SIGNATURE                 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0010))\n\n// 0x80AA0011 - Duplicate part exists in dxil container.\n#define DXC_E_DUPLICATE_PART                          DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0011))\n\n// 0x80AA0012 - Error finding part in dxil container.\n#define DXC_E_MISSING_PART                            DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0012))\n\n// 0x80AA0013 - Malformed DXIL Container.\n#define DXC_E_MALFORMED_CONTAINER                     DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0013))\n\n// 0x80AA0014 - Incorrect Root Signature for shader.\n#define DXC_E_INCORRECT_ROOT_SIGNATURE                DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0014))\n\n// 0X80AA0015 - DXIL container is missing DebugInfo part.\n#define DXC_E_CONTAINER_MISSING_DEBUG                 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0015))\n\n// 0X80AA0016 - Unexpected failure in macro expansion.\n#define DXC_E_MACRO_EXPANSION_FAILURE                 DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0016))"
  },
  {
    "path": "src/Wrapper/dxc/Support/FileIOHelper.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// FileIOHelper.h                                                            //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Provides utitlity functions to work with files.                           //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n// Forward declarations.\nstruct IDxcBlob;\nstruct IDxcBlobEncoding;\n\nnamespace hlsl {\n\nvoid ReadBinaryFile(_In_z_ LPCWSTR pFileName,\n                    _Outptr_result_bytebuffer_(*pDataSize) void **ppData,\n                    _Out_ DWORD *pDataSize);\nvoid WriteBinaryFile(_In_z_ LPCWSTR pFileName,\n                     _In_reads_bytes_(DataSize) const void *pData,\n                     _In_ DWORD DataSize);\n\n///////////////////////////////////////////////////////////////////////////////\n// Blob and encoding manipulation functions.\n\nUINT32 DxcCodePageFromBytes(_In_count_(byteLen) const char *bytes,\n                            size_t byteLen) throw();\n\nHRESULT DxcCreateBlobFromFile(LPCWSTR pFileName, _In_opt_ UINT32 *pCodePage,\n                              _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) throw();\n\n// Given a blob, creates a subrange view.\nHRESULT DxcCreateBlobFromBlob(_In_ IDxcBlob *pBlob, UINT32 offset,\n                              UINT32 length,\n                              _COM_Outptr_ IDxcBlob **ppResult) throw();\n\nHRESULT\nDxcCreateBlobOnHeap(_In_bytecount_(size) LPCVOID pData, UINT32 size,\n                    _COM_Outptr_ IDxcBlob **ppResult) throw();\n\nHRESULT\nDxcCreateBlobOnHeapCopy(_In_bytecount_(size) LPCVOID pData, UINT32 size,\n                        _COM_Outptr_ IDxcBlob **ppResult) throw();\n\n// Given a blob, creates a new instance with a specific code page set.\nHRESULT\nDxcCreateBlobWithEncodingSet(_In_ IDxcBlob *pBlob, UINT32 codePage,\n                             _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) throw();\n\nHRESULT DxcCreateBlobWithEncodingFromPinned(\n    _In_bytecount_(size) LPCVOID pText, UINT32 size, UINT32 codePage,\n    _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) throw();\n\nHRESULT\nDxcCreateBlobWithEncodingFromStream(\n    IStream *pStream, bool newInstanceAlways, UINT32 codePage,\n    _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) throw();\n\nHRESULT\nDxcCreateBlobWithEncodingOnHeap(_In_bytecount_(size) LPCVOID pText, UINT32 size,\n                                UINT32 codePage,\n                                _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) throw();\n\nHRESULT\nDxcCreateBlobWithEncodingOnHeapCopy(\n    _In_bytecount_(size) LPCVOID pText, UINT32 size, UINT32 codePage,\n    _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) throw();\n\nHRESULT\nDxcCreateBlobWithEncodingOnMalloc(\n  _In_bytecount_(size) LPCVOID pText, IMalloc *pIMalloc, UINT32 size, UINT32 codePage,\n  _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) throw();\n\nHRESULT DxcGetBlobAsUtf8(_In_ IDxcBlob *pBlob,\n                         _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) throw();\nHRESULT\nDxcGetBlobAsUtf8NullTerm(\n    _In_ IDxcBlob *pBlob,\n    _COM_Outptr_ IDxcBlobEncoding **ppBlobEncoding) throw();\n\nHRESULT DxcGetBlobAsUtf16(_In_ IDxcBlob *pBlob,\n                          _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) throw();\n\nbool IsBlobNullOrEmpty(_In_opt_ IDxcBlob *pBlob) throw();\n\n///////////////////////////////////////////////////////////////////////////////\n// Stream implementations.\nclass AbstractMemoryStream : public IStream {\npublic:\n  virtual LPBYTE GetPtr() throw() = 0;\n  virtual ULONG GetPtrSize() throw() = 0;\n  virtual LPBYTE Detach() throw() = 0;\n  virtual UINT64 GetPosition() throw() = 0;\n  virtual HRESULT Reserve(ULONG targetSize) throw() = 0;\n};\nHRESULT CreateMemoryStream(_In_ IMalloc *pMalloc, _COM_Outptr_ AbstractMemoryStream** ppResult) throw();\nHRESULT CreateReadOnlyBlobStream(_In_ IDxcBlob *pSource, _COM_Outptr_ IStream** ppResult) throw();\n\ntemplate <typename T>\nHRESULT WriteStreamValue(AbstractMemoryStream *pStream, const T& value) {\n  ULONG cb;\n  return pStream->Write(&value, sizeof(value), &cb);\n}\n\n} // namespace hlsl\n"
  },
  {
    "path": "src/Wrapper/dxc/Support/Global.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// Global.h                                                                  //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Provides important declarations global to all DX Compiler code.          //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n// Redeclare some macros to not depend on winerror.h\n#define DXC_FAILED(hr) (((HRESULT)(hr)) < 0)\n#ifndef _HRESULT_DEFINED\n#define _HRESULT_DEFINED\n#ifndef _Return_type_success_\ntypedef long HRESULT;\n#else\ntypedef _Return_type_success_(return >= 0) long HRESULT;\n#endif // _Return_type_success_\n#endif // !_HRESULT_DEFINED\n\n#include <stdarg.h>\n#include \"dxc/Support/Exception.h\"\n\nnamespace std { class error_code; }\nvoid CheckLLVMErrorCode(const std::error_code &ec);\n\n\n/******************************************************************************\n                          Project-wide macros\n******************************************************************************/\n#define SAFE_RELEASE(p)       { if (p) { (p)->Release();  (p) = nullptr; } }\n#define SAFE_ADDREF(p)        { if (p) { (p)->AddRef();               } }\n\n#define SAFE_DELETE_ARRAY(p)  { delete [](p); p = nullptr; }\n#define SAFE_DELETE(p)        { delete (p); p = nullptr;  }\n\n// VH is used in other DXC projects, but it's also a typedef in llvm.\n// Use the IFC (IfFailedCleanup) set of conventions.\n#define IFC(x)      { hr = (x); if (DXC_FAILED(hr)) goto Cleanup; }\n#define IFR(x)      { HRESULT __hr = (x); if (DXC_FAILED(__hr)) return __hr; }\n#define IFRBOOL(x,y){ if (!(x)) return (y); }\n#define IFCBOOL(x,y){ if (!(x)) { hr = (y); goto Cleanup; } }\n#define IFCOOM(x)   { if (nullptr == (x)) { hr = E_OUTOFMEMORY; goto Cleanup; } }\n#define IFROOM(x)   { if (nullptr == (x)) { return E_OUTOFMEMORY; } }\n#define IFCPTR(x)   { if (nullptr == (x)) { hr = E_POINTER; goto Cleanup; }}\n#define IFT(x)      { HRESULT __hr = (x); if (DXC_FAILED(__hr)) throw ::hlsl::Exception(__hr); }\n#define IFTBOOL(x,y){ if (!(x)) throw ::hlsl::Exception(y); }\n#define IFTOOM(x)   { if (nullptr == (x)) { throw ::hlsl::Exception(E_OUTOFMEMORY); }}\n#define IFTPTR(x)   { if (nullptr == (x)) { throw ::hlsl::Exception(E_POINTER); }}\n#define IFTARG(x)   { if (!(x)) { throw ::hlsl::Exception(E_INVALIDARG); }}\n#define IFTLLVM(x)  { CheckLLVMErrorCode(x); }\n#define IFTMSG(x, msg) { HRESULT __hr = (x); if (DXC_FAILED(__hr)) throw ::hlsl::Exception(__hr, msg); }\n#define IFTBOOLMSG(x, y, msg) { if (!(x)) throw ::hlsl::Exception(y, msg); }\n\n// Propagate an C++ exception into an HRESULT.\n#define CATCH_CPP_ASSIGN_HRESULT() \\\n  catch (std::bad_alloc&)                   { hr = E_OUTOFMEMORY; } \\\n  catch (hlsl::Exception& _hlsl_exception_) {                       \\\n    _Analysis_assume_(DXC_FAILED(_hlsl_exception_.hr));             \\\n    hr = _hlsl_exception_.hr;                                       \\\n  }                                                                 \\\n  catch (...)                               { hr = E_FAIL; }\n#define CATCH_CPP_RETURN_HRESULT() \\\n  catch (std::bad_alloc&)                   { return E_OUTOFMEMORY; } \\\n  catch (hlsl::Exception& _hlsl_exception_) {                         \\\n    _Analysis_assume_(DXC_FAILED(_hlsl_exception_.hr));               \\\n    return _hlsl_exception_.hr;                                       \\\n  }                                                                   \\\n  catch (...)                               { return E_FAIL; }\n\ntemplate<typename T> T *VerifyNullAndThrow(T *p) {\n  if (p == nullptr)\n    throw std::bad_alloc();\n  return p;\n}\n#define VNT(__p) VerifyNullAndThrow(__p)\n\nextern \"C\" __declspec(dllimport) void __stdcall OutputDebugStringA(_In_opt_ const char *msg);\n\ninline void OutputDebugBytes(const void *ptr, size_t len) {\n  const char digits[] = \"0123456789abcdef\";\n  const unsigned char *pBytes = (const unsigned char *)ptr;\n  const int bytesPerLine = 16;\n  char buffer[bytesPerLine * 3 + 2 + 1];\n  buffer[_countof(buffer) - 3] = '\\r';\n  buffer[_countof(buffer) - 2] = '\\n';\n  buffer[_countof(buffer) - 1] = '\\0';\n\n  char *pWrite = buffer;\n  char *pEnd = buffer + _countof(buffer) - 3;\n  while (len) {\n    *pWrite++ = digits[(*pBytes & 0xF0) >> 4];\n    *pWrite++ = digits[*pBytes & 0x0f];\n    *pWrite++ = ' ';\n    if (pWrite == pEnd) {\n      OutputDebugStringA(buffer);\n      pWrite = buffer;\n    }\n    --len;\n    ++pBytes;\n  }\n  if (pWrite != buffer) {\n    *pWrite = '\\0';\n    OutputDebugStringA(buffer);\n    OutputDebugStringA(\"\\r\\n\");\n  }\n}\n\ninline void OutputDebugFormatA(_In_ _Printf_format_string_ _Null_terminated_ const char* pszFormat, ...) {\n  char buffer[1024];\n\n  va_list argList;\n  va_start(argList, pszFormat);\n  int count = vsprintf_s(buffer, _countof(buffer), pszFormat, argList);\n  va_end(argList);\n\n  OutputDebugStringA(buffer);\n  if (count < 0) {\n    OutputDebugStringA(\"...\\n\");\n  }\n}\n\n#ifdef DBG\n\n// DXASSERT is used to debug break when 'exp' evaluates to false and is only\n//     intended for internal developer use. It is compiled out in free\n//     builds.  This means that code that should be in the final exe should\n//     NOT be inside of of an DXASSERT test.\n//\n// 'fmt' is a printf-like format string; positional arguments aren't\n//  supported.\n//\n// Example: DXASSERT(i > 10, \"Hello %s\", \"World\");\n// This prints 'Hello World (i > 10)' and breaks in the debugger if the\n// assertion doesn't hold.\n//\n#define DXASSERT(exp, fmt, ...)\\\n  do { _Analysis_assume_(exp); if(!(exp)) {                              \\\n    OutputDebugFormatA(\"Error: \\t%s\\t\\nFile:\\n%s(%d)\\t\\nFunc:\\t%s.\\n\\t\" fmt \"\\n\", \"!(\" #exp \")\", __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__); \\\n    __debugbreak();\\\n  } } while(0)\n\n#define DXASSERT_LOCALVAR(local, exp, s, ...) DXASSERT(exp, s, __VA_ARGS__)\n\n#define DXASSERT_NOMSG(exp) DXASSERT(exp, \"\")\n\n#define DXVERIFY_NOMSG(exp) DXASSERT(exp, \"\")\n\n// This should be improved with global enabled mask rather than a compile-time mask.\n#define DXTRACE_MASK_ENABLED  0\n#define DXTRACE_MASK_APIFS    1\n#define DXTRACE_ENABLED(subsystem) (DXTRACE_MASK_ENABLED & subsystem)\n\n// DXTRACE_FMT formats a debugger trace message if DXTRACE_MASK allows it.\n#define DXTRACE_FMT(subsystem, fmt, ...) do { \\\n  if (DXTRACE_ENABLED(subsystem)) OutputDebugFormatA(fmt, __VA_ARGS__); \\\n} while (0)\n/// DXTRACE_FMT_APIFS is used by the API-based virtual filesystem.\n#define DXTRACE_FMT_APIFS(fmt, ...) DXTRACE_FMT(DXTRACE_MASK_APIFS, fmt, __VA_ARGS__)\n\n#else\n\n// DXASSERT is disabled in free builds.\n#define DXASSERT(exp, s, ...) _Analysis_assume_(exp)\n\n// DXASSERT_LOCALVAR is disabled in free builds, but we keep the local referenced to avoid a warning.\n#define DXASSERT_LOCALVAR(local, exp, s, ...) do { (local); _Analysis_assume_(exp); } while (0)\n\n// DXASSERT_NOMSG is disabled in free builds.\n#define DXASSERT_NOMSG(exp) _Analysis_assume_(exp)\n\n// DXVERIFY is patterned after NT_VERIFY and will evaluate the expression\n#define DXVERIFY_NOMSG(exp) do { (exp); _Analysis_assume_(exp); } while (0)\n\n// DXTRACE_FMT and the subsystem versions are disabled in free builds.\n#define DXTRACE_FMT(...) (void)(0)\n#define DXTRACE_FMT_APIFS(...) (void)(0)\n\n#endif // DBG\n"
  },
  {
    "path": "src/Wrapper/dxc/Support/HLSLOptions.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// HLSLOptions.h                                                             //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Support for command-line-style option parsing.                            //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n#ifndef LLVM_HLSL_OPTIONS_H\n#define LLVM_HLSL_OPTIONS_H\n\n#include \"llvm/ADT/ArrayRef.h\"\n#include \"llvm/ADT/StringRef.h\"\n#include \"llvm/Option/ArgList.h\"\n#include \"dxc/dxcapi.h\"\n\nnamespace llvm {\nnamespace opt {\nclass OptTable;\nclass raw_ostream;\n}\n}\n\nnamespace dxc {\nclass DxcDllSupport;\n}\n\nnamespace hlsl {\n\nnamespace options {\n/// Flags specifically for clang options.  Must not overlap with\n/// llvm::opt::DriverFlag or (for clarity) with clang::driver::options.\nenum HlslFlags {\n  DriverOption = (1 << 13),\n  NoArgumentUnused = (1 << 14),\n  CoreOption = (1 << 15),\n  ISenseOption = (1 << 16),\n};\n\nenum ID {\n    OPT_INVALID = 0, // This is not an option ID.\n#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \\\n               HELPTEXT, METAVAR) OPT_##ID,\n#include \"dxc/Support/HLSLOptions.inc\"\n    LastOption\n#undef OPTION\n  };\n\nconst llvm::opt::OptTable *getHlslOptTable();\n\n///////////////////////////////////////////////////////////////////////////////\n// Helper classes to deal with options.\n\n/// Flags for IDxcCompiler APIs.\nstatic const unsigned CompilerFlags = HlslFlags::CoreOption;\n/// Flags for dxc.exe command-line tool.\nstatic const unsigned DxcFlags = HlslFlags::CoreOption | HlslFlags::DriverOption;\n/// Flags for dxr.exe command-line tool.\nstatic const unsigned DxrFlags = HlslFlags::CoreOption | HlslFlags::DriverOption;\n/// Flags for IDxcIntelliSense APIs.\nstatic const unsigned ISenseFlags = HlslFlags::CoreOption | HlslFlags::ISenseOption;\n\n/// Use this class to capture preprocessor definitions and manage their lifetime.\nclass DxcDefines {\npublic:\n  void push_back(llvm::StringRef value);\n  LPWSTR DefineValues = nullptr;\n  llvm::SmallVector<llvm::StringRef, 8> DefineStrings;\n  llvm::SmallVector<DxcDefine, 8> DefineVector;\n\n  ~DxcDefines() { delete[] DefineValues; }\n  DxcDefines(const DxcDefines &) = delete;\n  DxcDefines() {}\n  void BuildDefines(); // Must be called after all defines are pushed back\n  UINT32 ComputeNumberOfWCharsNeededForDefines();\n  const DxcDefine *data() const { return DefineVector.data(); }\n  unsigned size() const { return DefineVector.size(); }\n};\n\n/// Use this class to capture all options.\nclass DxcOpts {\npublic:\n  DxcDefines Defines;\n  llvm::opt::InputArgList Args = llvm::opt::InputArgList(nullptr, nullptr); // Original arguments.\n\n  llvm::StringRef AssemblyCode; // OPT_Fc\n  llvm::StringRef DebugFile;    // OPT_Fd\n  llvm::StringRef EntryPoint;   // OPT_entrypoint\n  llvm::StringRef ExternalFn;   // OPT_external_fn\n  llvm::StringRef ExternalLib;  // OPT_external_lib\n  llvm::StringRef ExtractPrivateFile; // OPT_getprivate\n  llvm::StringRef ForceRootSigVer; // OPT_force_rootsig_ver\n  llvm::StringRef InputFile; // OPT_INPUT\n  llvm::StringRef OutputHeader; // OPT_Fh\n  llvm::StringRef OutputObject; // OPT_Fo\n  llvm::StringRef OutputWarningsFile; // OPT_Fe\n  llvm::StringRef Preprocess; // OPT_P\n  llvm::StringRef TargetProfile; // OPT_target_profile\n  llvm::StringRef VariableName; // OPT_Vn\n  llvm::StringRef PrivateSource; // OPT_setprivate\n  llvm::StringRef RootSignatureSource; // OPT_setrootsignature\n  llvm::StringRef VerifyRootSignatureSource; //OPT_verifyrootsignature\n  llvm::StringRef RootSignatureDefine; // OPT_rootsig_define\n\n  bool AllResourcesBound; // OPT_all_resources_bound\n  bool AstDump; // OPT_ast_dump\n  bool ColorCodeAssembly; // OPT_Cc\n  bool CodeGenHighLevel; // OPT_fcgl\n  bool DebugInfo; // OPT__SLASH_Zi\n  bool DumpBin;        // OPT_dumpbin\n  bool WarningAsError; // OPT__SLASH_WX\n  bool IEEEStrict;     // OPT_Gis\n  bool DefaultColMajor;  // OPT_Zpc\n  bool DefaultRowMajor;  // OPT_Zpr\n  bool DisableValidation; // OPT_VD\n  unsigned OptLevel;      // OPT_O0/O1/O2/O3\n  bool DisableOptimizations; // OPT_Od\n  bool AvoidFlowControl;     // OPT_Gfa\n  bool PreferFlowControl;    // OPT_Gfp\n  bool EnableStrictMode;     // OPT_Ges\n  bool HLSL2015;  // OPT_hlsl_version (=2015)\n  bool HLSL2016;  // OPT_hlsl_version (=2016)\n  bool OptDump; // OPT_ODump - dump optimizer commands\n  bool OutputWarnings = true; // OPT_no_warnings\n  bool ShowHelp = false;  // OPT_help\n  bool UseColor; // OPT_Cc\n  bool UseHexLiterals; // OPT_Lx\n  bool UseInstructionByteOffsets; // OPT_No\n  bool UseInstructionNumbers; // OPT_Ni\n  bool NotUseLegacyCBufLoad;  // OPT_not_use_legacy_cbuf_load\n  bool PackPrefixStable;  // OPT_pack_prefix_stable\n  bool PackOptimized;  // OPT_pack_optimized\n  bool DisplayIncludeProcess; // OPT__vi\n  bool RecompileFromBinary; // OPT _Recompile (Recompiling the DXBC binary file not .hlsl file)\n  bool StripDebug; // OPT Qstrip_debug\n  bool StripRootSignature; // OPT_Qstrip_rootsignature\n  bool StripPrivate; // OPT_Qstrip_priv\n  bool StripReflection; // OPT_Qstrip_reflect\n  bool ExtractRootSignature; // OPT_extractrootsignature\n  bool DisassembleColorCoded; // OPT_Cc\n  bool DisassembleInstNumbers; //OPT_Ni\n  bool DisassembleByteOffset; //OPT_No\n  bool DisaseembleHex; //OPT_Lx\n  bool IsRootSignatureProfile();\n};\n\n/// Use this class to capture, convert and handle the lifetime for the\n/// command-line arguments to a program.\nclass MainArgs {\npublic:\n  llvm::SmallVector<std::string, 8> Utf8StringVector;\n  llvm::SmallVector<const char *, 8> Utf8CharPtrVector;\n\n  MainArgs() = default;\n  MainArgs(int argc, const wchar_t **argv, int skipArgCount = 1);\n  MainArgs(llvm::ArrayRef<llvm::StringRef> args);\n  MainArgs& operator=(const MainArgs &other);\n  llvm::ArrayRef<const char *> getArrayRef() const {\n    return llvm::ArrayRef<const char *>(Utf8CharPtrVector.data(),\n      Utf8CharPtrVector.size());\n  }\n};\n\n/// Use this class to convert a StringRef into a wstring, handling empty values as nulls.\nclass StringRefUtf16 {\nprivate:\n  std::wstring m_value;\n\npublic:\n  StringRefUtf16(llvm::StringRef value);\n  operator LPCWSTR() const { return m_value.size() ? m_value.data() : nullptr; }\n};\n\n/// Reads all options from the given argument strings, populates opts, and\n/// validates reporting errors and warnings.\nint ReadDxcOpts(const llvm::opt::OptTable *optionTable, unsigned flagsToInclude,\n                const MainArgs &argStrings, DxcOpts &opts,\n                llvm::raw_ostream &errors);\n\n/// Sets up the specified DxcDllSupport instance as per the given options.\nint SetupDxcDllSupport(const DxcOpts &opts, dxc::DxcDllSupport &dxcSupport,\n                       llvm::raw_ostream &errors);\n\nvoid CopyArgsToWStrings(const llvm::opt::InputArgList &inArgs,\n                        unsigned flagsToInclude,\n                        std::vector<std::wstring> &outArgs);\n}\n}\n\n#endif\n"
  },
  {
    "path": "src/Wrapper/dxc/Support/HLSLOptions.td",
    "content": "//===--- HLSLOptions.td - Options for HLSL --------------------------------===//\n///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// HLSLOptions.td                                                            //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n//  This file defines the options accepted by HLSL.                          //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n// Include the common option parsing interfaces.                             //\n\ninclude \"llvm/Option/OptParser.td\"\n\n//////////////////////////////////////////////////////////////////////////////\n// Flags\n\n// DriverOption - The option is a \"driver\" option, and should not be forwarded\n// to other tools.\ndef DriverOption : OptionFlag;\n\n// CoreOption - This is considered a \"core\" HLSL option.\ndef CoreOption : OptionFlag;\n\n// ISenseOption - This option is only supported for IntelliSense.\ndef ISenseOption : OptionFlag;\n\n//////////////////////////////////////////////////////////////////////////////\n// Groups\n\n// Meta-group for options which are only used for compilation,\n// and not linking etc.\ndef CompileOnly_Group     : OptionGroup<\"<CompileOnly group>\">;\n\ndef Action_Group          : OptionGroup<\"<action group>\">;\n\ndef I_Group               : OptionGroup<\"<I group>\">, Group<CompileOnly_Group>;\ndef M_Group               : OptionGroup<\"<M group>\">, Group<CompileOnly_Group>;\ndef T_Group               : OptionGroup<\"<T group>\">;\ndef O_Group               : OptionGroup<\"<O group>\">, Group<CompileOnly_Group>;\ndef R_Group               : OptionGroup<\"<R group>\">, Group<CompileOnly_Group>;\ndef R_value_Group         : OptionGroup<\"<R (with value) group>\">, Group<R_Group>;\ndef W_Group               : OptionGroup<\"<W group>\">, Group<CompileOnly_Group>;\ndef W_value_Group         : OptionGroup<\"<W (with value) group>\">, Group<W_Group>;\ndef d_Group               : OptionGroup<\"<d group>\">;\ndef f_Group               : OptionGroup<\"<f group>\">, Group<CompileOnly_Group>;\ndef f_clang_Group         : OptionGroup<\"<f (clang-only) group>\">, Group<CompileOnly_Group>;\ndef g_Group               : OptionGroup<\"<g group>\">;\ndef g_flags_Group         : OptionGroup<\"<g flags group>\">;\ndef i_Group               : OptionGroup<\"<i group>\">, Group<CompileOnly_Group>;\ndef clang_i_Group         : OptionGroup<\"<clang i group>\">, Group<i_Group>;\ndef m_Group               : OptionGroup<\"<m group>\">, Group<CompileOnly_Group>;\ndef u_Group               : OptionGroup<\"<u group>\">;\n\n// Developer Driver Options\n\ndef internal_Group : OptionGroup<\"<clang internal options>\">;\ndef internal_driver_Group : OptionGroup<\"<clang driver internal options>\">,\n  Group<internal_Group>, HelpText<\"DRIVER OPTIONS\">;\ndef internal_debug_Group :\n  OptionGroup<\"<clang debug/development internal options>\">,\n  Group<internal_Group>, HelpText<\"DEBUG/DEVELOPMENT OPTIONS\">;\n\ndef hlslcomp_Group : OptionGroup<\"HLSL Compilation\">, HelpText<\"Compilation Options\">;\ndef hlsloptz_Group : OptionGroup<\"HLSL Optimization\">, HelpText<\"Optimization Options\">;\ndef hlslutil_Group : OptionGroup<\"HLSL Utility\">, HelpText<\"Utility Options\">;\ndef hlslcore_Group : OptionGroup<\"HLSL Core\">, HelpText<\"Common Options\">;\n\n//////////////////////////////////////////////////////////////////////////////\n// Options\n\n// The internal option ID must be a valid C++ identifier and results in a\n// hlsl::options::OPT_XX enum constant for XX.\n//\n// See tools/clang/include/clang/Driver/Options.td for more notes.\n// These options are based on those used by clang.\n// fxc-based options kept for compatiblity are below.\n//\n// The general approach is to include only things that are in use, in the\n// same order as in Options.td.\n\ndef D : JoinedOrSeparate<[\"-\", \"/\"], \"D\">, Group<hlslcomp_Group>, Flags<[CoreOption]>,\n    HelpText<\"Define macro\">;\ndef H : Flag<[\"-\"], \"H\">, Flags<[CoreOption]>, Group<hlslcomp_Group>,\n    HelpText<\"Show header includes and nesting depth\">;\ndef I : JoinedOrSeparate<[\"-\", \"/\"], \"I\">, Group<hlslcomp_Group>, Flags<[CoreOption]>,\n    HelpText<\"Add directory to include search path\">;\ndef O0 : Flag<[\"-\", \"/\"], \"O0\">, Group<hlsloptz_Group>, Flags<[CoreOption]>,\n    HelpText<\"Optimization Level 0\">;\ndef O1 : Flag<[\"-\", \"/\"], \"O1\">, Group<hlsloptz_Group>, Flags<[CoreOption]>,\n    HelpText<\"Optimization Level 1\">;\ndef O2 : Flag<[\"-\", \"/\"], \"O2\">, Group<hlsloptz_Group>, Flags<[CoreOption]>,\n    HelpText<\"Optimization Level 2\">;\ndef O3 : Flag<[\"-\", \"/\"], \"O3\">, Group<hlsloptz_Group>, Flags<[CoreOption]>,\n    HelpText<\"Optimization Level 3 (Default)\">;\ndef O4 : Flag<[\"-\", \"/\"], \"O4\">, Group<hlsloptz_Group>, Flags<[CoreOption]>,\n    HelpText<\"Optimization Level 4\">;\ndef Odump : Flag<[\"-\", \"/\"], \"Odump\">, Group<hlslcomp_Group>, Flags<[CoreOption]>,\n    HelpText<\"Print the optimizer commands.\">;\ndef Qunused_arguments : Flag<[\"-\"], \"Qunused-arguments\">, Group<hlslcore_Group>, Flags<[CoreOption]>,\n  HelpText<\"Don't emit warning for unused driver arguments\">;\ndef Wall : Flag<[\"-\"], \"Wall\">, Group<hlslcomp_Group>, Flags<[CoreOption]>;\ndef Wdeprecated : Flag<[\"-\"], \"Wdeprecated\">, Group<hlslcomp_Group>, Flags<[CoreOption]>;\n//def W_Joined : Joined<[\"-\"], \"W\">, Group<hlslcomp_Group>, Flags<[CoreOption]>,\n//  MetaVarName<\"<warning>\">, HelpText<\"Enable the specified warning\">;\ndef d_Flag : Flag<[\"-\"], \"d\">, Group<d_Group>;\ndef d_Joined : Joined<[\"-\"], \"d\">, Group<d_Group>;\n//def fcolor_diagnostics : Flag<[\"-\"], \"fcolor-diagnostics\">, Group<hlslcomp_Group>,\n//  Flags<[CoreOption, DriverOption]>, HelpText<\"Use colors in diagnostics\">;\ndef fdiagnostics_color : Flag<[\"-\"], \"fdiagnostics-color\">, Group<hlslcomp_Group>,\n  Flags<[CoreOption, DriverOption]>;\ndef fdiagnostics_color_EQ : Joined<[\"-\"], \"fdiagnostics-color=\">, Group<hlslcomp_Group>;\n//def fansi_escape_codes : Flag<[\"-\"], \"fansi-escape-codes\">, Group<f_Group>, // HLSL Change: disable ANSI escape codes\n//  Flags<[CoreOption, CC1Option]>, HelpText<\"Use ANSI escape codes for diagnostics\">;\ndef fconstexpr_depth_EQ : Joined<[\"-\"], \"fconstexpr-depth=\">, Group<f_Group>;\ndef fconstexpr_steps_EQ : Joined<[\"-\"], \"fconstexpr-steps=\">, Group<f_Group>;\ndef fconstexpr_backtrace_limit_EQ : Joined<[\"-\"], \"fconstexpr-backtrace-limit=\">,\n                                    Group<f_Group>;\n//def fdiagnostics_show_option : Flag<[\"-\"], \"fdiagnostics-show-option\">, Group<hlslcomp_Group>,\n//    Flags<[CoreOption]>, HelpText<\"Print option name with mappable diagnostics\">;\ndef fdiagnostics_show_category_EQ : Joined<[\"-\"], \"fdiagnostics-show-category=\">, Group<hlslcomp_Group>;\ndef ferror_limit_EQ : Joined<[\"-\"], \"ferror-limit=\">, Group<hlslcomp_Group>, Flags<[CoreOption]>;\n\ndef funsafe_math_optimizations : Flag<[\"-\"], \"funsafe-math-optimizations\">,\n  Group<hlsloptz_Group>;\ndef fno_unsafe_math_optimizations : Flag<[\"-\"], \"fno-unsafe-math-optimizations\">,\n  Group<hlsloptz_Group>;\ndef fassociative_math : Flag<[\"-\"], \"fassociative-math\">, Group<hlsloptz_Group>;\ndef fno_associative_math : Flag<[\"-\"], \"fno-associative-math\">, Group<hlsloptz_Group>;\n//def freciprocal_math :\n//  Flag<[\"-\"], \"freciprocal-math\">, Group<hlsloptz_Group>, Flags<[CoreOption]>,\n//  HelpText<\"Allow division operations to be reassociated\">;\ndef fno_reciprocal_math : Flag<[\"-\"], \"fno-reciprocal-math\">, Group<hlsloptz_Group>;\ndef ffinite_math_only : Flag<[\"-\"], \"ffinite-math-only\">, Group<hlsloptz_Group>, Flags<[CoreOption]>;\ndef fno_finite_math_only : Flag<[\"-\"], \"fno-finite-math-only\">, Group<hlsloptz_Group>;\ndef fsigned_zeros : Flag<[\"-\"], \"fsigned-zeros\">, Group<hlsloptz_Group>;\n//def fno_signed_zeros :\n//  Flag<[\"-\"], \"fno-signed-zeros\">, Group<hlsloptz_Group>, Flags<[CoreOption]>,\n//  HelpText<\"Allow optimizations that ignore the sign of floating point zeros\">;\ndef fhonor_nans : Flag<[\"-\"], \"fhonor-nans\">, Group<hlsloptz_Group>;\ndef fno_honor_nans : Flag<[\"-\"], \"fno-honor-nans\">, Group<hlsloptz_Group>;\ndef fhonor_infinities : Flag<[\"-\"], \"fhonor-infinities\">, Group<hlsloptz_Group>;\ndef fno_honor_infinities : Flag<[\"-\"], \"fno-honor-infinities\">, Group<hlsloptz_Group>;\n//def ftrapping_math : Flag<[\"-\"], \"ftrapping-math\">, Group<f_Group>;\n//def fno_trapping_math : Flag<[\"-\"], \"fno-trapping-math\">, Group<f_Group>;\n//def ffp_contract : Joined<[\"-\"], \"ffp-contract=\">, Group<hlsloptz_Group>,\n//  Flags<[CoreOption]>, HelpText<\"Form fused FP ops (e.g. FMAs): fast (everywhere)\"\n//  \" | on (according to FP_CONTRACT pragma, default) | off (never fuse)\">;\ndef flimited_precision_EQ : Joined<[\"-\"], \"flimited-precision=\">, Group<hlsloptz_Group>;\n\n\n/*\ndef fno_caret_diagnostics : Flag<[\"-\"], \"fno-caret-diagnostics\">, Group<hlslcomp_Group>,\n Flags<[CoreOption]>;\ndef fno_color_diagnostics : Flag<[\"-\"], \"fno-color-diagnostics\">, Group<hlslcomp_Group>,\n  Flags<[CoreOption]>;\ndef fno_diagnostics_color : Flag<[\"-\"], \"fno-diagnostics-color\">, Group<hlslcomp_Group>,\n  Flags<[CoreOption, DriverOption]>;\ndef fno_show_column : Flag<[\"-\"], \"fno-show-column\">, Group<hlslcomp_Group>, Flags<[CoreOption]>,\n  HelpText<\"Do not include column number on diagnostics\">;\ndef fno_spell_checking : Flag<[\"-\"], \"fno-spell-checking\">, Group<hlslcomp_Group>,\n  Flags<[CoreOption]>, HelpText<\"Disable spell-checking\">;\ndef fshow_column : Flag<[\"-\"], \"fshow-column\">, Group<hlslcomp_Group>, Flags<[CoreOption]>;\ndef fshow_source_location : Flag<[\"-\"], \"fshow-source-location\">, Group<hlslcomp_Group>;\ndef fspell_checking : Flag<[\"-\"], \"fspell-checking\">, Group<hlslcomp_Group>;\ndef fspell_checking_limit_EQ : Joined<[\"-\"], \"fspell-checking-limit=\">, Group<hlslcomp_Group>;\ndef funroll_loops : Flag<[\"-\"], \"funroll-loops\">, Group<hlsloptz_Group>,\n  HelpText<\"Turn on loop unroller\">, Flags<[CoreOption]>;\ndef fno_unroll_loops : Flag<[\"-\"], \"fno-unroll-loops\">, Group<hlsloptz_Group>,\n  HelpText<\"Turn off loop unroller\">, Flags<[CoreOption]>;\ndef freroll_loops : Flag<[\"-\"], \"freroll-loops\">, Group<hlsloptz_Group>,\n  HelpText<\"Turn on loop reroller\">, Flags<[CoreOption]>;\ndef fno_reroll_loops : Flag<[\"-\"], \"fno-reroll-loops\">, Group<hlsloptz_Group>,\n  HelpText<\"Turn off loop reroller\">;\n*/\ndef help : Flag<[\"-\", \"--\", \"/\"], \"help\">, Flags<[DriverOption]>, Group<hlslcore_Group>,\n  HelpText<\"Display available options\">;\n/*\ndef imacros : JoinedOrSeparate<[\"-\", \"--\"], \"imacros\">, Group<clang_i_Group>, Flags<[CoreOption]>,\n  HelpText<\"Include macros from file before parsing\">, MetaVarName<\"<file>\">;\ndef include_ : JoinedOrSeparate<[\"-\", \"--\"], \"include\">, Group<clang_i_Group>, EnumName<\"include\">,\n    MetaVarName<\"<file>\">, HelpText<\"Include file before parsing\">, Flags<[CoreOption]>;\ndef mllvm : Separate<[\"-\"], \"mllvm\">, Flags<[CoreOption]>,\n  HelpText<\"Additional arguments to forward to LLVM's option processing\">;\ndef mms_bitfields : Flag<[\"-\"], \"mms-bitfields\">, Group<m_Group>, Flags<[CoreOption]>,\n  HelpText<\"Set the default structure layout to be compatible with the Microsoft compiler standard\">;\ndef o : JoinedOrSeparate<[\"-\"], \"o\">, Flags<[DriverOption, RenderAsInput, CoreOption]>,\n  HelpText<\"Write output to <file>\">, MetaVarName<\"<file>\">;\ndef time : Flag<[\"-\"], \"time\">,\n  HelpText<\"Time individual commands\">;\n// def U : JoinedOrSeparate<[\"-\"], \"U\">, Group<CompileOnly_Group>, Flags<[CoreOption]>;\ndef w : Flag<[\"-\"], \"w\">, HelpText<\"Suppress all warnings\">, Flags<[CoreOption]>;\ndef working_directory : JoinedOrSeparate<[\"-\"], \"working-directory\">, Flags<[CoreOption]>,\n  MetaVarName<\"<dir>\">, HelpText<\"Resolve file paths relative to the specified directory\">;\ndef working_directory_EQ : Joined<[\"-\"], \"working-directory=\">, Flags<[CoreOption]>,\n  MetaVarName<\"<dir>\">, Alias<working_directory>;\n*/\n\n// Double dash options, which are usually an alias for one of the previous\n// options.\n\ndef _all_warnings : Flag<[\"--\"], \"all-warnings\">, Flags<[CoreOption]>, Alias<Wall>;\ndef _help_hidden : Flag<[\"--\"], \"help-hidden\">, Flags<[DriverOption]>;\ndef _help_question : Flag<[\"-\", \"/\"], \"?\">, Flags<[DriverOption]>, Alias<help>;\n\n//////////////////////////////////////////////////////////////////////////////\n// New HLSL-specific flags.\n\ndef ast_dump : Flag<[\"-\", \"/\"], \"ast-dump\">, Flags<[CoreOption, DriverOption, HelpHidden]>,\n  HelpText<\"Dumps the parsed Abstract Syntax Tree.\">; // should not be core, but handy workaround until explicit API written\ndef external_lib : Separate<[\"-\", \"/\"], \"external\">, Group<hlslcore_Group>, Flags<[DriverOption, HelpHidden]>,\n  HelpText<\"External DLL name to load for compiler support\">;\ndef external_fn : Separate<[\"-\", \"/\"], \"external-fn\">, Group<hlslcore_Group>, Flags<[DriverOption, HelpHidden]>,\n  HelpText<\"External function name to load for compiler support\">;\ndef fcgl : Flag<[\"-\", \"/\"], \"fcgl\">, Group<hlslcore_Group>, Flags<[CoreOption, HelpHidden]>,\n  HelpText<\"Generate high-level code only\">;\ndef not_use_legacy_cbuf_load : Flag<[\"-\", \"/\"], \"not_use_legacy_cbuf_load\">, Group<hlslcomp_Group>, Flags<[CoreOption]>,\n  HelpText<\"Do not use legacy cbuffer load\">;\ndef pack_prefix_stable : Flag<[\"-\", \"/\"], \"pack_prefix_stable\">, Group<hlslcomp_Group>, Flags<[CoreOption]>,\n  HelpText<\"(default) Pack signatures preserving prefix-stable property - appended elements will not disturb placement of prior elements\">;\ndef pack_optimized : Flag<[\"-\", \"/\"], \"pack_optimized\">, Group<hlslcomp_Group>, Flags<[CoreOption]>,\n  HelpText<\"Optimize signature packing assuming identical signature provided for each connecting stage\">;\ndef hlsl_version : Separate<[\"-\", \"/\"], \"HV\">, Group<hlslcomp_Group>, Flags<[CoreOption]>,\n  HelpText<\"HLSL version (Only supports 2016 for now)\">;\ndef no_warnings : Flag<[\"-\", \"/\"], \"no-warnings\">, Group<hlslcomp_Group>, Flags<[CoreOption]>,\n  HelpText<\"Suppress warnings\">;\ndef rootsig_define : Separate<[\"-\", \"/\"], \"rootsig-define\">, Group<hlslcomp_Group>, Flags<[CoreOption]>,\n  HelpText<\"Read root signature from a #define\">;\n\n//////////////////////////////////////////////////////////////////////////////\n// fxc-based flags that don't match those previously defined.\n\ndef target_profile : JoinedOrSeparate<[\"-\", \"/\"], \"T\">, Flags<[CoreOption]>, Group<hlslcomp_Group>,\n  HelpText<\"Target profile\">;\ndef entrypoint :  JoinedOrSeparate<[\"-\", \"/\"], \"E\">, Flags<[CoreOption]>, Group<hlslcomp_Group>,\n  HelpText<\"Entry point name\">;\n// /I <include> - already defined above\ndef _vi : Flag<[\"-\", \"/\"], \"Vi\">, Alias<H>, Flags<[CoreOption]>, Group<hlslcomp_Group>,\n  HelpText<\"Display details about the include process.\">;\ndef Od : Flag<[\"-\", \"/\"], \"Od\">, Flags<[CoreOption]>, Group<hlslcomp_Group>,\n  HelpText<\"Disable optimizations\">;\ndef _SLASH_WX : Flag<[\"-\", \"/\"], \"WX\">, Flags<[CoreOption]>, Group<hlslcomp_Group>,\n  HelpText<\"Treat warnings as errors\">;\ndef VD : Flag<[\"-\", \"/\"], \"Vd\">, Flags<[CoreOption]>, Group<hlslcomp_Group>,\n  HelpText<\"Disable validation\">;\ndef _SLASH_Zi : Flag<[\"-\", \"/\"], \"Zi\">, Flags<[CoreOption]>, Group<hlslcomp_Group>,\n  HelpText<\"Enable debug information\">;\ndef recompile : Flag<[\"-\", \"/\"], \"recompile\">, Flags<[CoreOption]>, Group<hlslcomp_Group>,\n  HelpText<\"recompile from DXIL container with Debug Info or Debug Info bitcode file\">;\ndef Zpr : Flag<[\"-\", \"/\"], \"Zpr\">, Flags<[CoreOption]>, Group<hlslcomp_Group>,\n  HelpText<\"Pack matrices in row-major order\">;\ndef Zpc : Flag<[\"-\", \"/\"], \"Zpc\">, Flags<[CoreOption]>, Group<hlslcomp_Group>,\n  HelpText<\"Pack matrices in column-major order\">;\n\n// deprecated /Gpp def Gpp : Flag<[\"-\", \"/\"], \"Gpp\">, HelpText<\"Force partial precision\">;\ndef Gfa : Flag<[\"-\", \"/\"], \"Gfa\">, HelpText<\"Avoid flow control constructs\">, Flags<[CoreOption]>, Group<hlslcomp_Group>;\ndef Gfp : Flag<[\"-\", \"/\"], \"Gfp\">, HelpText<\"Prefer flow control constructs\">, Flags<[CoreOption]>, Group<hlslcomp_Group>;\n// /Gdp - disable effect performance mode - unsupported\ndef Ges : Flag<[\"-\", \"/\"], \"Ges\">, HelpText<\"Enable strict mode\">, Flags<[CoreOption]>, Group<hlslcomp_Group>;\ndef Gis : Flag<[\"-\", \"/\"], \"Gis\">, HelpText<\"Force IEEE strictness\">, Flags<[CoreOption]>, Group<hlslcomp_Group>;\n\ndef Fo : JoinedOrSeparate<[\"-\", \"/\"], \"Fo\">, MetaVarName<\"<file>\">, HelpText<\"Output object file\">, Flags<[DriverOption]>, Group<hlslcomp_Group>;\n// def Fl : JoinedOrSeparate<[\"-\", \"/\"], \"Fl\">, MetaVarName<\"<file>\">, HelpText<\"Output a library\">;\ndef Fc : JoinedOrSeparate<[\"-\", \"/\"], \"Fc\">, MetaVarName<\"<file>\">, HelpText<\"Output assembly code listing file\">, Flags<[DriverOption]>, Group<hlslcomp_Group>;\n//def Fx : JoinedOrSeparate<[\"-\", \"/\"], \"Fx\">, MetaVarName<\"<file>\">, HelpText<\"Output assembly code and hex listing file\">;\ndef Fh : JoinedOrSeparate<[\"-\", \"/\"], \"Fh\">, MetaVarName<\"<file>\">, HelpText<\"Output header file containing object code\">, Flags<[DriverOption]>, Group<hlslcomp_Group>;\ndef Fe : JoinedOrSeparate<[\"-\", \"/\"], \"Fe\">, MetaVarName<\"<file>\">, HelpText<\"Output warnings and errors to a specific file\">, Flags<[DriverOption]>, Group<hlslcomp_Group>;\ndef Fd : JoinedOrSeparate<[\"-\", \"/\"], \"Fd\">, MetaVarName<\"<file>\">, HelpText<\"Extract LLVM Debug IR and write to given file\">, Flags<[DriverOption]>, Group<hlslcomp_Group>;\ndef Vn : JoinedOrSeparate<[\"-\", \"/\"], \"Vn\">, MetaVarName<\"<name>\">, HelpText<\"Use <name> as variable name in header file\">, Flags<[DriverOption]>, Group<hlslcomp_Group>;\ndef Cc : Flag<[\"-\", \"/\"], \"Cc\">, HelpText<\"Output color coded assembly listings\">, Group<hlslcomp_Group>, Flags<[DriverOption]>;\ndef Ni : Flag<[\"-\", \"/\"], \"Ni\">, HelpText<\"Output instruction numbers in assembly listings\">, Group<hlslcomp_Group>, Flags<[DriverOption]>;\ndef No : Flag<[\"-\", \"/\"], \"No\">, HelpText<\"Output instruction byte offsets in assembly listings\">, Group<hlslcomp_Group>, Flags<[DriverOption]>;\ndef Lx : Flag<[\"-\", \"/\"], \"Lx\">, HelpText<\"Output hexadecimal literals\">, Group<hlslcomp_Group>, Flags<[DriverOption]>;\n\n// In place of 'E' for clang; fxc uses 'E' for entry point.\ndef P : Separate<[\"-\", \"/\"], \"P\">, Flags<[DriverOption]>, Group<hlslutil_Group>,\n  HelpText<\"Preprocess to file (must be used alone)\">;\n\n// @<file> - options response file\n\ndef dumpbin : Flag<[\"-\", \"/\"], \"dumpbin\">, Flags<[DriverOption]>, Group<hlslutil_Group>,\n  HelpText<\"Load a binary file rather than compiling\">;\ndef Qstrip_reflect : Flag<[\"-\", \"/\"], \"Qstrip_reflect\">, Flags<[DriverOption]>, Group<hlslutil_Group>,\n  HelpText<\"Strip reflection data from shader bytecode  (must be used with /Fo <file>)\">;\ndef Qstrip_debug : Flag<[\"-\", \"/\"], \"Qstrip_debug\">, Flags<[DriverOption]>, Group<hlslutil_Group>,\n  HelpText<\"Strip debug information from 4_0+ shader bytecode  (must be used with /Fo <file>)\">;\ndef Qstrip_priv : Flag<[\"-\", \"/\"], \"Qstrip_priv\">, Flags<[DriverOption]>, Group<hlslutil_Group>,\n  HelpText<\"Strip private data from shader bytecode  (must be used with /Fo <file>)\">;\n\ndef Qstrip_rootsignature : Flag<[\"-\", \"/\"], \"Qstrip_rootsignature\">, Flags<[DriverOption]>, Group<hlslutil_Group>, HelpText<\"Strip root signature data from shader bytecode  (must be used with /Fo <file>)\">;\ndef setrootsignature     : JoinedOrSeparate<[\"-\", \"/\"], \"setrootsignature\">,     MetaVarName<\"<file>\">, Flags<[DriverOption]>, Group<hlslutil_Group>, HelpText<\"Attach root signature to shader bytecode\">;\ndef extractrootsignature : Flag<[\"-\", \"/\"], \"extractrootsignature\">, Flags<[DriverOption]>, Group<hlslutil_Group>, HelpText<\"Extract root signature from shader bytecode (must be used with /Fo <file>)\">;\ndef verifyrootsignature  : JoinedOrSeparate<[\"-\", \"/\"], \"verifyrootsignature\">,  MetaVarName<\"<file>\">, Flags<[DriverOption]>, Group<hlslutil_Group>, HelpText<\"Verify shader bytecode with root signature\">;\ndef force_rootsig_ver    : JoinedOrSeparate<[\"-\", \"/\"], \"force_rootsig_ver\">,    Flags<[CoreOption]>, MetaVarName<\"<profile>\">, Group<hlslcomp_Group>, HelpText<\"force root signature version (rootsig_1_1 if omitted)\">;\n\n/*\ndef shtemplate : JoinedOrSeparate<[\"-\", \"/\"], \"shtemplate\">, MetaVarName<\"<file>\">, Group<hlslcomp_Group>,\n  HelpText<\"Template shader file for merging/matching resources\">;\ndef mergeUAVs : JoinedOrSeparate<[\"-\", \"/\"], \"mergeUAVs\">, MetaVarName<\"<file>\">, Group<hlslcomp_Group>,\n  HelpText<\"Merge UAV slots of template shader and current shader\">;\ndef matchUAVs : JoinedOrSeparate<[\"-\", \"/\"], \"matchUAVs\">, MetaVarName<\"<file>\">, Group<hlslcomp_Group>,\n  HelpText<\"Match template shader UAV slots in current shader\">;\ndef res_may_alias : Flag<[\"-\", \"/\"], \"res_may_alias\">, Flags<[CoreOption]>, Group<hlslcomp_Group>,\n  HelpText<\"Assume that UAVs/SRVs may alias\">;\ndef enable_unbounded_descriptor_tables : Flag<[\"-\", \"/\"], \"enable_unbounded_descriptor_tables\">, Flags<[CoreOption]>, Group<hlslcomp_Group>,\n  HelpText<\"Enables unbounded descriptor tables\">;\n*/\ndef all_resources_bound : Flag<[\"-\", \"/\"], \"all_resources_bound\">, Flags<[CoreOption]>, Group<hlslcomp_Group>,\n  HelpText<\"Enables agressive flattening\">;\n\ndef setprivate : JoinedOrSeparate<[\"-\", \"/\"], \"setprivate\">, Flags<[DriverOption]>, MetaVarName<\"<file>\">, Group<hlslutil_Group>,\n  HelpText<\"Private data to add to compiled shader blob\">;\ndef getprivate : JoinedOrSeparate<[\"-\", \"/\"], \"getprivate\">, Flags<[DriverOption]>, MetaVarName<\"<file>\">, Group<hlslutil_Group>,\n  HelpText<\"Save private data from shader blob\">;\n\ndef nologo : Flag<[\"-\", \"/\"], \"nologo\">, Group<hlslcore_Group>, Flags<[DriverOption]>,\n  HelpText<\"Suppress copyright message\">;\n\n// Also removed: compress, decompress, /Gch (child effect), /Gec (back compat), /Gpp (partial precision)\n// /Op - no support for preshaders.\n"
  },
  {
    "path": "src/Wrapper/dxc/Support/Unicode.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// Unicode.h                                                                 //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Provides utitlity functions to work with Unicode and other encodings.     //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n#include <string>\n#include <specstrings.h>\n\nnamespace Unicode\n{\n\n// Based on http://msdn.microsoft.com/en-us/library/windows/desktop/dd374101(v=vs.85).aspx.\nenum class Encoding { ASCII = 0, UTF8, UTF8_BOM, UTF16_LE, UTF16_BE, UTF32_LE, UTF32_BE };\n\n// An acp_char is a character encoded in the current Windows ANSI code page.\ntypedef char acp_char;\n\n// A ccp_char is a character encoded in the console code page.\ntypedef char ccp_char;\n\n_Success_(return != false)\nbool UTF8ToConsoleString(_In_z_ const char* text, _Inout_ std::string* pValue, _Out_opt_ bool* lossy);\n\n_Success_(return != false)\nbool UTF16ToConsoleString(_In_z_ const wchar_t* text, _Inout_ std::string* pValue, _Out_opt_ bool* lossy);\n\n_Success_(return != false)\nbool UTF8ToUTF16String(_In_opt_z_ const char *pUTF8, _Inout_ std::wstring *pUTF16);\n\n_Success_(return != false)\nbool UTF8ToUTF16String(_In_opt_count_(cbUTF8) const char *pUTF8, size_t cbUTF8, _Inout_ std::wstring *pUTF16);\n\nstd::wstring UTF8ToUTF16StringOrThrow(_In_z_ const char *pUTF8);\n\n_Success_(return != false)\nbool UTF16ToUTF8String(_In_z_ const wchar_t *pUTF16, _Inout_ std::string *pUTF8);\n\nstd::string UTF16ToUTF8StringOrThrow(_In_z_ const wchar_t *pUTF16);\n\nbool IsStarMatchUTF8(_In_reads_opt_(maskLen) const char *pMask, size_t maskLen,\n                     _In_reads_opt_(nameLen) const char *pName, size_t nameLen);\nbool IsStarMatchUTF16(_In_reads_opt_(maskLen) const wchar_t *pMask, size_t maskLen,\n                      _In_reads_opt_(nameLen) const wchar_t *pName, size_t nameLen);\n\n_Success_(return != false)\nbool UTF8BufferToUTF16Buffer(\n  _In_NLS_string_(cbUTF8) const char *pUTF8,\n  int cbUTF8, \n  _Outptr_result_buffer_(*pcchUTF16) wchar_t **ppUTF16,\n  size_t *pcchUTF16) throw();\n\n_Success_(return != false)\nbool UTF16BufferToUTF8Buffer(\n  _In_NLS_string_(cchUTF16) const wchar_t *pUTF16,\n  int cchUTF16,\n  _Outptr_result_buffer_(*pcbUTF8) char **ppUTF8,\n  size_t *pcbUTF8) throw();\n\n}  // namespace Unicode\n"
  },
  {
    "path": "src/Wrapper/dxc/Support/WinIncludes.h",
    "content": "//===- WinIncludes.h --------------------------------------------*- C++ -*-===//\n///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// WinIncludes.h                                                             //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n#define NOATOM 1\n#define NOGDICAPMASKS 1\n#define NOMETAFILE 1\n#define NOMINMAX 1\n#define NOOPENFILE 1\n#define NORASTEROPS 1\n#define NOSCROLL 1\n#define NOSOUND 1\n#define NOSYSMETRICS 1\n#define NOWH 1\n#define NOCOMM 1\n#define NOKANJI 1\n#define NOCRYPT 1\n#define NOMCX 1\n#define WIN32_LEAN_AND_MEAN 1\n#define VC_EXTRALEAN 1\n\n#include <windows.h>\n#include <unknwn.h>\n#include <atlbase.h> // atlbase.h needs to come before strsafe.h\n#include <strsafe.h>\n#include <intsafe.h>\n\n/// Swap two ComPtr classes.\ntemplate <class T> void swap(CComHeapPtr<T> &a, CComHeapPtr<T> &b) {\n  T *c(a.m_pData);\n  a.m_pData = b.m_pData;\n  b.m_pData = c;\n}\n"
  },
  {
    "path": "src/Wrapper/dxc/Support/dxcapi.impl.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// dxcapi.impl.h                                                             //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Provides support for DXC API implementations.                             //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#ifndef __DXCAPI_IMPL__\n#define __DXCAPI_IMPL__\n\n#include \"dxc/dxcapi.h\"\n#include \"dxc/Support/microcom.h\"\n#include \"llvm/Support/raw_ostream.h\"\n\n// Simple adaptor for IStream. Can probably do better.\nclass raw_stream_ostream : public llvm::raw_ostream {\nprivate:\n  CComPtr<hlsl::AbstractMemoryStream> m_pStream;\n  void write_impl(const char *Ptr, size_t Size) override {\n    ULONG cbWritten;\n    IFT(m_pStream->Write(Ptr, Size, &cbWritten));\n  }\n  uint64_t current_pos() const { return m_pStream->GetPosition(); }\npublic:\n  raw_stream_ostream(hlsl::AbstractMemoryStream* pStream) : m_pStream(pStream) { }\n  ~raw_stream_ostream() override {\n    flush();\n  }\n};\n\nclass DxcOperationResult : public IDxcOperationResult {\nprivate:\n  DXC_MICROCOM_REF_FIELD(m_dwRef)\n\n  DxcOperationResult(_In_opt_ IDxcBlob *pResultBlob,\n    _In_opt_ IDxcBlobEncoding *pErrorBlob, HRESULT status)\n    : m_dwRef(0), m_status(status), m_result(pResultBlob),\n    m_errors(pErrorBlob) {}\n\npublic:\n  DXC_MICROCOM_ADDREF_RELEASE_IMPL(m_dwRef)\n\n  HRESULT m_status;\n  CComPtr<IDxcBlob> m_result;\n  CComPtr<IDxcBlobEncoding> m_errors;\n\n  HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void **ppvObject) {\n    return DoBasicQueryInterface<IDxcOperationResult>(this, iid, ppvObject);\n  }\n\n  static HRESULT CreateFromResultErrorStatus(_In_opt_ IDxcBlob *pResultBlob,\n                                             _In_opt_ IDxcBlobEncoding *pErrorBlob,\n                                             HRESULT status,\n                                             _COM_Outptr_ IDxcOperationResult **ppResult) {\n    *ppResult = nullptr;\n    CComPtr<DxcOperationResult> result = new (std::nothrow) DxcOperationResult(pResultBlob, pErrorBlob, status);\n    if (result.p == nullptr) return E_OUTOFMEMORY;\n    *ppResult = result.Detach();\n    return S_OK;\n  }\n\n  static HRESULT\n  CreateFromUtf8Strings(_In_opt_z_ LPCSTR pErrorStr,\n      _In_opt_z_ LPCSTR pResultStr, HRESULT status,\n      _COM_Outptr_ IDxcOperationResult **pResult) {\n    *pResult = nullptr;\n    CComPtr<IDxcBlobEncoding> resultBlob;\n    CComPtr<IDxcBlobEncoding> errorBlob;\n    CComPtr<DxcOperationResult> result;\n\n    HRESULT hr = S_OK;\n\n    if (pErrorStr != nullptr) {\n      hr = hlsl::DxcCreateBlobWithEncodingOnHeapCopy(\n        pErrorStr, strlen(pErrorStr), CP_UTF8, &errorBlob);\n      if (FAILED(hr)) {\n        return hr;\n      }\n    }\n\n    if (pResultStr != nullptr) {\n      hr = hlsl::DxcCreateBlobWithEncodingOnHeap(\n        pResultStr, strlen(pResultStr), CP_UTF8, &resultBlob);\n      if (FAILED(hr)) {\n        return hr;\n      }\n    }\n\n    return CreateFromResultErrorStatus(resultBlob, errorBlob, status, pResult);\n  }\n\n  __override HRESULT STDMETHODCALLTYPE GetStatus(_Out_ HRESULT *pStatus) {\n    if (pStatus == nullptr)\n      return E_INVALIDARG;\n\n    *pStatus = m_status;\n    return S_OK;\n  }\n\n  __override HRESULT STDMETHODCALLTYPE\n    GetResult(_COM_Outptr_result_maybenull_ IDxcBlob **ppResult) {\n    return m_result.CopyTo(ppResult);\n  }\n\n  __override HRESULT STDMETHODCALLTYPE\n    GetErrorBuffer(_COM_Outptr_result_maybenull_ IDxcBlobEncoding **ppErrors) {\n    return m_errors.CopyTo(ppErrors);\n  }\n};\n\n#endif\n"
  },
  {
    "path": "src/Wrapper/dxc/Support/dxcapi.use.h",
    "content": "//////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// dxcapi.use.h                                                              //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Provides support for DXC API users.                                       //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#ifndef __DXCAPI_USE_H__\n#define __DXCAPI_USE_H__\n\n#include \"dxc/dxcapi.h\"\n\nnamespace dxc {\n\n// Helper class to dynamically load the dxcompiler or a compatible libraries.\nclass DxcDllSupport {\nprotected:\n  HMODULE m_dll;\n  DxcCreateInstanceProc m_createFn;\n\n  HRESULT InitializeInternal(LPCWSTR dllName, LPCSTR fnName) {\n    if (m_dll != nullptr) return S_OK;\n    m_dll = LoadLibraryW(dllName);\n\n    if (m_dll == nullptr) return HRESULT_FROM_WIN32(GetLastError());\n    m_createFn = (DxcCreateInstanceProc)GetProcAddress(m_dll, fnName);\n\n    if (m_createFn == nullptr) {\n      HRESULT hr = HRESULT_FROM_WIN32(GetLastError());\n      FreeLibrary(m_dll);\n      m_dll = nullptr;\n      return hr;\n    }\n\n    return S_OK;\n  }\n\npublic:\n  DxcDllSupport() : m_dll(nullptr), m_createFn(nullptr) {\n  }\n\n  DxcDllSupport(DxcDllSupport&& other) {\n    m_dll = other.m_dll; other.m_dll = nullptr;\n    m_createFn = other.m_createFn; other.m_dll = nullptr;\n  }\n\n  ~DxcDllSupport() {\n    Cleanup();\n  }\n\n  HRESULT Initialize() {\n    return InitializeInternal(L\"dxcompiler.dll\", \"DxcCreateInstance\");\n  }\n\n  HRESULT InitializeForDll(_In_z_ const wchar_t* dll, _In_z_ const char* entryPoint) {\n    return InitializeInternal(dll, entryPoint);\n  }\n\n  template <typename TInterface>\n  HRESULT CreateInstance(REFCLSID clsid, _Outptr_ TInterface** pResult) {\n    return CreateInstance(clsid, __uuidof(TInterface), (IUnknown**)pResult);\n  }\n\n  HRESULT CreateInstance(REFCLSID clsid, REFIID riid, _Outptr_ IUnknown **pResult) {\n    if (pResult == nullptr) return E_POINTER;\n    if (m_dll == nullptr) return E_FAIL;\n    HRESULT hr = m_createFn(clsid, riid, (LPVOID*)pResult);\n    return hr;\n  }\n\n  bool IsEnabled() const {\n    return m_dll != nullptr;\n  }\n\n  void Cleanup() {\n    if (m_dll != nullptr) {\n      m_createFn = nullptr;\n      FreeLibrary(m_dll);\n      m_dll = nullptr;\n    }\n  }\n\n  HMODULE Detach() {\n    HMODULE module = m_dll;\n    m_dll = nullptr;\n    return module;\n  }\n};\n\ninline DxcDefine GetDefine(_In_ LPCWSTR name, LPCWSTR value) {\n  DxcDefine result;\n  result.Name = name;\n  result.Value = value;\n  return result;\n}\n\n// Checks an HRESULT and formats an error message with the appended data.\nvoid IFT_Data(HRESULT hr, _In_opt_ LPCWSTR data);\n\nvoid EnsureEnabled(DxcDllSupport &dxcSupport);\nvoid ReadFileIntoBlob(DxcDllSupport &dxcSupport, _In_ LPCWSTR pFileName,\n                      _Outptr_ IDxcBlobEncoding **ppBlobEncoding);\nvoid WriteBlobToConsole(_In_opt_ IDxcBlob *pBlob, DWORD streamType = STD_OUTPUT_HANDLE);\nvoid WriteBlobToFile(_In_opt_ IDxcBlob *pBlob, _In_ LPCWSTR pFileName);\nvoid WriteBlobToHandle(_In_opt_ IDxcBlob *pBlob, HANDLE hFile, _In_opt_ LPCWSTR pFileName);\nvoid WriteUtf8ToConsole(_In_opt_count_(charCount) const char *pText,\n                        int charCount, DWORD streamType = STD_OUTPUT_HANDLE);\nvoid WriteUtf8ToConsoleSizeT(_In_opt_count_(charCount) const char *pText,\n                             size_t charCount, DWORD streamType = STD_OUTPUT_HANDLE);\nvoid WriteOperationErrorsToConsole(_In_ IDxcOperationResult *pResult,\n                                   bool outputWarnings);\nvoid WriteOperationResultToConsole(_In_ IDxcOperationResult *pRewriteResult,\n                                   bool outputWarnings);\n\n} // namespace dxc\n\n#endif\n"
  },
  {
    "path": "src/Wrapper/dxc/Support/exception.h",
    "content": "//===- exception.h ----------------------------------------------*- C++ -*-===//\n///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// exception.h                                                               //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#pragma once\n\n#include \"dxc/Support/ErrorCodes.h\"\n#include <exception>\n#include <string>\n\n\nnamespace hlsl\n{\n\n/// <summary>\n/// Exception stores off information about an error and its error message for\n/// later consumption by the hlsl compiler tools.\n/// </summary>\nstruct Exception : public std::exception\n{\n  /// <summary>HRESULT error code. Must be a failure.</summary>\n  HRESULT hr;\n  std::string msg;\n\n  Exception(HRESULT errCode) : hr(errCode) { }\n  Exception(HRESULT errCode, const std::string &errMsg) : hr(errCode), msg(errMsg) { }\n\n  // what returns a formatted message with the error code and the message used\n  // to create the message.\n  virtual const char *what() const throw() { return msg.c_str(); }\n};\n\n}  // namespace hlsl\n"
  },
  {
    "path": "src/Wrapper/dxc/Support/microcom.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// microcom.h                                                                //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Provides support for basic COM-like constructs.                           //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#ifndef __DXC_MICROCOM__\n#define __DXC_MICROCOM__\n\ntemplate <typename TIface>\nclass CComInterfaceArray {\nprivate:\n  TIface **m_pData;\n  unsigned m_length;\npublic:\n  CComInterfaceArray() : m_pData(nullptr), m_length(0) { }\n  ~CComInterfaceArray() {\n    clear();\n  }\n  bool empty() const { return m_length == 0; }\n  unsigned size() const { return m_length; }\n  TIface ***data_ref() { return &m_pData; }\n  unsigned *size_ref() { return &m_length; }\n  TIface **begin() {\n    return m_pData;\n  }\n  TIface **end() {\n    return m_pData + m_length;\n  }\n  void clear() {\n    if (m_length) {\n      for (unsigned i = 0; i < m_length; ++i) {\n        if (m_pData[i] != nullptr) {\n          m_pData[i]->Release();\n          m_pData[i] = nullptr;\n        }\n      }\n      m_length = 0;\n    }\n    if (m_pData) {\n      CoTaskMemFree(m_pData);\n      m_pData = nullptr;\n    }\n  }\n  HRESULT alloc(unsigned count) {\n    clear();\n    m_pData = (TIface**)CoTaskMemAlloc(sizeof(TIface*) * count);\n    if (m_pData == nullptr)\n      return E_OUTOFMEMORY;\n    m_length = count;\n    ZeroMemory(m_pData, sizeof(TIface*) * count);\n    return S_OK;\n  }\n  TIface **get_address_of(unsigned index) {\n    return &(m_pData[index]);\n  }\n  TIface **release() {\n    TIface **result = m_pData;\n    m_pData = nullptr;\n    m_length = 0;\n    return result;\n  }\n  void release(TIface ***pValues, unsigned *length) {\n    *pValues = m_pData;\n    m_pData = nullptr;\n    *length = m_length;\n    m_length = 0;\n  }\n};\n\n#define DXC_MICROCOM_REF_FIELD(m_dwRef) volatile ULONG m_dwRef;\n    \n#define DXC_MICROCOM_ADDREF_RELEASE_IMPL(m_dwRef) \\\n    bool HasSingleRef() { return 1 == m_dwRef; } \\\n    ULONG STDMETHODCALLTYPE AddRef()  {\\\n        return InterlockedIncrement(&m_dwRef); \\\n    } \\\n    ULONG STDMETHODCALLTYPE Release() { \\\n        ULONG result = InterlockedDecrement(&m_dwRef); \\\n        if (result == 0) delete this; \\\n        return result; \\\n    }\n\n/// <summary>\n/// Provides a QueryInterface implementation for a class that supports\n/// a single interface in addition to IUnknown.\n/// </summary>\n/// <remarks>\n/// This implementation will also report the instance as not supporting\n/// marshaling. This will help catch marshaling problems early or avoid\n/// them altogether.\n/// </remarks>\ntemplate <typename TInterface, typename TObject>\nHRESULT DoBasicQueryInterface(TObject* self, REFIID iid, void** ppvObject)\n{\n  if (ppvObject == nullptr) return E_POINTER;\n\n  // Support INoMarshal to void GIT shenanigans.\n  if (IsEqualIID(iid, __uuidof(IUnknown)) ||\n    IsEqualIID(iid, __uuidof(INoMarshal))) {\n    *ppvObject = reinterpret_cast<IUnknown*>(self);\n    reinterpret_cast<IUnknown*>(self)->AddRef();\n    return S_OK;\n  }\n\n  if (IsEqualIID(iid, __uuidof(TInterface))) {\n    *(TInterface**)ppvObject = self;\n    self->AddRef();\n    return S_OK;\n  }\n\n  return E_NOINTERFACE;\n}\n\n/// <summary>\n/// Provides a QueryInterface implementation for a class that supports\n/// two interfaces in addition to IUnknown.\n/// </summary>\n/// <remarks>\n/// This implementation will also report the instance as not supporting\n/// marshaling. This will help catch marshaling problems early or avoid\n/// them altogether.\n/// </remarks>\ntemplate <typename TInterface, typename TInterface2, typename TObject>\nHRESULT DoBasicQueryInterface2(TObject* self, REFIID iid, void** ppvObject)\n{\n  if (ppvObject == nullptr) return E_POINTER;\n\n  // Support INoMarshal to void GIT shenanigans.\n  if (IsEqualIID(iid, __uuidof(IUnknown)) ||\n      IsEqualIID(iid, __uuidof(INoMarshal))) {\n    *ppvObject = reinterpret_cast<IUnknown*>(self);\n    reinterpret_cast<IUnknown*>(self)->AddRef();\n    return S_OK;\n  }\n\n  if (IsEqualIID(__uuidof(TInterface), iid)) {\n    *(TInterface**)ppvObject = self;\n    self->AddRef();\n    return S_OK;\n  }\n\n  if (IsEqualIID(__uuidof(TInterface2), iid)) {\n    *(TInterface2**)ppvObject = self;\n    self->AddRef();\n    return S_OK;\n  }\n\n  return E_NOINTERFACE;\n}\n\n/// <summary>\n/// Provides a QueryInterface implementation for a class that supports\n/// three interfaces in addition to IUnknown.\n/// </summary>\n/// <remarks>\n/// This implementation will also report the instance as not supporting\n/// marshaling. This will help catch marshaling problems early or avoid\n/// them altogether.\n/// </remarks>\ntemplate <typename TInterface, typename TInterface2, typename TInterface3, typename TObject>\nHRESULT DoBasicQueryInterface3(TObject* self, REFIID iid, void** ppvObject)\n{\n  if (ppvObject == nullptr) return E_POINTER;\n  if (IsEqualIID(iid, __uuidof(TInterface3))) {\n    *(TInterface3**)ppvObject = self;\n    self->AddRef();\n    return S_OK;\n  }\n\n  return DoBasicQueryInterface2<TInterface, TInterface2, TObject>(self, iid, ppvObject);\n}\n\ntemplate <typename T>\nHRESULT AssignToOut(T value, _Out_ T* pResult) {\n  if (pResult == nullptr)\n    return E_POINTER;\n  *pResult = value;\n  return S_OK;\n}\ntemplate <typename T>\nHRESULT AssignToOut(nullptr_t value, _Out_ T* pResult) {\n  if (pResult == nullptr)\n    return E_POINTER;\n  *pResult = value;\n  return S_OK;\n}\ntemplate <typename T>\nHRESULT ZeroMemoryToOut(_Out_ T* pResult) {\n  if (pResult == nullptr)\n    return E_POINTER;\n  ZeroMemory(pResult, sizeof(*pResult));\n  return S_OK;\n}\n\ntemplate <typename T>\nvoid AssignToOutOpt(T value, _Out_opt_ T* pResult) {\n  if (pResult != nullptr)\n    *pResult = value;\n}\ntemplate <typename T>\nvoid AssignToOutOpt(nullptr_t value, _Out_opt_ T* pResult) {\n  if (pResult != nullptr)\n    *pResult = value;\n}\n\n#endif\n"
  },
  {
    "path": "src/Wrapper/dxc/Tracing/CMakeLists.txt",
    "content": "# Copyright (C) Microsoft Corporation. All rights reserved.\n# This file is distributed under the University of Illinois Open Source License. See LICENSE.TXT for details.\n# Generate ETW instrumentation.\n\n# Create the header in a temporary file and only update when necessary,\n# to avoid invalidating targets that depend on it.\nadd_custom_command(\n  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dxc/Tracing/tmpdxcetw.h\n  COMMAND mc -r ${CMAKE_CURRENT_BINARY_DIR} -h ${CMAKE_CURRENT_BINARY_DIR} -p DxcEtw_ -um -z tmpdxcetw ${CMAKE_CURRENT_SOURCE_DIR}/dxcetw.man\n  DEPENDS {CMAKE_CURRENT_SOURCE_DIR}/dxcetw.man\n  COMMENT \"Building instrumentation manifest ...\"\n)\nadd_custom_command(\n  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dxc/Tracing/dxcetw.h\n  COMMAND ${CMAKE_COMMAND} -E copy_if_different\n        ${CMAKE_CURRENT_BINARY_DIR}/tmpdxcetw.h\n        ${CMAKE_CURRENT_BINARY_DIR}/dxcetw.h\n  COMMAND ${CMAKE_COMMAND} -E copy_if_different\n        ${CMAKE_CURRENT_BINARY_DIR}/tmpdxcetw.rc\n        ${CMAKE_CURRENT_BINARY_DIR}/dxcetw.rc\n  COMMAND ${CMAKE_COMMAND} -E copy_if_different\n        ${CMAKE_CURRENT_BINARY_DIR}/tmpdxcetwTEMP.bin\n        ${CMAKE_CURRENT_BINARY_DIR}/dxcetwTEMP.bin\n  COMMAND ${CMAKE_COMMAND} -E copy_if_different\n        ${CMAKE_CURRENT_BINARY_DIR}/tmpdxcetw_MSG00001.bin\n        ${CMAKE_CURRENT_BINARY_DIR}/MSG00001.bin\n  DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/dxc/Tracing/tmpdxcetw.h\n  COMMENT \"Updating instrumentation manifest ...\"\n)\n\nset_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/dxcetw.h PROPERTIES GENERATED 1)\nset_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/dxcetw.rc PROPERTIES GENERATED 1)\nset_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/dxcetwTEMP.bin PROPERTIES GENERATED 1)\nset_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/MSG00001.bin PROPERTIES GENERATED 1)\n\nadd_custom_target(DxcEtw\n  DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/dxc/Tracing/dxcetw.h\n  SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/dxcetw.man\n)\n\n# Not quite tablegen, but close enough.\nset_target_properties(DxcEtw PROPERTIES FOLDER \"Tablegenning\")\n"
  },
  {
    "path": "src/Wrapper/dxc/Tracing/dxcetw.man",
    "content": "﻿<?xml version='1.0' encoding='utf-8' standalone='yes'?>\n<instrumentationManifest xmlns=\"http://schemas.microsoft.com/win/2004/08/events\">\n  <instrumentation\n      xmlns:win=\"http://manifests.microsoft.com/win/2004/08/windows/events\"\n      xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"\n      xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n      >\n    <events xmlns=\"http://schemas.microsoft.com/win/2004/08/events\">\n      <provider\n          guid=\"{5c65fe8c-9f96-4bfd-9a87-9f8ebd45da64}\"\n          message=\"$(string.eventProviderName)\"\n          messageFileName=\"%INSTALL_PATH%\\dxcompiler.dll\"\n          name=\"Microsoft-Windows-DXCompiler-API\"\n          resourceFileName=\"%INSTALL_PATH%\\dxcompiler.dll\"\n          symbol=\"MICROSOFT_WINDOWS_DXCOMPILER_PROVIDER\"\n          >\n        <channels>\n          <channel\n              chid=\"DXCompilerAnalytic\"\n              name=\"Microsoft-Windows-DXCompiler-API/Analytic\"\n              type=\"Analytic\"\n              />\n        </channels>\n        <tasks>\n          <task\n              name=\"DXCompilerInitialization\"\n              value=\"1\"\n              />\n          <task\n              name=\"DXCompilerShutdown\"\n              value=\"2\"\n              />\n          <task\n              name=\"DXCompilerCreateInstance\"\n              value=\"3\"\n              />\n          <task\n              name=\"DXCompilerIntelliSenseParse\"\n              value=\"4\"\n              />\n          <task\n              name=\"DXCompilerCompile\"\n              value=\"5\"\n              />\n          <task\n              name=\"DXCompilerPreprocess\"\n              value=\"6\"\n              />\n          <task\n              name=\"DXCompilerDisassemble\"\n              value=\"7\"\n              />\n          <task\n              name=\"DxcValidation\"\n              value=\"8\"\n              />\n        </tasks>\n        <events>\n          <event\n              channel=\"DXCompilerAnalytic\"\n              level=\"win:Informational\"\n              opcode=\"win:Start\"\n              symbol=\"DXCompilerInitialization_Start\"\n              task=\"DXCompilerInitialization\"\n              value=\"0\"\n              />\n          <event\n              channel=\"DXCompilerAnalytic\"\n              level=\"win:Informational\"\n              opcode=\"win:Stop\"\n              symbol=\"DXCompilerInitialization_Stop\"\n              task=\"DXCompilerInitialization\"\n              template=\"OperationResultTemplate\"\n              value=\"1\"\n              />\n          <event\n              channel=\"DXCompilerAnalytic\"\n              level=\"win:Informational\"\n              opcode=\"win:Start\"\n              symbol=\"DXCompilerShutdown_Start\"\n              task=\"DXCompilerShutdown\"\n              value=\"2\"\n              />\n          <event\n              channel=\"DXCompilerAnalytic\"\n              level=\"win:Informational\"\n              opcode=\"win:Stop\"\n              symbol=\"DXCompilerShutdown_Stop\"\n              task=\"DXCompilerShutdown\"\n              template=\"OperationResultTemplate\"\n              value=\"3\"\n              />\n          <event\n              channel=\"DXCompilerAnalytic\"\n              level=\"win:Informational\"\n              opcode=\"win:Start\"\n              symbol=\"DXCompilerCreateInstance_Start\"\n              task=\"DXCompilerCreateInstance\"\n              value=\"4\"\n              />\n          <event\n              channel=\"DXCompilerAnalytic\"\n              level=\"win:Informational\"\n              opcode=\"win:Stop\"\n              symbol=\"DXCompilerCreateInstance_Stop\"\n              task=\"DXCompilerCreateInstance\"\n              template=\"OperationResultTemplate\"\n              value=\"5\"\n              />\n          <event\n              channel=\"DXCompilerAnalytic\"\n              level=\"win:Informational\"\n              opcode=\"win:Start\"\n              symbol=\"DXCompilerIntelliSenseParse_Start\"\n              task=\"DXCompilerIntelliSenseParse\"\n              value=\"6\"\n              />\n          <event\n              channel=\"DXCompilerAnalytic\"\n              level=\"win:Informational\"\n              opcode=\"win:Stop\"\n              symbol=\"DXCompilerIntelliSenseParse_Stop\"\n              task=\"DXCompilerIntelliSenseParse\"\n              template=\"OperationResultTemplate\"\n              value=\"7\"\n              />\n          <event\n              channel=\"DXCompilerAnalytic\"\n              level=\"win:Informational\"\n              opcode=\"win:Start\"\n              symbol=\"DXCompilerCompile_Start\"\n              task=\"DXCompilerCompile\"\n              value=\"8\"\n              />\n          <event\n              channel=\"DXCompilerAnalytic\"\n              level=\"win:Informational\"\n              opcode=\"win:Stop\"\n              symbol=\"DXCompilerCompile_Stop\"\n              task=\"DXCompilerCompile\"\n              template=\"OperationResultTemplate\"\n              value=\"9\"\n              />\n          <event\n              channel=\"DXCompilerAnalytic\"\n              level=\"win:Informational\"\n              opcode=\"win:Start\"\n              symbol=\"DXCompilerPreprocess_Start\"\n              task=\"DXCompilerPreprocess\"\n              value=\"10\"\n              />\n          <event\n              channel=\"DXCompilerAnalytic\"\n              level=\"win:Informational\"\n              opcode=\"win:Stop\"\n              symbol=\"DXCompilerPreprocess_Stop\"\n              task=\"DXCompilerPreprocess\"\n              template=\"OperationResultTemplate\"\n              value=\"11\"\n              />\n          <event\n              channel=\"DXCompilerAnalytic\"\n              level=\"win:Informational\"\n              opcode=\"win:Start\"\n              symbol=\"DXCompilerDisassemble_Start\"\n              task=\"DXCompilerDisassemble\"\n              value=\"12\"\n              />\n          <event\n              channel=\"DXCompilerAnalytic\"\n              level=\"win:Informational\"\n              opcode=\"win:Stop\"\n              symbol=\"DXCompilerDisassemble_Stop\"\n              task=\"DXCompilerDisassemble\"\n              template=\"OperationResultTemplate\"\n              value=\"13\"\n              />\n          <event\n              channel=\"DXCompilerAnalytic\"\n              level=\"win:Informational\"\n              opcode=\"win:Start\"\n              symbol=\"DxcValidation_Start\"\n              task=\"DxcValidation\"\n              value=\"14\"\n              />\n          <event\n              channel=\"DXCompilerAnalytic\"\n              level=\"win:Informational\"\n              opcode=\"win:Stop\"\n              symbol=\"DxcValidation_Stop\"\n              task=\"DxcValidation\"\n              template=\"OperationResultTemplate\"\n              value=\"15\"\n              />\n        </events>\n        <templates>\n          <template tid=\"OperationResultTemplate\">\n            <data\n                inType=\"win:Int32\"\n                name=\"errorCode\"\n                outType=\"win:HResult\"\n                />\n          </template>\n        </templates>\n      </provider>\n    </events>\n  </instrumentation>\n  <localization>\n    <resources culture=\"en-US\">\n      <stringTable>\n        <string\n            id=\"eventProviderName\"\n            value=\"Microsoft-Windows-DXCompiler-API\"\n            />\n      </stringTable>\n    </resources>\n  </localization>\n</instrumentationManifest>\n"
  },
  {
    "path": "src/Wrapper/dxc/dxcapi.h",
    "content": "\n///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// dxcapi.h                                                                  //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Provides declarations for the DirectX Compiler API entry point.           //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#ifndef __DXC_API__\n#define __DXC_API__\n\n#ifndef DXC_API_IMPORT\n#define DXC_API_IMPORT __declspec(dllimport)\n#endif\n\nstruct IMalloc;\nstruct IDxcIncludeHandler;\n\n/// <summary>\n/// Creates a single uninitialized object of the class associated with a specified CLSID.\n/// </summary>\n/// <param name=\"rclsid\">\n/// The CLSID associated with the data and code that will be used to create the object.\n/// </param>\n/// <param name=\"riid\">\n/// A reference to the identifier of the interface to be used to communicate \n/// with the object.\n/// </param>\n/// <param name=\"ppv\">\n/// Address of pointer variable that receives the interface pointer requested\n/// in riid. Upon successful return, *ppv contains the requested interface\n/// pointer. Upon failure, *ppv contains NULL.</param>\n/// <remarks>\n/// While this function is similar to CoCreateInstance, there is no COM involvement.\n/// </remarks>\ntypedef HRESULT (__stdcall *DxcCreateInstanceProc)(\n    _In_ REFCLSID   rclsid,\n    _In_ REFIID     riid,\n    _Out_ LPVOID*   ppv\n);\n\ntypedef HRESULT(__stdcall *DxcCreateInstance2Proc)(\n  _In_ IMalloc    *pMalloc,\n  _In_ REFCLSID   rclsid,\n  _In_ REFIID     riid,\n  _Out_ LPVOID*   ppv\n  );\n\n/// <summary>\n/// Creates a single uninitialized object of the class associated with a specified CLSID.\n/// </summary>\n/// <param name=\"rclsid\">\n/// The CLSID associated with the data and code that will be used to create the object.\n/// </param>\n/// <param name=\"riid\">\n/// A reference to the identifier of the interface to be used to communicate \n/// with the object.\n/// </param>\n/// <param name=\"ppv\">\n/// Address of pointer variable that receives the interface pointer requested\n/// in riid. Upon successful return, *ppv contains the requested interface\n/// pointer. Upon failure, *ppv contains NULL.</param>\n/// <remarks>\n/// While this function is similar to CoCreateInstance, there is no COM involvement.\n/// </remarks>\nDXC_API_IMPORT HRESULT __stdcall DxcCreateInstance(\n  _In_ REFCLSID   rclsid,\n  _In_ REFIID     riid,\n  _Out_ LPVOID*   ppv\n  );\n\nDXC_API_IMPORT HRESULT __stdcall DxcCreateInstance2(\n  _In_ IMalloc    *pMalloc,\n  _In_ REFCLSID   rclsid,\n  _In_ REFIID     riid,\n  _Out_ LPVOID*   ppv\n);\n\n\n// IDxcBlob is an alias of ID3D10Blob and ID3DBlob\nstruct __declspec(uuid(\"8BA5FB08-5195-40e2-AC58-0D989C3A0102\"))\nIDxcBlob : public IUnknown {\npublic:\n  virtual LPVOID STDMETHODCALLTYPE GetBufferPointer(void) = 0;\n  virtual SIZE_T STDMETHODCALLTYPE GetBufferSize(void) = 0;\n};\n\nstruct __declspec(uuid(\"7241d424-2646-4191-97c0-98e96e42fc68\"))\nIDxcBlobEncoding : public IDxcBlob {\npublic:\n  virtual HRESULT STDMETHODCALLTYPE GetEncoding(_Out_ BOOL *pKnown,\n                                                _Out_ UINT32 *pCodePage) = 0;\n};\n\nstruct __declspec(uuid(\"e5204dc7-d18c-4c3c-bdfb-851673980fe7\"))\nIDxcLibrary : public IUnknown {\n  virtual HRESULT STDMETHODCALLTYPE SetMalloc(_In_opt_ IMalloc *pMalloc) = 0;\n  virtual HRESULT STDMETHODCALLTYPE CreateBlobFromBlob(\n    _In_ IDxcBlob *pBlob, UINT32 offset, UINT32 length, _COM_Outptr_ IDxcBlob **ppResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE CreateBlobFromFile(\n    LPCWSTR pFileName, _In_opt_ UINT32* codePage,\n    _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0;\n  virtual HRESULT STDMETHODCALLTYPE CreateBlobWithEncodingFromPinned(\n    LPBYTE pText, UINT32 size, UINT32 codePage,\n    _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0;\n  virtual HRESULT STDMETHODCALLTYPE CreateBlobWithEncodingOnHeapCopy(\n       _In_bytecount_(size) LPCVOID pText, UINT32 size, UINT32 codePage,\n      _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0;\n  virtual HRESULT STDMETHODCALLTYPE CreateBlobWithEncodingOnMalloc(\n    _In_bytecount_(size) LPCVOID pText, IMalloc *pIMalloc, UINT32 size, UINT32 codePage,\n    _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0;\n  virtual HRESULT STDMETHODCALLTYPE CreateIncludeHandler(\n      _COM_Outptr_ IDxcIncludeHandler **ppResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE CreateStreamFromBlobReadOnly(\n      _In_ IDxcBlob *pBlob, _COM_Outptr_ IStream **ppStream) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetBlobAsUtf8(\n      _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetBlobAsUtf16(\n      _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0;\n};\n\nstruct __declspec(uuid(\"CEDB484A-D4E9-445A-B991-CA21CA157DC2\"))\nIDxcOperationResult : public IUnknown {\n  virtual HRESULT STDMETHODCALLTYPE GetStatus(_Out_ HRESULT *pStatus) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetResult(_COM_Outptr_result_maybenull_ IDxcBlob **pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetErrorBuffer(_COM_Outptr_result_maybenull_ IDxcBlobEncoding **pErrors) = 0;\n};\n\nstruct __declspec(uuid(\"7f61fc7d-950d-467f-b3e3-3c02fb49187c\"))\nIDxcIncludeHandler : public IUnknown {\n  virtual HRESULT STDMETHODCALLTYPE LoadSource(\n    _In_ LPCWSTR pFilename,                                   // Candidate filename.\n    _COM_Outptr_result_maybenull_ IDxcBlob **ppIncludeSource  // Resultant source object for included file, nullptr if not found.\n    ) = 0;\n};\n\nstruct DxcDefine {\n  LPCWSTR Name;\n  _Maybenull_ LPCWSTR Value;\n};\n\nstruct __declspec(uuid(\"8c210bf3-011f-4422-8d70-6f9acb8db617\"))\nIDxcCompiler : public IUnknown {\n  // Compile a single entry point to the target shader model\n  virtual HRESULT STDMETHODCALLTYPE Compile(\n    _In_ IDxcBlob *pSource,                       // Source text to compile\n    _In_opt_ LPCWSTR pSourceName,                 // Optional file name for pSource. Used in errors and include handlers.\n    _In_ LPCWSTR pEntryPoint,                     // entry point name\n    _In_ LPCWSTR pTargetProfile,                  // shader profile to compile\n    _In_count_(argCount) LPCWSTR *pArguments,     // Array of pointers to arguments\n    _In_ UINT32 argCount,                         // Number of arguments\n    _In_count_(defineCount) const DxcDefine *pDefines,  // Array of defines\n    _In_ UINT32 defineCount,                      // Number of defines\n    _In_opt_ IDxcIncludeHandler *pIncludeHandler, // user-provided interface to handle #include directives (optional)\n    _COM_Outptr_ IDxcOperationResult **ppResult   // Compiler output status, buffer, and errors\n  ) = 0;\n\n  // Preprocess source text\n  virtual HRESULT STDMETHODCALLTYPE Preprocess(\n    _In_ IDxcBlob *pSource,                       // Source text to preprocess\n    _In_opt_ LPCWSTR pSourceName,                 // Optional file name for pSource. Used in errors and include handlers.\n    _In_count_(argCount) LPCWSTR *pArguments,     // Array of pointers to arguments\n    _In_ UINT32 argCount,                         // Number of arguments\n    _In_count_(defineCount) const DxcDefine *pDefines,  // Array of defines\n    _In_ UINT32 defineCount,                      // Number of defines\n    _In_opt_ IDxcIncludeHandler *pIncludeHandler, // user-provided interface to handle #include directives (optional)\n    _COM_Outptr_ IDxcOperationResult **ppResult   // Preprocessor output status, buffer, and errors\n  ) = 0;\n\n  // Disassemble a program.\n  virtual HRESULT STDMETHODCALLTYPE Disassemble(\n    _In_ IDxcBlob *pSource,                         // Program to disassemble.\n    _COM_Outptr_ IDxcBlobEncoding **ppDisassembly   // Disassembly text.\n    ) = 0;\n};\n\nstruct __declspec(uuid(\"A005A9D9-B8BB-4594-B5C9-0E633BEC4D37\"))\nIDxcCompiler2 : public IDxcCompiler {\n  // Compile a single entry point to the target shader model with debug information.\n  virtual HRESULT STDMETHODCALLTYPE CompileWithDebug(\n    _In_ IDxcBlob *pSource,                       // Source text to compile\n    _In_opt_ LPCWSTR pSourceName,                 // Optional file name for pSource. Used in errors and include handlers.\n    _In_ LPCWSTR pEntryPoint,                     // Entry point name\n    _In_ LPCWSTR pTargetProfile,                  // Shader profile to compile\n    _In_count_(argCount) LPCWSTR *pArguments,     // Array of pointers to arguments\n    _In_ UINT32 argCount,                         // Number of arguments\n    _In_count_(defineCount) const DxcDefine *pDefines,  // Array of defines\n    _In_ UINT32 defineCount,                      // Number of defines\n    _In_opt_ IDxcIncludeHandler *pIncludeHandler, // user-provided interface to handle #include directives (optional)\n    _COM_Outptr_ IDxcOperationResult **ppResult,  // Compiler output status, buffer, and errors\n    _Outptr_opt_result_z_ LPWSTR *ppDebugBlobName,// Suggested file name for debug blob.\n    _COM_Outptr_opt_ IDxcBlob **ppDebugBlob       // Debug blob\n  ) = 0;\n};\n\nstruct __declspec(uuid(\"F1B5BE2A-62DD-4327-A1C2-42AC1E1E78E6\"))\nIDxcLinker : public IUnknown {\npublic:\n  // Register a library with name to ref it later.\n  virtual HRESULT RegisterLibrary(\n      _In_opt_ LPCWSTR pLibName,         // Name of the library.\n      _In_ IDxcBlob *pLib                // Library blob.\n  ) = 0;\n\n  // Links the shader and produces a shader blob that the Direct3D runtime can\n  // use.\n  virtual HRESULT STDMETHODCALLTYPE Link(\n      _In_opt_ LPCWSTR pEntryName, // Entry point name\n      _In_ LPCWSTR pTargetProfile, // shader profile to link\n      _In_count_(libCount)\n          const LPCWSTR *pLibNames, // Array of library names to link\n      UINT32 libCount,              // Number of libraries to link\n      _In_count_(argCount)\n          const LPCWSTR *pArguments, // Array of pointers to arguments\n      _In_ UINT32 argCount,          // Number of arguments\n      _COM_Outptr_ IDxcOperationResult *\n          *ppResult // Linker output status, buffer, and errors\n  ) = 0;\n};\n\nstatic const UINT32 DxcValidatorFlags_Default = 0;\nstatic const UINT32 DxcValidatorFlags_InPlaceEdit = 1;  // Validator is allowed to update shader blob in-place.\nstatic const UINT32 DxcValidatorFlags_RootSignatureOnly = 2;\nstatic const UINT32 DxcValidatorFlags_ModuleOnly = 4;\nstatic const UINT32 DxcValidatorFlags_ValidMask = 0x7;\n\nstruct __declspec(uuid(\"A6E82BD2-1FD7-4826-9811-2857E797F49A\"))\nIDxcValidator : public IUnknown {\n  // Validate a shader.\n  virtual HRESULT STDMETHODCALLTYPE Validate(\n    _In_ IDxcBlob *pShader,                       // Shader to validate.\n    _In_ UINT32 Flags,                            // Validation flags.\n    _COM_Outptr_ IDxcOperationResult **ppResult   // Validation output status, buffer, and errors\n    ) = 0;\n};\n\nstruct __declspec(uuid(\"334b1f50-2292-4b35-99a1-25588d8c17fe\"))\nIDxcContainerBuilder : public IUnknown {\n  virtual HRESULT STDMETHODCALLTYPE Load(_In_ IDxcBlob *pDxilContainerHeader) = 0;                // Loads DxilContainer to the builder\n  virtual HRESULT STDMETHODCALLTYPE AddPart(_In_ UINT32 fourCC, _In_ IDxcBlob *pSource) = 0;      // Part to add to the container\n  virtual HRESULT STDMETHODCALLTYPE RemovePart(_In_ UINT32 fourCC) = 0;                           // Remove the part with fourCC\n  virtual HRESULT STDMETHODCALLTYPE SerializeContainer(_Out_ IDxcOperationResult **ppResult) = 0; // Builds a container of the given container builder state\n};\n\nstruct __declspec(uuid(\"091f7a26-1c1f-4948-904b-e6e3a8a771d5\"))\nIDxcAssembler : public IUnknown {\n  // Assemble dxil in ll or llvm bitcode to DXIL container.\n  virtual HRESULT STDMETHODCALLTYPE AssembleToContainer(\n    _In_ IDxcBlob *pShader,                       // Shader to assemble.\n    _COM_Outptr_ IDxcOperationResult **ppResult   // Assembly output status, buffer, and errors\n    ) = 0;\n};\n\nstruct __declspec(uuid(\"d2c21b26-8350-4bdc-976a-331ce6f4c54c\"))\nIDxcContainerReflection : public IUnknown {\n  virtual HRESULT STDMETHODCALLTYPE Load(_In_ IDxcBlob *pContainer) = 0; // Container to load.\n  virtual HRESULT STDMETHODCALLTYPE GetPartCount(_Out_ UINT32 *pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetPartKind(UINT32 idx, _Out_ UINT32 *pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetPartContent(UINT32 idx, _COM_Outptr_ IDxcBlob **ppResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE FindFirstPartKind(UINT32 kind, _Out_ UINT32 *pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetPartReflection(UINT32 idx, REFIID iid, void **ppvObject) = 0;\n};\n\nstruct __declspec(uuid(\"AE2CD79F-CC22-453F-9B6B-B124E7A5204C\"))\nIDxcOptimizerPass : public IUnknown {\n  virtual HRESULT STDMETHODCALLTYPE GetOptionName(_COM_Outptr_ LPWSTR *ppResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetDescription(_COM_Outptr_ LPWSTR *ppResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetOptionArgCount(_Out_ UINT32 *pCount) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetOptionArgName(UINT32 argIndex, _COM_Outptr_ LPWSTR *ppResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetOptionArgDescription(UINT32 argIndex, _COM_Outptr_ LPWSTR *ppResult) = 0;\n};\n\nstruct __declspec(uuid(\"25740E2E-9CBA-401B-9119-4FB42F39F270\"))\nIDxcOptimizer : public IUnknown {\n  virtual HRESULT STDMETHODCALLTYPE GetAvailablePassCount(_Out_ UINT32 *pCount) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetAvailablePass(UINT32 index, _COM_Outptr_ IDxcOptimizerPass** ppResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE RunOptimizer(IDxcBlob *pBlob,\n    _In_count_(optionCount) LPCWSTR *ppOptions, UINT32 optionCount,\n    _COM_Outptr_ IDxcBlob **pOutputModule,\n    _COM_Outptr_opt_ IDxcBlobEncoding **ppOutputText) = 0;\n};\n\nstatic const UINT32 DxcVersionInfoFlags_None = 0;\nstatic const UINT32 DxcVersionInfoFlags_Debug = 1; // Matches VS_FF_DEBUG\nstatic const UINT32 DxcVersionInfoFlags_Internal = 2; // Internal Validator (non-signing)\n\nstruct __declspec(uuid(\"b04f5b50-2059-4f12-a8ff-a1e0cde1cc7e\"))\nIDxcVersionInfo : public IUnknown {\n  virtual HRESULT STDMETHODCALLTYPE GetVersion(_Out_ UINT32 *pMajor, _Out_ UINT32 *pMinor) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetFlags(_Out_ UINT32 *pFlags) = 0;\n};\n\n// {73e22d93-e6ce-47f3-b5bf-f0664f39c1b0}\n__declspec(selectany) extern const CLSID CLSID_DxcCompiler = {\n  0x73e22d93,\n  0xe6ce,\n  0x47f3,\n  { 0xb5, 0xbf, 0xf0, 0x66, 0x4f, 0x39, 0xc1, 0xb0 }\n};\n\n// {EF6A8087-B0EA-4D56-9E45-D07E1A8B7806}\n__declspec(selectany) extern const GUID CLSID_DxcLinker = {\n    0xef6a8087,\n    0xb0ea,\n    0x4d56,\n    {0x9e, 0x45, 0xd0, 0x7e, 0x1a, 0x8b, 0x78, 0x6}\n};\n\n// {CD1F6B73-2AB0-484D-8EDC-EBE7A43CA09F}\n__declspec(selectany) extern const CLSID CLSID_DxcDiaDataSource = {\n  0xcd1f6b73,\n  0x2ab0,\n  0x484d,\n  { 0x8e, 0xdc, 0xeb, 0xe7, 0xa4, 0x3c, 0xa0, 0x9f }\n};\n\n// {6245D6AF-66E0-48FD-80B4-4D271796748C}\n__declspec(selectany) extern const GUID CLSID_DxcLibrary = {\n  0x6245d6af,\n  0x66e0,\n  0x48fd,\n  { 0x80, 0xb4, 0x4d, 0x27, 0x17, 0x96, 0x74, 0x8c }\n};\n\n// {8CA3E215-F728-4CF3-8CDD-88AF917587A1}\n__declspec(selectany) extern const GUID CLSID_DxcValidator = {\n  0x8ca3e215,\n  0xf728,\n  0x4cf3,\n  { 0x8c, 0xdd, 0x88, 0xaf, 0x91, 0x75, 0x87, 0xa1 }\n};\n\n// {D728DB68-F903-4F80-94CD-DCCF76EC7151}\n__declspec(selectany) extern const GUID CLSID_DxcAssembler = {\n  0xd728db68,\n  0xf903,\n  0x4f80,\n  { 0x94, 0xcd, 0xdc, 0xcf, 0x76, 0xec, 0x71, 0x51 }\n};\n\n// {b9f54489-55b8-400c-ba3a-1675e4728b91}\n__declspec(selectany) extern const GUID CLSID_DxcContainerReflection = {\n  0xb9f54489,\n  0x55b8,\n  0x400c,\n  { 0xba, 0x3a, 0x16, 0x75, 0xe4, 0x72, 0x8b, 0x91 }\n};\n\n// {AE2CD79F-CC22-453F-9B6B-B124E7A5204C}\n__declspec(selectany) extern const GUID CLSID_DxcOptimizer = {\n    0xae2cd79f,\n    0xcc22,\n    0x453f,\n    {0x9b, 0x6b, 0xb1, 0x24, 0xe7, 0xa5, 0x20, 0x4c}\n};\n\n// {94134294-411f-4574-b4d0-8741e25240d2}\n__declspec(selectany) extern const GUID CLSID_DxcContainerBuilder = {\n  0x94134294,\n  0x411f,\n  0x4574,  \n  { 0xb4, 0xd0, 0x87, 0x41, 0xe2, 0x52, 0x40, 0xd2 }\n};\n#endif\n"
  },
  {
    "path": "src/Wrapper/dxc/dxcapi.internal.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// dxcapi.internal.h                                                         //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Provides non-public declarations for the DirectX Compiler component.      //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#ifndef __DXC_API_INTERNAL__\n#define __DXC_API_INTERNAL__\n\n#include \"dxcapi.h\"\n\n///////////////////////////////////////////////////////////////////////////////\n// Forward declarations.\ntypedef interface ITextFont ITextFont;\ntypedef interface IEnumSTATSTG IEnumSTATSTG;\ntypedef interface ID3D10Blob ID3D10Blob;\n\n///////////////////////////////////////////////////////////////////////////////\n// Intrinsic definitions.\n#define AR_QUAL_IN             0x0000000000000010UI64\n#define AR_QUAL_OUT            0x0000000000000020UI64\n#define AR_QUAL_CONST          0x0000000000000200UI64\n#define AR_QUAL_ROWMAJOR       0x0000000000000400UI64\n#define AR_QUAL_COLMAJOR       0x0000000000000800UI64\n\n#define AR_QUAL_IN_OUT (AR_QUAL_IN | AR_QUAL_OUT)\n\nstatic const BYTE INTRIN_TEMPLATE_FROM_TYPE = 0xff;\nstatic const BYTE INTRIN_TEMPLATE_VARARGS = 0xfe;\n\n// Use this enumeration to describe allowed templates (layouts) in intrinsics.\nenum LEGAL_INTRINSIC_TEMPLATES {\n  LITEMPLATE_VOID   = 0,  // No return type.\n  LITEMPLATE_SCALAR = 1,  // Scalar types.\n  LITEMPLATE_VECTOR = 2,  // Vector types (eg. float3).\n  LITEMPLATE_MATRIX = 3,  // Matrix types (eg. float3x3).\n  LITEMPLATE_ANY    = 4,  // Any one of scalar, vector or matrix types (but not object).\n  LITEMPLATE_OBJECT = 5,  // Object types.\n\n  LITEMPLATE_COUNT = 6\n};\n\n// INTRIN_COMPTYPE_FROM_TYPE_ELT0 is for object method intrinsics to indicate\n// that the component type of the type is taken from the first subelement of the\n// object's template type; see for example Texture2D.Gather\nstatic const BYTE INTRIN_COMPTYPE_FROM_TYPE_ELT0 = 0xff;\n\nenum LEGAL_INTRINSIC_COMPTYPES {\n  LICOMPTYPE_VOID = 0,            // void, used for function returns\n  LICOMPTYPE_BOOL = 1,            // bool\n  LICOMPTYPE_INT = 2,             // i32, int-literal\n  LICOMPTYPE_UINT = 3,            // u32, int-literal\n  LICOMPTYPE_ANY_INT = 4,         // i32, u32, i64, u64, int-literal\n  LICOMPTYPE_ANY_INT32 = 5,       // i32, u32, int-literal\n  LICOMPTYPE_UINT_ONLY = 6,       // u32, u64, int-literal; no casts allowed\n  LICOMPTYPE_FLOAT = 7,           // f32, partial-precision-f32, float-literal\n  LICOMPTYPE_ANY_FLOAT = 8,       // f32, partial-precision-f32, f64, float-literal, min10-float, min16-float\n  LICOMPTYPE_FLOAT_LIKE = 9,      // f32, partial-precision-f32, float-literal, min10-float, min16-float\n  LICOMPTYPE_FLOAT_DOUBLE = 10,   // f32, partial-precision-f32, f64, float-literal\n  LICOMPTYPE_DOUBLE = 11,         // f64, float-literal\n  LICOMPTYPE_DOUBLE_ONLY = 12,    // f64; no casts allowed\n  LICOMPTYPE_NUMERIC = 13,        // float-literal, f32, partial-precision-f32, f64, min10-float, min16-float, int-literal, i32, u32, min12-int, min16-int, min16-uint, i64, u64\n  LICOMPTYPE_NUMERIC32 = 14,      // float-literal, f32, partial-precision-f32, int-literal, i32, u32\n  LICOMPTYPE_NUMERIC32_ONLY = 15, // float-literal, f32, partial-precision-f32, int-literal, i32, u32; no casts allowed\n  LICOMPTYPE_ANY = 16,            // float-literal, f32, partial-precision-f32, f64, min10-float, min16-float, int-literal, i32, u32, min12-int, min16-int, min16-uint, bool, i64, u64\n  LICOMPTYPE_SAMPLER1D = 17,\n  LICOMPTYPE_SAMPLER2D = 18,\n  LICOMPTYPE_SAMPLER3D = 19,\n  LICOMPTYPE_SAMPLERCUBE = 20,\n  LICOMPTYPE_SAMPLERCMP = 21,\n  LICOMPTYPE_SAMPLER = 22,\n  LICOMPTYPE_STRING = 23,\n  LICOMPTYPE_WAVE = 24,\n  LICOMPTYPE_UINT64 = 25,         // u64, int-literal\n  LICOMPTYPE_UINT32_64 = 26,      // u32, u64, int-literal\n\n  LICOMPTYPE_COUNT = 27\n};\n\nstatic const BYTE IA_SPECIAL_BASE = 0xf0;\nstatic const BYTE IA_R = 0xf0;\nstatic const BYTE IA_C = 0xf1;\nstatic const BYTE IA_R2 = 0xf2;\nstatic const BYTE IA_C2 = 0xf3;\nstatic const BYTE IA_SPECIAL_SLOTS = 4;\n\nstruct HLSL_INTRINSIC_ARGUMENT {\n  LPCSTR pName;               // Name of the argument; the first argument has the function name.\n  UINT64 qwUsage;             // A combination of AR_QUAL_IN|AR_QUAL_OUT|AR_QUAL_COLMAJOR|AR_QUAL_ROWMAJOR in parameter tables; other values possible elsewhere.\n\n  BYTE uTemplateId;           // One of INTRIN_TEMPLATE_FROM_TYPE, INTRIN_TEMPLATE_VARARGS or the argument # the template (layout) must match (trivially itself).\n  BYTE uLegalTemplates;       // A LEGAL_INTRINSIC_TEMPLATES value for allowed templates.\n  BYTE uComponentTypeId;      // INTRIN_COMPTYPE_FROM_TYPE_ELT0, or the argument # the component (element type) must match (trivially itself).\n  BYTE uLegalComponentTypes;  // A LEGAL_INTRINSIC_COMPTYPES value for allowed components.\n\n  BYTE uRows;                 // Required number of rows, or one of IA_R/IA_C/IA_R2/IA_C2 for matching input constraints.\n  BYTE uCols;                 // Required number of cols, or one of IA_R/IA_C/IA_R2/IA_C2 for matching input constraints.\n};\n\nstruct HLSL_INTRINSIC {\n  UINT Op;                              // Intrinsic Op ID\n  BOOL bReadOnly;                       // Only read memory\n  BOOL bReadNone;                       // Not read memory\n  INT  iOverloadParamIndex;             // Parameter decide the overload type, -1 means ret type\n  UINT uNumArgs;                        // Count of arguments in pArgs.\n  const HLSL_INTRINSIC_ARGUMENT* pArgs; // Pointer to first argument.\n};\n\n///////////////////////////////////////////////////////////////////////////////\n// Interfaces.\nstruct __declspec(uuid(\"f0d4da3f-f863-4660-b8b4-dfd94ded6215\"))\nIDxcIntrinsicTable : public IUnknown\n{\npublic:\n  virtual HRESULT STDMETHODCALLTYPE GetTableName(_Outptr_ LPCSTR *pTableName) = 0;\n  virtual HRESULT STDMETHODCALLTYPE LookupIntrinsic(\n    LPCWSTR typeName, LPCWSTR functionName,\n    const HLSL_INTRINSIC** pIntrinsic,\n    _Inout_ UINT64* pLookupCookie) = 0;\n\n  // Get the lowering strategy for an hlsl extension intrinsic.\n  virtual HRESULT STDMETHODCALLTYPE GetLoweringStrategy(UINT opcode, LPCSTR *pStrategy) = 0;\n  \n  // Callback to support custom naming of hlsl extension intrinsic functions in dxil.\n  // Return the empty string to get the default intrinsic name, which is the mangled\n  // name of the high level intrinsic function.\n  //\n  // Overloaded intrinsics are supported by use of an overload place holder in the\n  // name. The string \"$o\" in the name will be replaced by the return type of the\n  // intrinsic.\n  virtual HRESULT STDMETHODCALLTYPE GetIntrinsicName(UINT opcode, LPCSTR *pName) = 0;\n\n  // Callback to support the 'dxil' lowering strategy.\n  // Returns the dxil opcode that the intrinsic should use for lowering.\n  virtual HRESULT STDMETHODCALLTYPE GetDxilOpCode(UINT opcode, UINT *pDxilOpcode) = 0;\n};\n\nstruct __declspec(uuid(\"1d063e4f-515a-4d57-a12a-431f6a44cfb9\"))\nIDxcSemanticDefineValidator : public IUnknown\n{\npublic:\n  virtual HRESULT STDMETHODCALLTYPE GetSemanticDefineWarningsAndErrors(LPCSTR pName, LPCSTR pValue, IDxcBlobEncoding **ppWarningBlob, IDxcBlobEncoding **ppErrorBlob) = 0;\n};\n\nstruct __declspec(uuid(\"282a56b4-3f56-4360-98c7-9ea04a752272\"))\nIDxcLangExtensions : public IUnknown\n{\npublic:\n  /// <summary>\n  /// Registers the name of a preprocessor define that has semantic meaning\n  /// and should be preserved for downstream consumers.\n  /// </summary>\n  virtual HRESULT STDMETHODCALLTYPE RegisterSemanticDefine(LPCWSTR name) = 0;\n  /// <summary>Registers a name to exclude from semantic defines.</summary>\n  virtual HRESULT STDMETHODCALLTYPE RegisterSemanticDefineExclusion(LPCWSTR name) = 0;\n  /// <summary>Registers a definition for compilation.</summary>\n  virtual HRESULT STDMETHODCALLTYPE RegisterDefine(LPCWSTR name) = 0;\n  /// <summary>Registers a table of built-in intrinsics.</summary>\n  virtual HRESULT STDMETHODCALLTYPE RegisterIntrinsicTable(_In_ IDxcIntrinsicTable* pTable) = 0;\n  /// <summary>Sets an (optional) validator for parsed semantic defines.<summary>\n  /// This provides a hook to check that the semantic defines present in the source\n  /// contain valid data. One validator is used to validate all parsed semantic defines.\n  virtual HRESULT STDMETHODCALLTYPE SetSemanticDefineValidator(_In_ IDxcSemanticDefineValidator* pValidator) = 0;\n  /// <summary>Sets the name for the root metadata node used in DXIL to hold the semantic defines.</summary>\n  virtual HRESULT STDMETHODCALLTYPE SetSemanticDefineMetaDataName(LPCSTR name) = 0;\n};\n\nstruct __declspec(uuid(\"454b764f-3549-475b-958c-a7a6fcd05fbc\"))\nIDxcSystemAccess : public IUnknown\n{\npublic:\n  virtual HRESULT STDMETHODCALLTYPE EnumFiles(LPCWSTR fileName, IEnumSTATSTG** pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE OpenStorage(\n    _In_      LPCWSTR lpFileName,\n    _In_      DWORD dwDesiredAccess,\n    _In_      DWORD dwShareMode,\n    _In_      DWORD dwCreationDisposition,\n    _In_      DWORD dwFlagsAndAttributes, IUnknown** pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE SetStorageTime(_In_ IUnknown* storage,\n    _In_opt_  const FILETIME *lpCreationTime,\n    _In_opt_  const FILETIME *lpLastAccessTime,\n    _In_opt_  const FILETIME *lpLastWriteTime) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetFileInformationForStorage(_In_ IUnknown* storage, _Out_ LPBY_HANDLE_FILE_INFORMATION lpFileInformation) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetFileTypeForStorage(_In_ IUnknown* storage, _Out_ DWORD* fileType) = 0;\n  virtual HRESULT STDMETHODCALLTYPE CreateHardLinkInStorage(_In_ LPCWSTR lpFileName, _In_ LPCWSTR lpExistingFileName) = 0;\n  virtual HRESULT STDMETHODCALLTYPE MoveStorage(_In_ LPCWSTR lpExistingFileName, _In_opt_ LPCWSTR lpNewFileName, _In_ DWORD dwFlags) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetFileAttributesForStorage(_In_ LPCWSTR lpFileName, _Out_ DWORD* pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE DeleteStorage(_In_ LPCWSTR lpFileName) = 0;\n  virtual HRESULT STDMETHODCALLTYPE RemoveDirectoryStorage(LPCWSTR lpFileName) = 0;\n  virtual HRESULT STDMETHODCALLTYPE CreateDirectoryStorage(_In_ LPCWSTR lpPathName) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetCurrentDirectoryForStorage(DWORD nBufferLength, _Out_writes_(nBufferLength) LPWSTR lpBuffer, _Out_ DWORD* written) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetMainModuleFileNameW(DWORD nBufferLength, _Out_writes_(nBufferLength) LPWSTR lpBuffer, _Out_ DWORD* written) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetTempStoragePath(DWORD nBufferLength, _Out_writes_(nBufferLength) LPWSTR lpBuffer, _Out_ DWORD* written) = 0;\n  virtual HRESULT STDMETHODCALLTYPE SupportsCreateSymbolicLink(_Out_ BOOL* pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE CreateSymbolicLinkInStorage(_In_ LPCWSTR lpSymlinkFileName, _In_ LPCWSTR lpTargetFileName, DWORD dwFlags) = 0;\n  virtual HRESULT STDMETHODCALLTYPE CreateStorageMapping(\n    _In_      IUnknown* hFile,\n    _In_      DWORD flProtect,\n    _In_      DWORD dwMaximumSizeHigh,\n    _In_      DWORD dwMaximumSizeLow,\n    _Outptr_  IUnknown** pResult) = 0;\n  virtual HRESULT MapViewOfFile(\n    _In_  IUnknown* hFileMappingObject,\n    _In_  DWORD dwDesiredAccess,\n    _In_  DWORD dwFileOffsetHigh,\n    _In_  DWORD dwFileOffsetLow,\n    _In_  SIZE_T dwNumberOfBytesToMap,\n    _Outptr_ ID3D10Blob** pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE OpenStdStorage(int standardFD, _Outptr_ IUnknown** pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetStreamDisplay(_COM_Outptr_result_maybenull_ ITextFont** textFont, _Out_ unsigned* columnCount) = 0;\n};\n\nstruct __declspec(uuid(\"e991ca8d-2045-413c-a8b8-788b2c06e14d\"))\nIDxcContainerEventsHandler : public IUnknown\n{\npublic:\n  virtual HRESULT STDMETHODCALLTYPE OnDxilContainerBuilt(_In_ IDxcBlob *pSource, _Out_ IDxcBlob **ppTarget) = 0;\n};\n\nstruct __declspec(uuid(\"0cfc5058-342b-4ff2-83f7-04c12aad3d01\"))\nIDxcContainerEvent : public IUnknown\n{\npublic:\n  virtual HRESULT STDMETHODCALLTYPE RegisterDxilContainerEventHandler(IDxcContainerEventsHandler *pHandler, UINT64 *pCookie) = 0;\n  virtual HRESULT STDMETHODCALLTYPE UnRegisterDxilContainerEventHandler(UINT64 cookie) = 0;\n};\n#endif\n"
  },
  {
    "path": "src/Wrapper/dxc/dxcisense.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// dxcisense.h                                                               //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Provides declarations for the DirectX Compiler IntelliSense component.    //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#ifndef __DXC_ISENSE__\n#define __DXC_ISENSE__\n\ntypedef enum DxcGlobalOptions\n{\n  DxcGlobalOpt_None = 0x0,\n  DxcGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1,\n  DxcGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2,\n  DxcGlobalOpt_ThreadBackgroundPriorityForAll =\n    DxcGlobalOpt_ThreadBackgroundPriorityForIndexing | DxcGlobalOpt_ThreadBackgroundPriorityForEditing\n} DxcGlobalOptions;\n\ntypedef enum DxcTokenKind\n{\n  DxcTokenKind_Punctuation = 0, // A token that contains some kind of punctuation.\n  DxcTokenKind_Keyword = 1,     // A language keyword.\n  DxcTokenKind_Identifier = 2,  // An identifier (that is not a keyword).\n  DxcTokenKind_Literal = 3,     // A numeric, string, or character literal.\n  DxcTokenKind_Comment = 4,     // A comment.\n  DxcTokenKind_Unknown = 5,     // An unknown token (possibly known to a future version).\n  DxcTokenKind_BuiltInType = 6, // A built-in type like int, void or float3.\n} DxcTokenKind;\n\ntypedef enum DxcTypeKind\n{\n  DxcTypeKind_Invalid = 0, // Reprents an invalid type (e.g., where no type is available).\n  DxcTypeKind_Unexposed = 1, // A type whose specific kind is not exposed via this interface.\n  // Builtin types\n  DxcTypeKind_Void = 2,\n  DxcTypeKind_Bool = 3,\n  DxcTypeKind_Char_U = 4,\n  DxcTypeKind_UChar = 5,\n  DxcTypeKind_Char16 = 6,\n  DxcTypeKind_Char32 = 7,\n  DxcTypeKind_UShort = 8,\n  DxcTypeKind_UInt = 9,\n  DxcTypeKind_ULong = 10,\n  DxcTypeKind_ULongLong = 11,\n  DxcTypeKind_UInt128 = 12,\n  DxcTypeKind_Char_S = 13,\n  DxcTypeKind_SChar = 14,\n  DxcTypeKind_WChar = 15,\n  DxcTypeKind_Short = 16,\n  DxcTypeKind_Int = 17,\n  DxcTypeKind_Long = 18,\n  DxcTypeKind_LongLong = 19,\n  DxcTypeKind_Int128 = 20,\n  DxcTypeKind_Float = 21,\n  DxcTypeKind_Double = 22,\n  DxcTypeKind_LongDouble = 23,\n  DxcTypeKind_NullPtr = 24,\n  DxcTypeKind_Overload = 25,\n  DxcTypeKind_Dependent = 26,\n  DxcTypeKind_ObjCId = 27,\n  DxcTypeKind_ObjCClass = 28,\n  DxcTypeKind_ObjCSel = 29,\n  DxcTypeKind_FirstBuiltin = DxcTypeKind_Void,\n  DxcTypeKind_LastBuiltin = DxcTypeKind_ObjCSel,\n\n  DxcTypeKind_Complex = 100,\n  DxcTypeKind_Pointer = 101,\n  DxcTypeKind_BlockPointer = 102,\n  DxcTypeKind_LValueReference = 103,\n  DxcTypeKind_RValueReference = 104,\n  DxcTypeKind_Record = 105,\n  DxcTypeKind_Enum = 106,\n  DxcTypeKind_Typedef = 107,\n  DxcTypeKind_ObjCInterface = 108,\n  DxcTypeKind_ObjCObjectPointer = 109,\n  DxcTypeKind_FunctionNoProto = 110,\n  DxcTypeKind_FunctionProto = 111,\n  DxcTypeKind_ConstantArray = 112,\n  DxcTypeKind_Vector = 113,\n  DxcTypeKind_IncompleteArray = 114,\n  DxcTypeKind_VariableArray = 115,\n  DxcTypeKind_DependentSizedArray = 116,\n  DxcTypeKind_MemberPointer = 117\n} DxcTypeKind;\n\n// Describes the severity of a particular diagnostic.\ntypedef enum DxcDiagnosticSeverity\n{\n  // A diagnostic that has been suppressed, e.g., by a command-line option.\n  DxcDiagnostic_Ignored = 0,\n\n  // This diagnostic is a note that should be attached to the previous (non-note) diagnostic.\n  DxcDiagnostic_Note = 1,\n\n  // This diagnostic indicates suspicious code that may not be wrong.\n  DxcDiagnostic_Warning = 2,\n\n  // This diagnostic indicates that the code is ill-formed.\n  DxcDiagnostic_Error = 3,\n\n  // This diagnostic indicates that the code is ill-formed such that future\n  // parser rec unlikely to produce useful results.\n  DxcDiagnostic_Fatal = 4\n\n} DxcDiagnosticSeverity;\n\n// Options to control the display of diagnostics.\ntypedef enum DxcDiagnosticDisplayOptions\n{\n  // Display the source-location information where the diagnostic was located.\n  DxcDiagnostic_DisplaySourceLocation = 0x01,\n\n  // If displaying the source-location information of the diagnostic,\n  // also include the column number.\n  DxcDiagnostic_DisplayColumn = 0x02,\n\n  // If displaying the source-location information of the diagnostic,\n  // also include information about source ranges in a machine-parsable format.\n  DxcDiagnostic_DisplaySourceRanges = 0x04,\n\n  // Display the option name associated with this diagnostic, if any.\n  DxcDiagnostic_DisplayOption = 0x08,\n\n  // Display the category number associated with this diagnostic, if any.\n  DxcDiagnostic_DisplayCategoryId = 0x10,\n\n  // Display the category name associated with this diagnostic, if any.\n  DxcDiagnostic_DisplayCategoryName = 0x20,\n\n\t// Display the severity of the diagnostic message.\n\tDxcDiagnostic_DisplaySeverity = 0x200\n} DxcDiagnosticDisplayOptions;\n\ntypedef enum DxcTranslationUnitFlags\n{\n  // Used to indicate that no special translation-unit options are needed.\n  DxcTranslationUnitFlags_None = 0x0,\n\n  // Used to indicate that the parser should construct a \"detailed\"\n  // preprocessing record, including all macro definitions and instantiations.\n  DxcTranslationUnitFlags_DetailedPreprocessingRecord = 0x01,\n\n  // Used to indicate that the translation unit is incomplete.\n  DxcTranslationUnitFlags_Incomplete = 0x02,\n\n  // Used to indicate that the translation unit should be built with an\n  // implicit precompiled header for the preamble.\n  DxcTranslationUnitFlags_PrecompiledPreamble = 0x04,\n\n  // Used to indicate that the translation unit should cache some\n  // code-completion results with each reparse of the source file.\n  DxcTranslationUnitFlags_CacheCompletionResults = 0x08,\n\n  // Used to indicate that the translation unit will be serialized with\n  // SaveTranslationUnit.\n  DxcTranslationUnitFlags_ForSerialization = 0x10,\n\n  // DEPRECATED\n  DxcTranslationUnitFlags_CXXChainedPCH = 0x20,\n\n  // Used to indicate that function/method bodies should be skipped while parsing.\n  DxcTranslationUnitFlags_SkipFunctionBodies = 0x40,\n\n  // Used to indicate that brief documentation comments should be\n  // included into the set of code completions returned from this translation\n  // unit.\n  DxcTranslationUnitFlags_IncludeBriefCommentsInCodeCompletion = 0x80,\n\n  // Used to indicate that compilation should occur on the caller's thread.\n  DxcTranslationUnitFlags_UseCallerThread = 0x800\n} DxcTranslationUnitFlags;\n\ntypedef enum DxcCursorFormatting\n{\n  DxcCursorFormatting_Default = 0x0,             // Default rules, language-insensitive formatting.\n  DxcCursorFormatting_UseLanguageOptions = 0x1,  // Language-sensitive formatting.\n  DxcCursorFormatting_SuppressSpecifiers = 0x2,  // Supresses type specifiers.\n  DxcCursorFormatting_SuppressTagKeyword = 0x4,  // Suppressed tag keyword (eg, 'class').\n  DxcCursorFormatting_IncludeNamespaceKeyword = 0x8,  // Include namespace keyword.\n} DxcCursorFormatting;\n\nenum DxcCursorKind {\n  /* Declarations */\n  DxcCursor_UnexposedDecl = 1, // A declaration whose specific kind is not exposed via this interface.\n  DxcCursor_StructDecl = 2, // A C or C++ struct.\n  DxcCursor_UnionDecl = 3, // A C or C++ union.\n  DxcCursor_ClassDecl = 4, // A C++ class.\n  DxcCursor_EnumDecl = 5, // An enumeration.\n  DxcCursor_FieldDecl = 6, // A field (in C) or non-static data member (in C++) in a struct, union, or C++ class.\n  DxcCursor_EnumConstantDecl = 7, // An enumerator constant.\n  DxcCursor_FunctionDecl = 8, // A function.\n  DxcCursor_VarDecl = 9, // A variable.\n  DxcCursor_ParmDecl = 10, // A function or method parameter.\n  DxcCursor_ObjCInterfaceDecl = 11, // An Objective-C interface.\n  DxcCursor_ObjCCategoryDecl = 12, // An Objective-C interface for a category.\n  DxcCursor_ObjCProtocolDecl = 13, // An Objective-C protocol declaration.\n  DxcCursor_ObjCPropertyDecl = 14, // An Objective-C property declaration.\n  DxcCursor_ObjCIvarDecl = 15, // An Objective-C instance variable.\n  DxcCursor_ObjCInstanceMethodDecl = 16, // An Objective-C instance method.\n  DxcCursor_ObjCClassMethodDecl = 17, // An Objective-C class method.\n  DxcCursor_ObjCImplementationDecl = 18, // An Objective-C \\@implementation.\n  DxcCursor_ObjCCategoryImplDecl = 19, // An Objective-C \\@implementation for a category.\n  DxcCursor_TypedefDecl = 20, // A typedef\n  DxcCursor_CXXMethod = 21, // A C++ class method.\n  DxcCursor_Namespace = 22, // A C++ namespace.\n  DxcCursor_LinkageSpec = 23, // A linkage specification, e.g. 'extern \"C\"'.\n  DxcCursor_Constructor = 24, // A C++ constructor.\n  DxcCursor_Destructor = 25, // A C++ destructor.\n  DxcCursor_ConversionFunction = 26, // A C++ conversion function.\n  DxcCursor_TemplateTypeParameter = 27, // A C++ template type parameter.\n  DxcCursor_NonTypeTemplateParameter = 28, // A C++ non-type template parameter.\n  DxcCursor_TemplateTemplateParameter = 29, // A C++ template template parameter.\n  DxcCursor_FunctionTemplate = 30, // A C++ function template.\n  DxcCursor_ClassTemplate = 31, // A C++ class template.\n  DxcCursor_ClassTemplatePartialSpecialization = 32, // A C++ class template partial specialization.\n  DxcCursor_NamespaceAlias = 33, // A C++ namespace alias declaration.\n  DxcCursor_UsingDirective = 34, // A C++ using directive.\n  DxcCursor_UsingDeclaration = 35, // A C++ using declaration.\n  DxcCursor_TypeAliasDecl = 36, // A C++ alias declaration\n  DxcCursor_ObjCSynthesizeDecl = 37, // An Objective-C \\@synthesize definition.\n  DxcCursor_ObjCDynamicDecl = 38, // An Objective-C \\@dynamic definition.\n  DxcCursor_CXXAccessSpecifier = 39, // An access specifier.\n\n  DxcCursor_FirstDecl = DxcCursor_UnexposedDecl,\n  DxcCursor_LastDecl = DxcCursor_CXXAccessSpecifier,\n\n  /* References */\n  DxcCursor_FirstRef = 40, /* Decl references */\n  DxcCursor_ObjCSuperClassRef = 40,\n  DxcCursor_ObjCProtocolRef = 41,\n  DxcCursor_ObjCClassRef = 42,\n  /**\n  * \\brief A reference to a type declaration.\n  *\n  * A type reference occurs anywhere where a type is named but not\n  * declared. For example, given:\n  *\n  * \\code\n  * typedef unsigned size_type;\n  * size_type size;\n  * \\endcode\n  *\n  * The typedef is a declaration of size_type (DxcCursor_TypedefDecl),\n  * while the type of the variable \"size\" is referenced. The cursor\n  * referenced by the type of size is the typedef for size_type.\n  */\n  DxcCursor_TypeRef = 43, // A reference to a type declaration.\n  DxcCursor_CXXBaseSpecifier = 44,\n  DxcCursor_TemplateRef = 45, // A reference to a class template, function template, template template parameter, or class template partial specialization.\n  DxcCursor_NamespaceRef = 46, // A reference to a namespace or namespace alias.\n  DxcCursor_MemberRef = 47, // A reference to a member of a struct, union, or class that occurs in some non-expression context, e.g., a designated initializer.\n  /**\n  * \\brief A reference to a labeled statement.\n  *\n  * This cursor kind is used to describe the jump to \"start_over\" in the\n  * goto statement in the following example:\n  *\n  * \\code\n  *   start_over:\n  *     ++counter;\n  *\n  *     goto start_over;\n  * \\endcode\n  *\n  * A label reference cursor refers to a label statement.\n  */\n  DxcCursor_LabelRef = 48, // A reference to a labeled statement.\n\n  // A reference to a set of overloaded functions or function templates\n  // that has not yet been resolved to a specific function or function template.\n  //\n  // An overloaded declaration reference cursor occurs in C++ templates where\n  // a dependent name refers to a function.\n  DxcCursor_OverloadedDeclRef = 49,\n  DxcCursor_VariableRef = 50, // A reference to a variable that occurs in some non-expression context, e.g., a C++ lambda capture list.\n\n  DxcCursor_LastRef = DxcCursor_VariableRef,\n\n  /* Error conditions */\n  DxcCursor_FirstInvalid = 70,\n  DxcCursor_InvalidFile = 70,\n  DxcCursor_NoDeclFound = 71,\n  DxcCursor_NotImplemented = 72,\n  DxcCursor_InvalidCode = 73,\n  DxcCursor_LastInvalid = DxcCursor_InvalidCode,\n\n  /* Expressions */\n  DxcCursor_FirstExpr = 100,\n\n  /**\n  * \\brief An expression whose specific kind is not exposed via this\n  * interface.\n  *\n  * Unexposed expressions have the same operations as any other kind\n  * of expression; one can extract their location information,\n  * spelling, children, etc. However, the specific kind of the\n  * expression is not reported.\n  */\n  DxcCursor_UnexposedExpr = 100, // An expression whose specific kind is not exposed via this interface.\n  DxcCursor_DeclRefExpr = 101, // An expression that refers to some value declaration, such as a function, varible, or enumerator.\n  DxcCursor_MemberRefExpr = 102, // An expression that refers to a member of a struct, union, class, Objective-C class, etc.\n  DxcCursor_CallExpr = 103, // An expression that calls a function.\n  DxcCursor_ObjCMessageExpr = 104, // An expression that sends a message to an Objective-C object or class.\n  DxcCursor_BlockExpr = 105, // An expression that represents a block literal.\n  DxcCursor_IntegerLiteral = 106, // An integer literal.\n  DxcCursor_FloatingLiteral = 107, // A floating point number literal.\n  DxcCursor_ImaginaryLiteral = 108, // An imaginary number literal.\n  DxcCursor_StringLiteral = 109, // A string literal.\n  DxcCursor_CharacterLiteral = 110, // A character literal.\n  DxcCursor_ParenExpr = 111, // A parenthesized expression, e.g. \"(1)\". This AST node is only formed if full location information is requested.\n  DxcCursor_UnaryOperator = 112, // This represents the unary-expression's (except sizeof and alignof).\n  DxcCursor_ArraySubscriptExpr = 113, // [C99 6.5.2.1] Array Subscripting.\n  DxcCursor_BinaryOperator = 114, // A builtin binary operation expression such as \"x + y\" or \"x <= y\".\n  DxcCursor_CompoundAssignOperator = 115, // Compound assignment such as \"+=\".\n  DxcCursor_ConditionalOperator = 116, // The ?: ternary operator.\n  DxcCursor_CStyleCastExpr = 117, // An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr.cast]), which uses the syntax (Type)expr, eg: (int)f.\n  DxcCursor_CompoundLiteralExpr = 118, // [C99 6.5.2.5]\n  DxcCursor_InitListExpr = 119, // Describes an C or C++ initializer list.\n  DxcCursor_AddrLabelExpr = 120, // The GNU address of label extension, representing &&label.\n  DxcCursor_StmtExpr = 121, // This is the GNU Statement Expression extension: ({int X=4; X;})\n  DxcCursor_GenericSelectionExpr = 122, // Represents a C11 generic selection.\n\n  /** \\brief Implements the GNU __null extension, which is a name for a null\n  * pointer constant that has integral type (e.g., int or long) and is the same\n  * size and alignment as a pointer.\n  *\n  * The __null extension is typically only used by system headers, which define\n  * NULL as __null in C++ rather than using 0 (which is an integer that may not\n  * match the size of a pointer).\n  */\n  DxcCursor_GNUNullExpr = 123,\n  DxcCursor_CXXStaticCastExpr = 124, // C++'s static_cast<> expression.\n  DxcCursor_CXXDynamicCastExpr = 125, // C++'s dynamic_cast<> expression.\n  DxcCursor_CXXReinterpretCastExpr = 126, // C++'s reinterpret_cast<> expression.\n  DxcCursor_CXXConstCastExpr = 127, // C++'s const_cast<> expression.\n\n  /** \\brief Represents an explicit C++ type conversion that uses \"functional\"\n  * notion (C++ [expr.type.conv]).\n  *\n  * Example:\n  * \\code\n  *   x = int(0.5);\n  * \\endcode\n  */\n  DxcCursor_CXXFunctionalCastExpr = 128,\n  DxcCursor_CXXTypeidExpr = 129, // A C++ typeid expression (C++ [expr.typeid]).\n  DxcCursor_CXXBoolLiteralExpr = 130, // [C++ 2.13.5] C++ Boolean Literal.\n  DxcCursor_CXXNullPtrLiteralExpr = 131, // [C++0x 2.14.7] C++ Pointer Literal.\n  DxcCursor_CXXThisExpr = 132, // Represents the \"this\" expression in C++\n  DxcCursor_CXXThrowExpr = 133, // [C++ 15] C++ Throw Expression, both 'throw' and 'throw' assignment-expression.\n  DxcCursor_CXXNewExpr = 134, // A new expression for memory allocation and constructor calls, e.g: \"new CXXNewExpr(foo)\".\n  DxcCursor_CXXDeleteExpr = 135, // A delete expression for memory deallocation and destructor calls, e.g. \"delete[] pArray\".\n  DxcCursor_UnaryExpr = 136, // A unary expression.\n  DxcCursor_ObjCStringLiteral = 137, // An Objective-C string literal i.e. @\"foo\".\n  DxcCursor_ObjCEncodeExpr = 138, // An Objective-C \\@encode expression.\n  DxcCursor_ObjCSelectorExpr = 139, // An Objective-C \\@selector expression.\n  DxcCursor_ObjCProtocolExpr = 140, // An Objective-C \\@protocol expression.\n\n  /** \\brief An Objective-C \"bridged\" cast expression, which casts between\n  * Objective-C pointers and C pointers, transferring ownership in the process.\n  *\n  * \\code\n  *   NSString *str = (__bridge_transfer NSString *)CFCreateString();\n  * \\endcode\n  */\n  DxcCursor_ObjCBridgedCastExpr = 141,\n\n  /** \\brief Represents a C++0x pack expansion that produces a sequence of\n  * expressions.\n  *\n  * A pack expansion expression contains a pattern (which itself is an\n  * expression) followed by an ellipsis. For example:\n  *\n  * \\code\n  * template<typename F, typename ...Types>\n  * void forward(F f, Types &&...args) {\n  *  f(static_cast<Types&&>(args)...);\n  * }\n  * \\endcode\n  */\n  DxcCursor_PackExpansionExpr = 142,\n\n  /** \\brief Represents an expression that computes the length of a parameter\n  * pack.\n  *\n  * \\code\n  * template<typename ...Types>\n  * struct count {\n  *   static const unsigned value = sizeof...(Types);\n  * };\n  * \\endcode\n  */\n  DxcCursor_SizeOfPackExpr = 143,\n\n  /* \\brief Represents a C++ lambda expression that produces a local function\n  * object.\n  *\n  * \\code\n  * void abssort(float *x, unsigned N) {\n  *   std::sort(x, x + N,\n  *             [](float a, float b) {\n  *               return std::abs(a) < std::abs(b);\n  *             });\n  * }\n  * \\endcode\n  */\n  DxcCursor_LambdaExpr = 144,\n  DxcCursor_ObjCBoolLiteralExpr = 145, // Objective-c Boolean Literal.\n  DxcCursor_ObjCSelfExpr = 146, // Represents the \"self\" expression in a ObjC method.\n  DxcCursor_LastExpr = DxcCursor_ObjCSelfExpr,\n\n  /* Statements */\n  DxcCursor_FirstStmt = 200,\n  /**\n  * \\brief A statement whose specific kind is not exposed via this\n  * interface.\n  *\n  * Unexposed statements have the same operations as any other kind of\n  * statement; one can extract their location information, spelling,\n  * children, etc. However, the specific kind of the statement is not\n  * reported.\n  */\n  DxcCursor_UnexposedStmt = 200,\n\n  /** \\brief A labelled statement in a function.\n  *\n  * This cursor kind is used to describe the \"start_over:\" label statement in\n  * the following example:\n  *\n  * \\code\n  *   start_over:\n  *     ++counter;\n  * \\endcode\n  *\n  */\n  DxcCursor_LabelStmt = 201,\n  DxcCursor_CompoundStmt = 202, // A group of statements like { stmt stmt }. This cursor kind is used to describe compound statements, e.g. function bodies.\n  DxcCursor_CaseStmt = 203, // A case statement.\n  DxcCursor_DefaultStmt = 204, // A default statement.\n  DxcCursor_IfStmt = 205, // An if statement\n  DxcCursor_SwitchStmt = 206, // A switch statement.\n  DxcCursor_WhileStmt = 207, // A while statement.\n  DxcCursor_DoStmt = 208, // A do statement.\n  DxcCursor_ForStmt = 209, // A for statement.\n  DxcCursor_GotoStmt = 210, // A goto statement.\n  DxcCursor_IndirectGotoStmt = 211, // An indirect goto statement.\n  DxcCursor_ContinueStmt = 212, // A continue statement.\n  DxcCursor_BreakStmt = 213, // A break statement.\n  DxcCursor_ReturnStmt = 214, // A return statement.\n  DxcCursor_GCCAsmStmt = 215, // A GCC inline assembly statement extension.\n  DxcCursor_AsmStmt = DxcCursor_GCCAsmStmt,\n\n  DxcCursor_ObjCAtTryStmt = 216, // Objective-C's overall \\@try-\\@catch-\\@finally statement.\n  DxcCursor_ObjCAtCatchStmt = 217, // Objective-C's \\@catch statement.\n  DxcCursor_ObjCAtFinallyStmt = 218, // Objective-C's \\@finally statement.\n  DxcCursor_ObjCAtThrowStmt = 219, // Objective-C's \\@throw statement.\n  DxcCursor_ObjCAtSynchronizedStmt = 220, // Objective-C's \\@synchronized statement.\n  DxcCursor_ObjCAutoreleasePoolStmt = 221, // Objective-C's autorelease pool statement.\n  DxcCursor_ObjCForCollectionStmt = 222, // Objective-C's collection statement.\n\n  DxcCursor_CXXCatchStmt = 223, // C++'s catch statement.\n  DxcCursor_CXXTryStmt = 224, // C++'s try statement.\n  DxcCursor_CXXForRangeStmt = 225, // C++'s for (* : *) statement.\n\n  DxcCursor_SEHTryStmt = 226, // Windows Structured Exception Handling's try statement.\n  DxcCursor_SEHExceptStmt = 227, // Windows Structured Exception Handling's except statement.\n  DxcCursor_SEHFinallyStmt = 228, // Windows Structured Exception Handling's finally statement.\n\n  DxcCursor_MSAsmStmt = 229, // A MS inline assembly statement extension.\n  DxcCursor_NullStmt = 230, // The null satement \";\": C99 6.8.3p3.\n  DxcCursor_DeclStmt = 231, // Adaptor class for mixing declarations with statements and expressions.\n  DxcCursor_OMPParallelDirective = 232, // OpenMP parallel directive.\n  DxcCursor_OMPSimdDirective = 233,  // OpenMP SIMD directive.\n  DxcCursor_OMPForDirective = 234,  // OpenMP for directive.\n  DxcCursor_OMPSectionsDirective = 235,  // OpenMP sections directive.\n  DxcCursor_OMPSectionDirective = 236,  // OpenMP section directive.\n  DxcCursor_OMPSingleDirective = 237,  // OpenMP single directive.\n  DxcCursor_OMPParallelForDirective = 238,  // OpenMP parallel for directive.\n  DxcCursor_OMPParallelSectionsDirective = 239,  // OpenMP parallel sections directive.\n  DxcCursor_OMPTaskDirective = 240,  // OpenMP task directive.\n  DxcCursor_OMPMasterDirective = 241,  // OpenMP master directive.\n  DxcCursor_OMPCriticalDirective = 242,  // OpenMP critical directive.\n  DxcCursor_OMPTaskyieldDirective = 243,  // OpenMP taskyield directive.\n  DxcCursor_OMPBarrierDirective = 244,  // OpenMP barrier directive.\n  DxcCursor_OMPTaskwaitDirective = 245,  // OpenMP taskwait directive.\n  DxcCursor_OMPFlushDirective = 246,  // OpenMP flush directive.\n  DxcCursor_SEHLeaveStmt = 247,  // Windows Structured Exception Handling's leave statement.\n  DxcCursor_OMPOrderedDirective = 248,  // OpenMP ordered directive.\n  DxcCursor_OMPAtomicDirective = 249,  // OpenMP atomic directive.\n  DxcCursor_OMPForSimdDirective = 250,  // OpenMP for SIMD directive.\n  DxcCursor_OMPParallelForSimdDirective = 251,  // OpenMP parallel for SIMD directive.\n  DxcCursor_OMPTargetDirective = 252,  // OpenMP target directive.\n  DxcCursor_OMPTeamsDirective = 253,  // OpenMP teams directive.\n  DxcCursor_OMPTaskgroupDirective = 254,  // OpenMP taskgroup directive.\n  DxcCursor_OMPCancellationPointDirective = 255,  // OpenMP cancellation point directive.\n  DxcCursor_OMPCancelDirective = 256,  // OpenMP cancel directive.\n  DxcCursor_LastStmt = DxcCursor_OMPCancelDirective,\n\n  DxcCursor_TranslationUnit = 300, // Cursor that represents the translation unit itself.\n\n  /* Attributes */\n  DxcCursor_FirstAttr = 400,\n  /**\n  * \\brief An attribute whose specific kind is not exposed via this\n  * interface.\n  */\n  DxcCursor_UnexposedAttr = 400,\n\n  DxcCursor_IBActionAttr = 401,\n  DxcCursor_IBOutletAttr = 402,\n  DxcCursor_IBOutletCollectionAttr = 403,\n  DxcCursor_CXXFinalAttr = 404,\n  DxcCursor_CXXOverrideAttr = 405,\n  DxcCursor_AnnotateAttr = 406,\n  DxcCursor_AsmLabelAttr = 407,\n  DxcCursor_PackedAttr = 408,\n  DxcCursor_PureAttr = 409,\n  DxcCursor_ConstAttr = 410,\n  DxcCursor_NoDuplicateAttr = 411,\n  DxcCursor_CUDAConstantAttr = 412,\n  DxcCursor_CUDADeviceAttr = 413,\n  DxcCursor_CUDAGlobalAttr = 414,\n  DxcCursor_CUDAHostAttr = 415,\n  DxcCursor_CUDASharedAttr = 416,\n  DxcCursor_LastAttr = DxcCursor_CUDASharedAttr,\n\n  /* Preprocessing */\n  DxcCursor_PreprocessingDirective = 500,\n  DxcCursor_MacroDefinition = 501,\n  DxcCursor_MacroExpansion = 502,\n  DxcCursor_MacroInstantiation = DxcCursor_MacroExpansion,\n  DxcCursor_InclusionDirective = 503,\n  DxcCursor_FirstPreprocessing = DxcCursor_PreprocessingDirective,\n  DxcCursor_LastPreprocessing = DxcCursor_InclusionDirective,\n\n  /* Extra Declarations */\n  /**\n  * \\brief A module import declaration.\n  */\n  DxcCursor_ModuleImportDecl = 600,\n  DxcCursor_FirstExtraDecl = DxcCursor_ModuleImportDecl,\n  DxcCursor_LastExtraDecl = DxcCursor_ModuleImportDecl\n};\n\nenum DxcCursorKindFlags\n{\n  DxcCursorKind_None = 0,\n  DxcCursorKind_Declaration = 0x1,\n  DxcCursorKind_Reference = 0x2,\n  DxcCursorKind_Expression = 0x4,\n  DxcCursorKind_Statement = 0x8,\n  DxcCursorKind_Attribute = 0x10,\n  DxcCursorKind_Invalid = 0x20,\n  DxcCursorKind_TranslationUnit = 0x40,\n  DxcCursorKind_Preprocessing = 0x80,\n  DxcCursorKind_Unexposed = 0x100,\n};\n\nstruct IDxcCursor;\nstruct IDxcDiagnostic;\nstruct IDxcFile;\nstruct IDxcInclusion;\nstruct IDxcIntelliSense;\nstruct IDxcIndex;\nstruct IDxcSourceLocation;\nstruct IDxcSourceRange;\nstruct IDxcToken;\nstruct IDxcTranslationUnit;\nstruct IDxcType;\nstruct IDxcUnsavedFile;\n\nstruct __declspec(uuid(\"1467b985-288d-4d2a-80c1-ef89c42c40bc\"))\nIDxcCursor : public IUnknown\n{\n  virtual HRESULT STDMETHODCALLTYPE GetExtent(_Outptr_result_nullonfailure_ IDxcSourceRange** pRange) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetLocation(_Outptr_result_nullonfailure_ IDxcSourceLocation** pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetKind(_Out_ DxcCursorKind* pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetKindFlags(_Out_ DxcCursorKindFlags* pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetSemanticParent(_Outptr_result_nullonfailure_ IDxcCursor** pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetLexicalParent(_Outptr_result_nullonfailure_ IDxcCursor** pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetCursorType(_Outptr_result_nullonfailure_ IDxcType** pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetNumArguments(_Out_ int* pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetArgumentAt(int index, _Outptr_result_nullonfailure_ IDxcCursor** pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetReferencedCursor(_Outptr_result_nullonfailure_ IDxcCursor** pResult) = 0;\n  /// <summary>For a cursor that is either a reference to or a declaration of some entity, retrieve a cursor that describes the definition of that entity.</summary>\n  /// <remarks>Some entities can be declared multiple times within a translation unit, but only one of those declarations can also be a definition.</remarks>\n  /// <returns>A cursor to the definition of this entity; nullptr if there is no definition in this translation unit.</returns>\n  virtual HRESULT STDMETHODCALLTYPE GetDefinitionCursor(_Outptr_result_nullonfailure_ IDxcCursor** pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE FindReferencesInFile(\n    _In_ IDxcFile* file, unsigned skip, unsigned top,\n    _Out_ unsigned* pResultLength, _Outptr_result_buffer_maybenull_(*pResultLength) IDxcCursor*** pResult) = 0;\n  /// <summary>Gets the name for the entity references by the cursor, e.g. foo for an 'int foo' variable.</summary>\n  virtual HRESULT STDMETHODCALLTYPE GetSpelling(_Outptr_result_maybenull_ LPSTR* pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE IsEqualTo(_In_ IDxcCursor* other, _Out_ BOOL* pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE IsNull(_Out_ BOOL* pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE IsDefinition(_Out_ BOOL* pResult) = 0;\n  /// <summary>Gets the display name for the cursor, including e.g. parameter types for a function.</summary>\n  virtual HRESULT STDMETHODCALLTYPE GetDisplayName(_Out_ BSTR* pResult) = 0;\n  /// <summary>Gets the qualified name for the symbol the cursor refers to.</summary>\n  virtual HRESULT STDMETHODCALLTYPE GetQualifiedName(BOOL includeTemplateArgs, _Outptr_result_maybenull_ BSTR* pResult) = 0;\n  /// <summary>Gets a name for the cursor, applying the specified formatting flags.</summary>\n  virtual HRESULT STDMETHODCALLTYPE GetFormattedName(DxcCursorFormatting formatting , _Outptr_result_maybenull_ BSTR* pResult) = 0;\n  /// <summary>Gets children in pResult up to top elements.</summary>\n  virtual HRESULT STDMETHODCALLTYPE GetChildren(\n    unsigned skip, unsigned top,\n    _Out_ unsigned* pResultLength, _Outptr_result_buffer_maybenull_(*pResultLength) IDxcCursor*** pResult) = 0;\n  /// <summary>Gets the cursor following a location within a compound cursor.</summary>\n  virtual HRESULT STDMETHODCALLTYPE GetSnappedChild(_In_ IDxcSourceLocation* location, _Outptr_result_maybenull_ IDxcCursor** pResult) = 0;\n};\n\nstruct __declspec(uuid(\"4f76b234-3659-4d33-99b0-3b0db994b564\"))\nIDxcDiagnostic : public IUnknown\n{\n  virtual HRESULT STDMETHODCALLTYPE FormatDiagnostic(\n    DxcDiagnosticDisplayOptions options,\n    _Outptr_result_maybenull_ LPSTR* pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetSeverity(_Out_ DxcDiagnosticSeverity* pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetLocation(_Outptr_result_nullonfailure_ IDxcSourceLocation** pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetSpelling(_Outptr_result_maybenull_ LPSTR* pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetCategoryText(_Outptr_result_maybenull_ LPSTR* pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetNumRanges(_Out_ unsigned* pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetRangeAt(unsigned index, _Outptr_result_nullonfailure_ IDxcSourceRange** pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetNumFixIts(_Out_ unsigned* pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetFixItAt(unsigned index,\n    _Outptr_result_nullonfailure_ IDxcSourceRange** pReplacementRange, _Outptr_result_maybenull_ LPSTR* pText) = 0;\n};\n\nstruct __declspec(uuid(\"bb2fca9e-1478-47ba-b08c-2c502ada4895\"))\nIDxcFile : public IUnknown\n{\n  /// <summary>Gets the file name for this file.</summary>\n  virtual HRESULT STDMETHODCALLTYPE GetName(_Outptr_result_maybenull_ LPSTR* pResult) = 0;\n  /// <summary>Checks whether this file is equal to the other specified file.</summary>\n  virtual HRESULT STDMETHODCALLTYPE IsEqualTo(_In_ IDxcFile* other, _Out_ BOOL* pResult) = 0;\n};\n\nstruct __declspec(uuid(\"0c364d65-df44-4412-888e-4e552fc5e3d6\"))\nIDxcInclusion : public IUnknown\n{\n  virtual HRESULT STDMETHODCALLTYPE GetIncludedFile(_Outptr_result_nullonfailure_ IDxcFile** pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetStackLength(_Out_ unsigned *pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetStackItem(unsigned index, _Outptr_result_nullonfailure_ IDxcSourceLocation **pResult) = 0;\n};\n\nstruct __declspec(uuid(\"b1f99513-46d6-4112-8169-dd0d6053f17d\"))\nIDxcIntelliSense : public IUnknown\n{\n  virtual HRESULT STDMETHODCALLTYPE CreateIndex(_Outptr_result_nullonfailure_ IDxcIndex** index) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetNullLocation(_Outptr_result_nullonfailure_ IDxcSourceLocation** location) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetNullRange(_Outptr_result_nullonfailure_ IDxcSourceRange** location) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetRange(\n    _In_ IDxcSourceLocation* start,\n    _In_ IDxcSourceLocation* end,\n    _Outptr_result_nullonfailure_ IDxcSourceRange** location) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetDefaultDiagnosticDisplayOptions(\n    _Out_ DxcDiagnosticDisplayOptions* pValue) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetDefaultEditingTUOptions(_Out_ DxcTranslationUnitFlags* pValue) = 0;\n  virtual HRESULT STDMETHODCALLTYPE CreateUnsavedFile(_In_ LPCSTR fileName, _In_ LPCSTR contents, unsigned contentLength, _Outptr_result_nullonfailure_ IDxcUnsavedFile** pResult) = 0;\n};\n\nstruct __declspec(uuid(\"937824a0-7f5a-4815-9ba7-7fc0424f4173\"))\nIDxcIndex : public IUnknown\n{\n  virtual HRESULT STDMETHODCALLTYPE SetGlobalOptions(DxcGlobalOptions options) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetGlobalOptions(_Out_ DxcGlobalOptions* options) = 0;\n  virtual HRESULT STDMETHODCALLTYPE ParseTranslationUnit(\n      _In_z_ const char *source_filename,\n      _In_count_(num_command_line_args) const char * const *command_line_args,\n      int num_command_line_args,\n      _In_count_(num_unsaved_files) IDxcUnsavedFile** unsaved_files,\n      unsigned num_unsaved_files,\n      DxcTranslationUnitFlags options,\n      _Out_ IDxcTranslationUnit** pTranslationUnit) = 0;\n};\n\nstruct __declspec(uuid(\"8e7ddf1c-d7d3-4d69-b286-85fccba1e0cf\"))\nIDxcSourceLocation : public IUnknown\n{\n  virtual HRESULT STDMETHODCALLTYPE IsEqualTo(_In_ IDxcSourceLocation* other, _Out_ BOOL* pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetSpellingLocation(\n    _Outptr_opt_ IDxcFile** pFile,\n    _Out_opt_ unsigned* pLine,\n    _Out_opt_ unsigned* pCol,\n    _Out_opt_ unsigned* pOffset) = 0;\n  virtual HRESULT STDMETHODCALLTYPE IsNull(_Out_ BOOL* pResult) = 0;\n};\n\nstruct __declspec(uuid(\"f1359b36-a53f-4e81-b514-b6b84122a13f\"))\nIDxcSourceRange : public IUnknown\n{\n  virtual HRESULT STDMETHODCALLTYPE IsNull(_Out_ BOOL* pValue) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetStart(_Out_ IDxcSourceLocation** pValue) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetEnd(_Out_ IDxcSourceLocation** pValue) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetOffsets(_Out_ unsigned* startOffset, _Out_ unsigned* endOffset) = 0;\n};\n\nstruct __declspec(uuid(\"7f90b9ff-a275-4932-97d8-3cfd234482a2\"))\nIDxcToken : public IUnknown\n{\n  virtual HRESULT STDMETHODCALLTYPE GetKind(_Out_ DxcTokenKind* pValue) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetLocation(_Out_ IDxcSourceLocation** pValue) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetExtent(_Out_ IDxcSourceRange** pValue) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetSpelling(_Out_ LPSTR* pValue) = 0;\n};\n\nstruct __declspec(uuid(\"9677dee0-c0e5-46a1-8b40-3db3168be63d\"))\nIDxcTranslationUnit : public IUnknown\n{\n  virtual HRESULT STDMETHODCALLTYPE GetCursor(_Out_ IDxcCursor** pCursor) = 0;\n  virtual HRESULT STDMETHODCALLTYPE Tokenize(\n    _In_ IDxcSourceRange* range,\n    _Outptr_result_buffer_maybenull_(*pTokenCount) IDxcToken*** pTokens,\n    _Out_ unsigned* pTokenCount) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetLocation(\n    _In_ IDxcFile* file,\n    unsigned line, unsigned column,\n    _Outptr_result_nullonfailure_ IDxcSourceLocation** pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetNumDiagnostics(_Out_ unsigned* pValue) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetDiagnostic(unsigned index, _Outptr_result_nullonfailure_ IDxcDiagnostic** pValue) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetFile(_In_ const char* name, _Outptr_result_nullonfailure_ IDxcFile** pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetFileName(_Outptr_result_maybenull_ LPSTR* pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE Reparse(\n    _In_count_(num_unsaved_files) IDxcUnsavedFile** unsaved_files,\n    unsigned num_unsaved_files) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetCursorForLocation(_In_ IDxcSourceLocation* location, _Outptr_result_nullonfailure_ IDxcCursor** pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetLocationForOffset(_In_ IDxcFile* file, unsigned offset, _Outptr_result_nullonfailure_ IDxcSourceLocation** pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetSkippedRanges(_In_ IDxcFile* file, _Out_ unsigned* pResultCount, _Outptr_result_buffer_(*pResultCount) IDxcSourceRange*** pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetDiagnosticDetails(unsigned index, DxcDiagnosticDisplayOptions options,\n    _Out_ unsigned* errorCode,\n    _Out_ unsigned* errorLine,\n    _Out_ unsigned* errorColumn,\n    _Out_ BSTR* errorFile,\n    _Out_ unsigned* errorOffset,\n    _Out_ unsigned* errorLength,\n    _Out_ BSTR* errorMessage) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetInclusionList(_Out_ unsigned* pResultCount, _Outptr_result_buffer_(*pResultCount) IDxcInclusion*** pResult) = 0;\n};\n\nstruct __declspec(uuid(\"2ec912fd-b144-4a15-ad0d-1c5439c81e46\"))\nIDxcType : public IUnknown\n{\n  virtual HRESULT STDMETHODCALLTYPE GetSpelling(_Outptr_result_z_ LPSTR* pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE IsEqualTo(_In_ IDxcType* other, _Out_ BOOL* pResult) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetKind(_Out_ DxcTypeKind* pResult) = 0;\n};\n\nstruct __declspec(uuid(\"8ec00f98-07d0-4e60-9d7c-5a50b5b0017f\"))\nIDxcUnsavedFile : public IUnknown\n{\n  virtual HRESULT STDMETHODCALLTYPE GetFileName(_Outptr_result_z_ LPSTR* pFileName) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetContents(_Outptr_result_z_ LPSTR* pContents) = 0;\n  virtual HRESULT STDMETHODCALLTYPE GetLength(_Out_ unsigned* pLength) = 0;\n};\n\n// Fun fact: 'extern' is required because const is by default static in C++, so\n// CLSID_DxcIntelliSense is not visible externally (this is OK in C, since const is\n// not by default static in C)\n__declspec(selectany)\nextern const CLSID CLSID_DxcIntelliSense = { /* 3047833c-d1c0-4b8e-9d40-102878605985 */\n    0x3047833c,\n    0xd1c0,\n    0x4b8e,\n    {0x9d, 0x40, 0x10, 0x28, 0x78, 0x60, 0x59, 0x85}\n  };\n\n#endif\n"
  },
  {
    "path": "src/Wrapper/dxc/dxctools.h",
    "content": "///////////////////////////////////////////////////////////////////////////////\n//                                                                           //\n// dxctools.h                                                                //\n// Copyright (C) Microsoft Corporation. All rights reserved.                 //\n// This file is distributed under the University of Illinois Open Source     //\n// License. See LICENSE.TXT for details.                                     //\n//                                                                           //\n// Provides declarations for the DirectX Compiler tooling components.        //\n//                                                                           //\n///////////////////////////////////////////////////////////////////////////////\n\n#ifndef __DXC_TOOLS__\n#define __DXC_TOOLS__\n\n#include <dxc/dxcapi.h>\n\nenum RewriterOptionMask {\n  Default = 0,\n  SkipFunctionBody = 1,\n  SkipStatic = 2,\n  GlobalExternByDefault = 4,\n  KeepUserMacro = 8,\n};\n\nstruct __declspec(uuid(\"c012115b-8893-4eb9-9c5a-111456ea1c45\"))\nIDxcRewriter : public IUnknown {\n\n  virtual HRESULT STDMETHODCALLTYPE RemoveUnusedGlobals(_In_ IDxcBlobEncoding *pSource,\n                                                        _In_z_ LPCWSTR entryPoint,\n                                                        _In_count_(defineCount) DxcDefine *pDefines,\n                                                        _In_ UINT32 defineCount,\n                                                        _COM_Outptr_ IDxcOperationResult **ppResult) = 0;\n\n\n  virtual HRESULT STDMETHODCALLTYPE RewriteUnchanged(_In_ IDxcBlobEncoding *pSource,\n                                                     _In_count_(defineCount) DxcDefine *pDefines,\n                                                     _In_ UINT32 defineCount,\n                                                     _COM_Outptr_ IDxcOperationResult **ppResult) = 0;\n\n  virtual HRESULT STDMETHODCALLTYPE RewriteUnchangedWithInclude(_In_ IDxcBlobEncoding *pSource,\n                                                     // Optional file name for pSource. Used in errors and include handlers.\n                                                     _In_opt_ LPCWSTR pSourceName,\n                                                     _In_count_(defineCount) DxcDefine *pDefines,\n                                                     _In_ UINT32 defineCount,\n                                                     // user-provided interface to handle #include directives (optional)\n                                                     _In_opt_ IDxcIncludeHandler *pIncludeHandler,\n                                                     _In_ UINT32  rewriteOption,\n                                                     _COM_Outptr_ IDxcOperationResult **ppResult) = 0;\n\n};\n\n__declspec(selectany)\nextern const CLSID CLSID_DxcRewriter = { /* b489b951-e07f-40b3-968d-93e124734da4 */\n  0xb489b951,\n  0xe07f,\n  0x40b3,\n  { 0x96, 0x8d, 0x93, 0xe1, 0x24, 0x73, 0x4d, 0xa4 }\n};\n\n#endif\n"
  },
  {
    "path": "src/Wrapper/elf.h",
    "content": "/*\n * CDDL HEADER START\n *\n * The contents of this file are subject to the terms of the\n * Common Development and Distribution License (the \"License\").\n * You may not use this file except in compliance with the License.\n *\n * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE\n * or http://www.opensolaris.org/os/licensing.\n * See the License for the specific language governing permissions\n * and limitations under the License.\n *\n * When distributing Covered Code, include this CDDL HEADER in each\n * file and include the License file at usr/src/OPENSOLARIS.LICENSE.\n * If applicable, add the following below this CDDL HEADER, with the\n * fields enclosed by brackets \"[]\" replaced with your own identifying\n * information: Portions Copyright [yyyy] [name of copyright owner]\n *\n * CDDL HEADER END\n */\n/*\n * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.\n * Use is subject to license terms.\n */\n\n/*\tCopyright (c) 1984, 1986, 1987, 1988, 1989 AT&T\t*/\n/*\t  All Rights Reserved  \t*/\n\n\n#ifndef _SYS_ELF_H\n#define\t_SYS_ELF_H\n\n#include <inttypes.h>\n\n/* Type for a 16-bit quantity.  */\ntypedef uint16_t Elf32_Half;\ntypedef uint16_t Elf64_Half;\n \n/* Types for signed and unsigned 32-bit quantities.  */\ntypedef uint32_t Elf32_Word;\ntypedef int32_t  Elf32_Sword;\ntypedef uint32_t Elf64_Word;\ntypedef int32_t  Elf64_Sword;\n \n/* Types for signed and unsigned 64-bit quantities.  */\ntypedef uint64_t Elf32_Xword;\ntypedef int64_t  Elf32_Sxword;\ntypedef uint64_t Elf64_Xword;\ntypedef int64_t  Elf64_Sxword;\n\n/* Type of addresses.  */\ntypedef uint32_t Elf32_Addr;\ntypedef uint64_t Elf64_Addr;\n\n/* Type of file offsets.  */\ntypedef uint32_t Elf32_Off;\ntypedef uint64_t Elf64_Off;\n\n\n#ifdef\t__cplusplus\nextern \"C\" {\n#endif\n\n#define\tELF32_FSZ_ADDR\t4\n#define\tELF32_FSZ_HALF\t2\n#define\tELF32_FSZ_OFF\t4\n#define\tELF32_FSZ_SWORD\t4\n#define\tELF32_FSZ_WORD\t4\n\n#define\tELF64_FSZ_ADDR\t8\n#define\tELF64_FSZ_HALF\t2\n#define\tELF64_FSZ_OFF\t8\n#define\tELF64_FSZ_SWORD\t4\n#define\tELF64_FSZ_WORD\t4\n#define\tELF64_FSZ_SXWORD 8\n#define\tELF64_FSZ_XWORD\t8\n\n/*\n *\t\"Enumerations\" below use ...NUM as the number of\n *\tvalues in the list.  It should be 1 greater than the\n *\thighest \"real\" value.\n */\n\n/*\n *\tELF header\n */\n\n#define\tEI_NIDENT\t16\n\ntypedef struct {\n\tunsigned char\te_ident[EI_NIDENT];\t/* ident bytes */\n\tElf32_Half\te_type;\t\t\t/* file type */\n\tElf32_Half\te_machine;\t\t/* target machine */\n\tElf32_Word\te_version;\t\t/* file version */\n\tElf32_Addr\te_entry;\t\t/* start address */\n\tElf32_Off\te_phoff;\t\t/* phdr file offset */\n\tElf32_Off\te_shoff;\t\t/* shdr file offset */\n\tElf32_Word\te_flags;\t\t/* file flags */\n\tElf32_Half\te_ehsize;\t\t/* sizeof ehdr */\n\tElf32_Half\te_phentsize;\t\t/* sizeof phdr */\n\tElf32_Half\te_phnum;\t\t/* number phdrs */\n\tElf32_Half\te_shentsize;\t\t/* sizeof shdr */\n\tElf32_Half\te_shnum;\t\t/* number shdrs */\n\tElf32_Half\te_shstrndx;\t\t/* shdr string index */\n} Elf32_Ehdr;\n\n#define\tEI_MAG0\t\t0\t/* e_ident[] indexes */\n#define\tEI_MAG1\t\t1\n#define\tEI_MAG2\t\t2\n#define\tEI_MAG3\t\t3\n#define\tEI_CLASS\t4\t/* File class */\n#define\tEI_DATA\t\t5\t/* Data encoding */\n#define\tEI_VERSION\t6\t/* File version */\n#define\tEI_OSABI\t7\t/* Operating system/ABI identification */\n#define\tEI_ABIVERSION\t8\t/* ABI version */\n#define\tEI_PAD\t\t9\t/* Start of padding bytes */\n\n#define\tELFMAG0\t\t0x7f\t\t/* EI_MAG */\n#define\tELFMAG1\t\t'E'\n#define\tELFMAG2\t\t'L'\n#define\tELFMAG3\t\t'F'\n#define\tELFMAG\t\t\"\\177ELF\"\n#define\tSELFMAG\t\t4\n\n#define\tELFCLASSNONE\t0\t\t/* EI_CLASS */\n#define\tELFCLASS32\t1\n#define\tELFCLASS64\t2\n#define\tELFCLASSNUM\t3\n\n#define\tELFDATANONE\t0\t\t/* EI_DATA */\n#define\tELFDATA2LSB\t1\n#define\tELFDATA2MSB\t2\n#define\tELFDATANUM\t3\n\n#define\tET_NONE\t\t0\t\t/* e_type */\n#define\tET_REL\t\t1\n#define\tET_EXEC\t\t2\n#define\tET_DYN\t\t3\n#define\tET_CORE\t\t4\n#define\tET_NUM\t\t5\n#define\tET_LOOS\t\t0xfe00\t\t/* OS specific range */\n#define\tET_LOSUNW\t0xfeff\n#define\tET_SUNWPSEUDO\t0xfeff\n#define\tET_HISUNW\t0xfeff\n#define\tET_HIOS\t\t0xfeff\n#define\tET_LOPROC\t0xff00\t\t/* processor specific range */\n#define\tET_HIPROC\t0xffff\n\n#define\tET_LOPROC\t0xff00\t\t/* processor specific range */\n#define\tET_HIPROC\t0xffff\n\n#define\tEM_NONE\t\t0\t\t/* e_machine */\n#define\tEM_M32\t\t1\t\t/* AT&T WE 32100 */\n#define\tEM_SPARC\t2\t\t/* Sun SPARC */\n#define\tEM_386\t\t3\t\t/* Intel 80386 */\n#define\tEM_68K\t\t4\t\t/* Motorola 68000 */\n#define\tEM_88K\t\t5\t\t/* Motorola 88000 */\n#define\tEM_486\t\t6\t\t/* Intel 80486 */\n#define\tEM_860\t\t7\t\t/* Intel i860 */\n#define\tEM_MIPS\t\t8\t\t/* MIPS RS3000 Big-Endian */\n#define\tEM_S370\t\t9\t\t/* IBM System/370 Processor */\n#define\tEM_MIPS_RS3_LE\t10\t\t/* MIPS RS3000 Little-Endian */\n#define\tEM_RS6000\t11\t\t/* RS6000 */\n#define\tEM_UNKNOWN12\t12\n#define\tEM_UNKNOWN13\t13\n#define\tEM_UNKNOWN14\t14\n#define\tEM_PA_RISC\t15\t\t/* PA-RISC */\n#define\tEM_PARISC\tEM_PA_RISC\t/* Alias: GNU compatibility */\n#define\tEM_nCUBE\t16\t\t/* nCUBE */\n#define\tEM_VPP500\t17\t\t/* Fujitsu VPP500 */\n#define\tEM_SPARC32PLUS\t18\t\t/* Sun SPARC 32+ */\n#define\tEM_960\t\t19\t\t/* Intel 80960 */\n#define\tEM_PPC\t\t20\t\t/* PowerPC */\n#define\tEM_PPC64\t21\t\t/* 64-bit PowerPC */\n#define\tEM_S390\t\t22\t\t/* IBM System/390 Processor */\n#define\tEM_UNKNOWN22\tEM_S390\t\t/* Alias: Older published name */\n#define\tEM_UNKNOWN23\t23\n#define\tEM_UNKNOWN24\t24\n#define\tEM_UNKNOWN25\t25\n#define\tEM_UNKNOWN26\t26\n#define\tEM_UNKNOWN27\t27\n#define\tEM_UNKNOWN28\t28\n#define\tEM_UNKNOWN29\t29\n#define\tEM_UNKNOWN30\t30\n#define\tEM_UNKNOWN31\t31\n#define\tEM_UNKNOWN32\t32\n#define\tEM_UNKNOWN33\t33\n#define\tEM_UNKNOWN34\t34\n#define\tEM_UNKNOWN35\t35\n#define\tEM_V800\t\t36\t\t/* NEX V800 */\n#define\tEM_FR20\t\t37\t\t/* Fujitsu FR20 */\n#define\tEM_RH32\t\t38\t\t/* TRW RH-32 */\n#define\tEM_RCE\t\t39\t\t/* Motorola RCE */\n#define\tEM_ARM\t\t40\t\t/* Advanced RISC Marchines ARM */\n#define\tEM_ALPHA\t41\t\t/* Digital Alpha */\n#define\tEM_SH\t\t42\t\t/* Hitachi SH */\n#define\tEM_SPARCV9\t43\t\t/* Sun SPARC V9 (64-bit) */\n#define\tEM_TRICORE\t44\t\t/* Siemens Tricore embedded processor */\n#define\tEM_ARC\t\t45\t\t/* Argonaut RISC Core, */\n\t\t\t\t\t/*\tArgonaut Technologies Inc. */\n#define\tEM_H8_300\t46\t\t/* Hitachi H8/300 */\n#define\tEM_H8_300H\t47\t\t/* Hitachi H8/300H */\n#define\tEM_H8S\t\t48\t\t/* Hitachi H8S */\n#define\tEM_H8_500\t49\t\t/* Hitachi H8/500 */\n#define\tEM_IA_64\t50\t\t/* Intel IA64 */\n#define\tEM_MIPS_X\t51\t\t/* Stanford MIPS-X */\n#define\tEM_COLDFIRE\t52\t\t/* Motorola ColdFire */\n#define\tEM_68HC12\t53\t\t/* Motorola M68HC12 */\n#define\tEM_MMA\t\t54\t\t/* Fujitsu MMA Mulimedia Accelerator */\n#define\tEM_PCP\t\t55\t\t/* Siemens PCP */\n#define\tEM_NCPU\t\t56\t\t/* Sony nCPU embedded RISC processor */\n#define\tEM_NDR1\t\t57\t\t/* Denso NDR1 microprocessor */\n#define\tEM_STARCORE\t58\t\t/* Motorola Star*Core processor */\n#define\tEM_ME16\t\t59\t\t/* Toyota ME16 processor */\n#define\tEM_ST100\t60\t\t/* STMicroelectronics ST100 processor */\n#define\tEM_TINYJ\t61\t\t/* Advanced Logic Corp. TinyJ */\n\t\t\t\t\t/*\tembedded processor family */\n#define\tEM_AMD64\t62\t\t/* AMDs x86-64 architecture */\n#define\tEM_X86_64\tEM_AMD64\t/* (compatibility) */\n\n#define\tEM_PDSP\t\t63\t\t/* Sony DSP Processor */\n#define\tEM_UNKNOWN64\t64\n#define\tEM_UNKNOWN65\t65\n#define\tEM_FX66\t\t66\t\t/* Siemens FX66 microcontroller */\n#define\tEM_ST9PLUS\t67\t\t/* STMicroelectronics ST9+8/16 bit */\n\t\t\t\t\t/*\tmicrocontroller */\n#define\tEM_ST7\t\t68\t\t/* STMicroelectronics ST7 8-bit */\n\t\t\t\t\t/*\tmicrocontroller */\n#define\tEM_68HC16\t69\t\t/* Motorola MC68HC16 Microcontroller */\n#define\tEM_68HC11\t70\t\t/* Motorola MC68HC11 Microcontroller */\n#define\tEM_68HC08\t71\t\t/* Motorola MC68HC08 Microcontroller */\n#define\tEM_68HC05\t72\t\t/* Motorola MC68HC05 Microcontroller */\n#define\tEM_SVX\t\t73\t\t/* Silicon Graphics SVx */\n#define\tEM_ST19\t\t74\t\t/* STMicroelectronics ST19 8-bit */\n\t\t\t\t\t/*\tmicrocontroller */\n#define\tEM_VAX\t\t75\t\t/* Digital VAX */\n#define\tEM_CRIS\t\t76\t\t/* Axis Communications 32-bit */\n\t\t\t\t\t/*\tembedded processor */\n#define\tEM_JAVELIN\t77\t\t/* Infineon Technologies 32-bit */\n\t\t\t\t\t/*\tembedded processor */\n#define\tEM_FIREPATH\t78\t\t/* Element 14 64-bit DSP Processor */\n#define\tEM_ZSP\t\t79\t\t/* LSI Logic 16-bit DSP Processor */\n#define\tEM_MMIX\t\t80\t\t/* Donald Knuth's educational */\n\t\t\t\t\t/*\t64-bit processor */\n#define\tEM_HUANY\t81\t\t/* Harvard University */\n\t\t\t\t\t/*\tmachine-independent */\n\t\t\t\t\t/*\tobject files */\n#define\tEM_PRISM\t82\t\t/* SiTera Prism */\n#define\tEM_AVR\t\t83\t\t/* Atmel AVR 8-bit microcontroller */\n#define\tEM_FR30\t\t84\t\t/* Fujitsu FR30 */\n#define\tEM_D10V\t\t85\t\t/* Mitsubishi D10V */\n#define\tEM_D30V\t\t86\t\t/* Mitsubishi D30V */\n#define\tEM_V850\t\t87\t\t/* NEC v850 */\n#define\tEM_M32R\t\t88\t\t/* Mitsubishi M32R */\n#define\tEM_MN10300\t89\t\t/* Matsushita MN10300 */\n#define\tEM_MN10200\t90\t\t/* Matsushita MN10200 */\n#define\tEM_PJ\t\t91\t\t/* picoJava */\n#define\tEM_OPENRISC\t92\t\t/* OpenRISC 32-bit embedded processor */\n#define\tEM_ARC_A5\t93\t\t/* ARC Cores Tangent-A5 */\n#define\tEM_XTENSA\t94\t\t/* Tensilica Xtensa architecture */\n#define\tEM_NUM\t\t95\n\n#define\tEV_NONE\t\t0\t\t/* e_version, EI_VERSION */\n#define\tEV_CURRENT\t1\n#define\tEV_NUM\t\t2\n\n\n#define\tELFOSABI_NONE\t\t0\t/* No extensions or unspecified */\n#define\tELFOSABI_SYSV\t\tELFOSABI_NONE\n#define\tELFOSABI_HPUX\t\t1\t/* Hewlett-Packard HP-UX */\n#define\tELFOSABI_NETBSD\t\t2\t/* NetBSD */\n#define\tELFOSABI_LINUX\t\t3\t/* Linux */\n#define\tELFOSABI_UNKNOWN4\t4\n#define\tELFOSABI_UNKNOWN5\t5\n#define\tELFOSABI_SOLARIS\t6\t/* Sun Solaris */\n#define\tELFOSABI_AIX\t\t7\t/* AIX */\n#define\tELFOSABI_IRIX\t\t8\t/* IRIX */\n#define\tELFOSABI_FREEBSD\t9\t/* FreeBSD */\n#define\tELFOSABI_TRU64\t\t10\t/* Compaq TRU64 UNIX */\n#define\tELFOSABI_MODESTO\t11\t/* Novell Modesto */\n#define\tELFOSABI_OPENBSD\t12\t/* Open BSD */\n#define\tELFOSABI_OPENVMS\t13\t/* Open VMS */\n#define\tELFOSABI_NSK\t\t14\t/* Hewlett-Packard Non-Stop Kernel */\n#define\tELFOSABI_AROS\t\t15\t/* Amiga Research OS */\n#define\tELFOSABI_ARM\t\t97\t/* ARM */\n#define\tELFOSABI_STANDALONE\t255\t/* standalone (embedded) application */\n\n/*\n *\tProgram header\n */\n\ntypedef struct {\n\tElf32_Word\tp_type;\t\t/* entry type */\n\tElf32_Off\tp_offset;\t/* file offset */\n\tElf32_Addr\tp_vaddr;\t/* virtual address */\n\tElf32_Addr\tp_paddr;\t/* physical address */\n\tElf32_Word\tp_filesz;\t/* file size */\n\tElf32_Word\tp_memsz;\t/* memory size */\n\tElf32_Word\tp_flags;\t/* entry flags */\n\tElf32_Word\tp_align;\t/* memory/file alignment */\n} Elf32_Phdr;\n\n#if defined(_LP64) || defined(_LONGLONG_TYPE)\ntypedef struct {\n\tElf64_Word\tp_type;\t\t/* entry type */\n\tElf64_Word\tp_flags;\t/* entry flags */\n\tElf64_Off\tp_offset;\t/* file offset */\n\tElf64_Addr\tp_vaddr;\t/* virtual address */\n\tElf64_Addr\tp_paddr;\t/* physical address */\n\tElf64_Xword\tp_filesz;\t/* file size */\n\tElf64_Xword\tp_memsz;\t/* memory size */\n\tElf64_Xword\tp_align;\t/* memory/file alignment */\n} Elf64_Phdr;\n#endif\t/* defined(_LP64) || defined(_LONGLONG_TYPE) */\n\n\n#define\tPT_NULL\t\t0\t\t/* p_type */\n#define\tPT_LOAD\t\t1\n#define\tPT_DYNAMIC\t2\n#define\tPT_INTERP\t3\n#define\tPT_NOTE\t\t4\n#define\tPT_SHLIB\t5\n#define\tPT_PHDR\t\t6\n#define\tPT_TLS\t\t7\n#define\tPT_NUM\t\t8\n\n#define\tPT_LOOS\t\t0x60000000\t/* OS specific range */\n\n/*\n * Note: The amd64 psABI defines that the UNWIND program header\n *\t should reside in the OS specific range of the program\n *\t headers.\n */\n#define\tPT_SUNW_UNWIND\t0x6464e550\t/* amd64 UNWIND program header */\n#define\tPT_GNU_EH_FRAME\tPT_SUNW_UNWIND\n\n\n#define\tPT_LOSUNW\t0x6ffffffa\n#define\tPT_SUNWBSS\t0x6ffffffa\t/* Sun Specific segment */\n#define\tPT_SUNWSTACK\t0x6ffffffb\t/* describes the stack segment */\n#define\tPT_SUNWDTRACE\t0x6ffffffc\t/* private */\n#define\tPT_SUNWCAP\t0x6ffffffd\t/* hard/soft capabilities segment */\n#define\tPT_HISUNW\t0x6fffffff\n#define\tPT_HIOS\t\t0x6fffffff\n\n#define\tPT_LOPROC\t0x70000000\t/* processor specific range */\n#define\tPT_HIPROC\t0x7fffffff\n\n#define\tPF_R\t\t0x4\t\t/* p_flags */\n#define\tPF_W\t\t0x2\n#define\tPF_X\t\t0x1\n\n#define\tPF_MASKOS\t0x0ff00000\t/* OS specific values */\n#define\tPF_MASKPROC\t0xf0000000\t/* processor specific values */\n\n#define\tPF_SUNW_FAILURE\t0x00100000\t/* mapping absent due to failure */\n\n#define\tPN_XNUM\t\t0xffff\t\t/* extended program header index */\n\n/*\n *\tSection header\n */\n\ntypedef struct {\n\tElf32_Word\tsh_name;\t/* section name */\n\tElf32_Word\tsh_type;\t/* SHT_... */\n\tElf32_Word\tsh_flags;\t/* SHF_... */\n\tElf32_Addr\tsh_addr;\t/* virtual address */\n\tElf32_Off\tsh_offset;\t/* file offset */\n\tElf32_Word\tsh_size;\t/* section size */\n\tElf32_Word\tsh_link;\t/* misc info */\n\tElf32_Word\tsh_info;\t/* misc info */\n\tElf32_Word\tsh_addralign;\t/* memory alignment */\n\tElf32_Word\tsh_entsize;\t/* entry size if table */\n} Elf32_Shdr;\n\n#if defined(_LP64) || defined(_LONGLONG_TYPE)\ntypedef struct {\n\tElf64_Word\tsh_name;\t/* section name */\n\tElf64_Word\tsh_type;\t/* SHT_... */\n\tElf64_Xword\tsh_flags;\t/* SHF_... */\n\tElf64_Addr\tsh_addr;\t/* virtual address */\n\tElf64_Off\tsh_offset;\t/* file offset */\n\tElf64_Xword\tsh_size;\t/* section size */\n\tElf64_Word\tsh_link;\t/* misc info */\n\tElf64_Word\tsh_info;\t/* misc info */\n\tElf64_Xword\tsh_addralign;\t/* memory alignment */\n\tElf64_Xword\tsh_entsize;\t/* entry size if table */\n} Elf64_Shdr;\n#endif\t/* defined(_LP64) || defined(_LONGLONG_TYPE) */\n\n#define\tSHT_NULL\t\t0\t\t/* sh_type */\n#define\tSHT_PROGBITS\t\t1\n#define\tSHT_SYMTAB\t\t2\n#define\tSHT_STRTAB\t\t3\n#define\tSHT_RELA\t\t4\n#define\tSHT_HASH\t\t5\n#define\tSHT_DYNAMIC\t\t6\n#define\tSHT_NOTE\t\t7\n#define\tSHT_NOBITS\t\t8\n#define\tSHT_REL\t\t\t9\n#define\tSHT_SHLIB\t\t10\n#define\tSHT_DYNSYM\t\t11\n#define\tSHT_UNKNOWN12\t\t12\n#define\tSHT_UNKNOWN13\t\t13\n#define\tSHT_INIT_ARRAY\t\t14\n#define\tSHT_FINI_ARRAY\t\t15\n#define\tSHT_PREINIT_ARRAY\t16\n#define\tSHT_GROUP\t\t17\n#define\tSHT_SYMTAB_SHNDX\t18\n#define\tSHT_NUM\t\t\t19\n\n/* Solaris ABI specific values */\n#define\tSHT_LOOS\t\t0x60000000\t/* OS specific range */\n#define\tSHT_LOSUNW\t\t0x6ffffff1\n#define\tSHT_SUNW_symsort\t0x6ffffff1\n#define\tSHT_SUNW_tlssort\t0x6ffffff2\n#define\tSHT_SUNW_LDYNSYM\t0x6ffffff3\n#define\tSHT_SUNW_dof\t\t0x6ffffff4\n#define\tSHT_SUNW_cap\t\t0x6ffffff5\n#define\tSHT_SUNW_SIGNATURE\t0x6ffffff6\n#define\tSHT_SUNW_ANNOTATE\t0x6ffffff7\n#define\tSHT_SUNW_DEBUGSTR\t0x6ffffff8\n#define\tSHT_SUNW_DEBUG\t\t0x6ffffff9\n#define\tSHT_SUNW_move\t\t0x6ffffffa\n#define\tSHT_SUNW_COMDAT\t\t0x6ffffffb\n#define\tSHT_SUNW_syminfo\t0x6ffffffc\n#define\tSHT_SUNW_verdef\t\t0x6ffffffd\n#define\tSHT_SUNW_verneed\t0x6ffffffe\n#define\tSHT_SUNW_versym\t\t0x6fffffff\n#define\tSHT_HISUNW\t\t0x6fffffff\n#define\tSHT_HIOS\t\t0x6fffffff\n\n/* GNU/Linux ABI specific values */\n#define\tSHT_GNU_verdef\t\t0x6ffffffd\n#define\tSHT_GNU_verneed\t\t0x6ffffffe\n#define\tSHT_GNU_versym\t\t0x6fffffff\n\n#define\tSHT_LOPROC\t0x70000000\t/* processor specific range */\n#define\tSHT_HIPROC\t0x7fffffff\n\n#define\tSHT_LOUSER\t0x80000000\n#define\tSHT_HIUSER\t0xffffffff\n\n#define\tSHF_WRITE\t\t0x01\t\t/* sh_flags */\n#define\tSHF_ALLOC\t\t0x02\n#define\tSHF_EXECINSTR\t\t0x04\n#define\tSHF_MERGE\t\t0x10\n#define\tSHF_STRINGS\t\t0x20\n#define\tSHF_INFO_LINK\t\t0x40\n#define\tSHF_LINK_ORDER\t\t0x80\n#define\tSHF_OS_NONCONFORMING\t0x100\n#define\tSHF_GROUP\t\t0x200\n#define\tSHF_TLS\t\t\t0x400\n\n#define\tSHF_MASKOS\t0x0ff00000\t/* OS specific values */\n\n\n#define\tSHF_MASKPROC\t0xf0000000\t/* processor specific values */\n\n#define\tSHN_UNDEF\t0\t\t/* special section numbers */\n#define\tSHN_LORESERVE\t0xff00\n#define\tSHN_LOPROC\t0xff00\t\t/* processor specific range */\n#define\tSHN_HIPROC\t0xff1f\n#define\tSHN_LOOS\t0xff20\t\t/* OS specific range */\n#define\tSHN_LOSUNW\t0xff3f\n#define\tSHN_SUNW_IGNORE\t0xff3f\n#define\tSHN_HISUNW\t0xff3f\n#define\tSHN_HIOS\t0xff3f\n#define\tSHN_ABS\t\t0xfff1\n#define\tSHN_COMMON\t0xfff2\n#if defined(__APPLE__)\n#define SHN_MACHO_64\t0xfffd\t\t/* Mach-o_64 direct string access */\n#define SHN_MACHO\t0xfffe\t\t/* Mach-o direct string access */\n#endif /* __APPLE__ */\n#define\tSHN_XINDEX\t0xffff\t\t/* extended sect index */\n#define\tSHN_HIRESERVE\t0xffff\n\n\n\n/*\n *\tSymbol table\n */\n\ntypedef struct {\n\tElf32_Word\tst_name;\n\tElf32_Addr\tst_value;\n\tElf32_Word\tst_size;\n\tunsigned char\tst_info;\t/* bind, type: ELF_32_ST_... */\n\tunsigned char\tst_other;\n\tElf32_Half\tst_shndx;\t/* SHN_... */\n} Elf32_Sym;\n\n#if defined(_LP64) || defined(_LONGLONG_TYPE)\ntypedef struct {\n#if !defined(__APPLE__)\n\tElf64_Word\tst_name;\n#else\n\tElf64_Sxword\tst_name;\n#endif /* __APPLE__ */\n\tunsigned char\tst_info;\t/* bind, type: ELF_64_ST_... */\n\tunsigned char\tst_other;\n\tElf64_Half\tst_shndx;\t/* SHN_... */\n\tElf64_Addr\tst_value;\n\tElf64_Xword\tst_size;\n} Elf64_Sym;\n#endif\t/* defined(_LP64) || defined(_LONGLONG_TYPE) */\n\n#define\tSTN_UNDEF\t0\n\n/*\n *\tThe macros compose and decompose values for S.st_info\n *\n *\tbind = ELF32_ST_BIND(S.st_info)\n *\ttype = ELF32_ST_TYPE(S.st_info)\n *\tS.st_info = ELF32_ST_INFO(bind, type)\n */\n\n#define\tELF32_ST_BIND(info)\t\t((info) >> 4)\n#define\tELF32_ST_TYPE(info)\t\t((info) & 0xf)\n#define\tELF32_ST_INFO(bind, type)\t(((bind)<<4)+((type)&0xf))\n\n#define\tELF64_ST_BIND(info)\t\t((info) >> 4)\n#define\tELF64_ST_TYPE(info)\t\t((info) & 0xf)\n#define\tELF64_ST_INFO(bind, type)\t(((bind)<<4)+((type)&0xf))\n\n\n#define\tSTB_LOCAL\t0\t\t/* BIND */\n#define\tSTB_GLOBAL\t1\n#define\tSTB_WEAK\t2\n#define\tSTB_NUM\t\t3\n\n#define\tSTB_LOPROC\t13\t\t/* processor specific range */\n#define\tSTB_HIPROC\t15\n\n#define\tSTT_NOTYPE\t0\t\t/* TYPE */\n#define\tSTT_OBJECT\t1\n#define\tSTT_FUNC\t2\n#define\tSTT_SECTION\t3\n#define\tSTT_FILE\t4\n#define\tSTT_COMMON\t5\n#define\tSTT_TLS\t\t6\n#define\tSTT_NUM\t\t7\n\n#define\tSTT_LOPROC\t13\t\t/* processor specific range */\n#define\tSTT_HIPROC\t15\n\n/*\n *\tThe macros decompose values for S.st_other\n *\n *\tvisibility = ELF32_ST_VISIBILITY(S.st_other)\n */\n#define\tELF32_ST_VISIBILITY(other)\t((other)&0x7)\n#define\tELF64_ST_VISIBILITY(other)\t((other)&0x7)\n\n#define\tSTV_DEFAULT\t0\n#define\tSTV_INTERNAL\t1\n#define\tSTV_HIDDEN\t2\n#define\tSTV_PROTECTED\t3\n#define\tSTV_EXPORTED\t4\n#define\tSTV_SINGLETON\t5\n#define\tSTV_ELIMINATE\t6\n\n#define\tSTV_NUM\t\t7\n\n/*\n *\tRelocation\n */\n\ntypedef struct {\n\tElf32_Addr\tr_offset;\n\tElf32_Word\tr_info;\t\t/* sym, type: ELF32_R_... */\n} Elf32_Rel;\n\ntypedef struct {\n\tElf32_Addr\tr_offset;\n\tElf32_Word\tr_info;\t\t/* sym, type: ELF32_R_... */\n\tElf32_Sword\tr_addend;\n} Elf32_Rela;\n\n#if defined(_LP64) || defined(_LONGLONG_TYPE)\ntypedef struct {\n\tElf64_Addr\tr_offset;\n\tElf64_Xword\tr_info;\t\t/* sym, type: ELF64_R_... */\n} Elf64_Rel;\n\ntypedef struct {\n\tElf64_Addr\tr_offset;\n\tElf64_Xword\tr_info;\t\t/* sym, type: ELF64_R_... */\n\tElf64_Sxword\tr_addend;\n} Elf64_Rela;\n#endif\t/* defined(_LP64) || defined(_LONGLONG_TYPE) */\n\n\n/*\n *\tThe macros compose and decompose values for Rel.r_info, Rela.f_info\n *\n *\tsym = ELF32_R_SYM(R.r_info)\n *\ttype = ELF32_R_TYPE(R.r_info)\n *\tR.r_info = ELF32_R_INFO(sym, type)\n */\n\n#define\tELF32_R_SYM(info)\t((info)>>8)\n#define\tELF32_R_TYPE(info)\t((unsigned char)(info))\n#define\tELF32_R_INFO(sym, type)\t(((sym)<<8)+(unsigned char)(type))\n\n#define\tELF64_R_SYM(info)\t((info)>>32)\n#define\tELF64_R_TYPE(info)    \t((Elf64_Word)(info))\n#define\tELF64_R_INFO(sym, type)\t(((Elf64_Xword)(sym)<<32)+(Elf64_Xword)(type))\n\n\n/*\n * The r_info field is composed of two 32-bit components: the symbol\n * table index and the relocation type.  The relocation type for SPARC V9\n * is further decomposed into an 8-bit type identifier and a 24-bit type\n * dependent data field.  For the existing Elf32 relocation types,\n * that data field is zero.\n */\n#define\tELF64_R_TYPE_DATA(info)\t(((Elf64_Xword)(info)<<32)>>40)\n#define\tELF64_R_TYPE_ID(info)\t(((Elf64_Xword)(info)<<56)>>56)\n#define\tELF64_R_TYPE_INFO(data, type)\t\\\n\t\t(((Elf64_Xword)(data)<<8)+(Elf64_Xword)(type))\n\n\n/*\n * Section Group Flags (SHT_GROUP)\n */\n#define\tGRP_COMDAT\t0x01\n\n\n/*\n *\tNote entry header\n */\n\ntypedef struct {\n\tElf32_Word\tn_namesz;\t/* length of note's name */\n\tElf32_Word\tn_descsz;\t/* length of note's \"desc\" */\n\tElf32_Word\tn_type;\t\t/* type of note */\n} Elf32_Nhdr;\n\n#if defined(_LP64) || defined(_LONGLONG_TYPE)\ntypedef struct {\n\tElf64_Word\tn_namesz;\t/* length of note's name */\n\tElf64_Word\tn_descsz;\t/* length of note's \"desc\" */\n\tElf64_Word\tn_type;\t\t/* type of note */\n} Elf64_Nhdr;\n#endif\t/* defined(_LP64) || defined(_LONGLONG_TYPE) */\n\n/*\n *\tMove entry\n */\n#if defined(_LP64) || defined(_LONGLONG_TYPE)\ntypedef struct {\n\tElf32_Lword\tm_value;\t/* symbol value */\n\tElf32_Word \tm_info;\t\t/* size + index */\n\tElf32_Word\tm_poffset;\t/* symbol offset */\n\tElf32_Half\tm_repeat;\t/* repeat count */\n\tElf32_Half\tm_stride;\t/* stride info */\n} Elf32_Move;\n\n/*\n *\tThe macros compose and decompose values for Move.r_info\n *\n *\tsym = ELF32_M_SYM(M.m_info)\n *\tsize = ELF32_M_SIZE(M.m_info)\n *\tM.m_info = ELF32_M_INFO(sym, size)\n */\n#define\tELF32_M_SYM(info)\t((info)>>8)\n#define\tELF32_M_SIZE(info)\t((unsigned char)(info))\n#define\tELF32_M_INFO(sym, size)\t(((sym)<<8)+(unsigned char)(size))\n\ntypedef struct {\n\tElf64_Lword\tm_value;\t/* symbol value */\n\tElf64_Xword \tm_info;\t\t/* size + index */\n\tElf64_Xword\tm_poffset;\t/* symbol offset */\n\tElf64_Half\tm_repeat;\t/* repeat count */\n\tElf64_Half\tm_stride;\t/* stride info */\n} Elf64_Move;\n#define\tELF64_M_SYM(info)\t((info)>>8)\n#define\tELF64_M_SIZE(info)\t((unsigned char)(info))\n#define\tELF64_M_INFO(sym, size)\t(((sym)<<8)+(unsigned char)(size))\n\n#endif\t/* defined(_LP64) || defined(_LONGLONG_TYPE) */\n\n\n/*\n *\tHardware/Software capabilities entry\n */\n#ifndef\t_ASM\ntypedef struct {\n\tElf32_Word\tc_tag;\t\t/* how to interpret value */\n\tunion {\n\t\tElf32_Word\tc_val;\n\t\tElf32_Addr\tc_ptr;\n\t} c_un;\n} Elf32_Cap;\n\n#if defined(_LP64) || defined(_LONGLONG_TYPE)\ntypedef struct {\n\tElf64_Xword\tc_tag;\t\t/* how to interpret value */\n\tunion {\n\t\tElf64_Xword\tc_val;\n\t\tElf64_Addr\tc_ptr;\n\t} c_un;\n} Elf64_Cap;\n#endif\t/* defined(_LP64) || defined(_LONGLONG_TYPE) */\n#endif\n\n#define\tCA_SUNW_NULL\t0\n#define\tCA_SUNW_HW_1\t1\t\t/* first hardware capabilities entry */\n#define\tCA_SUNW_SF_1\t2\t\t/* first software capabilities entry */\n\n/*\n * Define software capabilities (CA_SUNW_SF_1 values).  Note, hardware\n * capabilities (CA_SUNW_HW_1 values) are taken directly from sys/auxv_$MACH.h.\n */\n#define\tSF1_SUNW_FPKNWN\t0x001\t\t/* use/non-use of frame pointer is */\n#define\tSF1_SUNW_FPUSED\t0x002\t\t/*\tknown, and frame pointer is */\n\t\t\t\t\t/*\tin use */\n#define\tSF1_SUNW_MASK\t0x003\t\t/* known software capabilities mask */\n\n\n/*\n *\tKnown values for note entry types (e_type == ET_CORE)\n */\n\n#define\tNT_PRSTATUS\t1\t/* prstatus_t\t<sys/old_procfs.h>\t*/\n#define\tNT_PRFPREG\t2\t/* prfpregset_t\t<sys/old_procfs.h>\t*/\n#define\tNT_PRPSINFO\t3\t/* prpsinfo_t\t<sys/old_procfs.h>\t*/\n#define\tNT_PRXREG\t4\t/* prxregset_t\t<sys/procfs.h>\t\t*/\n#define\tNT_PLATFORM\t5\t/* string from sysinfo(SI_PLATFORM)\t*/\n#define\tNT_AUXV\t\t6\t/* auxv_t array\t<sys/auxv.h>\t\t*/\n#define\tNT_GWINDOWS\t7\t/* gwindows_t\tSPARC only\t\t*/\n#define\tNT_ASRS\t\t8\t/* asrset_t\tSPARC V9 only\t\t*/\n#define\tNT_LDT\t\t9\t/* ssd array\t<sys/sysi86.h> IA32 only */\n#define\tNT_PSTATUS\t10\t/* pstatus_t\t<sys/procfs.h>\t\t*/\n#define\tNT_PSINFO\t13\t/* psinfo_t\t<sys/procfs.h>\t\t*/\n#define\tNT_PRCRED\t14\t/* prcred_t\t<sys/procfs.h>\t\t*/\n#define\tNT_UTSNAME\t15\t/* struct utsname <sys/utsname.h>\t*/\n#define\tNT_LWPSTATUS\t16\t/* lwpstatus_t\t<sys/procfs.h>\t\t*/\n#define\tNT_LWPSINFO\t17\t/* lwpsinfo_t\t<sys/procfs.h>\t\t*/\n#define\tNT_PRPRIV\t18\t/* prpriv_t\t<sys/procfs.h>\t\t*/\n#define\tNT_PRPRIVINFO\t19\t/* priv_impl_info_t <sys/priv.h>\t*/\n#define\tNT_CONTENT\t20\t/* core_content_t <sys/corectl.h>\t*/\n#define\tNT_ZONENAME\t21\t/* string from getzonenamebyid(3C)\t*/\n#define\tNT_NUM\t\t21\n\n\n#ifdef _KERNEL\n/*\n * The following routine checks the processor-specific\n * fields of an ELF header.\n */\nint\telfheadcheck(unsigned char, Elf32_Half, Elf32_Word);\n#endif\n\n#ifdef\t__cplusplus\n}\n#endif\n\n#if defined(ELF_TARGET_ALL) || defined(ELF_TARGET_SPARC)\n#include <sys/elf_SPARC.h>\n#endif\n\n#if defined(ELF_TARGET_ALL) || defined(ELF_TARGET_386)\n\n#if !defined(__APPLE__)\n#include <sys/elf_386.h>\n#else /* is Apple Mac OS X */\n#include \"elf_386.h\" /* In lieu of Solaris <sys/elf_386.h> */\n#endif /* __APPLE__ */\n#endif\n\n#if defined(ELF_TARGET_ALL) || defined(ELF_TARGET_AMD64)\n#include <sys/elf_amd64.h>\n#endif\n\n#endif\t/* _SYS_ELF_H */"
  },
  {
    "path": "test/ShadowMaps.txt",
    "content": "\n\nTexture2D<float> tShadowMap;\nSamplerComparisonState sShadowSampler;\nTexture2D<float3> tTexture;\nsampler sTexture;\n\nfloat2 vShadowMapSize;\n\nstruct VSOut\n{\n    float3 N      : TEXCOORD0;\n    float4 vPosSM : TEXCOORD1;\n    float3 L      : TEXCOORD2;\n    float2 uv     : TEXCOORD3;\n    float4 vPos   : SV_POSITION;\n};\n\n\n \n\n\nfloat PCFGather7x7( float3 vPosSM, float2 Size, Texture2D<float> t, SamplerComparisonState s )\n{\n    float z   = saturate(vPosSM.z);\n    \n    float2 uv = (vPosSM.xy*Size);    \n    float2 vWeights = frac(uv.xy); // grab bilinear weights\n    \n    // snap UV to texel center\n    //  If we don't do this, we can end up rouning differently\n    //  than the sampler does, and our weights will be wrong\n    uv = (floor(uv)+0.5)/Size; \n\n    float4 v0  = t.GatherCmp( s, uv, z, int2(-3, -3) );\n    float4 v1  = t.GatherCmp( s, uv, z, int2(-1, -3) );\n    float4 v2  = t.GatherCmp( s, uv, z, int2( 1, -3) );\n    float4 v3  = t.GatherCmp( s, uv, z, int2( 3, -3) );\n\n    float4 v4  = t.GatherCmp( s, uv, z, int2(-3, -1) );\n    float4 v5  = t.GatherCmp( s, uv, z, int2(-1, -1) );\n    float4 v6  = t.GatherCmp( s, uv, z, int2( 1, -1) );\n    float4 v7  = t.GatherCmp( s, uv, z, int2( 3, -1) );\n\n    float4 v8  = t.GatherCmp( s, uv, z, int2(-3, 1) );\n    float4 v9  = t.GatherCmp( s, uv, z, int2(-1, 1) );\n    float4 v10 = t.GatherCmp( s, uv, z, int2( 1, 1) );\n    float4 v11 = t.GatherCmp( s, uv, z, int2( 3, 1) );\n\n    float4 v12 = t.GatherCmp( s, uv, z, int2(-3, 3) );\n    float4 v13 = t.GatherCmp( s, uv, z, int2(-1, 3) );\n    float4 v14 = t.GatherCmp( s, uv, z, int2( 1, 3) );\n    float4 v15 = t.GatherCmp( s, uv, z, int2( 3, 3) );\n\n\n    // tap locations\n    //    .    .   .   .   .   .   .    .\n    //      0        1       2       3\n    //    .    .   .   .   .   .   .    .\n    //          \n    //    .    .   .   .   .   .   .    .\n    //      4        5       6       7\n    //    .    .   .   .   .   .   .    .\n    //                   x\n    //    .    .   .   .   .   .   .    .\n    //      8        9      10       11\n    //    .    .   .   .   .   .   .    .\n    //\n    //    .    .   .   .   .   .   .    .\n    //      12       13      14      15\n    //    .    .   .   .   .   .   .    .  \n    //\n    // gather4 texel ordering:\n    //  w  z\n    //  x  y\n    //       \n  \n    float u = vWeights.x;\n    float v = vWeights.y;\n    float r0 = ( v0.z  + v1.z  + v1.w  + v2.z  + v2.w  + v3.w  ) + u*v3.z  + (1-u)*v0.w;\n    float r1 = ( v0.y  + v1.y  + v1.x  + v2.y  + v2.x  + v3.x  ) + u*v3.y  + (1-u)*v0.x;\n    float r2 = ( v4.z  + v5.z  + v5.w  + v6.z  + v6.w  + v7.w  ) + u*v7.z  + (1-u)*v4.w;\n    float r3 = ( v4.y  + v5.y  + v5.x  + v6.y  + v6.x  + v7.x  ) + u*v7.y  + (1-u)*v4.x;\n    float r4 = ( v8.z  + v9.z  + v9.w  + v10.z + v10.w + v11.w ) + u*v11.z + (1-u)*v8.w;\n    float r5 = ( v8.y  + v9.y  + v9.x  + v10.y + v10.x + v11.x ) + u*v11.y + (1-u)*v8.x;\n    float r6 = ( v12.z + v13.z + v13.w + v14.z + v14.w + v15.w ) + u*v15.z + (1-u)*v12.w;\n    float r7 = ( v12.y + v13.y + v13.x + v14.y + v14.x + v15.x ) + u*v15.y + (1-u)*v12.x;\n    float blend = r0*(1-v) + r1 + r2 + r3 + r4 + r5 + r6 + r7*v;\n    return blend/49;\n}\n\n\n// Simple grid of NxN bilinear taps\n// taps == 2*n+1.   use n=0 for 1x1, n=1 for 3x3, n=2 for 5x5, etc\nfloat PCFBilin(float3 vPosSM, Texture2D<float> t, SamplerComparisonState s, int n )\n{  \n    float2 uv = vPosSM.xy;\n    float z = saturate(vPosSM.z);\n    float v=0;\n\n    [unroll]\n    for( int x=-n; x<=n; x+= 1 )\n        [unroll]\n        for( int y=-n; y<=n; y+= 1 )\n            v += t.SampleCmp(s,uv,z,int2(x,y) );\n   \n    float ntaps = (2*n+1)*(2*n+1);\n    return v/(ntaps);\n}\n\nfloat PCFBilin3x3(float3 vPosSM, Texture2D<float> t, SamplerComparisonState s, int n )\n{  \n    float2 uv = vPosSM.xy;\n    float z = saturate(vPosSM.z);\n\n    float t0 = t.SampleCmp( s,uv,z,int2(-2,-2) );\n    float t1 = t.SampleCmp( s,uv,z,int2(-2,-1) );\n    float t2 = t.SampleCmp( s,uv,z,int2(-2,-0) );\n    float t3 = t.SampleCmp( s,uv,z,int2(-2,1) );\n    float t4 = t.SampleCmp( s,uv,z,int2(-2,2) );\n    \n    t0 += t.SampleCmp( s,uv,z,int2(-1,-2) );\n    t1 += t.SampleCmp( s,uv,z,int2(-1,-1) );\n    t2 += t.SampleCmp( s,uv,z,int2(-1,-0) );\n    t3 += t.SampleCmp( s,uv,z,int2(-1, 1) );\n    t4 += t.SampleCmp( s,uv,z,int2(-1, 2) );\n    \n    t0 += t.SampleCmp( s,uv,z,int2(0,-2) );\n    t1 += t.SampleCmp( s,uv,z,int2(0,-1) );\n    t2 += t.SampleCmp( s,uv,z,int2(0,-0) );\n    t3 += t.SampleCmp( s,uv,z,int2(0, 1) );\n    t4 += t.SampleCmp( s,uv,z,int2(0, 2) );\n    \n    t0 += t.SampleCmp( s,uv,z,int2(1,-2) );\n    t1 += t.SampleCmp( s,uv,z,int2(1,-1) );\n    t2 += t.SampleCmp( s,uv,z,int2(1,-0) );\n    t3 += t.SampleCmp( s,uv,z,int2(1, 1) );\n    t4 += t.SampleCmp( s,uv,z,int2(1, 2) );\n    \n    t0 += t.SampleCmp( s,uv,z,int2(2,-2) );\n    t1 += t.SampleCmp( s,uv,z,int2(2,-1) );\n    t2 += t.SampleCmp( s,uv,z,int2(2,-0) );\n    t3 += t.SampleCmp( s,uv,z,int2(2, 1) );\n    t4 += t.SampleCmp( s,uv,z,int2(2, 2) );\n    \n   \tfloat v = (t0+t1)+t2+(t3+t4);\n    float ntaps = (2*n+1)*(2*n+1);\n    return v/(ntaps);\n}\n\n\nfloat4 main(  VSOut input ) : SV_TARGET\n{\n    float3 vPosSM = input.vPosSM.xyz / input.vPosSM.w;\n    float2 vClip  = ( abs(vPosSM.xy) > 1 ? 1 : 0 );\n   \n    vPosSM.xy = vPosSM.xy*float2(0.5,-0.5) + float2(0.5,0.5);\n    //float fShadow = tShadowMap.SampleCmp( sShadowSampler, vPosSM.xy, saturate(vPosSM.z) );\n    //float fShadow = PCFGather5x5(vPosSM, vShadowMapSize, tShadowMap, sShadowSampler  );\n    float fShadow = PCFBilin(vPosSM,tShadowMap,sShadowSampler,2);\n    float3 L      = normalize( input.L );\n    float3 N      = normalize( input.N );\n    float3 C      = saturate(dot(N,L)) * saturate(fShadow-vClip.x-vClip.y) * tTexture.Sample(sTexture,input.uv) ;\n    return float4(pow(C.xyz,1/2.2),1);\n}"
  },
  {
    "path": "test/branches_test",
    "content": "\nbool b;\nbool c;\nbool d;\nint n;\nBuffer<float> f;\n\nfloat4 main() : SV_TARGET \n{ \n  int i=0;\n  float q=0;\n\n  while(1)\n  {\n     q+= f[i++];\n     if( i >= n )\n        break;\n  } \n  \n  [branch]\n  if( d )\n     q += 42;\n\n  if( b )\n  {\n     if(c)\n     {\n        return 1+q;\n     }\n     else\n     {\n        return 2+q;\n     }\n  }\n  else\n  {\n      return 3+q;\n  }\n\n}\n"
  },
  {
    "path": "test/cs_addreturntest",
    "content": "\ngroupshared uint LDS;\n\nBuffer<uint> counts;\nBuffer<uint> data;\nRWBuffer<uint> vout;\n\n[numthreads(64,1,1)]\nvoid main( uint3 idx : SV_DispatchThreadID )\n{\n   LDS=0;\n   GroupMemoryBarrierWithGroupSync();\n\n   uint N = counts[idx.x];\n   uint loc;\n   InterlockedAdd(LDS,N,loc);\n   for( uint i=0; i<N; i++ )\n     vout[loc+i] = data[idx.x+i];\n}"
  },
  {
    "path": "test/cs_append",
    "content": "\nstruct DrawCall\n{\n   uint nShaderID;\n   uint nStartIndex;\n   uint nIndexCount;\n};\n\nAppendStructuredBuffer<DrawCall> StuffToDraw;\n\nfloat4 g_Frustum[6];\n\nBuffer<float4>   Spheres;\nBuffer<DrawCall> Draws;\n\n[numthreads(64,1,1)]\nvoid main( uint3 tid : SV_DispatchThreadID )\n{\n\n   float4 sph = Spheres[tid.x];\n   \n   [unroll]\n   for( uint i=0; i<6; i++ ) \n   {\n        float d = dot(g_Frustum[i].xyzw,float4(sph.xyz,1));\n        if( d < 0 )\n            return;\n   }\n\n   StuffToDraw.Append(Draws[tid.x]);\n\n}"
  },
  {
    "path": "test/cs_barrier_test",
    "content": "Texture2D<float> tTx;\nRWTexture2D<float> tAvg;\n\ngroupshared float Foo[16][16];\n\n[numthreads(16,16,1)]\nvoid main( uint3 tid : SV_DispatchThreadID,\n           uint3 gid : SV_GroupThreadID )\n{\n\tfloat f = tTx.Load( uint3( tid.xy,0) );\n\tFoo[gid.x][gid.y] = f;\n\t\n\tGroupMemoryBarrierWithGroupSync();\n\t\n\tfloat avg=0;\n\tfor( int i=0; i<16; i++ )\n\t\tfor( int j=0; j<16; j++ )\n\t\t\tavg += Foo[i][j];\n\t\t\t\n\t\n\ttAvg[ uint2(tid.x>>4,tid.y>>4)] = avg;\n\n}"
  },
  {
    "path": "test/cs_cull",
    "content": " \n\n#define THREADGROUP_WIDTH 1024 \n\ncbuffer globals\n{\n    row_major float4x4 mViewProj;\n    float2 g_vResolution; \n};\ncbuffer drawcall\n{\n    row_major float4x4 mWorld;\n};\n\nstruct TriGroup\n{\n\tuint nFirstIndex;\n\tuint nFirstVertex;\n\tuint nTriangles;\n\tuint nVerts;\n};\n\nStructuredBuffer<TriGroup> g_Groups;\n\n// Public service announcement.  Raw buffers are SIGNIFICANTLY more efficient than TBuffers\n//  Buffer<xxx> and friends.   Because of stupid DX constraint that R32G32B32 views cannot be used on VB/IB\n//   it is necessary to load single elements from these.  \n//  Using ByteAddressBuffer instead gives me a sizable boost because we can load multiple dwords at once\n\nByteAddressBuffer g_VertexBuffer;\nByteAddressBuffer g_IndexBuffer; \n\nstruct IndexStruct\n{\n\tuint3 Indices;\n};\nAppendStructuredBuffer<IndexStruct> g_OutIndices;\n\ngroupshared float3 g_Verts[THREADGROUP_WIDTH];\n\n[numthreads(THREADGROUP_WIDTH,1,1)]\nvoid main( uint3 ThreadID      : SV_DispatchThreadID,\n            uint3 GroupID       : SV_GroupID,\n            uint3 GroupThreadID : SV_GroupThreadID )\n{ \n    uint tid        = ThreadID.x;\n\tuint tid_local\t= GroupThreadID.x;\n\n\t// initialize stuff\n\tuint3 Indices = 0;\n\tbool bKeepTri = false;\n\t\n\t// fetch tri-group information\n\tTriGroup kGroup = g_Groups[GroupID.x];\n\t\n\t// load this thread's triangle indices\n\tuint IndexLocation = 12*tid_local + kGroup.nFirstIndex;\n    Indices = g_IndexBuffer.Load3( IndexLocation );\n    \n\t// fetch and transform this thread's vertex\n\t[branch]\n\tif( gid < kGroup.nVerts )\n\t{\n\t\tfloat3 P0 = asfloat( g_VertexBuffer.Load3( 12*(gid+kGroup.nFirstVertex) ) );\n\t\tfloat3 P0w = mul( float4(P0,1),  mWorld ).xyz;\n\t\tfloat4 P0p = mul( float4(P0w,1), mViewProj );\n        g_Verts[gid] = P0p.xyw;\n\t}\n\t\n\t// sync up\n\tGroupMemoryBarrierWithGroupSync();\n\t\n\t// perform triangle backface tests\n\t[branch]\n\tif( gid < kGroup.nTriangles )\n    {\n        float3 P0p = g_Verts[Indices.x];\n        float3 P1p = g_Verts[Indices.y];\n        float3 P2p = g_Verts[Indices.z];\n       \n        // Culling in homogenous coordinates\n\t    // Read: \"Triangle Scan Conversion using 2D Homogeneous Coordinates\"\n\t    //       by Marc Olano, Trey Greer\n\t    //       http://www.cs.unc.edu/~olano/papers/2dh-tri/2dh-tri.pdf\n\t    float3x3 m =\n\t    {\n\t        P0p.xyz, P1p.xyz, P2p.xyz\n\t    };\n\t    \n\t\tif( determinant(m)>0 )\n\t  \t{\n\t  \t\tIndexStruct id;\n\t  \t\tid.Indices = Indices + kGroup.nFirstVertex;\n\t  \t\tg_OutIndices.Append(id);\n\t  \t}\n    }\n}\n\ngroupshared uint g_Prefix[THREADGROUP_WIDTH];\ngroupshared uint OutputBaseAddress;\n\t\nRWByteAddressBuffer g_DrawIndirectBuffer;\nRWByteAddressBuffer g_OutputIB;\n\n[numthreads(THREADGROUP_WIDTH,1,1)]\nvoid main_prefix( uint3 ThreadID      : SV_DispatchThreadID,\n            \t  uint3 GroupID       : SV_GroupID,\n            \t  uint3 GroupThreadID : SV_GroupThreadID )\n{ \n    uint tid        = ThreadID.x;\n\tuint gid\t\t= GroupThreadID.x;\n\n\t// initialize stuff\n\tuint3 Indices = 0;\n\tbool bKeepTri = false;\n\tg_Prefix[gid] = 0;\n\t\n\t// fetch tri-group information\n\tTriGroup kGroup = g_Groups[GroupID.x];\n\t\n\t// load this thread's triangle indices\n    Indices = g_IndexBuffer.Load3( 12*gid + kGroup.nFirstIndex );\n    \n\t// fetch and transform this thread's vertex\n\t[branch]\n\tif( gid < kGroup.nVerts )\n\t{\n\t\tfloat3 P0 = asfloat( g_VertexBuffer.Load3( 12*(gid+kGroup.nFirstVertex) ) );\n\t\tfloat3 P0w = mul( float4(P0,1),  mWorld ).xyz;\n\t\tfloat4 P0p = mul( float4(P0w,1), mViewProj );\n        g_Verts[gid] = P0p.xyw;\n\t}\n\t\n\t// sync up\n\tGroupMemoryBarrierWithGroupSync();\n\t\n\t// perform triangle backface tests\n\t[branch]\n\tif( gid < kGroup.nTriangles )\n    {\n        float3 P0p = g_Verts[Indices.x];\n        float3 P1p = g_Verts[Indices.y];\n        float3 P2p = g_Verts[Indices.z];\n       \n        // Culling in homogenous coordinates\n\t    // Read: \"Triangle Scan Conversion using 2D Homogeneous Coordinates\"\n\t    //       by Marc Olano, Trey Greer\n\t    //       http://www.cs.unc.edu/~olano/papers/2dh-tri/2dh-tri.pdf\n\t    float3x3 m =\n\t    {\n\t        P0p.xyz, P1p.xyz, P2p.xyz\n\t    };\n\t    \n\t \tg_Prefix[gid] = (determinant(m)>0) ? 1 : 0;\n    }\n\n\t// prefix-sum on cull results\n\tGroupMemoryBarrierWithGroupSync();\n\t\n\t[unroll]\n\tfor(int t=1; t<THREADGROUP_WIDTH; t=t<<1)\n\t{\n\t\tif (gid >= t)\n\t\t\tg_Prefix[gid] += g_Prefix[gid-t];\n\t\tGroupMemoryBarrier();\n\t\n\t}\n\t\n\t// one thread does one single atomic inc to offset into output IB\n\tif( gid == kGroup.nTriangles-1 )\n\t{\n\t\tuint nIndices = 3*g_Prefix[gid];\n\t\tg_DrawIndirectBuffer.InterlockedAdd(0,nIndices, OutputBaseAddress);\n\t}\n\t\n\tGroupMemoryBarrierWithGroupSync();\n\t\n\tif( gid < kGroup.nTriangles )\n\t{\n\t\tuint nLoc = 4*(OutputBaseAddress + 3*g_Prefix[gid]);\n\t\tg_OutputIB.Store3(nLoc, Indices);\n\t}\n}\n\n\n\n/*\n[numthreads(THREADGROUP_WIDTH,1,1)]\nvoid main( uint3 ThreadID      : SV_DispatchThreadID,\n            uint3 GroupID       : SV_GroupID,\n            uint3 GroupThreadID : SV_GroupThreadID )\n{ \n    uint tid        = ThreadID.x;\n\n    [branch]\n    if( tid < g_nTriangles )\n    {\n        // fetch verts\n        //   NOTE: No Vertex re-use.   Possible to add some?\n        uint3 Indices = g_Indices.Load3( 12*tid );\n        float3 P0 = asfloat( g_Verts.Load3( 12*Indices.x ) );\n        float3 P1 = asfloat( g_Verts.Load3( 12*Indices.y ) );\n        float3 P2 = asfloat( g_Verts.Load3( 12*Indices.z ) );\n\t\t\n        // transform verts\n        float3 P0w = mul( float4(P0,1),  mWorld ).xyz;\n        float3 P1w = mul( float4(P1,1),  mWorld ).xyz;\n        float3 P2w = mul( float4(P2,1),  mWorld ).xyz;\n        float4 P0p = mul( float4(P0w,1), mViewProj );\n        float4 P1p = mul( float4(P1w,1), mViewProj );\n        float4 P2p = mul( float4(P2w,1), mViewProj );\n        P0p.w   = rcp(P0p.w); \n        P1p.w   = rcp(P1p.w);\n        P2p.w   = rcp(P2p.w);\n        P0p.xyz *= P0p.w; \n        P1p.xyz *= P1p.w;\n        P2p.xyz *= P2p.w;\n\n        // clip-space to viewport transform\n        P0p.xy = g_vResolution*(float2(0.5,-0.5)*P0p.xy + float2(0.5,0.5));\n        P1p.xy = g_vResolution*(float2(0.5,-0.5)*P1p.xy + float2(0.5,0.5));\n        P2p.xy = g_vResolution*(float2(0.5,-0.5)*P2p.xy + float2(0.5,0.5));\n\n        // compute AABB\n        float2 vBBMin = min(P0p.xy,min(P1p.xy,P2p.xy));\n        float2 vBBMax = max(P0p.xy,max(P1p.xy,P2p.xy));\n        \n        // clip AABB to screen\n        vBBMin = max(vBBMin.xy,0);\n        vBBMax = min(vBBMax.xy,g_vResolution);\n\n        // reject out-of-bounds triangles\n        [branch]\n        if( all(vBBMin < vBBMax) )\n        {\n            // back-face test\n            float2 v01 = P1p.xy-P0p.xy;\n            float2 v20 = P0p.xy-P2p.xy;\n            [branch]\n            if( (v01.x*v20.y - v20.x*v01.y) < 0 )\n            {\n                // Setup Edge functions\n                float2 N01 = float2(-v01.y,v01.x);\n                float2 N20 = float2(-v20.y,v20.x);\n                float3 E01 = float3(N01.xy,-dot(N01,P0p.xy));\n                float3 E20 = float3(N20.xy,-dot(N20,P0p.xy));\n                E01 *= rcp(dot(E01,float3(P2p.xy,1)));\n                E20 *= rcp(dot(E20,float3(P1p.xy,1)));\n\n                // Setup interpolation functions for Z and 1/w\n                float3 ZPlane = float3(P0p.z, P2p.z-P0p.z, P1p.z-P0p.z);\n                float3 WPlane = float3(P0p.w, P2p.w-P0p.w, P1p.w-P0p.w);\n\n                // Round AABB to pixels\n                float2 TriMin = floor(vBBMin);\n                float2 TriMax = ceil(vBBMax);\n\n                // offset to pixel center\n                TriMin += 0.5f;\n                TriMax += 0.5f;\n\n                // iterate pixels\n                \n                float2 vPos;\n                for( vPos.y=TriMin.y; vPos.y < TriMax.y; vPos.y++ )\n                {\n                    for( vPos.x=TriMin.x; vPos.x < TriMax.x; vPos.x++ )\n                    {\n                        // TODO: Incremental?\n                        float u = dot( float3(vPos,1), E01 );\n                        float v = dot( float3(vPos,1), E20 );\n                        [branch]\n                        if( u>=0 && v>=0 && (u+v)<=1 )\n                        {\n                            // Interpolate depth\n                            float z = dot( float3(1,u,v),ZPlane );\n                            float w = dot( float3(1,u,v),WPlane );\n                            float depth = z/w;\n\n                            // Surprisingly, reading the Z-buffer first\n                            //    and then skipping redundant Interlocked ops\n                            //     results in a massive boost\n                            //\n                            //  I'm not so sure whether this is due to depth complexity or\n                            //   if we're somehow speeding up the atomics by ensuring\n                            //   that the pixels are in cache first\n                            //\n                            uint zb = g_ZBuffer[uint2(vPos.xy)];\n\n                            [branch]\n                            if( zb > asuint(depth) )\n                                InterlockedMin(g_ZBuffer[uint2(vPos.xy)], asuint(depth) );\n                        }\n                    }\n                }\n            }\n        }\n    }\n}\n*/"
  },
  {
    "path": "test/cs_raster.hlsl",
    "content": " \n\n#define THREADGROUP_WIDTH 160 // 1 SIMD16 thread per EU \n\ncbuffer globals\n{\n    row_major float4x4 mViewProj;\n    float2 g_vResolution; \n};\ncbuffer drawcall\n{\n    row_major float4x4 mWorld;\n    uint g_nTriangles;\n};\n\n// Public service announcement.  Raw buffers are SIGNIFICANTLY more efficient than TBuffers\n//  Buffer<xxx> and friends.   Because of stupid DX constraint that R32G32B32 views cannot be used on VB/IB\n//   it is necessary to load single elements from these.  \n//  Using ByteAddressBuffer instead gives me a sizable boost because we can load multiple dwords at once\n\nByteAddressBuffer g_Verts;\nByteAddressBuffer g_Indices; \n\nRWTexture2D<uint> g_ZBuffer : register(u0);\n\n\n[numthreads(THREADGROUP_WIDTH,1,1)]\nvoid main( uint3 ThreadID      : SV_DispatchThreadID,\n            uint3 GroupID       : SV_GroupID,\n            uint3 GroupThreadID : SV_GroupThreadID )\n{ \n    uint tid        = ThreadID.x;\n\n    [branch]\n    if( tid < g_nTriangles )\n    {\n        // fetch verts\n        //   NOTE: No Vertex re-use.   Possible to add some?\n        uint3 Indices = g_Indices.Load3( 12*tid );\n        float3 P0 = asfloat( g_Verts.Load3( 12*Indices.x ) );\n        float3 P1 = asfloat( g_Verts.Load3( 12*Indices.y ) );\n        float3 P2 = asfloat( g_Verts.Load3( 12*Indices.z ) );\n\t\t\n        // transform verts\n        float3 P0w = mul( float4(P0,1),  mWorld ).xyz;\n        float3 P1w = mul( float4(P1,1),  mWorld ).xyz;\n        float3 P2w = mul( float4(P2,1),  mWorld ).xyz;\n        float4 P0p = mul( float4(P0w,1), mViewProj );\n        float4 P1p = mul( float4(P1w,1), mViewProj );\n        float4 P2p = mul( float4(P2w,1), mViewProj );\n        P0p.w   = rcp(P0p.w); \n        P1p.w   = rcp(P1p.w);\n        P2p.w   = rcp(P2p.w);\n        P0p.xyz *= P0p.w; \n        P1p.xyz *= P1p.w;\n        P2p.xyz *= P2p.w;\n\n        // clip-space to viewport transform\n        P0p.xy = g_vResolution*(float2(0.5,-0.5)*P0p.xy + float2(0.5,0.5));\n        P1p.xy = g_vResolution*(float2(0.5,-0.5)*P1p.xy + float2(0.5,0.5));\n        P2p.xy = g_vResolution*(float2(0.5,-0.5)*P2p.xy + float2(0.5,0.5));\n\n        // compute AABB\n        float2 vBBMin = min(P0p.xy,min(P1p.xy,P2p.xy));\n        float2 vBBMax = max(P0p.xy,max(P1p.xy,P2p.xy));\n        \n        // clip AABB to screen\n        vBBMin = max(vBBMin.xy,0);\n        vBBMax = min(vBBMax.xy,g_vResolution);\n\n        // reject out-of-bounds triangles\n        [branch]\n        if( all(vBBMin < vBBMax) )\n        {\n            // back-face test\n            float2 v01 = P1p.xy-P0p.xy;\n            float2 v20 = P0p.xy-P2p.xy;\n            [branch]\n            if( (v01.x*v20.y - v20.x*v01.y) < 0 )\n            {\n                // Setup Edge functions\n                float2 N01 = float2(-v01.y,v01.x);\n                float2 N20 = float2(-v20.y,v20.x);\n                float3 E01 = float3(N01.xy,-dot(N01,P0p.xy));\n                float3 E20 = float3(N20.xy,-dot(N20,P0p.xy));\n                E01 *= rcp(dot(E01,float3(P2p.xy,1)));\n                E20 *= rcp(dot(E20,float3(P1p.xy,1)));\n\n                // Setup interpolation functions for Z and 1/w\n                float3 ZPlane = float3(P0p.z, P2p.z-P0p.z, P1p.z-P0p.z);\n                float3 WPlane = float3(P0p.w, P2p.w-P0p.w, P1p.w-P0p.w);\n\n                // Round AABB to pixels\n                float2 TriMin = floor(vBBMin);\n                float2 TriMax = ceil(vBBMax);\n\n                // offset to pixel center\n                TriMin += 0.5f;\n                TriMax += 0.5f;\n\n                // iterate pixels\n                \n                float2 vPos;\n                for( vPos.y=TriMin.y; vPos.y < TriMax.y; vPos.y++ )\n                {\n                    for( vPos.x=TriMin.x; vPos.x < TriMax.x; vPos.x++ )\n                    {\n                        // TODO: Incremental?\n                        float u = dot( float3(vPos,1), E01 );\n                        float v = dot( float3(vPos,1), E20 );\n                        [branch]\n                        if( u>=0 && v>=0 && (u+v)<=1 )\n                        {\n                            // Interpolate depth\n                            float z = dot( float3(1,u,v),ZPlane );\n                            float w = dot( float3(1,u,v),WPlane );\n                            float depth = z/w;\n\n                            // Surprisingly, reading the Z-buffer first\n                            //    and then skipping redundant Interlocked ops\n                            //     results in a massive boost\n                            //\n                            //  I'm not so sure whether this is due to depth complexity or\n                            //   if we're somehow speeding up the atomics by ensuring\n                            //   that the pixels are in cache first\n                            //\n                            uint zb = g_ZBuffer[uint2(vPos.xy)];\n\n                            [branch]\n                            if( zb > asuint(depth) )\n                                InterlockedMin(g_ZBuffer[uint2(vPos.xy)], asuint(depth) );\n                        }\n                    }\n                }\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "test/cs_raycaster",
    "content": "static const float HUGE = 100000000;\n\nstruct Vertex\n{\n    float3 P;\n    float3 N;\n};\n\nstruct Box\n{\n    float3 Min;\n    float3 Max;\n};\n\nstruct Node\n{\n    Box box;\n    int ChildIndex;\n    int PrimCount;    \n};\n\nstruct TriHit\n{\n    float T;\n    float U;\n    float V;\n};\n\nstruct Ray\n{\n    float3 Origin;\n    float3 Direction;\n    float tmax;\n    int nTriHit;\n    float u;\n    float v;\n};\n\nfloat hmax( float3 v )\n{\n   return max( max(v.x,v.y), v.z );\n}\nfloat hmin( float3 v )\n{\n   return min( min(v.x,v.y), v.z );\n}\n\nbool RayBoxTest( Box box, float3 O, float3 DInv, float tmax )\n{\n    float3 tMin = (O.xyz - box.Min.xyz)*DInv.xyz;\n    float3 tMax = (O.xyz - box.Max.xyz)*DInv.xyz;\n    float3 t0 = min(tMin,tMax);\n    float3 t1 = max(tMin,tMax);\n    t0.x = hmax( t0 );\n    t1.x = hmin( t1 );\n    return (t0.x < min(t1.x,tmax)) && t1.x > 0;        \n}\n\n\nbool RayTriangleTest( float3 P0, float3 P1, float3 P2, float3 O, float3 D, \n                      float TMax, out TriHit hit )\n{   \n    float3 v10 = P1 - P0;\n    float3 v02 = P0 - P2;\n    float3 v10x02 = cross(v10,v02);\n    float3 v0a = P0 - O;\n    float3 v02x0a = cross(v02,v0a);\n    \n    float V = 1 / dot( v10x02, D );\n    float A = V * dot( v02x0a, D );\n \n    if( A >= 0.0)\n    {\n        float3 v10x0a = cross(v10,v0a);\n        float B = V * dot( v10x0a, D );\n        \n        if( B >= 0.0 && (A+B) <= 1.0 )\n        {\n            float VA = dot( v10x02, v0a );\n            float T = VA*V;\n            if( T > 0 && T < TMax )\n            {\n                hit.T = T;\n                hit.U = 1.0 - (A+B);\n                hit.V = A;\n                return true;\n            }\n        }\n    }\n    return false;\n}\n\nStructuredBuffer<Node> bvh;\nStructuredBuffer<Vertex> verts;\nBuffer<int> indices;\nRWStructuredBuffer<Ray> rays;\n\n[numthreads(64,1,1)]\nvoid main( uint3 tid : SV_DispatchThreadID )\n{\n    Ray ray = rays[tid.x];\n    float3 O = ray.Origin;\n    float3 D = ray.Direction;\n    float3 DInv = 1/D;\n    float tmax = ray.tmax;\n    ray.nTriHit = -1;\n    \n    int n = 0;\n    int sp=0;\n    int stack[64];\n    \n    while( true )\n    {\n        while( RayBoxTest( bvh[n].box, O, DInv, tmax ) )\n        {\n            if( bvh[n].PrimCount > 0 )\n            {\n                for( int i=0; i<bvh[n].PrimCount; i++ )\n                {\n                    int prim = 3*(bvh[n].ChildIndex+i);\n                    float3 v0 = verts[ indices[prim] ].P;\n                    float3 v1 = verts[ indices[prim+1] ].P;\n                    float3 v2 = verts[ indices[prim+2] ].P;\n                    \n                    TriHit h;\n                    if( RayTriangleTest( v0,v1,v2,O,D,tmax,h) )\n                    {\n                        tmax = h.T;\n                        ray.tmax = tmax;\n                        ray.u = h.U;\n                        ray.v = h.V;\n                        ray.nTriHit = prim;\n                    }                    \n                }                    \n            }\n            else\n            {\n                stack[sp] = bvh[n].ChildIndex+1;\n                sp = sp+1;\n                n = bvh[n].ChildIndex;            \n            }\n        }\n      \n        // pop stack\n        if( sp == 0 )\n            break;  \n            \n        sp = sp-1;\n        n = stack[sp];        \n    }   \n    \n    rays[tid.x] = ray;\n   \n}"
  },
  {
    "path": "test/cs_sepgauss",
    "content": "#define N 8\n\nTexture2D<float4> Texels;\nRWTexture2D<float4> Output;\n\ngroupshared float4 SCRATCH[N+6][N+6];\ngroupshared float4 H[N][N+6];\n\nstatic const float KERNEL[7] = {\n 0.1,0.3,0.5,1.0,0.5,0.3,0.1 // note: wrong weights\n};\n\n[numthreads(N,N,1)]\nvoid main( uint3 TID : SV_DispatchThreadID,\n           uint3 gid : SV_GroupThreadID,\n           uint3 group : SV_GroupID )\n{\n    // fetch the full NxN neighborhood, along with\n    //  a 3 texel border aroudn it\n    uint3 addr = uint3(TID.xy,0);\n    SCRATCH[gid.x][gid.y]     = Texels.Load(addr,int2(-3,-3));\n    SCRATCH[gid.x][gid.y+5]   = Texels.Load(addr,int2(-3,3));\n    SCRATCH[gid.x+5][gid.y]   = Texels.Load(addr,int2(3,-3));\n    SCRATCH[gid.x+5][gid.y+5] = Texels.Load(addr,int2(3,3));\n    GroupMemoryBarrierWithGroupSync();\n\n    {\n        float4 htop=0;\n        float4 hbottom=0;\n        [unroll]\n        for( int i=0; i<7; i++ )\n        {\n            htop += KERNEL[i]*SCRATCH[gid.x+i][gid.y];\n            hbottom += KERNEL[i]*SCRATCH[gid.x+i][gid.y+5];\n        }\n        H[gid.x][gid.y] = htop;\n        H[gid.x][gid.y+5] = hbottom;\n    }\n    GroupMemoryBarrierWithGroupSync();\n\n    // vertical pass\n    float4 v=0;\n    [unroll]\n    for( int i=0; i<7; i++ )\n        v += KERNEL[i]*H[3+gid.x][gid.y+(i-3)];\n    Output[TID.xy] = v;\n}"
  },
  {
    "path": "test/include/include_d.txt",
    "content": "#include \"include_e.txt\""
  },
  {
    "path": "test/include/include_e.txt",
    "content": "static const float E = 16;"
  },
  {
    "path": "test/include_a.txt",
    "content": "#include \"include_b.txt\"\nfloat Function() { return B + 5; }\n"
  },
  {
    "path": "test/include_b.txt",
    "content": "static const float B = 42;"
  },
  {
    "path": "test/include_root.txt",
    "content": "//#extension GL_GOOGLE_include_directive : require\n#include \"include_a.txt\"\n#include \"include_d.txt\"\n\nfloat main() : SV_Target\n{\n   return Function() + E;\n}"
  },
  {
    "path": "test/manual_trilerp",
    "content": "\nfloat2 g_fSize;\nTexture2D<float> tx;\n\nfloat4 bilerp( float2 uv, float lod )\n{\n\tfloat2 coords = (uv)/exp(lod);\n\tcoords = coords-0.5;\n\tfloat2 weights = frac(coords);\n\t\n\tint3 icoords = int3(coords,lod);\n\tfloat4 t0 = tx.Load( icoords, uint2(0,0) );\n\tfloat4 t1 = tx.Load( icoords, uint2(1,0) );\n\tfloat4 t2 = tx.Load( icoords, uint2(0,1) );\n\tfloat4 t3 = tx.Load( icoords, uint2(1,1) );\n\t\n\treturn lerp( lerp(t0,t1,weights.x),\n\t             lerp(t2,t3,weights.x), weights.y );\n}\n\nfloat4 main( float2 uv : uv ) : SV_Target\n{\n    uv = uv*g_fSize;\n\tfloat2 sizes = abs(ddx(uv)+ddy(uv));\n\tfloat lod = log2( max(sizes.x,sizes.y) );\n\t\n\tfloat4 l0 = bilerp(uv,floor(lod));\n\tfloat4 l1 = bilerp(uv,floor(lod)+1);\n\treturn lerp(l0,l1,frac(lod));\n}"
  },
  {
    "path": "test/manual_trilerp_glsl",
    "content": "#version 300 es\nprecision highp float;\n\nuniform vec2 g_fSize;\nuniform sampler2D tx;\n\nvec4 bilerp( vec2 uv, float lod )\n{\n\tvec2 coords = (uv)/exp(lod);\n\tcoords = coords-vec2(0.5);\n\tvec2 weights = fract(coords);\n\t\n\tivec2 icoords = ivec2(coords);\n\tint ilod = int(lod);\n\tvec4 t0 = texelFetch( tx, icoords + ivec2(0,0), ilod );\n\tvec4 t1 = texelFetch( tx, icoords + ivec2(1,0), ilod );\n\tvec4 t2 = texelFetch( tx, icoords + ivec2(0,1), ilod );\n\tvec4 t3 = texelFetch( tx, icoords + ivec2(1,1), ilod );\n\t\n\treturn mix( mix(t0,t1,weights.x),\n\t             mix(t2,t3,weights.x), weights.y );\n}\n\nin vec2 UV;\nout vec4 Color;\nvoid main( )\n{\n    vec2 uv = UV*g_fSize;\n\tvec2 sizes = abs(dFdx(uv)+dFdy(uv));\n\tfloat lod = log2( max(sizes.x,sizes.y) );\n\t\n\tvec4 l0 = bilerp(uv,floor(lod));\n\tvec4 l1 = bilerp(uv,floor(lod)+1.f);\n\tColor= mix(l0,l1,fract(lod));\n}"
  },
  {
    "path": "test/matthias_bug",
    "content": "Texture2D               myTexture : register(t0);\nSamplerState    mySampler : register(s0);\n \nfloat linearToSRGB( float cl )\n{\n        float cs;\n        if( isnan(cl) ) {\n                /* Map IEEE-754 Not-a-number to zero. */\n                cs = 0.0;\n        } else if (cl > 1.0) {\n                cs = 1.0;\n        } else if (cl < 0.0) {\n                cs = 0.0;\n        } else if (cl < 0.0031308) {\n                cs = 12.92 * cl;\n        } else {\n                cs = 1.055 * pow(cl, 0.41666) - 0.055;\n        }\n       \n        return cs;\n}\n \nfloat3 linearToSRGB( float3 cl )\n{\n        return float3( linearToSRGB(cl.x), linearToSRGB(cl.y), linearToSRGB(cl.z) );\n}\n \nfloat4 main( float2 uv : TEXCOORD0 ) : SV_Target\n{\n        uv.y = 1.0f - uv.y;\n        float4 colour = myTexture.Sample( mySampler, uv ).xyzw;\n        return float4( linearToSRGB( colour.xyz ), colour.w );\n}"
  },
  {
    "path": "test/mips",
    "content": "\nfloat3 accurateSRGBToLinear (in float3 sRGBCol )\n{\n float3 linearRGBLo = sRGBCol / 12.92;\n float3 linearRGBHi = pow (( sRGBCol + 0.055) / 1.055 , 2.4) ;\n float3 linearRGB = ( sRGBCol <= 0.04045) ? linearRGBLo : linearRGBHi ;\n return linearRGB ;\n }\n\n float3 accurateLinearToSRGB (in float3 linearCol )\n {\n float3 sRGBLo = linearCol * 12.92;\n float3 sRGBHi = ( pow( abs ( linearCol ) , 1.0/2.4) * 1.055) - 0.055;\n float3 sRGB = ( linearCol <= 0.0031308) ? sRGBLo : sRGBHi ;\n return sRGB;\n }\n\n#define NUMTHREADS 8\n\nTexture2D<float4> SrcMip : register(t0);\nRWTexture2D<float4> DstMip : register(u0);\nsampler SS_DEFAULT : register(s0);\n\nfloat2 vDims;\nuint g_bSRGB;\n\n[numthreads(NUMTHREADS,NUMTHREADS,1)]\nvoid main( uint2 gid : SV_GroupID, \n           uint2 tid : SV_GroupThreadID )\n{ \n\tuint2 vPixel = gid*NUMTHREADS + tid;\n\t\n\tuint2 dims;\n\tSrcMip.GetDimensions(dims.x,dims.y);\n\t\n\tfloat2 uv = (vPixel + float2(0.5f,0.5f)) * rcp(dims.xy);\n\tfloat4 vTap = SrcMip.SampleLevel( SS_DEFAULT, uv, 0 );\n\t\n\t\n\tDstMip[vPixel] = g_bSRGB ? accurateLinearToSRGB(vTap) : vTap;\n}\n"
  },
  {
    "path": "test/moblur_reduc",
    "content": "\n#define TILE_SIZE 32\n#define THREAD_COUNT TILE_SIZE*TILE_SIZE\n\nTexture2D<float2> tx_velocity;\nRWTexture2D<float2> tx_tile_out;\n\ngroupshared float2 SCRATCH[TILE_SIZE*TILE_SIZE];\n\n\n[numthreads(THREAD_COUNT,1,1)]\nvoid main( uint3 tid : SV_DispatchThreadID, \n           uint3 tid_local : SV_GroupThreadID,\n           uint3 gid : SV_GroupID )\n{\n\tuint x = tid_local.x % TILE_SIZE;\n\tuint y = tid_local.y / TILE_SIZE;\n\t\n\tuint2 fetch = gid.xy*TILE_SIZE + uint2(x,y);\n\t\n\tfloat2 v = tx_velocity.Load( uint3(fetch.xy,0) );\n\tSCRATCH[tid_local.x] = v;\n\t\n\tuint n = THREAD_COUNT/2; \n\tdo\n\t{\n\t\tGroupMemoryBarrierWithGroupSync();\n\t\tif( tid_local.x < n )\t\t\n\t\t{\n\t\t\tfloat2 v0 = SCRATCH[tid_local.x];\n\t\t\tfloat2 v1 = SCRATCH[tid_local.x+n];\n\t\t\tfloat m0 = dot(v0,v0);\n\t\t\tfloat m1 = dot(v1,v1);\n\t\t\tfloat2 big = (m0>m1) ? v0 : v1;\n\t\t\tSCRATCH[tid_local.x] = big;\n\t\t}\n\n\t\tn = n/2;\n\t} while( n > 1 );\n\t\n\t\n\tif( tid_local.x == 0 )\n\t\ttx_tile_out[gid.xy] = SCRATCH[0];\n}\n"
  },
  {
    "path": "test/ps_lighting.txt",
    "content": "\nuint nLights;\nBuffer<float3> g_LightPositions;\nBuffer<float3> g_LightColors;\nTexture2D<float3> g_Tx;\nsampler g_S;\nfloat4 main( float3 P : P, float3 N : N ) : SV_Target\n{\n    float3 Diff = g_Tx.Sample(g_S,P.xy);\n    float3 C=0;\n    for( uint i=0; i<nLights; i++ )\n    {\n        float3 Pl = g_LightPositions.Load(i);\n        float3 Cl = g_LightColors.Load(i);\n        float3 L = normalize( Pl - P );\n        C += Cl*saturate(dot(N,L));\n    }\n    return float4(C*Diff,1);\n}"
  },
  {
    "path": "test/ps_lighting_normalmap",
    "content": "\n\n\n\nstruct VSOut\n{\n    float3 N      : TEXCOORD0;\n    float3 T      : TEXCOORD1;\n    float3 B      : TEXCOORD2;\n    float3 P      : TEXCOORD3;\n    float2 uv     : TEXCOORD4;\n    float4 vPos   : SV_POSITION;\n};\n\n\nBuffer<float4> g_LightPositions; // w == radius\nBuffer<float3> g_LightColors;\nuint g_nLights;\nfloat3 g_CamPos;\nTexture2D<float3> tNormalMap;\nTexture2D<float3> tTexture;\nTextureCube<float3> tCube;\nsampler sTexture;\n\nfloat4 main(  VSOut input ) : SV_TARGET\n{\n    float3 vN     = tNormalMap.Sample( sTexture, input.uv );\n  \tfloat3 N      = ( input.N );\n    float3 T      = ( input.T );\n    float3 B      = ( input.B );\n    N = N*vN.z + T*vN.y + B*vN.x;\n  \t\n    float3 vTex   = tTexture.Sample( sTexture, input.uv );\n    float3 diff = tCube.SampleBias( sTexture, N, 15 );\n    \n    float3 R = reflect( N, input.P-g_CamPos);\n    float3 spec = tCube.Sample( sTexture, R );\n    \n    for( int i=0; i<g_nLights; i++ )\n    {\n        float3 Pl     = g_LightPositions[i].xyz;\n        float r       = g_LightPositions[i].w;\n        float falloff = length(Pl-input.P)/r;\n    \tfloat3 L      = normalize( Pl - input.P );\n    \tfloat3 Cl     = g_LightColors[i].xyz*saturate(dot(N,L));\n    \tdiff += Cl*falloff;\n    }\n    \n    diff *= vTex;\n   \n    return float4(diff+spec,1);\n}"
  },
  {
    "path": "test/ps_ubershader",
    "content": "\ncbuffer switches\n{\n\tbool g_bObjectSpaceNM;\n\tbool g_bSpec;\n\tbool g_bCube;\n\tbool g_bRough;\n\tbool g_bMetallic;\n\tbool g_bNM;\n\tbool g_bSMap;\n\tfloat3 g_LightDir;\n\tfloat3 g_LightColor;\n\tfloat3 g_EyePos;\n\tfloat g_StaticRoughness;\n\t\n\tfloat4x4 g_mShadowMap;\n\tfloat2 g_ShadowMapSize;\n\n};\n\n#define PI 3.1415926\n\nTexture2D<float4> tDiff;\nTexture2D<float3> tNormal;\nTexture2D<float> tRough;\nTextureCube<float4> tCube;\n\nTexture2D<float> tShadowMap;\nSamplerComparisonState sCmp;\n\nsampler s;\n\nstruct Inputs\n{\n   float3 N : N;\n   float2 UV : uv;\n   float3 T : T;\n   float3 Pos : P;\n};\n\nfloat PCFGather5x5( float3 vPosSM, float2 Size, Texture2D<float> t, SamplerComparisonState s )\n{\n    float2 uv = (vPosSM.xy*Size);\n    float z   = saturate(vPosSM.z);\n    float2 vWeights = frac(uv.xy); // grab bilinear weights\n    \n    // snap UV to texel center\n    //  If we don't do this, our texels won't agree with the sampler's texels\n    uv = (floor(uv)+0.5)/Size; \n\n    float4 v0 = t.GatherCmp( s, uv, z, int2(-2, -2) );\n    float4 v1 = t.GatherCmp( s, uv, z, int2( 0, -2) );\n    float4 v2 = t.GatherCmp( s, uv, z, int2( 2, -2) );\n    float4 v3 = t.GatherCmp( s, uv, z, int2(-2,  0) );\n    float4 v4 = t.GatherCmp( s, uv, z, int2( 0,  0) );\n    float4 v5 = t.GatherCmp( s, uv, z, int2( 2,  0) );\n    float4 v6 = t.GatherCmp( s, uv, z, int2(-2,  2) );\n    float4 v7 = t.GatherCmp( s, uv, z, int2( 0,  2) );\n    float4 v8 = t.GatherCmp( s, uv, z, int2( 2,  2) );\n\n    // tap locations\n    //    .    .   .   .   .   .  \n    //      0        1       2\n    //    .    .   .   .   .   .   \n    //          \n    //    .    .   .   .   .   .   \n    //      3        4       5\n    //    .    .   .   .   .   .  \n    //      \n    //    .    .   .   .   .   .   \n    //      6        7       8\n    //    .    .   .   .   .   .  \n    //\n        \n    // gather4 texel ordering:\n    //  w  z\n    //  x  y\n    //       \n     \n    float u = vWeights.x;\n    float v = vWeights.y;\n    float r0 = ( v0.z  + v1.z  + v1.w  + v2.w ) + u*v2.z  + (1-u)*v0.w;\n    float r1 = ( v0.y  + v1.y  + v1.x  + v2.x ) + u*v2.y  + (1-u)*v0.x;\n    float r2 = ( v3.z  + v4.z  + v4.w  + v5.w ) + u*v5.z  + (1-u)*v3.w;\n    float r3 = ( v3.y  + v4.y  + v4.x  + v5.x ) + u*v5.y  + (1-u)*v3.x;\n    float r4 = ( v6.z  + v7.z  + v7.w  + v8.w ) + u*v8.z  + (1-u)*v6.w;\n    float r5 = ( v6.y  + v7.y  + v7.x  + v8.x ) + u*v8.y  + (1-u)*v6.x;\n    float blend = r0*(1-v) + r1 + r2 + r3 + r4 + r5*v;\n    return blend/25;\n}\n\n\n\nfloat4 SHADE( \n           Inputs input,\n           bool NORMAL_MAP,\n           bool TANGENT_SPACE_NM,\n           bool SPEC,\n           bool METALLIC,\n           bool ROUGHNESS_MAP,\n           bool CUBE_MAP,\n           bool SHADOWS\n           ) : SV_TARGET\n{ \n    float2 UV = input.UV;\n    float4 diff   = tDiff.Sample(s,UV);\n\tfloat3 V = normalize(input.Pos - g_EyePos);\n    float3 N = normalize(input.N);\n   \n   \n   \n   \t[branch]\n    if( NORMAL_MAP )\n    {\n    \tfloat3 normaltx = tNormal.Sample(s,UV).xyz;\n    \t\n   \t\t[branch]\n    \tif( TANGENT_SPACE_NM )\n    \t{\n\t    \tfloat3 T = normalize(input.T);\n\t        float3 B = cross(N,T);\n\t    \t\t N = B * normaltx.x + \n\t    \t         T * normaltx.y +\n\t    \t         N * normaltx.z;\n    \t}\n    }\n    \n    float3 vDirect = diff.xyz*saturate( dot(N,g_LightDir) );\n  \n   \t[branch]\n    if( SPEC )\n   \t{\n   \t\tfloat rough = g_StaticRoughness;\n   \t\n   \t\t[branch]\n   \t\tif( ROUGHNESS_MAP )\n   \t\t{\n   \t\t     rough = tRough.Sample( s, UV );\n   \t\t}\n   \t\t     \n   \t\tfloat3 H = normalize( g_LightDir +V  );\n   \t\tfloat fSpec = ((rough+1)/(2.0f*PI))*pow( saturate(dot(N,H)), rough );\n   \t\tfloat3 vSpec = fSpec;\n   \t\t\n   \t\t[branch]\n   \t\tif( METALLIC )\n   \t\t    vSpec *= diff.xyz;\n   \t\t    \n   \t\tvDirect += vSpec;\n   \t}\n   \tfloat3 vIndirect = 0;\n   \t\n   \t[branch]\n\tif( CUBE_MAP )\n\t{\n\t   \tfloat3 cube = tCube.Sample( s, reflect(N,V) );\n\t   \t\n   \t\t[branch]\n\t   \tif( METALLIC )\n\t   \t\tcube *= diff.xyz;\n\t   \tvIndirect += cube;\n\t}\n\t\n    [branch]\n   \tif( SHADOWS )\n   \t{\n   \t\tfloat4 vPosSM = mul( float4(input.Pos,1), g_mShadowMap  );\n   \t\tfloat sh = PCFGather5x5( vPosSM.xyz/vPosSM.w, g_ShadowMapSize, tShadowMap, sCmp );\n   \t\tvDirect *= sh;\n   \t}\n   \t\n   \t\t\n\treturn float4(vDirect*g_LightColor + vIndirect,1); \n}\n\n\n\n\nfloat4 main( Inputs input ) : SV_TARGET\n{\n\n\t//return SHADE_GOOD(input);\n\n\treturn SHADE(input,true,true,true,true,true, true, true );\n\n\t//return SHADE(input,g_bNM, g_bObjectSpaceNM, g_bSpec,g_bMetallic, g_bCube, g_bRough, g_bSMap );\n}"
  },
  {
    "path": "test/trivial_test_shaders.txt",
    "content": "float4 mainPS() : SV_Target { return 0; }\nfloat4 mainVS() : SV_Position { return 0; }\n\nstruct GSIn\n{\n    float4 v : SV_Position;\n};\nstruct GSOut\n{\n    float4 vPos : SV_Position;\n};\n[maxvertexcount(4)]\nvoid mainGS( point GSIn p[1], inout TriangleStream<GSOut> triStream )\n{\n    GSOut v;\n    v.vPos = p[0].v;\n    triStream.Append(v);\n    triStream.Append(v);\n    triStream.Append(v);\n}\n\n\nstruct VertexDS\n{\n   float3 p : SV_Position;\n};\n\nstruct PatchInfoDS\n{\n   float v[2] : SV_InsideTessFactor;\n   float edges[4] : SV_TessFactor;\n};\n\n[domain(\"quad\")]\nfloat4 mainDS( in PatchInfoDS info, float2 UV : SV_DomainLocation, const OutputPatch<VertexDS, 4> bezpatch ) : SV_Position\n{\n    float4 v = 0;\n    v.xyz = lerp( lerp( bezpatch[0].p, bezpatch[1].p, UV.x ),\n                  lerp( bezpatch[2].p, bezpatch[3].p, UV.x ), UV.y );\n    \n    v.w = 1;\n    return v;  \n}\n\n\n\nstruct VertexHS\n{\n   float3 p : Pos;\n};\n\nstruct PatchInfoHS\n{\n   float v[2] : SV_InsideTessFactor;\n   float edges[4] : SV_TessFactor;\n};\n\nPatchInfoHS HSConstants()\n{\n   PatchInfoHS info;\n   info.v[0] = 0;\n   info.v[1] = 0;\n   info.edges[0] = 0;\n   info.edges[1] = 0;\n   info.edges[2] = 0;\n   info.edges[3] = 0;\n   return info;\n}\n\n[domain(\"quad\")]\n[partitioning(\"integer\")]\n[outputtopology(\"triangle_cw\")]\n[outputcontrolpoints(16)]\n[patchconstantfunc(\"HSConstants\")]\nVertexHS mainHS( \n    InputPatch<VertexHS, 4> ip, \n    uint i : SV_OutputControlPointID,\n    uint PatchID : SV_PrimitiveID )\n{\n    VertexHS Output;\n    Output.p.xyz = 0;\n    return Output;\n}\n\n\nRWBuffer<float2> Out;\n\n[numthreads(64,1,1)]\nvoid mainCS( uint id : SV_DispatchThreadID )\n{\n   Out[id] = 0;\n}\n\n"
  },
  {
    "path": "test/trivial_vs_glsl",
    "content": "#version 300 es\nprecision highp float;\n\nin vec4 Pos;\nout vec4 Pos_x;\nvoid main( )\n{\n\tPos_x = Pos;\n}"
  },
  {
    "path": "test/vs_rigid",
    "content": "\nfloat4x4 mViewProj;\nfloat4x4 mWorld;\n\nstruct VSOut\n{\n   float4 P : SV_Position;\n   float3 N : n;\n   float2 uv : uv;\n};\n\nVSOut main( float3 P : p,\n            float3 N : n,\n            float2 uv : uv\n            )\n{\n    float3 vP=0;\n    float3 vN=0;\n    vP = mul( float4(P,1), mWorld );\n    vN = mul( float4(N,0), mWorld );\n    \n\tVSOut o;\n\to.P   = mul( float4(vP,1), mViewProj );\n\to.N   = normalize(vN);\n\to.uv  = uv;\n\treturn o;\n}"
  },
  {
    "path": "test/vs_skinning",
    "content": "\nfloat4x4 mViewProj;\nfloat4x4 mSkin[30];\n\nstruct VSOut\n{\n   float4 P : SV_Position;\n   float4 N : n;\n   float2 uv : uv;\n};\n\nVSOut main( float3 P   : p,\n            float3 N   : n,\n            float2 uv  : uv,\n            float4 w   : weights,\n            uint4 idx  : indices,\n            float3 foo : foo)\n{\n    float3 vP=0;\n    float3 vN=0;\n    \n    [unroll]\n    for( int i=0; i<4; i++ )\n    {\n        vP += mul( float4(P,1), mSkin[idx[i]] ) * w[i];\n        vN += mul( float4(N,0), mSkin[idx[i]] ) * w[i];\n    }\n    \n\tVSOut o;\n\to.P   = mul( float4(vP,1), mViewProj );\n\to.N   = float4(vN.xyz,1);\n\to.uv  = uv.xy;\n\treturn o;\n}"
  }
]