Commit 7721e484 authored by peter.rybin@gmail.com's avatar peter.rybin@gmail.com

Format

Review URL: http://codereview.chromium.org/1589036

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4420 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 0e9149c5
......@@ -31,24 +31,22 @@
// A LiveEdit namespace is declared inside a single function constructor.
Debug.LiveEdit = new function() {
// TODO(LiveEdit): restore indentation below
// Changes script text and recompiles all relevant functions if possible.
// The change is always a substring (change_pos, change_pos + change_len)
// being replaced with a completely different string new_str.
//
// Only one function will have its Code changed in result of this function.
// All nested functions (should they have any instances at the moment) are left
// unchanged and re-linked to a newly created script instance representing old
// version of the source. (Generally speaking,
// during the change all nested functions are erased and completely different
// set of nested functions are introduced.) All other functions just have
// their positions updated.
//
// @param {Script} script that is being changed
// @param {Array} change_log a list that collects engineer-readable description
// of what happened.
function ApplyPatch(script, change_pos, change_len, new_str,
// Changes script text and recompiles all relevant functions if possible.
// The change is always a substring (change_pos, change_pos + change_len)
// being replaced with a completely different string new_str.
//
// Only one function will have its Code changed in result of this function.
// All nested functions (should they have any instances at the moment) are left
// unchanged and re-linked to a newly created script instance representing old
// version of the source. (Generally speaking,
// during the change all nested functions are erased and completely different
// set of nested functions are introduced.) All other functions just have
// their positions updated.
//
// @param {Script} script that is being changed
// @param {Array} change_log a list that collects engineer-readable description
// of what happened.
function ApplyPatch(script, change_pos, change_len, new_str,
change_log) {
// Fully compiles source string as a script. Returns Array of
......@@ -319,11 +317,11 @@ function ApplyPatch(script, change_pos, change_len, new_str,
for (var i = function_being_patched + 1; i < old_next_sibling; i++) {
LinkToOldScript(FindFunctionInfo(i), old_script);
}
}
// Function is public.
this.ApplyPatch = ApplyPatch;
}
// Function is public.
this.ApplyPatch = ApplyPatch;
function Assert(condition, message) {
function Assert(condition, message) {
if (!condition) {
if (message) {
throw "Assert " + message;
......@@ -331,11 +329,11 @@ function Assert(condition, message) {
throw "Assert";
}
}
}
}
// An object describing function compilation details. Its index fields
// apply to indexes inside array that stores these objects.
function FunctionCompileInfo(raw_array) {
// An object describing function compilation details. Its index fields
// apply to indexes inside array that stores these objects.
function FunctionCompileInfo(raw_array) {
this.function_name = raw_array[0];
this.start_position = raw_array[1];
this.end_position = raw_array[2];
......@@ -345,25 +343,25 @@ function FunctionCompileInfo(raw_array) {
this.outer_index = raw_array[6];
this.next_sibling_index = null;
this.raw_array = raw_array;
}
}
function SharedInfoWrapper(raw_array) {
function SharedInfoWrapper(raw_array) {
this.function_name = raw_array[0];
this.start_position = raw_array[1];
this.end_position = raw_array[2];
this.info = raw_array[3];
this.raw_array = raw_array;
}
}
// Adds a suffix to script name to mark that it is old version.
function CreateNameForOldScript(script) {
// Adds a suffix to script name to mark that it is old version.
function CreateNameForOldScript(script) {
// TODO(635): try better than this; support several changes.
return script.name + " (old)";
}
}
// Compares a function interface old and new version, whether it
// changed or not.
function CompareFunctionExpectations(function_info1, function_info2) {
// Compares a function interface old and new version, whether it
// changed or not.
function CompareFunctionExpectations(function_info1, function_info2) {
// Check that function has the same number of parameters (there may exist
// an adapter, that won't survive function parameter number change).
if (function_info1.param_num != function_info2.param_num) {
......@@ -383,15 +381,15 @@ function CompareFunctionExpectations(function_info1, function_info2) {
// Check that outer scope structure is not changed. Otherwise the function
// will not properly work with existing scopes.
return scope_info1.toString() == scope_info2.toString();
}
}
// Minifier forward declaration.
var FunctionPatchabilityStatus;
// Minifier forward declaration.
var FunctionPatchabilityStatus;
// For array of wrapped shared function infos checks that none of them
// have activations on stack (of any thread). Throws a Failure exception
// if this proves to be false.
function CheckStackActivations(shared_wrapper_list, change_log) {
// For array of wrapped shared function infos checks that none of them
// have activations on stack (of any thread). Throws a Failure exception
// if this proves to be false.
function CheckStackActivations(shared_wrapper_list, change_log) {
var shared_list = new Array();
for (var i = 0; i < shared_wrapper_list.length; i++) {
shared_list[i] = shared_wrapper_list[i].info;
......@@ -426,47 +424,45 @@ function CheckStackActivations(shared_wrapper_list, change_log) {
change_log.push( { functions_on_stack: problems } );
throw new Failure("Blocked by functions on stack");
}
}
}
// A copy of the FunctionPatchabilityStatus enum from liveedit.h
var FunctionPatchabilityStatus = {
// A copy of the FunctionPatchabilityStatus enum from liveedit.h
var FunctionPatchabilityStatus = {
AVAILABLE_FOR_PATCH: 1,
BLOCKED_ON_ACTIVE_STACK: 2,
BLOCKED_ON_OTHER_STACK: 3,
BLOCKED_UNDER_NATIVE_CODE: 4,
REPLACED_ON_ACTIVE_STACK: 5
}
}
FunctionPatchabilityStatus.SymbolName = function(code) {
FunctionPatchabilityStatus.SymbolName = function(code) {
var enum = FunctionPatchabilityStatus;
for (name in enum) {
if (enum[name] == code) {
return name;
}
}
}
}
// A logical failure in liveedit process. This means that change_log
// is valid and consistent description of what happened.
function Failure(message) {
// A logical failure in liveedit process. This means that change_log
// is valid and consistent description of what happened.
function Failure(message) {
this.message = message;
}
// Function (constructor) is public.
this.Failure = Failure;
}
// Function (constructor) is public.
this.Failure = Failure;
Failure.prototype.toString = function() {
Failure.prototype.toString = function() {
return "LiveEdit Failure: " + this.message;
}
}
// A testing entry.
function GetPcFromSourcePos(func, source_pos) {
// A testing entry.
function GetPcFromSourcePos(func, source_pos) {
return %GetFunctionCodePositionFromSource(func, source_pos);
}
// Function is public.
this.GetPcFromSourcePos = GetPcFromSourcePos;
// TODO(LiveEdit): restore indentation above
}
// Function is public.
this.GetPcFromSourcePos = GetPcFromSourcePos;
// LiveEdit main entry point: changes a script text to a new string.
function SetScriptSource(script, new_source, change_log) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment