diff options
Diffstat (limited to 'src/parseTools.js')
-rw-r--r-- | src/parseTools.js | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/parseTools.js b/src/parseTools.js index 6a10176c..c70b511a 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -167,7 +167,15 @@ function isFunctionDef(token, out) { return !fail; } + +function isPossiblyFunctionType(type) { + // A quick but unreliable way to see if something is a function type. Yes is just 'maybe', no is definite. + var len = type.length; + return type[len-2] == ')' && type[len-1] == '*'; +} + function isFunctionType(type, out) { + if (!isPossiblyFunctionType(type)) return false; type = type.replace(/"[^"]+"/g, '".."'); var parts; // hackish, but quick splitting of function def parts. this must be fast as it happens a lot @@ -184,14 +192,12 @@ function isFunctionType(type, out) { return isType(parts[0]) && isFunctionDef({ text: text, item: tokenize(text.substr(1, text.length-2), true) }, out); } -function isType(type) { // TODO! - return isVoidType(type) || Runtime.isNumberType(type) || isStructType(type) || isPointerType(type) || isFunctionType(type); -} - -function isPossiblyFunctionType(type) { - // A quick but unreliable way to see if something is a function type. Yes is just 'maybe', no is definite. - var suffix = ')*'; - return type.substr(-suffix.length) == suffix; +var isTypeCache = {}; // quite hot, optimize as much as possible +function isType(type) { + if (type in isTypeCache) return isTypeCache[type]; + var ret = isPointerType(type) || isVoidType(type) || Runtime.isNumberType(type) || isStructType(type) || isFunctionType(type); + isTypeCache[type] = ret; + return ret; } function isVarArgsFunctionType(type) { @@ -875,7 +881,6 @@ function correctRoundings() { } function checkSpecificSafeHeap() { - assert(!(SAFE_HEAP >= 2 && !Debugging.on), 'Need debugging for line-specific checks'); if (!Framework.currItem) return false; return (SAFE_HEAP === 2 && Debugging.getIdentifier() in SAFE_HEAP_LINES) || (SAFE_HEAP === 3 && !(Debugging.getIdentifier() in SAFE_HEAP_LINES)); @@ -1997,9 +2002,7 @@ function parseBlockAddress(segment) { } function finalizeBlockAddress(param) { - assert(param.func in Functions.blockAddresses); - assert(param.label in Functions.blockAddresses[param.func]); - return Functions.blockAddresses[param.func][param.label]; + return '{{{ BA_' + param.func + '|' + param.label + ' }}}'; // something python will replace later } function stripCorrections(param) { |