%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/self/root/usr/src/node-v0.10.4/out/Release/
Upload File :
Create Path :
Current File : //proc/self/root/usr/src/node-v0.10.4/out/Release/libv8_nosnapshot.a

!<arch>
/               1707480341  0     0     0       2288      `
$	�	�	�	�	�	�	�	�������������������������������������_ZN2v88internal17NativesCollectionILNS0_10NativeTypeE0EE16GetBuiltinsCountEv_ZN2v88internal17NativesCollectionILNS0_10NativeTypeE0EE16GetDebuggerCountEv_ZN2v88internal17NativesCollectionILNS0_10NativeTypeE0EE8GetIndexEPKc_ZN2v88internal17NativesCollectionILNS0_10NativeTypeE0EE17GetRawScriptsSizeEv_ZN2v88internal17NativesCollectionILNS0_10NativeTypeE0EE18GetRawScriptSourceEi_ZN2v88internal17NativesCollectionILNS0_10NativeTypeE0EE13GetScriptNameEi_ZN2v88internal17NativesCollectionILNS0_10NativeTypeE0EE16GetScriptsSourceEv_ZN2v88internal17NativesCollectionILNS0_10NativeTypeE0EE19SetRawScriptsSourceENS0_6VectorIKcEE_ZN2v88internal17NativesCollectionILNS0_10NativeTypeE1EE16GetBuiltinsCountEv_ZN2v88internal17NativesCollectionILNS0_10NativeTypeE1EE16GetDebuggerCountEv_ZN2v88internal17NativesCollectionILNS0_10NativeTypeE1EE8GetIndexEPKc_ZN2v88internal17NativesCollectionILNS0_10NativeTypeE1EE17GetRawScriptsSizeEv_ZN2v88internal17NativesCollectionILNS0_10NativeTypeE1EE18GetRawScriptSourceEi_ZN2v88internal17NativesCollectionILNS0_10NativeTypeE1EE13GetScriptNameEi_ZN2v88internal17NativesCollectionILNS0_10NativeTypeE1EE16GetScriptsSourceEv_ZN2v88internal17NativesCollectionILNS0_10NativeTypeE1EE19SetRawScriptsSourceENS0_6VectorIKcEE_ZN2v88internal8Snapshot24context_cell_space_used_E_ZN2v88internal8Snapshot23context_map_space_used_E_ZN2v88internal8Snapshot24context_code_space_used_E_ZN2v88internal8Snapshot24context_data_space_used_E_ZN2v88internal8Snapshot27context_pointer_space_used_E_ZN2v88internal8Snapshot23context_new_space_used_E_ZN2v88internal8Snapshot16cell_space_used_E_ZN2v88internal8Snapshot15map_space_used_E_ZN2v88internal8Snapshot16code_space_used_E_ZN2v88internal8Snapshot16data_space_used_E_ZN2v88internal8Snapshot19pointer_space_used_E_ZN2v88internal8Snapshot15new_space_used_E_ZN2v88internal8Snapshot17context_raw_size_E_ZN2v88internal8Snapshot13context_size_E_ZN2v88internal8Snapshot17context_raw_data_E_ZN2v88internal8Snapshot13context_data_E_ZN2v88internal8Snapshot9raw_size_E_ZN2v88internal8Snapshot5size_E_ZN2v88internal8Snapshot9raw_data_E_ZN2v88internal8Snapshot5data_E//                                              44        `
experimental-libraries.o/
snapshot-empty.o/
libraries.o/    1707480340  0     0     100644  243176    `
ELF>(�@@��f.���f.�SH����H�������)�����t9��H�������8�t�	�H�������8�u[���H�������8�t�
�H�������8�tŹ�H�������8�t���H�������8�t���H�������8��p����H����¸���T����H����¸	���8����H����¸
�������H����¸�������H����¸�����H�߾��������[Ð@f.��`��f.��������������������������������������	�.��
�=���L�����1҃�
������H���H���DH���H�e�DH��S<H���DH���)�H���lH�)�DH���OHٖ�DH���?H���DH��H�k�H�f��H���H���H|&�DH��-H%=�DH���_HRM�DH���H���DH���:H�0Ð@���������������������������������������	����
�������������
��HE¹�HE��f.����D���D���D���D���D���D���D���D��
�D���D���D���D��Ð@��`�Ð@H�=�debugmirrorliveeditruntimev8nativesarraystringurimathmessagesapinativesdatejsonregexpnative debug.jsnative mirror.jsnative liveedit.jsnative runtime.jsnative v8natives.jsnative array.jsnative string.jsnative uri.jsnative math.jsnative messages.jsnative apinatives.jsnative date.jsnative json.jsnative regexp.js










































var $Object=global.Object;
var $Array=global.Array;
var $String=global.String;
var $Number=global.Number;
var $Function=global.Function;
var $Boolean=global.Boolean;
var $NaN=%GetRootNaN();
var builtins=this;


function EQUALS(a){
if((typeof(this)==='string')&&(typeof(a)==='string'))return %StringEquals(this,a);
var b=this;

while(true){
if((typeof(b)==='number')){
while(true){
if((typeof(a)==='number'))return %NumberEquals(b,a);
if((a==null))return 1;
if(!(%_IsSpecObject(a))){

return %NumberEquals(b,%ToNumber(a));
}
a=%ToPrimitive(a,0);
}
}else if((typeof(b)==='string')){
while(true){
if((typeof(a)==='string'))return %StringEquals(b,a);
if((typeof(a)==='number'))return %NumberEquals(%ToNumber(b),a);
if((typeof(a)==='boolean'))return %NumberEquals(%ToNumber(b),%ToNumber(a));
if((a==null))return 1;
a=%ToPrimitive(a,0);
}
}else if((typeof(b)==='boolean')){
if((typeof(a)==='boolean'))return %_ObjectEquals(b,a)?0:1;
if((a==null))return 1;
if((typeof(a)==='number'))return %NumberEquals(%ToNumber(b),a);
if((typeof(a)==='string'))return %NumberEquals(%ToNumber(b),%ToNumber(a));

b=%ToNumber(b);
a=%ToPrimitive(a,0);
}else if((b==null)){
return(a==null)?0:1;
}else{

if((%_IsSpecObject(a))){
return %_ObjectEquals(b,a)?0:1;
}
if((a==null))return 1;
if((typeof(a)==='boolean'))a=%ToNumber(a);
b=%ToPrimitive(b,0);
}
}
}


function STRICT_EQUALS(a){
if((typeof(this)==='string')){
if(!(typeof(a)==='string'))return 1;
return %StringEquals(this,a);
}

if((typeof(this)==='number')){
if(!(typeof(a)==='number'))return 1;
return %NumberEquals(this,a);
}




return %_ObjectEquals(this,a)?0:1;
}




function COMPARE(a,b){
var c;
var d;

if((typeof(this)==='string')){
if((typeof(a)==='string'))return %_StringCompare(this,a);
if((typeof(a)==='undefined'))return b;
c=this;
}else if((typeof(this)==='number')){
if((typeof(a)==='number'))return %NumberCompare(this,a,b);
if((typeof(a)==='undefined'))return b;
c=this;
}else if((typeof(this)==='undefined')){
if(!(typeof(a)==='undefined')){
%ToPrimitive(a,1);
}
return b;
}else if((typeof(a)==='undefined')){
%ToPrimitive(this,1);
return b;
}else{
c=%ToPrimitive(this,1);
}

d=%ToPrimitive(a,1);
if((typeof(c)==='string')&&(typeof(d)==='string')){
return %_StringCompare(c,d);
}else{
var e=%ToNumber(c);
var f=%ToNumber(d);
if((!%_IsSmi(%IS_VAR(e))&&!(e==e))||(!%_IsSmi(%IS_VAR(f))&&!(f==f)))return b;
return %NumberCompare(e,f,b);
}
}









function ADD(a){

if((typeof(this)==='number')&&(typeof(a)==='number'))return %NumberAdd(this,a);
if((typeof(this)==='string')&&(typeof(a)==='string'))return %_StringAdd(this,a);


var b=%ToPrimitive(this,0);
var c=%ToPrimitive(a,0);

if((typeof(b)==='string')){
return %_StringAdd(b,%ToString(c));
}else if((typeof(c)==='string')){
return %_StringAdd(%NonStringToString(b),c);
}else{
return %NumberAdd(%ToNumber(b),%ToNumber(c));
}
}



function STRING_ADD_LEFT(a){
if(!(typeof(a)==='string')){
if((%_ClassOf(a)==='String')&&%_IsStringWrapperSafeForDefaultValueOf(a)){
a=%_ValueOf(a);
}else{
a=(typeof(a)==='number')
?%_NumberToString(a)
:%ToString(%ToPrimitive(a,0));
}
}
return %_StringAdd(this,a);
}



function STRING_ADD_RIGHT(a){
var b=this;
if(!(typeof(b)==='string')){
if((%_ClassOf(b)==='String')&&%_IsStringWrapperSafeForDefaultValueOf(b)){
b=%_ValueOf(b);
}else{
b=(typeof(b)==='number')
?%_NumberToString(b)
:%ToString(%ToPrimitive(b,0));
}
}
return %_StringAdd(b,a);
}



function SUB(a){
var b=(typeof(this)==='number')?this:%NonNumberToNumber(this);
if(!(typeof(a)==='number'))a=%NonNumberToNumber(a);
return %NumberSub(b,a);
}



function MUL(a){
var b=(typeof(this)==='number')?this:%NonNumberToNumber(this);
if(!(typeof(a)==='number'))a=%NonNumberToNumber(a);
return %NumberMul(b,a);
}



function DIV(a){
var b=(typeof(this)==='number')?this:%NonNumberToNumber(this);
if(!(typeof(a)==='number'))a=%NonNumberToNumber(a);
return %NumberDiv(b,a);
}



function MOD(a){
var b=(typeof(this)==='number')?this:%NonNumberToNumber(this);
if(!(typeof(a)==='number'))a=%NonNumberToNumber(a);
return %NumberMod(b,a);
}









function BIT_OR(a){
var b=(typeof(this)==='number')?this:%NonNumberToNumber(this);
if(!(typeof(a)==='number'))a=%NonNumberToNumber(a);
return %NumberOr(b,a);
}



function BIT_AND(a){
var b;
if((typeof(this)==='number')){
b=this;
if(!(typeof(a)==='number'))a=%NonNumberToNumber(a);
}else{
b=%NonNumberToNumber(this);




if(!(typeof(a)==='number'))a=%NonNumberToNumber(a);



if((!%_IsSmi(%IS_VAR(b))&&!(b==b)))return 0;
}
return %NumberAnd(b,a);
}



function BIT_XOR(a){
var b=(typeof(this)==='number')?this:%NonNumberToNumber(this);
if(!(typeof(a)==='number'))a=%NonNumberToNumber(a);
return %NumberXor(b,a);
}



function UNARY_MINUS(){
var a=(typeof(this)==='number')?this:%NonNumberToNumber(this);
return %NumberUnaryMinus(a);
}



function BIT_NOT(){
var a=(typeof(this)==='number')?this:%NonNumberToNumber(this);
return %NumberNot(a);
}



function SHL(a){
var b=(typeof(this)==='number')?this:%NonNumberToNumber(this);
if(!(typeof(a)==='number'))a=%NonNumberToNumber(a);
return %NumberShl(b,a);
}



function SAR(a){
var b;
if((typeof(this)==='number')){
b=this;
if(!(typeof(a)==='number'))a=%NonNumberToNumber(a);
}else{
b=%NonNumberToNumber(this);




if(!(typeof(a)==='number'))a=%NonNumberToNumber(a);



if((!%_IsSmi(%IS_VAR(b))&&!(b==b)))return 0;
}
return %NumberSar(b,a);
}



function SHR(a){
var b=(typeof(this)==='number')?this:%NonNumberToNumber(this);
if(!(typeof(a)==='number'))a=%NonNumberToNumber(a);
return %NumberShr(b,a);
}









function DELETE(a,b){
return %DeleteProperty(%ToObject(this),%ToString(a),b);
}



function IN(a){
if(!(%_IsSpecObject(a))){
throw %MakeTypeError('invalid_in_operator_use',[this,a]);
}
return %_IsNonNegativeSmi(this)?
%HasElement(a,this):%HasProperty(a,%ToString(this));
}






function INSTANCE_OF(a){
var b=this;
if(!(%_ClassOf(a)==='Function')){
throw %MakeTypeError('instanceof_function_expected',[b]);
}


if(!(%_IsSpecObject(b))){
return 1;
}



var c=%BoundFunctionGetBindings(a);
if(c){
a=c[0];
}

var d=a.prototype;
if(!(%_IsSpecObject(d))){
throw %MakeTypeError('instanceof_nonobject_proto',[d]);
}


return %IsInPrototypeChain(d,b)?0:1;
}





function FILTER_KEY(a){
var b=%ToString(a);
if(%HasProperty(this,b))return b;
return 0;
}


function CALL_NON_FUNCTION(){
var a=%GetFunctionDelegate(this);
if(!(%_IsFunction(a))){
throw %MakeTypeError('called_non_callable',[typeof this]);
}
return %Apply(a,this,arguments,0,%_ArgumentsLength());
}


function CALL_NON_FUNCTION_AS_CONSTRUCTOR(){
var a=%GetConstructorDelegate(this);
if(!(%_IsFunction(a))){
throw %MakeTypeError('called_non_callable',[typeof this]);
}
return %Apply(a,this,arguments,0,%_ArgumentsLength());
}


function CALL_FUNCTION_PROXY(){
var a=%_ArgumentsLength()-1;
var b=%_Arguments(a);
var c=%GetCallTrap(b);
return %Apply(c,this,arguments,0,a);
}


function CALL_FUNCTION_PROXY_AS_CONSTRUCTOR(){
var a=this;
var b=%GetConstructTrap(a);
return %Apply(b,this,arguments,0,%_ArgumentsLength());
}


function APPLY_PREPARE(a){
var b;



if((%_IsArray(a))){
b=a.length;
if(%_IsSmi(b)&&b>=0&&b<0x800000&&
(%_ClassOf(this)==='Function')){
return b;
}
}

b=(a==null)?0:%ToUint32(a.length);




if(b>0x800000){
throw %MakeRangeError('stack_overflow',[]);
}

if(!(%_ClassOf(this)==='Function')){
throw %MakeTypeError('apply_non_function',
[%ToString(this),typeof this]);
}


if(a!=null&&!(%_IsSpecObject(a))){
throw %MakeTypeError('apply_wrong_args',[]);
}



return b;
}


function APPLY_OVERFLOW(a){
throw %MakeRangeError('stack_overflow',[]);
}



function TO_OBJECT(){
return %ToObject(this);
}



function TO_NUMBER(){
return %ToNumber(this);
}



function TO_STRING(){
return %ToString(this);
}









function ToPrimitive(a,b){

if((typeof(a)==='string'))return a;

if(!(%_IsSpecObject(a)))return a;
if(b==0)b=((%_ClassOf(a)==='Date'))?2:1;
return(b==1)?%DefaultNumber(a):%DefaultString(a);
}



function ToBoolean(a){
if((typeof(a)==='boolean'))return a;
if((typeof(a)==='string'))return a.length!=0;
if(a==null)return false;
if((typeof(a)==='number'))return!((a==0)||(!%_IsSmi(%IS_VAR(a))&&!(a==a)));
return true;
}



function ToNumber(a){
if((typeof(a)==='number'))return a;
if((typeof(a)==='string')){
return %_HasCachedArrayIndex(a)?%_GetCachedArrayIndex(a)
:%StringToNumber(a);
}
if((typeof(a)==='boolean'))return a?1:0;
if((typeof(a)==='undefined'))return $NaN;
return((a===null))?0:ToNumber(%DefaultNumber(a));
}

function NonNumberToNumber(a){
if((typeof(a)==='string')){
return %_HasCachedArrayIndex(a)?%_GetCachedArrayIndex(a)
:%StringToNumber(a);
}
if((typeof(a)==='boolean'))return a?1:0;
if((typeof(a)==='undefined'))return $NaN;
return((a===null))?0:ToNumber(%DefaultNumber(a));
}



function ToString(a){
if((typeof(a)==='string'))return a;
if((typeof(a)==='number'))return %_NumberToString(a);
if((typeof(a)==='boolean'))return a?'true':'false';
if((typeof(a)==='undefined'))return'undefined';
return((a===null))?'null':%ToString(%DefaultString(a));
}

function NonStringToString(a){
if((typeof(a)==='number'))return %_NumberToString(a);
if((typeof(a)==='boolean'))return a?'true':'false';
if((typeof(a)==='undefined'))return'undefined';
return((a===null))?'null':%ToString(%DefaultString(a));
}



function ToObject(a){
if((typeof(a)==='string'))return new $String(a);
if((typeof(a)==='number'))return new $Number(a);
if((typeof(a)==='boolean'))return new $Boolean(a);
if((a==null)&&!(%_IsUndetectableObject(a))){
throw %MakeTypeError('null_to_object',[]);
}
return a;
}



function ToInteger(a){
if(%_IsSmi(a))return a;
return %NumberToInteger(ToNumber(a));
}



function ToUint32(a){
if(%_IsSmi(a)&&a>=0)return a;
return %NumberToJSUint32(ToNumber(a));
}



function ToInt32(a){
if(%_IsSmi(a))return a;
return %NumberToJSInt32(ToNumber(a));
}



function SameValue(a,b){
if(typeof a!=typeof b)return false;
if((typeof(a)==='number')){
if((!%_IsSmi(%IS_VAR(a))&&!(a==a))&&(!%_IsSmi(%IS_VAR(b))&&!(b==b)))return true;

if(a===0&&b===0&&(1/a)!=(1/b))return false;
}
return a===b;
}









function IsPrimitive(a){



return!(%_IsSpecObject(a));
}



function DefaultNumber(a){
var b=a.valueOf;
if((%_ClassOf(b)==='Function')){
var c=%_CallFunction(a,b);
if(%IsPrimitive(c))return c;
}

var d=a.toString;
if((%_ClassOf(d)==='Function')){
var e=%_CallFunction(a,d);
if(%IsPrimitive(e))return e;
}

throw %MakeTypeError('cannot_convert_to_primitive',[]);
}



function DefaultString(a){
var b=a.toString;
if((%_ClassOf(b)==='Function')){
var c=%_CallFunction(a,b);
if(%IsPrimitive(c))return c;
}

var d=a.valueOf;
if((%_ClassOf(d)==='Function')){
var e=%_CallFunction(a,d);
if(%IsPrimitive(e))return e;
}

throw %MakeTypeError('cannot_convert_to_primitive',[]);
}







%FunctionSetPrototype($Array,new $Array(0));









































var $isNaN=GlobalIsNaN;
var $isFinite=GlobalIsFinite;





function InstallFunctions(a,b,c){
if(c.length>=8){
%OptimizeObjectForAddingMultipleProperties(a,c.length>>1);
}
for(var d=0;d<c.length;d+=2){
var e=c[d];
var f=c[d+1];
%FunctionSetName(f,e);
%FunctionRemovePrototype(f);
%SetProperty(a,e,f,b);
%SetNativeFlag(f);
}
%ToFastProperties(a);
}





function SetUpLockedPrototype(a,b,c){
%CheckIsBootstrapping();
var d=a.prototype;


var e=(c.length>>1)+(b?b.length:0);
if(e>=4){
%OptimizeObjectForAddingMultipleProperties(d,e);
}
if(b){
for(var f=0;f<b.length;f++){
%SetProperty(d,b[f],void 0,2|4);
}
}
for(var f=0;f<c.length;f+=2){
var g=c[f];
var h=c[f+1];
%SetProperty(d,g,h,2|4|1);
%SetNativeFlag(h);
}
d.__proto__=null;
%ToFastProperties(d);
}






function GlobalIsNaN(a){
if(!(typeof(a)==='number'))a=NonNumberToNumber(a);
return(!%_IsSmi(%IS_VAR(a))&&!(a==a));
}



function GlobalIsFinite(a){
if(!(typeof(a)==='number'))a=NonNumberToNumber(a);
return(%_IsSmi(%IS_VAR(a))||((a==a)&&(a!=1/0)&&(a!=-1/0)));
}



function GlobalParseInt(a,b){
if((typeof(b)==='undefined')||b===10||b===0){





if(%_IsSmi(a))return a;
if((typeof(a)==='number')&&
((0.01<a&&a<1e9)||
(-1e9<a&&a<-0.01))){

return a|0;
}
a=((typeof(%IS_VAR(a))==='string')?a:NonStringToString(a));
b=b|0;
}else{

a=((typeof(%IS_VAR(a))==='string')?a:NonStringToString(a));
b=(%_IsSmi(%IS_VAR(b))?b:(b>>0));
if(!(b==0||(2<=b&&b<=36))){
return $NaN;
}
}

if(%_HasCachedArrayIndex(a)&&
(b==0||b==10)){
return %_GetCachedArrayIndex(a);
}
return %StringParseInt(a,b);
}



function GlobalParseFloat(a){
a=((typeof(%IS_VAR(a))==='string')?a:NonStringToString(a));
if(%_HasCachedArrayIndex(a))return %_GetCachedArrayIndex(a);
return %StringParseFloat(a);
}


function GlobalEval(a){
if(!(typeof(a)==='string'))return a;

var b=%GlobalReceiver(global);
var c=(global===b);






if(c){
throw new $EvalError('The "this" value passed to eval must '+
'be the global object from which eval originated');
}

var d=%CompileString(a);
if(!(%_IsFunction(d)))return d;

return %_CallFunction(b,d);
}





function SetUpGlobal(){
%CheckIsBootstrapping();

%SetProperty(global,"NaN",$NaN,2|4|1);


%SetProperty(global,"Infinity",1/0,2|4|1);


%SetProperty(global,"undefined",void 0,
2|4|1);


InstallFunctions(global,2,$Array(
"isNaN",GlobalIsNaN,
"isFinite",GlobalIsFinite,
"parseInt",GlobalParseInt,
"parseFloat",GlobalParseFloat,
"eval",GlobalEval
));
}

SetUpGlobal();





%SetCode($Boolean,function(a){
if(%_IsConstructCall()){
%_SetValueOf(this,ToBoolean(a));
}else{
return ToBoolean(a);
}
});

%FunctionSetPrototype($Boolean,new $Boolean(false));

%SetProperty($Boolean.prototype,"constructor",$Boolean,2);




$Object.prototype.constructor=$Object;


function ObjectToString(){
if((typeof(this)==='undefined')&&!(%_IsUndetectableObject(this))){
return'[object Undefined]';
}
if((this===null))return'[object Null]';
return"[object "+%_ClassOf(ToObject(this))+"]";
}



function ObjectToLocaleString(){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["Object.prototype.toLocaleString"]);
}
return this.toString();
}



function ObjectValueOf(){
return ToObject(this);
}



function ObjectHasOwnProperty(a){
if(%IsJSProxy(this)){
var b=%GetHandler(this);
return CallTrap1(b,"hasOwn",DerivedHasOwnTrap,((typeof(%IS_VAR(a))==='string')?a:NonStringToString(a)));
}
return %HasLocalProperty(((%_IsSpecObject(%IS_VAR(this)))?this:ToObject(this)),((typeof(%IS_VAR(a))==='string')?a:NonStringToString(a)));
}



function ObjectIsPrototypeOf(a){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["Object.prototype.isPrototypeOf"]);
}
if(!(%_IsSpecObject(a)))return false;
return %IsInPrototypeChain(this,a);
}



function ObjectPropertyIsEnumerable(a){
var b=ToString(a);
if(%IsJSProxy(this)){
var c=GetOwnProperty(this,b);
return(typeof(c)==='undefined')?false:c.isEnumerable();
}
return %IsPropertyEnumerable(ToObject(this),b);
}



function ObjectDefineGetter(a,b){
var c=this;
if(c==null&&!(%_IsUndetectableObject(c))){
c=%GlobalReceiver(global);
}
if(!(%_ClassOf(b)==='Function')){
throw new $TypeError(
'Object.prototype.__defineGetter__: Expecting function');
}
var d=new PropertyDescriptor();
d.setGet(b);
d.setEnumerable(true);
d.setConfigurable(true);
DefineOwnProperty(ToObject(c),ToString(a),d,false);
}


function ObjectLookupGetter(a){
var b=this;
if(b==null&&!(%_IsUndetectableObject(b))){
b=%GlobalReceiver(global);
}
return %LookupAccessor(ToObject(b),ToString(a),0);
}


function ObjectDefineSetter(a,b){
var c=this;
if(c==null&&!(%_IsUndetectableObject(c))){
c=%GlobalReceiver(global);
}
if(!(%_ClassOf(b)==='Function')){
throw new $TypeError(
'Object.prototype.__defineSetter__: Expecting function');
}
var d=new PropertyDescriptor();
d.setSet(b);
d.setEnumerable(true);
d.setConfigurable(true);
DefineOwnProperty(ToObject(c),ToString(a),d,false);
}


function ObjectLookupSetter(a){
var b=this;
if(b==null&&!(%_IsUndetectableObject(b))){
b=%GlobalReceiver(global);
}
return %LookupAccessor(ToObject(b),ToString(a),1);
}


function ObjectKeys(a){
if(!(%_IsSpecObject(a))){
throw MakeTypeError("called_on_non_object",["Object.keys"]);
}
if(%IsJSProxy(a)){
var b=%GetHandler(a);
var c=CallTrap0(b,"keys",DerivedKeysTrap);
return ToStringArray(c,"keys");
}
return %LocalKeys(a);
}



function IsAccessorDescriptor(a){
if((typeof(a)==='undefined'))return false;
return a.hasGetter()||a.hasSetter();
}



function IsDataDescriptor(a){
if((typeof(a)==='undefined'))return false;
return a.hasValue()||a.hasWritable();
}



function IsGenericDescriptor(a){
if((typeof(a)==='undefined'))return false;
return!(IsAccessorDescriptor(a)||IsDataDescriptor(a));
}


function IsInconsistentDescriptor(a){
return IsAccessorDescriptor(a)&&IsDataDescriptor(a);
}



function FromPropertyDescriptor(a){
if((typeof(a)==='undefined'))return a;

if(IsDataDescriptor(a)){
return{value:a.getValue(),
writable:a.isWritable(),
enumerable:a.isEnumerable(),
configurable:a.isConfigurable()};
}

return{get:a.getGet(),
set:a.getSet(),
enumerable:a.isEnumerable(),
configurable:a.isConfigurable()};
}



function FromGenericPropertyDescriptor(a){
if((typeof(a)==='undefined'))return a;
var b=new $Object();

if(a.hasValue()){
%IgnoreAttributesAndSetProperty(b,"value",a.getValue(),0);
}
if(a.hasWritable()){
%IgnoreAttributesAndSetProperty(b,"writable",a.isWritable(),0);
}
if(a.hasGetter()){
%IgnoreAttributesAndSetProperty(b,"get",a.getGet(),0);
}
if(a.hasSetter()){
%IgnoreAttributesAndSetProperty(b,"set",a.getSet(),0);
}
if(a.hasEnumerable()){
%IgnoreAttributesAndSetProperty(b,"enumerable",
a.isEnumerable(),0);
}
if(a.hasConfigurable()){
%IgnoreAttributesAndSetProperty(b,"configurable",
a.isConfigurable(),0);
}
return b;
}



function ToPropertyDescriptor(a){
if(!(%_IsSpecObject(a))){
throw MakeTypeError("property_desc_object",[a]);
}
var b=new PropertyDescriptor();

if("enumerable"in a){
b.setEnumerable(ToBoolean(a.enumerable));
}

if("configurable"in a){
b.setConfigurable(ToBoolean(a.configurable));
}

if("value"in a){
b.setValue(a.value);
}

if("writable"in a){
b.setWritable(ToBoolean(a.writable));
}

if("get"in a){
var c=a.get;
if(!(typeof(c)==='undefined')&&!(%_ClassOf(c)==='Function')){
throw MakeTypeError("getter_must_be_callable",[c]);
}
b.setGet(c);
}

if("set"in a){
var d=a.set;
if(!(typeof(d)==='undefined')&&!(%_ClassOf(d)==='Function')){
throw MakeTypeError("setter_must_be_callable",[d]);
}
b.setSet(d);
}

if(IsInconsistentDescriptor(b)){
throw MakeTypeError("value_and_accessor",[a]);
}
return b;
}



function ToCompletePropertyDescriptor(a){
var b=ToPropertyDescriptor(a);
if(IsGenericDescriptor(b)||IsDataDescriptor(b)){
if(!b.hasValue())b.setValue(void 0);
if(!b.hasWritable())b.setWritable(false);
}else{

if(!b.hasGetter())b.setGet(void 0);
if(!b.hasSetter())b.setSet(void 0);
}
if(!b.hasEnumerable())b.setEnumerable(false);
if(!b.hasConfigurable())b.setConfigurable(false);
return b;
}


function PropertyDescriptor(){


this.value_=void 0;
this.hasValue_=false;
this.writable_=false;
this.hasWritable_=false;
this.enumerable_=false;
this.hasEnumerable_=false;
this.configurable_=false;
this.hasConfigurable_=false;
this.get_=void 0;
this.hasGetter_=false;
this.set_=void 0;
this.hasSetter_=false;
}

SetUpLockedPrototype(PropertyDescriptor,$Array(
"value_",
"hasValue_",
"writable_",
"hasWritable_",
"enumerable_",
"hasEnumerable_",
"configurable_",
"hasConfigurable_",
"get_",
"hasGetter_",
"set_",
"hasSetter_"
),$Array(
"toString",function(){
return"[object PropertyDescriptor]";
},
"setValue",function(a){
this.value_=a;
this.hasValue_=true;
},
"getValue",function(){
return this.value_;
},
"hasValue",function(){
return this.hasValue_;
},
"setEnumerable",function(a){
this.enumerable_=a;
this.hasEnumerable_=true;
},
"isEnumerable",function(){
return this.enumerable_;
},
"hasEnumerable",function(){
return this.hasEnumerable_;
},
"setWritable",function(a){
this.writable_=a;
this.hasWritable_=true;
},
"isWritable",function(){
return this.writable_;
},
"hasWritable",function(){
return this.hasWritable_;
},
"setConfigurable",function(a){
this.configurable_=a;
this.hasConfigurable_=true;
},
"hasConfigurable",function(){
return this.hasConfigurable_;
},
"isConfigurable",function(){
return this.configurable_;
},
"setGet",function(a){
this.get_=a;
this.hasGetter_=true;
},
"getGet",function(){
return this.get_;
},
"hasGetter",function(){
return this.hasGetter_;
},
"setSet",function(a){
this.set_=a;
this.hasSetter_=true;
},
"getSet",function(){
return this.set_;
},
"hasSetter",function(){
return this.hasSetter_;
}));





function ConvertDescriptorArrayToDescriptor(a){
if(a===false){
throw'Internal error: invalid desc_array';
}

if((typeof(a)==='undefined')){
return void 0;
}

var b=new PropertyDescriptor();

if(a[0]){
b.setGet(a[2]);
b.setSet(a[3]);
}else{
b.setValue(a[1]);
b.setWritable(a[4]);
}
b.setEnumerable(a[5]);
b.setConfigurable(a[6]);

return b;
}



function GetTrap(a,b,c){
var d=a[b];
if((typeof(d)==='undefined')){
if((typeof(c)==='undefined')){
throw MakeTypeError("handler_trap_missing",[a,b]);
}
d=c;
}else if(!(%_ClassOf(d)==='Function')){
throw MakeTypeError("handler_trap_must_be_callable",[a,b]);
}
return d;
}


function CallTrap0(a,b,c){
return %_CallFunction(a,GetTrap(a,b,c));
}


function CallTrap1(a,b,c,d){
return %_CallFunction(a,d,GetTrap(a,b,c));
}


function CallTrap2(a,b,c,d,e){
return %_CallFunction(a,d,e,GetTrap(a,b,c));
}



function GetOwnProperty(a,b){
var c=ToString(b);
if(%IsJSProxy(a)){
var d=%GetHandler(a);
var e=CallTrap1(d,"getOwnPropertyDescriptor",void 0,c);
if((typeof(e)==='undefined'))return e;
var f=ToCompletePropertyDescriptor(e);
if(!f.isConfigurable()){
throw MakeTypeError("proxy_prop_not_configurable",
[d,"getOwnPropertyDescriptor",c,e]);
}
return f;
}




var g=%GetOwnProperty(ToObject(a),ToString(b));


if(g===false)return void 0;

return ConvertDescriptorArrayToDescriptor(g);
}



function Delete(a,b,c){
var d=GetOwnProperty(a,b);
if((typeof(d)==='undefined'))return true;
if(d.isConfigurable()){
%DeleteProperty(a,b,0);
return true;
}else if(c){
throw MakeTypeError("define_disallowed",[b]);
}else{
return;
}
}



function DefineProxyProperty(a,b,c,d){
var e=%GetHandler(a);
var f=CallTrap2(e,"defineProperty",void 0,b,c);
if(!ToBoolean(f)){
if(d){
throw MakeTypeError("handler_returned_false",
[e,"defineProperty"]);
}else{
return false;
}
}
return true;
}



function DefineObjectProperty(a,b,c,d){
var e=%GetOwnProperty(ToObject(a),ToString(b));

if(e===false)return void 0;

var f=ConvertDescriptorArrayToDescriptor(e);
var g=%IsExtensible(ToObject(a));



if((typeof(f)==='undefined')&&!g){
if(d){
throw MakeTypeError("define_disallowed",[b]);
}else{
return false;
}
}

if(!(typeof(f)==='undefined')){

if((IsGenericDescriptor(c)||
IsDataDescriptor(c)==IsDataDescriptor(f))&&
(!c.hasEnumerable()||
SameValue(c.isEnumerable(),f.isEnumerable()))&&
(!c.hasConfigurable()||
SameValue(c.isConfigurable(),f.isConfigurable()))&&
(!c.hasWritable()||
SameValue(c.isWritable(),f.isWritable()))&&
(!c.hasValue()||
SameValue(c.getValue(),f.getValue()))&&
(!c.hasGetter()||
SameValue(c.getGet(),f.getGet()))&&
(!c.hasSetter()||
SameValue(c.getSet(),f.getSet()))){
return true;
}
if(!f.isConfigurable()){

if(c.isConfigurable()||
(c.hasEnumerable()&&
c.isEnumerable()!=f.isEnumerable())){
if(d){
throw MakeTypeError("redefine_disallowed",[b]);
}else{
return false;
}
}

if(!IsGenericDescriptor(c)){

if(IsDataDescriptor(f)!=IsDataDescriptor(c)){
if(d){
throw MakeTypeError("redefine_disallowed",[b]);
}else{
return false;
}
}

if(IsDataDescriptor(f)&&IsDataDescriptor(c)){
if(!f.isWritable()&&c.isWritable()){
if(d){
throw MakeTypeError("redefine_disallowed",[b]);
}else{
return false;
}
}
if(!f.isWritable()&&c.hasValue()&&
!SameValue(c.getValue(),f.getValue())){
if(d){
throw MakeTypeError("redefine_disallowed",[b]);
}else{
return false;
}
}
}

if(IsAccessorDescriptor(c)&&IsAccessorDescriptor(f)){
if(c.hasSetter()&&!SameValue(c.getSet(),f.getSet())){
if(d){
throw MakeTypeError("redefine_disallowed",[b]);
}else{
return false;
}
}
if(c.hasGetter()&&!SameValue(c.getGet(),f.getGet())){
if(d){
throw MakeTypeError("redefine_disallowed",[b]);
}else{
return false;
}
}
}
}
}
}





var h=0;
if(c.hasEnumerable()){
h|=c.isEnumerable()?0:2;
}else if(!(typeof(f)==='undefined')){
h|=f.isEnumerable()?0:2;
}else{
h|=2;
}

if(c.hasConfigurable()){
h|=c.isConfigurable()?0:4;
}else if(!(typeof(f)==='undefined')){
h|=f.isConfigurable()?0:4;
}else
h|=4;

if(IsDataDescriptor(c)||
(IsGenericDescriptor(c)&&
((typeof(f)==='undefined')||IsDataDescriptor(f)))){







if(c.hasWritable()){
h|=c.isWritable()?0:1;
}else if(!(typeof(f)==='undefined')){
h|=f.isWritable()?0:1;
}else{
h|=1;
}

var i=void 0;
if(c.hasValue()){
i=c.getValue();
}else if(!(typeof(f)==='undefined')&&IsDataDescriptor(f)){
i=f.getValue();
}

%DefineOrRedefineDataProperty(a,b,i,h);
}else{






var j=c.hasGetter()?c.getGet():null;
var k=c.hasSetter()?c.getSet():null;
%DefineOrRedefineAccessorProperty(a,b,j,k,h);
}
return true;
}



function DefineArrayProperty(a,b,c,d){





if(b=="length"){
var e=a.length;
if(!c.hasValue()){
return DefineObjectProperty(a,"length",c,d);
}
var f=ToUint32(c.getValue());
if(f!=ToNumber(c.getValue())){
throw new $RangeError('defineProperty() array length out of range');
}
var g=GetOwnProperty(a,"length");
if(f!=e&&!g.isWritable()){
if(d){
throw MakeTypeError("redefine_disallowed",[b]);
}else{
return false;
}
}
var h=false;
while(f<e--){
if(!Delete(a,ToString(e),false)){
f=e+1;
h=true;
break;
}
}


a.length=f;
c.value_=void 0;
c.hasValue_=false;
if(!DefineObjectProperty(a,"length",c,d)||h){
if(d){
throw MakeTypeError("redefine_disallowed",[b]);
}else{
return false;
}
}
return true;
}


var i=ToUint32(b);
if(i==ToNumber(b)&&i!=4294967295){
var e=a.length;
var g=GetOwnProperty(a,"length");
if((i>=e&&!g.isWritable())||
!DefineObjectProperty(a,b,c,true)){
if(d){
throw MakeTypeError("define_disallowed",[b]);
}else{
return false;
}
}
if(i>=e){
a.length=i+1;
}
return true;
}


return DefineObjectProperty(a,b,c,d);
}



function DefineOwnProperty(a,b,c,d){
if(%IsJSProxy(a)){
var e=FromGenericPropertyDescriptor(c);
return DefineProxyProperty(a,b,e,d);
}else if((%_IsArray(a))){
return DefineArrayProperty(a,b,c,d);
}else{
return DefineObjectProperty(a,b,c,d);
}
}



function ObjectGetPrototypeOf(a){
if(!(%_IsSpecObject(a))){
throw MakeTypeError("called_on_non_object",["Object.getPrototypeOf"]);
}
return %GetPrototype(a);
}



function ObjectGetOwnPropertyDescriptor(a,b){
if(!(%_IsSpecObject(a))){
throw MakeTypeError("called_on_non_object",
["Object.getOwnPropertyDescriptor"]);
}
var c=GetOwnProperty(a,b);
return FromPropertyDescriptor(c);
}



function ToStringArray(a,b){
if(!(%_IsSpecObject(a))){
throw MakeTypeError("proxy_non_object_prop_names",[a,b]);
}
var c=ToUint32(a.length);
var d=new $Array(c);
var e={};
for(var f=0;f<c;f++){
var g=ToString(a[f]);
if(%HasLocalProperty(e,g)){
throw MakeTypeError("proxy_repeated_prop_name",[a,b,g]);
}
d[f]=g;
e[g]=0;
}
return d;
}



function ObjectGetOwnPropertyNames(a){
if(!(%_IsSpecObject(a))){
throw MakeTypeError("called_on_non_object",["Object.getOwnPropertyNames"]);
}

if(%IsJSProxy(a)){
var b=%GetHandler(a);
var c=CallTrap0(b,"getOwnPropertyNames",void 0);
return ToStringArray(c,"getOwnPropertyNames");
}




var d=%GetLocalElementNames(a);


if(%GetInterceptorInfo(a)&1){
var e=
%GetIndexedInterceptorElementNames(a);
if(e){
d=d.concat(e);
}
}




d=d.concat(%GetLocalPropertyNames(a));



if(%GetInterceptorInfo(a)&2){
var f=
%GetNamedInterceptorPropertyNames(a);
if(f){
d=d.concat(f);
}
}


var g={};
var h=0;
for(var i=0;i<d.length;++i){
var j=ToString(d[i]);



if(g[j]===true){
continue;
}
g[j]=true;
d[h++]=j;
}
d.length=h;

return d;
}



function ObjectCreate(a,b){
if(!(%_IsSpecObject(a))&&a!==null){
throw MakeTypeError("proto_object_or_null",[a]);
}
var c=new $Object();
c.__proto__=a;
if(!(typeof(b)==='undefined'))ObjectDefineProperties(c,b);
return c;
}



function ObjectDefineProperty(a,b,c){
if(!(%_IsSpecObject(a))){
throw MakeTypeError("called_on_non_object",["Object.defineProperty"]);
}
var d=ToString(b);
if(%IsJSProxy(a)){



var e={};
for(var f in c){
e[f]=c[f];
}
DefineProxyProperty(a,d,e,true);


















}else{
var g=ToPropertyDescriptor(c);
DefineOwnProperty(a,d,g,true);
}
return a;
}


function GetOwnEnumerablePropertyNames(a){
var b=new InternalArray();
for(var c in a){
if(%HasLocalProperty(a,c)){
b.push(c);
}
}
return b;
}



function ObjectDefineProperties(a,b){
if(!(%_IsSpecObject(a))){
throw MakeTypeError("called_on_non_object",["Object.defineProperties"]);
}
var c=ToObject(b);
var d=GetOwnEnumerablePropertyNames(c);
var e=new InternalArray();
for(var f=0;f<d.length;f++){
e.push(ToPropertyDescriptor(c[d[f]]));
}
for(var f=0;f<d.length;f++){
DefineOwnProperty(a,d[f],e[f],true);
}
return a;
}



function ProxyFix(a){
var b=%GetHandler(a);
var c=CallTrap0(b,"fix",void 0);
if((typeof(c)==='undefined')){
throw MakeTypeError("handler_returned_undefined",[b,"fix"]);
}

if(%IsJSFunctionProxy(a)){
var d=%GetCallTrap(a);
var e=%GetConstructTrap(a);
var f=DelegateCallAndConstruct(d,e);
%Fix(a);
%SetCode(a,f);


var g=new $Object();
$Object.defineProperty(g,"constructor",
{value:a,writable:true,enumerable:false,configurable:true});

%FunctionSetPrototype(a,g);
a.length=0;
}else{
%Fix(a);
}
ObjectDefineProperties(a,c);
}



function ObjectSeal(a){
if(!(%_IsSpecObject(a))){
throw MakeTypeError("called_on_non_object",["Object.seal"]);
}
if(%IsJSProxy(a)){
ProxyFix(a);
}
var b=ObjectGetOwnPropertyNames(a);
for(var c=0;c<b.length;c++){
var d=b[c];
var e=GetOwnProperty(a,d);
if(e.isConfigurable()){
e.setConfigurable(false);
DefineOwnProperty(a,d,e,true);
}
}
%PreventExtensions(a);
return a;
}



function ObjectFreeze(a){
if(!(%_IsSpecObject(a))){
throw MakeTypeError("called_on_non_object",["Object.freeze"]);
}
if(%IsJSProxy(a)){
ProxyFix(a);
}
var b=ObjectGetOwnPropertyNames(a);
for(var c=0;c<b.length;c++){
var d=b[c];
var e=GetOwnProperty(a,d);
if(e.isWritable()||e.isConfigurable()){
if(IsDataDescriptor(e))e.setWritable(false);
e.setConfigurable(false);
DefineOwnProperty(a,d,e,true);
}
}
%PreventExtensions(a);
return a;
}



function ObjectPreventExtension(a){
if(!(%_IsSpecObject(a))){
throw MakeTypeError("called_on_non_object",["Object.preventExtension"]);
}
if(%IsJSProxy(a)){
ProxyFix(a);
}
%PreventExtensions(a);
return a;
}



function ObjectIsSealed(a){
if(!(%_IsSpecObject(a))){
throw MakeTypeError("called_on_non_object",["Object.isSealed"]);
}
if(%IsJSProxy(a)){
return false;
}
var b=ObjectGetOwnPropertyNames(a);
for(var c=0;c<b.length;c++){
var d=b[c];
var e=GetOwnProperty(a,d);
if(e.isConfigurable())return false;
}
if(!ObjectIsExtensible(a)){
return true;
}
return false;
}



function ObjectIsFrozen(a){
if(!(%_IsSpecObject(a))){
throw MakeTypeError("called_on_non_object",["Object.isFrozen"]);
}
if(%IsJSProxy(a)){
return false;
}
var b=ObjectGetOwnPropertyNames(a);
for(var c=0;c<b.length;c++){
var d=b[c];
var e=GetOwnProperty(a,d);
if(IsDataDescriptor(e)&&e.isWritable())return false;
if(e.isConfigurable())return false;
}
if(!ObjectIsExtensible(a)){
return true;
}
return false;
}



function ObjectIsExtensible(a){
if(!(%_IsSpecObject(a))){
throw MakeTypeError("called_on_non_object",["Object.isExtensible"]);
}
if(%IsJSProxy(a)){
return true;
}
return %IsExtensible(a);
}



function ObjectIs(a,b){
if(a===b){
return(a!==0)||(1/ a === 1 /b);
}else{
return(a!==a)&&(b!==b);
}
}


%SetCode($Object,function(a){
if(%_IsConstructCall()){
if(a==null)return this;
return ToObject(a);
}else{
if(a==null)return{};
return ToObject(a);
}
});

%SetExpectedNumberOfProperties($Object,4);




function SetUpObject(){
%CheckIsBootstrapping();

InstallFunctions($Object.prototype,2,$Array(
"toString",ObjectToString,
"toLocaleString",ObjectToLocaleString,
"valueOf",ObjectValueOf,
"hasOwnProperty",ObjectHasOwnProperty,
"isPrototypeOf",ObjectIsPrototypeOf,
"propertyIsEnumerable",ObjectPropertyIsEnumerable,
"__defineGetter__",ObjectDefineGetter,
"__lookupGetter__",ObjectLookupGetter,
"__defineSetter__",ObjectDefineSetter,
"__lookupSetter__",ObjectLookupSetter
));
InstallFunctions($Object,2,$Array(
"keys",ObjectKeys,
"create",ObjectCreate,
"defineProperty",ObjectDefineProperty,
"defineProperties",ObjectDefineProperties,
"freeze",ObjectFreeze,
"getPrototypeOf",ObjectGetPrototypeOf,
"getOwnPropertyDescriptor",ObjectGetOwnPropertyDescriptor,
"getOwnPropertyNames",ObjectGetOwnPropertyNames,
"is",ObjectIs,
"isExtensible",ObjectIsExtensible,
"isFrozen",ObjectIsFrozen,
"isSealed",ObjectIsSealed,
"preventExtensions",ObjectPreventExtension,
"seal",ObjectSeal
));
}

SetUpObject();




function BooleanToString(){


var a=this;
if(!(typeof(a)==='boolean')){
if(!(%_ClassOf(a)==='Boolean')){
throw new $TypeError('Boolean.prototype.toString is not generic');
}
a=%_ValueOf(a);
}
return a?'true':'false';
}


function BooleanValueOf(){


if(!(typeof(this)==='boolean')&&!(%_ClassOf(this)==='Boolean')){
throw new $TypeError('Boolean.prototype.valueOf is not generic');
}
return %_ValueOf(this);
}





function SetUpBoolean(){
%CheckIsBootstrapping();
InstallFunctions($Boolean.prototype,2,$Array(
"toString",BooleanToString,
"valueOf",BooleanValueOf
));
}

SetUpBoolean();






%SetCode($Number,function(a){
var b=%_ArgumentsLength()==0?0:ToNumber(a);
if(%_IsConstructCall()){
%_SetValueOf(this,b);
}else{
return b;
}
});

%FunctionSetPrototype($Number,new $Number(0));


function NumberToString(a){


var b=this;
if(!(typeof(this)==='number')){
if(!(%_ClassOf(this)==='Number')){
throw new $TypeError('Number.prototype.toString is not generic');
}

b=%_ValueOf(this);
}

if((typeof(a)==='undefined')||a===10){
return %_NumberToString(b);
}


a=(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a)));
if(a<2||a>36){
throw new $RangeError('toString() radix argument must be between 2 and 36');
}

return %NumberToRadixString(b,a);
}



function NumberToLocaleString(){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["Number.prototype.toLocaleString"]);
}
return this.toString();
}



function NumberValueOf(){


if(!(typeof(this)==='number')&&!(%_ClassOf(this)==='Number')){
throw new $TypeError('Number.prototype.valueOf is not generic');
}
return %_ValueOf(this);
}



function NumberToFixed(a){
var b=(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a)));
if(b<0||b>20){
throw new $RangeError("toFixed() digits argument must be between 0 and 20");
}
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["Number.prototype.toFixed"]);
}
var c=ToNumber(this);
return %NumberToFixed(c,b);
}



function NumberToExponential(a){
var b=-1;
if(!(typeof(a)==='undefined')){
b=(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a)));
if(b<0||b>20){
throw new $RangeError(
"toExponential() argument must be between 0 and 20");
}
}
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["Number.prototype.toExponential"]);
}
var c=ToNumber(this);
return %NumberToExponential(c,b);
}



function NumberToPrecision(a){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["Number.prototype.toPrecision"]);
}
if((typeof(a)==='undefined'))return ToString(%_ValueOf(this));
var b=(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a)));
if(b<1||b>21){
throw new $RangeError("toPrecision() argument must be between 1 and 21");
}
var c=ToNumber(this);
return %NumberToPrecision(c,b);
}



function NumberIsFinite(a){
return(typeof(a)==='number')&&(%_IsSmi(%IS_VAR(a))||((a==a)&&(a!=1/0)&&(a!=-1/0)));
}



function NumberIsNaN(a){
return(typeof(a)==='number')&&(!%_IsSmi(%IS_VAR(a))&&!(a==a));
}




function SetUpNumber(){
%CheckIsBootstrapping();
%OptimizeObjectForAddingMultipleProperties($Number.prototype,8);

%SetProperty($Number.prototype,"constructor",$Number,2);

%OptimizeObjectForAddingMultipleProperties($Number,5);

%SetProperty($Number,
"MAX_VALUE",
1.7976931348623157e+308,
2|4|1);


%SetProperty($Number,"MIN_VALUE",5e-324,
2|4|1);


%SetProperty($Number,"NaN",$NaN,2|4|1);


%SetProperty($Number,
"NEGATIVE_INFINITY",
-1/0,
2|4|1);


%SetProperty($Number,
"POSITIVE_INFINITY",
1/0,
2|4|1);
%ToFastProperties($Number);


InstallFunctions($Number.prototype,2,$Array(
"toString",NumberToString,
"toLocaleString",NumberToLocaleString,
"valueOf",NumberValueOf,
"toFixed",NumberToFixed,
"toExponential",NumberToExponential,
"toPrecision",NumberToPrecision
));
InstallFunctions($Number,2,$Array(
"isFinite",NumberIsFinite,
"isNaN",NumberIsNaN
));
}

SetUpNumber();





$Function.prototype.constructor=$Function;

function FunctionSourceString(a){
while(%IsJSFunctionProxy(a)){
a=%GetCallTrap(a);
}

if(!(%_IsFunction(a))){
throw new $TypeError('Function.prototype.toString is not generic');
}

var b=%FunctionGetSourceCode(a);
if(!(typeof(b)==='string')||%FunctionIsBuiltin(a)){
var c=%FunctionGetName(a);
if(c){

return'function '+c+'() { [native code] }';
}else{
return'function () { [native code] }';
}
}

var c=%FunctionNameShouldPrintAsAnonymous(a)
?'anonymous'
:%FunctionGetName(a);
return'function '+c+b;
}


function FunctionToString(){
return FunctionSourceString(this);
}



function FunctionBind(a){
if(!(%_ClassOf(this)==='Function')){
throw new $TypeError('Bind must be called on a function');
}
var b=function(){

"use strict";


if(%_IsConstructCall()){
return %NewObjectFromBound(b);
}
var c=%BoundFunctionGetBindings(b);

var d=%_ArgumentsLength();
if(d==0){
return %Apply(c[0],c[1],c,2,c.length-2);
}
if(c.length===2){
return %Apply(c[0],c[1],arguments,0,d);
}
var e=c.length-2;
var f=new InternalArray(e+d);
for(var g=0;g<e;g++){
f[g]=c[g+2];
}
for(var h=0;h<d;h++){
f[g++]=%_Arguments(h);
}
return %Apply(c[0],c[1],f,0,e+d);
};

%FunctionRemovePrototype(b);
var i=0;
if(%_ClassOf(this)=="Function"){

var j=this.length;

if((typeof j==="number")&&
((j>>>0)===j)){
var d=%_ArgumentsLength();
if(d>0)d--;
i=j-d;
if(i<0)i=0;
}
}


var k=%FunctionBindArguments(b,this,
a,i);








return k;
}


function NewFunction(a){
var b=%_ArgumentsLength();
var c='';
if(b>1){
c=new InternalArray(b-1);
for(var d=0;d<b-1;d++)c[d]=%_Arguments(d);
c=Join(c,b-1,',',NonStringToString);



if(c.indexOf(')')!=-1)throw MakeSyntaxError('unable_to_parse',[]);
}
var e=(b>0)?ToString(%_Arguments(b-1)):'';
var f='(function('+c+') {\n'+e+'\n})';



var g=%GlobalReceiver(global);
var h=%_CallFunction(g,%CompileString(f));

%FunctionMarkNameShouldPrintAsAnonymous(h);
return %SetNewFunctionAttributes(h);
}

%SetCode($Function,NewFunction);



function SetUpFunction(){
%CheckIsBootstrapping();
InstallFunctions($Function.prototype,2,$Array(
"bind",FunctionBind,
"toString",FunctionToString
));
}

SetUpFunction();




































var visited_arrays=new InternalArray();




function GetSortedArrayKeys(a,b){
var c=b.length;
var d=[];
for(var e=0;e<c;e++){
var f=b[e];
if(f<0){
var g=-1-f;
var h=g+b[++e];
for(;g<h;g++){
var i=a[g];
if(!(typeof(i)==='undefined')||g in a){
d.push(g);
}
}
}else{

if(!(typeof(f)==='undefined')){
var i=a[f];
if(!(typeof(i)==='undefined')||f in a){
d.push(f);
}
}
}
}
%_CallFunction(d,function(j,k){return j-k;},ArraySort);
return d;
}


function SparseJoinWithSeparator(a,b,c,d){
var e=GetSortedArrayKeys(a,%GetArrayKeys(a,b));
var f=0;
var g=new InternalArray(e.length*2);
var h=-1;
for(var i=0;i<e.length;i++){
var j=e[i];
if(j!=h){
var k=a[j];
if(!(typeof(k)==='string'))k=c(k);
g[i*2]=j;
g[i*2+1]=k;
h=j;
}
}
return %SparseJoinWithSeparator(g,b,d);
}



function SparseJoin(a,b,c){
var d=GetSortedArrayKeys(a,%GetArrayKeys(a,b));
var e=-1;
var f=d.length;

var g=new InternalArray(f);
var h=0;

for(var i=0;i<f;i++){
var j=d[i];
if(j!=e){
var k=a[j];
if(!(typeof(k)==='string'))k=c(k);
g[h++]=k;
e=j;
}
}
return %StringBuilderConcat(g,h,'');
}


function UseSparseVariant(a,b,c){
return c&&
b>1000&&
(!%_IsSmi(b)||
%EstimateNumberOfElements(a)<(b>>2));
}


function Join(a,b,c,d){
if(b==0)return'';

var e=(%_IsArray(a));

if(e){


if(!%PushIfAbsent(visited_arrays,a))return'';
}


try{
if(UseSparseVariant(a,b,e)){
if(c.length==0){
return SparseJoin(a,b,d);
}else{
return SparseJoinWithSeparator(a,b,d,c);
}
}


if(b==1){
var f=a[0];
if((typeof(f)==='string'))return f;
return d(f);
}


var g=new InternalArray(b);


if(c.length==0){
var h=0;
for(var i=0;i<b;i++){
var f=a[i];
if(!(typeof(f)==='string'))f=d(f);
g[h++]=f;
}
g.length=h;
var j=%_FastAsciiArrayJoin(g,'');
if(!(typeof(j)==='undefined'))return j;
return %StringBuilderConcat(g,h,'');
}



if(!(typeof(a[0])==='number')){
for(var i=0;i<b;i++){
var f=a[i];
if(!(typeof(f)==='string'))f=d(f);
g[i]=f;
}
}else{
for(var i=0;i<b;i++){
var f=a[i];
if((typeof(f)==='number')){
f=%_NumberToString(f);
}else if(!(typeof(f)==='string')){
f=d(f);
}
g[i]=f;
}
}
var j=%_FastAsciiArrayJoin(g,c);
if(!(typeof(j)==='undefined'))return j;

return %StringBuilderJoin(g,b,c);
}finally{


if(e)visited_arrays.length=visited_arrays.length-1;
}
}


function ConvertToString(a){

if((typeof(a)==='number'))return %_NumberToString(a);
if((typeof(a)==='boolean'))return a?'true':'false';
return((a==null))?'':%ToString(%DefaultString(a));
}


function ConvertToLocaleString(a){
if((a==null)){
return'';
}else{



var b=ToObject(a);
return %ToString(b.toLocaleString());
}
}




function SmartSlice(a,b,c,d,f){


var g=%GetArrayKeys(a,b+c);
var h=g.length;
for(var i=0;i<h;i++){
var j=g[i];
if(j<0){
var k=-1-j;
var l=k+g[++i];
if(k<b){
k=b;
}
for(;k<l;k++){




var m=a[k];
if(!(typeof(m)==='undefined')||k in a){
f[k-b]=m;
}
}
}else{
if(!(typeof(j)==='undefined')){
if(j>=b){




var m=a[j];
if(!(typeof(m)==='undefined')||j in a){
f[j-b]=m;
}
}
}
}
}
}




function SmartMove(a,b,c,d,f){

var g=new InternalArray(d-c+f);
var h=%GetArrayKeys(a,d);
var i=h.length;
for(var j=0;j<i;j++){
var k=h[j];
if(k<0){
var l=-1-k;
var m=l+h[++j];
while(l<b&&l<m){



var n=a[l];
if(!(typeof(n)==='undefined')||l in a){
g[l]=n;
}
l++;
}
l=b+c;
while(l<m){




var n=a[l];
if(!(typeof(n)==='undefined')||l in a){
g[l-c+f]=n;
}
l++;
}
}else{
if(!(typeof(k)==='undefined')){
if(k<b){



var n=a[k];
if(!(typeof(n)==='undefined')||k in a){
g[k]=n;
}
}else if(k>=b+c){




var n=a[k];
if(!(typeof(n)==='undefined')||k in a){
g[k-c+f]=n;
}
}
}
}
}

%MoveArrayContents(g,a);
}





function SimpleSlice(a,b,c,d,f){
for(var g=0;g<c;g++){
var h=b+g;



var i=a[h];
if(!(typeof(i)==='undefined')||h in a){
f[g]=i;
}
}
}


function SimpleMove(a,b,c,d,f){
if(f!==c){


if(f>c){
for(var g=d-c;g>b;g--){
var h=g+c-1;
var i=g+f-1;



var j=a[h];
if(!(typeof(j)==='undefined')||h in a){
a[i]=j;
}else{
delete a[i];
}
}
}else{
for(var g=b;g<d-c;g++){
var h=g+c;
var i=g+f;



var j=a[h];
if(!(typeof(j)==='undefined')||h in a){
a[i]=j;
}else{
delete a[i];
}
}
for(var g=d;g>d-c+f;g--){
delete a[g-1];
}
}
}
}





function ArrayToString(){
var a;
var b;
if((%_IsArray(this))){
b=this.join;
if(b===ArrayJoin){
return Join(this,this.length,',',ConvertToString);
}
a=this;
}else{
a=ToObject(this);
b=a.join;
}
if(!(%_ClassOf(b)==='Function')){
return %_CallFunction(a,ObjectToString);
}
return %_CallFunction(a,b);
}


function ArrayToLocaleString(){
var a=ToObject(this);
var b=a.length;
var c=(b>>>0);
if(c===0)return"";
return Join(a,c,',',ConvertToLocaleString);
}


function ArrayJoin(a){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["Array.prototype.join"]);
}

if((typeof(a)==='undefined')){
a=',';
}else if(!(typeof(a)==='string')){
a=NonStringToString(a);
}

var b=%_FastAsciiArrayJoin(this,a);
if(!(typeof(b)==='undefined'))return b;

return Join(this,(this.length>>>0),a,ConvertToString);
}




function ArrayPop(){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["Array.prototype.pop"]);
}

var a=(this.length>>>0);
if(a==0){
this.length=a;
return;
}
a--;
var b=this[a];
this.length=a;
delete this[a];
return b;
}




function ArrayPush(){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["Array.prototype.push"]);
}

var a=(this.length>>>0);
var b=%_ArgumentsLength();
for(var c=0;c<b;c++){
this[c+a]=%_Arguments(c);
}
this.length=a+b;
return this.length;
}





function ArrayConcat(a){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["Array.prototype.concat"]);
}

var b=ToObject(this);
var c=%_ArgumentsLength();
var d=new InternalArray(1+c);
d[0]=b;
for(var f=0;f<c;f++){
d[f+1]=%_Arguments(f);
}

return %ArrayConcat(d);
}



function SparseReverse(a,b){
var c=GetSortedArrayKeys(a,%GetArrayKeys(a,b));
var d=c.length-1;
var f=0;
while(f<=d){
var g=c[f];
var h=c[d];

var i=b-h-1;
var j,k;

if(i<=g){
k=h;
while(c[--d]==h){}
j=i;
}
if(i>=g){
j=g;
while(c[++f]==g){}
k=b-g-1;
}

var l=a[j];
if(!(typeof(l)==='undefined')||j in a){
var m=a[k];
if(!(typeof(m)==='undefined')||k in a){
a[j]=m;
a[k]=l;
}else{
a[k]=l;
delete a[j];
}
}else{
var m=a[k];
if(!(typeof(m)==='undefined')||k in a){
a[j]=m;
delete a[k];
}
}
}
}


function ArrayReverse(){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["Array.prototype.reverse"]);
}

var a=(this.length>>>0)-1;

if(UseSparseVariant(this,a,(%_IsArray(this)))){
SparseReverse(this,a+1);
return this;
}

for(var b=0;b<a;b++,a--){
var c=this[b];
if(!(typeof(c)==='undefined')||b in this){
var d=this[a];
if(!(typeof(d)==='undefined')||a in this){
this[b]=d;
this[a]=c;
}else{
this[a]=c;
delete this[b];
}
}else{
var d=this[a];
if(!(typeof(d)==='undefined')||a in this){
this[b]=d;
delete this[a];
}
}
}
return this;
}


function ArrayShift(){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["Array.prototype.shift"]);
}

var a=(this.length>>>0);

if(a===0){
this.length=0;
return;
}

var b=this[0];

if((%_IsArray(this))){
SmartMove(this,0,1,a,0);
}else{
SimpleMove(this,0,1,a,0);
}

this.length=a-1;

return b;
}


function ArrayUnshift(a){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["Array.prototype.unshift"]);
}

var b=(this.length>>>0);
var c=%_ArgumentsLength();

if((%_IsArray(this))){
SmartMove(this,0,0,b,c);
}else{
SimpleMove(this,0,0,b,c);
}

for(var d=0;d<c;d++){
this[d]=%_Arguments(d);
}

this.length=b+c;

return b+c;
}


function ArraySlice(a,b){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["Array.prototype.slice"]);
}

var c=(this.length>>>0);
var d=(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a)));
var f=c;

if(b!==void 0)f=(%_IsSmi(%IS_VAR(b))?b:%NumberToInteger(ToNumber(b)));

if(d<0){
d+=c;
if(d<0)d=0;
}else{
if(d>c)d=c;
}

if(f<0){
f+=c;
if(f<0)f=0;
}else{
if(f>c)f=c;
}

var g=[];

if(f<d)return g;

if((%_IsArray(this))&&
(f>1000)&&
(%EstimateNumberOfElements(this)<f)){
SmartSlice(this,d,f-d,c,g);
}else{
SimpleSlice(this,d,f-d,c,g);
}

g.length=f-d;

return g;
}


function ArraySplice(a,b){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["Array.prototype.splice"]);
}

var c=%_ArgumentsLength();

var d=(this.length>>>0);
var f=(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a)));

if(f<0){
f+=d;
if(f<0)f=0;
}else{
if(f>d)f=d;
}






var g=0;
if(c==1){
g=d-f;
}else{
g=(%_IsSmi(%IS_VAR(b))?b:%NumberToInteger(ToNumber(b)));
if(g<0)g=0;
if(g>d-f)g=d-f;
}

var h=[];
h.length=g;


var i=0;
if(c>2){
i=c-2;
}

var j=true;

if((%_IsArray(this))&&i!==g){



var k=%EstimateNumberOfElements(this);
if(d>20&&(k>>2)<(d-f)){
j=false;
}
}

if(j){
SimpleSlice(this,f,g,d,h);
SimpleMove(this,f,g,d,i);
}else{
SmartSlice(this,f,g,d,h);
SmartMove(this,f,g,d,i);
}



var l=f;
var m=2;
var n=%_ArgumentsLength();
while(m<n){
this[l++]=%_Arguments(m++);
}
this.length=d-g+i;


return h;
}


function ArraySort(a){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["Array.prototype.sort"]);
}




if(!(%_ClassOf(a)==='Function')){
a=function(b,c){
if(b===c)return 0;
if(%_IsSmi(b)&&%_IsSmi(c)){
return %SmiLexicographicCompare(b,c);
}
b=ToString(b);
c=ToString(c);
if(b==c)return 0;
else return b<c?-1:1;
};
}
var d=%GetDefaultReceiver(a);

var f=function InsertionSort(g,h,i){
for(var j=h+1;j<i;j++){
var k=g[j];
for(var l=j-1;l>=h;l--){
var m=g[l];
var n=%_CallFunction(d,m,k,a);
if(n>0){
g[l+1]=m;
}else{
break;
}
}
g[l+1]=k;
}
};

var o=function(g,h,i){
var q=[];

var r=200+((i-h)&15);
for(var j=h+1;j<i-1;j+=r){
q.push([j,g[j]]);
}
q.sort(function(g,s){
return %_CallFunction(d,g[1],s[1],a)});
var t=q[q.length>>1][0];
return t;
}

var u=function QuickSort(g,h,i){
var t=0;
while(true){

if(i-h<=10){
f(g,h,i);
return;
}
if(i-h>1000){
t=o(g,h,i);
}else{
t=h+((i-h)>>1);
}

var w=g[h];
var z=g[i-1];
var A=g[t];
var B=%_CallFunction(d,w,z,a);
if(B>0){

var m=w;
w=z;
z=m;
}
var C=%_CallFunction(d,w,A,a);
if(C>=0){

var m=w;
w=A;
A=z;
z=m;
}else{

var D=%_CallFunction(d,z,A,a);
if(D>0){

var m=z;
z=A;
A=m;
}
}

g[h]=w;
g[i-1]=A;
var E=z;
var G=h+1;
var H=i-1;
g[t]=g[G];
g[G]=E;



partition:for(var j=G+1;j<H;j++){
var k=g[j];
var n=%_CallFunction(d,k,E,a);
if(n<0){
g[j]=g[G];
g[G]=k;
G++;
}else if(n>0){
do{
H--;
if(H==j)break partition;
var I=g[H];
n=%_CallFunction(d,I,E,a);
}while(n>0);
g[j]=g[H];
g[H]=k;
if(n<0){
k=g[j];
g[j]=g[G];
g[G]=k;
G++;
}
}
}
if(i-H<G-h){
u(g,H,i);
i=G;
}else{
u(g,h,G);
h=H;
}
}
};




var J=function CopyFromPrototype(K,L){
var M=0;
for(var N=K.__proto__;N;N=N.__proto__){
var O=%GetArrayKeys(N,L);
if(O.length>0){
if(O[0]==-1){

var P=O[1];
for(var j=0;j<P;j++){
if(!K.hasOwnProperty(j)&&N.hasOwnProperty(j)){
K[j]=N[j];
if(j>=M){M=j+1;}
}
}
}else{
for(var j=0;j<O.length;j++){
var Q=O[j];
if(!(typeof(Q)==='undefined')&&
!K.hasOwnProperty(Q)&&N.hasOwnProperty(Q)){
K[Q]=N[Q];
if(Q>=M){M=Q+1;}
}
}
}
}
}
return M;
};




var R=function(K,h,i){
for(var N=K.__proto__;N;N=N.__proto__){
var O=%GetArrayKeys(N,i);
if(O.length>0){
if(O[0]==-1){

var P=O[1];
for(var j=h;j<P;j++){
if(N.hasOwnProperty(j)){
K[j]=void 0;
}
}
}else{
for(var j=0;j<O.length;j++){
var Q=O[j];
if(!(typeof(Q)==='undefined')&&h<=Q&&
N.hasOwnProperty(Q)){
K[Q]=void 0;
}
}
}
}
}
};

var S=function SafeRemoveArrayHoles(K){



var T=0;
var U=L-1;
var W=0;
while(T<U){

while(T<U&&
!(typeof(K[T])==='undefined')){
T++;
}


if(!K.hasOwnProperty(T)){
W++;
}


while(T<U&&
(typeof(K[U])==='undefined')){
if(!K.hasOwnProperty(U)){
W++;
}
U--;
}
if(T<U){

K[T]=K[U];
K[U]=void 0;
}
}




if(!(typeof(K[T])==='undefined'))T++;


var j;
for(j=T;j<L-W;j++){
K[j]=void 0;
}
for(j=L-W;j<L;j++){

if(j in K.__proto__){
K[j]=void 0;
}else{
delete K[j];
}
}


return T;
};

var L=(this.length>>>0);
if(L<2)return this;

var X=(%_IsArray(this));
var Y;
if(!X){








Y=J(this,L);
}

var Z=%RemoveArrayHoles(this,L);
if(Z==-1){



Z=S(this);
}

u(this,0,Z);

if(!X&&(Z+1<Y)){


R(this,Z,Y);
}

return this;
}





function ArrayFilter(a,b){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["Array.prototype.filter"]);
}



var c=ToObject(this);
var d=ToUint32(c.length);

if(!(%_ClassOf(a)==='Function')){
throw MakeTypeError('called_non_callable',[a]);
}
if((b==null)){
b=%GetDefaultReceiver(a)||b;
}else if(!(%_IsSpecObject(b))){
b=ToObject(b);
}

var g=new $Array();
var h=new InternalArray();
var i=0;
if(%DebugCallbackSupportsStepping(a)){
for(var j=0;j<d;j++){
if(j in c){
var k=c[j];

%DebugPrepareStepInIfStepping(a);
if(%_CallFunction(b,k,j,c,a)){
h[i++]=k;
}
}
}
}else{

for(var j=0;j<d;j++){
if(j in c){
var k=c[j];
if(%_CallFunction(b,k,j,c,a)){
h[i++]=k;
}
}
}

}
%MoveArrayContents(h,g);
return g;
}


function ArrayForEach(a,b){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["Array.prototype.forEach"]);
}



var c=ToObject(this);
var d=(c.length>>>0);

if(!(%_ClassOf(a)==='Function')){
throw MakeTypeError('called_non_callable',[a]);
}
if((b==null)){
b=%GetDefaultReceiver(a)||b;
}else if(!(%_IsSpecObject(b))){
b=ToObject(b);
}
if(%DebugCallbackSupportsStepping(a)){
for(var g=0;g<d;g++){
if(g in c){
var h=c[g];

%DebugPrepareStepInIfStepping(a);
%_CallFunction(b,h,g,c,a);
}
}
}else{

for(var g=0;g<d;g++){
if(g in c){
var h=c[g];
%_CallFunction(b,h,g,c,a);
}
}

}
}




function ArraySome(a,b){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["Array.prototype.some"]);
}



var c=ToObject(this);
var d=(c.length>>>0);

if(!(%_ClassOf(a)==='Function')){
throw MakeTypeError('called_non_callable',[a]);
}
if((b==null)){
b=%GetDefaultReceiver(a)||b;
}else if(!(%_IsSpecObject(b))){
b=ToObject(b);
}

if(%DebugCallbackSupportsStepping(a)){
for(var g=0;g<d;g++){
if(g in c){
var h=c[g];

%DebugPrepareStepInIfStepping(a);
if(%_CallFunction(b,h,g,c,a))return true;
}
}
}else{

for(var g=0;g<d;g++){
if(g in c){
var h=c[g];
if(%_CallFunction(b,h,g,c,a))return true;
}
}

}
return false;
}


function ArrayEvery(a,b){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["Array.prototype.every"]);
}



var c=ToObject(this);
var d=(c.length>>>0);

if(!(%_ClassOf(a)==='Function')){
throw MakeTypeError('called_non_callable',[a]);
}
if((b==null)){
b=%GetDefaultReceiver(a)||b;
}else if(!(%_IsSpecObject(b))){
b=ToObject(b);
}

if(%DebugCallbackSupportsStepping(a)){
for(var g=0;g<d;g++){
if(g in c){
var h=c[g];

%DebugPrepareStepInIfStepping(a);
if(!%_CallFunction(b,h,g,c,a))return false;
}
}
}else{

for(var g=0;g<d;g++){
if(g in c){
var h=c[g];
if(!%_CallFunction(b,h,g,c,a))return false;
}
}

}
return true;
}

function ArrayMap(a,b){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["Array.prototype.map"]);
}



var c=ToObject(this);
var d=(c.length>>>0);

if(!(%_ClassOf(a)==='Function')){
throw MakeTypeError('called_non_callable',[a]);
}
if((b==null)){
b=%GetDefaultReceiver(a)||b;
}else if(!(%_IsSpecObject(b))){
b=ToObject(b);
}

var g=new $Array();
var h=new InternalArray(d);
if(%DebugCallbackSupportsStepping(a)){
for(var i=0;i<d;i++){
if(i in c){
var j=c[i];

%DebugPrepareStepInIfStepping(a);
h[i]=%_CallFunction(b,j,i,c,a);
}
}
}else{

for(var i=0;i<d;i++){
if(i in c){
var j=c[i];
h[i]=%_CallFunction(b,j,i,c,a);
}
}

}
%MoveArrayContents(h,g);
return g;
}


function ArrayIndexOf(a,b){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["Array.prototype.indexOf"]);
}

var c=(this.length>>>0);
if(c==0)return-1;
if((typeof(b)==='undefined')){
b=0;
}else{
b=(%_IsSmi(%IS_VAR(b))?b:%NumberToInteger(ToNumber(b)));

if(b<0){
b=c+b;

if(b<0)b=0;
}
}
var d=b;
var g=c;
if(UseSparseVariant(this,c,(%_IsArray(this)))){
var h=%GetArrayKeys(this,c);
if(h.length==2&&h[0]<0){

var i=-(h[0]+1);
var j=i+h[1];
if(d<i)d=i;
g=j;

}else{
if(h.length==0)return-1;

var k=GetSortedArrayKeys(this,h);
var l=k.length;
var m=0;
while(m<l&&k[m]<b)m++;
while(m<l){
var n=k[m];
if(!(typeof(n)==='undefined')&&this[n]===a)return n;
m++;
}
return-1;
}
}

if(!(typeof(a)==='undefined')){
for(var m=d;m<g;m++){
if(this[m]===a)return m;
}
return-1;
}

for(var m=d;m<g;m++){
if((typeof(this[m])==='undefined')&&m in this){
return m;
}
}
return-1;
}


function ArrayLastIndexOf(a,b){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["Array.prototype.lastIndexOf"]);
}

var c=(this.length>>>0);
if(c==0)return-1;
if(%_ArgumentsLength()<2){
b=c-1;
}else{
b=(%_IsSmi(%IS_VAR(b))?b:%NumberToInteger(ToNumber(b)));

if(b<0)b+=c;

if(b<0)return-1;
else if(b>=c)b=c-1;
}
var d=0;
var g=b;
if(UseSparseVariant(this,c,(%_IsArray(this)))){
var h=%GetArrayKeys(this,b+1);
if(h.length==2&&h[0]<0){

var i=-(h[0]+1);
var j=i+h[1];
if(d<i)d=i;
g=j;

}else{
if(h.length==0)return-1;

var k=GetSortedArrayKeys(this,h);
var l=k.length-1;
while(l>=0){
var m=k[l];
if(!(typeof(m)==='undefined')&&this[m]===a)return m;
l--;
}
return-1;
}
}

if(!(typeof(a)==='undefined')){
for(var l=g;l>=d;l--){
if(this[l]===a)return l;
}
return-1;
}
for(var l=g;l>=d;l--){
if((typeof(this[l])==='undefined')&&l in this){
return l;
}
}
return-1;
}


function ArrayReduce(a,b){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["Array.prototype.reduce"]);
}



var c=ToObject(this);
var d=ToUint32(c.length);

if(!(%_ClassOf(a)==='Function')){
throw MakeTypeError('called_non_callable',[a]);
}

var g=0;
find_initial:if(%_ArgumentsLength()<2){
for(;g<d;g++){
b=c[g];
if(!(typeof(b)==='undefined')||g in c){
g++;
break find_initial;
}
}
throw MakeTypeError('reduce_no_initial',[]);
}

var h=%GetDefaultReceiver(a);

if(%DebugCallbackSupportsStepping(a)){
for(;g<d;g++){
if(g in c){
var i=c[g];

%DebugPrepareStepInIfStepping(a);
b=
%_CallFunction(h,b,i,g,c,a);
}
}
}else{

for(;g<d;g++){
if(g in c){
var i=c[g];
b=
%_CallFunction(h,b,i,g,c,a);
}
}

}
return b;
}

function ArrayReduceRight(a,b){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["Array.prototype.reduceRight"]);
}



var c=ToObject(this);
var d=ToUint32(c.length);

if(!(%_ClassOf(a)==='Function')){
throw MakeTypeError('called_non_callable',[a]);
}

var g=d-1;
find_initial:if(%_ArgumentsLength()<2){
for(;g>=0;g--){
b=c[g];
if(!(typeof(b)==='undefined')||g in c){
g--;
break find_initial;
}
}
throw MakeTypeError('reduce_no_initial',[]);
}

var h=%GetDefaultReceiver(a);

if(%DebugCallbackSupportsStepping(a)){
for(;g>=0;g--){
if(g in c){
var i=c[g];

%DebugPrepareStepInIfStepping(a);
b=
%_CallFunction(h,b,i,g,c,a);
}
}
}else{

for(;g>=0;g--){
if(g in c){
var i=c[g];
b=
%_CallFunction(h,b,i,g,c,a);
}
}

}
return b;
}


function ArrayIsArray(a){
return(%_IsArray(a));
}



function SetUpArray(){
%CheckIsBootstrapping();


%SetProperty($Array.prototype,"constructor",$Array,2);


InstallFunctions($Array,2,$Array(
"isArray",ArrayIsArray
));

var a=%SpecialArrayFunctions({});

var b=function(c,d,g){
var h=d;
if(a.hasOwnProperty(c)){
h=a[c];
}
if(!(typeof(g)==='undefined')){
%FunctionSetLength(h,g);
}
return h;
};





InstallFunctions($Array.prototype,2,$Array(
"toString",b("toString",ArrayToString),
"toLocaleString",b("toLocaleString",ArrayToLocaleString),
"join",b("join",ArrayJoin),
"pop",b("pop",ArrayPop),
"push",b("push",ArrayPush,1),
"concat",b("concat",ArrayConcat,1),
"reverse",b("reverse",ArrayReverse),
"shift",b("shift",ArrayShift),
"unshift",b("unshift",ArrayUnshift,1),
"slice",b("slice",ArraySlice,2),
"splice",b("splice",ArraySplice,2),
"sort",b("sort",ArraySort),
"filter",b("filter",ArrayFilter,1),
"forEach",b("forEach",ArrayForEach,1),
"some",b("some",ArraySome,1),
"every",b("every",ArrayEvery,1),
"map",b("map",ArrayMap,1),
"indexOf",b("indexOf",ArrayIndexOf,1),
"lastIndexOf",b("lastIndexOf",ArrayLastIndexOf,1),
"reduce",b("reduce",ArrayReduce,1),
"reduceRight",b("reduceRight",ArrayReduceRight,1)
));

%FinishArrayPrototypeSetup($Array.prototype);




SetUpLockedPrototype(InternalArray,$Array(),$Array(
"join",b("join",ArrayJoin),
"pop",b("pop",ArrayPop),
"push",b("push",ArrayPush)
));
}

SetUpArray();




































%SetCode($String,function(a){
var b=%_ArgumentsLength()==0?'':((typeof(%IS_VAR(a))==='string')?a:NonStringToString(a));
if(%_IsConstructCall()){
%_SetValueOf(this,b);
}else{
return b;
}
});

%FunctionSetPrototype($String,new $String());


function StringToString(){
if(!(typeof(this)==='string')&&!(%_ClassOf(this)==='String')){
throw new $TypeError('String.prototype.toString is not generic');
}
return %_ValueOf(this);
}



function StringValueOf(){
if(!(typeof(this)==='string')&&!(%_ClassOf(this)==='String')){
throw new $TypeError('String.prototype.valueOf is not generic');
}
return %_ValueOf(this);
}



function StringCharAt(a){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["String.prototype.charAt"]);
}
var b=%_StringCharAt(this,a);
if(%_IsSmi(b)){
b=%_StringCharAt(((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)),(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a))));
}
return b;
}



function StringCharCodeAt(a){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["String.prototype.charCodeAt"]);
}
var b=%_StringCharCodeAt(this,a);
if(!%_IsSmi(b)){
b=%_StringCharCodeAt(((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)),(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a))));
}
return b;
}



function StringConcat(){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["String.prototype.concat"]);
}
var a=%_ArgumentsLength();
var b=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this));
if(a===1){
return b+%_Arguments(0);
}
var c=new InternalArray(a+1);
c[0]=b;
for(var d=0;d<a;d++){
var g=%_Arguments(d);
c[d+1]=((typeof(%IS_VAR(g))==='string')?g:NonStringToString(g));
}
return %StringBuilderConcat(c,a+1,"");
}


%FunctionSetLength(StringConcat,1);



function StringIndexOf(a){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["String.prototype.indexOf"]);
}
var b=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this));
a=((typeof(%IS_VAR(a))==='string')?a:NonStringToString(a));
var c=0;
if(%_ArgumentsLength()>1){
c=%_Arguments(1);
c=(%_IsSmi(%IS_VAR(c))?c:%NumberToInteger(ToNumber(c)));
if(c<0)c=0;
if(c>b.length)c=b.length;
}
return %StringIndexOf(b,a,c);
}



function StringLastIndexOf(a){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["String.prototype.lastIndexOf"]);
}
var b=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this));
var c=b.length;
var a=((typeof(%IS_VAR(a))==='string')?a:NonStringToString(a));
var d=a.length;
var g=c-d;
if(%_ArgumentsLength()>1){
var h=ToNumber(%_Arguments(1));
if(!(!%_IsSmi(%IS_VAR(h))&&!(h==h))){
h=(%_IsSmi(%IS_VAR(h))?h:%NumberToInteger(ToNumber(h)));
if(h<0){
h=0;
}
if(h+d<c){
g=h;
}
}
}
if(g<0){
return-1;
}
return %StringLastIndexOf(b,a,g);
}






function StringLocaleCompare(a){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["String.prototype.localeCompare"]);
}
if(%_ArgumentsLength()===0)return 0;
return %StringLocaleCompare(((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)),
((typeof(%IS_VAR(a))==='string')?a:NonStringToString(a)));
}



function StringMatch(a){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["String.prototype.match"]);
}
var b=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this));
if((%_IsRegExp(a))){
if(!a.global)return RegExpExecNoTests(a,b,0);
%_Log('regexp','regexp-match,%0S,%1r',[b,a]);

var c=%StringMatch(b,a,lastMatchInfo);
if(c!==null)lastMatchInfoOverride=null;
return c;
}

a=new $RegExp(a);
return RegExpExecNoTests(a,b,0);
}





function SubString(a,b,c){

if(b+1==c)return %_StringCharAt(a,b);
return %_SubString(a,b,c);
}







var reusableMatchInfo=[2,"","",-1,-1];



function StringReplace(a,b){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["String.prototype.replace"]);
}
var c=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this));


if((%_IsRegExp(a))){
%_Log('regexp','regexp-replace,%0r,%1S',[a,c]);
if((%_ClassOf(b)==='Function')){
if(a.global){
return StringReplaceGlobalRegExpWithFunction(c,a,b);
}else{
return StringReplaceNonGlobalRegExpWithFunction(c,
a,
b);
}
}else{
if(lastMatchInfoOverride==null){
return %StringReplaceRegExpWithString(c,
a,
((typeof(%IS_VAR(b))==='string')?b:NonStringToString(b)),
lastMatchInfo);
}else{



var d=lastMatchInfo[1];
lastMatchInfo[1]=0;
var g=%StringReplaceRegExpWithString(c,
a,
((typeof(%IS_VAR(b))==='string')?b:NonStringToString(b)),
lastMatchInfo);
if(%_IsSmi(lastMatchInfo[1])){
lastMatchInfo[1]=d;
}else{
lastMatchInfoOverride=null;
}
return g;
}
}
}


a=((typeof(%IS_VAR(a))==='string')?a:NonStringToString(a));
if(a.length==1&&
c.length>0xFF&&
(typeof(b)==='string')&&
%StringIndexOf(b,'$',0)<0){



return %StringReplaceOneCharWithString(c,a,b);
}
var h=%StringIndexOf(c,a,0);
if(h<0)return c;
var i=h+a.length;

var j=SubString(c,0,h);


if((%_ClassOf(b)==='Function')){
var k=%GetDefaultReceiver(b);
j+=%_CallFunction(k,a,h,c,b);
}else{
reusableMatchInfo[3]=h;
reusableMatchInfo[4]=i;
b=((typeof(%IS_VAR(b))==='string')?b:NonStringToString(b));
j=ExpandReplacement(b,c,reusableMatchInfo,j);
}

return j+SubString(c,i,c.length);
}




function ExpandReplacement(a,b,c,d){
var g=a.length;
var h=%StringIndexOf(a,'$',0);
if(h<0){
if(g>0)d+=a;
return d;
}

if(h>0)d+=SubString(a,0,h);

while(true){
var i='$';
var j=h+1;
if(j<g){
var k=%_StringCharCodeAt(a,j);
if(k==36){
++j;
d+='$';
}else if(k==38){
++j;
d+=SubString(b,c[3],c[4]);
}else if(k==96){
++j;
d+=SubString(b,0,c[3]);
}else if(k==39){
++j;
d+=SubString(b,c[4],b.length);
}else{
d+='$';
}
}else{
d+='$';
}


h=%StringIndexOf(a,'$',j);



if(h<0){
if(j<g){
d+=SubString(a,j,g);
}
return d;
}


if(h>j){
d+=SubString(a,j,h);
}
}
return d;
}



function CaptureString(a,b,c){

var d=c<<1;

var g=b[(3+(d))];

if(g<0)return;
var h=b[(3+(d+1))];
return SubString(a,g,h);
}





var reusableReplaceArray=new InternalArray(16);



function StringReplaceGlobalRegExpWithFunction(a,b,c){
var d=reusableReplaceArray;
if(d){
reusableReplaceArray=null;
}else{




d=new InternalArray(16);
}
var g=%RegExpExecMultiple(b,
a,
lastMatchInfo,
d);
b.lastIndex=0;
if((g===null)){

reusableReplaceArray=d;
return a;
}
var h=g.length;
if(((lastMatchInfo)[0])==2){






var i=0;
var j=new InternalArray(null,0,a);
var k=%GetDefaultReceiver(c);
for(var l=0;l<h;l++){
var m=g[l];
if(%_IsSmi(m)){



if(m>0){
i=(m>>11)+(m&0x7ff);
}else{
i=g[++l]-m;
}
}else{
j[0]=m;
j[1]=i;
lastMatchInfoOverride=j;
var n=
%_CallFunction(k,m,i,a,c);


g[l]=((typeof(%IS_VAR(n))==='string')?n:NonStringToString(n));
i+=m.length;
}
}
}else{
var k=%GetDefaultReceiver(c);
for(var l=0;l<h;l++){
var m=g[l];
if(!%_IsSmi(m)){


lastMatchInfoOverride=m;
var n=%Apply(c,k,m,0,m.length);


g[l]=((typeof(%IS_VAR(n))==='string')?n:NonStringToString(n));
}
}
}
var o=new ReplaceResultBuilder(a,g);
var q=o.generate();
d.length=0;
reusableReplaceArray=d;
return q;
}


function StringReplaceNonGlobalRegExpWithFunction(a,b,c){
var d=DoRegExpExec(b,a,0);
if((d===null))return a;
var g=d[3];
var h=SubString(a,0,g);
var i=d[4];



var j=((d)[0])>>1;
var k;
var l=%GetDefaultReceiver(c);
if(j==1){

var m=SubString(a,g,i);

k=%_CallFunction(l,m,g,a,c);
}else{
var n=new InternalArray(j+2);
for(var o=0;o<j;o++){
n[o]=CaptureString(a,d,o);
}
n[o]=g;
n[o+1]=a;

k=%Apply(c,l,n,0,o+2);
}

h+=k;


return h+SubString(a,i,a.length);
}



function StringSearch(a){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["String.prototype.search"]);
}
var b;
if((typeof(a)==='string')){
b=%_GetFromCache(0,a);
}else if((%_IsRegExp(a))){
b=a;
}else{
b=new $RegExp(a);
}
var c=DoRegExpExec(b,((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)),0);
if(c){
return c[3];
}
return-1;
}



function StringSlice(a,b){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["String.prototype.slice"]);
}
var c=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this));
var d=c.length;
var g=(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a)));
var h=d;
if(b!==void 0){
h=(%_IsSmi(%IS_VAR(b))?b:%NumberToInteger(ToNumber(b)));
}

if(g<0){
g+=d;
if(g<0){
g=0;
}
}else{
if(g>d){
return'';
}
}

if(h<0){
h+=d;
if(h<0){
return'';
}
}else{
if(h>d){
h=d;
}
}

if(h<=g){
return'';
}

return SubString(c,g,h);
}



function StringSplit(a,b){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["String.prototype.split"]);
}
var c=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this));
b=((typeof(b)==='undefined'))?0xffffffff:(b>>>0);



if((typeof(a)==='undefined')){
return[c];
}

var d=c.length;
if(!(%_IsRegExp(a))){
a=((typeof(%IS_VAR(a))==='string')?a:NonStringToString(a));

if(b===0)return[];

var g=a.length;


if(g===0)return %StringToArray(c,b);

var h=%StringSplit(c,a,b);

return h;
}

if(b===0)return[];


return StringSplitOnRegExp(c,a,b,d);
}


function StringSplitOnRegExp(a,b,c,d){
%_Log('regexp','regexp-split,%0S,%1r',[a,b]);

if(d===0){
if(DoRegExpExec(b,a,0,0)!=null){
return[];
}
return[a];
}

var g=0;
var h=0;
var i=0;
var j=[];

outer_loop:
while(true){

if(h===d){
j.push(SubString(a,g,d));
break;
}

var k=DoRegExpExec(b,a,h);
if(k==null||d===(i=k[3])){
j.push(SubString(a,g,d));
break;
}
var l=k[4];


if(h===l&&l===g){
h++;
continue;
}

if(g+1==i){
j.push(%_StringCharAt(a,g));
}else{
j.push(%_SubString(a,g,i));
}

if(j.length===c)break;

var m=((k)[0])+3;
for(var n=3+2;n<m;){
var o=k[n++];
var q=k[n++];
if(q!=-1){
if(o+1==q){
j.push(%_StringCharAt(a,o));
}else{
j.push(%_SubString(a,o,q));
}
}else{
j.push(void 0);
}
if(j.length===c)break outer_loop;
}

h=g=l;
}
return j;
}



function StringSubstring(a,b){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["String.prototype.subString"]);
}
var c=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this));
var d=c.length;

var g=(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a)));
if(g<0){
g=0;
}else if(g>d){
g=d;
}

var h=d;
if(!(typeof(b)==='undefined')){
h=(%_IsSmi(%IS_VAR(b))?b:%NumberToInteger(ToNumber(b)));
if(h>d){
h=d;
}else{
if(h<0)h=0;
if(g>h){
var i=h;
h=g;
g=i;
}
}
}

return((g+1==h)
?%_StringCharAt(c,g)
:%_SubString(c,g,h));
}



function StringSubstr(a,b){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["String.prototype.substr"]);
}
var c=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this));
var d;



if(b===void 0){
d=c.length;
}else{
d=(%_IsSmi(%IS_VAR(b))?b:%NumberToInteger(ToNumber(b)));
if(d<=0)return'';
}



if(a===void 0){
a=0;
}else{
a=(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a)));


if(a>=c.length)return'';


if(a<0){
a+=c.length;
if(a<0)a=0;
}
}

var g=a+d;
if(g>c.length)g=c.length;

return((a+1==g)
?%_StringCharAt(c,a)
:%_SubString(c,a,g));
}



function StringToLowerCase(){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["String.prototype.toLowerCase"]);
}
return %StringToLowerCase(((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)));
}



function StringToLocaleLowerCase(){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["String.prototype.toLocaleLowerCase"]);
}
return %StringToLowerCase(((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)));
}



function StringToUpperCase(){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["String.prototype.toUpperCase"]);
}
return %StringToUpperCase(((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)));
}



function StringToLocaleUpperCase(){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["String.prototype.toLocaleUpperCase"]);
}
return %StringToUpperCase(((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)));
}


function StringTrim(){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["String.prototype.trim"]);
}
return %StringTrim(((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)),true,true);
}

function StringTrimLeft(){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["String.prototype.trimLeft"]);
}
return %StringTrim(((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)),true,false);
}

function StringTrimRight(){
if((this==null)&&!(%_IsUndetectableObject(this))){
throw MakeTypeError("called_on_null_or_undefined",
["String.prototype.trimRight"]);
}
return %StringTrim(((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)),false,true);
}

var static_charcode_array=new InternalArray(4);


function StringFromCharCode(a){
var b=%_ArgumentsLength();
if(b==1){
if(!%_IsSmi(a))a=ToNumber(a);
return %_StringCharFromCode(a&0xffff);
}




var c=static_charcode_array;
for(var d=0;d<b;d++){
var a=%_Arguments(d);
if(!%_IsSmi(a))a=ToNumber(a);
c[d]=a;
}
c.length=b;
return %StringFromCharCodeArray(c);
}



function HtmlEscape(a){
return((typeof(%IS_VAR(a))==='string')?a:NonStringToString(a)).replace(/</g,"&lt;")
.replace(/>/g,"&gt;")
.replace(/"/g,"&quot;")
.replace(/'/g,"&#039;");
}




function StringLink(a){
return"<a href=\""+HtmlEscape(a)+"\">"+this+"</a>";
}


function StringAnchor(a){
return"<a name=\""+HtmlEscape(a)+"\">"+this+"</a>";
}


function StringFontcolor(a){
return"<font color=\""+HtmlEscape(a)+"\">"+this+"</font>";
}


function StringFontsize(a){
return"<font size=\""+HtmlEscape(a)+"\">"+this+"</font>";
}


function StringBig(){
return"<big>"+this+"</big>";
}


function StringBlink(){
return"<blink>"+this+"</blink>";
}


function StringBold(){
return"<b>"+this+"</b>";
}


function StringFixed(){
return"<tt>"+this+"</tt>";
}


function StringItalics(){
return"<i>"+this+"</i>";
}


function StringSmall(){
return"<small>"+this+"</small>";
}


function StringStrike(){
return"<strike>"+this+"</strike>";
}


function StringSub(){
return"<sub>"+this+"</sub>";
}


function StringSup(){
return"<sup>"+this+"</sup>";
}



function ReplaceResultBuilder(a){
if(%_ArgumentsLength()>1){
this.elements=%_Arguments(1);
}else{
this.elements=new InternalArray();
}
this.special_string=a;
}

SetUpLockedPrototype(ReplaceResultBuilder,
$Array("elements","special_string"),$Array(
"add",function(a){
a=((typeof(%IS_VAR(a))==='string')?a:NonStringToString(a));
if(a.length>0)this.elements.push(a);
},
"addSpecialSlice",function(a,b){
var c=b-a;
if(a<0||c<=0)return;
if(a<0x80000&&c<0x800){
this.elements.push((a<<11)|c);
}else{


var d=this.elements;
d.push(-c);
d.push(a);
}
},
"generate",function(){
var a=this.elements;
return %StringBuilderConcat(a,a.length,this.special_string);
}
));




function SetUpString(){
%CheckIsBootstrapping();

%SetProperty($String.prototype,"constructor",$String,2);



InstallFunctions($String,2,$Array(
"fromCharCode",StringFromCharCode
));



InstallFunctions($String.prototype,2,$Array(
"valueOf",StringValueOf,
"toString",StringToString,
"charAt",StringCharAt,
"charCodeAt",StringCharCodeAt,
"concat",StringConcat,
"indexOf",StringIndexOf,
"lastIndexOf",StringLastIndexOf,
"localeCompare",StringLocaleCompare,
"match",StringMatch,
"replace",StringReplace,
"search",StringSearch,
"slice",StringSlice,
"split",StringSplit,
"substring",StringSubstring,
"substr",StringSubstr,
"toLowerCase",StringToLowerCase,
"toLocaleLowerCase",StringToLocaleLowerCase,
"toUpperCase",StringToUpperCase,
"toLocaleUpperCase",StringToLocaleUpperCase,
"trim",StringTrim,
"trimLeft",StringTrimLeft,
"trimRight",StringTrimRight,
"link",StringLink,
"anchor",StringAnchor,
"fontcolor",StringFontcolor,
"fontsize",StringFontsize,
"big",StringBig,
"blink",StringBlink,
"bold",StringBold,
"fixed",StringFixed,
"italics",StringItalics,
"small",StringSmall,
"strike",StringStrike,
"sub",StringSub,
"sup",StringSup
));
}

SetUpString();


































var hexCharArray=0;
var hexCharCodeArray=0;


function URIAddEncodedOctetToBuffer(a,b,c){
b[c++]=37;
b[c++]=hexCharCodeArray[a>>4];
b[c++]=hexCharCodeArray[a&0x0F];
return c;
}


function URIEncodeOctets(a,b,c){
if(hexCharCodeArray===0){
hexCharCodeArray=[48,49,50,51,52,53,54,55,56,57,
65,66,67,68,69,70];
}
c=URIAddEncodedOctetToBuffer(a[0],b,c);
if(a[1])c=URIAddEncodedOctetToBuffer(a[1],b,c);
if(a[2])c=URIAddEncodedOctetToBuffer(a[2],b,c);
if(a[3])c=URIAddEncodedOctetToBuffer(a[3],b,c);
return c;
}


function URIEncodeSingle(a,b,c){
var d=(a>>12)&0xF;
var g=(a>>6)&63;
var h=a&63;
var i=new $Array(3);
if(a<=0x007F){
i[0]=a;
}else if(a<=0x07FF){
i[0]=g+192;
i[1]=h+128;
}else{
i[0]=d+224;
i[1]=g+128;
i[2]=h+128;
}
return URIEncodeOctets(i,b,c);
}


function URIEncodePair(a,b,c,d){
var g=((a>>6)&0xF)+1;
var h=(a>>2)&0xF;
var i=a&3;
var j=(b>>6)&0xF;
var k=b&63;
var l=new $Array(4);
l[0]=(g>>2)+240;
l[1]=(((g&3)<<4)|h)+128;
l[2]=((i<<4)|j)+128;
l[3]=k+128;
return URIEncodeOctets(l,c,d);
}


function URIHexCharsToCharCode(a,b){
var c=HexValueOf(a);
var d=HexValueOf(b);
if(c==-1||d==-1){
throw new $URIError("URI malformed");
}
return(c<<4)|d;
}


function URIDecodeOctets(a,b,c){
var d;
var g=a[0];
if(g<0x80){
d=g;
}else if(g<0xc2){
throw new $URIError("URI malformed");
}else{
var h=a[1];
if(g<0xe0){
var i=g&0x1f;
if((h<0x80)||(h>0xbf)){
throw new $URIError("URI malformed");
}
var j=h&0x3f;
d=(i<<6)+j;
if(d<0x80||d>0x7ff){
throw new $URIError("URI malformed");
}
}else{
var k=a[2];
if(g<0xf0){
var i=g&0x0f;
if((h<0x80)||(h>0xbf)){
throw new $URIError("URI malformed");
}
var j=h&0x3f;
if((k<0x80)||(k>0xbf)){
throw new $URIError("URI malformed");
}
var l=k&0x3f;
d=(i<<12)+(j<<6)+l;
if((d<0x800)||(d>0xffff)){
throw new $URIError("URI malformed");
}
}else{
var m=a[3];
if(g<0xf8){
var i=(g&0x07);
if((h<0x80)||(h>0xbf)){
throw new $URIError("URI malformed");
}
var j=(h&0x3f);
if((k<0x80)||(k>0xbf)){
throw new $URIError("URI malformed");
}
var l=(k&0x3f);
if((m<0x80)||(m>0xbf)){
throw new $URIError("URI malformed");
}
var o=(m&0x3f);
d=(i<<18)+(j<<12)+(l<<6)+o;
if((d<0x10000)||(d>0x10ffff)){
throw new $URIError("URI malformed");
}
}else{
throw new $URIError("URI malformed");
}
}
}
}
if(0xD800<=d&&d<=0xDFFF){
throw new $URIError("URI malformed");
}
if(d<0x10000){
b[c++]=d;
return c;
}else{
b[c++]=(d>>10)+0xd7c0;
b[c++]=(d&0x3ff)+0xdc00;
return c;
}
}



function Encode(a,b){
var c=a.length;



var d=new InternalArray(c);
var g=0;
for(var h=0;h<c;h++){
var i=a.charCodeAt(h);
if(b(i)){
d[g++]=i;
}else{
if(i>=0xDC00&&i<=0xDFFF)throw new $URIError("URI malformed");
if(i<0xD800||i>0xDBFF){
g=URIEncodeSingle(i,d,g);
}else{
h++;
if(h==c)throw new $URIError("URI malformed");
var j=a.charCodeAt(h);
if(j<0xDC00||j>0xDFFF)throw new $URIError("URI malformed");
g=URIEncodePair(i,j,d,g);
}
}
}
return %StringFromCharCodeArray(d);
}



function Decode(a,b){
var c=a.length;



var d=new InternalArray(c);
var g=0;
for(var h=0;h<c;h++){
var i=a.charAt(h);
if(i=='%'){
if(h+2>=c)throw new $URIError("URI malformed");
var j=URIHexCharsToCharCode(a.charCodeAt(++h),a.charCodeAt(++h));
if(j>>7){
var k=0;
while(((j<<++k)&0x80)!=0){}
if(k==1||k>4)throw new $URIError("URI malformed");
var l=new $Array(k);
l[0]=j;
if(h+3*(k-1)>=c)throw new $URIError("URI malformed");
for(var m=1;m<k;m++){
if(a.charAt(++h)!='%')throw new $URIError("URI malformed");
l[m]=URIHexCharsToCharCode(a.charCodeAt(++h),
a.charCodeAt(++h));
}
g=URIDecodeOctets(l,d,g);
}else{
if(b(j)){
d[g++]=37;
d[g++]=a.charCodeAt(h-1);
d[g++]=a.charCodeAt(h);
}else{
d[g++]=j;
}
}
}else{
d[g++]=i.charCodeAt(0);
}
}
d.length=g;
return %StringFromCharCodeArray(d);
}



function URIDecode(a){
var b=function(c){

if(35<=c&&c<=36)return true;

if(c==38)return true;

if(43<=c&&c<=44)return true;

if(c==47)return true;

if(58<=c&&c<=59)return true;

if(c==61)return true;

if(63<=c&&c<=64)return true;

return false;
};
var d=ToString(a);
return Decode(d,b);
}



function URIDecodeComponent(a){
var b=function(c){return false;};
var d=ToString(a);
return Decode(d,b);
}



function isAlphaNumeric(a){

if(97<=a&&a<=122)return true;

if(65<=a&&a<=90)return true;

if(48<=a&&a<=57)return true;

return false;
}



function URIEncode(a){
var b=function(c){
if(isAlphaNumeric(c))return true;

if(c==33)return true;

if(35<=c&&c<=36)return true;

if(38<=c&&c<=47)return true;

if(58<=c&&c<=59)return true;

if(c==61)return true;

if(63<=c&&c<=64)return true;

if(c==95)return true;

if(c==126)return true;

return false;
};

var d=ToString(a);
return Encode(d,b);
}



function URIEncodeComponent(a){
var b=function(c){
if(isAlphaNumeric(c))return true;

if(c==33)return true;

if(39<=c&&c<=42)return true;

if(45<=c&&c<=46)return true;

if(c==95)return true;

if(c==126)return true;

return false;
};

var d=ToString(a);
return Encode(d,b);
}


function HexValueOf(a){

if(a>=48&&a<=57)return a-48;

if(a>=65&&a<=70)return a-55;

if(a>=97&&a<=102)return a-87;

return-1;
}




function CharCodeToHex4Str(a){
var b="";
if(hexCharArray===0){
hexCharArray=["0","1","2","3","4","5","6","7","8","9",
"A","B","C","D","E","F"];
}
for(var c=0;c<4;++c){
var d=hexCharArray[a&0x0F];
b=d+b;
a=a>>>4;
}
return b;
}



function IsValidHex(a){
for(var b=0;b<a.length;++b){
var c=a.charCodeAt(b);
if((48<=c&&c<=57)||
(65<=c&&c<=70)||
(97<=c&&c<=102)){

}else{
return false;
}
}
return true;
}



function URIEscape(a){
var b=ToString(a);
return %URIEscape(b);
}



function URIUnescape(a){
var b=ToString(a);
return %URIUnescape(b);
}




function SetUpUri(){
%CheckIsBootstrapping();


InstallFunctions(global,2,$Array(
"escape",URIEscape,
"unescape",URIUnescape,
"decodeURI",URIDecode,
"decodeURIComponent",URIDecodeComponent,
"encodeURI",URIEncode,
"encodeURIComponent",URIEncodeComponent
));
}

SetUpUri();
































var $floor=MathFloor;
var $abs=MathAbs;



function MathConstructor(){}
%FunctionSetInstanceClassName(MathConstructor,'Math');
var $Math=new MathConstructor();
$Math.__proto__=$Object.prototype;
%SetProperty(global,"Math",$Math,2);


function MathAbs(a){
if(%_IsSmi(a))return a>=0?a:-a;
if(!(typeof(a)==='number'))a=NonNumberToNumber(a);
if(a===0)return 0;
return a>0?a:-a;
}


function MathAcos(a){
if(!(typeof(a)==='number'))a=NonNumberToNumber(a);
return %Math_acos(a);
}


function MathAsin(a){
if(!(typeof(a)==='number'))a=NonNumberToNumber(a);
return %Math_asin(a);
}


function MathAtan(a){
if(!(typeof(a)==='number'))a=NonNumberToNumber(a);
return %Math_atan(a);
}




function MathAtan2(a,b){
if(!(typeof(a)==='number'))a=NonNumberToNumber(a);
if(!(typeof(b)==='number'))b=NonNumberToNumber(b);
return %Math_atan2(a,b);
}


function MathCeil(a){
if(!(typeof(a)==='number'))a=NonNumberToNumber(a);
return %Math_ceil(a);
}


function MathCos(a){
if(!(typeof(a)==='number'))a=NonNumberToNumber(a);
return %_MathCos(a);
}


function MathExp(a){
if(!(typeof(a)==='number'))a=NonNumberToNumber(a);
return %Math_exp(a);
}


function MathFloor(a){
if(!(typeof(a)==='number'))a=NonNumberToNumber(a);


if(a<0x80000000&&a>0){




return(a>>>0);
}else{
return %Math_floor(a);
}
}


function MathLog(a){
if(!(typeof(a)==='number'))a=NonNumberToNumber(a);
return %_MathLog(a);
}


function MathMax(a,b){
var c=%_ArgumentsLength();
if(c==2){
if(!(typeof(a)==='number'))a=NonNumberToNumber(a);
if(!(typeof(b)==='number'))b=NonNumberToNumber(b);
if(b>a)return b;
if(a>b)return a;
if(a==b){


return(a==0&&!%_IsSmi(a)&&1/a<0)?b:a;
}

return 0/0;
}
if(c==0){
return-1/0;
}
var d=a;
if(!(typeof(d)==='number'))d=NonNumberToNumber(d);
if((!%_IsSmi(%IS_VAR(d))&&!(d==d)))return d;
for(var g=1;g<c;g++){
var h=%_Arguments(g);
if(!(typeof(h)==='number'))h=NonNumberToNumber(h);
if((!%_IsSmi(%IS_VAR(h))&&!(h==h)))return h;


if(h>d||(d==0&&h==0&&!%_IsSmi(d)&&1/d<0))d=h;
}
return d;
}


function MathMin(a,b){
var c=%_ArgumentsLength();
if(c==2){
if(!(typeof(a)==='number'))a=NonNumberToNumber(a);
if(!(typeof(b)==='number'))b=NonNumberToNumber(b);
if(b>a)return a;
if(a>b)return b;
if(a==b){


return(a==0&&!%_IsSmi(a)&&1/a<0)?a:b;
}

return 0/0;
}
if(c==0){
return 1/0;
}
var d=a;
if(!(typeof(d)==='number'))d=NonNumberToNumber(d);
if((!%_IsSmi(%IS_VAR(d))&&!(d==d)))return d;
for(var g=1;g<c;g++){
var h=%_Arguments(g);
if(!(typeof(h)==='number'))h=NonNumberToNumber(h);
if((!%_IsSmi(%IS_VAR(h))&&!(h==h)))return h;


if(h<d||(d==0&&h==0&&!%_IsSmi(h)&&1/h<0))d=h;
}
return d;
}


function MathPow(a,b){
if(!(typeof(a)==='number'))a=NonNumberToNumber(a);
if(!(typeof(b)==='number'))b=NonNumberToNumber(b);
return %_MathPow(a,b);
}


function MathRandom(){
return %_RandomHeapNumber();
}


function MathRound(a){
if(!(typeof(a)==='number'))a=NonNumberToNumber(a);
return %RoundNumber(a);
}


function MathSin(a){
if(!(typeof(a)==='number'))a=NonNumberToNumber(a);
return %_MathSin(a);
}


function MathSqrt(a){
if(!(typeof(a)==='number'))a=NonNumberToNumber(a);
return %_MathSqrt(a);
}


function MathTan(a){
if(!(typeof(a)==='number'))a=NonNumberToNumber(a);
return %_MathTan(a);
}




function SetUpMath(){
%CheckIsBootstrapping();


%OptimizeObjectForAddingMultipleProperties($Math,8);
%SetProperty($Math,
"E",
2.7182818284590452354,
2|4|1);

%SetProperty($Math,
"LN10",
2.302585092994046,
2|4|1);

%SetProperty($Math,
"LN2",
0.6931471805599453,
2|4|1);

%SetProperty($Math,
"LOG2E",
1.4426950408889634,
2|4|1);
%SetProperty($Math,
"LOG10E",
0.4342944819032518,
2|4|1);
%SetProperty($Math,
"PI",
3.1415926535897932,
2|4|1);
%SetProperty($Math,
"SQRT1_2",
0.7071067811865476,
2|4|1);
%SetProperty($Math,
"SQRT2",
1.4142135623730951,
2|4|1);
%ToFastProperties($Math);



InstallFunctions($Math,2,$Array(
"random",MathRandom,
"abs",MathAbs,
"acos",MathAcos,
"asin",MathAsin,
"atan",MathAtan,
"ceil",MathCeil,
"cos",MathCos,
"exp",MathExp,
"floor",MathFloor,
"log",MathLog,
"round",MathRound,
"sin",MathSin,
"sqrt",MathSqrt,
"tan",MathTan,
"atan2",MathAtan2,
"pow",MathPow,
"max",MathMax,
"min",MathMin
));
}

SetUpMath();

































var kAddMessageAccessorsMarker={};



var kMessages=0;

function FormatString(a,b){
var c=%MessageGetArguments(b);
var d="";
var g=0;
for(var h=0;h<a.length;h++){
var i=a[h];
if(i.length==2&&%_StringCharCodeAt(i,0)==0x25){

var g=(%_StringCharCodeAt(i,1)-0x30)>>>0;
if(g<4){

try{
i=ToDetailString(c[g]);
}catch(e){
if(%IsJSModule(c[g]))
i="module";
else if((%_IsSpecObject(c[g])))
i="object";
else
i="#<error>";
}
}
}
d+=i;
}
return d;
}






function IsNativeErrorObject(a){
switch(%_ClassOf(a)){
case'Error':
case'EvalError':
case'RangeError':
case'ReferenceError':
case'SyntaxError':
case'TypeError':
case'URIError':
return true;
}
return false;
}






function ToStringCheckErrorObject(a){
if(IsNativeErrorObject(a)){
return %_CallFunction(a,ErrorToString);
}else{
return ToString(a);
}
}


function ToDetailString(a){
if(a!=null&&(%_IsObject(a))&&a.toString===ObjectToString){
var b=a.constructor;
if(typeof b=="function"){
var c=b.name;
if((typeof(c)==='string')&&c!==""){
return"#<"+c+">";
}
}
}
return ToStringCheckErrorObject(a);
}


function MakeGenericError(a,b,c){
if((typeof(c)==='undefined')){
c=[];
}
var d=new a(kAddMessageAccessorsMarker);
d.type=b;
d.arguments=c;
return d;
}





%FunctionSetInstanceClassName(Script,'Script');
%SetProperty(Script.prototype,'constructor',Script,
2|4|1);
%SetCode(Script,function(a){

throw new $Error("Not supported");
});



function FormatMessage(a){
if(kMessages===0){
var b=[

"cyclic_proto",["Cyclic __proto__ value"],
"code_gen_from_strings",["%0"],

"unexpected_token",["Unexpected token ","%0"],
"unexpected_token_number",["Unexpected number"],
"unexpected_token_string",["Unexpected string"],
"unexpected_token_identifier",["Unexpected identifier"],
"unexpected_reserved",["Unexpected reserved word"],
"unexpected_strict_reserved",["Unexpected strict mode reserved word"],
"unexpected_eos",["Unexpected end of input"],
"malformed_regexp",["Invalid regular expression: /","%0","/: ","%1"],
"unterminated_regexp",["Invalid regular expression: missing /"],
"regexp_flags",["Cannot supply flags when constructing one RegExp from another"],
"incompatible_method_receiver",["Method ","%0"," called on incompatible receiver ","%1"],
"invalid_lhs_in_assignment",["Invalid left-hand side in assignment"],
"invalid_lhs_in_for_in",["Invalid left-hand side in for-in"],
"invalid_lhs_in_postfix_op",["Invalid left-hand side expression in postfix operation"],
"invalid_lhs_in_prefix_op",["Invalid left-hand side expression in prefix operation"],
"multiple_defaults_in_switch",["More than one default clause in switch statement"],
"newline_after_throw",["Illegal newline after throw"],
"redeclaration",["%0"," '","%1","' has already been declared"],
"no_catch_or_finally",["Missing catch or finally after try"],
"unknown_label",["Undefined label '","%0","'"],
"uncaught_exception",["Uncaught ","%0"],
"stack_trace",["Stack Trace:\n","%0"],
"called_non_callable",["%0"," is not a function"],
"undefined_method",["Object ","%1"," has no method '","%0","'"],
"property_not_function",["Property '","%0","' of object ","%1"," is not a function"],
"cannot_convert_to_primitive",["Cannot convert object to primitive value"],
"not_constructor",["%0"," is not a constructor"],
"not_defined",["%0"," is not defined"],
"non_object_property_load",["Cannot read property '","%0","' of ","%1"],
"non_object_property_store",["Cannot set property '","%0","' of ","%1"],
"non_object_property_call",["Cannot call method '","%0","' of ","%1"],
"with_expression",["%0"," has no properties"],
"illegal_invocation",["Illegal invocation"],
"no_setter_in_callback",["Cannot set property ","%0"," of ","%1"," which has only a getter"],
"apply_non_function",["Function.prototype.apply was called on ","%0",", which is a ","%1"," and not a function"],
"apply_wrong_args",["Function.prototype.apply: Arguments list has wrong type"],
"invalid_in_operator_use",["Cannot use 'in' operator to search for '","%0","' in ","%1"],
"instanceof_function_expected",["Expecting a function in instanceof check, but got ","%0"],
"instanceof_nonobject_proto",["Function has non-object prototype '","%0","' in instanceof check"],
"null_to_object",["Cannot convert null to object"],
"reduce_no_initial",["Reduce of empty array with no initial value"],
"getter_must_be_callable",["Getter must be a function: ","%0"],
"setter_must_be_callable",["Setter must be a function: ","%0"],
"value_and_accessor",["Invalid property.  A property cannot both have accessors and be writable or have a value, ","%0"],
"proto_object_or_null",["Object prototype may only be an Object or null"],
"property_desc_object",["Property description must be an object: ","%0"],
"redefine_disallowed",["Cannot redefine property: ","%0"],
"define_disallowed",["Cannot define property:","%0",", object is not extensible."],
"non_extensible_proto",["%0"," is not extensible"],
"handler_non_object",["Proxy.","%0"," called with non-object as handler"],
"proto_non_object",["Proxy.","%0"," called with non-object as prototype"],
"trap_function_expected",["Proxy.","%0"," called with non-function for '","%1","' trap"],
"handler_trap_missing",["Proxy handler ","%0"," has no '","%1","' trap"],
"handler_trap_must_be_callable",["Proxy handler ","%0"," has non-callable '","%1","' trap"],
"handler_returned_false",["Proxy handler ","%0"," returned false from '","%1","' trap"],
"handler_returned_undefined",["Proxy handler ","%0"," returned undefined from '","%1","' trap"],
"proxy_prop_not_configurable",["Proxy handler ","%0"," returned non-configurable descriptor for property '","%2","' from '","%1","' trap"],
"proxy_non_object_prop_names",["Trap '","%1","' returned non-object ","%0"],
"proxy_repeated_prop_name",["Trap '","%1","' returned repeated property name '","%2","'"],
"invalid_weakmap_key",["Invalid value used as weak map key"],
"not_date_object",["this is not a Date object."],

"invalid_array_length",["Invalid array length"],
"stack_overflow",["Maximum call stack size exceeded"],
"invalid_time_value",["Invalid time value"],

"unable_to_parse",["Parse error"],
"invalid_regexp_flags",["Invalid flags supplied to RegExp constructor '","%0","'"],
"invalid_regexp",["Invalid RegExp pattern /","%0","/"],
"illegal_break",["Illegal break statement"],
"illegal_continue",["Illegal continue statement"],
"illegal_return",["Illegal return statement"],
"illegal_let",["Illegal let declaration outside extended mode"],
"error_loading_debugger",["Error loading debugger"],
"no_input_to_regexp",["No input to ","%0"],
"invalid_json",["String '","%0","' is not valid JSON"],
"circular_structure",["Converting circular structure to JSON"],
"called_on_non_object",["%0"," called on non-object"],
"called_on_null_or_undefined",["%0"," called on null or undefined"],
"array_indexof_not_defined",["Array.getIndexOf: Argument undefined"],
"object_not_extensible",["Can't add property ","%0",", object is not extensible"],
"illegal_access",["Illegal access"],
"invalid_preparser_data",["Invalid preparser data for function ","%0"],
"strict_mode_with",["Strict mode code may not include a with statement"],
"strict_catch_variable",["Catch variable may not be eval or arguments in strict mode"],
"too_many_arguments",["Too many arguments in function call (only 32766 allowed)"],
"too_many_parameters",["Too many parameters in function definition (only 32766 allowed)"],
"too_many_variables",["Too many variables declared (only 131071 allowed)"],
"strict_param_name",["Parameter name eval or arguments is not allowed in strict mode"],
"strict_param_dupe",["Strict mode function may not have duplicate parameter names"],
"strict_var_name",["Variable name may not be eval or arguments in strict mode"],
"strict_function_name",["Function name may not be eval or arguments in strict mode"],
"strict_octal_literal",["Octal literals are not allowed in strict mode."],
"strict_duplicate_property",["Duplicate data property in object literal not allowed in strict mode"],
"accessor_data_property",["Object literal may not have data and accessor property with the same name"],
"accessor_get_set",["Object literal may not have multiple get/set accessors with the same name"],
"strict_lhs_assignment",["Assignment to eval or arguments is not allowed in strict mode"],
"strict_lhs_postfix",["Postfix increment/decrement may not have eval or arguments operand in strict mode"],
"strict_lhs_prefix",["Prefix increment/decrement may not have eval or arguments operand in strict mode"],
"strict_reserved_word",["Use of future reserved word in strict mode"],
"strict_delete",["Delete of an unqualified identifier in strict mode."],
"strict_delete_property",["Cannot delete property '","%0","' of ","%1"],
"strict_const",["Use of const in strict mode."],
"strict_function",["In strict mode code, functions can only be declared at top level or immediately within another function."],
"strict_read_only_property",["Cannot assign to read only property '","%0","' of ","%1"],
"strict_cannot_assign",["Cannot assign to read only '","%0","' in strict mode"],
"strict_poison_pill",["'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them"],
"strict_caller",["Illegal access to a strict mode caller function."],
"unprotected_let",["Illegal let declaration in unprotected statement context."],
"unprotected_const",["Illegal const declaration in unprotected statement context."],
"cant_prevent_ext_external_array_elements",["Cannot prevent extension of an object with external array elements"],
"redef_external_array_element",["Cannot redefine a property of an object with external array elements"],
"harmony_const_assign",["Assignment to constant variable."],
"invalid_module_path",["Module does not export '","%0","', or export is not itself a module"],
"module_type_error",["Module '","%0","' used improperly"],
"module_export_undefined",["Export '","%0","' is not defined in module"],
];
var c={__proto__:null};
for(var d=0;d<b.length;d+=2){
var g=b[d];
var h=b[d+1];

for(var i=0;i<h.length;i++){
%IgnoreAttributesAndSetProperty(h,%_NumberToString(i),h[i],
4|1|2);
}
%IgnoreAttributesAndSetProperty(h,'length',h.length,
4|1|2);
%PreventExtensions(h);
%IgnoreAttributesAndSetProperty(c,
g,
h,
4|2|1);
}
%PreventExtensions(c);
%IgnoreAttributesAndSetProperty(builtins,"kMessages",
c,
4|2|1);
}
var j=%MessageGetType(a);
var h=kMessages[j];
if(!h)return"<unknown message "+j+">";
return FormatString(h,a);
}


function GetLineNumber(a){
var b=%MessageGetStartPosition(a);
if(b==-1)return 0;
var c=%MessageGetScript(a);
var d=c.locationFromPosition(b,true);
if(d==null)return 0;
return d.line+1;
}




function GetSourceLine(a){
var b=%MessageGetScript(a);
var c=%MessageGetStartPosition(a);
var d=b.locationFromPosition(c,true);
if(d==null)return"";
d.restrict();
return d.sourceText();
}


function MakeTypeError(a,b){
return MakeGenericError($TypeError,a,b);
}


function MakeRangeError(a,b){
return MakeGenericError($RangeError,a,b);
}


function MakeSyntaxError(a,b){
return MakeGenericError($SyntaxError,a,b);
}


function MakeReferenceError(a,b){
return MakeGenericError($ReferenceError,a,b);
}


function MakeEvalError(a,b){
return MakeGenericError($EvalError,a,b);
}


function MakeError(a,b){
return MakeGenericError($Error,a,b);
}







function ScriptLineFromPosition(a){
var b=0;
var c=this.lineCount()-1;
var d=this.line_ends;


if(a>d[c]){
return-1;
}


if(a<=d[0]){
return 0;
}


while(c>=1){
var g=(b+c)>>1;

if(a>d[g]){
b=g+1;
}else if(a<=d[g-1]){
c=g-1;
}else{
return g;
}
}

return-1;
}









function ScriptLocationFromPosition(position,
include_resource_offset){
var a=this.lineFromPosition(position);
if(a==-1)return null;


var b=this.line_ends;
var c=a==0?0:b[a-1]+1;
var d=b[a];
if(d>0&&%_CallFunction(this.source,d-1,StringCharAt)=='\r'){
d--;
}
var g=position-c;


if(include_resource_offset){
a+=this.line_offset;
if(a==this.line_offset){
g+=this.column_offset;
}
}

return new SourceLocation(this,position,a,g,c,d);
}

















function ScriptLocationFromLine(a,b,c){


var d=0;
if(!(typeof(a)==='undefined')){
d=a-this.line_offset;
}



var g=b||0;
if(d==0){
g-=this.column_offset;
}

var h=c||0;
if(d<0||g<0||h<0)return null;
if(d==0){
return this.locationFromPosition(h+g,false);
}else{

var i=this.lineFromPosition(h);

if(i==-1||i+d>=this.lineCount()){
return null;
}

return this.locationFromPosition(
this.line_ends[i+d-1]+1+g);
}
}












function ScriptSourceSlice(a,b){
var c=(typeof(a)==='undefined')?this.line_offset
:a;
var d=(typeof(b)==='undefined')?this.line_offset+this.lineCount()
:b;


c-=this.line_offset;
d-=this.line_offset;
if(c<0)c=0;
if(d>this.lineCount())d=this.lineCount();


if(c>=this.lineCount()||
d<0||
c>d){
return null;
}

var g=this.line_ends;
var h=c==0?0:g[c-1]+1;
var i=d==0?0:g[d-1]+1;


return new SourceSlice(this,
c+this.line_offset,
d+this.line_offset,
h,i);
}


function ScriptSourceLine(a){


var b=0;
if(!(typeof(a)==='undefined')){
b=a-this.line_offset;
}


if(b<0||this.lineCount()<=b){
return null;
}


var c=this.line_ends;
var d=b==0?0:c[b-1]+1;
var g=c[b];
return %_CallFunction(this.source,d,g,StringSubstring);
}







function ScriptLineCount(){

return this.line_ends.length;
}












function ScriptNameOrSourceURL(){
if(this.line_offset>0||this.column_offset>0){
return this.name;
}



if(this.hasCachedNameOrSourceURL){
return this.cachedNameOrSourceURL;
}
this.hasCachedNameOrSourceURL=true;







var a=ToString(this.source);
var b=%StringIndexOf(a,"sourceURL=",0);
this.cachedNameOrSourceURL=this.name;
if(b>4){
var c=
/\/\/@[\040\t]sourceURL=[\040\t]*([^\s\'\"]*)[\040\t]*$/gm;



var d=new InternalArray((3+(3))+1);
var g=
%_RegExpExec(c,a,b-4,d);
if(g){
this.cachedNameOrSourceURL=
SubString(a,d[(3+(2))],d[(3+(3))]);
}
}
return this.cachedNameOrSourceURL;
}


SetUpLockedPrototype(Script,
$Array("source","name","line_ends","line_offset","column_offset",
"cachedNameOrSourceURL","hasCachedNameOrSourceURL"),
$Array(
"lineFromPosition",ScriptLineFromPosition,
"locationFromPosition",ScriptLocationFromPosition,
"locationFromLine",ScriptLocationFromLine,
"sourceSlice",ScriptSourceSlice,
"sourceLine",ScriptSourceLine,
"lineCount",ScriptLineCount,
"nameOrSourceURL",ScriptNameOrSourceURL
)
);























function SourceLocation(a,b,c,d,g,h){
this.script=a;
this.position=b;
this.line=c;
this.column=d;
this.start=g;
this.end=h;
}

var kLineLengthLimit=78;









function SourceLocationRestrict(a,b){

var c;
var d;
if(!(typeof(a)==='undefined')){
c=a;
}else{
c=kLineLengthLimit;
}
if(!(typeof(b)==='undefined')){
d=b;
}else{


if(c<=20){
d=$floor(c/2);
}else{
d=c-10;
}
}
if(d>=c){
d=c-1;
}




if(this.end-this.start>c){
var g=this.position-d;
var h=this.position+c-d;
if(this.start<g&&h<this.end){
this.start=g;
this.end=h;
}else if(this.start<g){
this.start=this.end-c;
}else{
this.end=this.start+c;
}
}
}







function SourceLocationSourceText(){
return %_CallFunction(this.script.source,
this.start,
this.end,
StringSubstring);
}


SetUpLockedPrototype(SourceLocation,
$Array("script","position","line","column","start","end"),
$Array(
"restrict",SourceLocationRestrict,
"sourceText",SourceLocationSourceText
)
);




















function SourceSlice(a,b,c,d,g){
this.script=a;
this.from_line=b;
this.to_line=c;
this.from_position=d;
this.to_position=g;
}






function SourceSliceSourceText(){
return %_CallFunction(this.script.source,
this.from_position,
this.to_position,
StringSubstring);
}

SetUpLockedPrototype(SourceSlice,
$Array("script","from_line","to_line","from_position","to_position"),
$Array("sourceText",SourceSliceSourceText)
);




function GetPositionInLine(a){
var b=%MessageGetScript(a);
var c=%MessageGetStartPosition(a);
var d=b.locationFromPosition(c,false);
if(d==null)return-1;
d.restrict();
return c-d.start;
}


function GetStackTraceLine(a,b,c,d){
return new CallSite(a,b,c).toString();
}






function DefineOneShotAccessor(a,b,c){



var d;
var g=c;
var h=function(){
if(g==null){
return d;
}
d=g(a);
g=null;
return d;
};
var i=function(j){
g=null;
d=j;
};
%DefineOrRedefineAccessorProperty(a,b,h,i,2);
}

function CallSite(a,b,c){
this.receiver=a;
this.fun=b;
this.pos=c;
}

function CallSiteGetThis(){
return this.receiver;
}

function CallSiteGetTypeName(){
return GetTypeName(this,false);
}

function CallSiteIsToplevel(){
if(this.receiver==null){
return true;
}
return(%_ClassOf(this.receiver)==='global');
}

function CallSiteIsEval(){
var a=%FunctionGetScript(this.fun);
return a&&a.compilation_type==1;
}

function CallSiteGetEvalOrigin(){
var a=%FunctionGetScript(this.fun);
return FormatEvalOrigin(a);
}

function CallSiteGetScriptNameOrSourceURL(){
var a=%FunctionGetScript(this.fun);
return a?a.nameOrSourceURL():null;
}

function CallSiteGetFunction(){
return this.fun;
}

function CallSiteGetFunctionName(){

var a=this.fun.name;
if(a){
return a;
}
a=%FunctionGetInferredName(this.fun);
if(a){
return a;
}

var b=%FunctionGetScript(this.fun);
if(b&&b.compilation_type==1){
return"eval";
}
return null;
}

function CallSiteGetMethodName(){


var a=this.fun.name;
if(a&&this.receiver&&
(%_CallFunction(this.receiver,
a,
ObjectLookupGetter)===this.fun||
%_CallFunction(this.receiver,
a,
ObjectLookupSetter)===this.fun||
this.receiver[a]===this.fun)){


return a;
}
var b=null;
for(var c in this.receiver){
if(%_CallFunction(this.receiver,c,ObjectLookupGetter)===this.fun||
%_CallFunction(this.receiver,c,ObjectLookupSetter)===this.fun||
(!%_CallFunction(this.receiver,c,ObjectLookupGetter)&&
this.receiver[c]===this.fun)){

if(b){
return null;
}
b=c;
}
}
if(b){
return b;
}
return null;
}

function CallSiteGetFileName(){
var a=%FunctionGetScript(this.fun);
return a?a.name:null;
}

function CallSiteGetLineNumber(){
if(this.pos==-1){
return null;
}
var a=%FunctionGetScript(this.fun);
var b=null;
if(a){
b=a.locationFromPosition(this.pos,true);
}
return b?b.line+1:null;
}

function CallSiteGetColumnNumber(){
if(this.pos==-1){
return null;
}
var a=%FunctionGetScript(this.fun);
var b=null;
if(a){
b=a.locationFromPosition(this.pos,true);
}
return b?b.column+1:null;
}

function CallSiteIsNative(){
var a=%FunctionGetScript(this.fun);
return a?(a.type==0):false;
}

function CallSiteGetPosition(){
return this.pos;
}

function CallSiteIsConstructor(){
var a=this.receiver?this.receiver.constructor:null;
if(!a){
return false;
}
return this.fun===a;
}

function CallSiteToString(){
var a;
var b="";
if(this.isNative()){
b="native";
}else{
if(this.isEval()){
a=this.getScriptNameOrSourceURL();
if(!a){
b=this.getEvalOrigin();
b+=", ";
}
}else{
a=this.getFileName();
}

if(a){
b+=a;
}else{



b+="<anonymous>";
}
var c=this.getLineNumber();
if(c!=null){
b+=":"+c;
var d=this.getColumnNumber();
if(d){
b+=":"+d;
}
}
}

var g="";
var h=this.getFunctionName();
var i=true;
var j=this.isConstructor();
var k=!(this.isToplevel()||j);
if(k){
var l=GetTypeName(this,true);
var m=this.getMethodName();
if(h){
if(l&&h.indexOf(l)!=0){
g+=l+".";
}
g+=h;
if(m&&h.lastIndexOf("."+m)!=
h.length-m.length-1){
g+=" [as "+m+"]";
}
}else{
g+=l+"."+(m||"<anonymous>");
}
}else if(j){
g+="new "+(h||"<anonymous>");
}else if(h){
g+=h;
}else{
g+=b;
i=false;
}
if(i){
g+=" ("+b+")";
}
return g;
}

SetUpLockedPrototype(CallSite,$Array("receiver","fun","pos"),$Array(
"getThis",CallSiteGetThis,
"getTypeName",CallSiteGetTypeName,
"isToplevel",CallSiteIsToplevel,
"isEval",CallSiteIsEval,
"getEvalOrigin",CallSiteGetEvalOrigin,
"getScriptNameOrSourceURL",CallSiteGetScriptNameOrSourceURL,
"getFunction",CallSiteGetFunction,
"getFunctionName",CallSiteGetFunctionName,
"getMethodName",CallSiteGetMethodName,
"getFileName",CallSiteGetFileName,
"getLineNumber",CallSiteGetLineNumber,
"getColumnNumber",CallSiteGetColumnNumber,
"isNative",CallSiteIsNative,
"getPosition",CallSiteGetPosition,
"isConstructor",CallSiteIsConstructor,
"toString",CallSiteToString
));


function FormatEvalOrigin(a){
var b=a.nameOrSourceURL();
if(b){
return b;
}

var c="eval at ";
if(a.eval_from_function_name){
c+=a.eval_from_function_name;
}else{
c+="<anonymous>";
}

var d=a.eval_from_script;
if(d){
if(d.compilation_type==1){

c+=" ("+FormatEvalOrigin(d)+")";
}else{

if(d.name){
c+=" ("+d.name;
var g=d.locationFromPosition(
a.eval_from_script_position,true);
if(g){
c+=":"+(g.line+1);
c+=":"+(g.column+1);
}
c+=")";
}else{
c+=" (unknown source)";
}
}
}

return c;
}

function FormatStackTrace(a,b){
var c=[];
try{
c.push(a.toString());
}catch(e){
try{
c.push("<error: "+e+">");
}catch(ee){
c.push("<error>");
}
}
for(var d=0;d<b.length;d++){
var g=b[d];
var h;
try{
h=g.toString();
}catch(e){
try{
h="<error: "+e+">";
}catch(ee){

h="<error>";
}
}
c.push("    at "+h);
}
return c.join("\n");
}

function FormatRawStackTrace(a,b){
var c=[];
for(var d=0;d<b.length;d+=4){
var g=b[d];
var h=b[d+1];
var i=b[d+2];
var j=b[d+3];
var k=%FunctionGetPositionForOffset(i,j);
c.push(new CallSite(g,h,k));
}
if((%_IsFunction($Error.prepareStackTrace))){
return $Error.prepareStackTrace(a,c);
}else{
return FormatStackTrace(a,c);
}
}

function GetTypeName(a,b){
var c=a.receiver.constructor;
if(!c){
return b?null:
%_CallFunction(a.receiver,ObjectToString);
}
var d=c.name;
if(!d){
return b?null:
%_CallFunction(a.receiver,ObjectToString);
}
return d;
}

function captureStackTrace(a,b){
var c=$Error.stackTraceLimit;
if(!c||!(typeof(c)==='number'))return;
if(c<0||c>10000){
c=10000;
}
var d=%CollectStackTrace(a,
b?b:captureStackTrace,
c);
DefineOneShotAccessor(a,'stack',function(a){
return FormatRawStackTrace(a,d);
});
}


function SetUpError(){


var a=function(b){






var c=b.name;
%SetProperty(global,c,b,2);
%SetProperty(builtins,'$'+c,b,2|4|1);

if(c=='Error'){




var d=function(){};
%FunctionSetPrototype(d,$Object.prototype);
%FunctionSetInstanceClassName(d,'Error');
%FunctionSetPrototype(b,new d());
}else{
%FunctionSetPrototype(b,new $Error());
}
%FunctionSetInstanceClassName(b,'Error');
%SetProperty(b.prototype,'constructor',b,2);
%SetProperty(b.prototype,"name",c,2);
%SetCode(b,function(g){
if(%_IsConstructCall()){



%IgnoreAttributesAndSetProperty(this,'stack',void 0,2);
%IgnoreAttributesAndSetProperty(this,'arguments',void 0,2);
%IgnoreAttributesAndSetProperty(this,'type',void 0,2);
if(g===kAddMessageAccessorsMarker){


DefineOneShotAccessor(this,'message',function(h){
return FormatMessage(%NewMessageObject(h.type,h.arguments));
});
}else if(!(typeof(g)==='undefined')){
%IgnoreAttributesAndSetProperty(
this,'message',ToString(g),2);
}
captureStackTrace(this,b);
}else{
return new b(g);
}
});
%SetNativeFlag(b);
};

a(function Error(){});
a(function TypeError(){});
a(function RangeError(){});
a(function SyntaxError(){});
a(function ReferenceError(){});
a(function EvalError(){});
a(function URIError(){});
}

SetUpError();

$Error.captureStackTrace=captureStackTrace;

%SetProperty($Error.prototype,'message','',2);



var visited_errors=new InternalArray();
var cyclic_error_marker=new $Object();

function GetPropertyWithoutInvokingMonkeyGetters(a,b){

while(a&&!%HasLocalProperty(a,b)){
a=a.__proto__;
}
if(a===null)return void 0;
if(!(%_IsObject(a)))return a[b];



var c=%GetOwnProperty(a,b);
if(c&&c[0]){
var d=b==="name";
if(a===$ReferenceError.prototype)
return d?"ReferenceError":void 0;
if(a===$SyntaxError.prototype)
return d?"SyntaxError":void 0;
if(a===$TypeError.prototype)
return d?"TypeError":void 0;
}

return a[b];
}

function ErrorToStringDetectCycle(a){
if(!%PushIfAbsent(visited_errors,a))throw cyclic_error_marker;
try{
var b=GetPropertyWithoutInvokingMonkeyGetters(a,"type");
var c=GetPropertyWithoutInvokingMonkeyGetters(a,"name");
c=(typeof(c)==='undefined')?"Error":((typeof(%IS_VAR(c))==='string')?c:NonStringToString(c));
var d=GetPropertyWithoutInvokingMonkeyGetters(a,"message");
var g=%_CallFunction(a,"message",ObjectHasOwnProperty);
if(b&&!g){
var h=GetPropertyWithoutInvokingMonkeyGetters(a,"arguments");
d=FormatMessage(%NewMessageObject(b,h));
}
d=(typeof(d)==='undefined')?"":((typeof(%IS_VAR(d))==='string')?d:NonStringToString(d));
if(c==="")return d;
if(d==="")return c;
return c+": "+d;
}finally{
visited_errors.length=visited_errors.length-1;
}
}

function ErrorToString(){
if(!(%_IsSpecObject(this))){
throw MakeTypeError("called_on_non_object",["Error.prototype.toString"]);
}

try{
return ErrorToStringDetectCycle(this);
}catch(e){


if(e===cyclic_error_marker){
return'';
}
throw e;
}
}


InstallFunctions($Error.prototype,2,['toString',ErrorToString]);



var kStackOverflowBoilerplate=MakeRangeError('stack_overflow',[]);

































function CreateDate(a){
var b=new $Date();
b.setTime(a);
return b;
}


var kApiFunctionCache={};
var functionCache=kApiFunctionCache;


function Instantiate(a,b){
if(!%IsTemplate(a))return a;
var c=%GetTemplateField(a,0);
switch(c){
case 0:
return InstantiateFunction(a,b);
case 1:
var d=%GetTemplateField(a,2);


var g=typeof d==='undefined'?
{}:new(Instantiate(d))();
ConfigureTemplateInstance(g,a);
g=%ToFastProperties(g);
return g;
default:
throw'Unknown API tag <'+c+'>';
}
}


function InstantiateFunction(a,b){


var c=kApiFunctionCache;
var d=%GetTemplateField(a,2);
var g=
(d in c)&&(c[d]!=-1);
if(!g){
try{
c[d]=null;
var h=%CreateApiFunction(a);
if(b)%FunctionSetName(h,b);
c[d]=h;
var i=%GetTemplateField(a,5);
var j=%GetTemplateField(a,14);


h.prototype=typeof i==='undefined'?
{}:Instantiate(i);
if(j&(1<<3)){
%FunctionSetReadOnlyPrototype(h);
}
%SetProperty(h.prototype,"constructor",h,2);
var k=%GetTemplateField(a,6);


if(!(typeof k==='undefined')){
var l=Instantiate(k);
h.prototype.__proto__=l.prototype;
}
ConfigureTemplateInstance(h,a);
}catch(e){
c[d]=-1;
throw e;
}
}
return c[d];
}


function ConfigureTemplateInstance(a,b){
var c=%GetTemplateField(b,1);
if(c){

var d=%DisableAccessChecks(a);
try{
for(var g=0;g<c[0];g+=3){
var h=c[g+1];
var i=c[g+2];
var j=c[g+3];
var k=Instantiate(i,h);
%SetProperty(a,h,k,j);
}
}finally{
if(d)%EnableAccessChecks(a);
}
}
}





























var kDefaultBacktraceLength=10;

var Debug={};




var sourceLineBeginningSkip=/^(?:\s*(?:\/\*.*?\*\/)*)*/;



Debug.DebugEvent={Break:1,
Exception:2,
NewFunction:3,
BeforeCompile:4,
AfterCompile:5,
ScriptCollected:6};


Debug.ExceptionBreak={Caught:0,
Uncaught:1};


Debug.StepAction={StepOut:0,
StepNext:1,
StepIn:2,
StepMin:3,
StepInMin:4};


Debug.ScriptType={Native:0,
Extension:1,
Normal:2};



Debug.ScriptCompilationType={Host:0,
Eval:1,
JSON:2};


Debug.ScriptBreakPointType={ScriptId:0,
ScriptName:1,
ScriptRegExp:2};

function ScriptTypeFlag(a){
return(1<<a);
}


var next_response_seq=0;
var next_break_point_number=1;
var break_points=[];
var script_break_points=[];
var debugger_flags={
breakPointsActive:{
value:true,
getValue:function(){return this.value;},
setValue:function(a){
this.value=!!a;
%SetDisableBreak(!this.value);
}
},
breakOnCaughtException:{
getValue:function(){return Debug.isBreakOnException();},
setValue:function(a){
if(a){
Debug.setBreakOnException();
}else{
Debug.clearBreakOnException();
}
}
},
breakOnUncaughtException:{
getValue:function(){return Debug.isBreakOnUncaughtException();},
setValue:function(a){
if(a){
Debug.setBreakOnUncaughtException();
}else{
Debug.clearBreakOnUncaughtException();
}
}
},
};
var lol_is_enabled=%HasLOLEnabled();



function MakeBreakPoint(a,b){
var c=new BreakPoint(a,b);
break_points.push(c);
return c;
}






function BreakPoint(a,b){
this.source_position_=a;
if(b){
this.script_break_point_=b;
}else{
this.number_=next_break_point_number++;
}
this.hit_count_=0;
this.active_=true;
this.condition_=null;
this.ignoreCount_=0;
}


BreakPoint.prototype.number=function(){
return this.number_;
};


BreakPoint.prototype.func=function(){
return this.func_;
};


BreakPoint.prototype.source_position=function(){
return this.source_position_;
};


BreakPoint.prototype.hit_count=function(){
return this.hit_count_;
};


BreakPoint.prototype.active=function(){
if(this.script_break_point()){
return this.script_break_point().active();
}
return this.active_;
};


BreakPoint.prototype.condition=function(){
if(this.script_break_point()&&this.script_break_point().condition()){
return this.script_break_point().condition();
}
return this.condition_;
};


BreakPoint.prototype.ignoreCount=function(){
return this.ignoreCount_;
};


BreakPoint.prototype.script_break_point=function(){
return this.script_break_point_;
};


BreakPoint.prototype.enable=function(){
this.active_=true;
};


BreakPoint.prototype.disable=function(){
this.active_=false;
};


BreakPoint.prototype.setCondition=function(a){
this.condition_=a;
};


BreakPoint.prototype.setIgnoreCount=function(a){
this.ignoreCount_=a;
};


BreakPoint.prototype.isTriggered=function(a){

if(!this.active())return false;


if(this.condition()){

try{
var b=a.frame(0).evaluate(this.condition());

if(!(b instanceof ValueMirror)||!%ToBoolean(b.value_)){
return false;
}
}catch(e){

return false;
}
}


this.hit_count_++;
if(this.script_break_point_){
this.script_break_point_.hit_count_++;
}


if(this.ignoreCount_>0){
this.ignoreCount_--;
return false;
}


return true;
};




function IsBreakPointTriggered(a,b){
return b.isTriggered(MakeExecutionState(a));
}





function ScriptBreakPoint(type,script_id_or_name,opt_line,opt_column,
opt_groupId){
this.type_=type;
if(type==Debug.ScriptBreakPointType.ScriptId){
this.script_id_=script_id_or_name;
}else if(type==Debug.ScriptBreakPointType.ScriptName){
this.script_name_=script_id_or_name;
}else if(type==Debug.ScriptBreakPointType.ScriptRegExp){
this.script_regexp_object_=new RegExp(script_id_or_name);
}else{
throw new Error("Unexpected breakpoint type "+type);
}
this.line_=opt_line||0;
this.column_=opt_column;
this.groupId_=opt_groupId;
this.hit_count_=0;
this.active_=true;
this.condition_=null;
this.ignoreCount_=0;
this.break_points_=[];
}



ScriptBreakPoint.prototype.cloneForOtherScript=function(a){
var b=new ScriptBreakPoint(Debug.ScriptBreakPointType.ScriptId,
a.id,this.line_,this.column_,this.groupId_);
b.number_=next_break_point_number++;
script_break_points.push(b);

b.hit_count_=this.hit_count_;
b.active_=this.active_;
b.condition_=this.condition_;
b.ignoreCount_=this.ignoreCount_;
return b;
};


ScriptBreakPoint.prototype.number=function(){
return this.number_;
};


ScriptBreakPoint.prototype.groupId=function(){
return this.groupId_;
};


ScriptBreakPoint.prototype.type=function(){
return this.type_;
};


ScriptBreakPoint.prototype.script_id=function(){
return this.script_id_;
};


ScriptBreakPoint.prototype.script_name=function(){
return this.script_name_;
};


ScriptBreakPoint.prototype.script_regexp_object=function(){
return this.script_regexp_object_;
};


ScriptBreakPoint.prototype.line=function(){
return this.line_;
};


ScriptBreakPoint.prototype.column=function(){
return this.column_;
};


ScriptBreakPoint.prototype.actual_locations=function(){
var a=[];
for(var b=0;b<this.break_points_.length;b++){
a.push(this.break_points_[b].actual_location);
}
return a;
};


ScriptBreakPoint.prototype.update_positions=function(a,b){
this.line_=a;
this.column_=b;
};


ScriptBreakPoint.prototype.hit_count=function(){
return this.hit_count_;
};


ScriptBreakPoint.prototype.active=function(){
return this.active_;
};


ScriptBreakPoint.prototype.condition=function(){
return this.condition_;
};


ScriptBreakPoint.prototype.ignoreCount=function(){
return this.ignoreCount_;
};


ScriptBreakPoint.prototype.enable=function(){
this.active_=true;
};


ScriptBreakPoint.prototype.disable=function(){
this.active_=false;
};


ScriptBreakPoint.prototype.setCondition=function(a){
this.condition_=a;
};


ScriptBreakPoint.prototype.setIgnoreCount=function(a){
this.ignoreCount_=a;


for(var b=0;b<this.break_points_.length;b++){
this.break_points_[b].setIgnoreCount(a);
}
};




ScriptBreakPoint.prototype.matchesScript=function(a){
if(this.type_==Debug.ScriptBreakPointType.ScriptId){
return this.script_id_==a.id;
}else{

if(!(a.line_offset<=this.line_&&
this.line_<a.line_offset+a.lineCount())){
return false;
}
if(this.type_==Debug.ScriptBreakPointType.ScriptName){
return this.script_name_==a.nameOrSourceURL();
}else if(this.type_==Debug.ScriptBreakPointType.ScriptRegExp){
return this.script_regexp_object_.test(a.nameOrSourceURL());
}else{
throw new Error("Unexpected breakpoint type "+this.type_);
}
}
};



ScriptBreakPoint.prototype.set=function(a){
var b=this.column();
var c=this.line();



if((typeof(b)==='undefined')){
var d=a.sourceLine(this.line());


if(!a.sourceColumnStart_){
a.sourceColumnStart_=new Array(a.lineCount());
}


if((typeof(a.sourceColumnStart_[c])==='undefined')){
a.sourceColumnStart_[c]=
d.match(sourceLineBeginningSkip)[0].length;
}
b=a.sourceColumnStart_[c];
}


var g=Debug.findScriptSourcePosition(a,this.line(),b);



if(g===null)return;


break_point=MakeBreakPoint(g,this);
break_point.setIgnoreCount(this.ignoreCount());
var h=%SetScriptBreakPoint(a,g,break_point);
if((typeof(h)==='undefined')){
h=g;
}
var i=a.locationFromPosition(h,true);
break_point.actual_location={line:i.line,
column:i.column,
script_id:a.id};
this.break_points_.push(break_point);
return break_point;
};



ScriptBreakPoint.prototype.clear=function(){
var a=[];
for(var b=0;b<break_points.length;b++){
if(break_points[b].script_break_point()&&
break_points[b].script_break_point()===this){
%ClearBreakPoint(break_points[b]);
}else{
a.push(break_points[b]);
}
}
break_points=a;
this.break_points_=[];
};




function UpdateScriptBreakPoints(a){
for(var b=0;b<script_break_points.length;b++){
var c=script_break_points[b];
if((c.type()==Debug.ScriptBreakPointType.ScriptName||
c.type()==Debug.ScriptBreakPointType.ScriptRegExp)&&
c.matchesScript(a)){
c.set(a);
}
}
}


function GetScriptBreakPoints(a){
var b=[];
for(var c=0;c<script_break_points.length;c++){
if(script_break_points[c].matchesScript(a)){
b.push(script_break_points[c]);
}
}
return b;
}


Debug.setListener=function(a,b){
if(!(%_IsFunction(a))&&!(typeof(a)==='undefined')&&!(a===null)){
throw new Error('Parameters have wrong types.');
}
%SetDebugEventListener(a,b);
};


Debug.breakExecution=function(a){
%Break();
};

Debug.breakLocations=function(a){
if(!(%_IsFunction(a)))throw new Error('Parameters have wrong types.');
return %GetBreakLocations(a);
};






Debug.findScript=function(a){
if((%_IsFunction(a))){
return %FunctionGetScript(a);
}else if((%_IsRegExp(a))){
var b=Debug.scripts();
var c=null;
var d=0;
for(var g in b){
var h=b[g];
if(a.test(h.name)){
c=h;
d++;
}
}





if(d==1){
return c;
}else{
return undefined;
}
}else{
return %GetScript(a);
}
};





Debug.scriptSource=function(a){
return this.findScript(a).source;
};

Debug.source=function(a){
if(!(%_IsFunction(a)))throw new Error('Parameters have wrong types.');
return %FunctionGetSourceCode(a);
};

Debug.disassemble=function(a){
if(!(%_IsFunction(a)))throw new Error('Parameters have wrong types.');
return %DebugDisassembleFunction(a);
};

Debug.disassembleConstructor=function(a){
if(!(%_IsFunction(a)))throw new Error('Parameters have wrong types.');
return %DebugDisassembleConstructor(a);
};

Debug.ExecuteInDebugContext=function(a,b){
if(!(%_IsFunction(a)))throw new Error('Parameters have wrong types.');
return %ExecuteInDebugContext(a,!!b);
};

Debug.sourcePosition=function(a){
if(!(%_IsFunction(a)))throw new Error('Parameters have wrong types.');
return %FunctionGetScriptSourcePosition(a);
};


Debug.findFunctionSourceLocation=function(a,b,c){
var d=%FunctionGetScript(a);
var g=%FunctionGetScriptSourcePosition(a);
return d.locationFromLine(b,c,g);
};




Debug.findScriptSourcePosition=function(a,b,c){
var d=a.locationFromLine(b,c);
return d?d.position:null;
};


Debug.findBreakPoint=function(a,b){
var c;
for(var d=0;d<break_points.length;d++){
if(break_points[d].number()==a){
c=break_points[d];

if(b){
break_points.splice(d,1);
}
break;
}
}
if(c){
return c;
}else{
return this.findScriptBreakPoint(a,b);
}
};

Debug.findBreakPointActualLocations=function(a){
for(var b=0;b<script_break_points.length;b++){
if(script_break_points[b].number()==a){
return script_break_points[b].actual_locations();
}
}
for(var b=0;b<break_points.length;b++){
if(break_points[b].number()==a){
return[break_points[b].actual_location];
}
}
return[];
};

Debug.setBreakPoint=function(a,b,c,d){
if(!(%_IsFunction(a)))throw new Error('Parameters have wrong types.');

if(%FunctionIsAPIFunction(a)){
throw new Error('Cannot set break point in native code.');
}

var g=
this.findFunctionSourceLocation(a,b,c).position;
var h=g-this.sourcePosition(a);

var i=%FunctionGetScript(a);

if(i.type==Debug.ScriptType.Native){
throw new Error('Cannot set break point in native code.');
}


if(i&&i.id){

h+=%FunctionGetScriptSourcePosition(a);


var j=i.locationFromPosition(h,false);
return this.setScriptBreakPointById(i.id,
j.line,j.column,
d);
}else{

var k=MakeBreakPoint(h);
var l=
%SetFunctionBreakPoint(a,h,k);
l+=this.sourcePosition(a);
var m=i.locationFromPosition(l,true);
k.actual_location={line:m.line,
column:m.column,
script_id:i.id};
k.setCondition(d);
return k.number();
}
};


Debug.setBreakPointByScriptIdAndPosition=function(script_id,position,
condition,enabled)
{
break_point=MakeBreakPoint(position);
break_point.setCondition(condition);
if(!enabled){
break_point.disable();
}
var a=this.scripts();
for(var b=0;b<a.length;b++){
if(script_id==a[b].id){
break_point.actual_position=%SetScriptBreakPoint(a[b],position,
break_point);
break;
}
}
return break_point;
};


Debug.enableBreakPoint=function(a){
var b=this.findBreakPoint(a,false);

if(b){
b.enable();
}
};


Debug.disableBreakPoint=function(a){
var b=this.findBreakPoint(a,false);

if(b){
b.disable();
}
};


Debug.changeBreakPointCondition=function(a,b){
var c=this.findBreakPoint(a,false);
c.setCondition(b);
};


Debug.changeBreakPointIgnoreCount=function(a,b){
if(b<0){
throw new Error('Invalid argument');
}
var c=this.findBreakPoint(a,false);
c.setIgnoreCount(b);
};


Debug.clearBreakPoint=function(a){
var b=this.findBreakPoint(a,true);
if(b){
return %ClearBreakPoint(b);
}else{
b=this.findScriptBreakPoint(a,true);
if(!b){
throw new Error('Invalid breakpoint');
}
}
};


Debug.clearAllBreakPoints=function(){
for(var a=0;a<break_points.length;a++){
break_point=break_points[a];
%ClearBreakPoint(break_point);
}
break_points=[];
};


Debug.disableAllBreakPoints=function(){

for(var a=1;a<next_break_point_number;a++){
Debug.disableBreakPoint(a);
}

%ChangeBreakOnException(Debug.ExceptionBreak.Caught,false);
%ChangeBreakOnException(Debug.ExceptionBreak.Uncaught,false);
};


Debug.findScriptBreakPoint=function(a,b){
var c;
for(var d=0;d<script_break_points.length;d++){
if(script_break_points[d].number()==a){
c=script_break_points[d];

if(b){
c.clear();
script_break_points.splice(d,1);
}
break;
}
}
return c;
};




Debug.setScriptBreakPoint=function(type,script_id_or_name,
opt_line,opt_column,opt_condition,
opt_groupId){

var a=
new ScriptBreakPoint(type,script_id_or_name,opt_line,opt_column,
opt_groupId);


a.number_=next_break_point_number++;
a.setCondition(opt_condition);
script_break_points.push(a);



var b=this.scripts();
for(var c=0;c<b.length;c++){
if(a.matchesScript(b[c])){
a.set(b[c]);
}
}

return a.number();
};


Debug.setScriptBreakPointById=function(script_id,
opt_line,opt_column,
opt_condition,opt_groupId){
return this.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptId,
script_id,opt_line,opt_column,
opt_condition,opt_groupId);
};


Debug.setScriptBreakPointByName=function(script_name,
opt_line,opt_column,
opt_condition,opt_groupId){
return this.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptName,
script_name,opt_line,opt_column,
opt_condition,opt_groupId);
};


Debug.setScriptBreakPointByRegExp=function(script_regexp,
opt_line,opt_column,
opt_condition,opt_groupId){
return this.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptRegExp,
script_regexp,opt_line,opt_column,
opt_condition,opt_groupId);
};


Debug.enableScriptBreakPoint=function(a){
var b=this.findScriptBreakPoint(a,false);
b.enable();
};


Debug.disableScriptBreakPoint=function(a){
var b=this.findScriptBreakPoint(a,false);
b.disable();
};


Debug.changeScriptBreakPointCondition=function(
break_point_number,condition){
var a=this.findScriptBreakPoint(break_point_number,false);
a.setCondition(condition);
};


Debug.changeScriptBreakPointIgnoreCount=function(
break_point_number,ignoreCount){
if(ignoreCount<0){
throw new Error('Invalid argument');
}
var a=this.findScriptBreakPoint(break_point_number,false);
a.setIgnoreCount(ignoreCount);
};


Debug.scriptBreakPoints=function(){
return script_break_points;
};


Debug.clearStepping=function(){
%ClearStepping();
};

Debug.setBreakOnException=function(){
return %ChangeBreakOnException(Debug.ExceptionBreak.Caught,true);
};

Debug.clearBreakOnException=function(){
return %ChangeBreakOnException(Debug.ExceptionBreak.Caught,false);
};

Debug.isBreakOnException=function(){
return!!%IsBreakOnException(Debug.ExceptionBreak.Caught);
};

Debug.setBreakOnUncaughtException=function(){
return %ChangeBreakOnException(Debug.ExceptionBreak.Uncaught,true);
};

Debug.clearBreakOnUncaughtException=function(){
return %ChangeBreakOnException(Debug.ExceptionBreak.Uncaught,false);
};

Debug.isBreakOnUncaughtException=function(){
return!!%IsBreakOnException(Debug.ExceptionBreak.Uncaught);
};

Debug.showBreakPoints=function(a,b){
if(!(%_IsFunction(a)))throw new Error('Parameters have wrong types.');
var c=b?this.scriptSource(a):this.source(a);
var d=b?this.sourcePosition(a):0;
var g=this.breakLocations(a);
if(!g)return c;
g.sort(function(h,i){return h-i;});
var j="";
var k=0;
var l;
for(var m=0;m<g.length;m++){
l=g[m]-d;
j+=c.slice(k,l);
j+="[B"+m+"]";
k=l;
}
l=c.length;
j+=c.substring(k,l);
return j;
};




Debug.scripts=function(){

return %DebugGetLoadedScripts();
};


Debug.debuggerFlags=function(){
return debugger_flags;
};

Debug.MakeMirror=MakeMirror;

function MakeExecutionState(a){
return new ExecutionState(a);
}

function ExecutionState(a){
this.break_id=a;
this.selected_frame=0;
}

ExecutionState.prototype.prepareStep=function(a,b){
var c=Debug.StepAction.StepIn;
if(!(typeof(a)==='undefined'))c=%ToNumber(a);
var d=b?%ToNumber(b):1;

return %PrepareStep(this.break_id,c,d);
};

ExecutionState.prototype.evaluateGlobal=function(source,disable_break,
opt_additional_context){
return MakeMirror(%DebugEvaluateGlobal(this.break_id,source,
Boolean(disable_break),
opt_additional_context));
};

ExecutionState.prototype.frameCount=function(){
return %GetFrameCount(this.break_id);
};

ExecutionState.prototype.threadCount=function(){
return %GetThreadCount(this.break_id);
};

ExecutionState.prototype.frame=function(a){

if(a==null)a=this.selected_frame;
if(a<0||a>=this.frameCount()){
throw new Error('Illegal frame index.');
}
return new FrameMirror(this.break_id,a);
};

ExecutionState.prototype.setSelectedFrame=function(a){
var b=%ToNumber(a);
if(b<0||b>=this.frameCount())throw new Error('Illegal frame index.');
this.selected_frame=b;
};

ExecutionState.prototype.selectedFrame=function(){
return this.selected_frame;
};

ExecutionState.prototype.debugCommandProcessor=function(a){
return new DebugCommandProcessor(this,a);
};


function MakeBreakEvent(a,b){
return new BreakEvent(a,b);
}


function BreakEvent(a,b){
this.exec_state_=a;
this.break_points_hit_=b;
}


BreakEvent.prototype.executionState=function(){
return this.exec_state_;
};


BreakEvent.prototype.eventType=function(){
return Debug.DebugEvent.Break;
};


BreakEvent.prototype.func=function(){
return this.exec_state_.frame(0).func();
};


BreakEvent.prototype.sourceLine=function(){
return this.exec_state_.frame(0).sourceLine();
};


BreakEvent.prototype.sourceColumn=function(){
return this.exec_state_.frame(0).sourceColumn();
};


BreakEvent.prototype.sourceLineText=function(){
return this.exec_state_.frame(0).sourceLineText();
};


BreakEvent.prototype.breakPointsHit=function(){
return this.break_points_hit_;
};


BreakEvent.prototype.toJSONProtocol=function(){
var a={seq:next_response_seq++,
type:"event",
event:"break",
body:{invocationText:this.exec_state_.frame(0).invocationText(),
}
};


var b=this.func().script();
if(b){
a.body.sourceLine=this.sourceLine(),
a.body.sourceColumn=this.sourceColumn(),
a.body.sourceLineText=this.sourceLineText(),
a.body.script=MakeScriptObject_(b,false);
}


if(this.breakPointsHit()){
a.body.breakpoints=[];
for(var c=0;c<this.breakPointsHit().length;c++){


var d=this.breakPointsHit()[c];
var g=d.script_break_point();
var h;
if(g){
h=g.number();
}else{
h=d.number();
}
a.body.breakpoints.push(h);
}
}
return JSON.stringify(ObjectToProtocolObject_(a));
};


function MakeExceptionEvent(a,b,c){
return new ExceptionEvent(a,b,c);
}


function ExceptionEvent(a,b,c){
this.exec_state_=a;
this.exception_=b;
this.uncaught_=c;
}


ExceptionEvent.prototype.executionState=function(){
return this.exec_state_;
};


ExceptionEvent.prototype.eventType=function(){
return Debug.DebugEvent.Exception;
};


ExceptionEvent.prototype.exception=function(){
return this.exception_;
};


ExceptionEvent.prototype.uncaught=function(){
return this.uncaught_;
};


ExceptionEvent.prototype.func=function(){
return this.exec_state_.frame(0).func();
};


ExceptionEvent.prototype.sourceLine=function(){
return this.exec_state_.frame(0).sourceLine();
};


ExceptionEvent.prototype.sourceColumn=function(){
return this.exec_state_.frame(0).sourceColumn();
};


ExceptionEvent.prototype.sourceLineText=function(){
return this.exec_state_.frame(0).sourceLineText();
};


ExceptionEvent.prototype.toJSONProtocol=function(){
var a=new ProtocolMessage();
a.event="exception";
a.body={uncaught:this.uncaught_,
exception:MakeMirror(this.exception_)
};


if(this.exec_state_.frameCount()>0){
a.body.sourceLine=this.sourceLine();
a.body.sourceColumn=this.sourceColumn();
a.body.sourceLineText=this.sourceLineText();


var b=this.func().script();
if(b){
a.body.script=MakeScriptObject_(b,false);
}
}else{
a.body.sourceLine=-1;
}

return a.toJSONProtocol();
};


function MakeCompileEvent(a,b,c){
return new CompileEvent(a,b,c);
}


function CompileEvent(a,b,c){
this.exec_state_=a;
this.script_=MakeMirror(b);
this.before_=c;
}


CompileEvent.prototype.executionState=function(){
return this.exec_state_;
};


CompileEvent.prototype.eventType=function(){
if(this.before_){
return Debug.DebugEvent.BeforeCompile;
}else{
return Debug.DebugEvent.AfterCompile;
}
};


CompileEvent.prototype.script=function(){
return this.script_;
};


CompileEvent.prototype.toJSONProtocol=function(){
var a=new ProtocolMessage();
a.running=true;
if(this.before_){
a.event="beforeCompile";
}else{
a.event="afterCompile";
}
a.body={};
a.body.script=this.script_;

return a.toJSONProtocol();
};


function MakeNewFunctionEvent(a){
return new NewFunctionEvent(a);
}


function NewFunctionEvent(a){
this.func=a;
}


NewFunctionEvent.prototype.eventType=function(){
return Debug.DebugEvent.NewFunction;
};


NewFunctionEvent.prototype.name=function(){
return this.func.name;
};


NewFunctionEvent.prototype.setBreakPoint=function(a){
Debug.setBreakPoint(this.func,a||0);
};


function MakeScriptCollectedEvent(a,b){
return new ScriptCollectedEvent(a,b);
}


function ScriptCollectedEvent(a,b){
this.exec_state_=a;
this.id_=b;
}


ScriptCollectedEvent.prototype.id=function(){
return this.id_;
};


ScriptCollectedEvent.prototype.executionState=function(){
return this.exec_state_;
};


ScriptCollectedEvent.prototype.toJSONProtocol=function(){
var a=new ProtocolMessage();
a.running=true;
a.event="scriptCollected";
a.body={};
a.body.script={id:this.id()};
return a.toJSONProtocol();
};


function MakeScriptObject_(a,b){
var c={id:a.id(),
name:a.name(),
lineOffset:a.lineOffset(),
columnOffset:a.columnOffset(),
lineCount:a.lineCount(),
};
if(!(typeof(a.data())==='undefined')){
c.data=a.data();
}
if(b){
c.source=a.source();
}
return c;
}


function DebugCommandProcessor(a,b){
this.exec_state_=a;
this.running_=b||false;
}


DebugCommandProcessor.prototype.processDebugRequest=function(a){
return this.processDebugJSONRequest(a);
};


function ProtocolMessage(a){

this.seq=next_response_seq++;

if(a){


this.type='response';
this.request_seq=a.seq;
this.command=a.command;
}else{

this.type='event';
}
this.success=true;

this.running=undefined;
}


ProtocolMessage.prototype.setOption=function(a,b){
if(!this.options_){
this.options_={};
}
this.options_[a]=b;
};


ProtocolMessage.prototype.failed=function(a){
this.success=false;
this.message=a;
};


ProtocolMessage.prototype.toJSONProtocol=function(){

var a={};
a.seq=this.seq;
if(this.request_seq){
a.request_seq=this.request_seq;
}
a.type=this.type;
if(this.event){
a.event=this.event;
}
if(this.command){
a.command=this.command;
}
if(this.success){
a.success=this.success;
}else{
a.success=false;
}
if(this.body){

var b;
var c=MakeMirrorSerializer(true,this.options_);
if(this.body instanceof Mirror){
b=c.serializeValue(this.body);
}else if(this.body instanceof Array){
b=[];
for(var d=0;d<this.body.length;d++){
if(this.body[d]instanceof Mirror){
b.push(c.serializeValue(this.body[d]));
}else{
b.push(ObjectToProtocolObject_(this.body[d],c));
}
}
}else{
b=ObjectToProtocolObject_(this.body,c);
}
a.body=b;
a.refs=c.serializeReferencedObjects();
}
if(this.message){
a.message=this.message;
}
a.running=this.running;
return JSON.stringify(a);
};


DebugCommandProcessor.prototype.createResponse=function(a){
return new ProtocolMessage(a);
};


DebugCommandProcessor.prototype.processDebugJSONRequest=function(
json_request){
var a;
var b;
try{
try{

a=JSON.parse(json_request);


b=this.createResponse(a);

if(!a.type){
throw new Error('Type not specified');
}

if(a.type!='request'){
throw new Error("Illegal type '"+a.type+"' in request");
}

if(!a.command){
throw new Error('Command not specified');
}

if(a.arguments){
var c=a.arguments;


if(c.inlineRefs||c.compactFormat){
b.setOption('inlineRefs',true);
}
if(!(typeof(c.maxStringLength)==='undefined')){
b.setOption('maxStringLength',c.maxStringLength);
}
}

if(a.command=='continue'){
this.continueRequest_(a,b);
}else if(a.command=='break'){
this.breakRequest_(a,b);
}else if(a.command=='setbreakpoint'){
this.setBreakPointRequest_(a,b);
}else if(a.command=='changebreakpoint'){
this.changeBreakPointRequest_(a,b);
}else if(a.command=='clearbreakpoint'){
this.clearBreakPointRequest_(a,b);
}else if(a.command=='clearbreakpointgroup'){
this.clearBreakPointGroupRequest_(a,b);
}else if(a.command=='disconnect'){
this.disconnectRequest_(a,b);
}else if(a.command=='setexceptionbreak'){
this.setExceptionBreakRequest_(a,b);
}else if(a.command=='listbreakpoints'){
this.listBreakpointsRequest_(a,b);
}else if(a.command=='backtrace'){
this.backtraceRequest_(a,b);
}else if(a.command=='frame'){
this.frameRequest_(a,b);
}else if(a.command=='scopes'){
this.scopesRequest_(a,b);
}else if(a.command=='scope'){
this.scopeRequest_(a,b);
}else if(a.command=='evaluate'){
this.evaluateRequest_(a,b);
}else if(lol_is_enabled&&a.command=='getobj'){
this.getobjRequest_(a,b);
}else if(a.command=='lookup'){
this.lookupRequest_(a,b);
}else if(a.command=='references'){
this.referencesRequest_(a,b);
}else if(a.command=='source'){
this.sourceRequest_(a,b);
}else if(a.command=='scripts'){
this.scriptsRequest_(a,b);
}else if(a.command=='threads'){
this.threadsRequest_(a,b);
}else if(a.command=='suspend'){
this.suspendRequest_(a,b);
}else if(a.command=='version'){
this.versionRequest_(a,b);
}else if(a.command=='profile'){
this.profileRequest_(a,b);
}else if(a.command=='changelive'){
this.changeLiveRequest_(a,b);
}else if(a.command=='restartframe'){
this.restartFrameRequest_(a,b);
}else if(a.command=='flags'){
this.debuggerFlagsRequest_(a,b);
}else if(a.command=='v8flags'){
this.v8FlagsRequest_(a,b);


}else if(a.command=='gc'){
this.gcRequest_(a,b);


}else if(lol_is_enabled&&a.command=='lol-capture'){
this.lolCaptureRequest_(a,b);
}else if(lol_is_enabled&&a.command=='lol-delete'){
this.lolDeleteRequest_(a,b);
}else if(lol_is_enabled&&a.command=='lol-diff'){
this.lolDiffRequest_(a,b);
}else if(lol_is_enabled&&a.command=='lol-getid'){
this.lolGetIdRequest_(a,b);
}else if(lol_is_enabled&&a.command=='lol-info'){
this.lolInfoRequest_(a,b);
}else if(lol_is_enabled&&a.command=='lol-reset'){
this.lolResetRequest_(a,b);
}else if(lol_is_enabled&&a.command=='lol-retainers'){
this.lolRetainersRequest_(a,b);
}else if(lol_is_enabled&&a.command=='lol-path'){
this.lolPathRequest_(a,b);
}else if(lol_is_enabled&&a.command=='lol-print'){
this.lolPrintRequest_(a,b);
}else if(lol_is_enabled&&a.command=='lol-stats'){
this.lolStatsRequest_(a,b);

}else{
throw new Error('Unknown command "'+a.command+'" in request');
}
}catch(e){

if(!b){
b=this.createResponse();
}
b.success=false;
b.message=%ToString(e);
}


try{
if(!(typeof(b.running)==='undefined')){

this.running_=b.running;
}
b.running=this.running_;
return b.toJSONProtocol();
}catch(e){

return'{"seq":'+b.seq+','+
'"request_seq":'+a.seq+','+
'"type":"response",'+
'"success":false,'+
'"message":"Internal error: '+%ToString(e)+'"}';
}
}catch(e){

return'{"seq":0,"type":"response","success":false,"message":"Internal error"}';
}
};


DebugCommandProcessor.prototype.continueRequest_=function(a,b){

if(a.arguments){
var c=1;
var d=Debug.StepAction.StepIn;


var g=a.arguments.stepaction;
var h=a.arguments.stepcount;


if(h){
c=%ToNumber(h);
if(c<0){
throw new Error('Invalid stepcount argument "'+h+'".');
}
}


if(g){
if(g=='in'){
d=Debug.StepAction.StepIn;
}else if(g=='min'){
d=Debug.StepAction.StepMin;
}else if(g=='next'){
d=Debug.StepAction.StepNext;
}else if(g=='out'){
d=Debug.StepAction.StepOut;
}else{
throw new Error('Invalid stepaction argument "'+g+'".');
}
}


this.exec_state_.prepareStep(d,c);
}


b.running=true;
};


DebugCommandProcessor.prototype.breakRequest_=function(a,b){

};


DebugCommandProcessor.prototype.setBreakPointRequest_=
function(a,b){

if(!a.arguments){
b.failed('Missing arguments');
return;
}


var c=a.arguments.type;
var d=a.arguments.target;
var g=a.arguments.line;
var h=a.arguments.column;
var i=(typeof(a.arguments.enabled)==='undefined')?
true:a.arguments.enabled;
var j=a.arguments.condition;
var k=a.arguments.ignoreCount;
var l=a.arguments.groupId;


if(!c||(typeof(d)==='undefined')){
b.failed('Missing argument "type" or "target"');
return;
}


var m;
if(c=='function'){

if(!(typeof(d)==='string')){
b.failed('Argument "target" is not a string value');
return;
}
var o;
try{

o=this.exec_state_.evaluateGlobal(d).value();
}catch(e){
b.failed('Error: "'+%ToString(e)+
'" evaluating "'+d+'"');
return;
}
if(!(%_IsFunction(o))){
b.failed('"'+d+'" does not evaluate to a function');
return;
}


m=Debug.setBreakPoint(o,g,h,j);
}else if(c=='handle'){

var q=parseInt(d,10);
var r=LookupMirror(q);
if(!r){
return b.failed('Object #'+q+'# not found');
}
if(!r.isFunction()){
return b.failed('Object #'+q+'# is not a function');
}


m=Debug.setBreakPoint(r.value(),
g,h,j);
}else if(c=='script'){

m=
Debug.setScriptBreakPointByName(d,g,h,j,
l);
}else if(c=='scriptId'){
m=
Debug.setScriptBreakPointById(d,g,h,j,l);
}else if(c=='scriptRegExp'){
m=
Debug.setScriptBreakPointByRegExp(d,g,h,j,
l);
}else{
b.failed('Illegal type "'+c+'"');
return;
}


var t=Debug.findBreakPoint(m);
if(k){
Debug.changeBreakPointIgnoreCount(m,k);
}
if(!i){
Debug.disableBreakPoint(m);
}


b.body={type:c,
breakpoint:m};


if(t instanceof ScriptBreakPoint){
if(t.type()==Debug.ScriptBreakPointType.ScriptId){
b.body.type='scriptId';
b.body.script_id=t.script_id();
}else if(t.type()==Debug.ScriptBreakPointType.ScriptName){
b.body.type='scriptName';
b.body.script_name=t.script_name();
}else if(t.type()==Debug.ScriptBreakPointType.ScriptRegExp){
b.body.type='scriptRegExp';
b.body.script_regexp=t.script_regexp_object().source;
}else{
throw new Error("Internal error: Unexpected breakpoint type: "+
t.type());
}
b.body.line=t.line();
b.body.column=t.column();
b.body.actual_locations=t.actual_locations();
}else{
b.body.type='function';
b.body.actual_locations=[t.actual_location];
}
};


DebugCommandProcessor.prototype.changeBreakPointRequest_=function(
request,response){

if(!request.arguments){
response.failed('Missing arguments');
return;
}


var a=%ToNumber(request.arguments.breakpoint);
var b=request.arguments.enabled;
var c=request.arguments.condition;
var d=request.arguments.ignoreCount;


if(!a){
response.failed('Missing argument "breakpoint"');
return;
}


if(!(typeof(b)==='undefined')){
if(b){
Debug.enableBreakPoint(a);
}else{
Debug.disableBreakPoint(a);
}
}


if(!(typeof(c)==='undefined')){
Debug.changeBreakPointCondition(a,c);
}


if(!(typeof(d)==='undefined')){
Debug.changeBreakPointIgnoreCount(a,d);
}
};


DebugCommandProcessor.prototype.clearBreakPointGroupRequest_=function(
request,response){

if(!request.arguments){
response.failed('Missing arguments');
return;
}


var a=request.arguments.groupId;


if(!a){
response.failed('Missing argument "groupId"');
return;
}

var b=[];
var c=[];
for(var d=0;d<script_break_points.length;d++){
var g=script_break_points[d];
if(g.groupId()==a){
b.push(g.number());
g.clear();
}else{
c.push(g);
}
}
script_break_points=c;


response.body={breakpoints:b};
};


DebugCommandProcessor.prototype.clearBreakPointRequest_=function(
request,response){

if(!request.arguments){
response.failed('Missing arguments');
return;
}


var a=%ToNumber(request.arguments.breakpoint);


if(!a){
response.failed('Missing argument "breakpoint"');
return;
}


Debug.clearBreakPoint(a);


response.body={breakpoint:a};
};


DebugCommandProcessor.prototype.listBreakpointsRequest_=function(
request,response){
var a=[];
for(var b=0;b<script_break_points.length;b++){
var c=script_break_points[b];

var d={
number:c.number(),
line:c.line(),
column:c.column(),
groupId:c.groupId(),
hit_count:c.hit_count(),
active:c.active(),
condition:c.condition(),
ignoreCount:c.ignoreCount(),
actual_locations:c.actual_locations()
};

if(c.type()==Debug.ScriptBreakPointType.ScriptId){
d.type='scriptId';
d.script_id=c.script_id();
}else if(c.type()==Debug.ScriptBreakPointType.ScriptName){
d.type='scriptName';
d.script_name=c.script_name();
}else if(c.type()==Debug.ScriptBreakPointType.ScriptRegExp){
d.type='scriptRegExp';
d.script_regexp=c.script_regexp_object().source;
}else{
throw new Error("Internal error: Unexpected breakpoint type: "+
c.type());
}
a.push(d);
}

response.body={
breakpoints:a,
breakOnExceptions:Debug.isBreakOnException(),
breakOnUncaughtExceptions:Debug.isBreakOnUncaughtException()
};
};


DebugCommandProcessor.prototype.disconnectRequest_=
function(a,b){
Debug.disableAllBreakPoints();
this.continueRequest_(a,b);
};


DebugCommandProcessor.prototype.setExceptionBreakRequest_=
function(a,b){

if(!a.arguments){
b.failed('Missing arguments');
return;
}


var c=a.arguments.type;
if(!c){
b.failed('Missing argument "type"');
return;
}


var d;
if(c=='all'){
d=!Debug.isBreakOnException();
}else if(c=='uncaught'){
d=!Debug.isBreakOnUncaughtException();
}


if(!(typeof(a.arguments.enabled)==='undefined')){
d=a.arguments.enabled;
if((d!=true)&&(d!=false)){
b.failed('Illegal value for "enabled":"'+d+'"');
}
}


if(c=='all'){
%ChangeBreakOnException(Debug.ExceptionBreak.Caught,d);
}else if(c=='uncaught'){
%ChangeBreakOnException(Debug.ExceptionBreak.Uncaught,d);
}else{
b.failed('Unknown "type":"'+c+'"');
}


b.body={'type':c,'enabled':d};
};


DebugCommandProcessor.prototype.backtraceRequest_=function(
request,response){

var a=this.exec_state_.frameCount();


if(a==0){
response.body={
totalFrames:a
};
return;
}


var b=0;
var c=kDefaultBacktraceLength;


if(request.arguments){
if(request.arguments.fromFrame){
b=request.arguments.fromFrame;
}
if(request.arguments.toFrame){
c=request.arguments.toFrame;
}
if(request.arguments.bottom){
var d=a-b;
b=a-c;
c=d;
}
if(b<0||c<0){
return response.failed('Invalid frame number');
}
}


c=Math.min(a,c);

if(c<=b){
var g='Invalid frame range';
return response.failed(g);
}


var h=[];
for(var i=b;i<c;i++){
h.push(this.exec_state_.frame(i));
}
response.body={
fromFrame:b,
toFrame:c,
totalFrames:a,
frames:h
};
};


DebugCommandProcessor.prototype.frameRequest_=function(a,b){

if(this.exec_state_.frameCount()==0){
return b.failed('No frames');
}


if(a.arguments){
var c=a.arguments.number;
if(c<0||this.exec_state_.frameCount()<=c){
return b.failed('Invalid frame number');
}

this.exec_state_.setSelectedFrame(a.arguments.number);
}
b.body=this.exec_state_.frame();
};


DebugCommandProcessor.prototype.frameForScopeRequest_=function(a){


if(a.arguments&&!(typeof(a.arguments.frameNumber)==='undefined')){
frame_index=a.arguments.frameNumber;
if(frame_index<0||this.exec_state_.frameCount()<=frame_index){
throw new Error('Invalid frame number');
}
return this.exec_state_.frame(frame_index);
}else{
return this.exec_state_.frame();
}
};





DebugCommandProcessor.prototype.scopeHolderForScopeRequest_=
function(a){
if(a.arguments&&"functionHandle"in a.arguments){
if(!(typeof(a.arguments.functionHandle)==='number')){
throw new Error('Function handle must be a number');
}
var b=LookupMirror(a.arguments.functionHandle);
if(!b){
throw new Error('Failed to find function object by handle');
}
if(!b.isFunction()){
throw new Error('Value of non-function type is found by handle');
}
return b;
}else{

if(this.exec_state_.frameCount()==0){
throw new Error('No scopes');
}


var c=this.frameForScopeRequest_(a);
return c;
}
}


DebugCommandProcessor.prototype.scopesRequest_=function(a,b){
var c=this.scopeHolderForScopeRequest_(a);


var d=c.scopeCount();
var g=[];
for(var h=0;h<d;h++){
g.push(c.scope(h));
}
b.body={
fromScope:0,
toScope:d,
totalScopes:d,
scopes:g
};
};


DebugCommandProcessor.prototype.scopeRequest_=function(a,b){

var c=this.scopeHolderForScopeRequest_(a);


var d=0;
if(a.arguments&&!(typeof(a.arguments.number)==='undefined')){
d=%ToNumber(a.arguments.number);
if(d<0||c.scopeCount()<=d){
return b.failed('Invalid scope number');
}
}

b.body=c.scope(d);
};


DebugCommandProcessor.prototype.evaluateRequest_=function(a,b){
if(!a.arguments){
return b.failed('Missing arguments');
}


var c=a.arguments.expression;
var d=a.arguments.frame;
var g=a.arguments.global;
var h=a.arguments.disable_break;
var i=a.arguments.additional_context;



try{
c=String(c);
}catch(e){
return b.failed('Failed to convert expression argument to string');
}


if(!(typeof(d)==='undefined')&&g){
return b.failed('Arguments "frame" and "global" are exclusive');
}

var j;
if(i){
j={};
for(var k=0;k<i.length;k++){
var l=i[k];
if(!(typeof(l.name)==='string')||!(typeof(l.handle)==='number')){
return b.failed("Context element #"+k+
" must contain name:string and handle:number");
}
var m=LookupMirror(l.handle);
if(!m){
return b.failed("Context object '"+l.name+
"' #"+l.handle+"# not found");
}
j[l.name]=m.value();
}
}


if(g){

b.body=this.exec_state_.evaluateGlobal(
c,Boolean(h),j);
return;
}


if((typeof(h)==='undefined')){
h=true;
}


if(this.exec_state_.frameCount()==0){
return b.failed('No frames');
}


if(!(typeof(d)==='undefined')){
var o=%ToNumber(d);
if(o<0||o>=this.exec_state_.frameCount()){
return b.failed('Invalid frame "'+d+'"');
}

b.body=this.exec_state_.frame(o).evaluate(
c,Boolean(h),j);
return;
}else{

b.body=this.exec_state_.frame().evaluate(
c,Boolean(h),j);
return;
}
};


DebugCommandProcessor.prototype.getobjRequest_=function(a,b){
if(!a.arguments){
return b.failed('Missing arguments');
}


var c=a.arguments.obj_id;


if((typeof(c)==='undefined')){
return b.failed('Argument "obj_id" missing');
}


b.body=MakeMirror(%GetLOLObj(c));
};


DebugCommandProcessor.prototype.lookupRequest_=function(a,b){
if(!a.arguments){
return b.failed('Missing arguments');
}


var c=a.arguments.handles;


if((typeof(c)==='undefined')){
return b.failed('Argument "handles" missing');
}


if(!(typeof(a.arguments.includeSource)==='undefined')){
includeSource=%ToBoolean(a.arguments.includeSource);
b.setOption('includeSource',includeSource);
}


var d={};
for(var g=0;g<c.length;g++){
var h=c[g];
var i=LookupMirror(h);
if(!i){
return b.failed('Object #'+h+'# not found');
}
d[h]=i;
}
b.body=d;
};


DebugCommandProcessor.prototype.referencesRequest_=
function(a,b){
if(!a.arguments){
return b.failed('Missing arguments');
}


var c=a.arguments.type;
var d=a.arguments.handle;


if((typeof(c)==='undefined')){
return b.failed('Argument "type" missing');
}
if((typeof(d)==='undefined')){
return b.failed('Argument "handle" missing');
}
if(c!='referencedBy'&&c!='constructedBy'){
return b.failed('Invalid type "'+c+'"');
}


var g=LookupMirror(d);
if(g){
if(c=='referencedBy'){
b.body=g.referencedBy();
}else{
b.body=g.constructedBy();
}
}else{
return b.failed('Object #'+d+'# not found');
}
};


DebugCommandProcessor.prototype.sourceRequest_=function(a,b){

if(this.exec_state_.frameCount()==0){
return b.failed('No source');
}

var c;
var d;
var g=this.exec_state_.frame();
if(a.arguments){

c=a.arguments.fromLine;
d=a.arguments.toLine;

if(!(typeof(a.arguments.frame)==='undefined')){
var h=%ToNumber(a.arguments.frame);
if(h<0||h>=this.exec_state_.frameCount()){
return b.failed('Invalid frame "'+g+'"');
}
g=this.exec_state_.frame(h);
}
}


var i=g.func().script();
if(!i){
return b.failed('No source');
}


var j=i.sourceSlice(c,d);
if(!j){
return b.failed('Invalid line interval');
}
b.body={};
b.body.source=j.sourceText();
b.body.fromLine=j.from_line;
b.body.toLine=j.to_line;
b.body.fromPosition=j.from_position;
b.body.toPosition=j.to_position;
b.body.totalLines=i.lineCount();
};


DebugCommandProcessor.prototype.scriptsRequest_=function(a,b){
var c=ScriptTypeFlag(Debug.ScriptType.Normal);
var d=false;
var g=null;
if(a.arguments){

if(!(typeof(a.arguments.types)==='undefined')){
c=%ToNumber(a.arguments.types);
if(isNaN(c)||c<0){
return b.failed('Invalid types "'+
a.arguments.types+'"');
}
}

if(!(typeof(a.arguments.includeSource)==='undefined')){
d=%ToBoolean(a.arguments.includeSource);
b.setOption('includeSource',d);
}

if((%_IsArray(a.arguments.ids))){
g={};
var h=a.arguments.ids;
for(var i=0;i<h.length;i++){
g[h[i]]=true;
}
}

var j=null;
var k=null;
if(!(typeof(a.arguments.filter)==='undefined')){
var l=%ToNumber(a.arguments.filter);
if(!isNaN(l)){
k=l;
}
j=a.arguments.filter;
}
}


var m=%DebugGetLoadedScripts();

b.body=[];

for(var i=0;i<m.length;i++){
if(g&&!g[m[i].id]){
continue;
}
if(j||k){
var o=m[i];
var q=false;
if(k&&!q){
if(o.id&&o.id===k){
q=true;
}
}
if(j&&!q){
if(o.name&&o.name.indexOf(j)>=0){
q=true;
}
}
if(!q)continue;
}
if(c&ScriptTypeFlag(m[i].type)){
b.body.push(MakeMirror(m[i]));
}
}
};


DebugCommandProcessor.prototype.threadsRequest_=function(a,b){

var c=this.exec_state_.threadCount();


var d=[];
for(var g=0;g<c;g++){
var h=%GetThreadDetails(this.exec_state_.break_id,g);
var i={current:h[0],
id:h[1]
};
d.push(i);
}


b.body={
totalThreads:c,
threads:d
};
};


DebugCommandProcessor.prototype.suspendRequest_=function(a,b){
b.running=false;
};


DebugCommandProcessor.prototype.versionRequest_=function(a,b){
b.body={
V8Version:%GetV8Version()
};
};


DebugCommandProcessor.prototype.profileRequest_=function(a,b){
if(a.arguments.command=='resume'){
%ProfilerResume();
}else if(a.arguments.command=='pause'){
%ProfilerPause();
}else{
return b.failed('Unknown command');
}
b.body={};
};


DebugCommandProcessor.prototype.changeLiveRequest_=function(
request,response){
if(!request.arguments){
return response.failed('Missing arguments');
}
var a=request.arguments.script_id;
var b=!!request.arguments.preview_only;

var c=%DebugGetLoadedScripts();

var d=null;
for(var g=0;g<c.length;g++){
if(c[g].id==a){
d=c[g];
}
}
if(!d){
response.failed('Script not found');
return;
}

var h=new Array();

if(!(typeof(request.arguments.new_source)==='string')){
throw"new_source argument expected";
}

var i=request.arguments.new_source;

var j=Debug.LiveEdit.SetScriptSource(d,
i,b,h);
response.body={change_log:h,result:j};

if(!b&&!this.running_&&j.stack_modified){
response.body.stepin_recommended=true;
}
};


DebugCommandProcessor.prototype.restartFrameRequest_=function(
request,response){
if(!request.arguments){
return response.failed('Missing arguments');
}
var a=request.arguments.frame;


if(this.exec_state_.frameCount()==0){
return response.failed('No frames');
}

var b;

if(!(typeof(a)==='undefined')){
var c=%ToNumber(a);
if(c<0||c>=this.exec_state_.frameCount()){
return response.failed('Invalid frame "'+a+'"');
}

b=this.exec_state_.frame(c);
}else{

b=this.exec_state_.frame();
}

var d=Debug.LiveEdit.RestartFrame(b);
response.body={result:d};
};


DebugCommandProcessor.prototype.debuggerFlagsRequest_=function(request,
response){

if(!request.arguments){
response.failed('Missing arguments');
return;
}


var a=request.arguments.flags;

response.body={flags:[]};
if(!(typeof(a)==='undefined')){
for(var b=0;b<a.length;b++){
var c=a[b].name;
var d=debugger_flags[c];
if(!d){
continue;
}
if('value'in a[b]){
d.setValue(a[b].value);
}
response.body.flags.push({name:c,value:d.getValue()});
}
}else{
for(var c in debugger_flags){
var g=debugger_flags[c].getValue();
response.body.flags.push({name:c,value:g});
}
}
};


DebugCommandProcessor.prototype.v8FlagsRequest_=function(a,b){
var c=a.arguments.flags;
if(!c)c='';
%SetFlags(c);
};


DebugCommandProcessor.prototype.gcRequest_=function(a,b){
var c=a.arguments.type;
if(!c)c='all';

var d=%GetHeapUsage();
%CollectGarbage(c);
var g=%GetHeapUsage();

b.body={"before":d,"after":g};
};


DebugCommandProcessor.prototype.lolCaptureRequest_=
function(a,b){
b.body=%CaptureLOL();
};


DebugCommandProcessor.prototype.lolDeleteRequest_=
function(a,b){
var c=a.arguments.id;
var d=%DeleteLOL(c);
if(d){
b.body={id:c};
}else{
b.failed('Failed to delete: live object list '+c+' not found.');
}
};


DebugCommandProcessor.prototype.lolDiffRequest_=function(a,b){
var c=a.arguments.id1;
var d=a.arguments.id2;
var g=a.arguments.verbose;
var h=a.arguments.filter;
if(g===true){
var i=a.arguments.start;
var j=a.arguments.count;
b.body=%DumpLOL(c,d,i,j,h);
}else{
b.body=%SummarizeLOL(c,d,h);
}
};


DebugCommandProcessor.prototype.lolGetIdRequest_=function(a,b){
var c=a.arguments.address;
b.body={};
b.body.id=%GetLOLObjId(c);
};


DebugCommandProcessor.prototype.lolInfoRequest_=function(a,b){
var c=a.arguments.start;
var d=a.arguments.count;
b.body=%InfoLOL(c,d);
};


DebugCommandProcessor.prototype.lolResetRequest_=function(a,b){
%ResetLOL();
};


DebugCommandProcessor.prototype.lolRetainersRequest_=
function(a,b){
var c=a.arguments.id;
var d=a.arguments.verbose;
var g=a.arguments.start;
var h=a.arguments.count;
var i=a.arguments.filter;

b.body=%GetLOLObjRetainers(c,Mirror.prototype,d,
g,h,i);
};


DebugCommandProcessor.prototype.lolPathRequest_=function(a,b){
var c=a.arguments.id1;
var d=a.arguments.id2;
b.body={};
b.body.path=%GetLOLPath(c,d,Mirror.prototype);
};


DebugCommandProcessor.prototype.lolPrintRequest_=function(a,b){
var c=a.arguments.id;
b.body={};
b.body.dump=%PrintLOLObj(c);
};




DebugCommandProcessor.prototype.isRunning=function(){
return this.running_;
};


DebugCommandProcessor.prototype.systemBreak=function(a,b){
return %SystemBreak();
};


function NumberToHex8Str(a){
var b="";
for(var c=0;c<8;++c){
var d=hexCharArray[a&0x0F];
b=d+b;
a=a>>>4;
}
return b;
}














function ObjectToProtocolObject_(a,b){
var c={};
for(var d in a){

if(typeof d=='string'){

var g=ValueToProtocolValue_(a[d],
b);

if(!(typeof(g)==='undefined')){
c[d]=g;
}
}
}

return c;
}










function ArrayToProtocolArray_(a,b){
var c=[];
for(var d=0;d<a.length;d++){
c.push(ValueToProtocolValue_(a[d],b));
}
return c;
}









function ValueToProtocolValue_(a,b){

var c;
switch(typeof a){
case'object':
if(a instanceof Mirror){
c=b.serializeValue(a);
}else if((%_IsArray(a))){
c=ArrayToProtocolArray_(a,b);
}else{
c=ObjectToProtocolObject_(a,b);
}
break;

case'boolean':
case'string':
case'number':
c=a;
break;

default:
c=null;
}
return c;
}





























var next_handle_=0;
var next_transient_handle_=-1;


var mirror_cache_=[];





function ClearMirrorCache(){
next_handle_=0;
mirror_cache_=[];
}










function MakeMirror(a,b){
var c;


if(!b){
for(id in mirror_cache_){
c=mirror_cache_[id];
if(c.value()===a){
return c;
}

if(c.isNumber()&&isNaN(c.value())&&
typeof a=='number'&&isNaN(a)){
return c;
}
}
}

if((typeof(a)==='undefined')){
c=new UndefinedMirror();
}else if((a===null)){
c=new NullMirror();
}else if((typeof(a)==='boolean')){
c=new BooleanMirror(a);
}else if((typeof(a)==='number')){
c=new NumberMirror(a);
}else if((typeof(a)==='string')){
c=new StringMirror(a);
}else if((%_IsArray(a))){
c=new ArrayMirror(a);
}else if((%_ClassOf(a)==='Date')){
c=new DateMirror(a);
}else if((%_IsFunction(a))){
c=new FunctionMirror(a);
}else if((%_IsRegExp(a))){
c=new RegExpMirror(a);
}else if((%_ClassOf(a)==='Error')){
c=new ErrorMirror(a);
}else if((%_ClassOf(a)==='Script')){
c=new ScriptMirror(a);
}else{
c=new ObjectMirror(a,OBJECT_TYPE,b);
}

mirror_cache_[c.handle()]=c;
return c;
}









function LookupMirror(a){
return mirror_cache_[a];
}







function GetUndefinedMirror(){
return MakeMirror(void 0);
}















function inherits(a,b){
var c=function(){};
c.prototype=b.prototype;
a.super_=b.prototype;
a.prototype=new c();
a.prototype.constructor=a;
}



var UNDEFINED_TYPE='undefined';
var NULL_TYPE='null';
var BOOLEAN_TYPE='boolean';
var NUMBER_TYPE='number';
var STRING_TYPE='string';
var OBJECT_TYPE='object';
var FUNCTION_TYPE='function';
var REGEXP_TYPE='regexp';
var ERROR_TYPE='error';
var PROPERTY_TYPE='property';
var INTERNAL_PROPERTY_TYPE='internalProperty';
var FRAME_TYPE='frame';
var SCRIPT_TYPE='script';
var CONTEXT_TYPE='context';
var SCOPE_TYPE='scope';


var kMaxProtocolStringLength=80;


var PropertyKind={};
PropertyKind.Named=1;
PropertyKind.Indexed=2;



var PropertyType={};
PropertyType.Normal=0;
PropertyType.Field=1;
PropertyType.ConstantFunction=2;
PropertyType.Callbacks=3;
PropertyType.Handler=4;
PropertyType.Interceptor=5;
PropertyType.Transition=6;
PropertyType.Nonexistent=7;



var PropertyAttribute={};
PropertyAttribute.None=0;
PropertyAttribute.ReadOnly=1;
PropertyAttribute.DontEnum=2;
PropertyAttribute.DontDelete=4;



var ScopeType={Global:0,
Local:1,
With:2,
Closure:3,
Catch:4,
Block:5};



























function Mirror(a){
this.type_=a;
}


Mirror.prototype.type=function(){
return this.type_;
};






Mirror.prototype.isValue=function(){
return this instanceof ValueMirror;
};






Mirror.prototype.isUndefined=function(){
return this instanceof UndefinedMirror;
};






Mirror.prototype.isNull=function(){
return this instanceof NullMirror;
};






Mirror.prototype.isBoolean=function(){
return this instanceof BooleanMirror;
};






Mirror.prototype.isNumber=function(){
return this instanceof NumberMirror;
};






Mirror.prototype.isString=function(){
return this instanceof StringMirror;
};






Mirror.prototype.isObject=function(){
return this instanceof ObjectMirror;
};






Mirror.prototype.isFunction=function(){
return this instanceof FunctionMirror;
};






Mirror.prototype.isUnresolvedFunction=function(){
return this instanceof UnresolvedFunctionMirror;
};






Mirror.prototype.isArray=function(){
return this instanceof ArrayMirror;
};






Mirror.prototype.isDate=function(){
return this instanceof DateMirror;
};






Mirror.prototype.isRegExp=function(){
return this instanceof RegExpMirror;
};






Mirror.prototype.isError=function(){
return this instanceof ErrorMirror;
};






Mirror.prototype.isProperty=function(){
return this instanceof PropertyMirror;
};






Mirror.prototype.isInternalProperty=function(){
return this instanceof InternalPropertyMirror;
};






Mirror.prototype.isFrame=function(){
return this instanceof FrameMirror;
};






Mirror.prototype.isScript=function(){
return this instanceof ScriptMirror;
};






Mirror.prototype.isContext=function(){
return this instanceof ContextMirror;
};






Mirror.prototype.isScope=function(){
return this instanceof ScopeMirror;
};





Mirror.prototype.allocateHandle_=function(){
this.handle_=next_handle_++;
};






Mirror.prototype.allocateTransientHandle_=function(){
this.handle_=next_transient_handle_--;
};


Mirror.prototype.toText=function(){

return"#<"+this.constructor.name+">";
};











function ValueMirror(a,b,c){
%_CallFunction(this,a,Mirror);
this.value_=b;
if(!c){
this.allocateHandle_();
}else{
this.allocateTransientHandle_();
}
}
inherits(ValueMirror,Mirror);


Mirror.prototype.handle=function(){
return this.handle_;
};






ValueMirror.prototype.isPrimitive=function(){
var a=this.type();
return a==='undefined'||
a==='null'||
a==='boolean'||
a==='number'||
a==='string';
};






ValueMirror.prototype.value=function(){
return this.value_;
};







function UndefinedMirror(){
%_CallFunction(this,UNDEFINED_TYPE,void 0,ValueMirror);
}
inherits(UndefinedMirror,ValueMirror);


UndefinedMirror.prototype.toText=function(){
return'undefined';
};







function NullMirror(){
%_CallFunction(this,NULL_TYPE,null,ValueMirror);
}
inherits(NullMirror,ValueMirror);


NullMirror.prototype.toText=function(){
return'null';
};








function BooleanMirror(a){
%_CallFunction(this,BOOLEAN_TYPE,a,ValueMirror);
}
inherits(BooleanMirror,ValueMirror);


BooleanMirror.prototype.toText=function(){
return this.value_?'true':'false';
};








function NumberMirror(a){
%_CallFunction(this,NUMBER_TYPE,a,ValueMirror);
}
inherits(NumberMirror,ValueMirror);


NumberMirror.prototype.toText=function(){
return %NumberToString(this.value_);
};








function StringMirror(a){
%_CallFunction(this,STRING_TYPE,a,ValueMirror);
}
inherits(StringMirror,ValueMirror);


StringMirror.prototype.length=function(){
return this.value_.length;
};

StringMirror.prototype.getTruncatedValue=function(a){
if(a!=-1&&this.length()>a){
return this.value_.substring(0,a)+
'... (length: '+this.length()+')';
}
return this.value_;
};

StringMirror.prototype.toText=function(){
return this.getTruncatedValue(kMaxProtocolStringLength);
};










function ObjectMirror(a,b,c){
%_CallFunction(this,b||OBJECT_TYPE,a,c,ValueMirror);
}
inherits(ObjectMirror,ValueMirror);


ObjectMirror.prototype.className=function(){
return %_ClassOf(this.value_);
};


ObjectMirror.prototype.constructorFunction=function(){
return MakeMirror(%DebugGetProperty(this.value_,'constructor'));
};


ObjectMirror.prototype.prototypeObject=function(){
return MakeMirror(%DebugGetProperty(this.value_,'prototype'));
};


ObjectMirror.prototype.protoObject=function(){
return MakeMirror(%DebugGetPrototype(this.value_));
};


ObjectMirror.prototype.hasNamedInterceptor=function(){

var a=%GetInterceptorInfo(this.value_);
return(a&2)!=0;
};


ObjectMirror.prototype.hasIndexedInterceptor=function(){

var a=%GetInterceptorInfo(this.value_);
return(a&1)!=0;
};










ObjectMirror.prototype.propertyNames=function(a,b){

a=a||PropertyKind.Named|PropertyKind.Indexed;

var c;
var d;
var g=0;


if(a&PropertyKind.Named){

c=%GetLocalPropertyNames(this.value_);
g+=c.length;


if(this.hasNamedInterceptor()&&(a&PropertyKind.Named)){
var h=
%GetNamedInterceptorPropertyNames(this.value_);
if(h){
c=c.concat(h);
g+=h.length;
}
}
}


if(a&PropertyKind.Indexed){

d=%GetLocalElementNames(this.value_);
g+=d.length;


if(this.hasIndexedInterceptor()&&(a&PropertyKind.Indexed)){
var i=
%GetIndexedInterceptorElementNames(this.value_);
if(i){
d=d.concat(i);
g+=i.length;
}
}
}
b=Math.min(b||g,g);

var j=new Array(b);
var k=0;


if(a&PropertyKind.Named){
for(var l=0;k<b&&l<c.length;l++){
j[k++]=c[l];
}
}


if(a&PropertyKind.Indexed){
for(var l=0;k<b&&l<d.length;l++){
j[k++]=d[l];
}
}

return j;
};










ObjectMirror.prototype.properties=function(a,b){
var c=this.propertyNames(a,b);
var d=new Array(c.length);
for(var g=0;g<c.length;g++){
d[g]=this.property(c[g]);
}

return d;
};







ObjectMirror.prototype.internalProperties=function(){
return ObjectMirror.GetInternalProperties(this.value_);
}


ObjectMirror.prototype.property=function(a){
var b=%DebugGetPropertyDetails(this.value_,%ToString(a));
if(b){
return new PropertyMirror(this,a,b);
}


return GetUndefinedMirror();
};









ObjectMirror.prototype.lookupProperty=function(a){
var b=this.properties();


for(var c=0;c<b.length;c++){


var d=b[c];
if(d.propertyType()!=PropertyType.Callbacks){
if(%_ObjectEquals(d.value_,a.value_)){
return d;
}
}
}


return GetUndefinedMirror();
};








ObjectMirror.prototype.referencedBy=function(a){

var b=%DebugReferencedBy(this.value_,
Mirror.prototype,a||0);


for(var c=0;c<b.length;c++){
b[c]=MakeMirror(b[c]);
}

return b;
};


ObjectMirror.prototype.toText=function(){
var a;
var b=this.constructorFunction();
if(!b.isFunction()){
a=this.className();
}else{
a=b.name();
if(!a){
a=this.className();
}
}
return'#<'+a+'>';
};









ObjectMirror.GetInternalProperties=function(a){
if((%_ClassOf(a)==='String')||(%_ClassOf(a)==='Number')||
(%_ClassOf(a)==='Boolean')){
var b=%_ValueOf(a);
return[new InternalPropertyMirror("[[PrimitiveValue]]",b)];
}else if((%_IsFunction(a))){
var c=%BoundFunctionGetBindings(a);
var d=[];
if(c&&(%_IsArray(c))){
d.push(new InternalPropertyMirror("[[TargetFunction]]",
c[0]));
d.push(new InternalPropertyMirror("[[BoundThis]]",c[1]));
var g=[];
for(var h=2;h<c.length;h++){
g.push(c[h]);
}
d.push(new InternalPropertyMirror("[[BoundArgs]]",g));
}
return d;
}
return[];
}








function FunctionMirror(a){
%_CallFunction(this,a,FUNCTION_TYPE,ObjectMirror);
this.resolved_=true;
}
inherits(FunctionMirror,ObjectMirror);







FunctionMirror.prototype.resolved=function(){
return this.resolved_;
};






FunctionMirror.prototype.name=function(){
return %FunctionGetName(this.value_);
};






FunctionMirror.prototype.inferredName=function(){
return %FunctionGetInferredName(this.value_);
};







FunctionMirror.prototype.source=function(){


if(this.resolved()){
return builtins.FunctionSourceString(this.value_);
}
};







FunctionMirror.prototype.script=function(){


if(this.resolved()){
var a=%FunctionGetScript(this.value_);
if(a){
return MakeMirror(a);
}
}
};







FunctionMirror.prototype.sourcePosition_=function(){


if(this.resolved()){
return %FunctionGetScriptSourcePosition(this.value_);
}
};







FunctionMirror.prototype.sourceLocation=function(){
if(this.resolved()&&this.script()){
return this.script().locationFromPosition(this.sourcePosition_(),
true);
}
};








FunctionMirror.prototype.constructedBy=function(a){
if(this.resolved()){

var b=%DebugConstructedBy(this.value_,a||0);


for(var c=0;c<b.length;c++){
b[c]=MakeMirror(b[c]);
}

return b;
}else{
return[];
}
};


FunctionMirror.prototype.scopeCount=function(){
if(this.resolved()){
return %GetFunctionScopeCount(this.value());
}else{
return 0;
}
};


FunctionMirror.prototype.scope=function(a){
if(this.resolved()){
return new ScopeMirror(void 0,this,a);
}
};


FunctionMirror.prototype.toText=function(){
return this.source();
};









function UnresolvedFunctionMirror(a){


%_CallFunction(this,FUNCTION_TYPE,a,ValueMirror);
this.propertyCount_=0;
this.elementCount_=0;
this.resolved_=false;
}
inherits(UnresolvedFunctionMirror,FunctionMirror);


UnresolvedFunctionMirror.prototype.className=function(){
return'Function';
};


UnresolvedFunctionMirror.prototype.constructorFunction=function(){
return GetUndefinedMirror();
};


UnresolvedFunctionMirror.prototype.prototypeObject=function(){
return GetUndefinedMirror();
};


UnresolvedFunctionMirror.prototype.protoObject=function(){
return GetUndefinedMirror();
};


UnresolvedFunctionMirror.prototype.name=function(){
return this.value_;
};


UnresolvedFunctionMirror.prototype.inferredName=function(){
return undefined;
};


UnresolvedFunctionMirror.prototype.propertyNames=function(a,b){
return[];
};








function ArrayMirror(a){
%_CallFunction(this,a,ObjectMirror);
}
inherits(ArrayMirror,ObjectMirror);


ArrayMirror.prototype.length=function(){
return this.value_.length;
};


ArrayMirror.prototype.indexedPropertiesFromRange=function(opt_from_index,
opt_to_index){
var a=opt_from_index||0;
var b=opt_to_index||this.length()-1;
if(a>b)return new Array();
var c=new Array(b-a+1);
for(var d=a;d<=b;d++){
var g=%DebugGetPropertyDetails(this.value_,%ToString(d));
var h;
if(g){
h=new PropertyMirror(this,d,g);
}else{
h=GetUndefinedMirror();
}
c[d-a]=h;
}
return c;
};








function DateMirror(a){
%_CallFunction(this,a,ObjectMirror);
}
inherits(DateMirror,ObjectMirror);


DateMirror.prototype.toText=function(){
var a=JSON.stringify(this.value_);
return a.substring(1,a.length-1);
};








function RegExpMirror(a){
%_CallFunction(this,a,REGEXP_TYPE,ObjectMirror);
}
inherits(RegExpMirror,ObjectMirror);






RegExpMirror.prototype.source=function(){
return this.value_.source;
};






RegExpMirror.prototype.global=function(){
return this.value_.global;
};






RegExpMirror.prototype.ignoreCase=function(){
return this.value_.ignoreCase;
};






RegExpMirror.prototype.multiline=function(){
return this.value_.multiline;
};


RegExpMirror.prototype.toText=function(){

return"/"+this.source()+"/";
};








function ErrorMirror(a){
%_CallFunction(this,a,ERROR_TYPE,ObjectMirror);
}
inherits(ErrorMirror,ObjectMirror);






ErrorMirror.prototype.message=function(){
return this.value_.message;
};


ErrorMirror.prototype.toText=function(){

var a;
try{
str=%_CallFunction(this.value_,builtins.ErrorToString);
}catch(e){
str='#<Error>';
}
return str;
};










function PropertyMirror(a,b,c){
%_CallFunction(this,PROPERTY_TYPE,Mirror);
this.mirror_=a;
this.name_=b;
this.value_=c[0];
this.details_=c[1];
if(c.length>2){
this.exception_=c[2];
this.getter_=c[3];
this.setter_=c[4];
}
}
inherits(PropertyMirror,Mirror);


PropertyMirror.prototype.isReadOnly=function(){
return(this.attributes()&PropertyAttribute.ReadOnly)!=0;
};


PropertyMirror.prototype.isEnum=function(){
return(this.attributes()&PropertyAttribute.DontEnum)==0;
};


PropertyMirror.prototype.canDelete=function(){
return(this.attributes()&PropertyAttribute.DontDelete)==0;
};


PropertyMirror.prototype.name=function(){
return this.name_;
};


PropertyMirror.prototype.isIndexed=function(){
for(var a=0;a<this.name_.length;a++){
if(this.name_[a]<'0'||'9'<this.name_[a]){
return false;
}
}
return true;
};


PropertyMirror.prototype.value=function(){
return MakeMirror(this.value_,false);
};






PropertyMirror.prototype.isException=function(){
return this.exception_?true:false;
};


PropertyMirror.prototype.attributes=function(){
return %DebugPropertyAttributesFromDetails(this.details_);
};


PropertyMirror.prototype.propertyType=function(){
return %DebugPropertyTypeFromDetails(this.details_);
};


PropertyMirror.prototype.insertionIndex=function(){
return %DebugPropertyIndexFromDetails(this.details_);
};






PropertyMirror.prototype.hasGetter=function(){
return this.getter_?true:false;
};






PropertyMirror.prototype.hasSetter=function(){
return this.setter_?true:false;
};







PropertyMirror.prototype.getter=function(){
if(this.hasGetter()){
return MakeMirror(this.getter_);
}else{
return GetUndefinedMirror();
}
};







PropertyMirror.prototype.setter=function(){
if(this.hasSetter()){
return MakeMirror(this.setter_);
}else{
return GetUndefinedMirror();
}
};








PropertyMirror.prototype.isNative=function(){
return(this.propertyType()==PropertyType.Interceptor)||
((this.propertyType()==PropertyType.Callbacks)&&
!this.hasGetter()&&!this.hasSetter());
};











function InternalPropertyMirror(a,b){
%_CallFunction(this,INTERNAL_PROPERTY_TYPE,Mirror);
this.name_=a;
this.value_=b;
}
inherits(InternalPropertyMirror,Mirror);


InternalPropertyMirror.prototype.name=function(){
return this.name_;
};


InternalPropertyMirror.prototype.value=function(){
return MakeMirror(this.value_,false);
};


var kFrameDetailsFrameIdIndex=0;
var kFrameDetailsReceiverIndex=1;
var kFrameDetailsFunctionIndex=2;
var kFrameDetailsArgumentCountIndex=3;
var kFrameDetailsLocalCountIndex=4;
var kFrameDetailsSourcePositionIndex=5;
var kFrameDetailsConstructCallIndex=6;
var kFrameDetailsAtReturnIndex=7;
var kFrameDetailsFlagsIndex=8;
var kFrameDetailsFirstDynamicIndex=9;

var kFrameDetailsNameIndex=0;
var kFrameDetailsValueIndex=1;
var kFrameDetailsNameValueSize=2;

var kFrameDetailsFlagDebuggerFrameMask=1<<0;
var kFrameDetailsFlagOptimizedFrameMask=1<<1;
var kFrameDetailsFlagInlinedFrameIndexMask=7<<2;





















function FrameDetails(a,b){
this.break_id_=a;
this.details_=%GetFrameDetails(a,b);
}


FrameDetails.prototype.frameId=function(){
%CheckExecutionState(this.break_id_);
return this.details_[kFrameDetailsFrameIdIndex];
};


FrameDetails.prototype.receiver=function(){
%CheckExecutionState(this.break_id_);
return this.details_[kFrameDetailsReceiverIndex];
};


FrameDetails.prototype.func=function(){
%CheckExecutionState(this.break_id_);
return this.details_[kFrameDetailsFunctionIndex];
};


FrameDetails.prototype.isConstructCall=function(){
%CheckExecutionState(this.break_id_);
return this.details_[kFrameDetailsConstructCallIndex];
};


FrameDetails.prototype.isAtReturn=function(){
%CheckExecutionState(this.break_id_);
return this.details_[kFrameDetailsAtReturnIndex];
};


FrameDetails.prototype.isDebuggerFrame=function(){
%CheckExecutionState(this.break_id_);
var a=kFrameDetailsFlagDebuggerFrameMask;
return(this.details_[kFrameDetailsFlagsIndex]&a)==a;
};


FrameDetails.prototype.isOptimizedFrame=function(){
%CheckExecutionState(this.break_id_);
var a=kFrameDetailsFlagOptimizedFrameMask;
return(this.details_[kFrameDetailsFlagsIndex]&a)==a;
};


FrameDetails.prototype.isInlinedFrame=function(){
return this.inlinedFrameIndex()>0;
};


FrameDetails.prototype.inlinedFrameIndex=function(){
%CheckExecutionState(this.break_id_);
var a=kFrameDetailsFlagInlinedFrameIndexMask;
return(this.details_[kFrameDetailsFlagsIndex]&a)>>2;
};


FrameDetails.prototype.argumentCount=function(){
%CheckExecutionState(this.break_id_);
return this.details_[kFrameDetailsArgumentCountIndex];
};


FrameDetails.prototype.argumentName=function(a){
%CheckExecutionState(this.break_id_);
if(a>=0&&a<this.argumentCount()){
return this.details_[kFrameDetailsFirstDynamicIndex+
a*kFrameDetailsNameValueSize+
kFrameDetailsNameIndex];
}
};


FrameDetails.prototype.argumentValue=function(a){
%CheckExecutionState(this.break_id_);
if(a>=0&&a<this.argumentCount()){
return this.details_[kFrameDetailsFirstDynamicIndex+
a*kFrameDetailsNameValueSize+
kFrameDetailsValueIndex];
}
};


FrameDetails.prototype.localCount=function(){
%CheckExecutionState(this.break_id_);
return this.details_[kFrameDetailsLocalCountIndex];
};


FrameDetails.prototype.sourcePosition=function(){
%CheckExecutionState(this.break_id_);
return this.details_[kFrameDetailsSourcePositionIndex];
};


FrameDetails.prototype.localName=function(a){
%CheckExecutionState(this.break_id_);
if(a>=0&&a<this.localCount()){
var b=kFrameDetailsFirstDynamicIndex+
this.argumentCount()*kFrameDetailsNameValueSize;
return this.details_[b+
a*kFrameDetailsNameValueSize+
kFrameDetailsNameIndex];
}
};


FrameDetails.prototype.localValue=function(a){
%CheckExecutionState(this.break_id_);
if(a>=0&&a<this.localCount()){
var b=kFrameDetailsFirstDynamicIndex+
this.argumentCount()*kFrameDetailsNameValueSize;
return this.details_[b+
a*kFrameDetailsNameValueSize+
kFrameDetailsValueIndex];
}
};


FrameDetails.prototype.returnValue=function(){
%CheckExecutionState(this.break_id_);
var a=
kFrameDetailsFirstDynamicIndex+
(this.argumentCount()+this.localCount())*kFrameDetailsNameValueSize;
if(this.details_[kFrameDetailsAtReturnIndex]){
return this.details_[a];
}
};


FrameDetails.prototype.scopeCount=function(){
return %GetScopeCount(this.break_id_,this.frameId());
};










function FrameMirror(a,b){
%_CallFunction(this,FRAME_TYPE,Mirror);
this.break_id_=a;
this.index_=b;
this.details_=new FrameDetails(a,b);
}
inherits(FrameMirror,Mirror);


FrameMirror.prototype.index=function(){
return this.index_;
};


FrameMirror.prototype.func=function(){

var a=this.details_.func();




if((%_IsFunction(a))){
return MakeMirror(a);
}else{
return new UnresolvedFunctionMirror(a);
}
};


FrameMirror.prototype.receiver=function(){
return MakeMirror(this.details_.receiver());
};


FrameMirror.prototype.isConstructCall=function(){
return this.details_.isConstructCall();
};


FrameMirror.prototype.isAtReturn=function(){
return this.details_.isAtReturn();
};


FrameMirror.prototype.isDebuggerFrame=function(){
return this.details_.isDebuggerFrame();
};


FrameMirror.prototype.isOptimizedFrame=function(){
return this.details_.isOptimizedFrame();
};


FrameMirror.prototype.isInlinedFrame=function(){
return this.details_.isInlinedFrame();
};


FrameMirror.prototype.inlinedFrameIndex=function(){
return this.details_.inlinedFrameIndex();
};


FrameMirror.prototype.argumentCount=function(){
return this.details_.argumentCount();
};


FrameMirror.prototype.argumentName=function(a){
return this.details_.argumentName(a);
};


FrameMirror.prototype.argumentValue=function(a){
return MakeMirror(this.details_.argumentValue(a));
};


FrameMirror.prototype.localCount=function(){
return this.details_.localCount();
};


FrameMirror.prototype.localName=function(a){
return this.details_.localName(a);
};


FrameMirror.prototype.localValue=function(a){
return MakeMirror(this.details_.localValue(a));
};


FrameMirror.prototype.returnValue=function(){
return MakeMirror(this.details_.returnValue());
};


FrameMirror.prototype.sourcePosition=function(){
return this.details_.sourcePosition();
};


FrameMirror.prototype.sourceLocation=function(){
if(this.func().resolved()&&this.func().script()){
return this.func().script().locationFromPosition(this.sourcePosition(),
true);
}
};


FrameMirror.prototype.sourceLine=function(){
if(this.func().resolved()){
var a=this.sourceLocation();
if(a){
return a.line;
}
}
};


FrameMirror.prototype.sourceColumn=function(){
if(this.func().resolved()){
var a=this.sourceLocation();
if(a){
return a.column;
}
}
};


FrameMirror.prototype.sourceLineText=function(){
if(this.func().resolved()){
var a=this.sourceLocation();
if(a){
return a.sourceText();
}
}
};


FrameMirror.prototype.scopeCount=function(){
return this.details_.scopeCount();
};


FrameMirror.prototype.scope=function(a){
return new ScopeMirror(this,void 0,a);
};


FrameMirror.prototype.evaluate=function(source,disable_break,
opt_context_object){
var a=%DebugEvaluate(this.break_id_,
this.details_.frameId(),
this.details_.inlinedFrameIndex(),
source,
Boolean(disable_break),
opt_context_object);
return MakeMirror(a);
};


FrameMirror.prototype.invocationText=function(){

var a='';
var b=this.func();
var c=this.receiver();
if(this.isConstructCall()){

a+='new ';
a+=b.name()?b.name():'[anonymous]';
}else if(this.isDebuggerFrame()){
a+='[debugger]';
}else{

var d=
!c.className||(c.className()!='global');
if(d){
a+=c.toText();
}


var g=GetUndefinedMirror();
if(c.isObject()){
for(var h=c;
!h.isNull()&&g.isUndefined();
h=h.protoObject()){
g=h.lookupProperty(b);
}
}
if(!g.isUndefined()){


if(!g.isIndexed()){
if(d){
a+='.';
}
a+=g.name();
}else{
a+='[';
a+=g.name();
a+=']';
}


if(b.name()&&b.name()!=g.name()){
a+='(aka '+b.name()+')';
}
}else{


if(d){
a+='.';
}
a+=b.name()?b.name():'[anonymous]';
}
}


if(!this.isDebuggerFrame()){
a+='(';
for(var i=0;i<this.argumentCount();i++){
if(i!=0)a+=', ';
if(this.argumentName(i)){
a+=this.argumentName(i);
a+='=';
}
a+=this.argumentValue(i).toText();
}
a+=')';
}

if(this.isAtReturn()){
a+=' returning ';
a+=this.returnValue().toText();
}

return a;
};


FrameMirror.prototype.sourceAndPositionText=function(){

var a='';
var b=this.func();
if(b.resolved()){
if(b.script()){
if(b.script().name()){
a+=b.script().name();
}else{
a+='[unnamed]';
}
if(!this.isDebuggerFrame()){
var c=this.sourceLocation();
a+=' line ';
a+=!(typeof(c)==='undefined')?(c.line+1):'?';
a+=' column ';
a+=!(typeof(c)==='undefined')?(c.column+1):'?';
if(!(typeof(this.sourcePosition())==='undefined')){
a+=' (position '+(this.sourcePosition()+1)+')';
}
}
}else{
a+='[no source]';
}
}else{
a+='[unresolved]';
}

return a;
};


FrameMirror.prototype.localsText=function(){

var a='';
var b=this.localCount();
if(b>0){
for(var c=0;c<b;++c){
a+='      var ';
a+=this.localName(c);
a+=' = ';
a+=this.localValue(c).toText();
if(c<b-1)a+='\n';
}
}

return a;
};


FrameMirror.prototype.restart=function(){
var a=%LiveEditRestartFrame(this.break_id_,this.index_);
if((typeof(a)==='undefined')){
a="Failed to find requested frame";
}
return a;
};


FrameMirror.prototype.toText=function(a){
var b='';
b+='#'+(this.index()<=9?'0':'')+this.index();
b+=' ';
b+=this.invocationText();
b+=' ';
b+=this.sourceAndPositionText();
if(a){
b+='\n';
b+=this.localsText();
}
return b;
};


var kScopeDetailsTypeIndex=0;
var kScopeDetailsObjectIndex=1;

function ScopeDetails(a,b,c){
if(a){
this.break_id_=a.break_id_;
this.details_=%GetScopeDetails(a.break_id_,
a.details_.frameId(),
a.details_.inlinedFrameIndex(),
c);
}else{
this.details_=%GetFunctionScopeDetails(b.value(),c);
this.break_id_=undefined;
}
}


ScopeDetails.prototype.type=function(){
if(!(typeof(this.break_id_)==='undefined')){
%CheckExecutionState(this.break_id_);
}
return this.details_[kScopeDetailsTypeIndex];
};


ScopeDetails.prototype.object=function(){
if(!(typeof(this.break_id_)==='undefined')){
%CheckExecutionState(this.break_id_);
}
return this.details_[kScopeDetailsObjectIndex];
};











function ScopeMirror(a,b,c){
%_CallFunction(this,SCOPE_TYPE,Mirror);
if(a){
this.frame_index_=a.index_;
}else{
this.frame_index_=undefined;
}
this.scope_index_=c;
this.details_=new ScopeDetails(a,b,c);
}
inherits(ScopeMirror,Mirror);


ScopeMirror.prototype.frameIndex=function(){
return this.frame_index_;
};


ScopeMirror.prototype.scopeIndex=function(){
return this.scope_index_;
};


ScopeMirror.prototype.scopeType=function(){
return this.details_.type();
};


ScopeMirror.prototype.scopeObject=function(){



var a=this.scopeType()==ScopeType.Local||
this.scopeType()==ScopeType.Closure;
return MakeMirror(this.details_.object(),a);
};








function ScriptMirror(a){
%_CallFunction(this,SCRIPT_TYPE,Mirror);
this.script_=a;
this.context_=new ContextMirror(a.context_data);
this.allocateHandle_();
}
inherits(ScriptMirror,Mirror);


ScriptMirror.prototype.value=function(){
return this.script_;
};


ScriptMirror.prototype.name=function(){
return this.script_.name||this.script_.nameOrSourceURL();
};


ScriptMirror.prototype.id=function(){
return this.script_.id;
};


ScriptMirror.prototype.source=function(){
return this.script_.source;
};


ScriptMirror.prototype.setSource=function(a){
%DebugSetScriptSource(this.script_,a);
};


ScriptMirror.prototype.lineOffset=function(){
return this.script_.line_offset;
};


ScriptMirror.prototype.columnOffset=function(){
return this.script_.column_offset;
};


ScriptMirror.prototype.data=function(){
return this.script_.data;
};


ScriptMirror.prototype.scriptType=function(){
return this.script_.type;
};


ScriptMirror.prototype.compilationType=function(){
return this.script_.compilation_type;
};


ScriptMirror.prototype.lineCount=function(){
return this.script_.lineCount();
};


ScriptMirror.prototype.locationFromPosition=function(
position,include_resource_offset){
return this.script_.locationFromPosition(position,include_resource_offset);
};


ScriptMirror.prototype.sourceSlice=function(a,b){
return this.script_.sourceSlice(a,b);
};


ScriptMirror.prototype.context=function(){
return this.context_;
};


ScriptMirror.prototype.evalFromScript=function(){
return MakeMirror(this.script_.eval_from_script);
};


ScriptMirror.prototype.evalFromFunctionName=function(){
return MakeMirror(this.script_.eval_from_function_name);
};


ScriptMirror.prototype.evalFromLocation=function(){
var a=this.evalFromScript();
if(!a.isUndefined()){
var b=this.script_.eval_from_script_position;
return a.locationFromPosition(b,true);
}
};


ScriptMirror.prototype.toText=function(){
var a='';
a+=this.name();
a+=' (lines: ';
if(this.lineOffset()>0){
a+=this.lineOffset();
a+='-';
a+=this.lineOffset()+this.lineCount()-1;
}else{
a+=this.lineCount();
}
a+=')';
return a;
};








function ContextMirror(a){
%_CallFunction(this,CONTEXT_TYPE,Mirror);
this.data_=a;
this.allocateHandle_();
}
inherits(ContextMirror,Mirror);


ContextMirror.prototype.data=function(){
return this.data_;
};











function MakeMirrorSerializer(a,b){
return new JSONProtocolSerializer(a,b);
}








function JSONProtocolSerializer(a,b){
this.details_=a;
this.options_=b;
this.mirrors_=[];
}









JSONProtocolSerializer.prototype.serializeReference=function(a){
return this.serialize_(a,true,true);
};









JSONProtocolSerializer.prototype.serializeValue=function(a){
var b=this.serialize_(a,false,true);
return b;
};









JSONProtocolSerializer.prototype.serializeReferencedObjects=function(){

var a=[];


var b=this.mirrors_.length;

for(var c=0;c<b;c++){
a.push(this.serialize_(this.mirrors_[c],false,false));
}

return a;
};


JSONProtocolSerializer.prototype.includeSource_=function(){
return this.options_&&this.options_.includeSource;
};


JSONProtocolSerializer.prototype.inlineRefs_=function(){
return this.options_&&this.options_.inlineRefs;
};


JSONProtocolSerializer.prototype.maxStringLength_=function(){
if((typeof(this.options_)==='undefined')||
(typeof(this.options_.maxStringLength)==='undefined')){
return kMaxProtocolStringLength;
}
return this.options_.maxStringLength;
};


JSONProtocolSerializer.prototype.add_=function(a){

for(var b=0;b<this.mirrors_.length;b++){
if(this.mirrors_[b]===a){
return;
}
}


this.mirrors_.push(a);
};








JSONProtocolSerializer.prototype.serializeReferenceWithDisplayData_=
function(a){
var b={};
b.ref=a.handle();
b.type=a.type();
switch(a.type()){
case UNDEFINED_TYPE:
case NULL_TYPE:
case BOOLEAN_TYPE:
case NUMBER_TYPE:
b.value=a.value();
break;
case STRING_TYPE:
b.value=a.getTruncatedValue(this.maxStringLength_());
break;
case FUNCTION_TYPE:
b.name=a.name();
b.inferredName=a.inferredName();
if(a.script()){
b.scriptId=a.script().id();
}
break;
case ERROR_TYPE:
case REGEXP_TYPE:
b.value=a.toText();
break;
case OBJECT_TYPE:
b.className=a.className();
break;
}
return b;
};


JSONProtocolSerializer.prototype.serialize_=function(mirror,reference,
details){


if(reference&&
(mirror.isValue()||mirror.isScript()||mirror.isContext())){
if(this.inlineRefs_()&&mirror.isValue()){
return this.serializeReferenceWithDisplayData_(mirror);
}else{
this.add_(mirror);
return{'ref':mirror.handle()};
}
}


var a={};


if(mirror.isValue()||mirror.isScript()||mirror.isContext()){
a.handle=mirror.handle();
}


a.type=mirror.type();

switch(mirror.type()){
case UNDEFINED_TYPE:
case NULL_TYPE:

break;

case BOOLEAN_TYPE:

a.value=mirror.value();
break;

case NUMBER_TYPE:

a.value=NumberToJSON_(mirror.value());
break;

case STRING_TYPE:

if(this.maxStringLength_()!=-1&&
mirror.length()>this.maxStringLength_()){
var b=mirror.getTruncatedValue(this.maxStringLength_());
a.value=b;
a.fromIndex=0;
a.toIndex=this.maxStringLength_();
}else{
a.value=mirror.value();
}
a.length=mirror.length();
break;

case OBJECT_TYPE:
case FUNCTION_TYPE:
case ERROR_TYPE:
case REGEXP_TYPE:

this.serializeObject_(mirror,a,details);
break;

case PROPERTY_TYPE:
case INTERNAL_PROPERTY_TYPE:
throw new Error('PropertyMirror cannot be serialized independently');
break;

case FRAME_TYPE:

this.serializeFrame_(mirror,a);
break;

case SCOPE_TYPE:

this.serializeScope_(mirror,a);
break;

case SCRIPT_TYPE:

if(mirror.name()){
a.name=mirror.name();
}
a.id=mirror.id();
a.lineOffset=mirror.lineOffset();
a.columnOffset=mirror.columnOffset();
a.lineCount=mirror.lineCount();
if(mirror.data()){
a.data=mirror.data();
}
if(this.includeSource_()){
a.source=mirror.source();
}else{
var c=mirror.source().substring(0,80);
a.sourceStart=c;
}
a.sourceLength=mirror.source().length;
a.scriptType=mirror.scriptType();
a.compilationType=mirror.compilationType();


if(mirror.compilationType()==1&&
mirror.evalFromScript()){
a.evalFromScript=
this.serializeReference(mirror.evalFromScript());
var d=mirror.evalFromLocation();
if(d){
a.evalFromLocation={line:d.line,
column:d.column};
}
if(mirror.evalFromFunctionName()){
a.evalFromFunctionName=mirror.evalFromFunctionName();
}
}
if(mirror.context()){
a.context=this.serializeReference(mirror.context());
}
break;

case CONTEXT_TYPE:
a.data=mirror.data();
break;
}


a.text=mirror.toText();


return a;
};














JSONProtocolSerializer.prototype.serializeObject_=function(mirror,content,
details){

content.className=mirror.className();
content.constructorFunction=
this.serializeReference(mirror.constructorFunction());
content.protoObject=this.serializeReference(mirror.protoObject());
content.prototypeObject=this.serializeReference(mirror.prototypeObject());


if(mirror.hasNamedInterceptor()){
content.namedInterceptor=true;
}
if(mirror.hasIndexedInterceptor()){
content.indexedInterceptor=true;
}


if(mirror.isFunction()){

content.name=mirror.name();
if(!(typeof(mirror.inferredName())==='undefined')){
content.inferredName=mirror.inferredName();
}
content.resolved=mirror.resolved();
if(mirror.resolved()){
content.source=mirror.source();
}
if(mirror.script()){
content.script=this.serializeReference(mirror.script());
content.scriptId=mirror.script().id();

serializeLocationFields(mirror.sourceLocation(),content);
}

content.scopes=[];
for(var a=0;a<mirror.scopeCount();a++){
var b=mirror.scope(a);
content.scopes.push({
type:b.scopeType(),
index:a
});
}
}


if(mirror.isDate()){

content.value=mirror.value();
}


var c=mirror.propertyNames(PropertyKind.Named);
var d=mirror.propertyNames(PropertyKind.Indexed);
var g=new Array(c.length+d.length);
for(var a=0;a<c.length;a++){
var h=mirror.property(c[a]);
g[a]=this.serializeProperty_(h);
if(details){
this.add_(h.value());
}
}
for(var a=0;a<d.length;a++){
var h=mirror.property(d[a]);
g[c.length+a]=this.serializeProperty_(h);
if(details){
this.add_(h.value());
}
}
content.properties=g;

var i=mirror.internalProperties();
if(i.length>0){
var j=[];
for(var a=0;a<i.length;a++){
j.push(this.serializeInternalProperty_(i[a]));
}
content.internalProperties=j;
}
};











function serializeLocationFields(a,b){
if(!a){
return;
}
b.position=a.position;
var c=a.line;
if(!(typeof(c)==='undefined')){
b.line=c;
}
var d=a.column;
if(!(typeof(d)==='undefined')){
b.column=d;
}
}





















JSONProtocolSerializer.prototype.serializeProperty_=function(a){
var b={};

b.name=a.name();
var c=a.value();
if(this.inlineRefs_()&&c.isValue()){
b.value=this.serializeReferenceWithDisplayData_(c);
}else{
if(a.attributes()!=PropertyAttribute.None){
b.attributes=a.attributes();
}
if(a.propertyType()!=PropertyType.Normal){
b.propertyType=a.propertyType();
}
b.ref=c.handle();
}
return b;
};














JSONProtocolSerializer.prototype.serializeInternalProperty_=
function(a){
var b={};

b.name=a.name();
var c=a.value();
if(this.inlineRefs_()&&c.isValue()){
b.value=this.serializeReferenceWithDisplayData_(c);
}else{
b.ref=c.handle();
}
return b;
};


JSONProtocolSerializer.prototype.serializeFrame_=function(a,b){
b.index=a.index();
b.receiver=this.serializeReference(a.receiver());
var c=a.func();
b.func=this.serializeReference(c);
if(c.script()){
b.script=this.serializeReference(c.script());
}
b.constructCall=a.isConstructCall();
b.atReturn=a.isAtReturn();
if(a.isAtReturn()){
b.returnValue=this.serializeReference(a.returnValue());
}
b.debuggerFrame=a.isDebuggerFrame();
var d=new Array(a.argumentCount());
for(var g=0;g<a.argumentCount();g++){
var h={};
var i=a.argumentName(g);
if(i){
h.name=i;
}
h.value=this.serializeReference(a.argumentValue(g));
d[g]=h;
}
b.arguments=d;
var d=new Array(a.localCount());
for(var g=0;g<a.localCount();g++){
var j={};
j.name=a.localName(g);
j.value=this.serializeReference(a.localValue(g));
d[g]=j;
}
b.locals=d;
serializeLocationFields(a.sourceLocation(),b);
var k=a.sourceLineText();
if(!(typeof(k)==='undefined')){
b.sourceLineText=k;
}

b.scopes=[];
for(var g=0;g<a.scopeCount();g++){
var l=a.scope(g);
b.scopes.push({
type:l.scopeType(),
index:g
});
}
};


JSONProtocolSerializer.prototype.serializeScope_=function(a,b){
b.index=a.scopeIndex();
b.frameIndex=a.frameIndex();
b.type=a.scopeType();
b.object=this.inlineRefs_()?
this.serializeValue(a.scopeObject()):
this.serializeReference(a.scopeObject());
};











function NumberToJSON_(a){
if(isNaN(a)){
return'NaN';
}
if(!(%_IsSmi(%IS_VAR(a))||((a==a)&&(a!=1/0)&&(a!=-1/0)))){
if(a>0){
return'Infinity';
}else{
return'-Infinity';
}
}
return a;
}













































Debug.LiveEdit=new function(){


var a;

var b="stack_update_needs_step_in";




function ApplyPatchMultiChunk(script,diff_array,new_source,preview_only,
change_log){

var c=script.source;


var d=GatherCompileInfo(c,script);


var g=BuildCodeInfoTree(d);

var h=new PosTranslator(diff_array);


MarkChangedFunctions(g,h.GetChunks());


FindLiveSharedInfos(g,script);


var i;
try{
i=GatherCompileInfo(new_source,script);
}catch(e){
throw new Failure("Failed to compile new version of script: "+e);
}
var j=BuildCodeInfoTree(i);


FindCorrespondingFunctions(g,j);


var k=new Array();
var l=new Array();
var m=new Array();
var o=new Array();

function HarvestTodo(q){
function CollectDamaged(r){
l.push(r);
for(var t=0;t<r.children.length;t++){
CollectDamaged(r.children[t]);
}
}



function CollectNew(u){
for(var t=0;t<u.length;t++){
m.push(u[t]);
CollectNew(u[t].children);
}
}

if(q.status==a.DAMAGED){
CollectDamaged(q);
return;
}
if(q.status==a.UNCHANGED){
o.push(q);
}else if(q.status==a.SOURCE_CHANGED){
o.push(q);
}else if(q.status==a.CHANGED){
k.push(q);
CollectNew(q.unmatched_new_nodes);
}
for(var t=0;t<q.children.length;t++){
HarvestTodo(q.children[t]);
}
}

var w={
change_tree:DescribeChangeTree(g),
textual_diff:{
old_len:c.length,
new_len:new_source.length,
chunks:diff_array
},
updated:false
};

if(preview_only){
return w;
}

HarvestTodo(g);


var z=new Array();
for(var t=0;t<k.length;t++){
var A=
k[t].live_shared_function_infos;

if(A){
for(var B=0;B<A.length;B++){
z.push(A[B]);
}
}
}





var C=
CheckStackActivations(z,change_log);

w.stack_modified=C!=0;



w[b]=
w.stack_modified;



var D=TemporaryRemoveBreakPoints(script,change_log);

var E;



if(l.length==0){
%LiveEditReplaceScript(script,new_source,null);
E=void 0;
}else{
var G=CreateNameForOldScript(script);



E=%LiveEditReplaceScript(script,new_source,
G);

var H=new Array();
change_log.push({linked_to_old_script:H});


for(var t=0;t<l.length;t++){
LinkToOldScript(l[t],E,
H);
}

w.created_script_name=G;
}


for(var t=0;t<m.length;t++){
%LiveEditFunctionSetScript(
m[t].info.shared_function_info,script);
}

for(var t=0;t<k.length;t++){
PatchFunctionCode(k[t],change_log);
}

var I=new Array();
change_log.push({position_patched:I});

for(var t=0;t<o.length;t++){


PatchPositions(o[t],diff_array,
I);

if(o[t].live_shared_function_infos){
o[t].live_shared_function_infos.
forEach(function(J){
%LiveEditFunctionSourceUpdated(J.raw_array);
});
}
}

D(h,E);

w.updated=true;
return w;
}

this.ApplyPatchMultiChunk=ApplyPatchMultiChunk;











function GatherCompileInfo(K,L){


var M=%LiveEditGatherCompileInfo(L,K);


var N=new Array();
var O=new Array();
for(var t=0;t<M.length;t++){
var J=new FunctionCompileInfo(M[t]);




%LiveEditFunctionSetScript(J.shared_function_info,void 0);
N.push(J);
O.push(t);
}

for(var t=0;t<N.length;t++){
var P=t;
for(var B=t+1;B<N.length;B++){
if(N[P].start_position>N[B].start_position){
P=B;
}
}
if(P!=t){
var Q=N[P];
var R=O[P];
N[P]=N[t];
O[P]=O[t];
N[t]=Q;
O[t]=R;
}
}



var S=0;



function ResetIndexes(T,U){
var W=-1;
while(S<N.length&&
N[S].outer_index==U){
var X=S;
N[X].outer_index=T;
if(W!=-1){
N[W].next_sibling_index=X;
}
W=X;
S++;
ResetIndexes(X,O[X]);
}
if(W!=-1){
N[W].next_sibling_index=-1;
}
}

ResetIndexes(-1,-1);
Assert(S==N.length);

return N;
}



function PatchFunctionCode(q,Y){
var Z=q.corresponding_node.info;
if(q.live_shared_function_infos){
q.live_shared_function_infos.forEach(function(aa){
%LiveEditReplaceFunctionCode(Z.raw_array,
aa.raw_array);







for(var t=0;t<q.children.length;t++){
if(q.children[t].corresponding_node){
var ab=
q.children[t].corresponding_node.info.
shared_function_info;

if(q.children[t].live_shared_function_infos){
q.children[t].live_shared_function_infos.
forEach(function(ac){
%LiveEditReplaceRefToNestedFunction(
aa.info,
ab,
ac.info);
});
}
}
}
});

Y.push({function_patched:Z.function_name});
}else{
Y.push({function_patched:Z.function_name,
function_info_not_found:true});
}
}





function LinkToOldScript(ad,E,ae){
if(ad.live_shared_function_infos){
ad.live_shared_function_infos.
forEach(function(J){
%LiveEditFunctionSetScript(J.info,E);
});

ae.push({name:ad.info.function_name});
}else{
ae.push(
{name:ad.info.function_name,not_found:true});
}
}



function TemporaryRemoveBreakPoints(af,Y){
var ag=GetScriptBreakPoints(af);

var ah=[];
Y.push({break_points_update:ah});

var ai=[];
for(var t=0;t<ag.length;t++){
var aj=ag[t];

aj.clear();


var ak=Debug.findScriptSourcePosition(af,
aj.line(),aj.column());

var al={
position:ak,
line:aj.line(),
column:aj.column()
};
ai.push(al);
}




return function(h,am){


for(var t=0;t<ag.length;t++){
var aj=ag[t];
if(am){
var an=aj.cloneForOtherScript(am);
an.set(am);

ah.push({
type:"copied_to_old",
id:aj.number(),
new_id:an.number(),
positions:ai[t]
});
}

var ao=h.Translate(
ai[t].position,
PosTranslator.ShiftWithTopInsideChunkHandler);

var ap=
af.locationFromPosition(ao,false);

aj.update_positions(ap.line,ap.column);

var aq={
position:ao,
line:ap.line,
column:ap.column
};

aj.set(af);

ah.push({type:"position_changed",
id:aj.number(),
old_positions:ai[t],
new_positions:aq
});
}
};
}


function Assert(ar,as){
if(!ar){
if(as){
throw"Assert "+as;
}else{
throw"Assert";
}
}
}

function DiffChunk(at,au,av,aw){
this.pos1=at;
this.pos2=au;
this.len1=av;
this.len2=aw;
}

function PosTranslator(ax){
var ay=new Array();
var az=0;
for(var t=0;t<ax.length;t+=3){
var aA=ax[t];
var aB=aA+az;
var aC=ax[t+1];
var aD=ax[t+2];
ay.push(new DiffChunk(aA,aB,aC-aA,
aD-aB));
az=aD-aC;
}
this.chunks=ay;
}
PosTranslator.prototype.GetChunks=function(){
return this.chunks;
};

PosTranslator.prototype.Translate=function(aE,aF){
var aG=this.chunks;
if(aG.length==0||aE<aG[0].pos1){
return aE;
}
var aH=0;
var aI=aG.length-1;

while(aH<aI){
var aJ=Math.floor((aH+aI)/2);
if(aE<aG[aJ+1].pos1){
aI=aJ;
}else{
aH=aJ+1;
}
}
var aK=aG[aH];
if(aE>=aK.pos1+aK.len1){
return aE+aK.pos2+aK.len2-aK.pos1-aK.len1;
}

if(!aF){
aF=PosTranslator.DefaultInsideChunkHandler;
}
return aF(aE,aK);
};

PosTranslator.DefaultInsideChunkHandler=function(aE,aL){
Assert(false,"Cannot translate position in changed area");
};

PosTranslator.ShiftWithTopInsideChunkHandler=
function(aE,aL){


return aE-aL.pos1+aL.pos2;
};

var a={


UNCHANGED:"unchanged",


SOURCE_CHANGED:"source changed",


CHANGED:"changed",

DAMAGED:"damaged"
};

function CodeInfoTreeNode(aM,aN,aO){
this.info=aM;
this.children=aN;

this.array_index=aO;
this.parent=void 0;

this.status=a.UNCHANGED;


this.status_explanation=void 0;
this.new_start_pos=void 0;
this.new_end_pos=void 0;
this.corresponding_node=void 0;
this.unmatched_new_nodes=void 0;







this.textual_corresponding_node=void 0;
this.textually_unmatched_new_nodes=void 0;

this.live_shared_function_infos=void 0;
}



function BuildCodeInfoTree(aP){

var aQ=0;


function BuildNode(){
var aR=aQ;
aQ++;
var aS=new Array();
while(aQ<aP.length&&
aP[aQ].outer_index==aR){
aS.push(BuildNode());
}
var r=new CodeInfoTreeNode(aP[aR],aS,
aR);
for(var t=0;t<aS.length;t++){
aS[t].parent=r;
}
return r;
}

var aT=BuildNode();
Assert(aQ==aP.length);
return aT;
}




function MarkChangedFunctions(aU,ay){



var aV=new function(){
var aW=0;
var aX=0;
this.current=function(){return ay[aW];};
this.next=function(){
var aK=ay[aW];
aX=aK.pos2+aK.len2-(aK.pos1+aK.len1);
aW++;
};
this.done=function(){return aW>=ay.length;};
this.TranslatePos=function(aE){return aE+aX;};
};




function ProcessInternals(aY){
aY.new_start_pos=aV.TranslatePos(
aY.info.start_position);
var aZ=0;
var ba=false;
var bb=false;

while(!aV.done()&&
aV.current().pos1<aY.info.end_position){
if(aZ<aY.children.length){
var bc=aY.children[aZ];

if(bc.info.end_position<=aV.current().pos1){
ProcessUnchangedChild(bc);
aZ++;
continue;
}else if(bc.info.start_position>=
aV.current().pos1+aV.current().len1){
ba=true;
aV.next();
continue;
}else if(bc.info.start_position<=aV.current().pos1&&
bc.info.end_position>=aV.current().pos1+
aV.current().len1){
ProcessInternals(bc);
bb=bb||
(bc.status!=a.UNCHANGED);
ba=ba||
(bc.status==a.DAMAGED);
aZ++;
continue;
}else{
ba=true;
bc.status=a.DAMAGED;
bc.status_explanation=
"Text diff overlaps with function boundary";
aZ++;
continue;
}
}else{
if(aV.current().pos1+aV.current().len1<=
aY.info.end_position){
aY.status=a.CHANGED;
aV.next();
continue;
}else{
aY.status=a.DAMAGED;
aY.status_explanation=
"Text diff overlaps with function boundary";
return;
}
}
Assert("Unreachable",false);
}
while(aZ<aY.children.length){
var bc=aY.children[aZ];
ProcessUnchangedChild(bc);
aZ++;
}
if(ba){
aY.status=a.CHANGED;
}else if(bb){
aY.status=a.SOURCE_CHANGED;
}
aY.new_end_pos=
aV.TranslatePos(aY.info.end_position);
}

function ProcessUnchangedChild(r){
r.new_start_pos=aV.TranslatePos(r.info.start_position);
r.new_end_pos=aV.TranslatePos(r.info.end_position);
}

ProcessInternals(aU);
}








function FindCorrespondingFunctions(bd,be){



function ProcessChildren(q,bf){
var bg=q.children;
var bh=bf.children;

var bi=[];
var bj=[];

var bk=0;
var bl=0;
while(bk<bg.length){
if(bg[bk].status==a.DAMAGED){
bk++;
}else if(bl<bh.length){
if(bh[bl].info.start_position<
bg[bk].new_start_pos){
bi.push(bh[bl]);
bj.push(bh[bl]);
bl++;
}else if(bh[bl].info.start_position==
bg[bk].new_start_pos){
if(bh[bl].info.end_position==
bg[bk].new_end_pos){
bg[bk].corresponding_node=
bh[bl];
bg[bk].textual_corresponding_node=
bh[bl];
if(bg[bk].status!=a.UNCHANGED){
ProcessChildren(bg[bk],
bh[bl]);
if(bg[bk].status==a.DAMAGED){
bi.push(
bg[bk].corresponding_node);
bg[bk].corresponding_node=void 0;
q.status=a.CHANGED;
}
}
}else{
bg[bk].status=a.DAMAGED;
bg[bk].status_explanation=
"No corresponding function in new script found";
q.status=a.CHANGED;
bi.push(bh[bl]);
bj.push(bh[bl]);
}
bl++;
bk++;
}else{
bg[bk].status=a.DAMAGED;
bg[bk].status_explanation=
"No corresponding function in new script found";
q.status=a.CHANGED;
bk++;
}
}else{
bg[bk].status=a.DAMAGED;
bg[bk].status_explanation=
"No corresponding function in new script found";
q.status=a.CHANGED;
bk++;
}
}

while(bl<bh.length){
bi.push(bh[bl]);
bj.push(bh[bl]);
bl++;
}

if(q.status==a.CHANGED){
var bm=
WhyFunctionExpectationsDiffer(q.info,bf.info);
if(bm){
q.status=a.DAMAGED;
q.status_explanation=bm;
}
}
q.unmatched_new_nodes=bi;
q.textually_unmatched_new_nodes=
bj;
}

ProcessChildren(bd,be);

bd.corresponding_node=be;
bd.textual_corresponding_node=be;

Assert(bd.status!=a.DAMAGED,
"Script became damaged");
}

function FindLiveSharedInfos(bd,L){
var bn=%LiveEditFindSharedFunctionInfosForScript(L);

var bo=new Array();

for(var t=0;t<bn.length;t++){
bo.push(new SharedInfoWrapper(bn[t]));
}



function FindFunctionInfos(N){
var bp=[];

for(var t=0;t<bo.length;t++){
var bq=bo[t];
if(bq.start_position==N.start_position&&
bq.end_position==N.end_position){
bp.push(bq);
}
}

if(bp.length>0){
return bp;
}
}

function TraverseTree(r){
r.live_shared_function_infos=FindFunctionInfos(r.info);

for(var t=0;t<r.children.length;t++){
TraverseTree(r.children[t]);
}
}

TraverseTree(bd);
}




function FunctionCompileInfo(br){
this.function_name=br[0];
this.start_position=br[1];
this.end_position=br[2];
this.param_num=br[3];
this.code=br[4];
this.code_scope_info=br[5];
this.scope_info=br[6];
this.outer_index=br[7];
this.shared_function_info=br[8];
this.next_sibling_index=null;
this.raw_array=br;
}

function SharedInfoWrapper(br){
this.function_name=br[0];
this.start_position=br[1];
this.end_position=br[2];
this.info=br[3];
this.raw_array=br;
}


function PatchPositions(ad,ax,ae){
if(ad.live_shared_function_infos){
ad.live_shared_function_infos.forEach(function(J){
%LiveEditPatchFunctionPositions(J.raw_array,
ax);
});

ae.push({name:ad.info.function_name});
}else{

ae.push(
{name:ad.info.function_name,info_not_found:true});
}
}


function CreateNameForOldScript(L){

return L.name+" (old)";
}



function WhyFunctionExpectationsDiffer(bs,bt){


if(bs.param_num!=bt.param_num){
return"Changed parameter number: "+bs.param_num+
" and "+bt.param_num;
}
var bu=bs.scope_info;
var bv=bt.scope_info;

var bw;
var bx;

if(bu){
bw=bu.toString();
}else{
bw="";
}
if(bv){
bx=bv.toString();
}else{
bx="";
}

if(bw!=bx){
return"Incompatible variable maps: ["+bw+
"] and ["+bx+"]";
}

return;
}


var by;




function CheckStackActivations(bz,Y){
var bA=new Array();
for(var t=0;t<bz.length;t++){
bA[t]=bz[t].info;
}
var bB=%LiveEditCheckAndDropActivations(bA,true);
if(bB[bA.length]){

throw new Failure(bB[bA.length]);
}

var bC=new Array();
var bD=new Array();
for(var t=0;t<bA.length;t++){
var bE=bz[t];
if(bB[t]==by.REPLACED_ON_ACTIVE_STACK){
bD.push({name:bE.function_name});
}else if(bB[t]!=by.AVAILABLE_FOR_PATCH){
var bF={
name:bE.function_name,
start_pos:bE.start_position,
end_pos:bE.end_position,
replace_problem:
by.SymbolName(bB[t])
};
bC.push(bF);
}
}
if(bD.length>0){
Y.push({dropped_from_stack:bD});
}
if(bC.length>0){
Y.push({functions_on_stack:bC});
throw new Failure("Blocked by functions on stack");
}

return bD.length;
}


var by={
AVAILABLE_FOR_PATCH:1,
BLOCKED_ON_ACTIVE_STACK:2,
BLOCKED_ON_OTHER_STACK:3,
BLOCKED_UNDER_NATIVE_CODE:4,
REPLACED_ON_ACTIVE_STACK:5
};

by.SymbolName=function(bG){
var bH=by;
for(name in bH){
if(bH[name]==bG){
return name;
}
}
};




function Failure(as){
this.message=as;
}

this.Failure=Failure;

Failure.prototype.toString=function(){
return"LiveEdit Failure: "+this.message;
};


function GetPcFromSourcePos(bI,bJ){
return %GetFunctionCodePositionFromSource(bI,bJ);
}

this.GetPcFromSourcePos=GetPcFromSourcePos;


function SetScriptSource(L,bK,bL,Y){
var c=L.source;
var bM=CompareStrings(c,bK);
return ApplyPatchMultiChunk(L,bM,bK,bL,
Y);
}

this.SetScriptSource=SetScriptSource;

function CompareStrings(bN,bO){
return %LiveEditCompareStrings(bN,bO);
}









function ApplySingleChunkPatch(L,change_pos,change_len,new_str,
Y){
var c=L.source;


var bK=c.substring(0,change_pos)+
new_str+c.substring(change_pos+change_len);

return ApplyPatchMultiChunk(L,
[change_pos,change_pos+change_len,change_pos+new_str.length],
bK,false,Y);
}


function DescribeChangeTree(bd){

function ProcessOldNode(r){
var bP=[];
for(var t=0;t<r.children.length;t++){
var bc=r.children[t];
if(bc.status!=a.UNCHANGED){
bP.push(ProcessOldNode(bc));
}
}
var bQ=[];
if(r.textually_unmatched_new_nodes){
for(var t=0;t<r.textually_unmatched_new_nodes.length;t++){
var bc=r.textually_unmatched_new_nodes[t];
bQ.push(ProcessNewNode(bc));
}
}
var bR={
name:r.info.function_name,
positions:DescribePositions(r),
status:r.status,
children:bP,
new_children:bQ
};
if(r.status_explanation){
bR.status_explanation=r.status_explanation;
}
if(r.textual_corresponding_node){
bR.new_positions=DescribePositions(r.textual_corresponding_node);
}
return bR;
}

function ProcessNewNode(r){
var bP=[];

if(false){
for(var t=0;t<r.children.length;t++){
bP.push(ProcessNewNode(r.children[t]));
}
}
var bR={
name:r.info.function_name,
positions:DescribePositions(r),
children:bP,
};
return bR;
}

function DescribePositions(r){
return{
start_position:r.info.start_position,
end_position:r.info.end_position
};
}

return ProcessOldNode(bd);
}


function RestartFrame(bS){
var bB=bS.restart();
if((typeof(bB)==='string')){
throw new Failure("Failed to restart frame: "+bB);
}
var bB={};
bB[b]=true;
return bB;
}

this.RestartFrame=RestartFrame;


this.TestApi={
PosTranslator:PosTranslator,
CompareStrings:CompareStrings,
ApplySingleChunkPatch:ApplySingleChunkPatch
};
};








































var $Date=global.Date;


function ThrowDateTypeError(){
throw new $TypeError('this is not a Date object.');
}


var timezone_cache_time=$NaN;
var timezone_cache_timezone;

function LocalTimezone(a){
if((!%_IsSmi(%IS_VAR(a))&&!(a==a)))return"";
if(a==timezone_cache_time){
return timezone_cache_timezone;
}
var b=%DateLocalTimezone(a);
timezone_cache_time=a;
timezone_cache_timezone=b;
return b;
}


function UTC(a){
if((!%_IsSmi(%IS_VAR(a))&&!(a==a)))return a;


return %DateToUTC(a);
}



function MakeTime(a,b,c,d){
if(!$isFinite(a))return $NaN;
if(!$isFinite(b))return $NaN;
if(!$isFinite(c))return $NaN;
if(!$isFinite(d))return $NaN;
return(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a)))*3600000
+(%_IsSmi(%IS_VAR(b))?b:%NumberToInteger(ToNumber(b)))*60000
+(%_IsSmi(%IS_VAR(c))?c:%NumberToInteger(ToNumber(c)))*1000
+(%_IsSmi(%IS_VAR(d))?d:%NumberToInteger(ToNumber(d)));
}



function TimeInYear(a){
return DaysInYear(a)*86400000;
}








function MakeDay(a,b,c){
if(!$isFinite(a)||!$isFinite(b)||!$isFinite(c))return $NaN;


a=(%_IsSmi(%IS_VAR(a))?a:%NumberToIntegerMapMinusZero(ToNumber(a)));
b=(%_IsSmi(%IS_VAR(b))?b:%NumberToIntegerMapMinusZero(ToNumber(b)));
c=(%_IsSmi(%IS_VAR(c))?c:%NumberToIntegerMapMinusZero(ToNumber(c)));

if(a<-1000000||a>1000000||
b<-10000000||b>10000000){
return $NaN;
}


return %DateMakeDay(a,b)+c-1;
}



function MakeDate(a,b){
var b=a*86400000+b;





if($abs(b)>8640002592000000)return $NaN;
return b;
}



function TimeClip(a){
if(!$isFinite(a))return $NaN;
if($abs(a)>8640000000000000)return $NaN;
return(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a)));
}




var Date_cache={

time:$NaN,

string:null
};


%SetCode($Date,function(a,b,c,d,g,h,i){
if(!%_IsConstructCall()){

return(new $Date()).toString();
}


var j=%_ArgumentsLength();
var k;
if(j==0){
k=%DateCurrentTime();
(%DateSetValue(this,k,1));
}else if(j==1){
if((typeof(a)==='number')){
k=a;
}else if((typeof(a)==='string')){


var l=Date_cache;
if(l.string===a){
k=l.time;
}else{
k=DateParse(a);
if(!(!%_IsSmi(%IS_VAR(k))&&!(k==k))){
l.time=k;
l.string=a;
}
}

}else{







var m=ToPrimitive(a,1);
k=(typeof(m)==='string')?DateParse(m):ToNumber(m);
}
(%DateSetValue(this,k,1));
}else{
a=ToNumber(a);
b=ToNumber(b);
c=j>2?ToNumber(c):1;
d=j>3?ToNumber(d):0;
g=j>4?ToNumber(g):0;
h=j>5?ToNumber(h):0;
i=j>6?ToNumber(i):0;
a=(!(!%_IsSmi(%IS_VAR(a))&&!(a==a))&&
0<=(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a)))&&
(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a)))<=99)?1900+(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a))):a;
var o=MakeDay(a,b,c);
var m=MakeTime(d,g,h,i);
k=MakeDate(o,m);
(%DateSetValue(this,k,0));
}
});


%FunctionSetPrototype($Date,new $Date($NaN));


var WeekDays=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
var Months=['Jan','Feb','Mar','Apr','May','Jun',
'Jul','Aug','Sep','Oct','Nov','Dec'];


function TwoDigitString(a){
return a<10?"0"+a:""+a;
}


function DateString(a){
return WeekDays[(%_DateField(a,4))]+' '
+Months[(%_DateField(a,2))]+' '
+TwoDigitString((%_DateField(a,3)))+' '
+(%_DateField(a,1));
}


var LongWeekDays=['Sunday','Monday','Tuesday','Wednesday',
'Thursday','Friday','Saturday'];
var LongMonths=['January','February','March','April','May','June',
'July','August','September','October','November','December'];


function LongDateString(a){
return LongWeekDays[(%_DateField(a,4))]+', '
+LongMonths[(%_DateField(a,2))]+' '
+TwoDigitString((%_DateField(a,3)))+', '
+(%_DateField(a,1));
}


function TimeString(a){
return TwoDigitString((%_DateField(a,5)))+':'
+TwoDigitString((%_DateField(a,6)))+':'
+TwoDigitString((%_DateField(a,7)));
}


function TimeStringUTC(a){
return TwoDigitString((%_DateField(a,15)))+':'
+TwoDigitString((%_DateField(a,16)))+':'
+TwoDigitString((%_DateField(a,17)));
}


function LocalTimezoneString(a){
var b=LocalTimezone((%_DateField(a,0)));

var c=-(%_DateField(a,21));
var d=(c>=0)?1:-1;
var g=$floor((d*c)/60);
var h=$floor((d*c)%60);
var i=' GMT'+((d==1)?'+':'-')+
TwoDigitString(g)+TwoDigitString(h);
return i+' ('+b+')';
}


function DatePrintString(a){
return DateString(a)+' '+TimeString(a);
}




var parse_buffer=$Array(8);


function DateParse(a){
var b=%DateParseString(ToString(a),parse_buffer);
if((b===null))return $NaN;

var c=MakeDay(b[0],b[1],b[2]);
var d=MakeTime(b[3],b[4],b[5],b[6]);
var g=MakeDate(c,d);

if((b[7]===null)){
return TimeClip(UTC(g));
}else{
return TimeClip(g-b[7]*1000);
}
}



function DateUTC(a,b,c,d,g,h,i){
a=ToNumber(a);
b=ToNumber(b);
var j=%_ArgumentsLength();
c=j>2?ToNumber(c):1;
d=j>3?ToNumber(d):0;
g=j>4?ToNumber(g):0;
h=j>5?ToNumber(h):0;
i=j>6?ToNumber(i):0;
a=(!(!%_IsSmi(%IS_VAR(a))&&!(a==a))&&
0<=(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a)))&&
(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a)))<=99)?1900+(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a))):a;
var k=MakeDay(a,b,c);
var l=MakeTime(d,g,h,i);
return TimeClip(MakeDate(k,l));
}




function DateNow(){
return %DateCurrentTime();
}



function DateToString(){
var a=(%_DateField(this,0))
if((!%_IsSmi(%IS_VAR(a))&&!(a==a)))return'Invalid Date';
var b=LocalTimezoneString(this)
return DatePrintString(this)+b;
}



function DateToDateString(){
var a=(%_DateField(this,0));
if((!%_IsSmi(%IS_VAR(a))&&!(a==a)))return'Invalid Date';
return DateString(this);
}



function DateToTimeString(){
var a=(%_DateField(this,0));
if((!%_IsSmi(%IS_VAR(a))&&!(a==a)))return'Invalid Date';
var b=LocalTimezoneString(this);
return TimeString(this)+b;
}



function DateToLocaleString(){
return %_CallFunction(this,DateToString);
}



function DateToLocaleDateString(){
var a=(%_DateField(this,0));
if((!%_IsSmi(%IS_VAR(a))&&!(a==a)))return'Invalid Date';
return LongDateString(this);
}



function DateToLocaleTimeString(){
var a=(%_DateField(this,0));
if((!%_IsSmi(%IS_VAR(a))&&!(a==a)))return'Invalid Date';
return TimeString(this);
}



function DateValueOf(){
return(%_DateField(this,0));
}



function DateGetTime(){
return(%_DateField(this,0));
}



function DateGetFullYear(){
return(%_DateField(this,1));
}



function DateGetUTCFullYear(){
return(%_DateField(this,11));
}



function DateGetMonth(){
return(%_DateField(this,2));
}



function DateGetUTCMonth(){
return(%_DateField(this,12));
}



function DateGetDate(){
return(%_DateField(this,3));
}



function DateGetUTCDate(){
return(%_DateField(this,13));
}



function DateGetDay(){
return(%_DateField(this,4));
}



function DateGetUTCDay(){
return(%_DateField(this,14));
}



function DateGetHours(){
return(%_DateField(this,5));
}



function DateGetUTCHours(){
return(%_DateField(this,15));
}



function DateGetMinutes(){
return(%_DateField(this,6));
}



function DateGetUTCMinutes(){
return(%_DateField(this,16));
}



function DateGetSeconds(){
return(%_DateField(this,7));
}



function DateGetUTCSeconds(){
return(%_DateField(this,17))
}



function DateGetMilliseconds(){
return(%_DateField(this,8));
}



function DateGetUTCMilliseconds(){
return(%_DateField(this,18));
}



function DateGetTimezoneOffset(){
return(%_DateField(this,21));
}



function DateSetTime(a){
if(%_ClassOf(this)!=='Date')ThrowDateTypeError();
(%DateSetValue(this,ToNumber(a),1));
return(%_DateField(this,0));
}



function DateSetMilliseconds(a){
var b=(%_DateField(this,0)+%_DateField(this,21));
a=ToNumber(a);
var c=MakeTime((%_DateField(this,5)),(%_DateField(this,6)),(%_DateField(this,7)),a);
return(%DateSetValue(this,MakeDate((%_DateField(this,9)),c),0));
}



function DateSetUTCMilliseconds(a){
var b=(%_DateField(this,0));
a=ToNumber(a);
var c=MakeTime((%_DateField(this,15)),
(%_DateField(this,16)),
(%_DateField(this,17)),
a);
return(%DateSetValue(this,MakeDate((%_DateField(this,19)),c),1));
}



function DateSetSeconds(a,b){
var c=(%_DateField(this,0)+%_DateField(this,21));
a=ToNumber(a);
b=%_ArgumentsLength()<2?(%_DateField(this,8)):ToNumber(b);
var d=MakeTime((%_DateField(this,5)),(%_DateField(this,6)),a,b);
return(%DateSetValue(this,MakeDate((%_DateField(this,9)),d),0));
}



function DateSetUTCSeconds(a,b){
var c=(%_DateField(this,0));
a=ToNumber(a);
b=%_ArgumentsLength()<2?(%_DateField(this,18)):ToNumber(b);
var d=MakeTime((%_DateField(this,15)),(%_DateField(this,16)),a,b);
return(%DateSetValue(this,MakeDate((%_DateField(this,19)),d),1));
}



function DateSetMinutes(a,b,c){
var d=(%_DateField(this,0)+%_DateField(this,21));
a=ToNumber(a);
var g=%_ArgumentsLength();
b=g<2?(%_DateField(this,7)):ToNumber(b);
c=g<3?(%_DateField(this,8)):ToNumber(c);
var h=MakeTime((%_DateField(this,5)),a,b,c);
return(%DateSetValue(this,MakeDate((%_DateField(this,9)),h),0));
}



function DateSetUTCMinutes(a,b,c){
var d=(%_DateField(this,0));
a=ToNumber(a);
var g=%_ArgumentsLength();
b=g<2?(%_DateField(this,17)):ToNumber(b);
c=g<3?(%_DateField(this,18)):ToNumber(c);
var h=MakeTime((%_DateField(this,15)),a,b,c);
return(%DateSetValue(this,MakeDate((%_DateField(this,19)),h),1));
}



function DateSetHours(a,b,c,d){
var g=(%_DateField(this,0)+%_DateField(this,21));
a=ToNumber(a);
var h=%_ArgumentsLength();
b=h<2?(%_DateField(this,6)):ToNumber(b);
c=h<3?(%_DateField(this,7)):ToNumber(c);
d=h<4?(%_DateField(this,8)):ToNumber(d);
var i=MakeTime(a,b,c,d);
return(%DateSetValue(this,MakeDate((%_DateField(this,9)),i),0));
}



function DateSetUTCHours(a,b,c,d){
var g=(%_DateField(this,0));
a=ToNumber(a);
var h=%_ArgumentsLength();
b=h<2?(%_DateField(this,16)):ToNumber(b);
c=h<3?(%_DateField(this,17)):ToNumber(c);
d=h<4?(%_DateField(this,18)):ToNumber(d);
var i=MakeTime(a,b,c,d);
return(%DateSetValue(this,MakeDate((%_DateField(this,19)),i),1));
}



function DateSetDate(a){
var b=(%_DateField(this,0)+%_DateField(this,21));
a=ToNumber(a);
var c=MakeDay((%_DateField(this,1)),(%_DateField(this,2)),a);
return(%DateSetValue(this,MakeDate(c,(%_DateField(this,10))),0));
}



function DateSetUTCDate(a){
var b=(%_DateField(this,0));
a=ToNumber(a);
var c=MakeDay((%_DateField(this,11)),(%_DateField(this,12)),a);
return(%DateSetValue(this,MakeDate(c,(%_DateField(this,20))),1));
}



function DateSetMonth(a,b){
var c=(%_DateField(this,0)+%_DateField(this,21));
a=ToNumber(a);
b=%_ArgumentsLength()<2?(%_DateField(this,3)):ToNumber(b);
var d=MakeDay((%_DateField(this,1)),a,b);
return(%DateSetValue(this,MakeDate(d,(%_DateField(this,10))),0));
}



function DateSetUTCMonth(a,b){
var c=(%_DateField(this,0));
a=ToNumber(a);
b=%_ArgumentsLength()<2?(%_DateField(this,13)):ToNumber(b);
var d=MakeDay((%_DateField(this,11)),a,b);
return(%DateSetValue(this,MakeDate(d,(%_DateField(this,20))),1));
}



function DateSetFullYear(a,b,c){
var d=(%_DateField(this,0)+%_DateField(this,21));
a=ToNumber(a);
var g=%_ArgumentsLength();
var h;
if((!%_IsSmi(%IS_VAR(d))&&!(d==d))){
b=g<2?0:ToNumber(b);
c=g<3?1:ToNumber(c);
h=0;
}else{
b=g<2?(%_DateField(this,2)):ToNumber(b);
c=g<3?(%_DateField(this,3)):ToNumber(c);
h=(%_DateField(this,10));
}
var i=MakeDay(a,b,c);
return(%DateSetValue(this,MakeDate(i,h),0));
}



function DateSetUTCFullYear(a,b,c){
var d=(%_DateField(this,0));
a=ToNumber(a);
var g=%_ArgumentsLength();
var h;
if((!%_IsSmi(%IS_VAR(d))&&!(d==d))){
b=g<2?0:ToNumber(b);
c=g<3?1:ToNumber(c);
h=0;
}else{
b=g<2?(%_DateField(this,12)):ToNumber(b);
c=g<3?(%_DateField(this,13)):ToNumber(c);
h=(%_DateField(this,20));
}
var i=MakeDay(a,b,c);
return(%DateSetValue(this,MakeDate(i,h),1));
}



function DateToUTCString(){
var a=(%_DateField(this,0));
if((!%_IsSmi(%IS_VAR(a))&&!(a==a)))return'Invalid Date';

return WeekDays[(%_DateField(this,14))]+', '
+TwoDigitString((%_DateField(this,13)))+' '
+Months[(%_DateField(this,12))]+' '
+(%_DateField(this,11))+' '
+TimeStringUTC(this)+' GMT';
}



function DateGetYear(){
return(%_DateField(this,1))-1900;
}



function DateSetYear(a){
if(%_ClassOf(this)!=='Date')ThrowDateTypeError();
a=ToNumber(a);
if((!%_IsSmi(%IS_VAR(a))&&!(a==a)))return(%DateSetValue(this,$NaN,1));
a=(0<=(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a)))&&(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a)))<=99)
?1900+(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a))):a;
var b=(%_DateField(this,0)+%_DateField(this,21));
var c,d,g;
if((!%_IsSmi(%IS_VAR(b))&&!(b==b))){
c=0;
d=1;
g=0;
}else{
c=(%_DateField(this,2));
d=(%_DateField(this,3));
g=(%_DateField(this,10));
}
var h=MakeDay(a,c,d);
return(%DateSetValue(this,MakeDate(h,g),0));
}









function DateToGMTString(){
return %_CallFunction(this,DateToUTCString);
}


function PadInt(a,b){
if(b==1)return a;
return a<MathPow(10,b-1)?'0'+PadInt(a,b-1):a;
}



function DateToISOString(){
var a=(%_DateField(this,0));
if((!%_IsSmi(%IS_VAR(a))&&!(a==a)))throw MakeRangeError("invalid_time_value",[]);
var b=this.getUTCFullYear();
var c;
if(b>=0&&b<=9999){
c=PadInt(b,4);
}else{
if(b<0){
c="-"+PadInt(-b,6);
}else{
c="+"+PadInt(b,6);
}
}
return c+
'-'+PadInt(this.getUTCMonth()+1,2)+
'-'+PadInt(this.getUTCDate(),2)+
'T'+PadInt(this.getUTCHours(),2)+
':'+PadInt(this.getUTCMinutes(),2)+
':'+PadInt(this.getUTCSeconds(),2)+
'.'+PadInt(this.getUTCMilliseconds(),3)+
'Z';
}


function DateToJSON(a){
var b=ToObject(this);
var c=DefaultNumber(b);
if((typeof(c)==='number')&&!(%_IsSmi(%IS_VAR(c))||((c==c)&&(c!=1/0)&&(c!=-1/0)))){
return null;
}
return b.toISOString();
}


function ResetDateCache(){

timezone_cache_time=$NaN;
timezone_cache_timezone=undefined;


cache=Date_cache;
cache.time=$NaN;
cache.string=null;
}




function SetUpDate(){
%CheckIsBootstrapping();

InstallFunctions($Date,2,$Array(
"UTC",DateUTC,
"parse",DateParse,
"now",DateNow
));


%SetProperty($Date.prototype,"constructor",$Date,2);



InstallFunctions($Date.prototype,2,$Array(
"toString",DateToString,
"toDateString",DateToDateString,
"toTimeString",DateToTimeString,
"toLocaleString",DateToLocaleString,
"toLocaleDateString",DateToLocaleDateString,
"toLocaleTimeString",DateToLocaleTimeString,
"valueOf",DateValueOf,
"getTime",DateGetTime,
"getFullYear",DateGetFullYear,
"getUTCFullYear",DateGetUTCFullYear,
"getMonth",DateGetMonth,
"getUTCMonth",DateGetUTCMonth,
"getDate",DateGetDate,
"getUTCDate",DateGetUTCDate,
"getDay",DateGetDay,
"getUTCDay",DateGetUTCDay,
"getHours",DateGetHours,
"getUTCHours",DateGetUTCHours,
"getMinutes",DateGetMinutes,
"getUTCMinutes",DateGetUTCMinutes,
"getSeconds",DateGetSeconds,
"getUTCSeconds",DateGetUTCSeconds,
"getMilliseconds",DateGetMilliseconds,
"getUTCMilliseconds",DateGetUTCMilliseconds,
"getTimezoneOffset",DateGetTimezoneOffset,
"setTime",DateSetTime,
"setMilliseconds",DateSetMilliseconds,
"setUTCMilliseconds",DateSetUTCMilliseconds,
"setSeconds",DateSetSeconds,
"setUTCSeconds",DateSetUTCSeconds,
"setMinutes",DateSetMinutes,
"setUTCMinutes",DateSetUTCMinutes,
"setHours",DateSetHours,
"setUTCHours",DateSetUTCHours,
"setDate",DateSetDate,
"setUTCDate",DateSetUTCDate,
"setMonth",DateSetMonth,
"setUTCMonth",DateSetUTCMonth,
"setFullYear",DateSetFullYear,
"setUTCFullYear",DateSetUTCFullYear,
"toGMTString",DateToGMTString,
"toUTCString",DateToUTCString,
"getYear",DateGetYear,
"setYear",DateSetYear,
"toISOString",DateToISOString,
"toJSON",DateToJSON
));
}

SetUpDate();




























var $JSON=global.JSON;

function Revive(a,b,c){
var d=a[b];
if((%_IsObject(d))){
if((%_IsArray(d))){
var g=d.length;
for(var h=0;h<g;h++){
var i=Revive(d,$String(h),c);
d[h]=i;
}
}else{
for(var j in d){
if(%_CallFunction(d,j,ObjectHasOwnProperty)){
var i=Revive(d,j,c);
if((typeof(i)==='undefined')){
delete d[j];
}else{
d[j]=i;
}
}
}
}
}
return %_CallFunction(a,b,d,c);
}

function JSONParse(a,b){
var c=%ParseJson(((typeof(%IS_VAR(a))==='string')?a:NonStringToString(a)));
if((%_ClassOf(b)==='Function')){
return Revive({'':c},'',b);
}else{
return c;
}
}

function SerializeArray(a,b,c,d,g){
if(!%PushIfAbsent(c,a)){
throw MakeTypeError('circular_structure',$Array());
}
var h=d;
d+=g;
var i=new InternalArray();
var j=a.length;
for(var k=0;k<j;k++){
var l=JSONSerialize($String(k),a,b,c,
d,g);
if((typeof(l)==='undefined')){
l="null";
}
i.push(l);
}
var m;
if(g==""){
m="["+i.join(",")+"]";
}else if(i.length>0){
var o=",\n"+d;
m="[\n"+d+i.join(o)+"\n"+
h+"]";
}else{
m="[]";
}
c.pop();
return m;
}

function SerializeObject(a,b,c,d,g){
if(!%PushIfAbsent(c,a)){
throw MakeTypeError('circular_structure',$Array());
}
var h=d;
d+=g;
var i=new InternalArray();
if((%_IsArray(b))){
var j=b.length;
for(var k=0;k<j;k++){
if(%_CallFunction(b,k,ObjectHasOwnProperty)){
var l=b[k];
var m=JSONSerialize(l,a,b,c,d,g);
if(!(typeof(m)==='undefined')){
var o=%QuoteJSONString(l)+":";
if(g!="")o+=" ";
o+=m;
i.push(o);
}
}
}
}else{
for(var l in a){
if(%_CallFunction(a,l,ObjectHasOwnProperty)){
var m=JSONSerialize(l,a,b,c,d,g);
if(!(typeof(m)==='undefined')){
var o=%QuoteJSONString(l)+":";
if(g!="")o+=" ";
o+=m;
i.push(o);
}
}
}
}
var q;
if(g==""){
q="{"+i.join(",")+"}";
}else if(i.length>0){
var r=",\n"+d;
q="{\n"+d+i.join(r)+"\n"+
h+"}";
}else{
q="{}";
}
c.pop();
return q;
}

function JSONSerialize(a,b,c,d,g,h){
var i=b[a];
if((%_IsSpecObject(i))){
var j=i.toJSON;
if((%_ClassOf(j)==='Function')){
i=%_CallFunction(i,a,j);
}
}
if((%_ClassOf(c)==='Function')){
i=%_CallFunction(b,a,i,c);
}
if((typeof(i)==='string')){
return %QuoteJSONString(i);
}else if((typeof(i)==='number')){
return((%_IsSmi(%IS_VAR(i))||i-i==0)?%_NumberToString(i):"null");
}else if((typeof(i)==='boolean')){
return i?"true":"false";
}else if((i===null)){
return"null";
}else if((%_IsSpecObject(i))&&!(typeof i=="function")){

if((%_IsArray(i))){
return SerializeArray(i,c,d,g,h);
}else if((%_ClassOf(i)==='Number')){
i=ToNumber(i);
return((%_IsSmi(%IS_VAR(i))||i-i==0)?%_NumberToString(i):"null");
}else if((%_ClassOf(i)==='String')){
return %QuoteJSONString(ToString(i));
}else if((%_ClassOf(i)==='Boolean')){
return %_ValueOf(i)?"true":"false";
}else{
return SerializeObject(i,c,d,g,h);
}
}

return void 0;
}


function BasicSerializeArray(a,b,c){
var d=a.length;
if(d==0){
c.push("[]");
return;
}
if(!%PushIfAbsent(b,a)){
throw MakeTypeError('circular_structure',$Array());
}
c.push("[");
var g=a[0];
if((typeof(g)==='string')){

var h=%QuoteJSONStringArray(a);
if(!(typeof(h)==='undefined')){

c[c.length-1]=h;
b.pop();
return;
}else{
c.push(%QuoteJSONString(g));
for(var i=1;i<d;i++){
g=a[i];
if((typeof(g)==='string')){
c.push(%QuoteJSONStringComma(g));
}else{
c.push(",");
var j=c.length;
BasicJSONSerialize(i,g,b,c);
if(j==c.length)c[j-1]=",null";
}
}
}
}else if((typeof(g)==='number')){

c.push(((%_IsSmi(%IS_VAR(g))||g-g==0)?%_NumberToString(g):"null"));
for(var i=1;i<d;i++){
c.push(",");
g=a[i];
if((typeof(g)==='number')){
c.push(((%_IsSmi(%IS_VAR(g))||g-g==0)?%_NumberToString(g):"null"));
}else{
var j=c.length;
BasicJSONSerialize(i,g,b,c);
if(j==c.length)c[j-1]=",null";
}
}
}else{
var j=c.length;
BasicJSONSerialize(0,g,b,c);
if(j==c.length)c.push("null");
for(var i=1;i<d;i++){
c.push(",");
j=c.length;
BasicJSONSerialize(i,a[i],b,c);
if(j==c.length)c[j-1]=",null";
}
}
b.pop();
c.push("]");
}


function BasicSerializeObject(a,b,c){
if(!%PushIfAbsent(b,a)){
throw MakeTypeError('circular_structure',$Array());
}
c.push("{");
var d=true;
var g=%ObjectKeys(a);
var h=g.length;
for(var i=0;i<h;i++){
var j=g[i];
if(!d){
c.push(%QuoteJSONStringComma(j));
}else{
c.push(%QuoteJSONString(j));
}
c.push(":");
var k=c.length;
BasicJSONSerialize(j,a[j],b,c);
if(k==c.length){
c.pop();
c.pop();
}else{
d=false;
}
}
b.pop();
c.push("}");
}


function BasicJSONSerialize(a,b,c,d){
if((%_IsSpecObject(b))){
var g=b.toJSON;
if((%_ClassOf(g)==='Function')){
b=%_CallFunction(b,ToString(a),g);
}
}
if((typeof(b)==='string')){
d.push(b!==""?%QuoteJSONString(b):'""');
}else if((typeof(b)==='number')){
d.push(((%_IsSmi(%IS_VAR(b))||b-b==0)?%_NumberToString(b):"null"));
}else if((typeof(b)==='boolean')){
d.push(b?"true":"false");
}else if((b===null)){
d.push("null");
}else if((%_IsSpecObject(b))&&!(typeof b=="function")){


if((%_ClassOf(b)==='Number')){
b=ToNumber(b);
d.push(((%_IsSmi(%IS_VAR(b))||b-b==0)?%_NumberToString(b):"null"));
}else if((%_ClassOf(b)==='String')){
d.push(%QuoteJSONString(ToString(b)));
}else if((%_ClassOf(b)==='Boolean')){
d.push(%_ValueOf(b)?"true":"false");
}else if((%_IsArray(b))){
BasicSerializeArray(b,c,d);
}else{
BasicSerializeObject(b,c,d);
}
}
}


function JSONStringify(a,b,c){
if(%_ArgumentsLength()==1){
var d=new InternalArray();
BasicJSONSerialize('',a,new InternalArray(),d);
if(d.length==0)return;
var g=%_FastAsciiArrayJoin(d,"");
if(!(typeof(g)==='undefined'))return g;
return %StringBuilderConcat(d,d.length,"");
}
if((%_IsObject(c))){

if((%_ClassOf(c)==='Number')){
c=ToNumber(c);
}else if((%_ClassOf(c)==='String')){
c=ToString(c);
}
}
var h;
if((typeof(c)==='number')){
c=MathMax(0,MathMin(ToInteger(c),10));
h=SubString("          ",0,c);
}else if((typeof(c)==='string')){
if(c.length>10){
h=SubString(c,0,10);
}else{
h=c;
}
}else{
h="";
}
return JSONSerialize('',{'':a},b,new InternalArray(),"",h);
}

function SetUpJSON(){
%CheckIsBootstrapping();
InstallFunctions($JSON,2,$Array(
"parse",JSONParse,
"stringify",JSONStringify
));
}

SetUpJSON();































var $RegExp=global.RegExp;



function DoConstructRegExp(a,b,c){

if((%_IsRegExp(b))){
if(!(typeof(c)==='undefined')){
throw MakeTypeError('regexp_flags',[]);
}
c=(b.global?'g':'')
+(b.ignoreCase?'i':'')
+(b.multiline?'m':'');
b=b.source;
}

b=(typeof(b)==='undefined')?'':ToString(b);
c=(typeof(c)==='undefined')?'':ToString(c);

var d=false;
var g=false;
var h=false;
for(var i=0;i<c.length;i++){
var j=%_CallFunction(c,i,StringCharAt);
switch(j){
case'g':
if(d){
throw MakeSyntaxError("invalid_regexp_flags",[c]);
}
d=true;
break;
case'i':
if(g){
throw MakeSyntaxError("invalid_regexp_flags",[c]);
}
g=true;
break;
case'm':
if(h){
throw MakeSyntaxError("invalid_regexp_flags",[c]);
}
h=true;
break;
default:
throw MakeSyntaxError("invalid_regexp_flags",[c]);
}
}

%RegExpInitializeObject(a,b,d,g,h);


%RegExpCompile(a,b,c);
}


function RegExpConstructor(a,b){
if(%_IsConstructCall()){
DoConstructRegExp(this,a,b);
}else{

if((%_IsRegExp(a))&&(typeof(b)==='undefined')){
return a;
}
return new $RegExp(a,b);
}
}





function RegExpCompile(a,b){







if(this==$RegExp.prototype){

throw MakeTypeError('incompatible_method_receiver',
['RegExp.prototype.compile',this]);
}
if((typeof(a)==='undefined')&&%_ArgumentsLength()!=0){
DoConstructRegExp(this,'undefined',b);
}else{
DoConstructRegExp(this,a,b);
}
}


function DoRegExpExec(a,b,c){
var d=%_RegExpExec(a,b,c,lastMatchInfo);
if(d!==null)lastMatchInfoOverride=null;
return d;
}


function BuildResultFromMatchInfo(a,b){
var c=((a)[0])>>1;
var d=a[3];
var g=a[4];
var h=%_RegExpConstructResult(c,d,b);
if(d+1==g){
h[0]=%_StringCharAt(b,d);
}else{
h[0]=%_SubString(b,d,g);
}
var i=3+2;
for(var j=1;j<c;j++){
d=a[i++];
if(d!=-1){
g=a[i];
if(d+1==g){
h[j]=%_StringCharAt(b,d);
}else{
h[j]=%_SubString(b,d,g);
}
}
i++;
}
return h;
}


function RegExpExecNoTests(a,b,c){

var d=%_RegExpExec(a,b,c,lastMatchInfo);
if(d!==null){
lastMatchInfoOverride=null;
return BuildResultFromMatchInfo(d,b);
}
return null;
}


function RegExpExec(a){
if(!(%_IsRegExp(this))){
throw MakeTypeError('incompatible_method_receiver',
['RegExp.prototype.exec',this]);
}

a=((typeof(%IS_VAR(a))==='string')?a:NonStringToString(a));
var b=this.lastIndex;



var c=(%_IsSmi(%IS_VAR(b))?b:%NumberToInteger(ToNumber(b)));

var d=this.global;
if(d){
if(c<0||c>a.length){
this.lastIndex=0;
return null;
}
}else{
c=0;
}

%_Log('regexp','regexp-exec,%0r,%1S,%2i',[this,a,b]);

var g=%_RegExpExec(this,a,c,lastMatchInfo);

if(g===null){
if(d)this.lastIndex=0;
return null;
}


lastMatchInfoOverride=null;
if(d){
this.lastIndex=lastMatchInfo[4];
}
return BuildResultFromMatchInfo(g,a);
}



var regexp_key;
var regexp_val;





function RegExpTest(a){
if(!(%_IsRegExp(this))){
throw MakeTypeError('incompatible_method_receiver',
['RegExp.prototype.test',this]);
}
a=((typeof(%IS_VAR(a))==='string')?a:NonStringToString(a));

var b=this.lastIndex;



var c=(%_IsSmi(%IS_VAR(b))?b:%NumberToInteger(ToNumber(b)));

if(this.global){
if(c<0||c>a.length){
this.lastIndex=0;
return false;
}
%_Log('regexp','regexp-exec,%0r,%1S,%2i',[this,a,b]);

var d=%_RegExpExec(this,a,c,lastMatchInfo);
if(d===null){
this.lastIndex=0;
return false;
}
lastMatchInfoOverride=null;
this.lastIndex=lastMatchInfo[4];
return true;
}else{




var g=this;
if(%_StringCharCodeAt(g.source,0)==46&&
%_StringCharCodeAt(g.source,1)==42&&
%_StringCharCodeAt(g.source,2)!=63){
g=TrimRegExp(g);
}
%_Log('regexp','regexp-exec,%0r,%1S,%2i',[g,a,b]);

var d=%_RegExpExec(g,a,0,lastMatchInfo);
if(d===null)return false;
lastMatchInfoOverride=null;
return true;
}
}

function TrimRegExp(a){
if(!%_ObjectEquals(regexp_key,a)){
regexp_key=a;
regexp_val=
new $RegExp(SubString(a.source,2,a.source.length),
(a.ignoreCase?a.multiline?"im":"i"
:a.multiline?"m":""));
}
return regexp_val;
}


function RegExpToString(){
if(!(%_IsRegExp(this))){
throw MakeTypeError('incompatible_method_receiver',
['RegExp.prototype.toString',this]);
}
var a='/'+this.source+'/';
if(this.global)a+='g';
if(this.ignoreCase)a+='i';
if(this.multiline)a+='m';
return a;
}






function RegExpGetLastMatch(){
if(lastMatchInfoOverride!==null){
return((lastMatchInfoOverride)[0]);
}
var a=((lastMatchInfo)[1]);
return SubString(a,
lastMatchInfo[3],
lastMatchInfo[4]);
}


function RegExpGetLastParen(){
if(lastMatchInfoOverride){
var a=lastMatchInfoOverride;
if(a.length<=3)return'';
return a[a.length-3];
}
var b=((lastMatchInfo)[0]);
if(b<=2)return'';



var c=((lastMatchInfo)[1]);
var d=lastMatchInfo[(3+(b-2))];
var g=lastMatchInfo[(3+(b-1))];
if(d!=-1&&g!=-1){
return SubString(c,d,g);
}
return"";
}


function RegExpGetLeftContext(){
var a;
var b;
if(!lastMatchInfoOverride){
a=lastMatchInfo[3];
b=((lastMatchInfo)[1]);
}else{
var c=lastMatchInfoOverride;
a=((c)[(c).length-2]);
b=((c)[(c).length-1]);
}
return SubString(b,0,a);
}


function RegExpGetRightContext(){
var a;
var b;
if(!lastMatchInfoOverride){
a=lastMatchInfo[4];
b=((lastMatchInfo)[1]);
}else{
var c=lastMatchInfoOverride;
b=((c)[(c).length-1]);
var d=((c)[0]);
a=((c)[(c).length-2])+d.length;
}
return SubString(b,a,b.length);
}





function RegExpMakeCaptureGetter(a){
return function(){
if(lastMatchInfoOverride){
if(a<lastMatchInfoOverride.length-2){
return((lastMatchInfoOverride)[(a)]);
}
return'';
}
var b=a*2;
if(b>=((lastMatchInfo)[0]))return'';
var c=lastMatchInfo[(3+(b))];
var d=lastMatchInfo[(3+(b+1))];
if(c==-1||d==-1)return'';
return SubString(((lastMatchInfo)[1]),c,d);
};
}








var lastMatchInfo=new InternalArray(
2,
"",
void 0,
0,
0
);





var lastMatchInfoOverride=null;



function SetUpRegExp(){
%CheckIsBootstrapping();
%FunctionSetInstanceClassName($RegExp,'RegExp');
%SetProperty($RegExp.prototype,'constructor',$RegExp,2);
%SetCode($RegExp,RegExpConstructor);

InstallFunctions($RegExp.prototype,2,$Array(
"exec",RegExpExec,
"test",RegExpTest,
"toString",RegExpToString,
"compile",RegExpCompile
));


%FunctionSetLength($RegExp.prototype.compile,1);




var a=function(){
var b=((lastMatchInfo)[2]);
return(typeof(b)==='undefined')?"":b;
};
var c=function(d){
((lastMatchInfo)[2])=ToString(d);
};

%OptimizeObjectForAddingMultipleProperties($RegExp,22);
%DefineOrRedefineAccessorProperty($RegExp,'input',a,
c,4);
%DefineOrRedefineAccessorProperty($RegExp,'$_',a,
c,2|4);
%DefineOrRedefineAccessorProperty($RegExp,'$input',a,
c,2|4);









var g=false;
var h=function(){return g;};
var i=function(j){g=j?true:false;};

%DefineOrRedefineAccessorProperty($RegExp,'multiline',h,
i,4);
%DefineOrRedefineAccessorProperty($RegExp,'$*',h,
i,
2|4);


var k=function(l){};



%DefineOrRedefineAccessorProperty($RegExp,'lastMatch',RegExpGetLastMatch,
k,4);
%DefineOrRedefineAccessorProperty($RegExp,'$&',RegExpGetLastMatch,
k,2|4);
%DefineOrRedefineAccessorProperty($RegExp,'lastParen',RegExpGetLastParen,
k,4);
%DefineOrRedefineAccessorProperty($RegExp,'$+',RegExpGetLastParen,
k,2|4);
%DefineOrRedefineAccessorProperty($RegExp,'leftContext',
RegExpGetLeftContext,k,
4);
%DefineOrRedefineAccessorProperty($RegExp,'$`',RegExpGetLeftContext,
k,2|4);
%DefineOrRedefineAccessorProperty($RegExp,'rightContext',
RegExpGetRightContext,k,
4);
%DefineOrRedefineAccessorProperty($RegExp,"$'",RegExpGetRightContext,
k,2|4);

for(var m=1;m<10;++m){
%DefineOrRedefineAccessorProperty($RegExp,'$'+m,
RegExpMakeCaptureGetter(m),k,
4);
}
%ToFastProperties($RegExp);
}

SetUpRegExp();

GCC: (GNU) 4.8.5 20150623 (Red Hat 4.8.5-44)zRx�0 D�A�[
D0h|��k���-`�	
G�� �'.�|����kb libraries.cc_ZN2v88internalL11raw_sourcesE_ZN2v88internalL7sourcesE_ZN2v88internal17NativesCollectionILNS0_10NativeTypeE0EE16GetBuiltinsCountEv_ZN2v88internal17NativesCollectionILNS0_10NativeTypeE0EE16GetDebuggerCountEv_ZN2v88internal17NativesCollectionILNS0_10NativeTypeE0EE8GetIndexEPKcstrcmp_ZN2v88internal17NativesCollectionILNS0_10NativeTypeE0EE17GetRawScriptsSizeEv_ZN2v88internal17NativesCollectionILNS0_10NativeTypeE0EE18GetRawScriptSourceEi_ZN2v88internal17NativesCollectionILNS0_10NativeTypeE0EE13GetScriptNameEi_ZN2v88internal17NativesCollectionILNS0_10NativeTypeE0EE16GetScriptsSourceEv_ZN2v88internal17NativesCollectionILNS0_10NativeTypeE0EE19SetRawScriptsSourceENS0_6VectorIKcEE*
H
f

�
�
�
(�
.�
5
9��������(
>0��������D
GL��������`
Rh��������|
W����������
\���������L
cc��������{���������������������������������������������������������������������+��������C��������[��������s�����������������
c
BA
dQ
ta
�q
��
��
��
��
3�
��
��
��

$
#�������� 4H l������� .symtab.strtab.shstrtab.rela.text.rela.data.bss.rodata.str1.1.rodata.comment.note.GNU-stack.rela.eh_frame @(@���+h&@ذ1p62pSE�`� M0@�.Vn�kp��f@��
8��
	0����u/0              1707480340  0     0     100644  10152     `
ELF>�#@@��f.�1�Ðf�f.�H����H�������)�����t%H�ֿ������)��������������v�f.���t1҃��t��fDH����H�f��H��fD��t$����HE¹�HE��@��Ðf�f.���vÐ@H�=�proxycollectionnative proxy.jsnative collection.js


























"use strict";

global.Proxy=new $Object();

var $Proxy=global.Proxy

$Proxy.create=function(a,b){
if(!(%_IsSpecObject(a)))
throw MakeTypeError("handler_non_object",["create"])
if((typeof(b)==='undefined'))
b=null
else if(!((%_IsSpecObject(b))||b===null))
throw MakeTypeError("proto_non_object",["create"])
return %CreateJSProxy(a,b)
}

$Proxy.createFunction=function(a,b,c){
if(!(%_IsSpecObject(a)))
throw MakeTypeError("handler_non_object",["create"])
if(!(%_ClassOf(b)==='Function'))
throw MakeTypeError("trap_function_expected",["createFunction","call"])
if((typeof(c)==='undefined')){
c=DerivedConstructTrap(b)
}else if((%_ClassOf(c)==='Function')){

var d=c
c=function(){
return %Apply(d,void 0,arguments,0,%_ArgumentsLength());
}
}else{
throw MakeTypeError("trap_function_expected",
["createFunction","construct"])
}
return %CreateJSFunctionProxy(
a,b,c,$Function.prototype)
}







function DerivedConstructTrap(a){
return function(){
var b=this.prototype
if(!(%_IsSpecObject(b)))b=$Object.prototype
var c=new $Object()
c.__proto__=b
var d=%Apply(a,c,arguments,0,%_ArgumentsLength());
return(%_IsSpecObject(d))?d:c
}
}

function DelegateCallAndConstruct(a,b){
return function(){
return %Apply(%_IsConstructCall()?b:a,
this,arguments,0,%_ArgumentsLength())
}
}

function DerivedGetTrap(a,b){
var c=this.getPropertyDescriptor(b)
if((typeof(c)==='undefined')){return c}
if('value'in c){
return c.value
}else{
if((typeof(c.get)==='undefined')){return c.get}

return %_CallFunction(a,c.get)
}
}

function DerivedSetTrap(a,b,c){
var d=this.getOwnPropertyDescriptor(b)
if(d){
if('writable'in d){
if(d.writable){
d.value=c
this.defineProperty(b,d)
return true
}else{
return false
}
}else{
if(d.set){

%_CallFunction(a,c,d.set)
return true
}else{
return false
}
}
}
d=this.getPropertyDescriptor(b)
if(d){
if('writable'in d){
if(d.writable){

}else{
return false
}
}else{
if(d.set){

%_CallFunction(a,c,d.set)
return true
}else{
return false
}
}
}
this.defineProperty(b,{
value:c,
writable:true,
enumerable:true,
configurable:true});
return true;
}

function DerivedHasTrap(a){
return!!this.getPropertyDescriptor(a)
}

function DerivedHasOwnTrap(a){
return!!this.getOwnPropertyDescriptor(a)
}

function DerivedKeysTrap(){
var a=this.getOwnPropertyNames()
var b=[]
for(var c=0,count=0;c<a.length;++c){
var d=a[c]
var e=this.getOwnPropertyDescriptor(((typeof(%IS_VAR(d))==='string')?d:NonStringToString(d)))
if(!(typeof(e)==='undefined')&&e.enumerable){
b[count++]=a[c]
}
}
return b
}

function DerivedEnumerateTrap(){
var a=this.getPropertyNames()
var b=[]
for(var c=0,count=0;c<a.length;++c){
var d=a[c]
var e=this.getPropertyDescriptor(((typeof(%IS_VAR(d))==='string')?d:NonStringToString(d)))
if(!(typeof(e)==='undefined')&&e.enumerable){
b[count++]=a[c]
}
}
return b
}

function ProxyEnumerate(a){
var b=%GetHandler(a)
if((typeof(b.enumerate)==='undefined')){
return %Apply(DerivedEnumerateTrap,b,[],0,0)
}else{
return ToStringArray(b.enumerate(),"enumerate")
}
}




























"use strict";

var $Set=global.Set;
var $Map=global.Map;
var $WeakMap=global.WeakMap;





var undefined_sentinel={};


function SetConstructor(){
if(%_IsConstructCall()){
%SetInitialize(this);
}else{
return new $Set();
}
}


function SetAdd(a){
if(!(%_ClassOf(this)==='Set')){
throw MakeTypeError('incompatible_method_receiver',
['Set.prototype.add',this]);
}
if((typeof(a)==='undefined')){
a=undefined_sentinel;
}
return %SetAdd(this,a);
}


function SetHas(a){
if(!(%_ClassOf(this)==='Set')){
throw MakeTypeError('incompatible_method_receiver',
['Set.prototype.has',this]);
}
if((typeof(a)==='undefined')){
a=undefined_sentinel;
}
return %SetHas(this,a);
}


function SetDelete(a){
if(!(%_ClassOf(this)==='Set')){
throw MakeTypeError('incompatible_method_receiver',
['Set.prototype.delete',this]);
}
if((typeof(a)==='undefined')){
a=undefined_sentinel;
}
if(%SetHas(this,a)){
%SetDelete(this,a);
return true;
}else{
return false;
}
}


function MapConstructor(){
if(%_IsConstructCall()){
%MapInitialize(this);
}else{
return new $Map();
}
}


function MapGet(a){
if(!(%_ClassOf(this)==='Map')){
throw MakeTypeError('incompatible_method_receiver',
['Map.prototype.get',this]);
}
if((typeof(a)==='undefined')){
a=undefined_sentinel;
}
return %MapGet(this,a);
}


function MapSet(a,b){
if(!(%_ClassOf(this)==='Map')){
throw MakeTypeError('incompatible_method_receiver',
['Map.prototype.set',this]);
}
if((typeof(a)==='undefined')){
a=undefined_sentinel;
}
return %MapSet(this,a,b);
}


function MapHas(a){
if(!(%_ClassOf(this)==='Map')){
throw MakeTypeError('incompatible_method_receiver',
['Map.prototype.has',this]);
}
if((typeof(a)==='undefined')){
a=undefined_sentinel;
}
return %MapHas(this,a);
}


function MapDelete(a){
if(!(%_ClassOf(this)==='Map')){
throw MakeTypeError('incompatible_method_receiver',
['Map.prototype.delete',this]);
}
if((typeof(a)==='undefined')){
a=undefined_sentinel;
}
return %MapDelete(this,a);
}


function WeakMapConstructor(){
if(%_IsConstructCall()){
%WeakMapInitialize(this);
}else{
return new $WeakMap();
}
}


function WeakMapGet(a){
if(!(%_ClassOf(this)==='WeakMap')){
throw MakeTypeError('incompatible_method_receiver',
['WeakMap.prototype.get',this]);
}
if(!(%_IsSpecObject(a))){
throw %MakeTypeError('invalid_weakmap_key',[this,a]);
}
return %WeakMapGet(this,a);
}


function WeakMapSet(a,b){
if(!(%_ClassOf(this)==='WeakMap')){
throw MakeTypeError('incompatible_method_receiver',
['WeakMap.prototype.set',this]);
}
if(!(%_IsSpecObject(a))){
throw %MakeTypeError('invalid_weakmap_key',[this,a]);
}
return %WeakMapSet(this,a,b);
}


function WeakMapHas(a){
if(!(%_ClassOf(this)==='WeakMap')){
throw MakeTypeError('incompatible_method_receiver',
['WeakMap.prototype.has',this]);
}
if(!(%_IsSpecObject(a))){
throw %MakeTypeError('invalid_weakmap_key',[this,a]);
}
return %WeakMapHas(this,a);
}


function WeakMapDelete(a){
if(!(%_ClassOf(this)==='WeakMap')){
throw MakeTypeError('incompatible_method_receiver',
['WeakMap.prototype.delete',this]);
}
if(!(%_IsSpecObject(a))){
throw %MakeTypeError('invalid_weakmap_key',[this,a]);
}
return %WeakMapDelete(this,a);
}



(function(){
%CheckIsBootstrapping();


%SetCode($Set,SetConstructor);
%SetCode($Map,MapConstructor);


%SetProperty($Set.prototype,"constructor",$Set,2);
%SetProperty($Map.prototype,"constructor",$Map,2);


InstallFunctions($Set.prototype,2,$Array(
"add",SetAdd,
"has",SetHas,
"delete",SetDelete
));


InstallFunctions($Map.prototype,2,$Array(
"get",MapGet,
"set",MapSet,
"has",MapHas,
"delete",MapDelete
));


%SetCode($WeakMap,WeakMapConstructor);


%SetProperty($WeakMap.prototype,"constructor",$WeakMap,2);


InstallFunctions($WeakMap.prototype,2,$Array(
"get",WeakMapGet,
"set",WeakMapSet,
"has",WeakMapHas,
"delete",WeakMapDelete
));
})();

GCC: (GNU) 4.8.5 20150623 (Red Hat 4.8.5-44)zRx�0DHXl:�3���:v	
T�� H4p��:��3hexperimental-libraries.cc_ZN2v88internalL11raw_sourcesE_ZN2v88internalL7sourcesE_ZN2v88internal17NativesCollectionILNS0_10NativeTypeE1EE16GetBuiltinsCountEv_ZN2v88internal17NativesCollectionILNS0_10NativeTypeE1EE16GetDebuggerCountEv_ZN2v88internal17NativesCollectionILNS0_10NativeTypeE1EE8GetIndexEPKc_ZN2v88internal17NativesCollectionILNS0_10NativeTypeE1EE17GetRawScriptsSizeEv_ZN2v88internal17NativesCollectionILNS0_10NativeTypeE1EE18GetRawScriptSourceEi_ZN2v88internal17NativesCollectionILNS0_10NativeTypeE1EE13GetScriptNameEi_ZN2v88internal17NativesCollectionILNS0_10NativeTypeE1EE16GetScriptsSourceEv_ZN2v88internal17NativesCollectionILNS0_10NativeTypeE1EE19SetRawScriptsSourceENS0_6VectorIKcEE)
E
�
�������������������
�
"�

�������� 4H \pp�����.symtab.strtab.shstrtab.rela.text.rela.data.bss.rodata.str1.1.rodata.comment.note.GNU-stack.rela.eh_frame @@�!�+X&@�"1`62`7E�v M0.VDkH�f@�"�
�
	��p#u/26             1707480341  0     0     100644  2480      `
ELF>0@@
	GCC: (GNU) 4.8.5 20150623 (Red Hat 4.8.5-44)�Gz��Lx� �$�(*,U0�4��8<%@EiDsnapshot-empty.cc_ZN2v88internal8Snapshot24context_cell_space_used_E_ZN2v88internal8Snapshot23context_map_space_used_E_ZN2v88internal8Snapshot24context_code_space_used_E_ZN2v88internal8Snapshot24context_data_space_used_E_ZN2v88internal8Snapshot27context_pointer_space_used_E_ZN2v88internal8Snapshot23context_new_space_used_E_ZN2v88internal8Snapshot16cell_space_used_E_ZN2v88internal8Snapshot15map_space_used_E_ZN2v88internal8Snapshot16code_space_used_E_ZN2v88internal8Snapshot16data_space_used_E_ZN2v88internal8Snapshot19pointer_space_used_E_ZN2v88internal8Snapshot15new_space_used_E_ZN2v88internal8Snapshot17context_raw_size_E_ZN2v88internal8Snapshot13context_size_E_ZN2v88internal8Snapshot17context_raw_data_E_ZN2v88internal8Snapshot13context_data_E_ZN2v88internal8Snapshot9raw_size_E_ZN2v88internal8Snapshot5size_E_ZN2v88internal8Snapshot9raw_data_E_ZN2v88internal8Snapshot5data_E.symtab.strtab.shstrtab.text.data.bss.rodata.comment.note.GNU-stack@!@'@,@E40�.=���	X��M

Zerion Mini Shell 1.0