Changeset 121871 in webkit for trunk/Source/JavaScriptCore/interpreter/Interpreter.h
- Timestamp:
- Jul 4, 2012, 2:36:52 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/interpreter/Interpreter.h
r121393 r121871 1 1 /* 2 2 * Copyright (C) 2008 Apple Inc. All rights reserved. 3 * Copyright (C) 2012 Research In Motion Limited. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 40 41 41 42 #include <wtf/HashMap.h> 43 #include <wtf/text/StringBuilder.h> 42 44 43 45 namespace JSC { … … 81 83 UString toString(CallFrame* callFrame) const 82 84 { 83 bool hasSourceURLInfo = !sourceURL.isNull() && !sourceURL.isEmpty(); 84 bool hasLineInfo = line > -1; 85 StringBuilder traceBuild; 86 String functionName = friendlyFunctionName(callFrame); 87 String sourceURL = friendlySourceURL(); 88 traceBuild.append(functionName); 89 if (!sourceURL.isEmpty()) { 90 if (!functionName.isEmpty()) 91 traceBuild.append('@'); 92 traceBuild.append(sourceURL); 93 if (line > -1) { 94 traceBuild.append(':'); 95 traceBuild.append(String::number(line)); 96 } 97 } 98 return traceBuild.toString().impl(); 99 } 100 String friendlySourceURL() const 101 { 102 String traceLine; 103 104 switch (codeType) { 105 case StackFrameEvalCode: 106 case StackFrameFunctionCode: 107 case StackFrameGlobalCode: 108 if (!sourceURL.isEmpty()) 109 traceLine = sourceURL.impl(); 110 break; 111 case StackFrameNativeCode: 112 traceLine = "[native code]"; 113 break; 114 } 115 return traceLine.isNull() ? emptyString() : traceLine; 116 } 117 String friendlyFunctionName(CallFrame* callFrame) const 118 { 85 119 String traceLine; 86 120 JSObject* stackFrameCallee = callee.get(); … … 88 122 switch (codeType) { 89 123 case StackFrameEvalCode: 90 if (hasSourceURLInfo) { 91 traceLine = hasLineInfo ? String::format("eval code@%s:%d", sourceURL.ascii().data(), line) 92 : String::format("eval code@%s", sourceURL.ascii().data()); 93 } else 94 traceLine = String::format("eval code"); 95 break; 96 case StackFrameNativeCode: { 97 if (callee) { 98 UString functionName = getCalculatedDisplayName(callFrame, stackFrameCallee); 99 traceLine = String::format("%s@[native code]", functionName.ascii().data()); 100 } else 101 traceLine = "[native code]"; 124 traceLine = "eval code"; 125 break; 126 case StackFrameNativeCode: 127 if (callee) 128 traceLine = getCalculatedDisplayName(callFrame, stackFrameCallee).impl(); 129 break; 130 case StackFrameFunctionCode: 131 traceLine = getCalculatedDisplayName(callFrame, stackFrameCallee).impl(); 132 break; 133 case StackFrameGlobalCode: 134 traceLine = "global code"; 102 135 break; 103 136 } 104 case StackFrameFunctionCode: { 105 UString functionName = getCalculatedDisplayName(callFrame, stackFrameCallee); 106 if (hasSourceURLInfo) { 107 traceLine = hasLineInfo ? String::format("%s@%s:%d", functionName.ascii().data(), sourceURL.ascii().data(), line) 108 : String::format("%s@%s", functionName.ascii().data(), sourceURL.ascii().data()); 109 } else 110 traceLine = String::format("%s\n", functionName.ascii().data()); 111 break; 112 } 113 case StackFrameGlobalCode: 114 if (hasSourceURLInfo) { 115 traceLine = hasLineInfo ? String::format("global code@%s:%d", sourceURL.ascii().data(), line) 116 : String::format("global code@%s", sourceURL.ascii().data()); 117 } else 118 traceLine = String::format("global code"); 119 120 } 121 return traceLine.impl(); 137 return traceLine.isNull() ? emptyString() : traceLine; 138 } 139 unsigned friendlyLineNumber() const 140 { 141 return line > -1 ? line : 0; 122 142 } 123 143 };
Note:
See TracChangeset
for help on using the changeset viewer.