Line endings

This commit is contained in:
kobalicek
2014-06-07 19:23:35 +02:00
parent c87814b225
commit 0dbd42f350
5 changed files with 1901 additions and 1901 deletions

472
Doxyfile
View File

@@ -1,236 +1,236 @@
# Doxyfile 1.8.7
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = "AsmJit"
PROJECT_NUMBER = "1.1"
PROJECT_BRIEF = "Complete Remote and JIT Assembler for x86/x64"
OUTPUT_DIRECTORY = .
CREATE_SUBDIRS = NO
ALLOW_UNICODE_NAMES = NO
OUTPUT_LANGUAGE = English
FULL_PATH_NAMES = YES
STRIP_FROM_PATH =
STRIP_FROM_INC_PATH =
SHORT_NAMES = NO
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
QT_AUTOBRIEF = NO
JAVADOC_AUTOBRIEF = YES
MULTILINE_CPP_IS_BRIEF = YES
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
INHERIT_DOCS = YES
TAB_SIZE = 2
MARKDOWN_SUPPORT = YES
AUTOLINK_SUPPORT = NO
IDL_PROPERTY_SUPPORT = NO
SEPARATE_MEMBER_PAGES = NO
DISTRIBUTE_GROUP_DOC = NO
SUBGROUPING = YES
INLINE_GROUPED_CLASSES = NO
INLINE_SIMPLE_STRUCTS = NO
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
EXTRACT_ALL = NO
EXTRACT_PRIVATE = NO
EXTRACT_PACKAGE = NO
EXTRACT_STATIC = NO
EXTRACT_LOCAL_CLASSES = NO
HIDE_UNDOC_CLASSES = YES
HIDE_UNDOC_MEMBERS = NO
HIDE_FRIEND_COMPOUNDS = YES
HIDE_IN_BODY_DOCS = YES
INTERNAL_DOCS = NO
CASE_SENSE_NAMES = NO
# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with
# their full class and namespace scopes in the documentation. If set to YES the
# scope will be hidden.
# The default value is: NO.
HIDE_SCOPE_NAMES = NO
SHOW_INCLUDE_FILES = NO
SHOW_GROUPED_MEMB_INC = NO
INLINE_INFO = YES
SORT_MEMBER_DOCS = NO
SORT_BRIEF_DOCS = NO
SORT_GROUP_NAMES = NO
SORT_BY_SCOPE_NAME = YES
STRICT_PROTO_MATCHING = NO
GENERATE_TODOLIST = NO
GENERATE_TESTLIST = NO
GENERATE_BUGLIST = NO
GENERATE_DEPRECATEDLIST= NO
MAX_INITIALIZER_LINES = 0
SHOW_USED_FILES = NO
SHOW_FILES = NO
SHOW_NAMESPACES = NO
#---------------------------------------------------------------------------
# Configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = YES
WARNINGS = YES
WARN_IF_UNDOCUMENTED = NO
WARN_IF_DOC_ERROR = YES
WARN_NO_PARAMDOC = NO
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# Configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = src/asmjit
INPUT_ENCODING = UTF-8
RECURSIVE = YES
EXCLUDE =
USE_MDFILE_AS_MAINPAGE = README.md
#---------------------------------------------------------------------------
# Configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = NO
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
SOURCE_TOOLTIPS = YES
VERBATIM_HEADERS = NO
#---------------------------------------------------------------------------
# Configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = NO
#---------------------------------------------------------------------------
# Configuration options related to outputs
#---------------------------------------------------------------------------
GENERATE_HTML = YES
GENERATE_LATEX = NO
GENERATE_RTF = NO
GENERATE_MAN = NO
GENERATE_XML = YES
XML_OUTPUT = build_xml
XML_PROGRAMLISTING = NO
HTML_OUTPUT = build_doc
HTML_FILE_EXTENSION = .html
LAYOUT_FILE = tools/doc-layout.xml
HTML_HEADER = tools/doc-header.html
HTML_FOOTER = tools/doc-footer.html
HTML_STYLESHEET = tools/doc-style.css
HTML_EXTRA_STYLESHEET =
HTML_EXTRA_FILES =
HTML_COLORSTYLE_HUE = 220
HTML_COLORSTYLE_SAT = 100
HTML_COLORSTYLE_GAMMA = 80
HTML_TIMESTAMP = NO
HTML_DYNAMIC_SECTIONS = NO
HTML_INDEX_NUM_ENTRIES = 0
SEARCHENGINE = NO
#---------------------------------------------------------------------------
# Configuration options related to the CHM output
#---------------------------------------------------------------------------
# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three
# additional HTML index files: index.hhp, index.hhc, and index.hhk. The
# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop
# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on
# Windows.
#
# The HTML Help Workshop contains a compiler that can convert all HTML output
# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML
# files are now used as the Windows 98 help format, and will replace the old
# Windows help format (.hlp) on all Windows platforms in the future. Compressed
# HTML files also contain an index, a table of contents, and you can search for
# words in the documentation. The HTML workshop also contains a viewer for
# compressed HTML files.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
GENERATE_HTMLHELP = NO
# The CHM_FILE tag can be used to specify the file name of the resulting .chm
# file. You can add a path in front of the file if the result should not be
# written to the html output directory.
# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
CHM_FILE =
# The HHC_LOCATION tag can be used to specify the location (absolute path
# including file name) of the HTML help compiler ( hhc.exe). If non-empty
# doxygen will try to run the HTML help compiler on the generated index.hhp.
# The file has to be specified with full path.
# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
HHC_LOCATION =
# The BINARY_TOC flag controls whether a binary table of contents is generated (
# YES) or a normal table of contents ( NO) in the .chm file. Furthermore it
# enables the Previous and Next buttons.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
BINARY_TOC = NO
# The TOC_EXPAND flag can be set to YES to add extra items for group members to
# the table of contents of the HTML help documentation and to the tree view.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
TOC_EXPAND = NO
DISABLE_INDEX = NO
GENERATE_TREEVIEW = NO
ENUM_VALUES_PER_LINE = 0
TREEVIEW_WIDTH = 250
EXT_LINKS_IN_WINDOW = NO
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = NO
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
PREDEFINED = ASMJIT_DOCGEN \
ASMJIT_BUILD_X86 \
ASMJIT_BUILD_X64 \
ASMJIT_API
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = NO
CLASS_GRAPH = NO
# Doxyfile 1.8.7
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = "AsmJit"
PROJECT_NUMBER = "1.1"
PROJECT_BRIEF = "Complete Remote and JIT Assembler for x86/x64"
OUTPUT_DIRECTORY = .
CREATE_SUBDIRS = NO
ALLOW_UNICODE_NAMES = NO
OUTPUT_LANGUAGE = English
FULL_PATH_NAMES = YES
STRIP_FROM_PATH =
STRIP_FROM_INC_PATH =
SHORT_NAMES = NO
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
QT_AUTOBRIEF = NO
JAVADOC_AUTOBRIEF = YES
MULTILINE_CPP_IS_BRIEF = YES
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
INHERIT_DOCS = YES
TAB_SIZE = 2
MARKDOWN_SUPPORT = YES
AUTOLINK_SUPPORT = NO
IDL_PROPERTY_SUPPORT = NO
SEPARATE_MEMBER_PAGES = NO
DISTRIBUTE_GROUP_DOC = NO
SUBGROUPING = YES
INLINE_GROUPED_CLASSES = NO
INLINE_SIMPLE_STRUCTS = NO
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
EXTRACT_ALL = NO
EXTRACT_PRIVATE = NO
EXTRACT_PACKAGE = NO
EXTRACT_STATIC = NO
EXTRACT_LOCAL_CLASSES = NO
HIDE_UNDOC_CLASSES = YES
HIDE_UNDOC_MEMBERS = NO
HIDE_FRIEND_COMPOUNDS = YES
HIDE_IN_BODY_DOCS = YES
INTERNAL_DOCS = NO
CASE_SENSE_NAMES = NO
# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with
# their full class and namespace scopes in the documentation. If set to YES the
# scope will be hidden.
# The default value is: NO.
HIDE_SCOPE_NAMES = NO
SHOW_INCLUDE_FILES = NO
SHOW_GROUPED_MEMB_INC = NO
INLINE_INFO = YES
SORT_MEMBER_DOCS = NO
SORT_BRIEF_DOCS = NO
SORT_GROUP_NAMES = NO
SORT_BY_SCOPE_NAME = YES
STRICT_PROTO_MATCHING = NO
GENERATE_TODOLIST = NO
GENERATE_TESTLIST = NO
GENERATE_BUGLIST = NO
GENERATE_DEPRECATEDLIST= NO
MAX_INITIALIZER_LINES = 0
SHOW_USED_FILES = NO
SHOW_FILES = NO
SHOW_NAMESPACES = NO
#---------------------------------------------------------------------------
# Configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = YES
WARNINGS = YES
WARN_IF_UNDOCUMENTED = NO
WARN_IF_DOC_ERROR = YES
WARN_NO_PARAMDOC = NO
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# Configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = src/asmjit
INPUT_ENCODING = UTF-8
RECURSIVE = YES
EXCLUDE =
USE_MDFILE_AS_MAINPAGE = README.md
#---------------------------------------------------------------------------
# Configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = NO
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
SOURCE_TOOLTIPS = YES
VERBATIM_HEADERS = NO
#---------------------------------------------------------------------------
# Configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = NO
#---------------------------------------------------------------------------
# Configuration options related to outputs
#---------------------------------------------------------------------------
GENERATE_HTML = YES
GENERATE_LATEX = NO
GENERATE_RTF = NO
GENERATE_MAN = NO
GENERATE_XML = YES
XML_OUTPUT = build_xml
XML_PROGRAMLISTING = NO
HTML_OUTPUT = build_doc
HTML_FILE_EXTENSION = .html
LAYOUT_FILE = tools/doc-layout.xml
HTML_HEADER = tools/doc-header.html
HTML_FOOTER = tools/doc-footer.html
HTML_STYLESHEET = tools/doc-style.css
HTML_EXTRA_STYLESHEET =
HTML_EXTRA_FILES =
HTML_COLORSTYLE_HUE = 220
HTML_COLORSTYLE_SAT = 100
HTML_COLORSTYLE_GAMMA = 80
HTML_TIMESTAMP = NO
HTML_DYNAMIC_SECTIONS = NO
HTML_INDEX_NUM_ENTRIES = 0
SEARCHENGINE = NO
#---------------------------------------------------------------------------
# Configuration options related to the CHM output
#---------------------------------------------------------------------------
# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three
# additional HTML index files: index.hhp, index.hhc, and index.hhk. The
# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop
# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on
# Windows.
#
# The HTML Help Workshop contains a compiler that can convert all HTML output
# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML
# files are now used as the Windows 98 help format, and will replace the old
# Windows help format (.hlp) on all Windows platforms in the future. Compressed
# HTML files also contain an index, a table of contents, and you can search for
# words in the documentation. The HTML workshop also contains a viewer for
# compressed HTML files.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
GENERATE_HTMLHELP = NO
# The CHM_FILE tag can be used to specify the file name of the resulting .chm
# file. You can add a path in front of the file if the result should not be
# written to the html output directory.
# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
CHM_FILE =
# The HHC_LOCATION tag can be used to specify the location (absolute path
# including file name) of the HTML help compiler ( hhc.exe). If non-empty
# doxygen will try to run the HTML help compiler on the generated index.hhp.
# The file has to be specified with full path.
# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
HHC_LOCATION =
# The BINARY_TOC flag controls whether a binary table of contents is generated (
# YES) or a normal table of contents ( NO) in the .chm file. Furthermore it
# enables the Previous and Next buttons.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
BINARY_TOC = NO
# The TOC_EXPAND flag can be set to YES to add extra items for group members to
# the table of contents of the HTML help documentation and to the tree view.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
TOC_EXPAND = NO
DISABLE_INDEX = NO
GENERATE_TREEVIEW = NO
ENUM_VALUES_PER_LINE = 0
TREEVIEW_WIDTH = 250
EXT_LINKS_IN_WINDOW = NO
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = NO
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
PREDEFINED = ASMJIT_DOCGEN \
ASMJIT_BUILD_X86 \
ASMJIT_BUILD_X64 \
ASMJIT_API
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = NO
CLASS_GRAPH = NO

View File

@@ -1,21 +1,21 @@
<!--BEGIN GENERATE_TREEVIEW-->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
$navpath
<li class="footer">$generatedby
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="$relpath^doxygen.png" alt="doxygen"/></a> $doxygenversion </li>
</ul>
</div>
<!--END GENERATE_TREEVIEW-->
<!--BEGIN !GENERATE_TREEVIEW-->
<hr class="footer"/><address class="footer"><small>
$generatedby &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="$relpath^doxygen.png" alt="doxygen"/>
</a> $doxygenversion
</small></address>
<!--END !GENERATE_TREEVIEW-->
</body>
</html>
<!--BEGIN GENERATE_TREEVIEW-->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
$navpath
<li class="footer">$generatedby
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="$relpath^doxygen.png" alt="doxygen"/></a> $doxygenversion </li>
</ul>
</div>
<!--END GENERATE_TREEVIEW-->
<!--BEGIN !GENERATE_TREEVIEW-->
<hr class="footer"/><address class="footer"><small>
$generatedby &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="$relpath^doxygen.png" alt="doxygen"/>
</a> $doxygenversion
</small></address>
<!--END !GENERATE_TREEVIEW-->
</body>
</html>

View File

@@ -1,37 +1,37 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>$projectname: $title</title>
<script type="text/javascript" src="$relpath^jquery.js"></script>
<script type="text/javascript" src="$relpath^dynsections.js"></script>
$treeview
$search
<link href="$relpath^$stylesheet" rel="stylesheet" type="text/css" />
$extrastylesheet
</head>
<body>
<!-- do not remove this div, it is closed by doxygen! -->
<div id="top">
<!--BEGIN TITLEAREA-->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<!--BEGIN PROJECT_LOGO-->
<td id="projectlogo"><img alt="Logo" src="$relpath^$projectlogo"/></td>
<!--END PROJECT_LOGO-->
<td style="padding-left: 0.5em;">
<div id="projectname">$projectname&#160;<span id="projectnumber">$projectnumber</span> API</div>
<div id="projectbrief">$projectbrief</div>
</td>
</tr>
</tbody>
</table>
</div>
<!--END TITLEAREA-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>$projectname: $title</title>
<script type="text/javascript" src="$relpath^jquery.js"></script>
<script type="text/javascript" src="$relpath^dynsections.js"></script>
$treeview
$search
<link href="$relpath^$stylesheet" rel="stylesheet" type="text/css" />
$extrastylesheet
</head>
<body>
<!-- do not remove this div, it is closed by doxygen! -->
<div id="top">
<!--BEGIN TITLEAREA-->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<!--BEGIN PROJECT_LOGO-->
<td id="projectlogo"><img alt="Logo" src="$relpath^$projectlogo"/></td>
<!--END PROJECT_LOGO-->
<td style="padding-left: 0.5em;">
<div id="projectname">$projectname&#160;<span id="projectnumber">$projectnumber</span> API</div>
<div id="projectbrief">$projectbrief</div>
</td>
</tr>
</tbody>
</table>
</div>
<!--END TITLEAREA-->

File diff suppressed because it is too large Load Diff

View File

@@ -1,213 +1,213 @@
// [GenDefs]
//
// The purpose of this script is to fetch all instructions' names into a single
// string. It prevents relocation that has to be done by linked to make all
// pointers the binary application/library uses valid. This approach decreases
// the final size of AsmJit binary.
var fs = require("fs");
// ----------------------------------------------------------------------------
// [Configuration]
// ----------------------------------------------------------------------------
var injectStartMarker = "// ${kInstData:Begin}\n"
var injectEndMarker = "// ${kInstData:End}\n"
// ----------------------------------------------------------------------------
// [Utilities]
// ----------------------------------------------------------------------------
var uppercaseFirst = function(s) {
if (!s)
return s;
return s[0].toUpperCase() + s.substr(1);
};
var inject = function(s, start, end, code) {
var iStart = s.indexOf(start);
var iEnd = s.indexOf(end);
if (iStart === -1)
throw new Error("Couldn't locate start mark.");
if (iEnd === -1)
throw new Error("Couldn't locate end mark.");
return s.substr(0, iStart + start.length) + code + s.substr(iEnd);
};
// ----------------------------------------------------------------------------
// [Database]
// ----------------------------------------------------------------------------
// FullIndex - Index of the name of the instruction in one big string (no
// prefix/suffix concept).
// PrefixIndex - Index to a prefix string.
// SuffixIndex - Index to a suffix string.
var Database = (function() {
var IndexedString = function() {
this.array = [];
this.index = 0;
this.map = {};
};
IndexedString.prototype.add = function(s) {
var index = this.map[s];
if (typeof index === "number")
return index;
index = this.index;
this.array.push(s);
this.index += s.length + 1;
this.map[s] = index;
return index;
};
IndexedString.prototype.get = function(s) {
return this.map[s];
};
IndexedString.prototype.format = function(indent) {
var s = "";
var array = this.array;
for (var i = 0; i < array.length; i++) {
s += indent + "\"" + array[i] + "\\0\"";
if (i === array.length - 1)
s += ";";
s += "\n";
}
return s;
};
IndexedString.prototype.getSize = function() {
return this.index;
};
var Database = function() {
this.map = {};
this.alphabetical = new Array(26);
this.fullString = new IndexedString();
};
Database.prototype.add = function(name, id) {
this.map[name] = {
id: id,
fullIndex: 0,
prefixIndex: 0,
hasV: 0
};
};
Database.prototype.index = function() {
var map = this.map;
var alphabetical = this.alphabetical;
for (var name in map) {
var inst = map[name];
inst.fullIndex = this.fullString.add(name);
var aIndex = name.charCodeAt(0) - 'a'.charCodeAt(0);
if (aIndex < 0 || aIndex >= 26)
throw new Error("Alphabetical index error");
if (alphabetical[aIndex] === undefined)
alphabetical[aIndex] = inst.id;
if (name.indexOf("v") === 0) {
inst.hasV = 1;
name = name.substr(1);
}
}
};
return Database;
})();
// ----------------------------------------------------------------------------
// [Generate]
// ----------------------------------------------------------------------------
var generate = function(fileName, arch) {
var oldData = fs.readFileSync(fileName, "utf8").replace(/\r\n/g, "\n");
var data = oldData;
var code = "";
var Arch = uppercaseFirst(arch);
// Create database.
var db = new Database();
var re = new RegExp("INST\\(([A-Za-z0-9_]+)\\s*,\\s*\\\"([A-Za-z0-9_ ]*)\\\"", "g");
while (m = re.exec(data)) {
var id = m[1];
var name = m[2];
db.add(name, id);
}
db.index();
console.log("Full size: " + db.fullString.getSize());
// Generate InstName[] string.
code += "const char _instName[] =\n";
for (var k in db.map) {
var inst = db.map[k];
code += " \"" + k + "\\0\"\n";
}
code = code.substr(code, code.length - 1) + ";\n\n";
// Generate AlphaIndex.
code += "enum kInstAlphaIndex {\n";
code += " kInstAlphaIndexFirst = 'a',\n";
code += " kInstAlphaIndexLast = 'z',\n";
code += " kInstAlphaIndexInvalid = 0xFFFF\n";
code += "};\n";
code += "\n";
// Generate NameIndex.
code += "static const uint16_t _instAlphaIndex[26] = {\n";
for (var i = 0; i < db.alphabetical.length; i++) {
var id = db.alphabetical[i];
code += " " + (id === undefined ? "0xFFFF" : id);
if (i !== db.alphabetical.length - 1)
code += ",";
code += "\n";
}
code += "};\n\n";
code += "enum kInstData_NameIndex {\n";
for (var k in db.map) {
var inst = db.map[k];
code += " " + inst.id + "_NameIndex = " + inst.fullIndex + ",\n";
}
code = code.substr(code, code.length - 2) + "\n};\n";
// Inject.
data = inject(data, injectStartMarker, injectEndMarker, code);
// Save only if modified.
if (data !== oldData)
fs.writeFileSync(fileName, data, "utf8");
};
// ----------------------------------------------------------------------------
// [Main]
// ----------------------------------------------------------------------------
var main = function(files) {
files.forEach(function(file) {
generate(file.name, file.arch);
});
};
main([
{
name: "../src/asmjit/x86/x86inst.cpp",
arch: "x86"
}
]);
// [GenDefs]
//
// The purpose of this script is to fetch all instructions' names into a single
// string. It prevents relocation that has to be done by linked to make all
// pointers the binary application/library uses valid. This approach decreases
// the final size of AsmJit binary.
var fs = require("fs");
// ----------------------------------------------------------------------------
// [Configuration]
// ----------------------------------------------------------------------------
var injectStartMarker = "// ${kInstData:Begin}\n"
var injectEndMarker = "// ${kInstData:End}\n"
// ----------------------------------------------------------------------------
// [Utilities]
// ----------------------------------------------------------------------------
var uppercaseFirst = function(s) {
if (!s)
return s;
return s[0].toUpperCase() + s.substr(1);
};
var inject = function(s, start, end, code) {
var iStart = s.indexOf(start);
var iEnd = s.indexOf(end);
if (iStart === -1)
throw new Error("Couldn't locate start mark.");
if (iEnd === -1)
throw new Error("Couldn't locate end mark.");
return s.substr(0, iStart + start.length) + code + s.substr(iEnd);
};
// ----------------------------------------------------------------------------
// [Database]
// ----------------------------------------------------------------------------
// FullIndex - Index of the name of the instruction in one big string (no
// prefix/suffix concept).
// PrefixIndex - Index to a prefix string.
// SuffixIndex - Index to a suffix string.
var Database = (function() {
var IndexedString = function() {
this.array = [];
this.index = 0;
this.map = {};
};
IndexedString.prototype.add = function(s) {
var index = this.map[s];
if (typeof index === "number")
return index;
index = this.index;
this.array.push(s);
this.index += s.length + 1;
this.map[s] = index;
return index;
};
IndexedString.prototype.get = function(s) {
return this.map[s];
};
IndexedString.prototype.format = function(indent) {
var s = "";
var array = this.array;
for (var i = 0; i < array.length; i++) {
s += indent + "\"" + array[i] + "\\0\"";
if (i === array.length - 1)
s += ";";
s += "\n";
}
return s;
};
IndexedString.prototype.getSize = function() {
return this.index;
};
var Database = function() {
this.map = {};
this.alphabetical = new Array(26);
this.fullString = new IndexedString();
};
Database.prototype.add = function(name, id) {
this.map[name] = {
id: id,
fullIndex: 0,
prefixIndex: 0,
hasV: 0
};
};
Database.prototype.index = function() {
var map = this.map;
var alphabetical = this.alphabetical;
for (var name in map) {
var inst = map[name];
inst.fullIndex = this.fullString.add(name);
var aIndex = name.charCodeAt(0) - 'a'.charCodeAt(0);
if (aIndex < 0 || aIndex >= 26)
throw new Error("Alphabetical index error");
if (alphabetical[aIndex] === undefined)
alphabetical[aIndex] = inst.id;
if (name.indexOf("v") === 0) {
inst.hasV = 1;
name = name.substr(1);
}
}
};
return Database;
})();
// ----------------------------------------------------------------------------
// [Generate]
// ----------------------------------------------------------------------------
var generate = function(fileName, arch) {
var oldData = fs.readFileSync(fileName, "utf8").replace(/\r\n/g, "\n");
var data = oldData;
var code = "";
var Arch = uppercaseFirst(arch);
// Create database.
var db = new Database();
var re = new RegExp("INST\\(([A-Za-z0-9_]+)\\s*,\\s*\\\"([A-Za-z0-9_ ]*)\\\"", "g");
while (m = re.exec(data)) {
var id = m[1];
var name = m[2];
db.add(name, id);
}
db.index();
console.log("Full size: " + db.fullString.getSize());
// Generate InstName[] string.
code += "const char _instName[] =\n";
for (var k in db.map) {
var inst = db.map[k];
code += " \"" + k + "\\0\"\n";
}
code = code.substr(code, code.length - 1) + ";\n\n";
// Generate AlphaIndex.
code += "enum kInstAlphaIndex {\n";
code += " kInstAlphaIndexFirst = 'a',\n";
code += " kInstAlphaIndexLast = 'z',\n";
code += " kInstAlphaIndexInvalid = 0xFFFF\n";
code += "};\n";
code += "\n";
// Generate NameIndex.
code += "static const uint16_t _instAlphaIndex[26] = {\n";
for (var i = 0; i < db.alphabetical.length; i++) {
var id = db.alphabetical[i];
code += " " + (id === undefined ? "0xFFFF" : id);
if (i !== db.alphabetical.length - 1)
code += ",";
code += "\n";
}
code += "};\n\n";
code += "enum kInstData_NameIndex {\n";
for (var k in db.map) {
var inst = db.map[k];
code += " " + inst.id + "_NameIndex = " + inst.fullIndex + ",\n";
}
code = code.substr(code, code.length - 2) + "\n};\n";
// Inject.
data = inject(data, injectStartMarker, injectEndMarker, code);
// Save only if modified.
if (data !== oldData)
fs.writeFileSync(fileName, data, "utf8");
};
// ----------------------------------------------------------------------------
// [Main]
// ----------------------------------------------------------------------------
var main = function(files) {
files.forEach(function(file) {
generate(file.name, file.arch);
});
};
main([
{
name: "../src/asmjit/x86/x86inst.cpp",
arch: "x86"
}
]);