Better way of detecting the file under test

This commit is contained in:
Matt Godbolt
2016-06-12 16:57:21 -05:00
parent 0d6df6a2dd
commit 7e50f2cfc4
3 changed files with 37 additions and 9 deletions
-2
View File
@@ -6,8 +6,6 @@ compiler.cl19.versionFlag=/?
compiler.cl19_32.name=x86 msvc 19 (32 bit)
compiler.cl19_32.exe=etc\scripts\cl19_x86.bat
compiler.cl19_32.versionFlag=/?
# Kludge; we use this filename in asm.js to detect when we're processing user-input code
compileFilename=GccExplorer.cpp
postProcess=
binaryHideFuncRe=^(_.*|(de)?register_tm_clones|call_gmon_start|frame_dummy)$
needsMulti=false
+31 -3
View File
@@ -216,6 +216,30 @@
}
});
function compareWindowsFilename(lhs, rhs) {
function tildeCompare(lhs, rhs) {
var lhsTilde = lhs.indexOf("~");
var rhsTilde = rhs.indexOf("~");
if (lhsTilde >= 0) {
lhs = lhs.substr(0, lhsTilde);
rhs = rhs.substr(0, lhsTilde);
}
if (rhsTilde >= 0) {
lhs = lhs.substr(0, rhsTilde);
rhs = rhs.substr(0, rhsTilde);
}
return lhs === rhs;
}
lhs = lhs.toLowerCase().split('\\');
rhs = rhs.toLowerCase().split('\\');
if (lhs.length != rhs.length) return false;
for (var i = 0; i < lhs.length; ++i) {
if (!tildeCompare(lhs[i], rhs[i])) return false;
}
return true;
}
var directive = /^\s*(\.|([_A-Z]+\b))/;
var labelDefinition = /^([a-zA-Z0-9$_.]+):/;
var commentOnly = /^\s*([#@;]|\/\/).*/;
@@ -223,8 +247,10 @@
var fileFind = /^; File\s+(.*)$/;
var inMain = false;
var sourceTag = /^;\s*([0-9]+)\s*:/;
var ignoreAll = /^include listing\.inc$/;
var ignoreAll = /^\s*include listing\.inc$/;
var source = null;
var titleFind = /^\s*TITLE\s*(.*)/;
var title = null;
var result = [];
function demangle(line) {
@@ -304,9 +330,11 @@
}
line = demangle(line);
if (title === null && !!(match = line.match(titleFind))) {
title = match[1];
}
if (!!(match = line.match(fileFind))) {
// NB relies on magic name from properties; TODO fix this (or at least share the name instead of repeating it here)
inMain = !!match[1].match(/\\GccExplorer.cpp$/);
inMain = compareWindowsFilename(match[1], title);
return;
}
if (!!(match = line.match(sourceTag))) {
+6 -4
View File
@@ -1,12 +1,14 @@
; Listing generated by Microsoft (R) Optimizing Compiler Version 19.00.23918.0
include listing.inc
TITLE C:\Users\ADMINI~1\AppData\Local\Temp\2\gcc-explorer-compiler116510-3076-1fwzpub.e7utsm7vi\example.cpp
.686P
.XMM
include listing.inc
.model flat
INCLUDELIB LIBCMT
INCLUDELIB OLDNAMES
; Function compile flags: /Odtp
; File c:\users\administrator\desktop\GccExplorer.cpp
; File c:\users\administrator\appdata\local\temp\2\gcc-explorer-compiler116510-3076-1fwzpub.e7utsm7vi\example.cpp
_TEXT SEGMENT
self_regex$ = 32
s$ = 72