mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 02:07:06 +00:00
Fixes to enable building dart:io implementation cleanly in mojo tree
+ make Observatory respect script line offsets (which Sky uses). R=iposva@google.com Review URL: https://codereview.chromium.org//1101083003 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45427 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
641ea327ec
commit
e23be8563a
|
@ -185,6 +185,7 @@
|
|||
'toolsets': ['host', 'target'],
|
||||
'include_dirs': [
|
||||
'..',
|
||||
'../../third_party',
|
||||
'../include',
|
||||
],
|
||||
'includes': [
|
||||
|
@ -282,6 +283,7 @@
|
|||
'toolsets': ['host', 'target'],
|
||||
'include_dirs': [
|
||||
'..',
|
||||
'../../third_party',
|
||||
],
|
||||
'includes': [
|
||||
'io_impl_sources.gypi',
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "bin/builtin.h"
|
||||
#include "bin/utils.h"
|
||||
|
||||
#include "../third_party/zlib/zlib.h"
|
||||
#include "zlib/zlib.h"
|
||||
|
||||
|
||||
namespace dart {
|
||||
|
|
|
@ -335,7 +335,7 @@ class ScriptInsetElement extends ObservatoryElement {
|
|||
void computeAnnotations() {
|
||||
_startLine = (startPos != null
|
||||
? script.tokenToLine(startPos)
|
||||
: 1);
|
||||
: 1 + script.lineOffset);
|
||||
_currentLine = (currentPos != null
|
||||
? script.tokenToLine(currentPos)
|
||||
: null);
|
||||
|
@ -344,7 +344,7 @@ class ScriptInsetElement extends ObservatoryElement {
|
|||
: null);
|
||||
_endLine = (endPos != null
|
||||
? script.tokenToLine(endPos)
|
||||
: script.lines.length);
|
||||
: script.lines.length + script.lineOffset);
|
||||
|
||||
annotations.clear();
|
||||
if (_currentLine != null) {
|
||||
|
@ -386,8 +386,9 @@ class ScriptInsetElement extends ObservatoryElement {
|
|||
annotationsCursor = 0;
|
||||
|
||||
int blankLineCount = 0;
|
||||
for (int i = (_startLine - 1); i <= (_endLine - 1); i++) {
|
||||
if (script.lines[i].isBlank) {
|
||||
for (int i = _startLine; i <= _endLine; i++) {
|
||||
var line = script.getLine(i);
|
||||
if (line.isBlank) {
|
||||
// Try to introduce elipses if there are 4 or more contiguous
|
||||
// blank lines.
|
||||
blankLineCount++;
|
||||
|
@ -398,17 +399,17 @@ class ScriptInsetElement extends ObservatoryElement {
|
|||
if (blankLineCount < 4) {
|
||||
// Too few blank lines for an elipsis.
|
||||
for (int j = firstBlank; j <= lastBlank; j++) {
|
||||
table.append(lineElement(script.lines[j]));
|
||||
table.append(lineElement(script.getLine(j)));
|
||||
}
|
||||
} else {
|
||||
// Add an elipsis for the skipped region.
|
||||
table.append(lineElement(script.lines[firstBlank]));
|
||||
table.append(lineElement(script.getLine(firstBlank)));
|
||||
table.append(lineElement(null));
|
||||
table.append(lineElement(script.lines[lastBlank]));
|
||||
table.append(lineElement(script.getLine(lastBlank)));
|
||||
}
|
||||
blankLineCount = 0;
|
||||
}
|
||||
table.append(lineElement(script.lines[i]));
|
||||
table.append(lineElement(line));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2175,6 +2175,8 @@ class Script extends ServiceObject with Coverage {
|
|||
@observable String kind;
|
||||
@observable int firstTokenPos;
|
||||
@observable int lastTokenPos;
|
||||
@observable int lineOffset;
|
||||
@observable int columnOffset;
|
||||
@observable Library library;
|
||||
bool get canCache => true;
|
||||
bool get immutable => true;
|
||||
|
@ -2186,7 +2188,7 @@ class Script extends ServiceObject with Coverage {
|
|||
|
||||
ScriptLine getLine(int line) {
|
||||
assert(line >= 1);
|
||||
return lines[line - 1];
|
||||
return lines[line - lineOffset - 1];
|
||||
}
|
||||
|
||||
/// This function maps a token position to a line number.
|
||||
|
@ -2207,6 +2209,8 @@ class Script extends ServiceObject with Coverage {
|
|||
if (mapIsRef) {
|
||||
return;
|
||||
}
|
||||
lineOffset = map['lineOffset'];
|
||||
columnOffset = map['columnOffset'];
|
||||
_parseTokenPosTable(map['tokenPosTable']);
|
||||
_processSource(map['source']);
|
||||
library = map['library'];
|
||||
|
@ -2292,7 +2296,7 @@ class Script extends ServiceObject with Coverage {
|
|||
lines.clear();
|
||||
Logger.root.info('Adding ${sourceLines.length} source lines for ${_url}');
|
||||
for (var i = 0; i < sourceLines.length; i++) {
|
||||
lines.add(new ScriptLine(this, i + 1, sourceLines[i]));
|
||||
lines.add(new ScriptLine(this, i + lineOffset + 1, sourceLines[i]));
|
||||
}
|
||||
for (var bpt in isolate.breakpoints.values) {
|
||||
if (bpt.script == this) {
|
||||
|
|
|
@ -297,12 +297,14 @@ struct CompileAssert {
|
|||
};
|
||||
// Macro to concatenate two tokens. The helper is need to proper expansion
|
||||
// in case an argument is a macro itself.
|
||||
#if !defined(COMPILE_ASSERT)
|
||||
#define COMPILE_ASSERT_JOIN(a, b) COMPILE_ASSERT_JOIN_HELPER(a, b)
|
||||
#define COMPILE_ASSERT_JOIN_HELPER(a, b) a##b
|
||||
#define COMPILE_ASSERT(expr) \
|
||||
DART_UNUSED typedef CompileAssert<(static_cast<bool>(expr))> \
|
||||
COMPILE_ASSERT_JOIN(CompileAssertTypeDef, __LINE__)[static_cast<bool>(expr) \
|
||||
? 1 : -1]
|
||||
#endif // !defined(COMPILE_ASSERT)
|
||||
|
||||
#if defined(TESTING)
|
||||
|
||||
|
|
|
@ -96,6 +96,8 @@
|
|||
#error Automatic target os detection failed.
|
||||
#endif
|
||||
|
||||
namespace dart {
|
||||
|
||||
struct simd128_value_t {
|
||||
union {
|
||||
int32_t int_storage[4];
|
||||
|
@ -377,27 +379,30 @@ inline double MicrosecondsToMilliseconds(int64_t micros) {
|
|||
|
||||
// A macro to disallow the copy constructor and operator= functions.
|
||||
// This should be used in the private: declarations for a class.
|
||||
#if !defined(DISALLOW_COPY_AND_ASSIGN)
|
||||
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
||||
private: \
|
||||
TypeName(const TypeName&); \
|
||||
void operator=(const TypeName&)
|
||||
|
||||
#endif // !defined(DISALLOW_COPY_AND_ASSIGN)
|
||||
|
||||
// A macro to disallow all the implicit constructors, namely the default
|
||||
// constructor, copy constructor and operator= functions. This should be
|
||||
// used in the private: declarations for a class that wants to prevent
|
||||
// anyone from instantiating it. This is especially useful for classes
|
||||
// containing only static methods.
|
||||
#if !defined(DISALLOW_IMPLICIT_CONSTRUCTORS)
|
||||
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
|
||||
private: \
|
||||
TypeName(); \
|
||||
DISALLOW_COPY_AND_ASSIGN(TypeName)
|
||||
|
||||
#endif // !defined(DISALLOW_IMPLICIT_CONSTRUCTORS)
|
||||
|
||||
// Macro to disallow allocation in the C++ heap. This should be used
|
||||
// in the private section for a class. Don't use UNREACHABLE here to
|
||||
// avoid circular dependencies between platform/globals.h and
|
||||
// platform/assert.h.
|
||||
#if !defined(DISALLOW_ALLOCATION)
|
||||
#define DISALLOW_ALLOCATION() \
|
||||
public: \
|
||||
void operator delete(void* pointer) { \
|
||||
|
@ -406,7 +411,7 @@ public: \
|
|||
} \
|
||||
private: \
|
||||
void* operator new(size_t size);
|
||||
|
||||
#endif // !defined(DISALLOW_ALLOCATION)
|
||||
|
||||
// The USE(x) template is used to silence C++ compiler warnings issued
|
||||
// for unused variables.
|
||||
|
@ -543,4 +548,6 @@ static inline T ReadUnaligned(const T* ptr) {
|
|||
#define PRINTF_ATTRIBUTE(string_index, first_to_check)
|
||||
#endif
|
||||
|
||||
} // namespace dart
|
||||
|
||||
#endif // PLATFORM_GLOBALS_H_
|
||||
|
|
|
@ -8552,6 +8552,8 @@ void Script::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
}
|
||||
jsobj.AddProperty("library", lib);
|
||||
const String& source = String::Handle(Source());
|
||||
jsobj.AddProperty("lineOffset", line_offset());
|
||||
jsobj.AddProperty("columnOffset", col_offset());
|
||||
jsobj.AddPropertyStr("source", source);
|
||||
|
||||
// Print the line number table
|
||||
|
|
Loading…
Reference in a new issue