| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/object.h" | 5 #include "vm/object.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
| (...skipping 7797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7808 } | 7808 } |
| 7809 | 7809 |
| 7810 | 7810 |
| 7811 RawString* Script::GenerateSource() const { | 7811 RawString* Script::GenerateSource() const { |
| 7812 const TokenStream& token_stream = TokenStream::Handle(tokens()); | 7812 const TokenStream& token_stream = TokenStream::Handle(tokens()); |
| 7813 return token_stream.GenerateSource(); | 7813 return token_stream.GenerateSource(); |
| 7814 } | 7814 } |
| 7815 | 7815 |
| 7816 | 7816 |
| 7817 RawGrowableObjectArray* Script::GenerateLineNumberArray() const { | 7817 RawGrowableObjectArray* Script::GenerateLineNumberArray() const { |
| 7818 Isolate* isolate = Isolate::Current(); |
| 7818 const GrowableObjectArray& info = | 7819 const GrowableObjectArray& info = |
| 7819 GrowableObjectArray::Handle(GrowableObjectArray::New()); | 7820 GrowableObjectArray::Handle(isolate, GrowableObjectArray::New()); |
| 7820 const String& source = String::Handle(Source()); | 7821 const String& source = String::Handle(isolate, Source()); |
| 7821 const String& key = Symbols::Empty(); | 7822 const String& key = Symbols::Empty(); |
| 7822 const Object& line_separator = Object::Handle(); | 7823 const Object& line_separator = Object::Handle(isolate); |
| 7823 const TokenStream& tkns = TokenStream::Handle(tokens()); | 7824 const TokenStream& tkns = TokenStream::Handle(isolate, tokens()); |
| 7825 Smi& value = Smi::Handle(isolate); |
| 7826 String& tokenValue = String::Handle(isolate); |
| 7824 ASSERT(!tkns.IsNull()); | 7827 ASSERT(!tkns.IsNull()); |
| 7825 TokenStream::Iterator tkit(tkns, 0, TokenStream::Iterator::kAllTokens); | 7828 TokenStream::Iterator tkit(tkns, 0, TokenStream::Iterator::kAllTokens); |
| 7826 int current_line = -1; | 7829 int current_line = -1; |
| 7827 Scanner s(source, key); | 7830 Scanner s(source, key); |
| 7828 s.Scan(); | 7831 s.Scan(); |
| 7829 bool skippedNewline = false; | 7832 bool skippedNewline = false; |
| 7830 while (tkit.CurrentTokenKind() != Token::kEOS) { | 7833 while (tkit.CurrentTokenKind() != Token::kEOS) { |
| 7831 if (tkit.CurrentTokenKind() == Token::kNEWLINE) { | 7834 if (tkit.CurrentTokenKind() == Token::kNEWLINE) { |
| 7832 // Skip newlines from the token stream. | 7835 // Skip newlines from the token stream. |
| 7833 skippedNewline = true; | 7836 skippedNewline = true; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 7851 // 13 string('') interpol_var(foo) string('\n') | 7854 // 13 string('') interpol_var(foo) string('\n') |
| 7852 // 14 | 7855 // 14 |
| 7853 // | 7856 // |
| 7854 // In order to keep the token iterator and the scanner in sync, | 7857 // In order to keep the token iterator and the scanner in sync, |
| 7855 // we need to skip the extra empty string before the | 7858 // we need to skip the extra empty string before the |
| 7856 // interpolation. | 7859 // interpolation. |
| 7857 if (skippedNewline && | 7860 if (skippedNewline && |
| 7858 (s.current_token().kind == Token::kINTERPOL_VAR || | 7861 (s.current_token().kind == Token::kINTERPOL_VAR || |
| 7859 s.current_token().kind == Token::kINTERPOL_START) && | 7862 s.current_token().kind == Token::kINTERPOL_START) && |
| 7860 tkit.CurrentTokenKind() == Token::kSTRING) { | 7863 tkit.CurrentTokenKind() == Token::kSTRING) { |
| 7861 const String& tokenValue = String::Handle(tkit.CurrentLiteral()); | 7864 tokenValue = tkit.CurrentLiteral(); |
| 7862 if (tokenValue.Length() == 0) { | 7865 if (tokenValue.Length() == 0) { |
| 7863 tkit.Advance(); | 7866 tkit.Advance(); |
| 7864 } | 7867 } |
| 7865 } | 7868 } |
| 7866 } | 7869 } |
| 7867 skippedNewline = false; | 7870 skippedNewline = false; |
| 7868 ASSERT(s.current_token().kind == tkit.CurrentTokenKind()); | 7871 ASSERT(s.current_token().kind == tkit.CurrentTokenKind()); |
| 7869 int token_line = s.current_token().position.line; | 7872 int token_line = s.current_token().position.line; |
| 7870 if (token_line != current_line) { | 7873 if (token_line != current_line) { |
| 7871 // emit line | 7874 // emit line |
| 7872 info.Add(line_separator); | 7875 info.Add(line_separator); |
| 7873 info.Add(Smi::Handle(Smi::New(token_line + line_offset()))); | 7876 value = Smi::New(token_line + line_offset()); |
| 7877 info.Add(value); |
| 7874 current_line = token_line; | 7878 current_line = token_line; |
| 7875 } | 7879 } |
| 7876 // TODO(hausner): Could optimize here by not reporting tokens | 7880 // TODO(hausner): Could optimize here by not reporting tokens |
| 7877 // that will never be a location used by the debugger, e.g. | 7881 // that will never be a location used by the debugger, e.g. |
| 7878 // braces, semicolons, most keywords etc. | 7882 // braces, semicolons, most keywords etc. |
| 7879 info.Add(Smi::Handle(Smi::New(tkit.CurrentPosition()))); | 7883 value = Smi::New(tkit.CurrentPosition()); |
| 7884 info.Add(value); |
| 7880 int column = s.current_token().position.column; | 7885 int column = s.current_token().position.column; |
| 7881 // On the first line of the script we must add the column offset. | 7886 // On the first line of the script we must add the column offset. |
| 7882 if (token_line == 1) { | 7887 if (token_line == 1) { |
| 7883 column += col_offset(); | 7888 column += col_offset(); |
| 7884 } | 7889 } |
| 7885 info.Add(Smi::Handle(Smi::New(column))); | 7890 value = Smi::New(column); |
| 7891 info.Add(value); |
| 7886 tkit.Advance(); | 7892 tkit.Advance(); |
| 7887 s.Scan(); | 7893 s.Scan(); |
| 7888 } | 7894 } |
| 7889 return info.raw(); | 7895 return info.raw(); |
| 7890 } | 7896 } |
| 7891 | 7897 |
| 7892 | 7898 |
| 7893 const char* Script::GetKindAsCString() const { | 7899 const char* Script::GetKindAsCString() const { |
| 7894 switch (kind()) { | 7900 switch (kind()) { |
| 7895 case RawScript::kScriptTag: | 7901 case RawScript::kScriptTag: |
| (...skipping 11112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19008 return tag_label.ToCString(); | 19014 return tag_label.ToCString(); |
| 19009 } | 19015 } |
| 19010 | 19016 |
| 19011 | 19017 |
| 19012 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 19018 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 19013 Instance::PrintJSONImpl(stream, ref); | 19019 Instance::PrintJSONImpl(stream, ref); |
| 19014 } | 19020 } |
| 19015 | 19021 |
| 19016 | 19022 |
| 19017 } // namespace dart | 19023 } // namespace dart |
| OLD | NEW |