Index: runtime/vm/kernel_binary_flowgraph.h |
diff --git a/runtime/vm/kernel_binary_flowgraph.h b/runtime/vm/kernel_binary_flowgraph.h |
index 5d07c19ff012cd6808a44aaf7a465e96e33d3aba..6b8c707c7a965b702fb75464ce55e4beeaa4244b 100644 |
--- a/runtime/vm/kernel_binary_flowgraph.h |
+++ b/runtime/vm/kernel_binary_flowgraph.h |
@@ -51,10 +51,8 @@ class StreamingDartTypeTranslator { |
class TypeParameterScope { |
public: |
TypeParameterScope(StreamingDartTypeTranslator* translator, |
- intptr_t parameters_offset, |
intptr_t parameters_count) |
- : parameters_offset_(parameters_offset), |
- parameters_count_(parameters_count), |
+ : parameters_count_(parameters_count), |
Kevin Millikin (Google)
2017/08/09 12:08:51
parameter_count_
jensj
2017/08/10 07:37:34
Done.
|
outer_(translator->type_parameter_scope_), |
translator_(translator) { |
summed_outer_parameters_count_ = 0; |
@@ -67,14 +65,12 @@ class StreamingDartTypeTranslator { |
~TypeParameterScope() { translator_->type_parameter_scope_ = outer_; } |
TypeParameterScope* outer() const { return outer_; } |
- intptr_t parameters_offset() const { return parameters_offset_; } |
intptr_t parameters_count() const { return parameters_count_; } |
intptr_t summed_outer_parameters_count() const { |
return summed_outer_parameters_count_; |
} |
private: |
- intptr_t parameters_offset_; |
intptr_t parameters_count_; |
intptr_t summed_outer_parameters_count_; |
TypeParameterScope* outer_; |
@@ -100,9 +96,8 @@ class StreamingDartTypeTranslator { |
class StreamingScopeBuilder { |
public: |
StreamingScopeBuilder(ParsedFunction* parsed_function, |
- intptr_t kernel_offset, |
- const uint8_t* buffer, |
- intptr_t buffer_length); |
+ intptr_t relative_kernel_offset, |
+ const TypedData& body); |
virtual ~StreamingScopeBuilder(); |
@@ -160,7 +155,7 @@ class StreamingScopeBuilder { |
// Record an assignment or reference to a variable. If the occurrence is |
// in a nested function, ensure that the variable is handled properly as a |
// captured variable. |
- void LookupVariable(intptr_t declaration_binary_offest); |
+ void LookupVariable(intptr_t declaration_binary_offset); |
const dart::String& GenerateName(const char* prefix, intptr_t suffix); |
@@ -187,7 +182,7 @@ class StreamingScopeBuilder { |
ScopeBuildingResult* result_; |
ParsedFunction* parsed_function_; |
- intptr_t kernel_offset_; |
+ intptr_t relative_kernel_offset_; |
ActiveClass active_class_; |
@@ -308,14 +303,15 @@ class FunctionNodeHelper; |
class StreamingFlowGraphBuilder { |
public: |
StreamingFlowGraphBuilder(FlowGraphBuilder* flow_graph_builder, |
- const uint8_t* buffer, |
- intptr_t buffer_length) |
+ intptr_t relative_kernel_offset, |
+ const TypedData& body) |
: flow_graph_builder_(flow_graph_builder), |
translation_helper_(flow_graph_builder->translation_helper_), |
zone_(flow_graph_builder->zone_), |
- reader_(new Reader(buffer, buffer_length)), |
+ reader_(new Reader(body)), |
constant_evaluator_(this), |
type_translator_(this, /* finalize= */ true), |
+ relative_kernel_offset_(relative_kernel_offset), |
current_script_id_(-1), |
record_for_script_id_(-1), |
record_token_positions_into_(NULL), |
@@ -331,6 +327,23 @@ class StreamingFlowGraphBuilder { |
reader_(new Reader(buffer, buffer_length)), |
constant_evaluator_(this), |
type_translator_(this, /* finalize= */ true), |
+ relative_kernel_offset_(0), |
+ current_script_id_(-1), |
+ record_for_script_id_(-1), |
+ record_token_positions_into_(NULL), |
+ record_yield_positions_into_(NULL) {} |
+ |
+ StreamingFlowGraphBuilder(TranslationHelper* translation_helper, |
+ Zone* zone, |
+ intptr_t relative_kernel_offset, |
+ const TypedData& body) |
+ : flow_graph_builder_(NULL), |
+ translation_helper_(*translation_helper), |
+ zone_(zone), |
+ reader_(new Reader(body)), |
+ constant_evaluator_(this), |
+ type_translator_(this, /* finalize= */ true), |
+ relative_kernel_offset_(relative_kernel_offset), |
current_script_id_(-1), |
record_for_script_id_(-1), |
record_token_positions_into_(NULL), |
@@ -345,6 +358,7 @@ class StreamingFlowGraphBuilder { |
RawObject* EvaluateMetadata(intptr_t kernel_offset); |
void CollectTokenPositionsFor( |
intptr_t script_index, |
+ intptr_t initial_script_index, |
GrowableArray<intptr_t>* record_token_positions_in, |
GrowableArray<intptr_t>* record_yield_positions_in); |
intptr_t SourceTableSize(); |
@@ -357,22 +371,18 @@ class StreamingFlowGraphBuilder { |
const Function& function, |
Function* outermost_function); |
- /** |
- * Will return kernel offset for parent class if reading a constructor. |
- * Will otherwise return -1. |
- */ |
- intptr_t ReadUntilFunctionNode(); |
- StringIndex GetNameFromVariableDeclaration(intptr_t kernel_offset); |
+ void ReadUntilFunctionNode(); |
+ StringIndex GetNameFromVariableDeclaration(intptr_t kernel_offset, |
+ const Function& function); |
FlowGraph* BuildGraphOfStaticFieldInitializer(); |
FlowGraph* BuildGraphOfFieldAccessor(LocalVariable* setter_value); |
void SetupDefaultParameterValues(); |
Fragment BuildFieldInitializer(NameIndex canonical_name); |
- Fragment BuildInitializers(intptr_t constructor_class_parent_offset); |
+ Fragment BuildInitializers(const Class& parent_class); |
FlowGraph* BuildGraphOfImplicitClosureFunction(const Function& function); |
FlowGraph* BuildGraphOfConvertedClosureFunction(const Function& function); |
- FlowGraph* BuildGraphOfFunction( |
- intptr_t constructor_class_parent_offset = -1); |
+ FlowGraph* BuildGraphOfFunction(bool constructor); |
Fragment BuildExpression(TokenPosition* position = NULL); |
Fragment BuildStatement(); |
@@ -618,10 +628,8 @@ class StreamingFlowGraphBuilder { |
Fragment BuildYieldStatement(); |
Fragment BuildVariableDeclaration(); |
Fragment BuildFunctionDeclaration(); |
- Fragment BuildFunctionNode(intptr_t parent_kernel_offset, |
- TokenPosition parent_position, |
- bool declaration, |
- intptr_t variable_offeset); |
+ Fragment BuildFunctionNode(TokenPosition parent_position, |
+ StringIndex name_index); |
void SetupFunctionParameters(const dart::Class& klass, |
const dart::Function& function, |
bool is_method, |
@@ -634,6 +642,7 @@ class StreamingFlowGraphBuilder { |
Reader* reader_; |
StreamingConstantEvaluator constant_evaluator_; |
StreamingDartTypeTranslator type_translator_; |
+ intptr_t relative_kernel_offset_; |
intptr_t current_script_id_; |
intptr_t record_for_script_id_; |
GrowableArray<intptr_t>* record_token_positions_into_; |
@@ -855,7 +864,6 @@ class FieldHelper { |
kPosition, |
kEndPosition, |
kFlags, |
- kParentClassBinaryOffset, |
kName, |
kSourceUriIndex, |
kDocumentationCommentIndex, |
@@ -905,10 +913,6 @@ class FieldHelper { |
case kFlags: |
flags_ = builder_->ReadFlags(); // read flags. |
if (++next_read_ == field) return; |
- case kParentClassBinaryOffset: |
- parent_class_binary_offset_ = |
- builder_->ReadUInt(); // read parent class binary offset. |
- if (++next_read_ == field) return; |
case kName: |
builder_->SkipName(); // read name. |
if (++next_read_ == field) return; |
@@ -979,7 +983,6 @@ class FieldHelper { |
TokenPosition position_; |
TokenPosition end_position_; |
word flags_; |
- intptr_t parent_class_binary_offset_; |
intptr_t source_uri_index_; |
intptr_t annotation_count_; |
@@ -1008,7 +1011,6 @@ class ProcedureHelper { |
kEndPosition, |
kKind, |
kFlags, |
- kParentClassBinaryOffset, |
kName, |
kSourceUriIndex, |
kDocumentationCommentIndex, |
@@ -1053,10 +1055,6 @@ class ProcedureHelper { |
case kFlags: |
flags_ = builder_->ReadFlags(); // read flags. |
if (++next_read_ == field) return; |
- case kParentClassBinaryOffset: |
- parent_class_binary_offset_ = |
- builder_->ReadUInt(); // read parent class binary offset. |
- if (++next_read_ == field) return; |
case kName: |
builder_->SkipName(); // read name. |
if (++next_read_ == field) return; |
@@ -1109,7 +1107,6 @@ class ProcedureHelper { |
TokenPosition end_position_; |
Procedure::ProcedureKind kind_; |
word flags_; |
- intptr_t parent_class_binary_offset_; |
intptr_t source_uri_index_; |
intptr_t annotation_count_; |
@@ -1133,7 +1130,6 @@ class ConstructorHelper { |
kPosition, |
kEndPosition, |
kFlags, |
- kParentClassBinaryOffset, |
kName, |
kDocumentationCommentIndex, |
kAnnotations, |
@@ -1174,10 +1170,6 @@ class ConstructorHelper { |
case kFlags: |
flags_ = builder_->ReadFlags(); // read flags. |
if (++next_read_ == field) return; |
- case kParentClassBinaryOffset: |
- parent_class_binary_offset_ = |
- builder_->ReadUInt(); // read parent class binary offset. |
- if (++next_read_ == field) return; |
case kName: |
builder_->SkipName(); // read name. |
if (++next_read_ == field) return; |
@@ -1246,7 +1238,6 @@ class ConstructorHelper { |
TokenPosition position_; |
TokenPosition end_position_; |
word flags_; |
- intptr_t parent_class_binary_offset_; |
intptr_t annotation_count_; |
private: |
@@ -1527,19 +1518,49 @@ class LibraryHelper { |
class AlternativeReadingScope { |
public: |
AlternativeReadingScope(Reader* reader, intptr_t new_position) |
- : reader_(reader), saved_offset_(reader_->offset()) { |
+ : reader_(reader), |
+ saved_size_(reader_->size()), |
+ saved_raw_buffer_(reader_->raw_buffer()), |
+ saved_typed_data_(reader_->typed_data()), |
+ saved_offset_(reader_->offset()) { |
reader_->set_offset(new_position); |
} |
- explicit AlternativeReadingScope(Reader* reader) |
- : reader_(reader), saved_offset_(reader_->offset()) {} |
+ AlternativeReadingScope(Reader* reader, |
+ const TypedData* new_typed_data, |
+ intptr_t new_position) |
+ : reader_(reader), |
+ saved_size_(reader_->size()), |
+ saved_raw_buffer_(reader_->raw_buffer()), |
+ saved_typed_data_(reader_->typed_data()), |
+ saved_offset_(reader_->offset()) { |
+ reader_->set_raw_buffer(NULL); |
+ reader_->set_typed_data(new_typed_data); |
+ reader_->set_size(new_typed_data->Length()); |
+ reader_->set_offset(new_position); |
+ } |
- ~AlternativeReadingScope() { reader_->set_offset(saved_offset_); } |
+ explicit AlternativeReadingScope(Reader* reader) |
+ : reader_(reader), |
+ saved_size_(reader_->size()), |
+ saved_raw_buffer_(reader_->raw_buffer()), |
+ saved_typed_data_(reader_->typed_data()), |
+ saved_offset_(reader_->offset()) {} |
+ |
+ ~AlternativeReadingScope() { |
+ reader_->set_raw_buffer(saved_raw_buffer_); |
+ reader_->set_typed_data(saved_typed_data_); |
+ reader_->set_size(saved_size_); |
+ reader_->set_offset(saved_offset_); |
+ } |
intptr_t saved_offset() { return saved_offset_; } |
private: |
Reader* reader_; |
+ intptr_t saved_size_; |
+ const uint8_t* saved_raw_buffer_; |
+ const TypedData* saved_typed_data_; |
intptr_t saved_offset_; |
}; |