Edit C:\Users\Administrator\AppData\Local\Tencent\MiniBrowser\1.0.1118.400\natives_blob.bin
debug? "use strict"; var kDefaultBacktraceLength=10; var Debug={}; var sourceLineBeginningSkip=/^(?:\s*(?:\/\*.*?\*\/)*)*/; Debug.DebugEvent={Break:1, Exception:2, NewFunction:3, BeforeCompile:4, AfterCompile:5, CompileError:6, PromiseEvent:7, AsyncTaskEvent:8, BreakForCommand:9}; Debug.ExceptionBreak={Caught:0, Uncaught:1}; Debug.StepAction={StepOut:0, StepNext:1, StepIn:2, StepMin:3, StepInMin:4, StepFrame:5}; Debug.ScriptType={Native:0, Extension:1, Normal:2}; Debug.ScriptCompilationType={Host:0, Eval:1, JSON:2}; Debug.ScriptBreakPointType={ScriptId:0, ScriptName:1, ScriptRegExp:2}; Debug.BreakPositionAlignment={ Statement:0, BreakPosition:1 }; 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(); } } }, }; 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,opt_position_alignment){ 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.position_alignment_=(opt_position_alignment===(void 0)) ?Debug.BreakPositionAlignment.Statement:opt_position_alignment; 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_, this.position_alignment_); 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((b===(void 0))){ var d=a.sourceLine(this.line()); if(!a.sourceColumnStart_){ a.sourceColumnStart_=new Array(a.lineCount()); } if((a.sourceColumnStart_[c]===(void 0))){ a.sourceColumnStart_[c]= d.match(sourceLineBeginningSkip)[0].length; } b=a.sourceColumnStart_[c]; } var e=Debug.findScriptSourcePosition(a,this.line(),b); if((e===null))return; var f=MakeBreakPoint(e,this); f.setIgnoreCount(this.ignoreCount()); var g=%SetScriptBreakPoint(a,e, this.position_alignment_, f); if((g===(void 0))){ g=e; } var h=a.locationFromPosition(g,true); f.actual_location={line:h.line, column:h.column, script_id:a.id}; this.break_points_.push(f); return f; }; 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))&&!(a===(void 0))&&!(a===null)){ throw new Error('Parameters have wrong types.'); } %SetDebugEventListener(a,b); }; Debug.breakLocations=function(a,b){ if(!(%_IsFunction(a)))throw new Error('Parameters have wrong types.'); var c=(b===(void 0)) ?Debug.BreakPositionAlignment.Statement:b; return %GetBreakLocations(a,c); }; 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 e in b){ var g=b[e]; if(a.test(g.name)){ c=g; 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.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 e=%FunctionGetScriptSourcePosition(a); return d.locationFromLine(b,c,e); }; 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 e= this.findFunctionSourceLocation(a,b,c).position; var g=e-this.sourcePosition(a); var h=%FunctionGetScript(a); if(h.type==Debug.ScriptType.Native){ throw new Error('Cannot set break point in native code.'); } if(h&&h.id){ g+=%FunctionGetScriptSourcePosition(a); var i=h.locationFromPosition(g,false); return this.setScriptBreakPointById(h.id, i.line,i.column, d); }else{ var j=MakeBreakPoint(g); var k= %SetFunctionBreakPoint(a,g,j); k+=this.sourcePosition(a); var l=h.locationFromPosition(k,true); j.actual_location={line:l.line, column:l.column, script_id:h.id}; j.setCondition(d); return j.number(); } }; Debug.setBreakPointByScriptIdAndPosition=function(script_id,position, condition,enabled, opt_position_alignment) { var a=MakeBreakPoint(position); a.setCondition(condition); if(!enabled){ a.disable(); } var b=this.scripts(); var c=(opt_position_alignment===(void 0)) ?Debug.BreakPositionAlignment.Statement:opt_position_alignment; for(var d=0;d<b.length;d++){ if(script_id==b[d].id){ a.actual_position=%SetScriptBreakPoint(b[d],position, c,a); break; } } return a; }; 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++){ var b=break_points[a]; %ClearBreakPoint(b); } 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,opt_position_alignment){ var a= new ScriptBreakPoint(type,script_id_or_name,opt_line,opt_column, opt_groupId,opt_position_alignment); 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, opt_position_alignment){ return this.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptId, script_id,opt_line,opt_column, opt_condition,opt_groupId, opt_position_alignment); }; 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,c){ if(!(%_IsFunction(a)))throw new Error('Parameters have wrong types.'); var d=b?this.scriptSource(a):this.source(a); var e=b?this.sourcePosition(a):0; var g=this.breakLocations(a,c); if(!g)return d; 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]-e; j+=d.slice(k,l); j+="[B"+m+"]"; k=l; } l=d.length; j+=d.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(opt_action,opt_count, opt_callframe){ var a=Debug.StepAction.StepIn; if(!(opt_action===(void 0)))a=%ToNumber(opt_action); var b=opt_count?%ToNumber(opt_count):1; var c=0; if(!(opt_callframe===(void 0))){ c=opt_callframe.details_.frameId(); } return %PrepareStep(this.break_id,a,b,c); }; 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.frame_=new FrameMirror(a,0); this.break_points_hit_=b; } BreakEvent.prototype.eventType=function(){ return Debug.DebugEvent.Break; }; BreakEvent.prototype.func=function(){ return this.frame_.func(); }; BreakEvent.prototype.sourceLine=function(){ return this.frame_.sourceLine(); }; BreakEvent.prototype.sourceColumn=function(){ return this.frame_.sourceColumn(); }; BreakEvent.prototype.sourceLineText=function(){ return this.frame_.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.frame_.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 e=d.script_break_point(); var g; if(e){ g=e.number(); }else{ g=d.number(); } a.body.breakpoints.push(g); } } return JSON.stringify(ObjectToProtocolObject_(a)); }; function MakeExceptionEvent(a,b,c,d){ return new ExceptionEvent(a,b,c,d); } function ExceptionEvent(a,b,c,d){ this.exec_state_=new ExecutionState(a); this.exception_=b; this.uncaught_=c; this.promise_=d; } ExceptionEvent.prototype.eventType=function(){ return Debug.DebugEvent.Exception; }; ExceptionEvent.prototype.exception=function(){ return this.exception_; }; ExceptionEvent.prototype.uncaught=function(){ return this.uncaught_; }; ExceptionEvent.prototype.promise=function(){ return this.promise_; }; 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){ return new CompileEvent(a,b); } function CompileEvent(a,b){ this.script_=MakeMirror(a); this.type_=b; } CompileEvent.prototype.eventType=function(){ return this.type_; }; CompileEvent.prototype.script=function(){ return this.script_; }; CompileEvent.prototype.toJSONProtocol=function(){ var a=new ProtocolMessage(); a.running=true; switch(this.type_){ case Debug.DebugEvent.BeforeCompile: a.event="beforeCompile"; break; case Debug.DebugEvent.AfterCompile: a.event="afterCompile"; break; case Debug.DebugEvent.CompileError: a.event="compileError"; break; } a.body={}; a.body.script=this.script_; 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(!(a.data()===(void 0))){ c.data=a.data(); } if(b){ c.source=a.source(); } return c; } function MakePromiseEvent(a){ return new PromiseEvent(a); } function PromiseEvent(a){ this.promise_=a.promise; this.parentPromise_=a.parentPromise; this.status_=a.status; this.value_=a.value; } PromiseEvent.prototype.promise=function(){ return MakeMirror(this.promise_); } PromiseEvent.prototype.parentPromise=function(){ return MakeMirror(this.parentPromise_); } PromiseEvent.prototype.status=function(){ return this.status_; } PromiseEvent.prototype.value=function(){ return MakeMirror(this.value_); } function MakeAsyncTaskEvent(a){ return new AsyncTaskEvent(a); } function AsyncTaskEvent(a){ this.type_=a.type; this.name_=a.name; this.id_=a.id; } AsyncTaskEvent.prototype.type=function(){ return this.type_; } AsyncTaskEvent.prototype.name=function(){ return this.name_; } AsyncTaskEvent.prototype.id=function(){ return this.id_; } 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,b){ this.success=false; this.message=a; if((%_IsObject(b))){ this.error_details=b; } }; 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; } if(this.error_details){ a.error_details=this.error_details; } 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(!(c.maxStringLength===(void 0))){ b.setOption('maxStringLength',c.maxStringLength); } } var d=a.command.toLowerCase(); var e=DebugCommandProcessor.prototype.dispatch_[d]; if((%_IsFunction(e))){ %_CallFunction(this,a,b,e); }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(!(b.running===(void 0))){ 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 e=a.arguments.stepaction; var g=a.arguments.stepcount; if(g){ c=%ToNumber(g); if(c<0){ throw new Error('Invalid stepcount argument "'+g+'".'); } } if(e){ if(e=='in'){ d=Debug.StepAction.StepIn; }else if(e=='min'){ d=Debug.StepAction.StepMin; }else if(e=='next'){ d=Debug.StepAction.StepNext; }else if(e=='out'){ d=Debug.StepAction.StepOut; }else{ throw new Error('Invalid stepaction argument "'+e+'".'); } } 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 e=a.arguments.line; var g=a.arguments.column; var h=(a.arguments.enabled===(void 0))? true:a.arguments.enabled; var i=a.arguments.condition; var j=a.arguments.ignoreCount; var k=a.arguments.groupId; if(!c||(d===(void 0))){ b.failed('Missing argument "type" or "target"'); return; } var l; if(c=='function'){ if(!(typeof(d)==='string')){ b.failed('Argument "target" is not a string value'); return; } var m; try{ m=this.exec_state_.evaluateGlobal(d).value(); }catch(e){ b.failed('Error: "'+%ToString(e)+ '" evaluating "'+d+'"'); return; } if(!(%_IsFunction(m))){ b.failed('"'+d+'" does not evaluate to a function'); return; } l=Debug.setBreakPoint(m,e,g,i); }else if(c=='handle'){ var n=parseInt(d,10); var o=LookupMirror(n); if(!o){ return b.failed('Object #'+n+'# not found'); } if(!o.isFunction()){ return b.failed('Object #'+n+'# is not a function'); } l=Debug.setBreakPoint(o.value(), e,g,i); }else if(c=='script'){ l= Debug.setScriptBreakPointByName(d,e,g,i, k); }else if(c=='scriptId'){ l= Debug.setScriptBreakPointById(d,e,g,i,k); }else if(c=='scriptRegExp'){ l= Debug.setScriptBreakPointByRegExp(d,e,g,i, k); }else{ b.failed('Illegal type "'+c+'"'); return; } var p=Debug.findBreakPoint(l); if(j){ Debug.changeBreakPointIgnoreCount(l,j); } if(!h){ Debug.disableBreakPoint(l); } b.body={type:c, breakpoint:l}; if(p instanceof ScriptBreakPoint){ if(p.type()==Debug.ScriptBreakPointType.ScriptId){ b.body.type='scriptId'; b.body.script_id=p.script_id(); }else if(p.type()==Debug.ScriptBreakPointType.ScriptName){ b.body.type='scriptName'; b.body.script_name=p.script_name(); }else if(p.type()==Debug.ScriptBreakPointType.ScriptRegExp){ b.body.type='scriptRegExp'; b.body.script_regexp=p.script_regexp_object().source; }else{ throw new Error("Internal error: Unexpected breakpoint type: "+ p.type()); } b.body.line=p.line(); b.body.column=p.column(); b.body.actual_locations=p.actual_locations(); }else{ b.body.type='function'; b.body.actual_locations=[p.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(!(b===(void 0))){ if(b){ Debug.enableBreakPoint(a); }else{ Debug.disableBreakPoint(a); } } if(!(c===(void 0))){ Debug.changeBreakPointCondition(a,c); } if(!(d===(void 0))){ 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 e=script_break_points[d]; if(e.groupId()==a){ b.push(e.number()); e.clear(); }else{ c.push(e); } } 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(!(a.arguments.enabled===(void 0))){ 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 e='Invalid frame range'; return response.failed(e); } var g=[]; for(var h=b;h<c;h++){ g.push(this.exec_state_.frame(h)); } response.body={ fromFrame:b, toFrame:c, totalFrames:a, frames:g }; }; 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.resolveFrameFromScopeDescription_= function(a){ if(a&&!(a.frameNumber===(void 0))){ var b=a.frameNumber; if(b<0||this.exec_state_.frameCount()<=b){ throw new Error('Invalid frame number'); } return this.exec_state_.frame(b); }else{ return this.exec_state_.frame(); } }; DebugCommandProcessor.prototype.resolveScopeHolder_= function(a){ if(a&&"functionHandle"in a){ if(!(typeof(a.functionHandle)==='number')){ throw new Error('Function handle must be a number'); } var b=LookupMirror(a.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.resolveFrameFromScopeDescription_(a); return c; } } DebugCommandProcessor.prototype.scopesRequest_=function(a,b){ var c=this.resolveScopeHolder_(a.arguments); var d=c.scopeCount(); var e=[]; for(var g=0;g<d;g++){ e.push(c.scope(g)); } b.body={ fromScope:0, toScope:d, totalScopes:d, scopes:e }; }; DebugCommandProcessor.prototype.scopeRequest_=function(a,b){ var c=this.resolveScopeHolder_(a.arguments); var d=0; if(a.arguments&&!(a.arguments.number===(void 0))){ d=%ToNumber(a.arguments.number); if(d<0||c.scopeCount()<=d){ return b.failed('Invalid scope number'); } } b.body=c.scope(d); }; DebugCommandProcessor.resolveValue_=function(a){ if("handle"in a){ var b=LookupMirror(a.handle); if(!b){ throw new Error("Failed to resolve value by handle, ' #"+ a.handle+"# not found"); } return b.value(); }else if("stringDescription"in a){ if(a.type==BOOLEAN_TYPE){ return Boolean(a.stringDescription); }else if(a.type==NUMBER_TYPE){ return Number(a.stringDescription); }if(a.type==STRING_TYPE){ return String(a.stringDescription); }else{ throw new Error("Unknown type"); } }else if("value"in a){ return a.value; }else if(a.type==UNDEFINED_TYPE){ return(void 0); }else if(a.type==NULL_TYPE){ return null; }else{ throw new Error("Failed to parse value description"); } }; DebugCommandProcessor.prototype.setVariableValueRequest_= function(a,b){ if(!a.arguments){ b.failed('Missing arguments'); return; } if((a.arguments.name===(void 0))){ b.failed('Missing variable name'); } var c=a.arguments.name; var d=a.arguments.scope; var e=this.resolveScopeHolder_(d); if((d.number===(void 0))){ b.failed('Missing scope number'); } var g=%ToNumber(d.number); var h=e.scope(g); var i= DebugCommandProcessor.resolveValue_(a.arguments.newValue); h.setVariableValue(c,i); var j=MakeMirror(i); b.body={ newValue:j }; }; 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 e=a.arguments.global; var g=a.arguments.disable_break; var h=a.arguments.additional_context; try{ c=String(c); }catch(e){ return b.failed('Failed to convert expression argument to string'); } if(!(d===(void 0))&&e){ return b.failed('Arguments "frame" and "global" are exclusive'); } var i; if(h){ i={}; for(var j=0;j<h.length;j++){ var k=h[j]; if(!(typeof(k.name)==='string')){ return b.failed("Context element #"+j+ " doesn't contain name:string property"); } var l=DebugCommandProcessor.resolveValue_(k); i[k.name]=l; } } if(e){ b.body=this.exec_state_.evaluateGlobal( c,Boolean(g),i); return; } if((g===(void 0))){ g=true; } if(this.exec_state_.frameCount()==0){ return b.failed('No frames'); } if(!(d===(void 0))){ var m=%ToNumber(d); if(m<0||m>=this.exec_state_.frameCount()){ return b.failed('Invalid frame "'+d+'"'); } b.body=this.exec_state_.frame(m).evaluate( c,Boolean(g),i); return; }else{ b.body=this.exec_state_.frame().evaluate( c,Boolean(g),i); return; } }; DebugCommandProcessor.prototype.lookupRequest_=function(a,b){ if(!a.arguments){ return b.failed('Missing arguments'); } var c=a.arguments.handles; if((c===(void 0))){ return b.failed('Argument "handles" missing'); } if(!(a.arguments.includeSource===(void 0))){ var d=%ToBoolean(a.arguments.includeSource); b.setOption('includeSource',d); } var e={}; 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'); } e[h]=i; } b.body=e; }; 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((c===(void 0))){ return b.failed('Argument "type" missing'); } if((d===(void 0))){ return b.failed('Argument "handle" missing'); } if(c!='referencedBy'&&c!='constructedBy'){ return b.failed('Invalid type "'+c+'"'); } var e=LookupMirror(d); if(e){ if(c=='referencedBy'){ b.body=e.referencedBy(); }else{ b.body=e.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 e=this.exec_state_.frame(); if(a.arguments){ c=a.arguments.fromLine; d=a.arguments.toLine; if(!(a.arguments.frame===(void 0))){ var g=%ToNumber(a.arguments.frame); if(g<0||g>=this.exec_state_.frameCount()){ return b.failed('Invalid frame "'+e+'"'); } e=this.exec_state_.frame(g); } } var h=e.func().script(); if(!h){ return b.failed('No source'); } var i=h.sourceSlice(c,d); if(!i){ return b.failed('Invalid line interval'); } b.body={}; b.body.source=i.sourceText(); b.body.fromLine=i.from_line; b.body.toLine=i.to_line; b.body.fromPosition=i.from_position; b.body.toPosition=i.to_position; b.body.totalLines=h.lineCount(); }; DebugCommandProcessor.prototype.scriptsRequest_=function(a,b){ var c=ScriptTypeFlag(Debug.ScriptType.Normal); var d=false; var e=null; if(a.arguments){ if(!(a.arguments.types===(void 0))){ c=%ToNumber(a.arguments.types); if(isNaN(c)||c<0){ return b.failed('Invalid types "'+ a.arguments.types+'"'); } } if(!(a.arguments.includeSource===(void 0))){ d=%ToBoolean(a.arguments.includeSource); b.setOption('includeSource',d); } if((%_IsArray(a.arguments.ids))){ e={}; var g=a.arguments.ids; for(var h=0;h<g.length;h++){ e[g[h]]=true; } } var i=null; var j=null; if(!(a.arguments.filter===(void 0))){ var k=%ToNumber(a.arguments.filter); if(!isNaN(k)){ j=k; } i=a.arguments.filter; } } var l=%DebugGetLoadedScripts(); b.body=[]; for(var h=0;h<l.length;h++){ if(e&&!e[l[h].id]){ continue; } if(i||j){ var m=l[h]; var n=false; if(j&&!n){ if(m.id&&m.id===j){ n=true; } } if(i&&!n){ if(m.name&&m.name.indexOf(i)>=0){ n=true; } } if(!n)continue; } if(c&ScriptTypeFlag(l[h].type)){ b.body.push(MakeMirror(l[h])); } } }; DebugCommandProcessor.prototype.threadsRequest_=function(a,b){ var c=this.exec_state_.threadCount(); var d=[]; for(var e=0;e<c;e++){ var g=%GetThreadDetails(this.exec_state_.break_id,e); var h={current:g[0], id:g[1] }; d.push(h); } 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.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 e=0;e<c.length;e++){ if(c[e].id==a){ d=c[e]; } } if(!d){ response.failed('Script not found'); return; } var g=new Array(); if(!(typeof(request.arguments.new_source)==='string')){ throw"new_source argument expected"; } var h=request.arguments.new_source; var i; try{ i=Debug.LiveEdit.SetScriptSource(d, h,b,g); }catch(e){ if(e instanceof Debug.LiveEdit.Failure&&"details"in e){ response.failed(e.message,e.details); return; } throw e; } response.body={change_log:g,result:i}; if(!b&&!this.running_&&i.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(!(a===(void 0))){ 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(!(a===(void 0))){ 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 e=debugger_flags[c].getValue(); response.body.flags.push({name:c,value:e}); } } }; 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 e=%GetHeapUsage(); b.body={"before":d,"after":e}; }; DebugCommandProcessor.prototype.dispatch_=(function(){ var a=DebugCommandProcessor.prototype; return{ "continue":a.continueRequest_, "break":a.breakRequest_, "setbreakpoint":a.setBreakPointRequest_, "changebreakpoint":a.changeBreakPointRequest_, "clearbreakpoint":a.clearBreakPointRequest_, "clearbreakpointgroup":a.clearBreakPointGroupRequest_, "disconnect":a.disconnectRequest_, "setexceptionbreak":a.setExceptionBreakRequest_, "listbreakpoints":a.listBreakpointsRequest_, "backtrace":a.backtraceRequest_, "frame":a.frameRequest_, "scopes":a.scopesRequest_, "scope":a.scopeRequest_, "setvariablevalue":a.setVariableValueRequest_, "evaluate":a.evaluateRequest_, "lookup":a.lookupRequest_, "references":a.referencesRequest_, "source":a.sourceRequest_, "scripts":a.scriptsRequest_, "threads":a.threadsRequest_, "suspend":a.suspendRequest_, "version":a.versionRequest_, "changelive":a.changeLiveRequest_, "restartframe":a.restartFrameRequest_, "flags":a.debuggerFlagsRequest_, "v8flag":a.v8FlagsRequest_, "gc":a.gcRequest_, }; })(); DebugCommandProcessor.prototype.isRunning=function(){ return this.running_; }; DebugCommandProcessor.prototype.systemBreak=function(a,b){ return %SystemBreak(); }; function ObjectToProtocolObject_(a,b){ var c={}; for(var d in a){ if(typeof d=='string'){ var e=ValueToProtocolValue_(a[d], b); if(!(e===(void 0))){ c[d]=e; } } } 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; } mirrorr? "use strict"; var next_handle_=0; var next_transient_handle_=-1; var mirror_cache_=[]; var mirror_cache_enabled_=true; function ToggleMirrorCache(a){ mirror_cache_enabled_=a; next_handle_=0; mirror_cache_=[]; } function ObjectIsPromise(a){ try{ return(%_IsSpecObject(a))&& !(%DebugGetProperty(a,builtins.promiseStatus)===(void 0)); }catch(e){ return false; } } function MakeMirror(a,b){ var c; if(!b&&mirror_cache_enabled_){ for(var d in mirror_cache_){ c=mirror_cache_[d]; if(c.value()===a){ return c; } if(c.isNumber()&&isNaN(c.value())&& typeof a=='number'&&isNaN(a)){ return c; } } } if((a===(void 0))){ 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((typeof(a)==='symbol')){ c=new SymbolMirror(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 if((%_ClassOf(a)==='Map')||(%_ClassOf(a)==='WeakMap')){ c=new MapMirror(a); }else if((%_ClassOf(a)==='Set')||(%_ClassOf(a)==='WeakSet')){ c=new SetMirror(a); }else if((%_ClassOf(a)==='Map Iterator')||(%_ClassOf(a)==='Set Iterator')){ c=new IteratorMirror(a); }else if(ObjectIsPromise(a)){ c=new PromiseMirror(a); }else if((%_ClassOf(a)==='Generator')){ c=new GeneratorMirror(a); }else{ c=new ObjectMirror(a,OBJECT_TYPE,b); } if(mirror_cache_enabled_)mirror_cache_[c.handle()]=c; return c; } function LookupMirror(a){ if(!mirror_cache_enabled_)throw new Error("Mirror cache is disabled"); 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 SYMBOL_TYPE='symbol'; 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 PROMISE_TYPE='promise'; var MAP_TYPE='map'; var SET_TYPE='set'; var ITERATOR_TYPE='iterator'; var GENERATOR_TYPE='generator'; var kMaxProtocolStringLength=80; var PropertyKind={}; PropertyKind.Named=1; PropertyKind.Indexed=2; var PropertyType={}; PropertyType.Data=0; PropertyType.DataConstant=2; PropertyType.AccessorConstant=3; 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, Script:6}; 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.isSymbol=function(){ return this instanceof SymbolMirror; }; 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.isPromise=function(){ return this instanceof PromiseMirror; }; Mirror.prototype.isGenerator=function(){ return this instanceof GeneratorMirror; }; 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.isMap=function(){ return this instanceof MapMirror; }; Mirror.prototype.isSet=function(){ return this instanceof SetMirror; }; Mirror.prototype.isIterator=function(){ return this instanceof IteratorMirror; }; Mirror.prototype.allocateHandle_=function(){ if(mirror_cache_enabled_)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'|| a==='symbol'; }; 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 SymbolMirror(a){ %_CallFunction(this,SYMBOL_TYPE,a,ValueMirror); } inherits(SymbolMirror,ValueMirror); SymbolMirror.prototype.description=function(){ return %SymbolDescription(%_ValueOf(this.value_)); } SymbolMirror.prototype.toText=function(){ return %_CallFunction(this.value_,builtins.$symbolToString); } 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; }; function TryGetPropertyNames(a){ try{ return %GetOwnPropertyNames(a,32); }catch(e){ return[]; } } ObjectMirror.prototype.propertyNames=function(a,b){ a=a||PropertyKind.Named|PropertyKind.Indexed; var c; var d; var e=0; if(a&PropertyKind.Named){ c=TryGetPropertyNames(this.value_); e+=c.length; if(this.hasNamedInterceptor()&&(a&PropertyKind.Named)){ var g= %GetNamedInterceptorPropertyNames(this.value_); if(g){ c=c.concat(g); e+=g.length; } } } if(a&PropertyKind.Indexed){ d=%GetOwnElementNames(this.value_); e+=d.length; if(this.hasIndexedInterceptor()&&(a&PropertyKind.Indexed)){ var h= %GetIndexedInterceptorElementNames(this.value_); if(h){ d=d.concat(h); e+=h.length; } } } b=Math.min(b||e,e); var i=new Array(b); var j=0; if(a&PropertyKind.Named){ for(var k=0;j<b&&k<c.length;k++){ i[j++]=c[k]; } } if(a&PropertyKind.Indexed){ for(var k=0;j<b&&k<d.length;k++){ i[j++]=d[k]; } } return i; }; ObjectMirror.prototype.properties=function(a,b){ var c=this.propertyNames(a,b); var d=new Array(c.length); for(var e=0;e<c.length;e++){ d[e]=this.property(c[e]); } return d; }; ObjectMirror.prototype.internalProperties=function(){ return ObjectMirror.GetInternalProperties(this.value_); } ObjectMirror.prototype.property=function(a){ var b=%DebugGetPropertyDetails(this.value_,%ToName(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.AccessorConstant){ 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 e=[]; for(var g=2;g<c.length;g++){ e.push(c[g]); } d.push(new InternalPropertyMirror("[[BoundArgs]]",e)); } return d; }else if((%_ClassOf(a)==='Map Iterator')||(%_ClassOf(a)==='Set Iterator')){ var h=(%_ClassOf(a)==='Map Iterator')?%MapIteratorDetails(a) :%SetIteratorDetails(a); var i; switch(h[2]){ case 1:i="keys";break; case 2:i="values";break; case 3:i="entries";break; } var d=[ new InternalPropertyMirror("[[IteratorHasMore]]",h[0]), new InternalPropertyMirror("[[IteratorIndex]]",h[1]) ]; if(i){ d.push(new InternalPropertyMirror("[[IteratorKind]]",i)); } return d; }else if((%_ClassOf(a)==='Generator')){ return[ new InternalPropertyMirror("[[GeneratorStatus]]", GeneratorGetStatus_(a)), new InternalPropertyMirror("[[GeneratorFunction]]", %GeneratorGetFunction(a)), new InternalPropertyMirror("[[GeneratorReceiver]]", %GeneratorGetReceiver(a)) ]; }else if(ObjectIsPromise(a)){ return[ new InternalPropertyMirror("[[PromiseStatus]]",PromiseGetStatus_(a)), new InternalPropertyMirror("[[PromiseValue]]",PromiseGetValue_(a)) ]; } 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()){ if(this.script_){ return this.script_; } var a=%FunctionGetScript(this.value_); if(a){ return this.script_=MakeMirror(a); } } }; FunctionMirror.prototype.sourcePosition_=function(){ if(this.resolved()){ return %FunctionGetScriptSourcePosition(this.value_); } }; FunctionMirror.prototype.sourceLocation=function(){ if(this.resolved()){ var a=this.script(); if(a){ return a.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()){ if((this.scopeCount_===(void 0))){ this.scopeCount_=%GetFunctionScopeCount(this.value()); } return this.scopeCount_; }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 e=%DebugGetPropertyDetails(this.value_,%ToString(d)); var g; if(e){ g=new PropertyMirror(this,d,e); }else{ g=GetUndefinedMirror(); } c[d-a]=g; } 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.sticky=function(){ return this.value_.sticky; }; RegExpMirror.prototype.unicode=function(){ return this.value_.unicode; }; 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{ a=%_CallFunction(this.value_,builtins.ErrorToString); }catch(e){ a='#<Error>'; } return a; }; function PromiseMirror(a){ %_CallFunction(this,a,PROMISE_TYPE,ObjectMirror); } inherits(PromiseMirror,ObjectMirror); function PromiseGetStatus_(a){ var b=%DebugGetProperty(a,builtins.promiseStatus); if(b==0)return"pending"; if(b==1)return"resolved"; return"rejected"; } function PromiseGetValue_(a){ return %DebugGetProperty(a,builtins.promiseValue); } PromiseMirror.prototype.status=function(){ return PromiseGetStatus_(this.value_); }; PromiseMirror.prototype.promiseValue=function(){ return MakeMirror(PromiseGetValue_(this.value_)); }; function MapMirror(a){ %_CallFunction(this,a,MAP_TYPE,ObjectMirror); } inherits(MapMirror,ObjectMirror); MapMirror.prototype.entries=function(a){ var b=[]; if((%_ClassOf(this.value_)==='WeakMap')){ var c=%GetWeakMapEntries(this.value_,a||0); for(var d=0;d<c.length;d+=2){ b.push({ key:c[d], value:c[d+1] }); } return b; } var e=%_CallFunction(this.value_,builtins.MapEntries); var g; while((!a||b.length<a)&& !(g=e.next()).done){ b.push({ key:g.value[0], value:g.value[1] }); } return b; }; function SetMirror(a){ %_CallFunction(this,a,SET_TYPE,ObjectMirror); } inherits(SetMirror,ObjectMirror); function IteratorGetValues_(a,b,c){ var d=[]; var e; while((!c||d.length<c)&& !(e=%_CallFunction(a,b)).done){ d.push(e.value); } return d; } SetMirror.prototype.values=function(a){ if((%_ClassOf(this.value_)==='WeakSet')){ return %GetWeakSetValues(this.value_,a||0); } var b=%_CallFunction(this.value_,builtins.SetValues); return IteratorGetValues_(b,builtins.SetIteratorNextJS,a); }; function IteratorMirror(a){ %_CallFunction(this,a,ITERATOR_TYPE,ObjectMirror); } inherits(IteratorMirror,ObjectMirror); IteratorMirror.prototype.preview=function(a){ if((%_ClassOf(this.value_)==='Map Iterator')){ return IteratorGetValues_(%MapIteratorClone(this.value_), builtins.MapIteratorNextJS, a); }else if((%_ClassOf(this.value_)==='Set Iterator')){ return IteratorGetValues_(%SetIteratorClone(this.value_), builtins.SetIteratorNextJS, a); } }; function GeneratorMirror(a){ %_CallFunction(this,a,GENERATOR_TYPE,ObjectMirror); } inherits(GeneratorMirror,ObjectMirror); function GeneratorGetStatus_(a){ var b=%GeneratorGetContinuation(a); if(b<0)return"running"; if(b==0)return"closed"; return"suspended"; } GeneratorMirror.prototype.status=function(){ return GeneratorGetStatus_(this.value_); }; GeneratorMirror.prototype.sourcePosition_=function(){ return %GeneratorGetSourcePosition(this.value_); }; GeneratorMirror.prototype.sourceLocation=function(){ var a=this.sourcePosition_(); if(!(a===(void 0))){ var b=this.func().script(); if(b){ return b.locationFromPosition(a,true); } } }; GeneratorMirror.prototype.func=function(){ if(!this.func_){ this.func_=MakeMirror(%GeneratorGetFunction(this.value_)); } return this.func_; }; GeneratorMirror.prototype.context=function(){ if(!this.context_){ this.context_=new ContextMirror(%GeneratorGetContext(this.value_)); } return this.context_; }; GeneratorMirror.prototype.receiver=function(){ if(!this.receiver_){ this.receiver_=MakeMirror(%GeneratorGetReceiver(this.value_)); } return this.receiver_; }; function PropertyMirror(a,b,c){ %_CallFunction(this,PROPERTY_TYPE,Mirror); this.mirror_=a; this.name_=b; this.value_=c[0]; this.details_=c[1]; this.is_interceptor_=c[2]; if(c.length>3){ this.exception_=c[3]; this.getter_=c[4]; this.setter_=c[5]; } } 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.is_interceptor_|| ((this.propertyType()==PropertyType.AccessorConstant)&& !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(){ if((this.scopeCount_===(void 0))){ this.scopeCount_=%GetScopeCount(this.break_id_,this.frameId()); } return this.scopeCount_; }; FrameDetails.prototype.stepInPositionsImpl=function(){ return %GetStepInPositions(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.details=function(){ return this.details_; }; FrameMirror.prototype.index=function(){ return this.index_; }; FrameMirror.prototype.func=function(){ if(this.func_){ return this.func_; } var a=this.details_.func(); if((%_IsFunction(a))){ return this.func_=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(){ var a=this.func(); if(a.resolved()){ var b=a.script(); if(b){ return b.locationFromPosition(this.sourcePosition(),true); } } }; FrameMirror.prototype.sourceLine=function(){ var a=this.sourceLocation(); if(a){ return a.line; } }; FrameMirror.prototype.sourceColumn=function(){ var a=this.sourceLocation(); if(a){ return a.column; } }; FrameMirror.prototype.sourceLineText=function(){ 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.allScopes=function(a){ var b=%GetAllScopesDetails(this.break_id_, this.details_.frameId(), this.details_.inlinedFrameIndex(), !!a); var c=[]; for(var d=0;d<b.length;++d){ c.push(new ScopeMirror(this,(void 0),d,b[d])); } return c; }; FrameMirror.prototype.stepInPositions=function(){ var a=this.func().script(); var b=this.func().sourcePosition_(); var c=this.details_.stepInPositionsImpl(); var d=[]; if(c){ for(var e=0;e<c.length;e++){ var g={}; var h=a.locationFromPosition(b+c[e], true); serializeLocationFields(h,g); var i={ position:g }; d.push(i); } } return d; }; FrameMirror.prototype.evaluate=function(source,disable_break, opt_context_object){ return MakeMirror(%DebugEvaluate(this.break_id_, this.details_.frameId(), this.details_.inlinedFrameIndex(), source, Boolean(disable_break), opt_context_object)); }; 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 e=GetUndefinedMirror(); if(c.isObject()){ for(var g=c; !g.isNull()&&e.isUndefined(); g=g.protoObject()){ e=g.lookupProperty(b); } } if(!e.isUndefined()){ if(!e.isIndexed()){ if(d){ a+='.'; } a+=e.name(); }else{ a+='['; a+=e.name(); a+=']'; } if(b.name()&&b.name()!=e.name()){ a+='(aka '+b.name()+')'; } }else{ if(d){ a+='.'; } a+=b.name()?b.name():'[anonymous]'; } } if(!this.isDebuggerFrame()){ a+='('; for(var h=0;h<this.argumentCount();h++){ if(h!=0)a+=', '; if(this.argumentName(h)){ a+=this.argumentName(h); a+='='; } a+=this.argumentValue(h).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()){ var c=b.script(); if(c){ if(c.name()){ a+=c.name(); }else{ a+='[unnamed]'; } if(!this.isDebuggerFrame()){ var d=this.sourceLocation(); a+=' line '; a+=!(d===(void 0))?(d.line+1):'?'; a+=' column '; a+=!(d===(void 0))?(d.column+1):'?'; if(!(this.sourcePosition()===(void 0))){ 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((a===(void 0))){ 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,d){ if(a){ this.break_id_=a.break_id_; this.details_=d|| %GetScopeDetails(a.break_id_, a.details_.frameId(), a.details_.inlinedFrameIndex(), c); this.frame_id_=a.details_.frameId(); this.inlined_frame_id_=a.details_.inlinedFrameIndex(); }else{ this.details_=d||%GetFunctionScopeDetails(b.value(),c); this.fun_value_=b.value(); this.break_id_=undefined; } this.index_=c; } ScopeDetails.prototype.type=function(){ if(!(this.break_id_===(void 0))){ %CheckExecutionState(this.break_id_); } return this.details_[kScopeDetailsTypeIndex]; }; ScopeDetails.prototype.object=function(){ if(!(this.break_id_===(void 0))){ %CheckExecutionState(this.break_id_); } return this.details_[kScopeDetailsObjectIndex]; }; ScopeDetails.prototype.setVariableValueImpl=function(a,b){ var c; if(!(this.break_id_===(void 0))){ %CheckExecutionState(this.break_id_); c=%SetScopeVariableValue(this.break_id_,this.frame_id_, this.inlined_frame_id_,this.index_,a,b); }else{ c=%SetScopeVariableValue(this.fun_value_,null,null,this.index_, a,b); } if(!c){ throw new Error("Failed to set variable value"); } }; function ScopeMirror(a,b,c,d){ %_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,d); } inherits(ScopeMirror,Mirror); ScopeMirror.prototype.details=function(){ return this.details_; }; 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|| this.scopeType()==ScopeType.Script; return MakeMirror(this.details_.object(),a); }; ScopeMirror.prototype.setVariableValue=function(a,b){ this.details_.setVariableValueImpl(a,b); }; 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((this.options_===(void 0))|| (this.options_.maxStringLength===(void 0))){ 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 SYMBOL_TYPE: b.description=a.description(); 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 SYMBOL_TYPE: a.description=mirror.description(); break; case OBJECT_TYPE: case FUNCTION_TYPE: case ERROR_TYPE: case REGEXP_TYPE: case PROMISE_TYPE: case GENERATOR_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(!(mirror.inferredName()===(void 0))){ 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.isGenerator()){ content.status=mirror.status(); content.func=this.serializeReference(mirror.func()) content.receiver=this.serializeReference(mirror.receiver()) serializeLocationFields(mirror.sourceLocation(),content); } if(mirror.isDate()){ content.value=mirror.value(); } if(mirror.isPromise()){ content.status=mirror.status(); content.promiseValue=this.serializeReference(mirror.promiseValue()); } var c=mirror.propertyNames(PropertyKind.Named); var d=mirror.propertyNames(PropertyKind.Indexed); var e=new Array(c.length+d.length); for(var a=0;a<c.length;a++){ var g=mirror.property(c[a]); e[a]=this.serializeProperty_(g); if(details){ this.add_(g.value()); } } for(var a=0;a<d.length;a++){ var g=mirror.property(d[a]); e[c.length+a]=this.serializeProperty_(g); if(details){ this.add_(g.value()); } } content.properties=e; var h=mirror.internalProperties(); if(h.length>0){ var i=[]; for(var a=0;a<h.length;a++){ i.push(this.serializeInternalProperty_(h[a])); } content.internalProperties=i; } }; function serializeLocationFields(a,b){ if(!a){ return; } b.position=a.position; var c=a.line; if(!(c===(void 0))){ b.line=c; } var d=a.column; if(!(d===(void 0))){ 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(); } 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); var d=c.script(); if(d){ b.script=this.serializeReference(d); } b.constructCall=a.isConstructCall(); b.atReturn=a.isAtReturn(); if(a.isAtReturn()){ b.returnValue=this.serializeReference(a.returnValue()); } b.debuggerFrame=a.isDebuggerFrame(); var e=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)); e[g]=h; } b.arguments=e; var e=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)); e[g]=j; } b.locals=e; serializeLocationFields(a.sourceLocation(),b); var k=a.sourceLineText(); if(!(k===(void 0))){ 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; } liveedit? "use strict"; 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 e=BuildCodeInfoTree(d); var g=new PosTranslator(diff_array); MarkChangedFunctions(e,g.GetChunks()); FindLiveSharedInfos(e,script); var h; try{ h=GatherCompileInfo(new_source,script); }catch(e){ var i= new Failure("Failed to compile new version of script: "+e); if(e instanceof SyntaxError){ var j={ type:"liveedit_compile_error", syntaxErrorMessage:e.message }; CopyErrorPositionToDetails(e,j); i.details=j; } throw i; } var k=BuildCodeInfoTree(h); FindCorrespondingFunctions(e,k); var l=new Array(); var m=new Array(); var n=new Array(); var o=new Array(); function HarvestTodo(p){ function CollectDamaged(q){ m.push(q); for(var r=0;r<q.children.length;r++){ CollectDamaged(q.children[r]); } } function CollectNew(t){ for(var r=0;r<t.length;r++){ n.push(t[r]); CollectNew(t[r].children); } } if(p.status==a.DAMAGED){ CollectDamaged(p); return; } if(p.status==a.UNCHANGED){ o.push(p); }else if(p.status==a.SOURCE_CHANGED){ o.push(p); }else if(p.status==a.CHANGED){ l.push(p); CollectNew(p.unmatched_new_nodes); } for(var r=0;r<p.children.length;r++){ HarvestTodo(p.children[r]); } } var u={ change_tree:DescribeChangeTree(e), textual_diff:{ old_len:c.length, new_len:new_source.length, chunks:diff_array }, updated:false }; if(preview_only){ return u; } HarvestTodo(e); var v=new Array(); for(var r=0;r<l.length;r++){ var w= l[r].live_shared_function_infos; if(w){ for(var x=0;x<w.length;x++){ v.push(w[x]); } } } var y= CheckStackActivations(v,change_log); u.stack_modified=y!=0; u[b]= u.stack_modified; var z=TemporaryRemoveBreakPoints(script,change_log); var A; if(m.length==0){ %LiveEditReplaceScript(script,new_source,null); A=(void 0); }else{ var B=CreateNameForOldScript(script); A=%LiveEditReplaceScript(script,new_source, B); var C=new Array(); change_log.push({linked_to_old_script:C}); for(var r=0;r<m.length;r++){ LinkToOldScript(m[r],A, C); } u.created_script_name=B; } for(var r=0;r<n.length;r++){ %LiveEditFunctionSetScript( n[r].info.shared_function_info,script); } for(var r=0;r<l.length;r++){ PatchFunctionCode(l[r],change_log); } var D=new Array(); change_log.push({position_patched:D}); for(var r=0;r<o.length;r++){ PatchPositions(o[r],diff_array, D); if(o[r].live_shared_function_infos){ o[r].live_shared_function_infos. forEach(function(E){ %LiveEditFunctionSourceUpdated(E.raw_array); }); } } z(g,A); u.updated=true; return u; } this.ApplyPatchMultiChunk=ApplyPatchMultiChunk; function GatherCompileInfo(F,G){ var H=%LiveEditGatherCompileInfo(G,F); var I=new Array(); var J=new Array(); for(var r=0;r<H.length;r++){ var E=new FunctionCompileInfo(H[r]); %LiveEditFunctionSetScript(E.shared_function_info,(void 0)); I.push(E); J.push(r); } for(var r=0;r<I.length;r++){ var K=r; for(var x=r+1;x<I.length;x++){ if(I[K].start_position>I[x].start_position){ K=x; } } if(K!=r){ var L=I[K]; var M=J[K]; I[K]=I[r]; J[K]=J[r]; I[r]=L; J[r]=M; } } var N=0; function ResetIndexes(O,P){ var Q=-1; while(N<I.length&& I[N].outer_index==P){ var R=N; I[R].outer_index=O; if(Q!=-1){ I[Q].next_sibling_index=R; } Q=R; N++; ResetIndexes(R,J[R]); } if(Q!=-1){ I[Q].next_sibling_index=-1; } } ResetIndexes(-1,-1); Assert(N==I.length); return I; } function PatchFunctionCode(p,S){ var T=p.corresponding_node.info; if(p.live_shared_function_infos){ p.live_shared_function_infos.forEach(function(U){ %LiveEditReplaceFunctionCode(T.raw_array, U.raw_array); for(var r=0;r<p.children.length;r++){ if(p.children[r].corresponding_node){ var V= p.children[r].corresponding_node.info. shared_function_info; if(p.children[r].live_shared_function_infos){ p.children[r].live_shared_function_infos. forEach(function(W){ %LiveEditReplaceRefToNestedFunction( U.info, V, W.info); }); } } } }); S.push({function_patched:T.function_name}); }else{ S.push({function_patched:T.function_name, function_info_not_found:true}); } } function LinkToOldScript(X,A,Y){ if(X.live_shared_function_infos){ X.live_shared_function_infos. forEach(function(E){ %LiveEditFunctionSetScript(E.info,A); }); Y.push({name:X.info.function_name}); }else{ Y.push( {name:X.info.function_name,not_found:true}); } } function TemporaryRemoveBreakPoints(Z,S){ var aa=GetScriptBreakPoints(Z); var ab=[]; S.push({break_points_update:ab}); var ac=[]; for(var r=0;r<aa.length;r++){ var ad=aa[r]; ad.clear(); var ae=Debug.findScriptSourcePosition(Z, ad.line(),ad.column()); var af={ position:ae, line:ad.line(), column:ad.column() }; ac.push(af); } return function(g,ag){ for(var r=0;r<aa.length;r++){ var ad=aa[r]; if(ag){ var ah=ad.cloneForOtherScript(ag); ah.set(ag); ab.push({ type:"copied_to_old", id:ad.number(), new_id:ah.number(), positions:ac[r] }); } var ai=g.Translate( ac[r].position, PosTranslator.ShiftWithTopInsideChunkHandler); var aj= Z.locationFromPosition(ai,false); ad.update_positions(aj.line,aj.column); var ak={ position:ai, line:aj.line, column:aj.column }; ad.set(Z); ab.push({type:"position_changed", id:ad.number(), old_positions:ac[r], new_positions:ak }); } }; } function Assert(al,am){ if(!al){ if(am){ throw"Assert "+am; }else{ throw"Assert"; } } } function DiffChunk(an,ao,ap,aq){ this.pos1=an; this.pos2=ao; this.len1=ap; this.len2=aq; } function PosTranslator(ar){ var as=new Array(); var at=0; for(var r=0;r<ar.length;r+=3){ var au=ar[r]; var av=au+at; var aw=ar[r+1]; var ax=ar[r+2]; as.push(new DiffChunk(au,av,aw-au, ax-av)); at=ax-aw; } this.chunks=as; } PosTranslator.prototype.GetChunks=function(){ return this.chunks; }; PosTranslator.prototype.Translate=function(ay,az){ var aA=this.chunks; if(aA.length==0||ay<aA[0].pos1){ return ay; } var aB=0; var aC=aA.length-1; while(aB<aC){ var aD=Math.floor((aB+aC)/2); if(ay<aA[aD+1].pos1){ aC=aD; }else{ aB=aD+1; } } var aE=aA[aB]; if(ay>=aE.pos1+aE.len1){ return ay+aE.pos2+aE.len2-aE.pos1-aE.len1; } if(!az){ az=PosTranslator.DefaultInsideChunkHandler; } return az(ay,aE); }; PosTranslator.DefaultInsideChunkHandler=function(ay,aF){ Assert(false,"Cannot translate position in changed area"); }; PosTranslator.ShiftWithTopInsideChunkHandler= function(ay,aF){ return ay-aF.pos1+aF.pos2; }; var a={ UNCHANGED:"unchanged", SOURCE_CHANGED:"source changed", CHANGED:"changed", DAMAGED:"damaged" }; function CodeInfoTreeNode(aG,aH,aI){ this.info=aG; this.children=aH; this.array_index=aI; 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(aJ){ var aK=0; function BuildNode(){ var aL=aK; aK++; var aM=new Array(); while(aK<aJ.length&& aJ[aK].outer_index==aL){ aM.push(BuildNode()); } var q=new CodeInfoTreeNode(aJ[aL],aM, aL); for(var r=0;r<aM.length;r++){ aM[r].parent=q; } return q; } var aN=BuildNode(); Assert(aK==aJ.length); return aN; } function MarkChangedFunctions(aO,as){ var aP=new function(){ var aQ=0; var aR=0; this.current=function(){return as[aQ];}; this.next=function(){ var aE=as[aQ]; aR=aE.pos2+aE.len2-(aE.pos1+aE.len1); aQ++; }; this.done=function(){return aQ>=as.length;}; this.TranslatePos=function(ay){return ay+aR;}; }; function ProcessInternals(aS){ aS.new_start_pos=aP.TranslatePos( aS.info.start_position); var aT=0; var aU=false; var aV=false; while(!aP.done()&& aP.current().pos1<aS.info.end_position){ if(aT<aS.children.length){ var aW=aS.children[aT]; if(aW.info.end_position<=aP.current().pos1){ ProcessUnchangedChild(aW); aT++; continue; }else if(aW.info.start_position>= aP.current().pos1+aP.current().len1){ aU=true; aP.next(); continue; }else if(aW.info.start_position<=aP.current().pos1&& aW.info.end_position>=aP.current().pos1+ aP.current().len1){ ProcessInternals(aW); aV=aV|| (aW.status!=a.UNCHANGED); aU=aU|| (aW.status==a.DAMAGED); aT++; continue; }else{ aU=true; aW.status=a.DAMAGED; aW.status_explanation= "Text diff overlaps with function boundary"; aT++; continue; } }else{ if(aP.current().pos1+aP.current().len1<= aS.info.end_position){ aS.status=a.CHANGED; aP.next(); continue; }else{ aS.status=a.DAMAGED; aS.status_explanation= "Text diff overlaps with function boundary"; return; } } Assert("Unreachable",false); } while(aT<aS.children.length){ var aW=aS.children[aT]; ProcessUnchangedChild(aW); aT++; } if(aU){ aS.status=a.CHANGED; }else if(aV){ aS.status=a.SOURCE_CHANGED; } aS.new_end_pos= aP.TranslatePos(aS.info.end_position); } function ProcessUnchangedChild(q){ q.new_start_pos=aP.TranslatePos(q.info.start_position); q.new_end_pos=aP.TranslatePos(q.info.end_position); } ProcessInternals(aO); } function FindCorrespondingFunctions(aX,aY){ function ProcessNode(p,aZ){ var ba= IsFunctionContextLocalsChanged(p.info,aZ.info); if(ba){ p.status=a.CHANGED; } var bb=p.children; var bc=aZ.children; var bd=[]; var be=[]; var bf=0; var bg=0; while(bf<bb.length){ if(bb[bf].status==a.DAMAGED){ bf++; }else if(bg<bc.length){ if(bc[bg].info.start_position< bb[bf].new_start_pos){ bd.push(bc[bg]); be.push(bc[bg]); bg++; }else if(bc[bg].info.start_position== bb[bf].new_start_pos){ if(bc[bg].info.end_position== bb[bf].new_end_pos){ bb[bf].corresponding_node= bc[bg]; bb[bf].textual_corresponding_node= bc[bg]; if(ba){ bb[bf].status=a.DAMAGED; bb[bf].status_explanation= "Enclosing function is now incompatible. "+ ba; bb[bf].corresponding_node=(void 0); }else if(bb[bf].status!= a.UNCHANGED){ ProcessNode(bb[bf], bc[bg]); if(bb[bf].status==a.DAMAGED){ bd.push( bb[bf].corresponding_node); bb[bf].corresponding_node=(void 0); p.status=a.CHANGED; } } }else{ bb[bf].status=a.DAMAGED; bb[bf].status_explanation= "No corresponding function in new script found"; p.status=a.CHANGED; bd.push(bc[bg]); be.push(bc[bg]); } bg++; bf++; }else{ bb[bf].status=a.DAMAGED; bb[bf].status_explanation= "No corresponding function in new script found"; p.status=a.CHANGED; bf++; } }else{ bb[bf].status=a.DAMAGED; bb[bf].status_explanation= "No corresponding function in new script found"; p.status=a.CHANGED; bf++; } } while(bg<bc.length){ bd.push(bc[bg]); be.push(bc[bg]); bg++; } if(p.status==a.CHANGED){ if(p.info.param_num!=aZ.info.param_num){ p.status=a.DAMAGED; p.status_explanation="Changed parameter number: "+ p.info.param_num+" and "+aZ.info.param_num; } } p.unmatched_new_nodes=bd; p.textually_unmatched_new_nodes= be; } ProcessNode(aX,aY); aX.corresponding_node=aY; aX.textual_corresponding_node=aY; Assert(aX.status!=a.DAMAGED, "Script became damaged"); } function FindLiveSharedInfos(aX,G){ var bh=%LiveEditFindSharedFunctionInfosForScript(G); var bi=new Array(); for(var r=0;r<bh.length;r++){ bi.push(new SharedInfoWrapper(bh[r])); } function FindFunctionInfos(I){ var bj=[]; for(var r=0;r<bi.length;r++){ var bk=bi[r]; if(bk.start_position==I.start_position&& bk.end_position==I.end_position){ bj.push(bk); } } if(bj.length>0){ return bj; } } function TraverseTree(q){ q.live_shared_function_infos=FindFunctionInfos(q.info); for(var r=0;r<q.children.length;r++){ TraverseTree(q.children[r]); } } TraverseTree(aX); } function FunctionCompileInfo(bl){ this.function_name=bl[0]; this.start_position=bl[1]; this.end_position=bl[2]; this.param_num=bl[3]; this.code=bl[4]; this.code_scope_info=bl[5]; this.scope_info=bl[6]; this.outer_index=bl[7]; this.shared_function_info=bl[8]; this.next_sibling_index=null; this.raw_array=bl; } function SharedInfoWrapper(bl){ this.function_name=bl[0]; this.start_position=bl[1]; this.end_position=bl[2]; this.info=bl[3]; this.raw_array=bl; } function PatchPositions(X,ar,Y){ if(X.live_shared_function_infos){ X.live_shared_function_infos.forEach(function(E){ %LiveEditPatchFunctionPositions(E.raw_array, ar); }); Y.push({name:X.info.function_name}); }else{ Y.push( {name:X.info.function_name,info_not_found:true}); } } function CreateNameForOldScript(G){ return G.name+" (old)"; } function IsFunctionContextLocalsChanged(bm,bn){ var bo=bm.scope_info; var bp=bn.scope_info; var bq; var br; if(bo){ bq=bo.toString(); }else{ bq=""; } if(bp){ br=bp.toString(); }else{ br=""; } if(bq!=br){ return"Variable map changed: ["+bq+ "] => ["+br+"]"; } return; } var bs; function CheckStackActivations(bt,S){ var bu=new Array(); for(var r=0;r<bt.length;r++){ bu[r]=bt[r].info; } var bv=%LiveEditCheckAndDropActivations(bu,true); if(bv[bu.length]){ throw new Failure(bv[bu.length]); } var bw=new Array(); var bx=new Array(); for(var r=0;r<bu.length;r++){ var by=bt[r]; if(bv[r]==bs.REPLACED_ON_ACTIVE_STACK){ bx.push({name:by.function_name}); }else if(bv[r]!=bs.AVAILABLE_FOR_PATCH){ var bz={ name:by.function_name, start_pos:by.start_position, end_pos:by.end_position, replace_problem: bs.SymbolName(bv[r]) }; bw.push(bz); } } if(bx.length>0){ S.push({dropped_from_stack:bx}); } if(bw.length>0){ S.push({functions_on_stack:bw}); throw new Failure("Blocked by functions on stack"); } return bx.length; } var bs={ AVAILABLE_FOR_PATCH:1, BLOCKED_ON_ACTIVE_STACK:2, BLOCKED_ON_OTHER_STACK:3, BLOCKED_UNDER_NATIVE_CODE:4, REPLACED_ON_ACTIVE_STACK:5, BLOCKED_UNDER_GENERATOR:6, BLOCKED_ACTIVE_GENERATOR:7 }; bs.SymbolName=function(bA){ var bB=bs; for(var bC in bB){ if(bB[bC]==bA){ return bC; } } }; function Failure(am){ this.message=am; } this.Failure=Failure; Failure.prototype.toString=function(){ return"LiveEdit Failure: "+this.message; }; function CopyErrorPositionToDetails(bD,j){ function createPositionStruct(G,bE){ if(bE==-1)return; var bF=G.locationFromPosition(bE,true); if(bF==null)return; return{ line:bF.line+1, column:bF.column+1, position:bE }; } if(!("scriptObject"in bD)||!("startPosition"in bD)){ return; } var G=bD.scriptObject; var bG={ start:createPositionStruct(G,bD.startPosition), end:createPositionStruct(G,bD.endPosition) }; j.position=bG; } function GetPcFromSourcePos(bH,bI){ return %GetFunctionCodePositionFromSource(bH,bI); } this.GetPcFromSourcePos=GetPcFromSourcePos; function SetScriptSource(G,bJ,bK,S){ var c=G.source; var bL=CompareStrings(c,bJ); return ApplyPatchMultiChunk(G,bL,bJ,bK, S); } this.SetScriptSource=SetScriptSource; function CompareStrings(bM,bN){ return %LiveEditCompareStrings(bM,bN); } function ApplySingleChunkPatch(G,change_pos,change_len,new_str, S){ var c=G.source; var bJ=c.substring(0,change_pos)+ new_str+c.substring(change_pos+change_len); return ApplyPatchMultiChunk(G, [change_pos,change_pos+change_len,change_pos+new_str.length], bJ,false,S); } function DescribeChangeTree(aX){ function ProcessOldNode(q){ var bO=[]; for(var r=0;r<q.children.length;r++){ var aW=q.children[r]; if(aW.status!=a.UNCHANGED){ bO.push(ProcessOldNode(aW)); } } var bP=[]; if(q.textually_unmatched_new_nodes){ for(var r=0;r<q.textually_unmatched_new_nodes.length;r++){ var aW=q.textually_unmatched_new_nodes[r]; bP.push(ProcessNewNode(aW)); } } var bQ={ name:q.info.function_name, positions:DescribePositions(q), status:q.status, children:bO, new_children:bP }; if(q.status_explanation){ bQ.status_explanation=q.status_explanation; } if(q.textual_corresponding_node){ bQ.new_positions=DescribePositions(q.textual_corresponding_node); } return bQ; } function ProcessNewNode(q){ var bO=[]; if(false){ for(var r=0;r<q.children.length;r++){ bO.push(ProcessNewNode(q.children[r])); } } var bQ={ name:q.info.function_name, positions:DescribePositions(q), children:bO, }; return bQ; } function DescribePositions(q){ return{ start_position:q.info.start_position, end_position:q.info.end_position }; } return ProcessOldNode(aX); } function RestartFrame(bR){ var bv=bR.restart(); if((typeof(bv)==='string')){ throw new Failure("Failed to restart frame: "+bv); } var bv={}; bv[b]=true; return bv; } this.RestartFrame=RestartFrame; this.TestApi={ PosTranslator:PosTranslator, CompareStrings:CompareStrings, ApplySingleChunkPatch:ApplySingleChunkPatch }; }; `runtime? 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(); 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((typeof(a)==='symbol'))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)==='symbol'))return 1; 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)==='symbol')){ if((typeof(a)==='symbol'))return %_ObjectEquals(b,a)?0:1; return 1; }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)); if((typeof(a)==='symbol'))return 1; 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)==='symbol'))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((a===(void 0)))return b; c=this; }else if((typeof(this)==='number')){ if((typeof(a)==='number'))return %NumberCompare(this,a,b); if((a===(void 0)))return b; c=this; }else if((this===(void 0))){ if(!(a===(void 0))){ %ToPrimitive(a,1); } return b; }else if((a===(void 0))){ %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 g=%ToNumber(d); if((!%_IsSmi(%IS_VAR(e))&&!(e==e))||(!%_IsSmi(%IS_VAR(g))&&!(g==g)))return b; return %NumberCompare(e,g,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 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),%ToName(a),b); } function IN(a){ if(!(%_IsSpecObject(a))){ throw %MakeTypeError('invalid_in_operator_use',[this,a]); } if(%_IsNonNegativeSmi(this)){ if((%_IsArray(a))&&%_HasFastPackedElements(a)){ return this<a.length; } return %HasElement(a,this); } return %HasProperty(a,%ToName(this)); } function INSTANCE_OF(a){ var b=this; if(!(%_ClassOf(a)==='Function')){ throw %MakeTypeError('instanceof_function_expected',[a]); } 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=%ToName(a); if(%HasProperty(this,b))return b; return 0; } function CALL_NON_FUNCTION(){ var a=%GetFunctionDelegate(this); if(!(%_IsFunction(a))){ var b=%RenderCallSite(); if(b=="")b=typeof this; throw %MakeTypeError('called_non_callable',[b]); } return %Apply(a,this,arguments,0,%_ArgumentsLength()); } function CALL_NON_FUNCTION_AS_CONSTRUCTOR(){ var a=%GetConstructorDelegate(this); if(!(%_IsFunction(a))){ var b=%RenderCallSite(); if(b=="")b=typeof this; throw %MakeTypeError('called_non_callable',[b]); } 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 REFLECT_APPLY_PREPARE(a){ var b; if((%_IsArray(a))){ b=a.length; if(%_IsSmi(b)&&b>=0&&b<0x800000&& (%_ClassOf(this)==='Function')){ return b; } } if(!(%_ClassOf(this)==='Function')){ throw %MakeTypeError('called_non_callable',[%ToString(this)]); } if(!(%_IsSpecObject(a))){ throw %MakeTypeError('reflect_apply_wrong_args',[]); } b=%ToLength(a.length); if(b>0x800000){ throw %MakeRangeError('stack_overflow',[]); } return b; } function REFLECT_CONSTRUCT_PREPARE(a,b){ var c; var d=(%_ClassOf(this)==='Function')&&%IsConstructor(this); var e=(%_ClassOf(b)==='Function')&&%IsConstructor(b); if((%_IsArray(a))){ c=a.length; if(%_IsSmi(c)&&c>=0&&c<0x800000&& d&&e){ return c; } } if(!d){ if(!(%_ClassOf(this)==='Function')){ throw %MakeTypeError('called_non_callable',[%ToString(this)]); }else{ throw %MakeTypeError('not_constructor',[%ToString(this)]); } } if(!e){ if(!(%_ClassOf(b)==='Function')){ throw %MakeTypeError('called_non_callable',[%ToString(b)]); }else{ throw %MakeTypeError('not_constructor',[%ToString(b)]); } } if(!(%_IsSpecObject(a))){ throw %MakeTypeError('reflect_construct_wrong_args',[]); } c=%ToLength(a.length); if(c>0x800000){ throw %MakeRangeError('stack_overflow',[]); } return c; } function STACK_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 TO_NAME(){ return %ToName(this); } function ToPrimitive(a,b){ if((typeof(a)==='string'))return a; if(!(%_IsSpecObject(a)))return a; if((%_ClassOf(a)==='Symbol'))throw MakeTypeError('symbol_to_primitive',[]); 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((a===(void 0)))return $NaN; if((typeof(a)==='symbol'))throw MakeTypeError('symbol_to_number',[]); 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((a===(void 0)))return $NaN; if((typeof(a)==='symbol'))throw MakeTypeError('symbol_to_number',[]); 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((a===(void 0)))return'undefined'; if((typeof(a)==='symbol'))throw %MakeTypeError('symbol_to_string',[]); 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((a===(void 0)))return'undefined'; if((typeof(a)==='symbol'))throw %MakeTypeError('symbol_to_string',[]); return((a===null))?'null':%ToString(%DefaultString(a)); } function ToName(a){ return(typeof(a)==='symbol')?a:%ToString(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((typeof(a)==='symbol'))return %NewSymbolWrapper(a); if((a==null)&&!(%_IsUndetectableObject(a))){ throw %MakeTypeError('undefined_or_null_to_object',[]); } return a; } function ToInteger(a){ if(%_IsSmi(a))return a; return %NumberToInteger(ToNumber(a)); } function ToLength(a){ a=ToInteger(a); if(a<0)return 0; return a<$Number.MAX_SAFE_INTEGER?a:$Number.MAX_SAFE_INTEGER; } 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&&%_IsMinusZero(a)!=%_IsMinusZero(b)){ return false; } } return a===b; } function SameValueZero(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; } return a===b; } function IsPrimitive(a){ return!(%_IsSpecObject(a)); } function IsConcatSpreadable(a){ if(!(%_IsSpecObject(a)))return false; var b=a[symbolIsConcatSpreadable]; if((b===(void 0)))return(%_IsArray(a)); return ToBoolean(b); } function DefaultNumber(a){ if(!(%_ClassOf(a)==='Symbol')){ 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){ if(!(%_ClassOf(a)==='Symbol')){ 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',[]); } function ToPositiveInteger(a,b){ var c=(%_IsSmi(%IS_VAR(a))?a:%NumberToIntegerMapMinusZero(ToNumber(a))); if(c<0)throw MakeRangeError(b); return c; } %FunctionSetPrototype($Array,new $Array(0)); function STRING_LENGTH_STUB(a){ var b=this; return %_StringGetLength(%_JSValueGetValue(b)); } $v8natives? 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 g=c[d+1]; %FunctionSetName(g,e); %FunctionRemovePrototype(g); %AddNamedProperty(a,e,g,b); %SetNativeFlag(g); } %ToFastProperties(a); } function OverrideFunction(a,b,c){ ObjectDefineProperty(a,b,{value:c, writeable:true, configurable:true, enumerable:false}); %FunctionSetName(c,b); %FunctionRemovePrototype(c); %SetNativeFlag(c); } function InstallGetter(a,b,c){ %FunctionSetName(c,b); %FunctionRemovePrototype(c); %DefineAccessorPropertyUnchecked(a,b,c,null,2); %SetNativeFlag(c); } function InstallGetterSetter(a,b,c,d){ %FunctionSetName(c,b); %FunctionSetName(d,b); %FunctionRemovePrototype(c); %FunctionRemovePrototype(d); %DefineAccessorPropertyUnchecked(a,b,c,d,2); %SetNativeFlag(c); %SetNativeFlag(d); } function InstallConstants(a,b){ if(b.length>=4){ %OptimizeObjectForAddingMultipleProperties(a,b.length>>1); } var c=2|4|1; for(var d=0;d<b.length;d+=2){ var e=b[d]; var g=b[d+1]; %AddNamedProperty(a,e,g,c); } %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 g=0;g<b.length;g++){ %AddNamedProperty(d,b[g], (void 0),2|4); } } for(var g=0;g<c.length;g+=2){ var h=c[g]; var i=c[g+1]; %AddNamedProperty(d,h,i,2|4|1); %SetNativeFlag(i); } %InternalSetPrototype(d,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((b===(void 0))||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=%GlobalProxy(global); var c=%CompileString(a,false,0); if(!(%_IsFunction(c)))return c; return %_CallFunction(b,c); } function SetUpGlobal(){ %CheckIsBootstrapping(); var a=2|4|1; %AddNamedProperty(global,"NaN",$NaN,a); %AddNamedProperty(global,"Infinity",(1/0),a); %AddNamedProperty(global,"undefined",(void 0),a); InstallFunctions(global,2,$Array( "isNaN",GlobalIsNaN, "isFinite",GlobalIsFinite, "parseInt",GlobalParseInt, "parseFloat",GlobalParseFloat, "eval",GlobalEval )); } SetUpGlobal(); var DefaultObjectToString=NoSideEffectsObjectToString; function NoSideEffectsObjectToString(){ if((this===(void 0))&&!(%_IsUndetectableObject(this)))return"[object Undefined]"; if((this===null))return"[object Null]"; return"[object "+%_ClassOf(((%_IsSpecObject(%IS_VAR(this)))?this: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((%_IsSpecObject(%IS_VAR(this)))?this:ToObject(this)); } function ObjectHasOwnProperty(a){ if(%_IsJSProxy(this)){ if((typeof(a)==='symbol'))return false; var b=%GetHandler(this); return CallTrap1(b,"hasOwn",DerivedHasOwnTrap,ToName(a)); } return %HasOwnProperty(((%_IsSpecObject(%IS_VAR(this)))?this:ToObject(this)),ToName(a)); } function ObjectIsPrototypeOf(a){ if(!(%_IsSpecObject(a)))return false; if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Object.prototype.isPrototypeOf"]); return %IsInPrototypeChain(this,a); } function ObjectPropertyIsEnumerable(a){ var b=ToName(a); if(%_IsJSProxy(this)){ if((typeof(a)==='symbol'))return false; var c=GetOwnPropertyJS(this,b); return(c===(void 0))?false:c.isEnumerable(); } return %IsPropertyEnumerable(((%_IsSpecObject(%IS_VAR(this)))?this:ToObject(this)),b); } function ObjectDefineGetter(a,b){ var c=this; if(c==null&&!(%_IsUndetectableObject(c))){ c=%GlobalProxy(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(((%_IsSpecObject(%IS_VAR(c)))?c:ToObject(c)),ToName(a),d,false); } function ObjectLookupGetter(a){ var b=this; if(b==null&&!(%_IsUndetectableObject(b))){ b=%GlobalProxy(global); } return %LookupAccessor(((%_IsSpecObject(%IS_VAR(b)))?b:ToObject(b)),ToName(a),0); } function ObjectDefineSetter(a,b){ var c=this; if(c==null&&!(%_IsUndetectableObject(c))){ c=%GlobalProxy(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(((%_IsSpecObject(%IS_VAR(c)))?c:ToObject(c)),ToName(a),d,false); } function ObjectLookupSetter(a){ var b=this; if(b==null&&!(%_IsUndetectableObject(b))){ b=%GlobalProxy(global); } return %LookupAccessor(((%_IsSpecObject(%IS_VAR(b)))?b:ToObject(b)),ToName(a),1); } function ObjectKeys(a){ a=((%_IsSpecObject(%IS_VAR(a)))?a:ToObject(a)); if(%_IsJSProxy(a)){ var b=%GetHandler(a); var c=CallTrap0(b,"keys",DerivedKeysTrap); return ToNameArray(c,"keys",false); } return %OwnKeys(a); } function IsAccessorDescriptor(a){ if((a===(void 0)))return false; return a.hasGetter()||a.hasSetter(); } function IsDataDescriptor(a){ if((a===(void 0)))return false; return a.hasValue()||a.hasWritable(); } function IsGenericDescriptor(a){ if((a===(void 0)))return false; return!(IsAccessorDescriptor(a)||IsDataDescriptor(a)); } function IsInconsistentDescriptor(a){ return IsAccessorDescriptor(a)&&IsDataDescriptor(a); } function FromPropertyDescriptor(a){ if((a===(void 0)))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((a===(void 0)))return a; var b=new $Object(); if(a.hasValue()){ %AddNamedProperty(b,"value",a.getValue(),0); } if(a.hasWritable()){ %AddNamedProperty(b,"writable",a.isWritable(),0); } if(a.hasGetter()){ %AddNamedProperty(b,"get",a.getGet(),0); } if(a.hasSetter()){ %AddNamedProperty(b,"set",a.getSet(),0); } if(a.hasEnumerable()){ %AddNamedProperty(b,"enumerable",a.isEnumerable(),0); } if(a.hasConfigurable()){ %AddNamedProperty(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(!(c===(void 0))&&!(%_ClassOf(c)==='Function')){ throw MakeTypeError("getter_must_be_callable",[c]); } b.setGet(c); } if("set"in a){ var d=a.set; if(!(d===(void 0))&&!(%_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 PropertyDescriptor_ToString(){ return"[object PropertyDescriptor]"; }, "setValue",function PropertyDescriptor_SetValue(a){ this.value_=a; this.hasValue_=true; }, "getValue",function PropertyDescriptor_GetValue(){ return this.value_; }, "hasValue",function PropertyDescriptor_HasValue(){ return this.hasValue_; }, "setEnumerable",function PropertyDescriptor_SetEnumerable(a){ this.enumerable_=a; this.hasEnumerable_=true; }, "isEnumerable",function PropertyDescriptor_IsEnumerable(){ return this.enumerable_; }, "hasEnumerable",function PropertyDescriptor_HasEnumerable(){ return this.hasEnumerable_; }, "setWritable",function PropertyDescriptor_SetWritable(a){ this.writable_=a; this.hasWritable_=true; }, "isWritable",function PropertyDescriptor_IsWritable(){ return this.writable_; }, "hasWritable",function PropertyDescriptor_HasWritable(){ return this.hasWritable_; }, "setConfigurable", function PropertyDescriptor_SetConfigurable(a){ this.configurable_=a; this.hasConfigurable_=true; }, "hasConfigurable",function PropertyDescriptor_HasConfigurable(){ return this.hasConfigurable_; }, "isConfigurable",function PropertyDescriptor_IsConfigurable(){ return this.configurable_; }, "setGet",function PropertyDescriptor_SetGetter(a){ this.get_=a; this.hasGetter_=true; }, "getGet",function PropertyDescriptor_GetGetter(){ return this.get_; }, "hasGetter",function PropertyDescriptor_HasGetter(){ return this.hasGetter_; }, "setSet",function PropertyDescriptor_SetSetter(a){ this.set_=a; this.hasSetter_=true; }, "getSet",function PropertyDescriptor_GetSetter(){ return this.set_; }, "hasSetter",function PropertyDescriptor_HasSetter(){ return this.hasSetter_; })); function ConvertDescriptorArrayToDescriptor(a){ if((a===(void 0))){ 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((d===(void 0))){ if((c===(void 0))){ 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 GetOwnPropertyJS(a,b){ var c=ToName(b); if(%_IsJSProxy(a)){ if((typeof(b)==='symbol'))return(void 0); var d=%GetHandler(a); var e=CallTrap1( d,"getOwnPropertyDescriptor",(void 0),c); if((e===(void 0)))return e; var g=ToCompletePropertyDescriptor(e); if(!g.isConfigurable()){ throw MakeTypeError("proxy_prop_not_configurable", [d,"getOwnPropertyDescriptor",c,e]); } return g; } var h=%GetOwnProperty(((%_IsSpecObject(%IS_VAR(a)))?a:ToObject(a)),c); return ConvertDescriptorArrayToDescriptor(h); } function Delete(a,b,c){ var d=GetOwnPropertyJS(a,b); if((d===(void 0)))return true; if(d.isConfigurable()){ %DeleteProperty(a,b,0); return true; }else if(c){ throw MakeTypeError("define_disallowed",[b]); }else{ return; } } function GetMethod(a,b){ var c=a[b]; if((c==null))return(void 0); if((%_ClassOf(c)==='Function'))return c; throw MakeTypeError('called_non_callable',[typeof c]); } function DefineProxyProperty(a,b,c,d){ if((typeof(b)==='symbol'))return false; var e=%GetHandler(a); var g=CallTrap2(e,"defineProperty",(void 0),b,c); if(!ToBoolean(g)){ if(d){ throw MakeTypeError("handler_returned_false", [e,"defineProperty"]); }else{ return false; } } return true; } function DefineObjectProperty(a,b,c,d){ var e=%GetOwnProperty(a,ToName(b)); var g=ConvertDescriptorArrayToDescriptor(e); var h=%IsExtensible(a); if((g===(void 0))&&!h){ if(d){ throw MakeTypeError("define_disallowed",[b]); }else{ return false; } } if(!(g===(void 0))){ if((IsGenericDescriptor(c)|| IsDataDescriptor(c)==IsDataDescriptor(g))&& (!c.hasEnumerable()|| SameValue(c.isEnumerable(),g.isEnumerable()))&& (!c.hasConfigurable()|| SameValue(c.isConfigurable(),g.isConfigurable()))&& (!c.hasWritable()|| SameValue(c.isWritable(),g.isWritable()))&& (!c.hasValue()|| SameValue(c.getValue(),g.getValue()))&& (!c.hasGetter()|| SameValue(c.getGet(),g.getGet()))&& (!c.hasSetter()|| SameValue(c.getSet(),g.getSet()))){ return true; } if(!g.isConfigurable()){ if(c.isConfigurable()|| (c.hasEnumerable()&& c.isEnumerable()!=g.isEnumerable())){ if(d){ throw MakeTypeError("redefine_disallowed",[b]); }else{ return false; } } if(!IsGenericDescriptor(c)){ if(IsDataDescriptor(g)!=IsDataDescriptor(c)){ if(d){ throw MakeTypeError("redefine_disallowed",[b]); }else{ return false; } } if(IsDataDescriptor(g)&&IsDataDescriptor(c)){ if(!g.isWritable()&&c.isWritable()){ if(d){ throw MakeTypeError("redefine_disallowed",[b]); }else{ return false; } } if(!g.isWritable()&&c.hasValue()&& !SameValue(c.getValue(),g.getValue())){ if(d){ throw MakeTypeError("redefine_disallowed",[b]); }else{ return false; } } } if(IsAccessorDescriptor(c)&&IsAccessorDescriptor(g)){ if(c.hasSetter()&&!SameValue(c.getSet(),g.getSet())){ if(d){ throw MakeTypeError("redefine_disallowed",[b]); }else{ return false; } } if(c.hasGetter()&&!SameValue(c.getGet(),g.getGet())){ if(d){ throw MakeTypeError("redefine_disallowed",[b]); }else{ return false; } } } } } } var i=0; if(c.hasEnumerable()){ i|=c.isEnumerable()?0:2; }else if(!(g===(void 0))){ i|=g.isEnumerable()?0:2; }else{ i|=2; } if(c.hasConfigurable()){ i|=c.isConfigurable()?0:4; }else if(!(g===(void 0))){ i|=g.isConfigurable()?0:4; }else i|=4; if(IsDataDescriptor(c)|| (IsGenericDescriptor(c)&& ((g===(void 0))||IsDataDescriptor(g)))){ if(c.hasWritable()){ i|=c.isWritable()?0:1; }else if(!(g===(void 0))){ i|=g.isWritable()?0:1; }else{ i|=1; } var j=(void 0); if(c.hasValue()){ j=c.getValue(); }else if(!(g===(void 0))&&IsDataDescriptor(g)){ j=g.getValue(); } %DefineDataPropertyUnchecked(a,b,j,i); }else{ var k=null; if(c.hasGetter()){ k=c.getGet(); }else if(IsAccessorDescriptor(g)&&g.hasGetter()){ k=g.getGet(); } var l=null; if(c.hasSetter()){ l=c.getSet(); }else if(IsAccessorDescriptor(g)&&g.hasSetter()){ l=g.getSet(); } %DefineAccessorPropertyUnchecked(a,b,k,l,i); } return true; } function DefineArrayProperty(a,b,c,d){ if(b==="length"){ var e=a.length; var g=e; if(!c.hasValue()){ return DefineObjectProperty(a,"length",c,d); } var h=ToUint32(c.getValue()); if(h!=ToNumber(c.getValue())){ throw new $RangeError('defineProperty() array length out of range'); } var i=GetOwnPropertyJS(a,"length"); if(h!=e&&!i.isWritable()){ if(d){ throw MakeTypeError("redefine_disallowed",[b]); }else{ return false; } } var j=false; var k=%IsObserved(a)&&h!==g; var l; if(k){ BeginPerformSplice(a); l=[]; if(h<g) l.length=g-h; } while(h<e--){ var m=ToString(e); if(k){ var n=GetOwnPropertyJS(a,m); if(n&&n.hasValue()) l[e-h]=n.getValue(); } if(!Delete(a,m,false)){ h=e+1; j=true; break; } } j=!DefineObjectProperty(a,"length",c,d)||j; if(k){ EndPerformSplice(a); EnqueueSpliceRecord(a, h<g?h:g, l, h>g?h-g:0); } if(j){ if(d){ throw MakeTypeError("redefine_disallowed",[b]); }else{ return false; } } return true; } if(!(typeof(b)==='symbol')){ var m=ToUint32(b); var k=false; if(ToString(m)==b&&m!=4294967295){ var e=a.length; if(m>=e&&%IsObserved(a)){ k=true; BeginPerformSplice(a); } var i=GetOwnPropertyJS(a,"length"); if((m>=e&&!i.isWritable())|| !DefineObjectProperty(a,b,c,true)){ if(k) EndPerformSplice(a); if(d){ throw MakeTypeError("define_disallowed",[b]); }else{ return false; } } if(m>=e){ a.length=m+1; } if(k){ EndPerformSplice(a); EnqueueSpliceRecord(a,e,[],m+1-e); } return true; } } return DefineObjectProperty(a,b,c,d); } function DefineOwnProperty(a,b,c,d){ if(%_IsJSProxy(a)){ if((typeof(b)==='symbol'))return false; 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 ObjectSetPrototypeOf(a,b){ if((a==null)&&!(%_IsUndetectableObject(a)))throw MakeTypeError('called_on_null_or_undefined',["Object.setPrototypeOf"]); if(b!==null&&!(%_IsSpecObject(b))){ throw MakeTypeError("proto_object_or_null",[b]); } if((%_IsSpecObject(a))){ %SetPrototype(a,b); } return a; } function ObjectGetOwnPropertyDescriptor(a,b){ if(!(%_IsSpecObject(a))){ throw MakeTypeError("called_on_non_object", ["Object.getOwnPropertyDescriptor"]); } var c=GetOwnPropertyJS(a,b); return FromPropertyDescriptor(c); } function ToNameArray(a,b,c){ if(!(%_IsSpecObject(a))){ throw MakeTypeError("proxy_non_object_prop_names",[a,b]); } var d=ToUint32(a.length); var e=new $Array(d); var g=0; var h={__proto__:null}; for(var i=0;i<d;i++){ var j=ToName(a[i]); if((typeof(j)==='symbol')&&!c)continue; if(%HasOwnProperty(h,j)){ throw MakeTypeError("proxy_repeated_prop_name",[a,b,j]); } e[i]=j; ++g; h[j]=0; } e.length=g; return e; } function ObjectGetOwnPropertyKeys(a,b){ var c=new InternalArray(); b|=32; var d=%GetInterceptorInfo(a); if((b&8)===0){ var e=%GetOwnElementNames(a); for(var g=0;g<e.length;++g){ e[g]=%_NumberToString(e[g]); } c.push(e); if((d&1)!=0){ var h=%GetIndexedInterceptorElementNames(a); if(!(h===(void 0))){ c.push(h); } } } c.push(%GetOwnPropertyNames(a,b)); if((d&2)!=0){ var i= %GetNamedInterceptorPropertyNames(a); if(!(i===(void 0))){ c.push(i); } } var j= %Apply(InternalArray.prototype.concat, c[0],c,1,c.length-1); if(d!=0){ var k={__proto__:null}; var l=0; for(var g=0;g<j.length;++g){ var m=j[g]; if((typeof(m)==='symbol')){ if((b&16)||(%SymbolIsPrivate(m))){ continue; } }else{ if(b&8)continue; m=ToString(m); } if(k[m])continue; k[m]=true; j[l++]=m; } j.length=l; } return j; } function ObjectGetOwnPropertyNames(a){ a=((%_IsSpecObject(%IS_VAR(a)))?a:ToObject(a)); if(%_IsJSProxy(a)){ var b=%GetHandler(a); var c=CallTrap0(b,"getOwnPropertyNames",(void 0)); return ToNameArray(c,"getOwnPropertyNames",false); } return ObjectGetOwnPropertyKeys(a,16); } function ObjectCreate(a,b){ if(!(%_IsSpecObject(a))&&a!==null){ throw MakeTypeError("proto_object_or_null",[a]); } var c={}; %InternalSetPrototype(c,a); if(!(b===(void 0)))ObjectDefineProperties(c,b); return c; } function ObjectDefineProperty(a,b,c){ if(!(%_IsSpecObject(a))){ throw MakeTypeError("called_on_non_object",["Object.defineProperty"]); } var d=ToName(b); if(%_IsJSProxy(a)){ var e={__proto__:null}; for(var g in c){ e[g]=c[g]; } DefineProxyProperty(a,d,e,true); }else{ var h=ToPropertyDescriptor(c); DefineOwnProperty(a,d,h,true); } return a; } function GetOwnEnumerablePropertyNames(a){ var b=new InternalArray(); for(var c in a){ if(%HasOwnProperty(a,c)){ b.push(c); } } var d=8|32; var e=%GetOwnPropertyNames(a,d); for(var g=0;g<e.length;++g){ var h=e[g]; if((typeof(h)==='symbol')){ var i=ObjectGetOwnPropertyDescriptor(a,h); if(i.enumerable)b.push(h); } } return b; } function ObjectDefineProperties(a,b){ if(!(%_IsSpecObject(a))){ throw MakeTypeError("called_on_non_object",["Object.defineProperties"]); } var c=((%_IsSpecObject(%IS_VAR(b)))?b:ToObject(b)); var d=GetOwnEnumerablePropertyNames(c); var e=new InternalArray(); for(var g=0;g<d.length;g++){ e.push(ToPropertyDescriptor(c[d[g]])); } for(var g=0;g<d.length;g++){ DefineOwnProperty(a,d[g],e[g],true); } return a; } function ProxyFix(a){ var b=%GetHandler(a); var c=CallTrap0(b,"fix",(void 0)); if((c===(void 0))){ throw MakeTypeError("handler_returned_undefined",[b,"fix"]); } if(%IsJSFunctionProxy(a)){ var d=%GetCallTrap(a); var e=%GetConstructTrap(a); var g=DelegateCallAndConstruct(d,e); %Fix(a); %SetCode(a,g); var h=new $Object(); $Object.defineProperty(h,"constructor", {value:a,writable:true,enumerable:false,configurable:true}); %FunctionSetPrototype(a,h); a.length=0; }else{ %Fix(a); } ObjectDefineProperties(a,c); } function ObjectSealJS(a){ if(!(%_IsSpecObject(a))){ throw MakeTypeError("called_on_non_object",["Object.seal"]); } var b=%_IsJSProxy(a); if(b||%HasSloppyArgumentsElements(a)||%IsObserved(a)){ if(b){ ProxyFix(a); } var c=ObjectGetOwnPropertyNames(a); for(var d=0;d<c.length;d++){ var e=c[d]; var g=GetOwnPropertyJS(a,e); if(g.isConfigurable()){ g.setConfigurable(false); DefineOwnProperty(a,e,g,true); } } %PreventExtensions(a); }else{ %ObjectSeal(a); } return a; } function ObjectFreezeJS(a){ if(!(%_IsSpecObject(a))){ throw MakeTypeError("called_on_non_object",["Object.freeze"]); } var b=%_IsJSProxy(a); if(b||%HasSloppyArgumentsElements(a)||%IsObserved(a)){ if(b){ ProxyFix(a); } var c=ObjectGetOwnPropertyNames(a); for(var d=0;d<c.length;d++){ var e=c[d]; var g=GetOwnPropertyJS(a,e); if(g.isWritable()||g.isConfigurable()){ if(IsDataDescriptor(g))g.setWritable(false); g.setConfigurable(false); DefineOwnProperty(a,e,g,true); } } %PreventExtensions(a); }else{ %ObjectFreeze(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; } if(%IsExtensible(a)){ return false; } var b=ObjectGetOwnPropertyNames(a); for(var c=0;c<b.length;c++){ var d=b[c]; var e=GetOwnPropertyJS(a,d); if(e.isConfigurable()){ return false; } } return true; } function ObjectIsFrozen(a){ if(!(%_IsSpecObject(a))){ throw MakeTypeError("called_on_non_object",["Object.isFrozen"]); } if(%_IsJSProxy(a)){ return false; } if(%IsExtensible(a)){ return false; } var b=ObjectGetOwnPropertyNames(a); for(var c=0;c<b.length;c++){ var d=b[c]; var e=GetOwnPropertyJS(a,d); if(IsDataDescriptor(e)&&e.isWritable())return false; if(e.isConfigurable())return false; } return true; } 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){ return SameValue(a,b); } function ObjectGetProto(){ return %_GetPrototype(((%_IsSpecObject(%IS_VAR(this)))?this:ToObject(this))); } function ObjectSetProto(a){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Object.prototype.__proto__"]); if(((%_IsSpecObject(a))||(a===null))&&(%_IsSpecObject(this))){ %SetPrototype(this,a); } } function ObjectConstructor(a){ if(%_IsConstructCall()){ if(a==null)return this; return((%_IsSpecObject(%IS_VAR(a)))?a:ToObject(a)); }else{ if(a==null)return{}; return((%_IsSpecObject(%IS_VAR(a)))?a:ToObject(a)); } } function SetUpObject(){ %CheckIsBootstrapping(); %SetNativeFlag($Object); %SetCode($Object,ObjectConstructor); %AddNamedProperty($Object.prototype,"constructor",$Object,2); InstallFunctions($Object.prototype,2,$Array( "toString",NoSideEffectsObjectToString, "toLocaleString",ObjectToLocaleString, "valueOf",ObjectValueOf, "hasOwnProperty",ObjectHasOwnProperty, "isPrototypeOf",ObjectIsPrototypeOf, "propertyIsEnumerable",ObjectPropertyIsEnumerable, "__defineGetter__",ObjectDefineGetter, "__lookupGetter__",ObjectLookupGetter, "__defineSetter__",ObjectDefineSetter, "__lookupSetter__",ObjectLookupSetter )); InstallGetterSetter($Object.prototype,"__proto__", ObjectGetProto,ObjectSetProto); InstallFunctions($Object,2,$Array( "keys",ObjectKeys, "create",ObjectCreate, "defineProperty",ObjectDefineProperty, "defineProperties",ObjectDefineProperties, "freeze",ObjectFreezeJS, "getPrototypeOf",ObjectGetPrototypeOf, "setPrototypeOf",ObjectSetPrototypeOf, "getOwnPropertyDescriptor",ObjectGetOwnPropertyDescriptor, "getOwnPropertyNames",ObjectGetOwnPropertyNames, "is",ObjectIs, "isExtensible",ObjectIsExtensible, "isFrozen",ObjectIsFrozen, "isSealed",ObjectIsSealed, "preventExtensions",ObjectPreventExtension, "seal",ObjectSealJS )); } SetUpObject(); function BooleanConstructor(a){ if(%_IsConstructCall()){ %_SetValueOf(this,ToBoolean(a)); }else{ return ToBoolean(a); } } 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(); %SetCode($Boolean,BooleanConstructor); %FunctionSetPrototype($Boolean,new $Boolean(false)); %AddNamedProperty($Boolean.prototype,"constructor",$Boolean,2); InstallFunctions($Boolean.prototype,2,$Array( "toString",BooleanToString, "valueOf",BooleanValueOf )); } SetUpBoolean(); function NumberConstructor(a){ var b=%_ArgumentsLength()==0?0:ToNumber(a); if(%_IsConstructCall()){ %_SetValueOf(this,b); }else{ return b; } } function NumberToStringJS(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((a===(void 0))||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(){ return %_CallFunction(this,NumberToStringJS); } function NumberValueOf(){ if(!(typeof(this)==='number')&&!(%_ClassOf(this)==='Number')){ throw new $TypeError('Number.prototype.valueOf is not generic'); } return %_ValueOf(this); } function NumberToFixedJS(a){ var b=this; if(!(typeof(this)==='number')){ if(!(%_ClassOf(this)==='Number')){ throw MakeTypeError("incompatible_method_receiver", ["Number.prototype.toFixed",this]); } b=%_ValueOf(this); } var c=(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a))); if(c<0||c>20){ throw new $RangeError("toFixed() digits argument must be between 0 and 20"); } if((!%_IsSmi(%IS_VAR(b))&&!(b==b)))return"NaN"; if(b==(1/0))return"Infinity"; if(b==-(1/0))return"-Infinity"; return %NumberToFixed(b,c); } function NumberToExponentialJS(a){ var b=this; if(!(typeof(this)==='number')){ if(!(%_ClassOf(this)==='Number')){ throw MakeTypeError("incompatible_method_receiver", ["Number.prototype.toExponential",this]); } b=%_ValueOf(this); } var c=(a===(void 0))?(void 0):(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a))); if((!%_IsSmi(%IS_VAR(b))&&!(b==b)))return"NaN"; if(b==(1/0))return"Infinity"; if(b==-(1/0))return"-Infinity"; if((c===(void 0))){ c=-1; }else if(c<0||c>20){ throw new $RangeError("toExponential() argument must be between 0 and 20"); } return %NumberToExponential(b,c); } function NumberToPrecisionJS(a){ var b=this; if(!(typeof(this)==='number')){ if(!(%_ClassOf(this)==='Number')){ throw MakeTypeError("incompatible_method_receiver", ["Number.prototype.toPrecision",this]); } b=%_ValueOf(this); } if((a===(void 0)))return ToString(%_ValueOf(this)); var c=(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a))); if((!%_IsSmi(%IS_VAR(b))&&!(b==b)))return"NaN"; if(b==(1/0))return"Infinity"; if(b==-(1/0))return"-Infinity"; if(c<1||c>21){ throw new $RangeError("toPrecision() argument must be between 1 and 21"); } return %NumberToPrecision(b,c); } function NumberIsFinite(a){ return(typeof(a)==='number')&&(%_IsSmi(%IS_VAR(a))||((a==a)&&(a!=1/0)&&(a!=-1/0))); } function NumberIsInteger(a){ return NumberIsFinite(a)&&(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a)))==a; } function NumberIsNaN(a){ return(typeof(a)==='number')&&(!%_IsSmi(%IS_VAR(a))&&!(a==a)); } function NumberIsSafeInteger(a){ if(NumberIsFinite(a)){ var b=(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a))); if(b==a)return $abs(b)<=$Number.MAX_SAFE_INTEGER; } return false; } function SetUpNumber(){ %CheckIsBootstrapping(); %SetCode($Number,NumberConstructor); %FunctionSetPrototype($Number,new $Number(0)); %OptimizeObjectForAddingMultipleProperties($Number.prototype,8); %AddNamedProperty($Number.prototype,"constructor",$Number,2); InstallConstants($Number,$Array( "MAX_VALUE",1.7976931348623157e+308, "MIN_VALUE",5e-324, "NaN",$NaN, "NEGATIVE_INFINITY",-(1/0), "POSITIVE_INFINITY",(1/0), "MAX_SAFE_INTEGER",%_MathPow(2,53)-1, "MIN_SAFE_INTEGER",-%_MathPow(2,53)+1, "EPSILON",%_MathPow(2,-52) )); InstallFunctions($Number.prototype,2,$Array( "toString",NumberToStringJS, "toLocaleString",NumberToLocaleString, "valueOf",NumberValueOf, "toFixed",NumberToFixedJS, "toExponential",NumberToExponentialJS, "toPrecision",NumberToPrecisionJS )); InstallFunctions($Number,2,$Array( "isFinite",NumberIsFinite, "isInteger",NumberIsInteger, "isNaN",NumberIsNaN, "isSafeInteger",NumberIsSafeInteger, "parseInt",GlobalParseInt, "parseFloat",GlobalParseFloat )); } SetUpNumber(); function FunctionSourceString(a){ while(%IsJSFunctionProxy(a)){ a=%GetCallTrap(a); } if(!(%_IsFunction(a))){ throw new $TypeError('Function.prototype.toString is not generic'); } var b=%ClassGetSourceCode(a); if((typeof(b)==='string')){ return b; } var c=%FunctionGetSourceCode(a); if(!(typeof(c)==='string')||%FunctionIsBuiltin(a)){ var d=%FunctionGetName(a); if(d){ return'function '+d+'() { [native code] }'; }else{ return'function () { [native code] }'; } } if(%FunctionIsArrow(a)){ return c; } var d=%FunctionNameShouldPrintAsAnonymous(a) ?'anonymous' :%FunctionGetName(a); var e=%FunctionIsGenerator(a); var g=%FunctionIsConciseMethod(a) ?(e?'*':'') :(e?'function* ':'function '); return g+d+c; } 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 g=new InternalArray(e+d); for(var h=0;h<e;h++){ g[h]=c[h+2]; } for(var i=0;i<d;i++){ g[h++]=%_Arguments(i); } return %Apply(c[0],c[1],g,0,e+d); }; var j=0; var k=this.length; if((typeof k==="number")&& ((k>>>0)===k)){ var d=%_ArgumentsLength(); if(d>0)d--; j=k-d; if(j<0)j=0; } var l=%FunctionBindArguments(b,this, a,j); return l; } function NewFunctionFromString(a,b){ var c=a.length; var d=''; if(c>1){ d=ToString(a[0]); for(var e=1;e<c-1;e++){ d+=','+ToString(a[e]); } if(%_CallFunction(d,')',$stringIndexOf)!=-1){ throw MakeSyntaxError('paren_in_arg_string',[]); } d+='\n\x2f**\x2f'; } var g=(c>0)?ToString(a[c-1]):''; var h='('+b+'('+d+') {\n'; var i=h+g+'\n})'; var j=%GlobalProxy(global); var k=%_CallFunction(j,%CompileString(i,true,h.length)); %FunctionMarkNameShouldPrintAsAnonymous(k); return k; } function FunctionConstructor(a){ return NewFunctionFromString(arguments,'function'); } function SetUpFunction(){ %CheckIsBootstrapping(); %SetCode($Function,FunctionConstructor); %AddNamedProperty($Function.prototype,"constructor",$Function,2); InstallFunctions($Function.prototype,2,$Array( "bind",FunctionBind, "toString",FunctionToString )); } SetUpFunction(); function GetIterator(a,b){ if((b===(void 0))){ b=a[symbolIterator]; } if(!(%_ClassOf(b)==='Function')){ throw MakeTypeError('not_iterable',[a]); } var c=%_CallFunction(a,b); if(!(%_IsSpecObject(c))){ throw MakeTypeError('not_an_iterator',[c]); } return c; } symbolY var $symbolToString; (function(){ "use strict"; %CheckIsBootstrapping(); var a=global.Array; var b=global.Object; var c=global.Symbol; function SymbolConstructor(d){ if(%_IsConstructCall()){ throw MakeTypeError('not_constructor',["Symbol"]); } return %CreateSymbol((d===(void 0))?d:ToString(d)); } function SymbolToString(){ if(!((typeof(this)==='symbol')||(%_ClassOf(this)==='Symbol'))){ throw MakeTypeError( 'incompatible_method_receiver',["Symbol.prototype.toString",this]); } var e=%SymbolDescription(%_ValueOf(this)); return"Symbol("+((e===(void 0))?"":e)+")"; } function SymbolValueOf(){ if(!((typeof(this)==='symbol')||(%_ClassOf(this)==='Symbol'))){ throw MakeTypeError( 'incompatible_method_receiver',["Symbol.prototype.valueOf",this]); } return %_ValueOf(this); } function SymbolFor(g){ g=((typeof(%IS_VAR(g))==='string')?g:NonStringToString(g)); var h=%SymbolRegistry(); if((h.for[g]===(void 0))){ var i=%CreateSymbol(g); h.for[g]=i; h.keyFor[i]=g; } return h.for[g]; } function SymbolKeyFor(i){ if(!(typeof(i)==='symbol'))throw MakeTypeError("not_a_symbol",[i]); return %SymbolRegistry().keyFor[i]; } function ObjectGetOwnPropertySymbols(j){ j=ToObject(j); return ObjectGetOwnPropertyKeys(j,8); } %SetCode(c,SymbolConstructor); %FunctionSetPrototype(c,new b()); InstallConstants(c,a( "iterator",symbolIterator, "unscopables",symbolUnscopables )); InstallFunctions(c,2,a( "for",SymbolFor, "keyFor",SymbolKeyFor )); %AddNamedProperty( c.prototype,"constructor",c,2); %AddNamedProperty( c.prototype,symbolToStringTag,"Symbol",2|1); InstallFunctions(c.prototype,2,a( "toString",SymbolToString, "valueOf",SymbolValueOf )); InstallFunctions(b,2,a( "getOwnPropertySymbols",ObjectGetOwnPropertySymbols )); $symbolToString=SymbolToString; })(); array? "use strict"; var visited_arrays=new InternalArray(); function GetSortedArrayKeys(a,b){ var c=new InternalArray(); if((typeof(b)==='number')){ var d=b; for(var e=0;e<d;++e){ var g=a[e]; if(!(g===(void 0))||e in a){ c.push(e); } } }else{ var h=b.length; for(var i=0;i<h;++i){ var j=b[i]; if(!(j===(void 0))){ var g=a[j]; if(!(g===(void 0))||j in a){ c.push(j); } } } %_CallFunction(c,function(k,l){return k-l;},ArraySort); } return c; } function SparseJoinWithSeparatorJS(a,b,c,d){ var e=GetSortedArrayKeys(a,%GetArrayKeys(a,b)); var g=0; var h=new InternalArray(e.length*2); var i=-1; for(var j=0;j<e.length;j++){ var k=e[j]; if(k!=i){ var l=a[k]; if(!(typeof(l)==='string'))l=c(l); h[j*2]=k; h[j*2+1]=l; i=k; } } return %SparseJoinWithSeparator(h,b,d); } function SparseJoin(a,b,c){ var d=GetSortedArrayKeys(a,%GetArrayKeys(a,b)); var e=-1; var g=d.length; var h=new InternalArray(g); var i=0; for(var j=0;j<g;j++){ var k=d[j]; if(k!=e){ var l=a[k]; if(!(typeof(l)==='string'))l=c(l); h[i++]=l; e=k; } } return %StringBuilderConcat(h,i,''); } function UseSparseVariant(a,b,c,d){ if(!c||b<1000||%IsObserved(a)|| %HasComplexElements(a)){ return false; } if(!%_IsSmi(b)){ return true; } var e=b>>2; var g=%EstimateNumberOfElements(a); return(g<e)&& (d>g*4); } 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,b)){ %NormalizeElements(a); if(c.length==0){ return SparseJoin(a,b,d); }else{ return SparseJoinWithSeparatorJS(a,b,d,c); } } if(b==1){ var g=a[0]; if((typeof(g)==='string'))return g; return d(g); } var h=new InternalArray(b); if(c.length==0){ var i=0; for(var j=0;j<b;j++){ var g=a[j]; if(!(typeof(g)==='string'))g=d(g); h[i++]=g; } h.length=i; var k=%_FastOneByteArrayJoin(h,''); if(!(k===(void 0)))return k; return %StringBuilderConcat(h,i,''); } if(!(typeof(a[0])==='number')){ for(var j=0;j<b;j++){ var g=a[j]; if(!(typeof(g)==='string'))g=d(g); h[j]=g; } }else{ for(var j=0;j<b;j++){ var g=a[j]; if((typeof(g)==='number')){ g=%_NumberToString(g); }else if(!(typeof(g)==='string')){ g=d(g); } h[j]=g; } } var k=%_FastOneByteArrayJoin(h,c); if(!(k===(void 0)))return k; return %StringBuilderJoin(h,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 SparseSlice(a,b,c,d,g){ var h=%GetArrayKeys(a,b+c); if((typeof(h)==='number')){ var i=h; for(var j=b;j<i;++j){ var k=a[j]; if(!(k===(void 0))||j in a){ %AddElement(g,j-b,k,0); } } }else{ var l=h.length; for(var m=0;m<l;++m){ var n=h[m]; if(!(n===(void 0))){ if(n>=b){ var k=a[n]; if(!(k===(void 0))||n in a){ %AddElement(g,n-b,k,0); } } } } } } function SparseMove(a,b,c,d,g){ if(g===c)return; var h=new InternalArray( $min(d-c+g,0xffffffff)); var i; var j=%GetArrayKeys(a,d); if((typeof(j)==='number')){ var k=j; for(var l=0;l<b&&l<k;++l){ var m=a[l]; if(!(m===(void 0))||l in a){ h[l]=m; } } for(var l=b+c;l<k;++l){ var m=a[l]; if(!(m===(void 0))||l in a){ h[l-c+g]=m; } } }else{ var n=j.length; for(var o=0;o<n;++o){ var q=j[o]; if(!(q===(void 0))){ if(q<b){ var m=a[q]; if(!(m===(void 0))||q in a){ h[q]=m; } }else if(q>=b+c){ var m=a[q]; if(!(m===(void 0))||q in a){ var r=q-c+g; h[r]=m; if(r>0xffffffff){ i=i||new InternalArray(); i.push(r); } } } } } } %MoveArrayContents(h,a); if(!(i===(void 0))){ var n=i.length; for(var l=0;l<n;++l){ var q=i[l]; a[q]=h[q]; } } } function SimpleSlice(a,b,c,d,g){ var h=(%_IsArray(a)); for(var i=0;i<c;i++){ var j=b+i; if(((h&&%_HasFastPackedElements(%IS_VAR(a)))?(j<a.length):(j in a))){ var k=a[j]; %AddElement(g,i,k,0); } } } function SimpleMove(a,b,c,d,g){ var h=(%_IsArray(a)); if(g!==c){ if(g>c){ for(var i=d-c;i>b;i--){ var j=i+c-1; var k=i+g-1; if(((h&&%_HasFastPackedElements(%IS_VAR(a)))?(j<a.length):(j in a))){ a[k]=a[j]; }else{ delete a[k]; } } }else{ for(var i=b;i<d-c;i++){ var j=i+c; var k=i+g; if(((h&&%_HasFastPackedElements(%IS_VAR(a)))?(j<a.length):(j in a))){ a[k]=a[j]; }else{ delete a[k]; } } for(var i=d;i>d-c+g;i--){ delete a[i-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,DefaultObjectToString); } 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"]); var b=((%_IsSpecObject(%IS_VAR(this)))?this:ToObject(this)); var c=(b.length>>>0); if((a===(void 0))){ a=','; }else if(!(typeof(a)==='string')){ a=NonStringToString(a); } var d=%_FastOneByteArrayJoin(b,a); if(!(d===(void 0)))return d; if(c===1){ var g=b[0]; if((typeof(g)==='string'))return g; if((g==null))return''; return NonStringToString(g); } return Join(b,c,a,ConvertToString); } function ObservedArrayPop(a){ a--; var b=this[a]; try{ BeginPerformSplice(this); delete this[a]; this.length=a; }finally{ EndPerformSplice(this); EnqueueSpliceRecord(this,a,[b],0); } return b; } function ArrayPop(){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Array.prototype.pop"]); var a=((%_IsSpecObject(%IS_VAR(this)))?this:ToObject(this)); var b=(a.length>>>0); if(b==0){ a.length=b; return; } if(%IsObserved(a)) return ObservedArrayPop.call(a,b); b--; var c=a[b]; Delete(a,ToName(b),true); a.length=b; return c; } function ObservedArrayPush(){ var a=(this.length>>>0); var b=%_ArgumentsLength(); try{ BeginPerformSplice(this); for(var c=0;c<b;c++){ this[c+a]=%_Arguments(c); } var d=a+b; this.length=d; }finally{ EndPerformSplice(this); EnqueueSpliceRecord(this,a,[],b); } return d; } function ArrayPush(){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Array.prototype.push"]); if(%IsObserved(this)) return ObservedArrayPush.apply(this,arguments); var a=((%_IsSpecObject(%IS_VAR(this)))?this:ToObject(this)); var b=(a.length>>>0); var c=%_ArgumentsLength(); for(var d=0;d<c;d++){ a[d+b]=%_Arguments(d); } var g=b+c; a.length=g; return g; } function ArrayConcatJS(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 g=0;g<c;g++){ d[g+1]=%_Arguments(g); } return %ArrayConcat(d); } function SparseReverse(a,b){ var c=GetSortedArrayKeys(a,%GetArrayKeys(a,b)); var d=c.length-1; var g=0; while(g<=d){ var h=c[g]; var i=c[d]; var j=b-i-1; var k,l; if(j<=h){ l=i; while(c[--d]==i){} k=j; } if(j>=h){ k=h; while(c[++g]==h){} l=b-h-1; } var m=a[k]; if(!(m===(void 0))||k in a){ var o=a[l]; if(!(o===(void 0))||l in a){ a[k]=o; a[l]=m; }else{ a[l]=m; delete a[k]; } }else{ var o=a[l]; if(!(o===(void 0))||l in a){ a[k]=o; delete a[l]; } } } } function ArrayReverse(){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Array.prototype.reverse"]); var a=((%_IsSpecObject(%IS_VAR(this)))?this:ToObject(this)); var b=(a.length>>>0); if(UseSparseVariant(a,b,(%_IsArray(a)),b)){ %NormalizeElements(a); SparseReverse(a,b); return a; } var c=b-1; for(var d=0;d<c;d++,c--){ var g=a[d]; if(!(g===(void 0))||d in a){ var h=a[c]; if(!(h===(void 0))||c in a){ a[d]=h; a[c]=g; }else{ a[c]=g; delete a[d]; } }else{ var h=a[c]; if(!(h===(void 0))||c in a){ a[d]=h; delete a[c]; } } } return a; } function ObservedArrayShift(a){ var b=this[0]; try{ BeginPerformSplice(this); SimpleMove(this,0,1,a,0); this.length=a-1; }finally{ EndPerformSplice(this); EnqueueSpliceRecord(this,0,[b],0); } return b; } function ArrayShift(){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Array.prototype.shift"]); var a=((%_IsSpecObject(%IS_VAR(this)))?this:ToObject(this)); var b=(a.length>>>0); if(b===0){ a.length=0; return; } if(ObjectIsSealed(a)){ throw MakeTypeError("array_functions_change_sealed", ["Array.prototype.shift"]); } if(%IsObserved(a)) return ObservedArrayShift.call(a,b); var c=a[0]; if(UseSparseVariant(a,b,(%_IsArray(a)),b)){ SparseMove(a,0,1,b,0); }else{ SimpleMove(a,0,1,b,0); } a.length=b-1; return c; } function ObservedArrayUnshift(){ var a=(this.length>>>0); var b=%_ArgumentsLength(); try{ BeginPerformSplice(this); SimpleMove(this,0,0,a,b); for(var c=0;c<b;c++){ this[c]=%_Arguments(c); } var d=a+b; this.length=d; }finally{ EndPerformSplice(this); EnqueueSpliceRecord(this,0,[],b); } return d; } function ArrayUnshift(a){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Array.prototype.unshift"]); if(%IsObserved(this)) return ObservedArrayUnshift.apply(this,arguments); var b=((%_IsSpecObject(%IS_VAR(this)))?this:ToObject(this)); var c=(b.length>>>0); var d=%_ArgumentsLength(); if(c>0&&UseSparseVariant(b,c,(%_IsArray(b)),c)&& !ObjectIsSealed(b)){ SparseMove(b,0,0,c,d); }else{ SimpleMove(b,0,0,c,d); } for(var g=0;g<d;g++){ b[g]=%_Arguments(g); } var h=c+d; b.length=h; return h; } function ArraySlice(a,b){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Array.prototype.slice"]); var c=((%_IsSpecObject(%IS_VAR(this)))?this:ToObject(this)); var d=(c.length>>>0); 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)g=d; } if(h<0){ h+=d; if(h<0)h=0; }else{ if(h>d)h=d; } var i=[]; if(h<g)return i; if(UseSparseVariant(c,d,(%_IsArray(c)),h-g)){ %NormalizeElements(c); %NormalizeElements(i); SparseSlice(c,g,h-g,d,i); }else{ SimpleSlice(c,g,h-g,d,i); } i.length=h-g; return i; } function ComputeSpliceStartIndex(a,b){ if(a<0){ a+=b; return a<0?0:a; } return a>b?b:a; } function ComputeSpliceDeleteCount(a,b,c,d){ var g=0; if(b==1) return c-d; g=(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a))); if(g<0) return 0; if(g>c-d) return c-d; return g; } function ObservedArraySplice(a,b){ var c=%_ArgumentsLength(); var d=(this.length>>>0); var g=ComputeSpliceStartIndex((%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a))),d); var h=ComputeSpliceDeleteCount(b,c,d, g); var i=[]; i.length=h; var j=c>2?c-2:0; try{ BeginPerformSplice(this); SimpleSlice(this,g,h,d,i); SimpleMove(this,g,h,d,j); var k=g; var l=2; var m=%_ArgumentsLength(); while(l<m){ this[k++]=%_Arguments(l++); } this.length=d-h+j; }finally{ EndPerformSplice(this); if(i.length||j){ EnqueueSpliceRecord(this, g, i.slice(), j); } } return i; } function ArraySplice(a,b){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Array.prototype.splice"]); if(%IsObserved(this)) return ObservedArraySplice.apply(this,arguments); var c=%_ArgumentsLength(); var d=((%_IsSpecObject(%IS_VAR(this)))?this:ToObject(this)); var g=(d.length>>>0); var h=ComputeSpliceStartIndex((%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a))),g); var i=ComputeSpliceDeleteCount(b,c,g, h); var j=[]; j.length=i; var k=c>2?c-2:0; if(i!=k&&ObjectIsSealed(d)){ throw MakeTypeError("array_functions_change_sealed", ["Array.prototype.splice"]); }else if(i>0&&ObjectIsFrozen(d)){ throw MakeTypeError("array_functions_on_frozen", ["Array.prototype.splice"]); } var l=i; if(k!=i){ l+=g-h-i; } if(UseSparseVariant(d,g,(%_IsArray(d)),l)){ %NormalizeElements(d); %NormalizeElements(j); SparseSlice(d,h,i,g,j); SparseMove(d,h,i,g,k); }else{ SimpleSlice(d,h,i,g,j); SimpleMove(d,h,i,g,k); } var m=h; var o=2; var q=%_ArgumentsLength(); while(o<q){ d[m++]=%_Arguments(o++); } d.length=g-i+k; return j; } 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 g=function InsertionSort(h,i,j){ for(var k=i+1;k<j;k++){ var l=h[k]; for(var m=k-1;m>=i;m--){ var o=h[m]; var q=%_CallFunction(d,o,l,a); if(q>0){ h[m+1]=o; }else{ break; } } h[m+1]=l; } }; var r=function(h,i,j){ var t=[]; var u=200+((j-i)&15); for(var k=i+1,m=0;k<j-1;k+=u,m++){ t[m]=[k,h[k]]; } %_CallFunction(t,function(h,w){ return %_CallFunction(d,h[1],w[1],a); },ArraySort); var z=t[t.length>>1][0]; return z; } var A=function QuickSort(h,i,j){ var z=0; while(true){ if(j-i<=10){ g(h,i,j); return; } if(j-i>1000){ z=r(h,i,j); }else{ z=i+((j-i)>>1); } var B=h[i]; var C=h[j-1]; var D=h[z]; var E=%_CallFunction(d,B,C,a); if(E>0){ var o=B; B=C; C=o; } var G=%_CallFunction(d,B,D,a); if(G>=0){ var o=B; B=D; D=C; C=o; }else{ var H=%_CallFunction(d,C,D,a); if(H>0){ var o=C; C=D; D=o; } } h[i]=B; h[j-1]=D; var I=C; var J=i+1; var K=j-1; h[z]=h[J]; h[J]=I; partition:for(var k=J+1;k<K;k++){ var l=h[k]; var q=%_CallFunction(d,l,I,a); if(q<0){ h[k]=h[J]; h[J]=l; J++; }else if(q>0){ do{ K--; if(K==k)break partition; var L=h[K]; q=%_CallFunction(d,L,I,a); }while(q>0); h[k]=h[K]; h[K]=l; if(q<0){ l=h[k]; h[k]=h[J]; h[J]=l; J++; } } } if(j-K<J-i){ A(h,K,j); j=J; }else{ A(h,i,J); i=K; } } }; var M=function CopyFromPrototype(N,P){ var Q=0; for(var R=%_GetPrototype(N);R;R=%_GetPrototype(R)){ var S=%GetArrayKeys(R,P); if((typeof(S)==='number')){ var T=S; for(var k=0;k<T;k++){ if(!(%_CallFunction(N,k,ObjectHasOwnProperty))&&(%_CallFunction(R,k,ObjectHasOwnProperty))){ N[k]=R[k]; if(k>=Q){Q=k+1;} } } }else{ for(var k=0;k<S.length;k++){ var U=S[k]; if(!(U===(void 0))&&!(%_CallFunction(N,U,ObjectHasOwnProperty)) &&(%_CallFunction(R,U,ObjectHasOwnProperty))){ N[U]=R[U]; if(U>=Q){Q=U+1;} } } } } return Q; }; var W=function(N,i,j){ for(var R=%_GetPrototype(N);R;R=%_GetPrototype(R)){ var S=%GetArrayKeys(R,j); if((typeof(S)==='number')){ var T=S; for(var k=i;k<T;k++){ if((%_CallFunction(R,k,ObjectHasOwnProperty))){ N[k]=(void 0); } } }else{ for(var k=0;k<S.length;k++){ var U=S[k]; if(!(U===(void 0))&&i<=U&& (%_CallFunction(R,U,ObjectHasOwnProperty))){ N[U]=(void 0); } } } } }; var X=function SafeRemoveArrayHoles(N){ var Y=0; var Z=P-1; var aa=0; while(Y<Z){ while(Y<Z&& !(N[Y]===(void 0))){ Y++; } if(!(%_CallFunction(N,Y,ObjectHasOwnProperty))){ aa++; } while(Y<Z&& (N[Z]===(void 0))){ if(!(%_CallFunction(N,Z,ObjectHasOwnProperty))){ aa++; } Z--; } if(Y<Z){ N[Y]=N[Z]; N[Z]=(void 0); } } if(!(N[Y]===(void 0)))Y++; var k; for(k=Y;k<P-aa;k++){ N[k]=(void 0); } for(k=P-aa;k<P;k++){ if(k in %_GetPrototype(N)){ N[k]=(void 0); }else{ delete N[k]; } } return Y; }; var P=(this.length>>>0); if(P<2)return this; var ab=(%_IsArray(this)); var ac; if(!ab){ ac=M(this,P); } var ad=%RemoveArrayHoles(this,P); if(ad==-1){ ad=X(this); } A(this,0,ad); if(!ab&&(ad+1<ac)){ W(this,ad,ac); } 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]); } var g=false; if((b==null)){ b=%GetDefaultReceiver(a)||b; }else{ g=(!(%_IsSpecObject(b))&&%IsSloppyModeFunction(a)); } var h=new $Array(); var i=new InternalArray(); var j=0; var k=(%_IsArray(c)); var l=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(a); for(var m=0;m<d;m++){ if(((k&&%_HasFastPackedElements(%IS_VAR(c)))?(m<c.length):(m in c))){ var o=c[m]; if(l)%DebugPrepareStepInIfStepping(a); var q=g?ToObject(b):b; if(%_CallFunction(q,o,m,c,a)){ i[j++]=o; } } } %MoveArrayContents(i,h); return h; } 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]); } var g=false; if((b==null)){ b=%GetDefaultReceiver(a)||b; }else{ g=(!(%_IsSpecObject(b))&&%IsSloppyModeFunction(a)); } var h=(%_IsArray(c)); var i=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(a); for(var j=0;j<d;j++){ if(((h&&%_HasFastPackedElements(%IS_VAR(c)))?(j<c.length):(j in c))){ var k=c[j]; if(i)%DebugPrepareStepInIfStepping(a); var l=g?ToObject(b):b; %_CallFunction(l,k,j,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]); } var g=false; if((b==null)){ b=%GetDefaultReceiver(a)||b; }else{ g=(!(%_IsSpecObject(b))&&%IsSloppyModeFunction(a)); } var h=(%_IsArray(c)); var i=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(a); for(var j=0;j<d;j++){ if(((h&&%_HasFastPackedElements(%IS_VAR(c)))?(j<c.length):(j in c))){ var k=c[j]; if(i)%DebugPrepareStepInIfStepping(a); var l=g?ToObject(b):b; if(%_CallFunction(l,k,j,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]); } var g=false; if((b==null)){ b=%GetDefaultReceiver(a)||b; }else{ g=(!(%_IsSpecObject(b))&&%IsSloppyModeFunction(a)); } var h=(%_IsArray(c)); var i=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(a); for(var j=0;j<d;j++){ if(((h&&%_HasFastPackedElements(%IS_VAR(c)))?(j<c.length):(j in c))){ var k=c[j]; if(i)%DebugPrepareStepInIfStepping(a); var l=g?ToObject(b):b; if(!%_CallFunction(l,k,j,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]); } var g=false; if((b==null)){ b=%GetDefaultReceiver(a)||b; }else{ g=(!(%_IsSpecObject(b))&&%IsSloppyModeFunction(a)); } var h=new $Array(); var i=new InternalArray(d); var j=(%_IsArray(c)); var k=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(a); for(var l=0;l<d;l++){ if(((j&&%_HasFastPackedElements(%IS_VAR(c)))?(l<c.length):(l in c))){ var m=c[l]; if(k)%DebugPrepareStepInIfStepping(a); var o=g?ToObject(b):b; i[l]=%_CallFunction(o,m,l,c,a); } } %MoveArrayContents(i,h); return h; } 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((b===(void 0))){ 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)),g-d)){ %NormalizeElements(this); var h=%GetArrayKeys(this,c); if((typeof(h)==='number')){ g=h; }else{ if(h.length==0)return-1; var i=GetSortedArrayKeys(this,h); var j=i.length; var k=0; while(k<j&&i[k]<b)k++; while(k<j){ var l=i[k]; if(!(l===(void 0))&&this[l]===a)return l; k++; } return-1; } } if(!(a===(void 0))){ for(var k=d;k<g;k++){ if(this[k]===a)return k; } return-1; } for(var k=d;k<g;k++){ if((this[k]===(void 0))&&k in this){ return k; } } 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)),b)){ %NormalizeElements(this); var h=%GetArrayKeys(this,b+1); if((typeof(h)==='number')){ g=h; }else{ if(h.length==0)return-1; var i=GetSortedArrayKeys(this,h); var j=i.length-1; while(j>=0){ var k=i[j]; if(!(k===(void 0))&&this[k]===a)return k; j--; } return-1; } } if(!(a===(void 0))){ for(var j=g;j>=d;j--){ if(this[j]===a)return j; } return-1; } for(var j=g;j>=d;j--){ if((this[j]===(void 0))&&j in this){ return j; } } 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=(%_IsArray(c)); var h=0; find_initial:if(%_ArgumentsLength()<2){ for(;h<d;h++){ if(((g&&%_HasFastPackedElements(%IS_VAR(c)))?(h<c.length):(h in c))){ b=c[h++]; break find_initial; } } throw MakeTypeError('reduce_no_initial',[]); } var i=%GetDefaultReceiver(a); var j=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(a); for(;h<d;h++){ if(((g&&%_HasFastPackedElements(%IS_VAR(c)))?(h<c.length):(h in c))){ var k=c[h]; if(j)%DebugPrepareStepInIfStepping(a); b=%_CallFunction(i,b,k,h,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=(%_IsArray(c)); var h=d-1; find_initial:if(%_ArgumentsLength()<2){ for(;h>=0;h--){ if(((g&&%_HasFastPackedElements(%IS_VAR(c)))?(h<c.length):(h in c))){ b=c[h--]; break find_initial; } } throw MakeTypeError('reduce_no_initial',[]); } var i=%GetDefaultReceiver(a); var j=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(a); for(;h>=0;h--){ if(((g&&%_HasFastPackedElements(%IS_VAR(c)))?(h<c.length):(h in c))){ var k=c[h]; if(j)%DebugPrepareStepInIfStepping(a); b=%_CallFunction(i,b,k,h,c,a); } } return b; } function ArrayIsArray(a){ return(%_IsArray(a)); } function SetUpArray(){ %CheckIsBootstrapping(); %AddNamedProperty($Array.prototype,"constructor",$Array,2); var a={ __proto__:null, copyWithin:true, entries:true, fill:true, find:true, findIndex:true, keys:true, }; %AddNamedProperty($Array.prototype,symbolUnscopables,a, 2|1); InstallFunctions($Array,2,$Array( "isArray",ArrayIsArray )); var b=%SpecialArrayFunctions(); var c=function(d,g,h){ var i=g; if(b.hasOwnProperty(d)){ i=b[d]; } if(!(h===(void 0))){ %FunctionSetLength(i,h); } return i; }; InstallFunctions($Array.prototype,2,$Array( "toString",c("toString",ArrayToString), "toLocaleString",c("toLocaleString",ArrayToLocaleString), "join",c("join",ArrayJoin), "pop",c("pop",ArrayPop), "push",c("push",ArrayPush,1), "concat",c("concat",ArrayConcatJS,1), "reverse",c("reverse",ArrayReverse), "shift",c("shift",ArrayShift), "unshift",c("unshift",ArrayUnshift,1), "slice",c("slice",ArraySlice,2), "splice",c("splice",ArraySplice,2), "sort",c("sort",ArraySort), "filter",c("filter",ArrayFilter,1), "forEach",c("forEach",ArrayForEach,1), "some",c("some",ArraySome,1), "every",c("every",ArrayEvery,1), "map",c("map",ArrayMap,1), "indexOf",c("indexOf",ArrayIndexOf,1), "lastIndexOf",c("lastIndexOf",ArrayLastIndexOf,1), "reduce",c("reduce",ArrayReduce,1), "reduceRight",c("reduceRight",ArrayReduceRight,1) )); %FinishArrayPrototypeSetup($Array.prototype); SetUpLockedPrototype(InternalArray,$Array(),$Array( "concat",c("concat",ArrayConcatJS), "indexOf",c("indexOf",ArrayIndexOf), "join",c("join",ArrayJoin), "pop",c("pop",ArrayPop), "push",c("push",ArrayPush), "splice",c("splice",ArraySplice) )); SetUpLockedPrototype(InternalPackedArray,$Array(),$Array( "join",c("join",ArrayJoin), "pop",c("pop",ArrayPop), "push",c("push",ArrayPush) )); } SetUpArray(); stringRY var $stringCharAt; var $stringIndexOf; var $stringSubstring; (function(){ %CheckIsBootstrapping(); var a=global.Array; var b=global.RegExp; var c=global.String; function StringConstructor(d){ if(%_ArgumentsLength()==0)d=''; if(%_IsConstructCall()){ %_SetValueOf(this,((typeof(%IS_VAR(d))==='string')?d:NonStringToString(d))); }else{ return(typeof(d)==='symbol')? %_CallFunction(d,$symbolToString):((typeof(%IS_VAR(d))==='string')?d:NonStringToString(d)); } } 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 StringCharAtJS(g){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.charAt"]); var h=%_StringCharAt(this,g); if(%_IsSmi(h)){ h=%_StringCharAt(((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)),(%_IsSmi(%IS_VAR(g))?g:%NumberToInteger(ToNumber(g)))); } return h; } function StringCharCodeAtJS(g){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.charCodeAt"]); var h=%_StringCharCodeAt(this,g); if(!%_IsSmi(h)){ h=%_StringCharCodeAt(((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)),(%_IsSmi(%IS_VAR(g))?g:%NumberToInteger(ToNumber(g)))); } return h; } function StringConcat(i){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.concat"]); var j=%_ArgumentsLength(); var k=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)); if(j===1){ return k+((typeof(%IS_VAR(i))==='string')?i:NonStringToString(i)); } var l=new InternalArray(j+1); l[0]=k; for(var m=0;m<j;m++){ var o=%_Arguments(m); l[m+1]=((typeof(%IS_VAR(o))==='string')?o:NonStringToString(o)); } return %StringBuilderConcat(l,j+1,""); } function StringIndexOfJS(q){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.indexOf"]); var r=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)); q=((typeof(%IS_VAR(q))==='string')?q:NonStringToString(q)); var t=0; if(%_ArgumentsLength()>1){ t=%_Arguments(1); t=(%_IsSmi(%IS_VAR(t))?t:%NumberToInteger(ToNumber(t))); if(t<0)t=0; if(t>r.length)t=r.length; } return %StringIndexOf(r,q,t); } function StringLastIndexOfJS(u){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.lastIndexOf"]); var w=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)); var z=w.length; var u=((typeof(%IS_VAR(u))==='string')?u:NonStringToString(u)); var A=u.length; var t=z-A; if(%_ArgumentsLength()>1){ var B=ToNumber(%_Arguments(1)); if(!(!%_IsSmi(%IS_VAR(B))&&!(B==B))){ B=(%_IsSmi(%IS_VAR(B))?B:%NumberToInteger(ToNumber(B))); if(B<0){ B=0; } if(B+A<z){ t=B; } } } if(t<0){ return-1; } return %StringLastIndexOf(w,u,t); } function StringLocaleCompareJS(i){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.localeCompare"]); return %StringLocaleCompare(((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)), ((typeof(%IS_VAR(i))==='string')?i:NonStringToString(i))); } function StringMatchJS(C){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.match"]); var r=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)); if((%_IsRegExp(C))){ var D=C.lastIndex; (%_IsSmi(%IS_VAR(D))?D:ToNumber(D)); if(!C.global)return $regexpExecNoTests(C,r,0); var h=%StringMatch(r,C,$regexpLastMatchInfo); if(h!==null)$regexpLastMatchInfoOverride=null; C.lastIndex=0; return h; } C=new b(C); return $regexpExecNoTests(C,r,0); } var E=['NFC','NFD','NFKC','NFKD']; function StringNormalizeJS(G){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.normalize"]); var G=G?((typeof(%IS_VAR(G))==='string')?G:NonStringToString(G)):'NFC'; var H=E.indexOf(G); if(H===-1){ throw new $RangeError('The normalization form should be one of ' +E.join(', ')+'.'); } return %_ValueOf(this); } var I=[2,"","",-1,-1]; function StringReplace(J,K){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.replace"]); var r=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)); if((%_IsRegExp(J))){ var D=J.lastIndex; (%_IsSmi(%IS_VAR(D))?D:ToNumber(D)); if(!(%_ClassOf(K)==='Function')){ K=((typeof(%IS_VAR(K))==='string')?K:NonStringToString(K)); if(!J.global){ var L=$regexpExec(J,r,0); if(L==null){ J.lastIndex=0 return r; } if(K.length==0){ return %_SubString(r,0,L[3])+ %_SubString(r,L[4],r.length) } return ExpandReplacement(K,r,$regexpLastMatchInfo, %_SubString(r,0,L[3]))+ %_SubString(r,L[4],r.length); } J.lastIndex=0; if($regexpLastMatchInfoOverride==null){ return %StringReplaceGlobalRegExpWithString( r,J,K,$regexpLastMatchInfo); }else{ var M=$regexpLastMatchInfo[1]; $regexpLastMatchInfo[1]=0; var N=%StringReplaceGlobalRegExpWithString( r,J,K,$regexpLastMatchInfo); if(%_IsSmi($regexpLastMatchInfo[1])){ $regexpLastMatchInfo[1]=M; }else{ $regexpLastMatchInfoOverride=null; } return N; } } if(J.global){ return StringReplaceGlobalRegExpWithFunction(r,J,K); } return StringReplaceNonGlobalRegExpWithFunction(r,J,K); } J=((typeof(%IS_VAR(J))==='string')?J:NonStringToString(J)); if(J.length==1&& r.length>0xFF&& (typeof(K)==='string')&& %StringIndexOf(K,'$',0)<0){ return %StringReplaceOneCharWithString(r,J,K); } var P=%StringIndexOf(r,J,0); if(P<0)return r; var Q=P+J.length; var h=%_SubString(r,0,P); if((%_ClassOf(K)==='Function')){ var R=%GetDefaultReceiver(K); h+=%_CallFunction(R,J,P,r,K); }else{ I[3]=P; I[4]=Q; h=ExpandReplacement(((typeof(%IS_VAR(K))==='string')?K:NonStringToString(K)), r, I, h); } return h+%_SubString(r,Q,r.length); } function ExpandReplacement(S,r,T,h){ var U=S.length; var W=%StringIndexOf(S,'$',0); if(W<0){ if(U>0)h+=S; return h; } if(W>0)h+=%_SubString(S,0,W); while(true){ var X='$'; var B=W+1; if(B<U){ var Y=%_StringCharCodeAt(S,B); if(Y==36){ ++B; h+='$'; }else if(Y==38){ ++B; h+= %_SubString(r,T[3],T[4]); }else if(Y==96){ ++B; h+=%_SubString(r,0,T[3]); }else if(Y==39){ ++B; h+=%_SubString(r,T[4],r.length); }else if(Y>=48&&Y<=57){ var Z=(Y-48)<<1; var aa=1; var ab=((T)[0]); if(B+1<S.length){ var W=%_StringCharCodeAt(S,B+1); if(W>=48&&W<=57){ var ac=Z*10+((W-48)<<1); if(ac<ab){ Z=ac; aa=2; } } } if(Z!=0&&Z<ab){ var P=T[(3+(Z))]; if(P>=0){ h+= %_SubString(r,P,T[(3+(Z+1))]); } B+=aa; }else{ h+='$'; } }else{ h+='$'; } }else{ h+='$'; } W=%StringIndexOf(S,'$',B); if(W<0){ if(B<U){ h+=%_SubString(S,B,U); } return h; } if(W>B){ h+=%_SubString(S,B,W); } } return h; } function CaptureString(S,ad,t){ var ae=t<<1; var P=ad[(3+(ae))]; if(P<0)return; var Q=ad[(3+(ae+1))]; return %_SubString(S,P,Q); } var af=new InternalArray(16); function StringReplaceGlobalRegExpWithFunction(r,C,K){ var ag=af; if(ag){ af=null; }else{ ag=new InternalArray(16); } var ah=%RegExpExecMultiple(C, r, $regexpLastMatchInfo, ag); C.lastIndex=0; if((ah===null)){ af=ag; return r; } var j=ah.length; if((($regexpLastMatchInfo)[0])==2){ var ai=0; var aj=new InternalPackedArray(null,0,r); var R=%GetDefaultReceiver(K); for(var m=0;m<j;m++){ var ak=ah[m]; if(%_IsSmi(ak)){ if(ak>0){ ai=(ak>>11)+(ak&0x7ff); }else{ ai=ah[++m]-ak; } }else{ aj[0]=ak; aj[1]=ai; $regexpLastMatchInfoOverride=aj; var al= %_CallFunction(R,ak,ai,r,K); ah[m]=((typeof(%IS_VAR(al))==='string')?al:NonStringToString(al)); ai+=ak.length; } } }else{ var R=%GetDefaultReceiver(K); for(var m=0;m<j;m++){ var ak=ah[m]; if(!%_IsSmi(ak)){ $regexpLastMatchInfoOverride=ak; var al=%Apply(K,R,ak,0,ak.length); ah[m]=((typeof(%IS_VAR(al))==='string')?al:NonStringToString(al)); } } } var h=%StringBuilderConcat(ah,ah.length,r); ag.length=0; af=ag; return h; } function StringReplaceNonGlobalRegExpWithFunction(r,C,K){ var T=$regexpExec(C,r,0); if((T===null)){ C.lastIndex=0; return r; } var t=T[3]; var h=%_SubString(r,0,t); var am=T[4]; var an=((T)[0])>>1; var ao; var R=%GetDefaultReceiver(K); if(an==1){ var ap=%_SubString(r,t,am); ao=%_CallFunction(R,ap,t,r,K); }else{ var aq=new InternalArray(an+2); for(var ar=0;ar<an;ar++){ aq[ar]=CaptureString(r,T,ar); } aq[ar]=t; aq[ar+1]=r; ao=%Apply(K,R,aq,0,ar+2); } h+=ao; return h+%_SubString(r,am,r.length); } function StringSearch(as){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.search"]); var C; if((typeof(as)==='string')){ C=%_GetFromCache(0,as); }else if((%_IsRegExp(as))){ C=as; }else{ C=new b(as); } var L=$regexpExec(C,((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)),0); if(L){ return L[3]; } return-1; } function StringSlice(P,Q){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.slice"]); var ap=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)); var at=ap.length; var au=(%_IsSmi(%IS_VAR(P))?P:%NumberToInteger(ToNumber(P))); var av=at; if(!(Q===(void 0))){ av=(%_IsSmi(%IS_VAR(Q))?Q:%NumberToInteger(ToNumber(Q))); } if(au<0){ au+=at; if(au<0){ au=0; } }else{ if(au>at){ return''; } } if(av<0){ av+=at; if(av<0){ return''; } }else{ if(av>at){ av=at; } } if(av<=au){ return''; } return %_SubString(ap,au,av); } function StringSplitJS(aw,ax){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.split"]); var r=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)); ax=((ax===(void 0)))?0xffffffff:(ax>>>0); var U=r.length; if(!(%_IsRegExp(aw))){ var ay=((typeof(%IS_VAR(aw))==='string')?aw:NonStringToString(aw)); if(ax===0)return[]; if((aw===(void 0)))return[r]; var az=ay.length; if(az===0)return %StringToArray(r,ax); var h=%StringSplit(r,ay,ax); return h; } if(ax===0)return[]; return StringSplitOnRegExp(r,aw,ax,U); } function StringSplitOnRegExp(r,aw,ax,U){ if(U===0){ if($regexpExec(aw,r,0,0)!=null){ return[]; } return[r]; } var aA=0; var aB=0; var aC=0; var h=new InternalArray(); outer_loop: while(true){ if(aB===U){ h[h.length]=%_SubString(r,aA,U); break; } var T=$regexpExec(aw,r,aB); if(T==null||U===(aC=T[3])){ h[h.length]=%_SubString(r,aA,U); break; } var aD=T[4]; if(aB===aD&&aD===aA){ aB++; continue; } h[h.length]=%_SubString(r,aA,aC); if(h.length===ax)break; var aE=((T)[0])+3; for(var m=3+2;m<aE;){ var P=T[m++]; var Q=T[m++]; if(Q!=-1){ h[h.length]=%_SubString(r,P,Q); }else{ h[h.length]=(void 0); } if(h.length===ax)break outer_loop; } aB=aA=aD; } var aF=[]; %MoveArrayContents(h,aF); return aF; } function StringSubstring(P,Q){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.subString"]); var ap=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)); var at=ap.length; var au=(%_IsSmi(%IS_VAR(P))?P:%NumberToInteger(ToNumber(P))); if(au<0){ au=0; }else if(au>at){ au=at; } var av=at; if(!(Q===(void 0))){ av=(%_IsSmi(%IS_VAR(Q))?Q:%NumberToInteger(ToNumber(Q))); if(av>at){ av=at; }else{ if(av<0)av=0; if(au>av){ var aG=av; av=au; au=aG; } } } return %_SubString(ap,au,av); } function StringSubstr(P,aH){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.substr"]); var ap=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)); var j; if((aH===(void 0))){ j=ap.length; }else{ j=(%_IsSmi(%IS_VAR(aH))?aH:%NumberToInteger(ToNumber(aH))); if(j<=0)return''; } if((P===(void 0))){ P=0; }else{ P=(%_IsSmi(%IS_VAR(P))?P:%NumberToInteger(ToNumber(P))); if(P>=ap.length)return''; if(P<0){ P+=ap.length; if(P<0)P=0; } } var Q=P+j; if(Q>ap.length)Q=ap.length; return %_SubString(ap,P,Q); } function StringToLowerCaseJS(){ 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 StringToUpperCaseJS(){ 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 StringTrimJS(){ 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); } function StringFromCharCode(aI){ var aH=%_ArgumentsLength(); if(aH==1){ if(!%_IsSmi(aI))aI=ToNumber(aI); return %_StringCharFromCode(aI&0xffff); } var aJ=%NewString(aH,true); var m; for(m=0;m<aH;m++){ var aI=%_Arguments(m); if(!%_IsSmi(aI))aI=ToNumber(aI)&0xffff; if(aI<0)aI=aI&0xffff; if(aI>0xff)break; %_OneByteSeqStringSetChar(m,aI,aJ); } if(m==aH)return aJ; aJ=%TruncateString(aJ,m); var aK=%NewString(aH-m,false); for(var ar=0;m<aH;m++,ar++){ var aI=%_Arguments(m); if(!%_IsSmi(aI))aI=ToNumber(aI)&0xffff; %_TwoByteSeqStringSetChar(ar,aI,aK); } return aJ+aK; } function HtmlEscape(aL){ return((typeof(%IS_VAR(aL))==='string')?aL:NonStringToString(aL)).replace(/"/g,"""); } function StringAnchor(aM){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.anchor"]); return"<a name=\""+HtmlEscape(aM)+"\">"+this+"</a>"; } function StringBig(){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.big"]); return"<big>"+this+"</big>"; } function StringBlink(){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.blink"]); return"<blink>"+this+"</blink>"; } function StringBold(){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.bold"]); return"<b>"+this+"</b>"; } function StringFixed(){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.fixed"]); return"<tt>"+this+"</tt>"; } function StringFontcolor(aN){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.fontcolor"]); return"<font color=\""+HtmlEscape(aN)+"\">"+this+"</font>"; } function StringFontsize(aO){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.fontsize"]); return"<font size=\""+HtmlEscape(aO)+"\">"+this+"</font>"; } function StringItalics(){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.italics"]); return"<i>"+this+"</i>"; } function StringLink(ap){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.link"]); return"<a href=\""+HtmlEscape(ap)+"\">"+this+"</a>"; } function StringSmall(){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.small"]); return"<small>"+this+"</small>"; } function StringStrike(){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.strike"]); return"<strike>"+this+"</strike>"; } function StringSub(){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.sub"]); return"<sub>"+this+"</sub>"; } function StringSup(){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.sup"]); return"<sup>"+this+"</sup>"; } function StringRepeat(aP){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.repeat"]); var ap=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)); var aH=ToInteger(aP); if(aH<0||aH>%_MaxSmi()){ throw MakeRangeError("invalid_count_value",[]); } var aQ=""; while(true){ if(aH&1)aQ+=ap; aH>>=1; if(aH===0)return aQ; ap+=ap; } } function StringStartsWith(aR){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.startsWith"]); var ap=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)); if((%_IsRegExp(aR))){ throw MakeTypeError("first_argument_not_regexp", ["String.prototype.startsWith"]); } var aS=((typeof(%IS_VAR(aR))==='string')?aR:NonStringToString(aR)); var g=0; if(%_ArgumentsLength()>1){ g=%_Arguments(1); g=ToInteger(g); } var at=ap.length; var P=$min($max(g,0),at); var aT=aS.length; if(aT+P>at){ return false; } return %StringIndexOf(ap,aS,P)===P; } function StringEndsWith(aR){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.endsWith"]); var ap=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)); if((%_IsRegExp(aR))){ throw MakeTypeError("first_argument_not_regexp", ["String.prototype.endsWith"]); } var aS=((typeof(%IS_VAR(aR))==='string')?aR:NonStringToString(aR)); var at=ap.length; var g=at; if(%_ArgumentsLength()>1){ var aU=%_Arguments(1); if(!(aU===(void 0))){ g=ToInteger(aU); } } var Q=$min($max(g,0),at); var aT=aS.length; var P=Q-aT; if(P<0){ return false; } return %StringLastIndexOf(ap,aS,P)===P; } function StringIncludes(aR){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.includes"]); var ap=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)); if((%_IsRegExp(aR))){ throw MakeTypeError("first_argument_not_regexp", ["String.prototype.includes"]); } var aS=((typeof(%IS_VAR(aR))==='string')?aR:NonStringToString(aR)); var g=0; if(%_ArgumentsLength()>1){ g=%_Arguments(1); g=ToInteger(g); } var at=ap.length; var P=$min($max(g,0),at); var aT=aS.length; if(aT+P>at){ return false; } return %StringIndexOf(ap,aS,P)!==-1; } function StringCodePointAt(g){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.codePointAt"]); var S=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)); var aO=S.length; g=(%_IsSmi(%IS_VAR(g))?g:%NumberToInteger(ToNumber(g))); if(g<0||g>=aO){ return(void 0); } var aV=%_StringCharCodeAt(S,g); if(aV<0xD800||aV>0xDBFF||g+1==aO){ return aV; } var aW=%_StringCharCodeAt(S,g+1); if(aW<0xDC00||aW>0xDFFF){ return aV; } return(aV-0xD800)*0x400+aW+0x2400; } function StringFromCodePoint(aX){ var aI; var U=%_ArgumentsLength(); var t; var h=""; for(t=0;t<U;t++){ aI=%_Arguments(t); if(!%_IsSmi(aI)){ aI=ToNumber(aI); } if(aI<0||aI>0x10FFFF||aI!==(%_IsSmi(%IS_VAR(aI))?aI:%NumberToInteger(ToNumber(aI)))){ throw MakeRangeError("invalid_code_point",[aI]); } if(aI<=0xFFFF){ h+=%_StringCharFromCode(aI); }else{ aI-=0x10000; h+=%_StringCharFromCode((aI>>>10)&0x3FF|0xD800); h+=%_StringCharFromCode(aI&0x3FF|0xDC00); } } return h; } function StringRaw(aY){ var aZ=%_ArgumentsLength(); var ba=ToObject(aY); var bb=ToObject(ba.raw); var bc=ToLength(bb.length); if(bc<=0)return""; var h=ToString(bb[0]); for(var m=1;m<bc;++m){ if(m<aZ){ h+=ToString(%_Arguments(m)); } h+=ToString(bb[m]); } return h; } %SetCode(c,StringConstructor); %FunctionSetPrototype(c,new c()); %AddNamedProperty( c.prototype,"constructor",c,2); InstallFunctions(c,2,a( "fromCharCode",StringFromCharCode, "fromCodePoint",StringFromCodePoint, "raw",StringRaw )); InstallFunctions(c.prototype,2,a( "valueOf",StringValueOf, "toString",StringToString, "charAt",StringCharAtJS, "charCodeAt",StringCharCodeAtJS, "codePointAt",StringCodePointAt, "concat",StringConcat, "endsWith",StringEndsWith, "includes",StringIncludes, "indexOf",StringIndexOfJS, "lastIndexOf",StringLastIndexOfJS, "localeCompare",StringLocaleCompareJS, "match",StringMatchJS, "normalize",StringNormalizeJS, "repeat",StringRepeat, "replace",StringReplace, "search",StringSearch, "slice",StringSlice, "split",StringSplitJS, "substring",StringSubstring, "substr",StringSubstr, "startsWith",StringStartsWith, "toLowerCase",StringToLowerCaseJS, "toLocaleLowerCase",StringToLocaleLowerCase, "toUpperCase",StringToUpperCaseJS, "toLocaleUpperCase",StringToLocaleUpperCase, "trim",StringTrimJS, "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 )); $stringCharAt=StringCharAtJS; $stringIndexOf=StringIndexOfJS; $stringSubstring=StringSubstring; })(); uri? "use strict"; (function(){ 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 isAlphaNumeric(b){ if(97<=b&&b<=122)return true; if(65<=b&&b<=90)return true; if(48<=b&&b<=57)return true; return false; } var c=0; function URIAddEncodedOctetToBuffer(d,g,h){ g[h++]=37; g[h++]=c[d>>4]; g[h++]=c[d&0x0F]; return h; } function URIEncodeOctets(i,g,h){ if(c===0){ c=[48,49,50,51,52,53,54,55,56,57, 65,66,67,68,69,70]; } h=URIAddEncodedOctetToBuffer(i[0],g,h); if(i[1])h=URIAddEncodedOctetToBuffer(i[1],g,h); if(i[2])h=URIAddEncodedOctetToBuffer(i[2],g,h); if(i[3])h=URIAddEncodedOctetToBuffer(i[3],g,h); return h; } function URIEncodeSingle(b,g,h){ var j=(b>>12)&0xF; var k=(b>>6)&63; var l=b&63; var i=new InternalArray(3); if(b<=0x007F){ i[0]=b; }else if(b<=0x07FF){ i[0]=k+192; i[1]=l+128; }else{ i[0]=j+224; i[1]=k+128; i[2]=l+128; } return URIEncodeOctets(i,g,h); } function URIEncodePair(m,o,g,h){ var q=((m>>6)&0xF)+1; var r=(m>>2)&0xF; var j=m&3; var k=(o>>6)&0xF; var l=o&63; var i=new InternalArray(4); i[0]=(q>>2)+240; i[1]=(((q&3)<<4)|r)+128; i[2]=((j<<4)|k)+128; i[3]=l+128; return URIEncodeOctets(i,g,h); } function URIHexCharsToCharCode(t,u){ var w=HexValueOf(t); var z=HexValueOf(u); if(w==-1||z==-1){ throw new $URIError("URI malformed"); } return(w<<4)|z; } function URIDecodeOctets(i,g,h){ var A; var B=i[0]; if(B<0x80){ A=B; }else if(B<0xc2){ throw new $URIError("URI malformed"); }else{ var C=i[1]; if(B<0xe0){ var D=B&0x1f; if((C<0x80)||(C>0xbf)){ throw new $URIError("URI malformed"); } var E=C&0x3f; A=(D<<6)+E; if(A<0x80||A>0x7ff){ throw new $URIError("URI malformed"); } }else{ var G=i[2]; if(B<0xf0){ var D=B&0x0f; if((C<0x80)||(C>0xbf)){ throw new $URIError("URI malformed"); } var E=C&0x3f; if((G<0x80)||(G>0xbf)){ throw new $URIError("URI malformed"); } var H=G&0x3f; A=(D<<12)+(E<<6)+H; if((A<0x800)||(A>0xffff)){ throw new $URIError("URI malformed"); } }else{ var I=i[3]; if(B<0xf8){ var D=(B&0x07); if((C<0x80)||(C>0xbf)){ throw new $URIError("URI malformed"); } var E=(C&0x3f); if((G<0x80)||(G>0xbf)){ throw new $URIError("URI malformed"); } var H=(G&0x3f); if((I<0x80)||(I>0xbf)){ throw new $URIError("URI malformed"); } var J=(I&0x3f); A=(D<<18)+(E<<12)+(H<<6)+J; if((A<0x10000)||(A>0x10ffff)){ throw new $URIError("URI malformed"); } }else{ throw new $URIError("URI malformed"); } } } } if(0xD800<=A&&A<=0xDFFF){ throw new $URIError("URI malformed"); } if(A<0x10000){ %_TwoByteSeqStringSetChar(h++,A,g); }else{ %_TwoByteSeqStringSetChar(h++,(A>>10)+0xd7c0,g); %_TwoByteSeqStringSetChar(h++,(A&0x3ff)+0xdc00,g); } return h; } function Encode(K,L){ var M=K.length; var N=new InternalArray(M); var h=0; for(var P=0;P<M;P++){ var m=K.charCodeAt(P); if(L(m)){ N[h++]=m; }else{ if(m>=0xDC00&&m<=0xDFFF)throw new $URIError("URI malformed"); if(m<0xD800||m>0xDBFF){ h=URIEncodeSingle(m,N,h); }else{ P++; if(P==M)throw new $URIError("URI malformed"); var o=K.charCodeAt(P); if(o<0xDC00||o>0xDFFF)throw new $URIError("URI malformed"); h=URIEncodePair(m,o,N,h); } } } var g=%NewString(N.length,true); for(var Q=0;Q<N.length;Q++){ %_OneByteSeqStringSetChar(Q,N[Q],g); } return g; } function Decode(K,R){ var M=K.length; var S=%NewString(M,true); var h=0; var P=0; for(;P<M;P++){ var a=K.charCodeAt(P); if(a==37){ if(P+2>=M)throw new $URIError("URI malformed"); var b=URIHexCharsToCharCode(K.charCodeAt(P+1),K.charCodeAt(P+2)); if(b>>7)break; if(R(b)){ %_OneByteSeqStringSetChar(h++,37,S); %_OneByteSeqStringSetChar(h++,K.charCodeAt(P+1),S); %_OneByteSeqStringSetChar(h++,K.charCodeAt(P+2),S); }else{ %_OneByteSeqStringSetChar(h++,b,S); } P+=2; }else{ if(a>0x7f)break; %_OneByteSeqStringSetChar(h++,a,S); } } S=%TruncateString(S,h); if(P==M)return S; var T=%NewString(M-P,false); h=0; for(;P<M;P++){ var a=K.charCodeAt(P); if(a==37){ if(P+2>=M)throw new $URIError("URI malformed"); var b=URIHexCharsToCharCode(K.charCodeAt(++P),K.charCodeAt(++P)); if(b>>7){ var U=0; while(((b<<++U)&0x80)!=0){} if(U==1||U>4)throw new $URIError("URI malformed"); var i=new InternalArray(U); i[0]=b; if(P+3*(U-1)>=M)throw new $URIError("URI malformed"); for(var Q=1;Q<U;Q++){ if(K.charAt(++P)!='%')throw new $URIError("URI malformed"); i[Q]=URIHexCharsToCharCode(K.charCodeAt(++P), K.charCodeAt(++P)); } h=URIDecodeOctets(i,T,h); }else if(R(b)){ %_TwoByteSeqStringSetChar(h++,37,T); %_TwoByteSeqStringSetChar(h++,K.charCodeAt(P-1),T); %_TwoByteSeqStringSetChar(h++,K.charCodeAt(P),T); }else{ %_TwoByteSeqStringSetChar(h++,b,T); } }else{ %_TwoByteSeqStringSetChar(h++,a,T); } } T=%TruncateString(T,h); return S+T; } function URIEscapeJS(W){ var X=ToString(W); return %URIEscape(X); } function URIUnescapeJS(W){ var X=ToString(W); return %URIUnescape(X); } function URIDecode(K){ var Y=function(b){ if(35<=b&&b<=36)return true; if(b==38)return true; if(43<=b&&b<=44)return true; if(b==47)return true; if(58<=b&&b<=59)return true; if(b==61)return true; if(63<=b&&b<=64)return true; return false; }; var Z=ToString(K); return Decode(Z,Y); } function URIDecodeComponent(aa){ var Y=function(b){return false;}; var Z=ToString(aa); return Decode(Z,Y); } function URIEncode(K){ var ab=function(b){ if(isAlphaNumeric(b))return true; if(b==33)return true; if(35<=b&&b<=36)return true; if(38<=b&&b<=47)return true; if(58<=b&&b<=59)return true; if(b==61)return true; if(63<=b&&b<=64)return true; if(b==95)return true; if(b==126)return true; return false; }; var Z=ToString(K); return Encode(Z,ab); } function URIEncodeComponent(aa){ var ab=function(b){ if(isAlphaNumeric(b))return true; if(b==33)return true; if(39<=b&&b<=42)return true; if(45<=b&&b<=46)return true; if(b==95)return true; if(b==126)return true; return false; }; var Z=ToString(aa); return Encode(Z,ab); } %CheckIsBootstrapping(); InstallFunctions(global,2,$Array( "escape",URIEscapeJS, "unescape",URIUnescapeJS, "decodeURI",URIDecode, "decodeURIComponent",URIDecodeComponent, "encodeURI",URIEncode, "encodeURIComponent",URIEncodeComponent )); })(); math? var rngstate; var $abs; var $exp; var $floor; var $max; var $min; (function(){ "use strict"; %CheckIsBootstrapping(); var a=global.Object; var b=global.Array; function MathAbs(c){ c=+c; if(c>0)return c; return 0-c; } function MathAcosJS(c){ return %_MathAcos(+c); } function MathAsinJS(c){ return %_MathAsin(+c); } function MathAtanJS(c){ return %_MathAtan(+c); } function MathAtan2JS(d,c){ d=+d; c=+c; return %_MathAtan2(d,c); } function MathCeil(c){ return-%_MathFloor(-c); } function MathExp(c){ return %MathExpRT(((typeof(%IS_VAR(c))==='number')?c:NonNumberToNumber(c))); } function MathFloorJS(c){ return %_MathFloor(+c); } function MathLog(c){ return %_MathLogRT(((typeof(%IS_VAR(c))==='number')?c:NonNumberToNumber(c))); } function MathMax(g,h){ var i=%_ArgumentsLength(); if(i==2){ g=((typeof(%IS_VAR(g))==='number')?g:NonNumberToNumber(g)); h=((typeof(%IS_VAR(h))==='number')?h:NonNumberToNumber(h)); if(h>g)return h; if(g>h)return g; if(g==h){ return(g===0&&%_IsMinusZero(g))?h:g; } return $NaN; } var j=-(1/0); for(var k=0;k<i;k++){ var l=%_Arguments(k); if(!(typeof(l)==='number'))l=NonNumberToNumber(l); if((!%_IsSmi(%IS_VAR(l))&&!(l==l))||l>j||(j===0&&l===0&&%_IsMinusZero(j))){ j=l; } } return j; } function MathMin(g,h){ var i=%_ArgumentsLength(); if(i==2){ g=((typeof(%IS_VAR(g))==='number')?g:NonNumberToNumber(g)); h=((typeof(%IS_VAR(h))==='number')?h:NonNumberToNumber(h)); if(h>g)return g; if(g>h)return h; if(g==h){ return(g===0&&%_IsMinusZero(g))?g:h; } return $NaN; } var j=(1/0); for(var k=0;k<i;k++){ var l=%_Arguments(k); if(!(typeof(l)==='number'))l=NonNumberToNumber(l); if((!%_IsSmi(%IS_VAR(l))&&!(l==l))||l<j||(j===0&&l===0&&%_IsMinusZero(l))){ j=l; } } return j; } function MathPowJS(c,d){ return %_MathPow(((typeof(%IS_VAR(c))==='number')?c:NonNumberToNumber(c)),((typeof(%IS_VAR(d))==='number')?d:NonNumberToNumber(d))); } function MathRandom(){ var m=(MathImul(18030,rngstate[0]&0xFFFF)+(rngstate[0]>>>16))|0; rngstate[0]=m; var o=(MathImul(36969,rngstate[1]&0xFFFF)+(rngstate[1]>>>16))|0; rngstate[1]=o; var c=((m<<16)+(o&0xFFFF))|0; return(c<0?(c+0x100000000):c)*2.3283064365386962890625e-10; } function MathRound(c){ return %RoundNumber(((typeof(%IS_VAR(c))==='number')?c:NonNumberToNumber(c))); } function MathSqrtJS(c){ return %_MathSqrt(+c); } function MathImul(c,d){ return %NumberImul(((typeof(%IS_VAR(c))==='number')?c:NonNumberToNumber(c)),((typeof(%IS_VAR(d))==='number')?d:NonNumberToNumber(d))); } function MathSign(c){ c=+c; if(c>0)return 1; if(c<0)return-1; return c; } function MathTrunc(c){ c=+c; if(c>0)return %_MathFloor(c); if(c<0)return-%_MathFloor(-c); return c; } function MathTanh(c){ if(!(typeof(c)==='number'))c=NonNumberToNumber(c); if(c===0)return c; if(!(%_IsSmi(%IS_VAR(c))||((c==c)&&(c!=1/0)&&(c!=-1/0))))return MathSign(c); var q=MathExp(c); var r=MathExp(-c); return(q-r)/(q+r); } function MathAsinh(c){ if(!(typeof(c)==='number'))c=NonNumberToNumber(c); if(c===0||!(%_IsSmi(%IS_VAR(c))||((c==c)&&(c!=1/0)&&(c!=-1/0))))return c; if(c>0)return MathLog(c+%_MathSqrt(c*c+1)); return-MathLog(-c+%_MathSqrt(c*c+1)); } function MathAcosh(c){ if(!(typeof(c)==='number'))c=NonNumberToNumber(c); if(c<1)return $NaN; if(!(%_IsSmi(%IS_VAR(c))||((c==c)&&(c!=1/0)&&(c!=-1/0))))return c; return MathLog(c+%_MathSqrt(c+1)*%_MathSqrt(c-1)); } function MathAtanh(c){ if(!(typeof(c)==='number'))c=NonNumberToNumber(c); if(c===0)return c; if(!(%_IsSmi(%IS_VAR(c))||((c==c)&&(c!=1/0)&&(c!=-1/0))))return $NaN; return 0.5*MathLog((1+c)/(1-c)); } function MathHypot(c,d){ var i=%_ArgumentsLength(); var t=new InternalArray(i); var u=0; for(var k=0;k<i;k++){ var l=%_Arguments(k); if(!(typeof(l)==='number'))l=NonNumberToNumber(l); if(l===(1/0)||l===-(1/0))return(1/0); l=MathAbs(l); if(l>u)u=l; t[k]=l; } if(u===0)u=1; var w=0; var z=0; for(var k=0;k<i;k++){ var l=t[k]/u; var A=l*l-z; var B=w+A; z=(B-w)-A; w=B; } return %_MathSqrt(w)*u; } function MathFroundJS(c){ return %MathFround(((typeof(%IS_VAR(c))==='number')?c:NonNumberToNumber(c))); } function MathClz32JS(c){ return %_MathClz32(c>>>0); } function MathCbrt(c){ if(!(typeof(c)==='number'))c=NonNumberToNumber(c); if(c==0||!(%_IsSmi(%IS_VAR(c))||((c==c)&&(c!=1/0)&&(c!=-1/0))))return c; return c>=0?CubeRoot(c):-CubeRoot(-c); } function CubeRoot(c){ var C=MathFloorJS(%_DoubleHi(c)/3)+0x2A9F7893; var D=%_ConstructDouble(C,0); D=(1.0/3.0)*(c/(D*D)+2*D); ; D=(1.0/3.0)*(c/(D*D)+2*D); ; D=(1.0/3.0)*(c/(D*D)+2*D); ; return(1.0/3.0)*(c/(D*D)+2*D); ; } function MathConstructor(){} var E=new MathConstructor(); %InternalSetPrototype(E,a.prototype); %AddNamedProperty(global,"Math",E,2); %FunctionSetInstanceClassName(MathConstructor,'Math'); %AddNamedProperty(E,symbolToStringTag,"Math",1|2); InstallConstants(E,b( "E",2.7182818284590452354, "LN10",2.302585092994046, "LN2",0.6931471805599453, "LOG2E",1.4426950408889634, "LOG10E",0.4342944819032518, "PI",3.1415926535897932, "SQRT1_2",0.7071067811865476, "SQRT2",1.4142135623730951 )); InstallFunctions(E,2,b( "random",MathRandom, "abs",MathAbs, "acos",MathAcosJS, "asin",MathAsinJS, "atan",MathAtanJS, "ceil",MathCeil, "exp",MathExp, "floor",MathFloorJS, "log",MathLog, "round",MathRound, "sqrt",MathSqrtJS, "atan2",MathAtan2JS, "pow",MathPowJS, "max",MathMax, "min",MathMin, "imul",MathImul, "sign",MathSign, "trunc",MathTrunc, "tanh",MathTanh, "asinh",MathAsinh, "acosh",MathAcosh, "atanh",MathAtanh, "hypot",MathHypot, "fround",MathFroundJS, "clz32",MathClz32JS, "cbrt",MathCbrt )); %SetInlineBuiltinFlag(MathAbs); %SetInlineBuiltinFlag(MathAcosJS); %SetInlineBuiltinFlag(MathAsinJS); %SetInlineBuiltinFlag(MathAtanJS); %SetInlineBuiltinFlag(MathAtan2JS); %SetInlineBuiltinFlag(MathCeil); %SetInlineBuiltinFlag(MathClz32JS); %SetInlineBuiltinFlag(MathFloorJS); %SetInlineBuiltinFlag(MathRandom); %SetInlineBuiltinFlag(MathSign); %SetInlineBuiltinFlag(MathSqrtJS); %SetInlineBuiltinFlag(MathTrunc); $abs=MathAbs; $exp=MathExp; $floor=MathFloorJS; $max=MathMax; $min=MathMin; })(); fdlibm? var kMath; var rempio2result; (function(){ "use strict"; %CheckIsBootstrapping(); var a=global.Math; var b=global.Array; function KernelTan(c,d,g){ var h; var i; var j=%_DoubleHi(c); var k=j&0x7fffffff; if(k<0x3e300000){ if(((k|%_DoubleLo(c))|(g+1))==0){ return 1/$abs(c); }else{ if(g==1){ return c; }else{ var i=c+d; var h=%_ConstructDouble(%_DoubleHi(i),0); var l=d-(h-c); var m=-1/i; var o=%_ConstructDouble(%_DoubleHi(m),0); var q=1+o*h; return o+m*(q+o*l); } } } if(k>=0x3fe59428){ if(c<0){ c=-c; d=-d; } h=kMath[32]-c; i=kMath[33]-d; c=h+i; d=0; } h=c*c; i=h*h; var r=kMath[19+1] +i*(kMath[19+3] +i*(kMath[19+5] + i*(kMath[19+7] +i*(kMath[19+9] +i*kMath[19+11] )))); var l=h*(kMath[19+2] +i*(kMath[19+4] +i*(kMath[19+6] + i*(kMath[19+8] +i*(kMath[19+10] +i*kMath[19+12] ))))); var q=h*c; r=d+h*(q*(r+l)+d); r=r+kMath[19+0] *q; i=c+r; if(k>=0x3fe59428){ return(1-((j>>30)&2))* (g-2.0*(c-(i*i/(i+g)-r))); } if(g==1){ return i; }else{ h=%_ConstructDouble(%_DoubleHi(i),0); l=r-(h-c); var m=-1/i; var o=%_ConstructDouble(%_DoubleHi(m),0); q=1+o*h; return o+m*(q+o*l); } } function MathSinSlow(c){ var t,u,w; var j=%_DoubleHi(c); var k=j&0x7fffffff; if(k<0x4002d97c){ if(j>0){ var h=c-kMath[1]; if(k!=0x3ff921fb){ u=h-kMath[2]; w=(h-u)-kMath[2]; }else{ h-=kMath[3]; u=h-kMath[4]; w=(h-u)-kMath[4]; } t=1; }else{ var h=c+kMath[1]; if(k!=0x3ff921fb){ u=h+kMath[2]; w=(h-u)+kMath[2]; }else{ h+=kMath[3]; u=h+kMath[4]; w=(h-u)+kMath[4]; } t=-1; } }else if(k<=0x413921fb){ var o=$abs(c); t=(o*kMath[0]+0.5)|0; var r=o-t*kMath[1]; var i=t*kMath[2]; u=r-i; if(k-(%_DoubleHi(u)&0x7ff00000)>0x1000000){ o=r; i=t*kMath[3]; r=o-i; i=t*kMath[4]-((o-r)-i); u=r-i; if(k-(%_DoubleHi(u)&0x7ff00000)>0x3100000){ o=r; i=t*kMath[5]; r=o-i; i=t*kMath[6]-((o-r)-i); u=r-i; } } w=(r-u)-i; if(j<0){ t=-t; u=-u; w=-w; } }else{ t=%RemPiO2(c,rempio2result); u=rempio2result[0]; w=rempio2result[1]; } ; var z=1-(t&2); if(t&1){ var k=%_DoubleHi(u)&0x7fffffff; var h=u*u; var r=h*(4.16666666666666019037e-02+h*(-1.38888888888741095749e-03+h*(2.48015872894767294178e-05+h*(-2.75573143513906633035e-07+h*(2.08757232129817482790e-09+h*-1.13596475577881948265e-11))))); if(k<0x3fd33333){ return(1-(0.5*h-(h*r-u*w)))*z; }else{ var A; if(k>0x3fe90000){ A=0.28125; }else{ A=%_ConstructDouble(%_DoubleHi(0.25*u),0); } var B=0.5*h-A; return(1-A-(B-(h*r-u*w)))*z; } ; }else{ var h=u*u; var l=h*u; var r=8.33333333332248946124e-03+h*(-1.98412698298579493134e-04+h*(2.75573137070700676789e-06+h*(-2.50507602534068634195e-08+h*1.58969099521155010221e-10))); return(u-((h*(0.5*w-l*r)-w)-l*-1.66666666666666324348e-01))*z; ; } } function MathCosSlow(c){ var t,u,w; var j=%_DoubleHi(c); var k=j&0x7fffffff; if(k<0x4002d97c){ if(j>0){ var h=c-kMath[1]; if(k!=0x3ff921fb){ u=h-kMath[2]; w=(h-u)-kMath[2]; }else{ h-=kMath[3]; u=h-kMath[4]; w=(h-u)-kMath[4]; } t=1; }else{ var h=c+kMath[1]; if(k!=0x3ff921fb){ u=h+kMath[2]; w=(h-u)+kMath[2]; }else{ h+=kMath[3]; u=h+kMath[4]; w=(h-u)+kMath[4]; } t=-1; } }else if(k<=0x413921fb){ var o=$abs(c); t=(o*kMath[0]+0.5)|0; var r=o-t*kMath[1]; var i=t*kMath[2]; u=r-i; if(k-(%_DoubleHi(u)&0x7ff00000)>0x1000000){ o=r; i=t*kMath[3]; r=o-i; i=t*kMath[4]-((o-r)-i); u=r-i; if(k-(%_DoubleHi(u)&0x7ff00000)>0x3100000){ o=r; i=t*kMath[5]; r=o-i; i=t*kMath[6]-((o-r)-i); u=r-i; } } w=(r-u)-i; if(j<0){ t=-t; u=-u; w=-w; } }else{ t=%RemPiO2(c,rempio2result); u=rempio2result[0]; w=rempio2result[1]; } ; if(t&1){ var z=(t&2)-1; var h=u*u; var l=h*u; var r=8.33333333332248946124e-03+h*(-1.98412698298579493134e-04+h*(2.75573137070700676789e-06+h*(-2.50507602534068634195e-08+h*1.58969099521155010221e-10))); return(u-((h*(0.5*w-l*r)-w)-l*-1.66666666666666324348e-01))*z; ; }else{ var z=1-(t&2); var k=%_DoubleHi(u)&0x7fffffff; var h=u*u; var r=h*(4.16666666666666019037e-02+h*(-1.38888888888741095749e-03+h*(2.48015872894767294178e-05+h*(-2.75573143513906633035e-07+h*(2.08757232129817482790e-09+h*-1.13596475577881948265e-11))))); if(k<0x3fd33333){ return(1-(0.5*h-(h*r-u*w)))*z; }else{ var A; if(k>0x3fe90000){ A=0.28125; }else{ A=%_ConstructDouble(%_DoubleHi(0.25*u),0); } var B=0.5*h-A; return(1-A-(B-(h*r-u*w)))*z; } ; } } function MathSin(c){ c=+c; if((%_DoubleHi(c)&0x7fffffff)<=0x3fe921fb){ var h=c*c; var l=h*c; var r=8.33333333332248946124e-03+h*(-1.98412698298579493134e-04+h*(2.75573137070700676789e-06+h*(-2.50507602534068634195e-08+h*1.58969099521155010221e-10))); return(c-((h*(0.5*0-l*r)-0)-l*-1.66666666666666324348e-01)); ; } return+MathSinSlow(c); } function MathCos(c){ c=+c; if((%_DoubleHi(c)&0x7fffffff)<=0x3fe921fb){ var k=%_DoubleHi(c)&0x7fffffff; var h=c*c; var r=h*(4.16666666666666019037e-02+h*(-1.38888888888741095749e-03+h*(2.48015872894767294178e-05+h*(-2.75573143513906633035e-07+h*(2.08757232129817482790e-09+h*-1.13596475577881948265e-11))))); if(k<0x3fd33333){ return(1-(0.5*h-(h*r-c*0))); }else{ var A; if(k>0x3fe90000){ A=0.28125; }else{ A=%_ConstructDouble(%_DoubleHi(0.25*c),0); } var B=0.5*h-A; return(1-A-(B-(h*r-c*0))); } ; } return+MathCosSlow(c); } function MathTan(c){ c=c*1; if((%_DoubleHi(c)&0x7fffffff)<=0x3fe921fb){ return KernelTan(c,0,1); } var t,u,w; var j=%_DoubleHi(c); var k=j&0x7fffffff; if(k<0x4002d97c){ if(j>0){ var h=c-kMath[1]; if(k!=0x3ff921fb){ u=h-kMath[2]; w=(h-u)-kMath[2]; }else{ h-=kMath[3]; u=h-kMath[4]; w=(h-u)-kMath[4]; } t=1; }else{ var h=c+kMath[1]; if(k!=0x3ff921fb){ u=h+kMath[2]; w=(h-u)+kMath[2]; }else{ h+=kMath[3]; u=h+kMath[4]; w=(h-u)+kMath[4]; } t=-1; } }else if(k<=0x413921fb){ var o=$abs(c); t=(o*kMath[0]+0.5)|0; var r=o-t*kMath[1]; var i=t*kMath[2]; u=r-i; if(k-(%_DoubleHi(u)&0x7ff00000)>0x1000000){ o=r; i=t*kMath[3]; r=o-i; i=t*kMath[4]-((o-r)-i); u=r-i; if(k-(%_DoubleHi(u)&0x7ff00000)>0x3100000){ o=r; i=t*kMath[5]; r=o-i; i=t*kMath[6]-((o-r)-i); u=r-i; } } w=(r-u)-i; if(j<0){ t=-t; u=-u; w=-w; } }else{ t=%RemPiO2(c,rempio2result); u=rempio2result[0]; w=rempio2result[1]; } ; return KernelTan(u,w,(t&1)?-1:1); } function MathLog1p(c){ c=c*1; var j=%_DoubleHi(c); var C=j&0x7fffffff; var D=1; var E=c; var G=1; var H=0; var I=c; if(j<0x3fda827a){ if(C>=0x3ff00000){ if(c===-1){ return-(1/0); }else{ return $NaN; } }else if(C<0x3c900000){ return c; }else if(C<0x3e200000){ return c-c*c*0.5; } if((j>0)||(j<=-0x402D413D)){ D=0; } } if(j>=0x7ff00000)return c; if(D!==0){ if(j<0x43400000){ I=1+c; G=%_DoubleHi(I); D=(G>>20)-1023; H=(D>0)?1-(I-c):c-(I-1); H=H/I; }else{ G=%_DoubleHi(I); D=(G>>20)-1023; } G=G&0xfffff; if(G<0x6a09e){ I=%_ConstructDouble(G|0x3ff00000,%_DoubleLo(I)); }else{ ++D; I=%_ConstructDouble(G|0x3fe00000,%_DoubleLo(I)); G=(0x00100000-G)>>2; } E=I-1; } var J=0.5*E*E; if(G===0){ if(E===0){ if(D===0){ return 0.0; }else{ return D*kMath[34]+(H+D*kMath[35]); } } var K=J*(1-kMath[36]*E); if(D===0){ return E-K; }else{ return D*kMath[34]-((K-(D*kMath[35]+H))-E); } } var q=E/(2+E); var h=q*q; var K=h*((kMath[37+0]) +h*((kMath[37+1]) +h* ((kMath[37+2]) +h*((kMath[37+3]) +h* ((kMath[37+4]) +h*((kMath[37+5]) +h*(kMath[37+6]) )))))); if(D===0){ return E-(J-q*(J+K)); }else{ return D*kMath[34]-((J-(q*(J+K)+(D*kMath[35]+H)))-E); } } function MathExpm1(c){ c=c*1; var d; var L; var M; var D; var o; var H; var j=%_DoubleHi(c); var N=j&0x80000000; var d=(N===0)?c:-c; j&=0x7fffffff; if(j>=0x4043687a){ if(j>=0x40862e42){ if(j>=0x7ff00000){ return(c===-(1/0))?-1:c; } if(c>kMath[44])return(1/0); } if(N!=0)return-1; } if(j>0x3fd62e42){ if(j<0x3ff0a2b2){ if(N===0){ L=c-kMath[34]; M=kMath[35]; D=1; }else{ L=c+kMath[34]; M=-kMath[35]; D=-1; } }else{ D=(kMath[45]*c+((N===0)?0.5:-0.5))|0; o=D; L=c-o*kMath[34]; M=o*kMath[35]; } c=L-M; H=(L-c)-M; }else if(j<0x3c900000){ return c; }else{ D=0; } var P=0.5*c; var Q=c*P; var R=1+Q*((kMath[46+0]) +Q*((kMath[46+1]) +Q* ((kMath[46+2]) +Q*((kMath[46+3]) +Q*(kMath[46+4]) )))); o=3-R*P; var S=Q*((R-o)/(6-c*o)); if(D===0){ return c-(c*S-Q); }else{ S=(c*(S-H)-H); S-=Q; if(D===-1)return 0.5*(c-S)-0.5; if(D===1){ if(c<-0.25)return-2*(S-(c+0.5)); return 1+2*(c-S); } if(D<=-2||D>56){ d=1-(S-c); d=%_ConstructDouble(%_DoubleHi(d)+(D<<20),%_DoubleLo(d)); return d-1; } if(D<20){ o=%_ConstructDouble(0x3ff00000-(0x200000>>D),0); d=o-(S-c); d=%_ConstructDouble(%_DoubleHi(d)+(D<<20),%_DoubleLo(d)); }else{ o=%_ConstructDouble((0x3ff-D)<<20,0); d=c-(S+o); d+=1; d=%_ConstructDouble(%_DoubleHi(d)+(D<<20),%_DoubleLo(d)); } } return d; } function MathSinh(c){ c=c*1; var T=(c<0)?-0.5:0.5; var C=$abs(c); if(C<22){ if(C<3.725290298461914e-9)return c; var o=MathExpm1(C); if(C<1)return T*(2*o-o*o/(o+1)); return T*(o+o/(o+1)); } if(C<709.7822265625)return T*$exp(C); if(C<=kMath[51]){ var i=$exp(0.5*C); var o=T*i; return o*i; } return c*(1/0); } function MathCosh(c){ c=c*1; var k=%_DoubleHi(c)&0x7fffffff; if(k<0x3fd62e43){ var o=MathExpm1($abs(c)); var i=1+o; if(k<0x3c800000)return i; return 1+(o*o)/(i+i); } if(k<0x40360000){ var o=$exp($abs(c)); return 0.5*o+0.5/o; } if(k<0x40862e42)return 0.5*$exp($abs(c)); if($abs(c)<=kMath[51]){ var i=$exp(0.5*$abs(c)); var o=0.5*i; return o*i; } if((!%_IsSmi(%IS_VAR(c))&&!(c==c)))return c; return(1/0); } function MathLog10(c){ c=c*1; var j=%_DoubleHi(c); var U=%_DoubleLo(c); var D=0; if(j<0x00100000){ if(((j&0x7fffffff)|U)===0)return-(1/0); if(j<0)return $NaN; D-=54; c*=18014398509481984; j=%_DoubleHi(c); U=%_DoubleLo(c); } if(j>=0x7ff00000)return c; D+=(j>>20)-1023; i=(D&0x80000000)>>31; j=(j&0x000fffff)|((0x3ff-i)<<20); d=D+i; c=%_ConstructDouble(j,U); h=d*kMath[54]+kMath[52]*%_MathLogRT(c); return h+d*kMath[53]; } function MathLog2(c){ c=c*1; var C=$abs(c); var j=%_DoubleHi(c); var U=%_DoubleLo(c); var k=j&0x7fffffff; if((k|U)==0)return-(1/0); if(j<0)return $NaN; if(k>=0x7ff00000)return c; var t=0; if(k<0x00100000){ C*=9007199254740992; t-=53; k=%_DoubleHi(C); } t+=(k>>20)-0x3ff; var W=k&0x000fffff; k=W|0x3ff00000; var X=1; var Y=0; var Z=0; if(W>0x3988e){ if(W<0xbb67a){ X=1.5; Y=kMath[64]; Z=kMath[65]; }else{ t+=1; k-=0x00100000; } } C=%_ConstructDouble(k,%_DoubleLo(C)); var I=C-X; var l=1/(C+X); var aa=I*l; var ab=%_ConstructDouble(%_DoubleHi(aa),0); var ac=%_ConstructDouble(%_DoubleHi(C+X),0) var ad=C-(ac-X); var ae=l*((I-ab*ac)-ab*ad); var af=aa*aa; var r=af*af*((kMath[55+0]) +af*((kMath[55+1]) +af*((kMath[55+2]) +af*( (kMath[55+3]) +af*((kMath[55+4]) +af*(kMath[55+5]) ))))); r+=ae*(ab+aa); af=ab*ab; ac=%_ConstructDouble(%_DoubleHi(3.0+af+r),0); ad=r-((ac-3.0)-af); I=ab*ac; l=ae*ac+ad*aa; p_h=%_ConstructDouble(%_DoubleHi(I+l),0); p_l=l-(p_h-I); z_h=kMath[62]*p_h; z_l=kMath[63]*p_h+p_l*kMath[61]+Z; var o=t; var ag=%_ConstructDouble(%_DoubleHi(((z_h+z_l)+Y)+o),0); var ah=z_l-(((ag-o)-Y)-z_h); return ag+ah; } InstallFunctions(a,2,b( "cos",MathCos, "sin",MathSin, "tan",MathTan, "sinh",MathSinh, "cosh",MathCosh, "log10",MathLog10, "log2",MathLog2, "log1p",MathLog1p, "expm1",MathExpm1 )); %SetInlineBuiltinFlag(MathSin); %SetInlineBuiltinFlag(MathCos); })(); dateE? var $createDate; (function(){ "use strict"; %CheckIsBootstrapping(); var a=global.Date; function ThrowDateTypeError(){ throw new $TypeError('this is not a Date object.'); } var b=$NaN; var c; function LocalTimezone(d){ if((!%_IsSmi(%IS_VAR(d))&&!(d==d)))return""; CheckDateCacheCurrent(); if(d==b){ return c; } var g=%DateLocalTimezone(d); b=d; c=g; return g; } function UTC(h){ if((!%_IsSmi(%IS_VAR(h))&&!(h==h)))return h; return %DateToUTC(h); } function MakeTime(i,j,k,l){ if(!$isFinite(i))return $NaN; if(!$isFinite(j))return $NaN; if(!$isFinite(k))return $NaN; if(!$isFinite(l))return $NaN; return(%_IsSmi(%IS_VAR(i))?i:%NumberToInteger(ToNumber(i)))*3600000 +(%_IsSmi(%IS_VAR(j))?j:%NumberToInteger(ToNumber(j)))*60000 +(%_IsSmi(%IS_VAR(k))?k:%NumberToInteger(ToNumber(k)))*1000 +(%_IsSmi(%IS_VAR(l))?l:%NumberToInteger(ToNumber(l))); } function TimeInYear(m){ return DaysInYear(m)*86400000; } function MakeDay(m,o,q){ if(!$isFinite(m)||!$isFinite(o)||!$isFinite(q))return $NaN; m=(%_IsSmi(%IS_VAR(m))?m:%NumberToIntegerMapMinusZero(ToNumber(m))); o=(%_IsSmi(%IS_VAR(o))?o:%NumberToIntegerMapMinusZero(ToNumber(o))); q=(%_IsSmi(%IS_VAR(q))?q:%NumberToIntegerMapMinusZero(ToNumber(q))); if(m<-1000000||m>1000000|| o<-10000000||o>10000000){ return $NaN; } return %DateMakeDay(m|0,o|0)+q-1; } function MakeDate(r,h){ var h=r*86400000+h; if($abs(h)>8640002592000000)return $NaN; return h; } function TimeClip(h){ if(!$isFinite(h))return $NaN; if($abs(h)>8640000000000000)return $NaN; return(%_IsSmi(%IS_VAR(h))?h:%NumberToInteger(ToNumber(h))); } var t={ time:0, string:null }; function DateConstructor(m,o,q,u,w,z,l){ if(!%_IsConstructCall()){ return(new a()).toString(); } var A=%_ArgumentsLength(); var B; if(A==0){ B=%DateCurrentTime(); (%DateSetValue(this,B,1)); }else if(A==1){ if((typeof(m)==='number')){ B=m; }else if((typeof(m)==='string')){ CheckDateCacheCurrent(); var C=t; if(C.string===m){ B=C.time; }else{ B=DateParse(m); if(!(!%_IsSmi(%IS_VAR(B))&&!(B==B))){ C.time=B; C.string=m; } } }else{ var h=ToPrimitive(m,1); B=(typeof(h)==='string')?DateParse(h):ToNumber(h); } (%DateSetValue(this,B,1)); }else{ m=ToNumber(m); o=ToNumber(o); q=A>2?ToNumber(q):1; u=A>3?ToNumber(u):0; w=A>4?ToNumber(w):0; z=A>5?ToNumber(z):0; l=A>6?ToNumber(l):0; m=(!(!%_IsSmi(%IS_VAR(m))&&!(m==m))&& 0<=(%_IsSmi(%IS_VAR(m))?m:%NumberToInteger(ToNumber(m)))&& (%_IsSmi(%IS_VAR(m))?m:%NumberToInteger(ToNumber(m)))<=99)?1900+(%_IsSmi(%IS_VAR(m))?m:%NumberToInteger(ToNumber(m))):m; var r=MakeDay(m,o,q); var h=MakeTime(u,w,z,l); B=MakeDate(r,h); (%DateSetValue(this,B,0)); } } var D=['Sun','Mon','Tue','Wed','Thu','Fri','Sat']; var E=['Jan','Feb','Mar','Apr','May','Jun', 'Jul','Aug','Sep','Oct','Nov','Dec']; function TwoDigitString(B){ return B<10?"0"+B:""+B; } function DateString(q){ return D[(%_DateField(q,4))]+' ' +E[(%_DateField(q,2))]+' ' +TwoDigitString((%_DateField(q,3)))+' ' +(%_DateField(q,1)); } var G=['Sunday','Monday','Tuesday','Wednesday', 'Thursday','Friday','Saturday']; var H=['January','February','March','April','May','June', 'July','August','September','October','November','December']; function LongDateString(q){ return G[(%_DateField(q,4))]+', ' +H[(%_DateField(q,2))]+' ' +TwoDigitString((%_DateField(q,3)))+', ' +(%_DateField(q,1)); } function TimeString(q){ return TwoDigitString((%_DateField(q,5)))+':' +TwoDigitString((%_DateField(q,6)))+':' +TwoDigitString((%_DateField(q,7))); } function TimeStringUTC(q){ return TwoDigitString((%_DateField(q,15)))+':' +TwoDigitString((%_DateField(q,16)))+':' +TwoDigitString((%_DateField(q,17))); } function LocalTimezoneString(q){ var g=LocalTimezone((%_DateField(q,0))); var I=-(%_DateField(q,21)); var J=(I>=0)?1:-1; var u=$floor((J*I)/60); var j=$floor((J*I)%60); var K=' GMT'+((J==1)?'+':'-')+ TwoDigitString(u)+TwoDigitString(j); return K+' ('+g+')'; } function DatePrintString(q){ return DateString(q)+' '+TimeString(q); } var L=$Array(8); function DateParse(M){ var N=%DateParseString(ToString(M),L); if((N===null))return $NaN; var r=MakeDay(N[0],N[1],N[2]); var h=MakeTime(N[3],N[4],N[5],N[6]); var q=MakeDate(r,h); if((N[7]===null)){ return TimeClip(UTC(q)); }else{ return TimeClip(q-N[7]*1000); } } function DateUTC(m,o,q,u,w,z,l){ m=ToNumber(m); o=ToNumber(o); var A=%_ArgumentsLength(); q=A>2?ToNumber(q):1; u=A>3?ToNumber(u):0; w=A>4?ToNumber(w):0; z=A>5?ToNumber(z):0; l=A>6?ToNumber(l):0; m=(!(!%_IsSmi(%IS_VAR(m))&&!(m==m))&& 0<=(%_IsSmi(%IS_VAR(m))?m:%NumberToInteger(ToNumber(m)))&& (%_IsSmi(%IS_VAR(m))?m:%NumberToInteger(ToNumber(m)))<=99)?1900+(%_IsSmi(%IS_VAR(m))?m:%NumberToInteger(ToNumber(m))):m; var r=MakeDay(m,o,q); var h=MakeTime(u,w,z,l); return TimeClip(MakeDate(r,h)); } function DateNow(){ return %DateCurrentTime(); } function DateToString(){ var d=(%_DateField(this,0)) if((!%_IsSmi(%IS_VAR(d))&&!(d==d)))return'Invalid Date'; var P=LocalTimezoneString(this) return DatePrintString(this)+P; } function DateToDateString(){ var d=(%_DateField(this,0)); if((!%_IsSmi(%IS_VAR(d))&&!(d==d)))return'Invalid Date'; return DateString(this); } function DateToTimeString(){ var d=(%_DateField(this,0)); if((!%_IsSmi(%IS_VAR(d))&&!(d==d)))return'Invalid Date'; var P=LocalTimezoneString(this); return TimeString(this)+P; } function DateToLocaleString(){ return %_CallFunction(this,DateToString); } function DateToLocaleDateString(){ var d=(%_DateField(this,0)); if((!%_IsSmi(%IS_VAR(d))&&!(d==d)))return'Invalid Date'; return LongDateString(this); } function DateToLocaleTimeString(){ var d=(%_DateField(this,0)); if((!%_IsSmi(%IS_VAR(d))&&!(d==d)))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(l){ if(%_ClassOf(this)!=='Date')ThrowDateTypeError(); (%DateSetValue(this,ToNumber(l),1)); return(%_DateField(this,0)); } function DateSetMilliseconds(l){ var d=(%_DateField(this,0)+%_DateField(this,21)); l=ToNumber(l); var h=MakeTime((%_DateField(this,5)),(%_DateField(this,6)),(%_DateField(this,7)),l); return(%DateSetValue(this,MakeDate((%_DateField(this,9)),h),0)); } function DateSetUTCMilliseconds(l){ var d=(%_DateField(this,0)); l=ToNumber(l); var h=MakeTime((%_DateField(this,15)), (%_DateField(this,16)), (%_DateField(this,17)), l); return(%DateSetValue(this,MakeDate((%_DateField(this,19)),h),1)); } function DateSetSeconds(k,l){ var d=(%_DateField(this,0)+%_DateField(this,21)); k=ToNumber(k); l=%_ArgumentsLength()<2?(%_DateField(this,8)):ToNumber(l); var h=MakeTime((%_DateField(this,5)),(%_DateField(this,6)),k,l); return(%DateSetValue(this,MakeDate((%_DateField(this,9)),h),0)); } function DateSetUTCSeconds(k,l){ var d=(%_DateField(this,0)); k=ToNumber(k); l=%_ArgumentsLength()<2?(%_DateField(this,18)):ToNumber(l); var h=MakeTime((%_DateField(this,15)),(%_DateField(this,16)),k,l); return(%DateSetValue(this,MakeDate((%_DateField(this,19)),h),1)); } function DateSetMinutes(j,k,l){ var d=(%_DateField(this,0)+%_DateField(this,21)); j=ToNumber(j); var A=%_ArgumentsLength(); k=A<2?(%_DateField(this,7)):ToNumber(k); l=A<3?(%_DateField(this,8)):ToNumber(l); var h=MakeTime((%_DateField(this,5)),j,k,l); return(%DateSetValue(this,MakeDate((%_DateField(this,9)),h),0)); } function DateSetUTCMinutes(j,k,l){ var d=(%_DateField(this,0)); j=ToNumber(j); var A=%_ArgumentsLength(); k=A<2?(%_DateField(this,17)):ToNumber(k); l=A<3?(%_DateField(this,18)):ToNumber(l); var h=MakeTime((%_DateField(this,15)),j,k,l); return(%DateSetValue(this,MakeDate((%_DateField(this,19)),h),1)); } function DateSetHours(i,j,k,l){ var d=(%_DateField(this,0)+%_DateField(this,21)); i=ToNumber(i); var A=%_ArgumentsLength(); j=A<2?(%_DateField(this,6)):ToNumber(j); k=A<3?(%_DateField(this,7)):ToNumber(k); l=A<4?(%_DateField(this,8)):ToNumber(l); var h=MakeTime(i,j,k,l); return(%DateSetValue(this,MakeDate((%_DateField(this,9)),h),0)); } function DateSetUTCHours(i,j,k,l){ var d=(%_DateField(this,0)); i=ToNumber(i); var A=%_ArgumentsLength(); j=A<2?(%_DateField(this,16)):ToNumber(j); k=A<3?(%_DateField(this,17)):ToNumber(k); l=A<4?(%_DateField(this,18)):ToNumber(l); var h=MakeTime(i,j,k,l); return(%DateSetValue(this,MakeDate((%_DateField(this,19)),h),1)); } function DateSetDate(q){ var d=(%_DateField(this,0)+%_DateField(this,21)); q=ToNumber(q); var r=MakeDay((%_DateField(this,1)),(%_DateField(this,2)),q); return(%DateSetValue(this,MakeDate(r,(%_DateField(this,10))),0)); } function DateSetUTCDate(q){ var d=(%_DateField(this,0)); q=ToNumber(q); var r=MakeDay((%_DateField(this,11)),(%_DateField(this,12)),q); return(%DateSetValue(this,MakeDate(r,(%_DateField(this,20))),1)); } function DateSetMonth(o,q){ var d=(%_DateField(this,0)+%_DateField(this,21)); o=ToNumber(o); q=%_ArgumentsLength()<2?(%_DateField(this,3)):ToNumber(q); var r=MakeDay((%_DateField(this,1)),o,q); return(%DateSetValue(this,MakeDate(r,(%_DateField(this,10))),0)); } function DateSetUTCMonth(o,q){ var d=(%_DateField(this,0)); o=ToNumber(o); q=%_ArgumentsLength()<2?(%_DateField(this,13)):ToNumber(q); var r=MakeDay((%_DateField(this,11)),o,q); return(%DateSetValue(this,MakeDate(r,(%_DateField(this,20))),1)); } function DateSetFullYear(m,o,q){ var d=(%_DateField(this,0)+%_DateField(this,21)); m=ToNumber(m); var A=%_ArgumentsLength(); var h; if((!%_IsSmi(%IS_VAR(d))&&!(d==d))){ o=A<2?0:ToNumber(o); q=A<3?1:ToNumber(q); h=0; }else{ o=A<2?(%_DateField(this,2)):ToNumber(o); q=A<3?(%_DateField(this,3)):ToNumber(q); h=(%_DateField(this,10)); } var r=MakeDay(m,o,q); return(%DateSetValue(this,MakeDate(r,h),0)); } function DateSetUTCFullYear(m,o,q){ var d=(%_DateField(this,0)); m=ToNumber(m); var A=%_ArgumentsLength(); var h; if((!%_IsSmi(%IS_VAR(d))&&!(d==d))){ o=A<2?0:ToNumber(o); q=A<3?1:ToNumber(q); h=0; }else{ o=A<2?(%_DateField(this,12)):ToNumber(o); q=A<3?(%_DateField(this,13)):ToNumber(q); h=(%_DateField(this,20)); } var r=MakeDay(m,o,q); return(%DateSetValue(this,MakeDate(r,h),1)); } function DateToUTCString(){ var d=(%_DateField(this,0)); if((!%_IsSmi(%IS_VAR(d))&&!(d==d)))return'Invalid Date'; return D[(%_DateField(this,14))]+', ' +TwoDigitString((%_DateField(this,13)))+' ' +E[(%_DateField(this,12))]+' ' +(%_DateField(this,11))+' ' +TimeStringUTC(this)+' GMT'; } function DateGetYear(){ return(%_DateField(this,1))-1900; } function DateSetYear(m){ if(%_ClassOf(this)!=='Date')ThrowDateTypeError(); m=ToNumber(m); if((!%_IsSmi(%IS_VAR(m))&&!(m==m)))return(%DateSetValue(this,$NaN,1)); m=(0<=(%_IsSmi(%IS_VAR(m))?m:%NumberToInteger(ToNumber(m)))&&(%_IsSmi(%IS_VAR(m))?m:%NumberToInteger(ToNumber(m)))<=99) ?1900+(%_IsSmi(%IS_VAR(m))?m:%NumberToInteger(ToNumber(m))):m; var d=(%_DateField(this,0)+%_DateField(this,21)); var o,q,h; if((!%_IsSmi(%IS_VAR(d))&&!(d==d))){ o=0; q=1; h=0; }else{ o=(%_DateField(this,2)); q=(%_DateField(this,3)); h=(%_DateField(this,10)); } var r=MakeDay(m,o,q); return(%DateSetValue(this,MakeDate(r,h),0)); } function DateToGMTString(){ return %_CallFunction(this,DateToUTCString); } function PadInt(Q,R){ if(R==1)return Q; return Q<%_MathPow(10,R-1)?'0'+PadInt(Q,R-1):Q; } function DateToISOString(){ var d=(%_DateField(this,0)); if((!%_IsSmi(%IS_VAR(d))&&!(d==d)))throw MakeRangeError("invalid_time_value",[]); var m=this.getUTCFullYear(); var S; if(m>=0&&m<=9999){ S=PadInt(m,4); }else{ if(m<0){ S="-"+PadInt(-m,6); }else{ S="+"+PadInt(m,6); } } return S+ '-'+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(T){ var U=ToObject(this); var W=DefaultNumber(U); if((typeof(W)==='number')&&!(%_IsSmi(%IS_VAR(W))||((W==W)&&(W!=1/0)&&(W!=-1/0)))){ return null; } return U.toISOString(); } var X; var Y=$NaN; function CheckDateCacheCurrent(){ if(!X){ X=%DateCacheVersion(); if(!X)return; } if(X[0]==Y){ return; } Y=X[0]; b=$NaN; c=(void 0); t.time=$NaN; t.string=null; } function CreateDate(h){ var q=new a(); q.setTime(h); return q; } %SetCode(a,DateConstructor); %FunctionSetPrototype(a,new a($NaN)); InstallFunctions(a,2,$Array( "UTC",DateUTC, "parse",DateParse, "now",DateNow )); %AddNamedProperty(a.prototype,"constructor",a,2); InstallFunctions(a.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 )); $createDate=CreateDate; })(); regexp}o var $regexpExec; var $regexpExecNoTests; var $regexpLastMatchInfo; var $regexpLastMatchInfoOverride; var harmony_regexps=false; var harmony_unicode_regexps=false; (function(){ %CheckIsBootstrapping(); var a=global.RegExp; var b=global.Array; $regexpLastMatchInfo=new InternalPackedArray( 2, "", (void 0), 0, 0 ); $regexpLastMatchInfoOverride=null; function DoConstructRegExp(c,d,g){ if((%_IsRegExp(d))){ if(!(g===(void 0))){ throw MakeTypeError('regexp_flags',[]); } g=(d.global?'g':'') +(d.ignoreCase?'i':'') +(d.multiline?'m':''); if(harmony_unicode_regexps) g+=(d.unicode?'u':''); if(harmony_regexps) g+=(d.sticky?'y':''); d=d.source; } d=(d===(void 0))?'':ToString(d); g=(g===(void 0))?'':ToString(g); %RegExpInitializeAndCompile(c,d,g); } function RegExpConstructor(d,g){ if(%_IsConstructCall()){ DoConstructRegExp(this,d,g); }else{ if((%_IsRegExp(d))&&(g===(void 0))){ return d; } return new a(d,g); } } function RegExpCompileJS(d,g){ if(this==a.prototype){ throw MakeTypeError('incompatible_method_receiver', ['RegExp.prototype.compile',this]); } if((d===(void 0))&&%_ArgumentsLength()!=0){ DoConstructRegExp(this,'undefined',g); }else{ DoConstructRegExp(this,d,g); } } function DoRegExpExec(h,i,j){ var k=%_RegExpExec(h,i,j,$regexpLastMatchInfo); if(k!==null)$regexpLastMatchInfoOverride=null; return k; } function RegExpExecNoTests(h,i,l){ var m=%_RegExpExec(h,i,l,$regexpLastMatchInfo); if(m!==null){ $regexpLastMatchInfoOverride=null; var o=((m)[0])>>1; var l=m[3]; var q=m[4]; var r=%_SubString(i,l,q); var k=%_RegExpConstructResult(o,l,i); k[0]=r; if(o==1)return k; var t=3+2; for(var u=1;u<o;u++){ l=m[t++]; if(l!=-1){ q=m[t]; k[u]=%_SubString(i,l,q); } t++; } return k; ; } h.lastIndex=0; return null; } function RegExpExecJS(i){ if(!(%_IsRegExp(this))){ throw MakeTypeError('incompatible_method_receiver', ['RegExp.prototype.exec',this]); } i=((typeof(%IS_VAR(i))==='string')?i:NonStringToString(i)); var w=this.lastIndex; var u=(%_IsSmi(%IS_VAR(w))?w:%NumberToInteger(ToNumber(w))); var z=this.global||(harmony_regexps&&this.sticky); if(z){ if(u<0||u>i.length){ this.lastIndex=0; return null; } }else{ u=0; } var A=%_RegExpExec(this,i,u,$regexpLastMatchInfo); if((A===null)){ this.lastIndex=0; return null; } $regexpLastMatchInfoOverride=null; if(z){ this.lastIndex=$regexpLastMatchInfo[4]; } var o=((A)[0])>>1; var l=A[3]; var q=A[4]; var r=%_SubString(i,l,q); var k=%_RegExpConstructResult(o,l,i); k[0]=r; if(o==1)return k; var t=3+2; for(var u=1;u<o;u++){ l=A[t++]; if(l!=-1){ q=A[t]; k[u]=%_SubString(i,l,q); } t++; } return k; ; } var B; var C; function RegExpTest(i){ if(!(%_IsRegExp(this))){ throw MakeTypeError('incompatible_method_receiver', ['RegExp.prototype.test',this]); } i=((typeof(%IS_VAR(i))==='string')?i:NonStringToString(i)); var w=this.lastIndex; var u=(%_IsSmi(%IS_VAR(w))?w:%NumberToInteger(ToNumber(w))); if(this.global||(harmony_regexps&&this.sticky)){ if(u<0||u>i.length){ this.lastIndex=0; return false; } var A=%_RegExpExec(this,i,u,$regexpLastMatchInfo); if((A===null)){ this.lastIndex=0; return false; } $regexpLastMatchInfoOverride=null; this.lastIndex=$regexpLastMatchInfo[4]; return true; }else{ var h=this; if(h.source.length>=3&& %_StringCharCodeAt(h.source,0)==46&& %_StringCharCodeAt(h.source,1)==42&& %_StringCharCodeAt(h.source,2)!=63){ h=TrimRegExp(h); } var A=%_RegExpExec(h,i,0,$regexpLastMatchInfo); if((A===null)){ this.lastIndex=0; return false; } $regexpLastMatchInfoOverride=null; return true; } } function TrimRegExp(h){ if(!%_ObjectEquals(B,h)){ B=h; C= new a(%_SubString(h.source,2,h.source.length), (h.ignoreCase?h.multiline?"im":"i" :h.multiline?"m":"")); } return C; } function RegExpToString(){ if(!(%_IsRegExp(this))){ throw MakeTypeError('incompatible_method_receiver', ['RegExp.prototype.toString',this]); } var k='/'+this.source+'/'; if(this.global)k+='g'; if(this.ignoreCase)k+='i'; if(this.multiline)k+='m'; if(harmony_unicode_regexps&&this.unicode)k+='u'; if(harmony_regexps&&this.sticky)k+='y'; return k; } function RegExpGetLastMatch(){ if($regexpLastMatchInfoOverride!==null){ return(($regexpLastMatchInfoOverride)[0]); } var D=(($regexpLastMatchInfo)[1]); return %_SubString(D, $regexpLastMatchInfo[3], $regexpLastMatchInfo[4]); } function RegExpGetLastParen(){ if($regexpLastMatchInfoOverride){ var E=$regexpLastMatchInfoOverride; if(E.length<=3)return''; return E[E.length-3]; } var G=(($regexpLastMatchInfo)[0]); if(G<=2)return''; var D=(($regexpLastMatchInfo)[1]); var l=$regexpLastMatchInfo[(3+(G-2))]; var q=$regexpLastMatchInfo[(3+(G-1))]; if(l!=-1&&q!=-1){ return %_SubString(D,l,q); } return""; } function RegExpGetLeftContext(){ var H; var I; if(!$regexpLastMatchInfoOverride){ H=$regexpLastMatchInfo[3]; I=(($regexpLastMatchInfo)[1]); }else{ var E=$regexpLastMatchInfoOverride; H=((E)[(E).length-2]); I=((E)[(E).length-1]); } return %_SubString(I,0,H); } function RegExpGetRightContext(){ var H; var I; if(!$regexpLastMatchInfoOverride){ H=$regexpLastMatchInfo[4]; I=(($regexpLastMatchInfo)[1]); }else{ var E=$regexpLastMatchInfoOverride; I=((E)[(E).length-1]); var J=((E)[0]); H=((E)[(E).length-2])+J.length; } return %_SubString(I,H,I.length); } function RegExpMakeCaptureGetter(K){ return function foo(){ if($regexpLastMatchInfoOverride){ if(K<$regexpLastMatchInfoOverride.length-2){ return(($regexpLastMatchInfoOverride)[(K)]); } return''; } var j=K*2; if(j>=(($regexpLastMatchInfo)[0]))return''; var L=$regexpLastMatchInfo[(3+(j))]; var M=$regexpLastMatchInfo[(3+(j+1))]; if(L==-1||M==-1)return''; return %_SubString((($regexpLastMatchInfo)[1]),L,M); }; } %FunctionSetInstanceClassName(a,'RegExp'); %AddNamedProperty( a.prototype,'constructor',a,2); %SetCode(a,RegExpConstructor); InstallFunctions(a.prototype,2,b( "exec",RegExpExecJS, "test",RegExpTest, "toString",RegExpToString, "compile",RegExpCompileJS )); %FunctionSetLength(a.prototype.compile,1); var N=function(){ var P=(($regexpLastMatchInfo)[2]); return(P===(void 0))?"":P; }; var Q=function(i){ (($regexpLastMatchInfo)[2])=ToString(i); }; %OptimizeObjectForAddingMultipleProperties(a,22); %DefineAccessorPropertyUnchecked(a,'input',N, Q,4); %DefineAccessorPropertyUnchecked(a,'$_',N, Q,2|4); var R=false; var S=function(){return R;}; var T=function(U){R=U?true:false;}; %DefineAccessorPropertyUnchecked(a,'multiline',S, T,4); %DefineAccessorPropertyUnchecked(a,'$*',S, T, 2|4); var W=function(X){}; %DefineAccessorPropertyUnchecked(a,'lastMatch',RegExpGetLastMatch, W,4); %DefineAccessorPropertyUnchecked(a,'$&',RegExpGetLastMatch, W,2|4); %DefineAccessorPropertyUnchecked(a,'lastParen',RegExpGetLastParen, W,4); %DefineAccessorPropertyUnchecked(a,'$+',RegExpGetLastParen, W,2|4); %DefineAccessorPropertyUnchecked(a,'leftContext', RegExpGetLeftContext,W, 4); %DefineAccessorPropertyUnchecked(a,'$`',RegExpGetLeftContext, W,2|4); %DefineAccessorPropertyUnchecked(a,'rightContext', RegExpGetRightContext,W, 4); %DefineAccessorPropertyUnchecked(a,"$'",RegExpGetRightContext, W,2|4); for(var u=1;u<10;++u){ %DefineAccessorPropertyUnchecked(a,'$'+u, RegExpMakeCaptureGetter(u),W, 4); } %ToFastProperties(a); $regexpExecNoTests=RegExpExecNoTests; $regexpExec=DoRegExpExec; })(); ,arraybufferi "use strict"; var $ArrayBuffer=global.ArrayBuffer; function ArrayBufferConstructor(a){ if(%_IsConstructCall()){ var b=ToPositiveInteger(a,'invalid_array_buffer_length'); %ArrayBufferInitialize(this,b); }else{ throw MakeTypeError('constructor_not_function',["ArrayBuffer"]); } } function ArrayBufferGetByteLen(){ if(!(%_ClassOf(this)==='ArrayBuffer')){ throw MakeTypeError('incompatible_method_receiver', ['ArrayBuffer.prototype.byteLength',this]); } return %_ArrayBufferGetByteLength(this); } function ArrayBufferSlice(a,b){ if(!(%_ClassOf(this)==='ArrayBuffer')){ throw MakeTypeError('incompatible_method_receiver', ['ArrayBuffer.prototype.slice',this]); } var c=(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a))); if(!(b===(void 0))){ b=(%_IsSmi(%IS_VAR(b))?b:%NumberToInteger(ToNumber(b))); } var d; var g=%_ArrayBufferGetByteLength(this); if(c<0){ d=$max(g+c,0); }else{ d=$min(c,g); } var h=(b===(void 0))?g:b; var i; if(h<0){ i=$max(g+h,0); }else{ i=$min(h,g); } if(i<d){ i=d; } var j=i-d; var k=new $ArrayBuffer(j); %ArrayBufferSliceImpl(this,k,d); return k; } function ArrayBufferIsViewJS(a){ return %ArrayBufferIsView(a); } function SetUpArrayBuffer(){ %CheckIsBootstrapping(); %SetCode($ArrayBuffer,ArrayBufferConstructor); %FunctionSetPrototype($ArrayBuffer,new $Object()); %AddNamedProperty( $ArrayBuffer.prototype,"constructor",$ArrayBuffer,2); %AddNamedProperty($ArrayBuffer.prototype, symbolToStringTag,"ArrayBuffer",2|1); InstallGetter($ArrayBuffer.prototype,"byteLength",ArrayBufferGetByteLen); InstallFunctions($ArrayBuffer,2,$Array( "isView",ArrayBufferIsViewJS )); InstallFunctions($ArrayBuffer.prototype,2,$Array( "slice",ArrayBufferSlice )); } SetUpArrayBuffer(); (typedarray6? "use strict"; var $ArrayBuffer=global.ArrayBuffer; function Uint8ArrayConstructByArrayBuffer(a,b,c,d){ if(!(c===(void 0))){ c= ToPositiveInteger(c,"invalid_typed_array_length"); } if(!(d===(void 0))){ d=ToPositiveInteger(d,"invalid_typed_array_length"); } var g=%_ArrayBufferGetByteLength(b); var h; if((c===(void 0))){ h=0; }else{ h=c; if(h % 1!==0){ throw MakeRangeError("invalid_typed_array_alignment", ["start offset","Uint8Array",1]); } if(h>g){ throw MakeRangeError("invalid_typed_array_offset"); } } var i; var j; if((d===(void 0))){ if(g % 1!==0){ throw MakeRangeError("invalid_typed_array_alignment", ["byte length","Uint8Array",1]); } i=g-h; j=i/1; }else{ var j=d; i=j*1; } if((h+i>g) ||(j>%_MaxSmi())){ throw MakeRangeError("invalid_typed_array_length"); } %_TypedArrayInitialize(a,1,b,h,i); } function Uint8ArrayConstructByLength(a,b){ var c=(b===(void 0))? 0:ToPositiveInteger(b,"invalid_typed_array_length"); if(c>%_MaxSmi()){ throw MakeRangeError("invalid_typed_array_length"); } var d=c*1; if(d>%_TypedArrayMaxSizeInHeap()){ var g=new $ArrayBuffer(d); %_TypedArrayInitialize(a,1,g,0,d); }else{ %_TypedArrayInitialize(a,1,null,0,d); } } function Uint8ArrayConstructByArrayLike(a,b){ var c=b.length; var d=ToPositiveInteger(c,"invalid_typed_array_length"); if(d>%_MaxSmi()){ throw MakeRangeError("invalid_typed_array_length"); } if(!%TypedArrayInitializeFromArrayLike(a,1,b,d)){ for(var g=0;g<d;g++){ a[g]=b[g]; } } } function Uint8ArrayConstructor(a,b,c){ if(%_IsConstructCall()){ if((%_ClassOf(a)==='ArrayBuffer')){ Uint8ArrayConstructByArrayBuffer(this,a,b,c); }else if((typeof(a)==='number')||(typeof(a)==='string')|| (typeof(a)==='boolean')||(a===(void 0))){ Uint8ArrayConstructByLength(this,a); }else{ Uint8ArrayConstructByArrayLike(this,a); } }else{ throw MakeTypeError("constructor_not_function",["Uint8Array"]) } } function Uint8Array_GetBuffer(){ if(!(%_ClassOf(this)==='Uint8Array')){ throw MakeTypeError('incompatible_method_receiver', ["Uint8Array.buffer",this]); } return %TypedArrayGetBuffer(this); } function Uint8Array_GetByteLength(){ if(!(%_ClassOf(this)==='Uint8Array')){ throw MakeTypeError('incompatible_method_receiver', ["Uint8Array.byteLength",this]); } return %_ArrayBufferViewGetByteLength(this); } function Uint8Array_GetByteOffset(){ if(!(%_ClassOf(this)==='Uint8Array')){ throw MakeTypeError('incompatible_method_receiver', ["Uint8Array.byteOffset",this]); } return %_ArrayBufferViewGetByteOffset(this); } function Uint8Array_GetLength(){ if(!(%_ClassOf(this)==='Uint8Array')){ throw MakeTypeError('incompatible_method_receiver', ["Uint8Array.length",this]); } return %_TypedArrayGetLength(this); } var $Uint8Array=global.Uint8Array; function Uint8ArraySubArray(a,b){ if(!(%_ClassOf(this)==='Uint8Array')){ throw MakeTypeError('incompatible_method_receiver', ["Uint8Array.subarray",this]); } var c=(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a))); if(!(b===(void 0))){ b=(%_IsSmi(%IS_VAR(b))?b:%NumberToInteger(ToNumber(b))); } var d=%_TypedArrayGetLength(this); if(c<0){ c=$max(0,d+c); }else{ c=$min(d,c); } var g=(b===(void 0))?d:b; if(g<0){ g=$max(0,d+g); }else{ g=$min(g,d); } if(g<c){ g=c; } var h=g-c; var i= %_ArrayBufferViewGetByteOffset(this)+c*1; return new $Uint8Array(%TypedArrayGetBuffer(this), i,h); } function Int8ArrayConstructByArrayBuffer(a,b,c,d){ if(!(c===(void 0))){ c= ToPositiveInteger(c,"invalid_typed_array_length"); } if(!(d===(void 0))){ d=ToPositiveInteger(d,"invalid_typed_array_length"); } var g=%_ArrayBufferGetByteLength(b); var h; if((c===(void 0))){ h=0; }else{ h=c; if(h % 1!==0){ throw MakeRangeError("invalid_typed_array_alignment", ["start offset","Int8Array",1]); } if(h>g){ throw MakeRangeError("invalid_typed_array_offset"); } } var i; var j; if((d===(void 0))){ if(g % 1!==0){ throw MakeRangeError("invalid_typed_array_alignment", ["byte length","Int8Array",1]); } i=g-h; j=i/1; }else{ var j=d; i=j*1; } if((h+i>g) ||(j>%_MaxSmi())){ throw MakeRangeError("invalid_typed_array_length"); } %_TypedArrayInitialize(a,2,b,h,i); } function Int8ArrayConstructByLength(a,b){ var c=(b===(void 0))? 0:ToPositiveInteger(b,"invalid_typed_array_length"); if(c>%_MaxSmi()){ throw MakeRangeError("invalid_typed_array_length"); } var d=c*1; if(d>%_TypedArrayMaxSizeInHeap()){ var g=new $ArrayBuffer(d); %_TypedArrayInitialize(a,2,g,0,d); }else{ %_TypedArrayInitialize(a,2,null,0,d); } } function Int8ArrayConstructByArrayLike(a,b){ var c=b.length; var d=ToPositiveInteger(c,"invalid_typed_array_length"); if(d>%_MaxSmi()){ throw MakeRangeError("invalid_typed_array_length"); } if(!%TypedArrayInitializeFromArrayLike(a,2,b,d)){ for(var g=0;g<d;g++){ a[g]=b[g]; } } } function Int8ArrayConstructor(a,b,c){ if(%_IsConstructCall()){ if((%_ClassOf(a)==='ArrayBuffer')){ Int8ArrayConstructByArrayBuffer(this,a,b,c); }else if((typeof(a)==='number')||(typeof(a)==='string')|| (typeof(a)==='boolean')||(a===(void 0))){ Int8ArrayConstructByLength(this,a); }else{ Int8ArrayConstructByArrayLike(this,a); } }else{ throw MakeTypeError("constructor_not_function",["Int8Array"]) } } function Int8Array_GetBuffer(){ if(!(%_ClassOf(this)==='Int8Array')){ throw MakeTypeError('incompatible_method_receiver', ["Int8Array.buffer",this]); } return %TypedArrayGetBuffer(this); } function Int8Array_GetByteLength(){ if(!(%_ClassOf(this)==='Int8Array')){ throw MakeTypeError('incompatible_method_receiver', ["Int8Array.byteLength",this]); } return %_ArrayBufferViewGetByteLength(this); } function Int8Array_GetByteOffset(){ if(!(%_ClassOf(this)==='Int8Array')){ throw MakeTypeError('incompatible_method_receiver', ["Int8Array.byteOffset",this]); } return %_ArrayBufferViewGetByteOffset(this); } function Int8Array_GetLength(){ if(!(%_ClassOf(this)==='Int8Array')){ throw MakeTypeError('incompatible_method_receiver', ["Int8Array.length",this]); } return %_TypedArrayGetLength(this); } var $Int8Array=global.Int8Array; function Int8ArraySubArray(a,b){ if(!(%_ClassOf(this)==='Int8Array')){ throw MakeTypeError('incompatible_method_receiver', ["Int8Array.subarray",this]); } var c=(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a))); if(!(b===(void 0))){ b=(%_IsSmi(%IS_VAR(b))?b:%NumberToInteger(ToNumber(b))); } var d=%_TypedArrayGetLength(this); if(c<0){ c=$max(0,d+c); }else{ c=$min(d,c); } var g=(b===(void 0))?d:b; if(g<0){ g=$max(0,d+g); }else{ g=$min(g,d); } if(g<c){ g=c; } var h=g-c; var i= %_ArrayBufferViewGetByteOffset(this)+c*1; return new $Int8Array(%TypedArrayGetBuffer(this), i,h); } function Uint16ArrayConstructByArrayBuffer(a,b,c,d){ if(!(c===(void 0))){ c= ToPositiveInteger(c,"invalid_typed_array_length"); } if(!(d===(void 0))){ d=ToPositiveInteger(d,"invalid_typed_array_length"); } var g=%_ArrayBufferGetByteLength(b); var h; if((c===(void 0))){ h=0; }else{ h=c; if(h % 2!==0){ throw MakeRangeError("invalid_typed_array_alignment", ["start offset","Uint16Array",2]); } if(h>g){ throw MakeRangeError("invalid_typed_array_offset"); } } var i; var j; if((d===(void 0))){ if(g % 2!==0){ throw MakeRangeError("invalid_typed_array_alignment", ["byte length","Uint16Array",2]); } i=g-h; j=i/2; }else{ var j=d; i=j*2; } if((h+i>g) ||(j>%_MaxSmi())){ throw MakeRangeError("invalid_typed_array_length"); } %_TypedArrayInitialize(a,3,b,h,i); } function Uint16ArrayConstructByLength(a,b){ var c=(b===(void 0))? 0:ToPositiveInteger(b,"invalid_typed_array_length"); if(c>%_MaxSmi()){ throw MakeRangeError("invalid_typed_array_length"); } var d=c*2; if(d>%_TypedArrayMaxSizeInHeap()){ var g=new $ArrayBuffer(d); %_TypedArrayInitialize(a,3,g,0,d); }else{ %_TypedArrayInitialize(a,3,null,0,d); } } function Uint16ArrayConstructByArrayLike(a,b){ var c=b.length; var d=ToPositiveInteger(c,"invalid_typed_array_length"); if(d>%_MaxSmi()){ throw MakeRangeError("invalid_typed_array_length"); } if(!%TypedArrayInitializeFromArrayLike(a,3,b,d)){ for(var g=0;g<d;g++){ a[g]=b[g]; } } } function Uint16ArrayConstructor(a,b,c){ if(%_IsConstructCall()){ if((%_ClassOf(a)==='ArrayBuffer')){ Uint16ArrayConstructByArrayBuffer(this,a,b,c); }else if((typeof(a)==='number')||(typeof(a)==='string')|| (typeof(a)==='boolean')||(a===(void 0))){ Uint16ArrayConstructByLength(this,a); }else{ Uint16ArrayConstructByArrayLike(this,a); } }else{ throw MakeTypeError("constructor_not_function",["Uint16Array"]) } } function Uint16Array_GetBuffer(){ if(!(%_ClassOf(this)==='Uint16Array')){ throw MakeTypeError('incompatible_method_receiver', ["Uint16Array.buffer",this]); } return %TypedArrayGetBuffer(this); } function Uint16Array_GetByteLength(){ if(!(%_ClassOf(this)==='Uint16Array')){ throw MakeTypeError('incompatible_method_receiver', ["Uint16Array.byteLength",this]); } return %_ArrayBufferViewGetByteLength(this); } function Uint16Array_GetByteOffset(){ if(!(%_ClassOf(this)==='Uint16Array')){ throw MakeTypeError('incompatible_method_receiver', ["Uint16Array.byteOffset",this]); } return %_ArrayBufferViewGetByteOffset(this); } function Uint16Array_GetLength(){ if(!(%_ClassOf(this)==='Uint16Array')){ throw MakeTypeError('incompatible_method_receiver', ["Uint16Array.length",this]); } return %_TypedArrayGetLength(this); } var $Uint16Array=global.Uint16Array; function Uint16ArraySubArray(a,b){ if(!(%_ClassOf(this)==='Uint16Array')){ throw MakeTypeError('incompatible_method_receiver', ["Uint16Array.subarray",this]); } var c=(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a))); if(!(b===(void 0))){ b=(%_IsSmi(%IS_VAR(b))?b:%NumberToInteger(ToNumber(b))); } var d=%_TypedArrayGetLength(this); if(c<0){ c=$max(0,d+c); }else{ c=$min(d,c); } var g=(b===(void 0))?d:b; if(g<0){ g=$max(0,d+g); }else{ g=$min(g,d); } if(g<c){ g=c; } var h=g-c; var i= %_ArrayBufferViewGetByteOffset(this)+c*2; return new $Uint16Array(%TypedArrayGetBuffer(this), i,h); } function Int16ArrayConstructByArrayBuffer(a,b,c,d){ if(!(c===(void 0))){ c= ToPositiveInteger(c,"invalid_typed_array_length"); } if(!(d===(void 0))){ d=ToPositiveInteger(d,"invalid_typed_array_length"); } var g=%_ArrayBufferGetByteLength(b); var h; if((c===(void 0))){ h=0; }else{ h=c; if(h % 2!==0){ throw MakeRangeError("invalid_typed_array_alignment", ["start offset","Int16Array",2]); } if(h>g){ throw MakeRangeError("invalid_typed_array_offset"); } } var i; var j; if((d===(void 0))){ if(g % 2!==0){ throw MakeRangeError("invalid_typed_array_alignment", ["byte length","Int16Array",2]); } i=g-h; j=i/2; }else{ var j=d; i=j*2; } if((h+i>g) ||(j>%_MaxSmi())){ throw MakeRangeError("invalid_typed_array_length"); } %_TypedArrayInitialize(a,4,b,h,i); } function Int16ArrayConstructByLength(a,b){ var c=(b===(void 0))? 0:ToPositiveInteger(b,"invalid_typed_array_length"); if(c>%_MaxSmi()){ throw MakeRangeError("invalid_typed_array_length"); } var d=c*2; if(d>%_TypedArrayMaxSizeInHeap()){ var g=new $ArrayBuffer(d); %_TypedArrayInitialize(a,4,g,0,d); }else{ %_TypedArrayInitialize(a,4,null,0,d); } } function Int16ArrayConstructByArrayLike(a,b){ var c=b.length; var d=ToPositiveInteger(c,"invalid_typed_array_length"); if(d>%_MaxSmi()){ throw MakeRangeError("invalid_typed_array_length"); } if(!%TypedArrayInitializeFromArrayLike(a,4,b,d)){ for(var g=0;g<d;g++){ a[g]=b[g]; } } } function Int16ArrayConstructor(a,b,c){ if(%_IsConstructCall()){ if((%_ClassOf(a)==='ArrayBuffer')){ Int16ArrayConstructByArrayBuffer(this,a,b,c); }else if((typeof(a)==='number')||(typeof(a)==='string')|| (typeof(a)==='boolean')||(a===(void 0))){ Int16ArrayConstructByLength(this,a); }else{ Int16ArrayConstructByArrayLike(this,a); } }else{ throw MakeTypeError("constructor_not_function",["Int16Array"]) } } function Int16Array_GetBuffer(){ if(!(%_ClassOf(this)==='Int16Array')){ throw MakeTypeError('incompatible_method_receiver', ["Int16Array.buffer",this]); } return %TypedArrayGetBuffer(this); } function Int16Array_GetByteLength(){ if(!(%_ClassOf(this)==='Int16Array')){ throw MakeTypeError('incompatible_method_receiver', ["Int16Array.byteLength",this]); } return %_ArrayBufferViewGetByteLength(this); } function Int16Array_GetByteOffset(){ if(!(%_ClassOf(this)==='Int16Array')){ throw MakeTypeError('incompatible_method_receiver', ["Int16Array.byteOffset",this]); } return %_ArrayBufferViewGetByteOffset(this); } function Int16Array_GetLength(){ if(!(%_ClassOf(this)==='Int16Array')){ throw MakeTypeError('incompatible_method_receiver', ["Int16Array.length",this]); } return %_TypedArrayGetLength(this); } var $Int16Array=global.Int16Array; function Int16ArraySubArray(a,b){ if(!(%_ClassOf(this)==='Int16Array')){ throw MakeTypeError('incompatible_method_receiver', ["Int16Array.subarray",this]); } var c=(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a))); if(!(b===(void 0))){ b=(%_IsSmi(%IS_VAR(b))?b:%NumberToInteger(ToNumber(b))); } var d=%_TypedArrayGetLength(this); if(c<0){ c=$max(0,d+c); }else{ c=$min(d,c); } var g=(b===(void 0))?d:b; if(g<0){ g=$max(0,d+g); }else{ g=$min(g,d); } if(g<c){ g=c; } var h=g-c; var i= %_ArrayBufferViewGetByteOffset(this)+c*2; return new $Int16Array(%TypedArrayGetBuffer(this), i,h); } function Uint32ArrayConstructByArrayBuffer(a,b,c,d){ if(!(c===(void 0))){ c= ToPositiveInteger(c,"invalid_typed_array_length"); } if(!(d===(void 0))){ d=ToPositiveInteger(d,"invalid_typed_array_length"); } var g=%_ArrayBufferGetByteLength(b); var h; if((c===(void 0))){ h=0; }else{ h=c; if(h % 4!==0){ throw MakeRangeError("invalid_typed_array_alignment", ["start offset","Uint32Array",4]); } if(h>g){ throw MakeRangeError("invalid_typed_array_offset"); } } var i; var j; if((d===(void 0))){ if(g % 4!==0){ throw MakeRangeError("invalid_typed_array_alignment", ["byte length","Uint32Array",4]); } i=g-h; j=i/4; }else{ var j=d; i=j*4; } if((h+i>g) ||(j>%_MaxSmi())){ throw MakeRangeError("invalid_typed_array_length"); } %_TypedArrayInitialize(a,5,b,h,i); } function Uint32ArrayConstructByLength(a,b){ var c=(b===(void 0))? 0:ToPositiveInteger(b,"invalid_typed_array_length"); if(c>%_MaxSmi()){ throw MakeRangeError("invalid_typed_array_length"); } var d=c*4; if(d>%_TypedArrayMaxSizeInHeap()){ var g=new $ArrayBuffer(d); %_TypedArrayInitialize(a,5,g,0,d); }else{ %_TypedArrayInitialize(a,5,null,0,d); } } function Uint32ArrayConstructByArrayLike(a,b){ var c=b.length; var d=ToPositiveInteger(c,"invalid_typed_array_length"); if(d>%_MaxSmi()){ throw MakeRangeError("invalid_typed_array_length"); } if(!%TypedArrayInitializeFromArrayLike(a,5,b,d)){ for(var g=0;g<d;g++){ a[g]=b[g]; } } } function Uint32ArrayConstructor(a,b,c){ if(%_IsConstructCall()){ if((%_ClassOf(a)==='ArrayBuffer')){ Uint32ArrayConstructByArrayBuffer(this,a,b,c); }else if((typeof(a)==='number')||(typeof(a)==='string')|| (typeof(a)==='boolean')||(a===(void 0))){ Uint32ArrayConstructByLength(this,a); }else{ Uint32ArrayConstructByArrayLike(this,a); } }else{ throw MakeTypeError("constructor_not_function",["Uint32Array"]) } } function Uint32Array_GetBuffer(){ if(!(%_ClassOf(this)==='Uint32Array')){ throw MakeTypeError('incompatible_method_receiver', ["Uint32Array.buffer",this]); } return %TypedArrayGetBuffer(this); } function Uint32Array_GetByteLength(){ if(!(%_ClassOf(this)==='Uint32Array')){ throw MakeTypeError('incompatible_method_receiver', ["Uint32Array.byteLength",this]); } return %_ArrayBufferViewGetByteLength(this); } function Uint32Array_GetByteOffset(){ if(!(%_ClassOf(this)==='Uint32Array')){ throw MakeTypeError('incompatible_method_receiver', ["Uint32Array.byteOffset",this]); } return %_ArrayBufferViewGetByteOffset(this); } function Uint32Array_GetLength(){ if(!(%_ClassOf(this)==='Uint32Array')){ throw MakeTypeError('incompatible_method_receiver', ["Uint32Array.length",this]); } return %_TypedArrayGetLength(this); } var $Uint32Array=global.Uint32Array; function Uint32ArraySubArray(a,b){ if(!(%_ClassOf(this)==='Uint32Array')){ throw MakeTypeError('incompatible_method_receiver', ["Uint32Array.subarray",this]); } var c=(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a))); if(!(b===(void 0))){ b=(%_IsSmi(%IS_VAR(b))?b:%NumberToInteger(ToNumber(b))); } var d=%_TypedArrayGetLength(this); if(c<0){ c=$max(0,d+c); }else{ c=$min(d,c); } var g=(b===(void 0))?d:b; if(g<0){ g=$max(0,d+g); }else{ g=$min(g,d); } if(g<c){ g=c; } var h=g-c; var i= %_ArrayBufferViewGetByteOffset(this)+c*4; return new $Uint32Array(%TypedArrayGetBuffer(this), i,h); } function Int32ArrayConstructByArrayBuffer(a,b,c,d){ if(!(c===(void 0))){ c= ToPositiveInteger(c,"invalid_typed_array_length"); } if(!(d===(void 0))){ d=ToPositiveInteger(d,"invalid_typed_array_length"); } var g=%_ArrayBufferGetByteLength(b); var h; if((c===(void 0))){ h=0; }else{ h=c; if(h % 4!==0){ throw MakeRangeError("invalid_typed_array_alignment", ["start offset","Int32Array",4]); } if(h>g){ throw MakeRangeError("invalid_typed_array_offset"); } } var i; var j; if((d===(void 0))){ if(g % 4!==0){ throw MakeRangeError("invalid_typed_array_alignment", ["byte length","Int32Array",4]); } i=g-h; j=i/4; }else{ var j=d; i=j*4; } if((h+i>g) ||(j>%_MaxSmi())){ throw MakeRangeError("invalid_typed_array_length"); } %_TypedArrayInitialize(a,6,b,h,i); } function Int32ArrayConstructByLength(a,b){ var c=(b===(void 0))? 0:ToPositiveInteger(b,"invalid_typed_array_length"); if(c>%_MaxSmi()){ throw MakeRangeError("invalid_typed_array_length"); } var d=c*4; if(d>%_TypedArrayMaxSizeInHeap()){ var g=new $ArrayBuffer(d); %_TypedArrayInitialize(a,6,g,0,d); }else{ %_TypedArrayInitialize(a,6,null,0,d); } } function Int32ArrayConstructByArrayLike(a,b){ var c=b.length; var d=ToPositiveInteger(c,"invalid_typed_array_length"); if(d>%_MaxSmi()){ throw MakeRangeError("invalid_typed_array_length"); } if(!%TypedArrayInitializeFromArrayLike(a,6,b,d)){ for(var g=0;g<d;g++){ a[g]=b[g]; } } } function Int32ArrayConstructor(a,b,c){ if(%_IsConstructCall()){ if((%_ClassOf(a)==='ArrayBuffer')){ Int32ArrayConstructByArrayBuffer(this,a,b,c); }else if((typeof(a)==='number')||(typeof(a)==='string')|| (typeof(a)==='boolean')||(a===(void 0))){ Int32ArrayConstructByLength(this,a); }else{ Int32ArrayConstructByArrayLike(this,a); } }else{ throw MakeTypeError("constructor_not_function",["Int32Array"]) } } function Int32Array_GetBuffer(){ if(!(%_ClassOf(this)==='Int32Array')){ throw MakeTypeError('incompatible_method_receiver', ["Int32Array.buffer",this]); } return %TypedArrayGetBuffer(this); } function Int32Array_GetByteLength(){ if(!(%_ClassOf(this)==='Int32Array')){ throw MakeTypeError('incompatible_method_receiver', ["Int32Array.byteLength",this]); } return %_ArrayBufferViewGetByteLength(this); } function Int32Array_GetByteOffset(){ if(!(%_ClassOf(this)==='Int32Array')){ throw MakeTypeError('incompatible_method_receiver', ["Int32Array.byteOffset",this]); } return %_ArrayBufferViewGetByteOffset(this); } function Int32Array_GetLength(){ if(!(%_ClassOf(this)==='Int32Array')){ throw MakeTypeError('incompatible_method_receiver', ["Int32Array.length",this]); } return %_TypedArrayGetLength(this); } var $Int32Array=global.Int32Array; function Int32ArraySubArray(a,b){ if(!(%_ClassOf(this)==='Int32Array')){ throw MakeTypeError('incompatible_method_receiver', ["Int32Array.subarray",this]); } var c=(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a))); if(!(b===(void 0))){ b=(%_IsSmi(%IS_VAR(b))?b:%NumberToInteger(ToNumber(b))); } var d=%_TypedArrayGetLength(this); if(c<0){ c=$max(0,d+c); }else{ c=$min(d,c); } var g=(b===(void 0))?d:b; if(g<0){ g=$max(0,d+g); }else{ g=$min(g,d); } if(g<c){ g=c; } var h=g-c; var i= %_ArrayBufferViewGetByteOffset(this)+c*4; return new $Int32Array(%TypedArrayGetBuffer(this), i,h); } function Float32ArrayConstructByArrayBuffer(a,b,c,d){ if(!(c===(void 0))){ c= ToPositiveInteger(c,"invalid_typed_array_length"); } if(!(d===(void 0))){ d=ToPositiveInteger(d,"invalid_typed_array_length"); } var g=%_ArrayBufferGetByteLength(b); var h; if((c===(void 0))){ h=0; }else{ h=c; if(h % 4!==0){ throw MakeRangeError("invalid_typed_array_alignment", ["start offset","Float32Array",4]); } if(h>g){ throw MakeRangeError("invalid_typed_array_offset"); } } var i; var j; if((d===(void 0))){ if(g % 4!==0){ throw MakeRangeError("invalid_typed_array_alignment", ["byte length","Float32Array",4]); } i=g-h; j=i/4; }else{ var j=d; i=j*4; } if((h+i>g) ||(j>%_MaxSmi())){ throw MakeRangeError("invalid_typed_array_length"); } %_TypedArrayInitialize(a,7,b,h,i); } function Float32ArrayConstructByLength(a,b){ var c=(b===(void 0))? 0:ToPositiveInteger(b,"invalid_typed_array_length"); if(c>%_MaxSmi()){ throw MakeRangeError("invalid_typed_array_length"); } var d=c*4; if(d>%_TypedArrayMaxSizeInHeap()){ var g=new $ArrayBuffer(d); %_TypedArrayInitialize(a,7,g,0,d); }else{ %_TypedArrayInitialize(a,7,null,0,d); } } function Float32ArrayConstructByArrayLike(a,b){ var c=b.length; var d=ToPositiveInteger(c,"invalid_typed_array_length"); if(d>%_MaxSmi()){ throw MakeRangeError("invalid_typed_array_length"); } if(!%TypedArrayInitializeFromArrayLike(a,7,b,d)){ for(var g=0;g<d;g++){ a[g]=b[g]; } } } function Float32ArrayConstructor(a,b,c){ if(%_IsConstructCall()){ if((%_ClassOf(a)==='ArrayBuffer')){ Float32ArrayConstructByArrayBuffer(this,a,b,c); }else if((typeof(a)==='number')||(typeof(a)==='string')|| (typeof(a)==='boolean')||(a===(void 0))){ Float32ArrayConstructByLength(this,a); }else{ Float32ArrayConstructByArrayLike(this,a); } }else{ throw MakeTypeError("constructor_not_function",["Float32Array"]) } } function Float32Array_GetBuffer(){ if(!(%_ClassOf(this)==='Float32Array')){ throw MakeTypeError('incompatible_method_receiver', ["Float32Array.buffer",this]); } return %TypedArrayGetBuffer(this); } function Float32Array_GetByteLength(){ if(!(%_ClassOf(this)==='Float32Array')){ throw MakeTypeError('incompatible_method_receiver', ["Float32Array.byteLength",this]); } return %_ArrayBufferViewGetByteLength(this); } function Float32Array_GetByteOffset(){ if(!(%_ClassOf(this)==='Float32Array')){ throw MakeTypeError('incompatible_method_receiver', ["Float32Array.byteOffset",this]); } return %_ArrayBufferViewGetByteOffset(this); } function Float32Array_GetLength(){ if(!(%_ClassOf(this)==='Float32Array')){ throw MakeTypeError('incompatible_method_receiver', ["Float32Array.length",this]); } return %_TypedArrayGetLength(this); } var $Float32Array=global.Float32Array; function Float32ArraySubArray(a,b){ if(!(%_ClassOf(this)==='Float32Array')){ throw MakeTypeError('incompatible_method_receiver', ["Float32Array.subarray",this]); } var c=(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a))); if(!(b===(void 0))){ b=(%_IsSmi(%IS_VAR(b))?b:%NumberToInteger(ToNumber(b))); } var d=%_TypedArrayGetLength(this); if(c<0){ c=$max(0,d+c); }else{ c=$min(d,c); } var g=(b===(void 0))?d:b; if(g<0){ g=$max(0,d+g); }else{ g=$min(g,d); } if(g<c){ g=c; } var h=g-c; var i= %_ArrayBufferViewGetByteOffset(this)+c*4; return new $Float32Array(%TypedArrayGetBuffer(this), i,h); } function Float64ArrayConstructByArrayBuffer(a,b,c,d){ if(!(c===(void 0))){ c= ToPositiveInteger(c,"invalid_typed_array_length"); } if(!(d===(void 0))){ d=ToPositiveInteger(d,"invalid_typed_array_length"); } var g=%_ArrayBufferGetByteLength(b); var h; if((c===(void 0))){ h=0; }else{ h=c; if(h % 8!==0){ throw MakeRangeError("invalid_typed_array_alignment", ["start offset","Float64Array",8]); } if(h>g){ throw MakeRangeError("invalid_typed_array_offset"); } } var i; var j; if((d===(void 0))){ if(g % 8!==0){ throw MakeRangeError("invalid_typed_array_alignment", ["byte length","Float64Array",8]); } i=g-h; j=i/8; }else{ var j=d; i=j*8; } if((h+i>g) ||(j>%_MaxSmi())){ throw MakeRangeError("invalid_typed_array_length"); } %_TypedArrayInitialize(a,8,b,h,i); } function Float64ArrayConstructByLength(a,b){ var c=(b===(void 0))? 0:ToPositiveInteger(b,"invalid_typed_array_length"); if(c>%_MaxSmi()){ throw MakeRangeError("invalid_typed_array_length"); } var d=c*8; if(d>%_TypedArrayMaxSizeInHeap()){ var g=new $ArrayBuffer(d); %_TypedArrayInitialize(a,8,g,0,d); }else{ %_TypedArrayInitialize(a,8,null,0,d); } } function Float64ArrayConstructByArrayLike(a,b){ var c=b.length; var d=ToPositiveInteger(c,"invalid_typed_array_length"); if(d>%_MaxSmi()){ throw MakeRangeError("invalid_typed_array_length"); } if(!%TypedArrayInitializeFromArrayLike(a,8,b,d)){ for(var g=0;g<d;g++){ a[g]=b[g]; } } } function Float64ArrayConstructor(a,b,c){ if(%_IsConstructCall()){ if((%_ClassOf(a)==='ArrayBuffer')){ Float64ArrayConstructByArrayBuffer(this,a,b,c); }else if((typeof(a)==='number')||(typeof(a)==='string')|| (typeof(a)==='boolean')||(a===(void 0))){ Float64ArrayConstructByLength(this,a); }else{ Float64ArrayConstructByArrayLike(this,a); } }else{ throw MakeTypeError("constructor_not_function",["Float64Array"]) } } function Float64Array_GetBuffer(){ if(!(%_ClassOf(this)==='Float64Array')){ throw MakeTypeError('incompatible_method_receiver', ["Float64Array.buffer",this]); } return %TypedArrayGetBuffer(this); } function Float64Array_GetByteLength(){ if(!(%_ClassOf(this)==='Float64Array')){ throw MakeTypeError('incompatible_method_receiver', ["Float64Array.byteLength",this]); } return %_ArrayBufferViewGetByteLength(this); } function Float64Array_GetByteOffset(){ if(!(%_ClassOf(this)==='Float64Array')){ throw MakeTypeError('incompatible_method_receiver', ["Float64Array.byteOffset",this]); } return %_ArrayBufferViewGetByteOffset(this); } function Float64Array_GetLength(){ if(!(%_ClassOf(this)==='Float64Array')){ throw MakeTypeError('incompatible_method_receiver', ["Float64Array.length",this]); } return %_TypedArrayGetLength(this); } var $Float64Array=global.Float64Array; function Float64ArraySubArray(a,b){ if(!(%_ClassOf(this)==='Float64Array')){ throw MakeTypeError('incompatible_method_receiver', ["Float64Array.subarray",this]); } var c=(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a))); if(!(b===(void 0))){ b=(%_IsSmi(%IS_VAR(b))?b:%NumberToInteger(ToNumber(b))); } var d=%_TypedArrayGetLength(this); if(c<0){ c=$max(0,d+c); }else{ c=$min(d,c); } var g=(b===(void 0))?d:b; if(g<0){ g=$max(0,d+g); }else{ g=$min(g,d); } if(g<c){ g=c; } var h=g-c; var i= %_ArrayBufferViewGetByteOffset(this)+c*8; return new $Float64Array(%TypedArrayGetBuffer(this), i,h); } function Uint8ClampedArrayConstructByArrayBuffer(a,b,c,d){ if(!(c===(void 0))){ c= ToPositiveInteger(c,"invalid_typed_array_length"); } if(!(d===(void 0))){ d=ToPositiveInteger(d,"invalid_typed_array_length"); } var g=%_ArrayBufferGetByteLength(b); var h; if((c===(void 0))){ h=0; }else{ h=c; if(h % 1!==0){ throw MakeRangeError("invalid_typed_array_alignment", ["start offset","Uint8ClampedArray",1]); } if(h>g){ throw MakeRangeError("invalid_typed_array_offset"); } } var i; var j; if((d===(void 0))){ if(g % 1!==0){ throw MakeRangeError("invalid_typed_array_alignment", ["byte length","Uint8ClampedArray",1]); } i=g-h; j=i/1; }else{ var j=d; i=j*1; } if((h+i>g) ||(j>%_MaxSmi())){ throw MakeRangeError("invalid_typed_array_length"); } %_TypedArrayInitialize(a,9,b,h,i); } function Uint8ClampedArrayConstructByLength(a,b){ var c=(b===(void 0))? 0:ToPositiveInteger(b,"invalid_typed_array_length"); if(c>%_MaxSmi()){ throw MakeRangeError("invalid_typed_array_length"); } var d=c*1; if(d>%_TypedArrayMaxSizeInHeap()){ var g=new $ArrayBuffer(d); %_TypedArrayInitialize(a,9,g,0,d); }else{ %_TypedArrayInitialize(a,9,null,0,d); } } function Uint8ClampedArrayConstructByArrayLike(a,b){ var c=b.length; var d=ToPositiveInteger(c,"invalid_typed_array_length"); if(d>%_MaxSmi()){ throw MakeRangeError("invalid_typed_array_length"); } if(!%TypedArrayInitializeFromArrayLike(a,9,b,d)){ for(var g=0;g<d;g++){ a[g]=b[g]; } } } function Uint8ClampedArrayConstructor(a,b,c){ if(%_IsConstructCall()){ if((%_ClassOf(a)==='ArrayBuffer')){ Uint8ClampedArrayConstructByArrayBuffer(this,a,b,c); }else if((typeof(a)==='number')||(typeof(a)==='string')|| (typeof(a)==='boolean')||(a===(void 0))){ Uint8ClampedArrayConstructByLength(this,a); }else{ Uint8ClampedArrayConstructByArrayLike(this,a); } }else{ throw MakeTypeError("constructor_not_function",["Uint8ClampedArray"]) } } function Uint8ClampedArray_GetBuffer(){ if(!(%_ClassOf(this)==='Uint8ClampedArray')){ throw MakeTypeError('incompatible_method_receiver', ["Uint8ClampedArray.buffer",this]); } return %TypedArrayGetBuffer(this); } function Uint8ClampedArray_GetByteLength(){ if(!(%_ClassOf(this)==='Uint8ClampedArray')){ throw MakeTypeError('incompatible_method_receiver', ["Uint8ClampedArray.byteLength",this]); } return %_ArrayBufferViewGetByteLength(this); } function Uint8ClampedArray_GetByteOffset(){ if(!(%_ClassOf(this)==='Uint8ClampedArray')){ throw MakeTypeError('incompatible_method_receiver', ["Uint8ClampedArray.byteOffset",this]); } return %_ArrayBufferViewGetByteOffset(this); } function Uint8ClampedArray_GetLength(){ if(!(%_ClassOf(this)==='Uint8ClampedArray')){ throw MakeTypeError('incompatible_method_receiver', ["Uint8ClampedArray.length",this]); } return %_TypedArrayGetLength(this); } var $Uint8ClampedArray=global.Uint8ClampedArray; function Uint8ClampedArraySubArray(a,b){ if(!(%_ClassOf(this)==='Uint8ClampedArray')){ throw MakeTypeError('incompatible_method_receiver', ["Uint8ClampedArray.subarray",this]); } var c=(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a))); if(!(b===(void 0))){ b=(%_IsSmi(%IS_VAR(b))?b:%NumberToInteger(ToNumber(b))); } var d=%_TypedArrayGetLength(this); if(c<0){ c=$max(0,d+c); }else{ c=$min(d,c); } var g=(b===(void 0))?d:b; if(g<0){ g=$max(0,d+g); }else{ g=$min(g,d); } if(g<c){ g=c; } var h=g-c; var i= %_ArrayBufferViewGetByteOffset(this)+c*1; return new $Uint8ClampedArray(%TypedArrayGetBuffer(this), i,h); } function TypedArraySetFromArrayLike(a,b,c,d){ if(d>0){ for(var g=0;g<c;g++){ a[d+g]=b[g]; } } else{ for(var g=0;g<c;g++){ a[g]=b[g]; } } } function TypedArraySetFromOverlappingTypedArray(a,b,c){ var d=b.BYTES_PER_ELEMENT; var g=a.BYTES_PER_ELEMENT; var h=b.length; function CopyLeftPart(){ var i=a.byteOffset+(c+1)*g; var j=b.byteOffset; for(var k=0; k<h&&i<=j; k++){ a[c+k]=b[k]; i+=g; j+=d; } return k; } var k=CopyLeftPart(); function CopyRightPart(){ var i= a.byteOffset+(c+h-1)*g; var j= b.byteOffset+h*d; for(var l=h-1; l>=k&&i>=j; l--){ a[c+l]=b[l]; i-=g; j-=d; } return l; } var l=CopyRightPart(); var m=new $Array(l+1-k); for(var o=k;o<=l;o++){ m[o-k]=b[o]; } for(o=k;o<=l;o++){ a[c+o]=m[o-k]; } } function TypedArraySet(a,b){ var c=(b===(void 0))?0:(%_IsSmi(%IS_VAR(b))?b:%NumberToInteger(ToNumber(b))); if(c<0){ throw MakeTypeError("typed_array_set_negative_offset"); } if(c>%_MaxSmi()){ throw MakeRangeError("typed_array_set_source_too_large"); } switch(%TypedArraySetFastCases(this,a,c)){ case 0: return; case 1: TypedArraySetFromOverlappingTypedArray(this,a,c); return; case 2: TypedArraySetFromArrayLike(this,a,a.length,c); return; case 3: var d=a.length; if((d===(void 0))){ if((typeof(a)==='number')){ throw MakeTypeError("invalid_argument"); } return; } if(c+d>this.length){ throw MakeRangeError("typed_array_set_source_too_large"); } TypedArraySetFromArrayLike(this,a,d,c); return; } } function TypedArrayGetToStringTag(){ if(!%IsTypedArray(this))return; var a=%_ClassOf(this); if((a===(void 0)))return; return a; } function SetupTypedArrays(){ %CheckIsBootstrapping(); %SetCode(global.Uint8Array,Uint8ArrayConstructor); %FunctionSetPrototype(global.Uint8Array,new $Object()); %AddNamedProperty(global.Uint8Array,"BYTES_PER_ELEMENT",1, 1|2|4); %AddNamedProperty(global.Uint8Array.prototype, "constructor",global.Uint8Array,2); %AddNamedProperty(global.Uint8Array.prototype, "BYTES_PER_ELEMENT",1, 1|2|4); InstallGetter(global.Uint8Array.prototype,"buffer",Uint8Array_GetBuffer); InstallGetter(global.Uint8Array.prototype,"byteOffset",Uint8Array_GetByteOffset); InstallGetter(global.Uint8Array.prototype,"byteLength",Uint8Array_GetByteLength); InstallGetter(global.Uint8Array.prototype,"length",Uint8Array_GetLength); InstallGetter(global.Uint8Array.prototype,symbolToStringTag, TypedArrayGetToStringTag); InstallFunctions(global.Uint8Array.prototype,2,$Array( "subarray",Uint8ArraySubArray, "set",TypedArraySet )); %CheckIsBootstrapping(); %SetCode(global.Int8Array,Int8ArrayConstructor); %FunctionSetPrototype(global.Int8Array,new $Object()); %AddNamedProperty(global.Int8Array,"BYTES_PER_ELEMENT",1, 1|2|4); %AddNamedProperty(global.Int8Array.prototype, "constructor",global.Int8Array,2); %AddNamedProperty(global.Int8Array.prototype, "BYTES_PER_ELEMENT",1, 1|2|4); InstallGetter(global.Int8Array.prototype,"buffer",Int8Array_GetBuffer); InstallGetter(global.Int8Array.prototype,"byteOffset",Int8Array_GetByteOffset); InstallGetter(global.Int8Array.prototype,"byteLength",Int8Array_GetByteLength); InstallGetter(global.Int8Array.prototype,"length",Int8Array_GetLength); InstallGetter(global.Int8Array.prototype,symbolToStringTag, TypedArrayGetToStringTag); InstallFunctions(global.Int8Array.prototype,2,$Array( "subarray",Int8ArraySubArray, "set",TypedArraySet )); %CheckIsBootstrapping(); %SetCode(global.Uint16Array,Uint16ArrayConstructor); %FunctionSetPrototype(global.Uint16Array,new $Object()); %AddNamedProperty(global.Uint16Array,"BYTES_PER_ELEMENT",2, 1|2|4); %AddNamedProperty(global.Uint16Array.prototype, "constructor",global.Uint16Array,2); %AddNamedProperty(global.Uint16Array.prototype, "BYTES_PER_ELEMENT",2, 1|2|4); InstallGetter(global.Uint16Array.prototype,"buffer",Uint16Array_GetBuffer); InstallGetter(global.Uint16Array.prototype,"byteOffset",Uint16Array_GetByteOffset); InstallGetter(global.Uint16Array.prototype,"byteLength",Uint16Array_GetByteLength); InstallGetter(global.Uint16Array.prototype,"length",Uint16Array_GetLength); InstallGetter(global.Uint16Array.prototype,symbolToStringTag, TypedArrayGetToStringTag); InstallFunctions(global.Uint16Array.prototype,2,$Array( "subarray",Uint16ArraySubArray, "set",TypedArraySet )); %CheckIsBootstrapping(); %SetCode(global.Int16Array,Int16ArrayConstructor); %FunctionSetPrototype(global.Int16Array,new $Object()); %AddNamedProperty(global.Int16Array,"BYTES_PER_ELEMENT",2, 1|2|4); %AddNamedProperty(global.Int16Array.prototype, "constructor",global.Int16Array,2); %AddNamedProperty(global.Int16Array.prototype, "BYTES_PER_ELEMENT",2, 1|2|4); InstallGetter(global.Int16Array.prototype,"buffer",Int16Array_GetBuffer); InstallGetter(global.Int16Array.prototype,"byteOffset",Int16Array_GetByteOffset); InstallGetter(global.Int16Array.prototype,"byteLength",Int16Array_GetByteLength); InstallGetter(global.Int16Array.prototype,"length",Int16Array_GetLength); InstallGetter(global.Int16Array.prototype,symbolToStringTag, TypedArrayGetToStringTag); InstallFunctions(global.Int16Array.prototype,2,$Array( "subarray",Int16ArraySubArray, "set",TypedArraySet )); %CheckIsBootstrapping(); %SetCode(global.Uint32Array,Uint32ArrayConstructor); %FunctionSetPrototype(global.Uint32Array,new $Object()); %AddNamedProperty(global.Uint32Array,"BYTES_PER_ELEMENT",4, 1|2|4); %AddNamedProperty(global.Uint32Array.prototype, "constructor",global.Uint32Array,2); %AddNamedProperty(global.Uint32Array.prototype, "BYTES_PER_ELEMENT",4, 1|2|4); InstallGetter(global.Uint32Array.prototype,"buffer",Uint32Array_GetBuffer); InstallGetter(global.Uint32Array.prototype,"byteOffset",Uint32Array_GetByteOffset); InstallGetter(global.Uint32Array.prototype,"byteLength",Uint32Array_GetByteLength); InstallGetter(global.Uint32Array.prototype,"length",Uint32Array_GetLength); InstallGetter(global.Uint32Array.prototype,symbolToStringTag, TypedArrayGetToStringTag); InstallFunctions(global.Uint32Array.prototype,2,$Array( "subarray",Uint32ArraySubArray, "set",TypedArraySet )); %CheckIsBootstrapping(); %SetCode(global.Int32Array,Int32ArrayConstructor); %FunctionSetPrototype(global.Int32Array,new $Object()); %AddNamedProperty(global.Int32Array,"BYTES_PER_ELEMENT",4, 1|2|4); %AddNamedProperty(global.Int32Array.prototype, "constructor",global.Int32Array,2); %AddNamedProperty(global.Int32Array.prototype, "BYTES_PER_ELEMENT",4, 1|2|4); InstallGetter(global.Int32Array.prototype,"buffer",Int32Array_GetBuffer); InstallGetter(global.Int32Array.prototype,"byteOffset",Int32Array_GetByteOffset); InstallGetter(global.Int32Array.prototype,"byteLength",Int32Array_GetByteLength); InstallGetter(global.Int32Array.prototype,"length",Int32Array_GetLength); InstallGetter(global.Int32Array.prototype,symbolToStringTag, TypedArrayGetToStringTag); InstallFunctions(global.Int32Array.prototype,2,$Array( "subarray",Int32ArraySubArray, "set",TypedArraySet )); %CheckIsBootstrapping(); %SetCode(global.Float32Array,Float32ArrayConstructor); %FunctionSetPrototype(global.Float32Array,new $Object()); %AddNamedProperty(global.Float32Array,"BYTES_PER_ELEMENT",4, 1|2|4); %AddNamedProperty(global.Float32Array.prototype, "constructor",global.Float32Array,2); %AddNamedProperty(global.Float32Array.prototype, "BYTES_PER_ELEMENT",4, 1|2|4); InstallGetter(global.Float32Array.prototype,"buffer",Float32Array_GetBuffer); InstallGetter(global.Float32Array.prototype,"byteOffset",Float32Array_GetByteOffset); InstallGetter(global.Float32Array.prototype,"byteLength",Float32Array_GetByteLength); InstallGetter(global.Float32Array.prototype,"length",Float32Array_GetLength); InstallGetter(global.Float32Array.prototype,symbolToStringTag, TypedArrayGetToStringTag); InstallFunctions(global.Float32Array.prototype,2,$Array( "subarray",Float32ArraySubArray, "set",TypedArraySet )); %CheckIsBootstrapping(); %SetCode(global.Float64Array,Float64ArrayConstructor); %FunctionSetPrototype(global.Float64Array,new $Object()); %AddNamedProperty(global.Float64Array,"BYTES_PER_ELEMENT",8, 1|2|4); %AddNamedProperty(global.Float64Array.prototype, "constructor",global.Float64Array,2); %AddNamedProperty(global.Float64Array.prototype, "BYTES_PER_ELEMENT",8, 1|2|4); InstallGetter(global.Float64Array.prototype,"buffer",Float64Array_GetBuffer); InstallGetter(global.Float64Array.prototype,"byteOffset",Float64Array_GetByteOffset); InstallGetter(global.Float64Array.prototype,"byteLength",Float64Array_GetByteLength); InstallGetter(global.Float64Array.prototype,"length",Float64Array_GetLength); InstallGetter(global.Float64Array.prototype,symbolToStringTag, TypedArrayGetToStringTag); InstallFunctions(global.Float64Array.prototype,2,$Array( "subarray",Float64ArraySubArray, "set",TypedArraySet )); %CheckIsBootstrapping(); %SetCode(global.Uint8ClampedArray,Uint8ClampedArrayConstructor); %FunctionSetPrototype(global.Uint8ClampedArray,new $Object()); %AddNamedProperty(global.Uint8ClampedArray,"BYTES_PER_ELEMENT",1, 1|2|4); %AddNamedProperty(global.Uint8ClampedArray.prototype, "constructor",global.Uint8ClampedArray,2); %AddNamedProperty(global.Uint8ClampedArray.prototype, "BYTES_PER_ELEMENT",1, 1|2|4); InstallGetter(global.Uint8ClampedArray.prototype,"buffer",Uint8ClampedArray_GetBuffer); InstallGetter(global.Uint8ClampedArray.prototype,"byteOffset",Uint8ClampedArray_GetByteOffset); InstallGetter(global.Uint8ClampedArray.prototype,"byteLength",Uint8ClampedArray_GetByteLength); InstallGetter(global.Uint8ClampedArray.prototype,"length",Uint8ClampedArray_GetLength); InstallGetter(global.Uint8ClampedArray.prototype,symbolToStringTag, TypedArrayGetToStringTag); InstallFunctions(global.Uint8ClampedArray.prototype,2,$Array( "subarray",Uint8ClampedArraySubArray, "set",TypedArraySet )); } SetupTypedArrays(); var $DataView=global.DataView; function DataViewConstructor(a,b,c){ if(%_IsConstructCall()){ if(!(%_ClassOf(a)==='ArrayBuffer')){ throw MakeTypeError('data_view_not_array_buffer',[]); } if(!(b===(void 0))){ b=ToPositiveInteger(b,'invalid_data_view_offset'); } if(!(c===(void 0))){ c=(%_IsSmi(%IS_VAR(c))?c:%NumberToInteger(ToNumber(c))); } var d=%_ArrayBufferGetByteLength(a); var g=(b===(void 0))?0:b; if(g>d){ throw MakeRangeError('invalid_data_view_offset'); } var h=(c===(void 0)) ?d-g :c; if(h<0||g+h>d){ throw new MakeRangeError('invalid_data_view_length'); } %_DataViewInitialize(this,a,g,h); }else{ throw MakeTypeError('constructor_not_function',["DataView"]); } } function DataViewGetBufferJS(){ if(!(%_ClassOf(this)==='DataView')){ throw MakeTypeError('incompatible_method_receiver', ['DataView.buffer',this]); } return %DataViewGetBuffer(this); } function DataViewGetByteOffset(){ if(!(%_ClassOf(this)==='DataView')){ throw MakeTypeError('incompatible_method_receiver', ['DataView.byteOffset',this]); } return %_ArrayBufferViewGetByteOffset(this); } function DataViewGetByteLength(){ if(!(%_ClassOf(this)==='DataView')){ throw MakeTypeError('incompatible_method_receiver', ['DataView.byteLength',this]); } return %_ArrayBufferViewGetByteLength(this); } function ToPositiveDataViewOffset(a){ return ToPositiveInteger(a,'invalid_data_view_accessor_offset'); } function DataViewGetInt8JS(a,b){ if(!(%_ClassOf(this)==='DataView')){ throw MakeTypeError('incompatible_method_receiver', ['DataView.getInt8',this]); } if(%_ArgumentsLength()<1){ throw MakeTypeError('invalid_argument'); } return %DataViewGetInt8(this, ToPositiveDataViewOffset(a), !!b); } function DataViewSetInt8JS(a,b,c){ if(!(%_ClassOf(this)==='DataView')){ throw MakeTypeError('incompatible_method_receiver', ['DataView.setInt8',this]); } if(%_ArgumentsLength()<2){ throw MakeTypeError('invalid_argument'); } %DataViewSetInt8(this, ToPositiveDataViewOffset(a), ((typeof(%IS_VAR(b))==='number')?b:NonNumberToNumber(b)), !!c); } function DataViewGetUint8JS(a,b){ if(!(%_ClassOf(this)==='DataView')){ throw MakeTypeError('incompatible_method_receiver', ['DataView.getUint8',this]); } if(%_ArgumentsLength()<1){ throw MakeTypeError('invalid_argument'); } return %DataViewGetUint8(this, ToPositiveDataViewOffset(a), !!b); } function DataViewSetUint8JS(a,b,c){ if(!(%_ClassOf(this)==='DataView')){ throw MakeTypeError('incompatible_method_receiver', ['DataView.setUint8',this]); } if(%_ArgumentsLength()<2){ throw MakeTypeError('invalid_argument'); } %DataViewSetUint8(this, ToPositiveDataViewOffset(a), ((typeof(%IS_VAR(b))==='number')?b:NonNumberToNumber(b)), !!c); } function DataViewGetInt16JS(a,b){ if(!(%_ClassOf(this)==='DataView')){ throw MakeTypeError('incompatible_method_receiver', ['DataView.getInt16',this]); } if(%_ArgumentsLength()<1){ throw MakeTypeError('invalid_argument'); } return %DataViewGetInt16(this, ToPositiveDataViewOffset(a), !!b); } function DataViewSetInt16JS(a,b,c){ if(!(%_ClassOf(this)==='DataView')){ throw MakeTypeError('incompatible_method_receiver', ['DataView.setInt16',this]); } if(%_ArgumentsLength()<2){ throw MakeTypeError('invalid_argument'); } %DataViewSetInt16(this, ToPositiveDataViewOffset(a), ((typeof(%IS_VAR(b))==='number')?b:NonNumberToNumber(b)), !!c); } function DataViewGetUint16JS(a,b){ if(!(%_ClassOf(this)==='DataView')){ throw MakeTypeError('incompatible_method_receiver', ['DataView.getUint16',this]); } if(%_ArgumentsLength()<1){ throw MakeTypeError('invalid_argument'); } return %DataViewGetUint16(this, ToPositiveDataViewOffset(a), !!b); } function DataViewSetUint16JS(a,b,c){ if(!(%_ClassOf(this)==='DataView')){ throw MakeTypeError('incompatible_method_receiver', ['DataView.setUint16',this]); } if(%_ArgumentsLength()<2){ throw MakeTypeError('invalid_argument'); } %DataViewSetUint16(this, ToPositiveDataViewOffset(a), ((typeof(%IS_VAR(b))==='number')?b:NonNumberToNumber(b)), !!c); } function DataViewGetInt32JS(a,b){ if(!(%_ClassOf(this)==='DataView')){ throw MakeTypeError('incompatible_method_receiver', ['DataView.getInt32',this]); } if(%_ArgumentsLength()<1){ throw MakeTypeError('invalid_argument'); } return %DataViewGetInt32(this, ToPositiveDataViewOffset(a), !!b); } function DataViewSetInt32JS(a,b,c){ if(!(%_ClassOf(this)==='DataView')){ throw MakeTypeError('incompatible_method_receiver', ['DataView.setInt32',this]); } if(%_ArgumentsLength()<2){ throw MakeTypeError('invalid_argument'); } %DataViewSetInt32(this, ToPositiveDataViewOffset(a), ((typeof(%IS_VAR(b))==='number')?b:NonNumberToNumber(b)), !!c); } function DataViewGetUint32JS(a,b){ if(!(%_ClassOf(this)==='DataView')){ throw MakeTypeError('incompatible_method_receiver', ['DataView.getUint32',this]); } if(%_ArgumentsLength()<1){ throw MakeTypeError('invalid_argument'); } return %DataViewGetUint32(this, ToPositiveDataViewOffset(a), !!b); } function DataViewSetUint32JS(a,b,c){ if(!(%_ClassOf(this)==='DataView')){ throw MakeTypeError('incompatible_method_receiver', ['DataView.setUint32',this]); } if(%_ArgumentsLength()<2){ throw MakeTypeError('invalid_argument'); } %DataViewSetUint32(this, ToPositiveDataViewOffset(a), ((typeof(%IS_VAR(b))==='number')?b:NonNumberToNumber(b)), !!c); } function DataViewGetFloat32JS(a,b){ if(!(%_ClassOf(this)==='DataView')){ throw MakeTypeError('incompatible_method_receiver', ['DataView.getFloat32',this]); } if(%_ArgumentsLength()<1){ throw MakeTypeError('invalid_argument'); } return %DataViewGetFloat32(this, ToPositiveDataViewOffset(a), !!b); } function DataViewSetFloat32JS(a,b,c){ if(!(%_ClassOf(this)==='DataView')){ throw MakeTypeError('incompatible_method_receiver', ['DataView.setFloat32',this]); } if(%_ArgumentsLength()<2){ throw MakeTypeError('invalid_argument'); } %DataViewSetFloat32(this, ToPositiveDataViewOffset(a), ((typeof(%IS_VAR(b))==='number')?b:NonNumberToNumber(b)), !!c); } function DataViewGetFloat64JS(a,b){ if(!(%_ClassOf(this)==='DataView')){ throw MakeTypeError('incompatible_method_receiver', ['DataView.getFloat64',this]); } if(%_ArgumentsLength()<1){ throw MakeTypeError('invalid_argument'); } return %DataViewGetFloat64(this, ToPositiveDataViewOffset(a), !!b); } function DataViewSetFloat64JS(a,b,c){ if(!(%_ClassOf(this)==='DataView')){ throw MakeTypeError('incompatible_method_receiver', ['DataView.setFloat64',this]); } if(%_ArgumentsLength()<2){ throw MakeTypeError('invalid_argument'); } %DataViewSetFloat64(this, ToPositiveDataViewOffset(a), ((typeof(%IS_VAR(b))==='number')?b:NonNumberToNumber(b)), !!c); } function SetupDataView(){ %CheckIsBootstrapping(); %SetCode($DataView,DataViewConstructor); %FunctionSetPrototype($DataView,new $Object); %AddNamedProperty($DataView.prototype,"constructor",$DataView,2); %AddNamedProperty( $DataView.prototype,symbolToStringTag,"DataView",1|2); InstallGetter($DataView.prototype,"buffer",DataViewGetBufferJS); InstallGetter($DataView.prototype,"byteOffset",DataViewGetByteOffset); InstallGetter($DataView.prototype,"byteLength",DataViewGetByteLength); InstallFunctions($DataView.prototype,2,$Array( "getInt8",DataViewGetInt8JS, "setInt8",DataViewSetInt8JS, "getUint8",DataViewGetUint8JS, "setUint8",DataViewSetUint8JS, "getInt16",DataViewGetInt16JS, "setInt16",DataViewSetInt16JS, "getUint16",DataViewGetUint16JS, "setUint16",DataViewSetUint16JS, "getInt32",DataViewGetInt32JS, "setInt32",DataViewSetInt32JS, "getUint32",DataViewGetUint32JS, "setUint32",DataViewSetUint32JS, "getFloat32",DataViewGetFloat32JS, "setFloat32",DataViewSetFloat32JS, "getFloat64",DataViewGetFloat64JS, "setFloat64",DataViewSetFloat64JS )); } SetupDataView(); $generatora! "use strict"; function GeneratorObjectNext(a){ if(!(%_ClassOf(this)==='Generator')){ throw MakeTypeError('incompatible_method_receiver', ['[Generator].prototype.next',this]); } var b=%GeneratorGetContinuation(this); if(b>0){ if((%_DebugIsActive()!=0))%DebugPrepareStepInIfStepping(this); try{ return %_GeneratorNext(this,a); }catch(e){ %GeneratorClose(this); throw e; } }else if(b==0){ return{value:void 0,done:true}; }else{ throw MakeTypeError('generator_running',[]); } } function GeneratorObjectThrow(a){ if(!(%_ClassOf(this)==='Generator')){ throw MakeTypeError('incompatible_method_receiver', ['[Generator].prototype.throw',this]); } var b=%GeneratorGetContinuation(this); if(b>0){ try{ return %_GeneratorThrow(this,a); }catch(e){ %GeneratorClose(this); throw e; } }else if(b==0){ throw a; }else{ throw MakeTypeError('generator_running',[]); } } function GeneratorObjectIterator(){ return this; } function GeneratorFunctionPrototypeConstructor(a){ if(%_IsConstructCall()){ throw MakeTypeError('not_constructor',['GeneratorFunctionPrototype']); } } function GeneratorFunctionConstructor(a){ return NewFunctionFromString(arguments,'function*'); } function SetUpGenerators(){ %CheckIsBootstrapping(); %NeverOptimizeFunction(GeneratorObjectNext); %NeverOptimizeFunction(GeneratorObjectThrow); var a=GeneratorFunctionPrototype.prototype; InstallFunctions(a, 2|4|1, ["next",GeneratorObjectNext, "throw",GeneratorObjectThrow]); %FunctionSetName(GeneratorObjectIterator,'[Symbol.iterator]'); %AddNamedProperty(a,symbolIterator, GeneratorObjectIterator,2|4|1); %AddNamedProperty(a,"constructor", GeneratorFunctionPrototype,2|1); %AddNamedProperty(a, symbolToStringTag,"Generator",2|1); %InternalSetPrototype(GeneratorFunctionPrototype,$Function.prototype); %AddNamedProperty(GeneratorFunctionPrototype, symbolToStringTag,"GeneratorFunction",2|1); %SetCode(GeneratorFunctionPrototype,GeneratorFunctionPrototypeConstructor); %AddNamedProperty(GeneratorFunctionPrototype,"constructor", GeneratorFunction,2|1); %InternalSetPrototype(GeneratorFunction,$Function); %SetCode(GeneratorFunction,GeneratorFunctionConstructor); } SetUpGenerators(); 8object-observe? "use strict"; var observationState; function GetObservationStateJS(){ if((observationState===(void 0))){ observationState=%GetObservationState(); } if((observationState.callbackInfoMap===(void 0))){ observationState.callbackInfoMap=%ObservationWeakMapCreate(); observationState.objectInfoMap=%ObservationWeakMapCreate(); observationState.notifierObjectInfoMap=%ObservationWeakMapCreate(); observationState.pendingObservers=null; observationState.nextCallbackPriority=0; observationState.lastMicrotaskId=0; } return observationState; } function GetPendingObservers(){ return GetObservationStateJS().pendingObservers; } function SetPendingObservers(a){ GetObservationStateJS().pendingObservers=a; } function GetNextCallbackPriority(){ return GetObservationStateJS().nextCallbackPriority++; } function nullProtoObject(){ return{__proto__:null}; } function TypeMapCreate(){ return nullProtoObject(); } function TypeMapAddType(a,b,c){ a[b]=c?1:(a[b]||0)+1; } function TypeMapRemoveType(a,b){ a[b]--; } function TypeMapCreateFromList(a,b){ var c=TypeMapCreate(); for(var d=0;d<b;d++){ TypeMapAddType(c,a[d],true); } return c; } function TypeMapHasType(a,b){ return!!a[b]; } function TypeMapIsDisjointFrom(a,b){ if(!a||!b) return true; for(var c in a){ if(TypeMapHasType(a,c)&&TypeMapHasType(b,c)) return false; } return true; } var defaultAcceptTypes=(function(){ var a=[ 'add', 'update', 'delete', 'setPrototype', 'reconfigure', 'preventExtensions' ]; return TypeMapCreateFromList(a,a.length); })(); function ObserverCreate(a,b){ if((b===(void 0))) return a; var c=nullProtoObject(); c.callback=a; c.accept=b; return c; } function ObserverGetCallback(a){ return(%_ClassOf(a)==='Function')?a:a.callback; } function ObserverGetAcceptTypes(a){ return(%_ClassOf(a)==='Function')?defaultAcceptTypes:a.accept; } function ObserverIsActive(a,b){ return TypeMapIsDisjointFrom(ObjectInfoGetPerformingTypes(b), ObserverGetAcceptTypes(a)); } function ObjectInfoGetOrCreate(a){ var b=ObjectInfoGet(a); if((b===(void 0))){ if(!%_IsJSProxy(a)){ %SetIsObserved(a); } b={ object:a, changeObservers:null, notifier:null, performing:null, performingCount:0, }; %WeakCollectionSet(GetObservationStateJS().objectInfoMap, a,b); } return b; } function ObjectInfoGet(a){ return %WeakCollectionGet(GetObservationStateJS().objectInfoMap,a); } function ObjectInfoGetFromNotifier(a){ return %WeakCollectionGet(GetObservationStateJS().notifierObjectInfoMap, a); } function ObjectInfoGetNotifier(a){ if((a.notifier===null)){ a.notifier={__proto__:notifierPrototype}; %WeakCollectionSet(GetObservationStateJS().notifierObjectInfoMap, a.notifier,a); } return a.notifier; } function ChangeObserversIsOptimized(a){ return(%_ClassOf(a)==='Function')|| (%_ClassOf(a.callback)==='Function'); } function ObjectInfoNormalizeChangeObservers(a){ if(ChangeObserversIsOptimized(a.changeObservers)){ var b=a.changeObservers; var c=ObserverGetCallback(b); var d=CallbackInfoGet(c); var g=CallbackInfoGetPriority(d); a.changeObservers=nullProtoObject(); a.changeObservers[g]=b; } } function ObjectInfoAddObserver(a,b,c){ var d=CallbackInfoGetOrCreate(b); var g=ObserverCreate(b,c); if(!a.changeObservers){ a.changeObservers=g; return; } ObjectInfoNormalizeChangeObservers(a); var h=CallbackInfoGetPriority(d); a.changeObservers[h]=g; } function ObjectInfoRemoveObserver(a,b){ if(!a.changeObservers) return; if(ChangeObserversIsOptimized(a.changeObservers)){ if(b===ObserverGetCallback(a.changeObservers)) a.changeObservers=null; return; } var c=CallbackInfoGet(b); var d=CallbackInfoGetPriority(c); a.changeObservers[d]=null; } function ObjectInfoHasActiveObservers(a){ if((a===(void 0))||!a.changeObservers) return false; if(ChangeObserversIsOptimized(a.changeObservers)) return ObserverIsActive(a.changeObservers,a); for(var b in a.changeObservers){ var c=a.changeObservers[b]; if(!(c===null)&&ObserverIsActive(c,a)) return true; } return false; } function ObjectInfoAddPerformingType(a,b){ a.performing=a.performing||TypeMapCreate(); TypeMapAddType(a.performing,b); a.performingCount++; } function ObjectInfoRemovePerformingType(a,b){ a.performingCount--; TypeMapRemoveType(a.performing,b); } function ObjectInfoGetPerformingTypes(a){ return a.performingCount>0?a.performing:null; } function ConvertAcceptListToTypeMap(a){ if((a===(void 0))) return a; if(!(%_IsSpecObject(a))) throw MakeTypeError("observe_invalid_accept"); var b=ToInteger(a.length); if(b<0)b=0; return TypeMapCreateFromList(a,b); } function CallbackInfoGet(a){ return %WeakCollectionGet(GetObservationStateJS().callbackInfoMap,a); } function CallbackInfoSet(a,b){ %WeakCollectionSet(GetObservationStateJS().callbackInfoMap, a,b); } function CallbackInfoGetOrCreate(a){ var b=CallbackInfoGet(a); if(!(b===(void 0))) return b; var c=GetNextCallbackPriority(); CallbackInfoSet(a,c); return c; } function CallbackInfoGetPriority(a){ if((typeof(a)==='number')) return a; else return a.priority; } function CallbackInfoNormalize(a){ var b=CallbackInfoGet(a); if((typeof(b)==='number')){ var c=b; b=new InternalArray; b.priority=c; CallbackInfoSet(a,b); } return b; } function ObjectObserve(a,b,c){ if(!(%_IsSpecObject(a))) throw MakeTypeError("observe_non_object",["observe"]); if(%IsJSGlobalProxy(a)) throw MakeTypeError("observe_global_proxy",["observe"]); if(!(%_ClassOf(b)==='Function')) throw MakeTypeError("observe_non_function",["observe"]); if(ObjectIsFrozen(b)) throw MakeTypeError("observe_callback_frozen"); var d=%GetObjectContextObjectObserve(a); return d(a,b,c); } function NativeObjectObserve(a,b,c){ var d=ObjectInfoGetOrCreate(a); var g=ConvertAcceptListToTypeMap(c); ObjectInfoAddObserver(d,b,g); return a; } function ObjectUnobserve(a,b){ if(!(%_IsSpecObject(a))) throw MakeTypeError("observe_non_object",["unobserve"]); if(%IsJSGlobalProxy(a)) throw MakeTypeError("observe_global_proxy",["unobserve"]); if(!(%_ClassOf(b)==='Function')) throw MakeTypeError("observe_non_function",["unobserve"]); var c=ObjectInfoGet(a); if((c===(void 0))) return a; ObjectInfoRemoveObserver(c,b); return a; } function ArrayObserve(a,b){ return ObjectObserve(a,b,['add', 'update', 'delete', 'splice']); } function ArrayUnobserve(a,b){ return ObjectUnobserve(a,b); } function ObserverEnqueueIfActive(a,b,c){ if(!ObserverIsActive(a,b)|| !TypeMapHasType(ObserverGetAcceptTypes(a),c.type)){ return; } var d=ObserverGetCallback(a); if(!%ObserverObjectAndRecordHaveSameOrigin(d,c.object, c)){ return; } var g=CallbackInfoNormalize(d); if((GetPendingObservers()===null)){ SetPendingObservers(nullProtoObject()); if((%_DebugIsActive()!=0)){ var h=++GetObservationStateJS().lastMicrotaskId; var i="Object.observe"; %EnqueueMicrotask(function(){ %DebugAsyncTaskEvent({type:"willHandle",id:h,name:i}); ObserveMicrotaskRunner(); %DebugAsyncTaskEvent({type:"didHandle",id:h,name:i}); }); %DebugAsyncTaskEvent({type:"enqueue",id:h,name:i}); }else{ %EnqueueMicrotask(ObserveMicrotaskRunner); } } GetPendingObservers()[g.priority]=d; g.push(c); } function ObjectInfoEnqueueExternalChangeRecord(a,b,c){ if(!ObjectInfoHasActiveObservers(a)) return; var d=!(c===(void 0)); var g=d? {object:a.object,type:c}: {object:a.object}; for(var h in b){ if(h==='object'||(d&&h==='type'))continue; %DefineDataPropertyUnchecked( g,h,b[h],1+4); } ObjectFreezeJS(g); ObjectInfoEnqueueInternalChangeRecord(a,g); } function ObjectInfoEnqueueInternalChangeRecord(a,b){ if((typeof(b.name)==='symbol'))return; if(ChangeObserversIsOptimized(a.changeObservers)){ var c=a.changeObservers; ObserverEnqueueIfActive(c,a,b); return; } for(var d in a.changeObservers){ var c=a.changeObservers[d]; if((c===null)) continue; ObserverEnqueueIfActive(c,a,b); } } function BeginPerformSplice(a){ var b=ObjectInfoGet(a); if(!(b===(void 0))) ObjectInfoAddPerformingType(b,'splice'); } function EndPerformSplice(a){ var b=ObjectInfoGet(a); if(!(b===(void 0))) ObjectInfoRemovePerformingType(b,'splice'); } function EnqueueSpliceRecord(a,b,c,d){ var g=ObjectInfoGet(a); if(!ObjectInfoHasActiveObservers(g)) return; var h={ type:'splice', object:a, index:b, removed:c, addedCount:d }; ObjectFreezeJS(h); ObjectFreezeJS(h.removed); ObjectInfoEnqueueInternalChangeRecord(g,h); } function NotifyChange(a,b,c,d){ var g=ObjectInfoGet(b); if(!ObjectInfoHasActiveObservers(g)) return; var h; if(arguments.length==2){ h={type:a,object:b}; }else if(arguments.length==3){ h={type:a,object:b,name:c}; }else{ h={ type:a, object:b, name:c, oldValue:d }; } ObjectFreezeJS(h); ObjectInfoEnqueueInternalChangeRecord(g,h); } var notifierPrototype={}; function ObjectNotifierNotify(a){ if(!(%_IsSpecObject(this))) throw MakeTypeError("called_on_non_object",["notify"]); var b=ObjectInfoGetFromNotifier(this); if((b===(void 0))) throw MakeTypeError("observe_notify_non_notifier"); if(!(typeof(a.type)==='string')) throw MakeTypeError("observe_type_non_string"); ObjectInfoEnqueueExternalChangeRecord(b,a); } function ObjectNotifierPerformChange(a,b){ if(!(%_IsSpecObject(this))) throw MakeTypeError("called_on_non_object",["performChange"]); var c=ObjectInfoGetFromNotifier(this); if((c===(void 0))) throw MakeTypeError("observe_notify_non_notifier"); if(!(typeof(a)==='string')) throw MakeTypeError("observe_perform_non_string"); if(!(%_ClassOf(b)==='Function')) throw MakeTypeError("observe_perform_non_function"); var d=%GetObjectContextNotifierPerformChange(c); d(c,a,b); } function NativeObjectNotifierPerformChange(a,b,c){ ObjectInfoAddPerformingType(a,b); var d; try{ d=%_CallFunction((void 0),c); }finally{ ObjectInfoRemovePerformingType(a,b); } if((%_IsSpecObject(d))) ObjectInfoEnqueueExternalChangeRecord(a,d,b); } function ObjectGetNotifier(a){ if(!(%_IsSpecObject(a))) throw MakeTypeError("observe_non_object",["getNotifier"]); if(%IsJSGlobalProxy(a)) throw MakeTypeError("observe_global_proxy",["getNotifier"]); if(ObjectIsFrozen(a))return null; if(!%ObjectWasCreatedInCurrentOrigin(a))return null; var b=%GetObjectContextObjectGetNotifier(a); return b(a); } function NativeObjectGetNotifier(a){ var b=ObjectInfoGetOrCreate(a); return ObjectInfoGetNotifier(b); } function CallbackDeliverPending(a){ var b=CallbackInfoGet(a); if((b===(void 0))||(typeof(b)==='number')) return false; var c=b.priority; CallbackInfoSet(a,c); var d=GetPendingObservers(); if(!(d===null)) delete d[c]; var g=[]; %MoveArrayContents(b,g); %DeliverObservationChangeRecords(a,g); return true; } function ObjectDeliverChangeRecords(a){ if(!(%_ClassOf(a)==='Function')) throw MakeTypeError("observe_non_function",["deliverChangeRecords"]); while(CallbackDeliverPending(a)){} } function ObserveMicrotaskRunner(){ var a=GetPendingObservers(); if(!(a===null)){ SetPendingObservers(null); for(var b in a){ CallbackDeliverPending(a[b]); } } } function SetupObjectObserve(){ %CheckIsBootstrapping(); InstallFunctions($Object,2,$Array( "deliverChangeRecords",ObjectDeliverChangeRecords, "getNotifier",ObjectGetNotifier, "observe",ObjectObserve, "unobserve",ObjectUnobserve )); InstallFunctions($Array,2,$Array( "observe",ArrayObserve, "unobserve",ArrayUnobserve )); InstallFunctions(notifierPrototype,2,$Array( "notify",ObjectNotifierNotify, "performChange",ObjectNotifierPerformChange )); } SetupObjectObserve(); (collectionUK "use strict"; var $Set=global.Set; var $Map=global.Map; function SetConstructor(a){ if(!%_IsConstructCall()){ throw MakeTypeError('constructor_not_function',['Set']); } %_SetInitialize(this); if(!(a==null)){ var b=this.add; if(!(%_ClassOf(b)==='Function')){ throw MakeTypeError('property_not_function',['add',this]); } for(var c of a){ %_CallFunction(this,c,b); } } } function SetAddJS(a){ if(!(%_ClassOf(this)==='Set')){ throw MakeTypeError('incompatible_method_receiver', ['Set.prototype.add',this]); } if(a===0){ a=0; } return %_SetAdd(this,a); } function SetHasJS(a){ if(!(%_ClassOf(this)==='Set')){ throw MakeTypeError('incompatible_method_receiver', ['Set.prototype.has',this]); } return %_SetHas(this,a); } function SetDeleteJS(a){ if(!(%_ClassOf(this)==='Set')){ throw MakeTypeError('incompatible_method_receiver', ['Set.prototype.delete',this]); } return %_SetDelete(this,a); } function SetGetSizeJS(){ if(!(%_ClassOf(this)==='Set')){ throw MakeTypeError('incompatible_method_receiver', ['Set.prototype.size',this]); } return %_SetGetSize(this); } function SetClearJS(){ if(!(%_ClassOf(this)==='Set')){ throw MakeTypeError('incompatible_method_receiver', ['Set.prototype.clear',this]); } %_SetClear(this); } function SetForEach(a,b){ if(!(%_ClassOf(this)==='Set')){ throw MakeTypeError('incompatible_method_receiver', ['Set.prototype.forEach',this]); } if(!(%_ClassOf(a)==='Function')){ throw MakeTypeError('called_non_callable',[a]); } var c=false; if((b==null)){ b=%GetDefaultReceiver(a)||b; }else{ c=(!(%_IsSpecObject(b))&&%IsSloppyModeFunction(a)); } var d=new SetIterator(this,2); var g; var h=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(a); var i=[(void 0)]; while(%SetIteratorNext(d,i)){ if(h)%DebugPrepareStepInIfStepping(a); g=i[0]; var j=c?ToObject(b):b; %_CallFunction(j,g,g,this,a); } } function SetUpSet(){ %CheckIsBootstrapping(); %SetCode($Set,SetConstructor); %FunctionSetPrototype($Set,new $Object()); %AddNamedProperty($Set.prototype,"constructor",$Set,2); %AddNamedProperty( $Set.prototype,symbolToStringTag,"Set",2|1); %FunctionSetLength(SetForEach,1); InstallGetter($Set.prototype,"size",SetGetSizeJS); InstallFunctions($Set.prototype,2,$Array( "add",SetAddJS, "has",SetHasJS, "delete",SetDeleteJS, "clear",SetClearJS, "forEach",SetForEach )); } SetUpSet(); function MapConstructor(a){ if(!%_IsConstructCall()){ throw MakeTypeError('constructor_not_function',['Map']); } %_MapInitialize(this); if(!(a==null)){ var b=this.set; if(!(%_ClassOf(b)==='Function')){ throw MakeTypeError('property_not_function',['set',this]); } for(var c of a){ if(!(%_IsSpecObject(c))){ throw MakeTypeError('iterator_value_not_an_object',[c]); } %_CallFunction(this,c[0],c[1],b); } } } function MapGetJS(a){ if(!(%_ClassOf(this)==='Map')){ throw MakeTypeError('incompatible_method_receiver', ['Map.prototype.get',this]); } return %_MapGet(this,a); } function MapSetJS(a,b){ if(!(%_ClassOf(this)==='Map')){ throw MakeTypeError('incompatible_method_receiver', ['Map.prototype.set',this]); } if(a===0){ a=0; } return %_MapSet(this,a,b); } function MapHasJS(a){ if(!(%_ClassOf(this)==='Map')){ throw MakeTypeError('incompatible_method_receiver', ['Map.prototype.has',this]); } return %_MapHas(this,a); } function MapDeleteJS(a){ if(!(%_ClassOf(this)==='Map')){ throw MakeTypeError('incompatible_method_receiver', ['Map.prototype.delete',this]); } return %_MapDelete(this,a); } function MapGetSizeJS(){ if(!(%_ClassOf(this)==='Map')){ throw MakeTypeError('incompatible_method_receiver', ['Map.prototype.size',this]); } return %_MapGetSize(this); } function MapClearJS(){ if(!(%_ClassOf(this)==='Map')){ throw MakeTypeError('incompatible_method_receiver', ['Map.prototype.clear',this]); } %_MapClear(this); } function MapForEach(a,b){ if(!(%_ClassOf(this)==='Map')){ throw MakeTypeError('incompatible_method_receiver', ['Map.prototype.forEach',this]); } if(!(%_ClassOf(a)==='Function')){ throw MakeTypeError('called_non_callable',[a]); } var c=false; if((b==null)){ b=%GetDefaultReceiver(a)||b; }else{ c=(!(%_IsSpecObject(b))&&%IsSloppyModeFunction(a)); } var d=new MapIterator(this,3); var g=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(a); var h=[(void 0),(void 0)]; while(%MapIteratorNext(d,h)){ if(g)%DebugPrepareStepInIfStepping(a); var i=c?ToObject(b):b; %_CallFunction(i,h[1],h[0],this,a); } } function SetUpMap(){ %CheckIsBootstrapping(); %SetCode($Map,MapConstructor); %FunctionSetPrototype($Map,new $Object()); %AddNamedProperty($Map.prototype,"constructor",$Map,2); %AddNamedProperty( $Map.prototype,symbolToStringTag,"Map",2|1); %FunctionSetLength(MapForEach,1); InstallGetter($Map.prototype,"size",MapGetSizeJS); InstallFunctions($Map.prototype,2,$Array( "get",MapGetJS, "set",MapSetJS, "has",MapHasJS, "delete",MapDeleteJS, "clear",MapClearJS, "forEach",MapForEach )); } SetUpMap(); <weak-collection?3 "use strict"; var $WeakMap=global.WeakMap; var $WeakSet=global.WeakSet; function WeakMapConstructor(a){ if(!%_IsConstructCall()){ throw MakeTypeError('constructor_not_function',['WeakMap']); } %WeakCollectionInitialize(this); if(!(a==null)){ var b=this.set; if(!(%_ClassOf(b)==='Function')){ throw MakeTypeError('property_not_function',['set',this]); } for(var c of a){ if(!(%_IsSpecObject(c))){ throw MakeTypeError('iterator_value_not_an_object',[c]); } %_CallFunction(this,c[0],c[1],b); } } } function WeakMapGet(a){ if(!(%_ClassOf(this)==='WeakMap')){ throw MakeTypeError('incompatible_method_receiver', ['WeakMap.prototype.get',this]); } if(!(%_IsSpecObject(a)))return(void 0); return %WeakCollectionGet(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 %WeakCollectionSet(this,a,b); } function WeakMapHas(a){ if(!(%_ClassOf(this)==='WeakMap')){ throw MakeTypeError('incompatible_method_receiver', ['WeakMap.prototype.has',this]); } if(!(%_IsSpecObject(a)))return false; return %WeakCollectionHas(this,a); } function WeakMapDelete(a){ if(!(%_ClassOf(this)==='WeakMap')){ throw MakeTypeError('incompatible_method_receiver', ['WeakMap.prototype.delete',this]); } if(!(%_IsSpecObject(a)))return false; return %WeakCollectionDelete(this,a); } function SetUpWeakMap(){ %CheckIsBootstrapping(); %SetCode($WeakMap,WeakMapConstructor); %FunctionSetPrototype($WeakMap,new $Object()); %AddNamedProperty($WeakMap.prototype,"constructor",$WeakMap,2); %AddNamedProperty( $WeakMap.prototype,symbolToStringTag,"WeakMap",2|1); InstallFunctions($WeakMap.prototype,2,$Array( "get",WeakMapGet, "set",WeakMapSet, "has",WeakMapHas, "delete",WeakMapDelete )); } SetUpWeakMap(); function WeakSetConstructor(a){ if(!%_IsConstructCall()){ throw MakeTypeError('constructor_not_function',['WeakSet']); } %WeakCollectionInitialize(this); if(!(a==null)){ var b=this.add; if(!(%_ClassOf(b)==='Function')){ throw MakeTypeError('property_not_function',['add',this]); } for(var c of a){ %_CallFunction(this,c,b); } } } function WeakSetAdd(a){ if(!(%_ClassOf(this)==='WeakSet')){ throw MakeTypeError('incompatible_method_receiver', ['WeakSet.prototype.add',this]); } if(!(%_IsSpecObject(a))){ throw %MakeTypeError('invalid_weakset_value',[this,a]); } return %WeakCollectionSet(this,a,true); } function WeakSetHas(a){ if(!(%_ClassOf(this)==='WeakSet')){ throw MakeTypeError('incompatible_method_receiver', ['WeakSet.prototype.has',this]); } if(!(%_IsSpecObject(a)))return false; return %WeakCollectionHas(this,a); } function WeakSetDelete(a){ if(!(%_ClassOf(this)==='WeakSet')){ throw MakeTypeError('incompatible_method_receiver', ['WeakSet.prototype.delete',this]); } if(!(%_IsSpecObject(a)))return false; return %WeakCollectionDelete(this,a); } function SetUpWeakSet(){ %CheckIsBootstrapping(); %SetCode($WeakSet,WeakSetConstructor); %FunctionSetPrototype($WeakSet,new $Object()); %AddNamedProperty($WeakSet.prototype,"constructor",$WeakSet,2); %AddNamedProperty( $WeakSet.prototype,symbolToStringTag,"WeakSet",2|1); InstallFunctions($WeakSet.prototype,2,$Array( "add",WeakSetAdd, "has",WeakSetHas, "delete",WeakSetDelete )); } SetUpWeakSet(); Lcollection-iterator?5 "use strict"; function SetIteratorConstructor(a,b){ %SetIteratorInitialize(this,a,b); } function SetIteratorNextJS(){ if(!(%_ClassOf(this)==='Set Iterator')){ throw MakeTypeError('incompatible_method_receiver', ['Set Iterator.prototype.next',this]); } var a=[(void 0),(void 0)]; var b={value:a,done:false}; switch(%SetIteratorNext(this,a)){ case 0: b.value=(void 0); b.done=true; break; case 2: b.value=a[0]; break; case 3: a[1]=a[0]; break; } return b; } function SetIteratorSymbolIterator(){ return this; } function SetEntries(){ if(!(%_ClassOf(this)==='Set')){ throw MakeTypeError('incompatible_method_receiver', ['Set.prototype.entries',this]); } return new SetIterator(this,3); } function SetValues(){ if(!(%_ClassOf(this)==='Set')){ throw MakeTypeError('incompatible_method_receiver', ['Set.prototype.values',this]); } return new SetIterator(this,2); } function SetUpSetIterator(){ %CheckIsBootstrapping(); %SetCode(SetIterator,SetIteratorConstructor); %FunctionSetPrototype(SetIterator,new $Object()); %FunctionSetInstanceClassName(SetIterator,'Set Iterator'); InstallFunctions(SetIterator.prototype,2,$Array( 'next',SetIteratorNextJS )); %FunctionSetName(SetIteratorSymbolIterator,'[Symbol.iterator]'); %AddNamedProperty(SetIterator.prototype,symbolIterator, SetIteratorSymbolIterator,2); %AddNamedProperty(SetIterator.prototype,symbolToStringTag, "Set Iterator",1|2); } SetUpSetIterator(); function ExtendSetPrototype(){ %CheckIsBootstrapping(); InstallFunctions($Set.prototype,2,$Array( 'entries',SetEntries, 'keys',SetValues, 'values',SetValues )); %AddNamedProperty($Set.prototype,symbolIterator,SetValues,2); } ExtendSetPrototype(); function MapIteratorConstructor(a,b){ %MapIteratorInitialize(this,a,b); } function MapIteratorSymbolIterator(){ return this; } function MapIteratorNextJS(){ if(!(%_ClassOf(this)==='Map Iterator')){ throw MakeTypeError('incompatible_method_receiver', ['Map Iterator.prototype.next',this]); } var a=[(void 0),(void 0)]; var b={value:a,done:false}; switch(%MapIteratorNext(this,a)){ case 0: b.value=(void 0); b.done=true; break; case 1: b.value=a[0]; break; case 2: b.value=a[1]; break; } return b; } function MapEntries(){ if(!(%_ClassOf(this)==='Map')){ throw MakeTypeError('incompatible_method_receiver', ['Map.prototype.entries',this]); } return new MapIterator(this,3); } function MapKeys(){ if(!(%_ClassOf(this)==='Map')){ throw MakeTypeError('incompatible_method_receiver', ['Map.prototype.keys',this]); } return new MapIterator(this,1); } function MapValues(){ if(!(%_ClassOf(this)==='Map')){ throw MakeTypeError('incompatible_method_receiver', ['Map.prototype.values',this]); } return new MapIterator(this,2); } function SetUpMapIterator(){ %CheckIsBootstrapping(); %SetCode(MapIterator,MapIteratorConstructor); %FunctionSetPrototype(MapIterator,new $Object()); %FunctionSetInstanceClassName(MapIterator,'Map Iterator'); InstallFunctions(MapIterator.prototype,2,$Array( 'next',MapIteratorNextJS )); %FunctionSetName(MapIteratorSymbolIterator,'[Symbol.iterator]'); %AddNamedProperty(MapIterator.prototype,symbolIterator, MapIteratorSymbolIterator,2); %AddNamedProperty(MapIterator.prototype,symbolToStringTag, "Map Iterator",1|2); } SetUpMapIterator(); function ExtendMapPrototype(){ %CheckIsBootstrapping(); InstallFunctions($Map.prototype,2,$Array( 'entries',MapEntries, 'keys',MapKeys, 'values',MapValues )); %AddNamedProperty($Map.prototype,symbolIterator,MapEntries,2); } ExtendMapPrototype(); promisej "use strict"; var IsPromise; var PromiseCreate; var PromiseResolve; var PromiseReject; var PromiseChain; var PromiseCatch; var PromiseThen; var PromiseHasRejectHandler; var PromiseHasUserDefinedRejectHandler; var promiseStatus=(%CreateGlobalPrivateOwnSymbol("Promise#status")); var promiseValue=(%CreateGlobalPrivateOwnSymbol("Promise#value")); var promiseOnResolve=(%CreateGlobalPrivateOwnSymbol("Promise#onResolve")); var promiseOnReject=(%CreateGlobalPrivateOwnSymbol("Promise#onReject")); var promiseRaw=(%CreateGlobalPrivateOwnSymbol("Promise#raw")); var promiseHasHandler=%PromiseHasHandlerSymbol(); var lastMicrotaskId=0; (function(){ var a=function Promise(b){ if(b===promiseRaw)return; if(!%_IsConstructCall())throw MakeTypeError('not_a_promise',[this]); if(!(%_ClassOf(b)==='Function')) throw MakeTypeError('resolver_not_a_function',[b]); var c=PromiseInit(this); try{ %DebugPushPromise(c,Promise); b(function(d){PromiseResolve(c,d)}, function(g){PromiseReject(c,g)}); }catch(e){ PromiseReject(c,e); }finally{ %DebugPopPromise(); } } function PromiseSet(c,h,i,j,k){ (c[promiseStatus]=h); (c[promiseValue]=i); (c[promiseOnResolve]=j); (c[promiseOnReject]=k); if((%_DebugIsActive()!=0)){ %DebugPromiseEvent({promise:c,status:h,value:i}); } return c; } function PromiseCreateAndSet(h,i){ var c=new a(promiseRaw); if((%_DebugIsActive()!=0))PromiseSet(c,0,(void 0)); return PromiseSet(c,h,i); } function PromiseInit(c){ return PromiseSet( c,0,(void 0),new InternalArray,new InternalArray) } function PromiseDone(c,h,i,l){ if((c[promiseStatus])===0){ var m=(c[l]); if(m.length)PromiseEnqueue(i,m,h); PromiseSet(c,h,i); } } function PromiseCoerce(o,d){ if(!IsPromise(d)&&(%_IsSpecObject(d))){ var q; try{ q=d.then; }catch(g){ return %_CallFunction(o,g,PromiseRejected); } if((%_ClassOf(q)==='Function')){ var r=%_CallFunction(o,PromiseDeferred); try{ %_CallFunction(d,r.resolve,r.reject,q); }catch(g){ r.reject(g); } return r.promise; } } return d; } function PromiseHandle(i,t,r){ try{ %DebugPushPromise(r.promise,PromiseHandle); if((%_DebugIsActive()!=0&&%DebugCallbackSupportsStepping(t)))%DebugPrepareStepInIfStepping(t); var u=t(i); if(u===r.promise) throw MakeTypeError('promise_cyclic',[u]); else if(IsPromise(u)) %_CallFunction(u,r.resolve,r.reject,PromiseChain); else r.resolve(u); }catch(exception){ try{r.reject(exception);}catch(e){} }finally{ %DebugPopPromise(); } } function PromiseEnqueue(i,m,h){ var w,z,A=(%_DebugIsActive()!=0); %EnqueueMicrotask(function(){ if(A){ %DebugAsyncTaskEvent({type:"willHandle",id:w,name:z}); } for(var B=0;B<m.length;B+=2){ PromiseHandle(i,m[B],m[B+1]) } if(A){ %DebugAsyncTaskEvent({type:"didHandle",id:w,name:z}); } }); if(A){ w=++lastMicrotaskId; z=h>0?"Promise.resolve":"Promise.reject"; %DebugAsyncTaskEvent({type:"enqueue",id:w,name:z}); } } function PromiseIdResolveHandler(d){return d} function PromiseIdRejectHandler(g){throw g} function PromiseNopResolver(){} IsPromise=function IsPromise(d){ return(%_IsSpecObject(d))&&(!(d[promiseStatus]===(void 0))); } PromiseCreate=function PromiseCreate(){ return new a(PromiseNopResolver) } PromiseResolve=function PromiseResolve(c,d){ PromiseDone(c,+1,d,promiseOnResolve) } PromiseReject=function PromiseReject(c,g){ if((c[promiseStatus])==0){ var C=(%_DebugIsActive()!=0); if(C||!(!(c[promiseHasHandler]===(void 0)))){ %PromiseRejectEvent(c,g,C); } } PromiseDone(c,-1,g,promiseOnReject) } function PromiseDeferred(){ if(this===a){ var c=PromiseInit(new a(promiseRaw)); return{ promise:c, resolve:function(d){PromiseResolve(c,d)}, reject:function(g){PromiseReject(c,g)} }; }else{ var u={}; u.promise=new this(function(D,E){ u.resolve=D; u.reject=E; }) return u; } } function PromiseResolved(d){ if(this===a){ return PromiseCreateAndSet(+1,d); }else{ return new this(function(D,E){D(d)}); } } function PromiseRejected(g){ var c; if(this===a){ c=PromiseCreateAndSet(-1,g); %PromiseRejectEvent(c,g,false); }else{ c=new this(function(D,E){E(g)}); } return c; } PromiseChain=function PromiseChain(j,k){ j=(j===(void 0))?PromiseIdResolveHandler:j; k=(k===(void 0))?PromiseIdRejectHandler:k; var r=%_CallFunction(this.constructor,PromiseDeferred); switch((this[promiseStatus])){ case(void 0): throw MakeTypeError('not_a_promise',[this]); case 0: (this[promiseOnResolve]).push(j,r); (this[promiseOnReject]).push(k,r); break; case+1: PromiseEnqueue((this[promiseValue]), [j,r], +1); break; case-1: if(!(!(this[promiseHasHandler]===(void 0)))){ %PromiseRevokeReject(this); } PromiseEnqueue((this[promiseValue]), [k,r], -1); break; } (this[promiseHasHandler]=true); if((%_DebugIsActive()!=0)){ %DebugPromiseEvent({promise:r.promise,parentPromise:this}); } return r.promise; } PromiseCatch=function PromiseCatch(k){ return this.then((void 0),k); } PromiseThen=function PromiseThen(j,k){ j=(%_ClassOf(j)==='Function')?j :PromiseIdResolveHandler; k=(%_ClassOf(k)==='Function')?k :PromiseIdRejectHandler; var G=this; var o=this.constructor; return %_CallFunction( this, function(d){ d=PromiseCoerce(o,d); if(d===G){ if((%_DebugIsActive()!=0&&%DebugCallbackSupportsStepping(k)))%DebugPrepareStepInIfStepping(k); return k(MakeTypeError('promise_cyclic',[d])); }else if(IsPromise(d)){ return d.then(j,k); }else{ if((%_DebugIsActive()!=0&&%DebugCallbackSupportsStepping(j)))%DebugPrepareStepInIfStepping(j); return j(d); } }, k, PromiseChain ); } function PromiseCast(d){ return IsPromise(d)?d:new this(function(D){D(d)}); } function PromiseAll(H){ var r=%_CallFunction(this,PromiseDeferred); var I=[]; try{ var J=0; var B=0; for(var i of H){ this.resolve(i).then( (function(B){ return function(d){ I[B]=d; if(--J===0)r.resolve(I); } })(B), function(g){r.reject(g);}); ++B; ++J; } if(J===0){ r.resolve(I); } }catch(e){ r.reject(e) } return r.promise; } function PromiseRace(H){ var r=%_CallFunction(this,PromiseDeferred); try{ for(var i of H){ this.resolve(i).then( function(d){r.resolve(d)}, function(g){r.reject(g)}); } }catch(e){ r.reject(e) } return r.promise; } function PromiseHasUserDefinedRejectHandlerRecursive(c){ var K=(c[promiseOnReject]); if((K===(void 0)))return false; for(var B=0;B<K.length;B+=2){ if(K[B]!=PromiseIdRejectHandler)return true; if(PromiseHasUserDefinedRejectHandlerRecursive(K[B+1].promise)){ return true; } } return false; } PromiseHasUserDefinedRejectHandler= function PromiseHasUserDefinedRejectHandler(){ return PromiseHasUserDefinedRejectHandlerRecursive(this); }; %CheckIsBootstrapping(); %AddNamedProperty(global,'Promise',a,2); %AddNamedProperty( a.prototype,symbolToStringTag,"Promise",2|1); InstallFunctions(a,2,[ "defer",PromiseDeferred, "accept",PromiseResolved, "reject",PromiseRejected, "all",PromiseAll, "race",PromiseRace, "resolve",PromiseCast ]); InstallFunctions(a.prototype,2,[ "chain",PromiseChain, "then",PromiseThen, "catch",PromiseCatch ]); })(); messages? var kMessages={ cyclic_proto:["Cyclic __proto__ value"], code_gen_from_strings:["%0"], constructor_is_generator:["Class constructor may not be a generator"], constructor_is_accessor:["Class constructor may not be an accessor"], generator_running:["Generator is already running"], 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"], unexpected_template_string:["Unexpected template string"], malformed_regexp:["Invalid regular expression: /","%0","/: ","%1"], malformed_regexp_flags:["Invalid regular expression flags"], unterminated_regexp:["Invalid regular expression: missing /"], unterminated_template:["Unterminated template literal"], unterminated_template_expr:["Missing } in template expression"], unterminated_arg_list:["missing ) after argument list"], regexp_flags:["Cannot supply flags when constructing one RegExp from another"], incompatible_method_receiver:["Method ","%0"," called on incompatible receiver ","%1"], multiple_defaults_in_switch:["More than one default clause in switch statement"], newline_after_throw:["Illegal newline after throw"], label_redeclaration:["Label '","%0","' has already been declared"], var_redeclaration:["Identifier '","%0","' has already been declared"], duplicate_template_property:["Object template has duplicate property '","%0","'"], 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_method:["'super' is referenced from non-method"], unsupported_super:["Unsupported reference to 'super'"], non_object_property_load:["Cannot read property '","%0","' of ","%1"], non_object_property_store:["Cannot set property '","%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"], reflect_apply_wrong_args:["Reflect.apply: Arguments list has wrong type"], reflect_construct_wrong_args:["Reflect.construct: Arguments list has wrong type"], flags_getter_non_object:["RegExp.prototype.flags getter called on non-object ","%0"], 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"], undefined_or_null_to_object:["Cannot convert undefined or 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: ","%0"], 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"], invalid_weakset_value:["Invalid value used in weak set"], not_date_object:["this is not a Date object."], observe_non_object:["Object.","%0"," cannot ","%0"," non-object"], observe_non_function:["Object.","%0"," cannot deliver to non-function"], observe_callback_frozen:["Object.observe cannot deliver to a frozen function object"], observe_invalid_accept:["Third argument to Object.observe must be an array of strings."], observe_type_non_string:["Invalid changeRecord with non-string 'type' property"], observe_perform_non_string:["Invalid non-string changeType"], observe_perform_non_function:["Cannot perform non-function"], observe_notify_non_notifier:["notify called on non-notifier object"], observe_global_proxy:["%0"," cannot be called on the global proxy object"], not_typed_array:["this is not a typed array."], invalid_argument:["invalid_argument"], data_view_not_array_buffer:["First argument to DataView constructor must be an ArrayBuffer"], constructor_not_function:["Constructor ","%0"," requires 'new'"], not_a_symbol:["%0"," is not a symbol"], not_a_promise:["%0"," is not a promise"], resolver_not_a_function:["Promise resolver ","%0"," is not a function"], promise_cyclic:["Chaining cycle detected for promise ","%0"], array_functions_on_frozen:["Cannot modify frozen array elements"], array_functions_change_sealed:["Cannot add/remove sealed array elements"], first_argument_not_regexp:["First argument to ","%0"," must not be a regular expression"], not_iterable:["%0"," is not iterable"], not_an_iterator:["%0"," is not an iterator"], iterator_result_not_an_object:["Iterator result ","%0"," is not an object"], iterator_value_not_an_object:["Iterator value ","%0"," is not an entry object"], invalid_array_length:["Invalid array length"], invalid_array_buffer_length:["Invalid array buffer length"], invalid_string_length:["Invalid string length"], invalid_typed_array_offset:["Start offset is too large:"], invalid_typed_array_length:["Invalid typed array length"], invalid_typed_array_alignment:["%0"," of ","%1"," should be a multiple of ","%2"], typed_array_set_source_too_large: ["Source is too large"], typed_array_set_negative_offset: ["Start offset is negative"], invalid_data_view_offset:["Start offset is outside the bounds of the buffer"], invalid_data_view_length:["Invalid data view length"], invalid_data_view_accessor_offset: ["Offset is outside the bounds of the DataView"], stack_overflow:["Maximum call stack size exceeded"], invalid_time_value:["Invalid time value"], invalid_count_value:["Invalid count value"], invalid_code_point:["Invalid code point ","%0"], invalid_lhs_in_assignment:["Invalid left-hand side in assignment"], invalid_lhs_in_for:["Invalid left-hand side in for-loop"], 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"], paren_in_arg_string:["Function arg string contains parenthesis"], not_isvar:["builtin %IS_VAR: not a variable"], single_function_literal:["Single function literal required"], 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"], 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"], static_prototype:["Classes may not have static property named prototype"], strict_mode_with:["Strict mode code may not include a with statement"], strict_eval_arguments:["Unexpected eval or arguments in strict mode"], too_many_arguments:["Too many arguments in function call (only 65535 allowed)"], too_many_parameters:["Too many parameters in function definition (only 65535 allowed)"], too_many_variables:["Too many variables declared (only 4194303 allowed)"], strict_param_dupe:["Strict mode function may not have duplicate parameter names"], strict_octal_literal:["Octal literals are not allowed in strict mode."], template_octal_literal:["Octal literals are not allowed in template strings."], strict_delete:["Delete of an unqualified identifier in strict mode."], strict_delete_property:["Cannot delete property '","%0","' of ","%1"], 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."], strong_ellision:["In strong mode, arrays with holes are deprecated, use maps instead"], strong_arguments:["In strong mode, 'arguments' is deprecated, use '...args' instead"], strong_equal:["In strong mode, '==' and '!=' are deprecated, use '===' and '!==' instead"], strong_delete:["In strong mode, 'delete' is deprecated, use maps or sets instead"], strong_var:["In strong mode, 'var' is deprecated, use 'let' or 'const' instead"], strong_for_in:["In strong mode, 'for'-'in' loops are deprecated, use 'for'-'of' instead"], strong_empty:["In strong mode, empty sub-statements are deprecated, make them explicit with '{}' instead"], strong_use_before_declaration:["In strong mode, declaring variable '","%0","' before its use is required"], strong_unbound_global:["In strong mode, using an undeclared global variable '","%0","' is not allowed"], strong_super_call_missing:["In strong mode, invoking the super constructor in a subclass is required"], strong_super_call_duplicate:["In strong mode, invoking the super constructor multiple times is deprecated"], strong_super_call_nested:["In strong mode, invoking the super constructor nested inside another statement or expression is deprecated"], strong_constructor_return_value:["In strong mode, returning a value from a constructor is deprecated"], strong_constructor_return_misplaced:["In strong mode, returning from a constructor before its super constructor invocation is deprecated"], sloppy_lexical:["Block-scoped declarations (let, const, function, class) not yet supported outside strict mode"], malformed_arrow_function_parameter_list:["Malformed arrow function parameter list"], generator_poison_pill:["'caller' and 'arguments' properties may not be accessed on generator functions."], 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"], const_assign:["Assignment to constant variable."], symbol_to_string:["Cannot convert a Symbol value to a string"], symbol_to_primitive:["Cannot convert a Symbol wrapper object to a primitive value"], symbol_to_number:["Cannot convert a Symbol value to a number"], module_export_undefined:["Export '","%0","' is not defined in module"], duplicate_export:["Duplicate export of '","%0","'"], unexpected_super:["'super' keyword unexpected here"], extends_value_not_a_function:["Class extends value ","%0"," is not a function or null"], prototype_parent_not_an_object:["Class extends value does not have valid prototype property ","%0"], duplicate_constructor:["A class may only have one constructor"], super_constructor_call:["A 'super' constructor call may only appear as the first statement of a function, and its arguments may not access 'this'. Other forms are not yet supported."], duplicate_proto:["Duplicate __proto__ fields are not allowed in object literals"], param_after_rest:["Rest parameter must be last formal parameter"], constructor_noncallable:["Class constructors cannot be invoked without 'new'"], array_not_subclassable:["Subclassing Arrays is not currently supported."] }; function FormatString(a,b){ var c=""; var d=0; for(var g=0;g<a.length;g++){ var h=a[g]; if(h.length==2&&%_StringCharCodeAt(h,0)==0x25){ var d=(%_StringCharCodeAt(h,1)-0x30)>>>0; if(d<4){ try{ h=NoSideEffectToString(b[d]); }catch(e){ if(%IsJSModule(b[d])) h="module"; else if((%_IsSpecObject(b[d]))) h="object"; else h="#<error>"; } } } c+=h; } return c; } function NoSideEffectToString(a){ if((typeof(a)==='string'))return a; if((typeof(a)==='number'))return %_NumberToString(a); if((typeof(a)==='boolean'))return a?'true':'false'; if((a===(void 0)))return'undefined'; if((a===null))return'null'; if((%_IsFunction(a))){ var b=%_CallFunction(a,FunctionToString); if(b.length>128){ b=%_SubString(b,0,111)+"...<omitted>..."+ %_SubString(b,b.length-2,b.length); } return b; } if((typeof(a)==='symbol'))return %_CallFunction(a,$symbolToString); if((%_IsObject(a)) &&%GetDataProperty(a,"toString")===DefaultObjectToString){ var c=%GetDataProperty(a,"constructor"); if(typeof c=="function"){ var d=c.name; if((typeof(d)==='string')&&d!==""){ return"#<"+d+">"; } } } if(CanBeSafelyTreatedAsAnErrorObject(a)){ return %_CallFunction(a,ErrorToString); } return %_CallFunction(a,NoSideEffectsObjectToString); } function CanBeSafelyTreatedAsAnErrorObject(a){ switch(%_ClassOf(a)){ case'Error': case'EvalError': case'RangeError': case'ReferenceError': case'SyntaxError': case'TypeError': case'URIError': return true; } var b=%GetDataProperty(a,"toString"); return a instanceof $Error&&b===ErrorToString; } function ToStringCheckErrorObject(a){ if(CanBeSafelyTreatedAsAnErrorObject(a)){ return %_CallFunction(a,ErrorToString); }else{ return ToString(a); } } function ToDetailString(a){ if(a!=null&&(%_IsObject(a))&&a.toString===DefaultObjectToString){ 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((c===(void 0)))c=[]; return new a(FormatMessage(b,c)); } %FunctionSetInstanceClassName(Script,'Script'); %AddNamedProperty(Script.prototype,'constructor',Script, 2|4|1); %SetCode(Script,function(a){ throw new $Error("Not supported"); }); function FormatMessage(a,b){ var c=kMessages[a]; if(!c)return"<unknown message "+a+">"; return FormatString(c,b); } 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""; 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 MakeTypeErrorEmbedded(a,b){ return MakeGenericError($TypeError,a,[b]); } function MakeSyntaxErrorEmbedded(a,b){ return MakeGenericError($SyntaxError,a,[b]); } function MakeReferenceErrorEmbedded(a,b){ return MakeGenericError($ReferenceError,a,[b]); } function ScriptLineFromPosition(a){ var b=this.line_ends; var c=b.length-1; if(c<0)return-1; if(a>b[c])return-1; if(a<=b[0])return 0; var d=1; while(true){ var g=(c+d)>>1; if(a<=b[g-1]){ c=g-1; }else if(a>b[g]){ d=g+1; }else{ return g; } } } 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(!(a===(void 0))){ 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=(a===(void 0))?this.line_offset :a; var d=(b===(void 0))?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(!(a===(void 0))){ 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.source_url){ return this.source_url; } return this.name; } SetUpLockedPrototype(Script, $Array("source","name","source_url","source_mapping_url","line_ends", "line_offset","column_offset"), $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; } function SourceLocationSourceText(){ return %_CallFunction(this.script.source, this.start, this.end, $stringSubstring); } SetUpLockedPrototype(SourceLocation, $Array("script","position","line","column","start","end"), $Array( "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; return c-d.start; } function GetStackTraceLine(a,b,c,d){ return new CallSite(a,b,c,false).toString(); } var CallSiteReceiverKey=(%CreatePrivateOwnSymbol("CallSite#receiver")); var CallSiteFunctionKey=(%CreatePrivateOwnSymbol("CallSite#function")); var CallSitePositionKey=(%CreatePrivateOwnSymbol("CallSite#position")); var CallSiteStrictModeKey=(%CreatePrivateOwnSymbol("CallSite#strict_mode")); function CallSite(a,b,c,d){ (this[CallSiteReceiverKey]=a); (this[CallSiteFunctionKey]=b); (this[CallSitePositionKey]=c); (this[CallSiteStrictModeKey]=d); } function CallSiteGetThis(){ return(this[CallSiteStrictModeKey]) ?(void 0):(this[CallSiteReceiverKey]); } function CallSiteGetTypeName(){ return GetTypeName((this[CallSiteReceiverKey]),false); } function CallSiteIsToplevel(){ if((this[CallSiteReceiverKey])==null){ return true; } return(%_ClassOf((this[CallSiteReceiverKey]))==='global'); } function CallSiteIsEval(){ var a=%FunctionGetScript((this[CallSiteFunctionKey])); return a&&a.compilation_type==1; } function CallSiteGetEvalOrigin(){ var a=%FunctionGetScript((this[CallSiteFunctionKey])); return FormatEvalOrigin(a); } function CallSiteGetScriptNameOrSourceURL(){ var a=%FunctionGetScript((this[CallSiteFunctionKey])); return a?a.nameOrSourceURL():null; } function CallSiteGetFunction(){ return(this[CallSiteStrictModeKey]) ?(void 0):(this[CallSiteFunctionKey]); } function CallSiteGetFunctionName(){ var a=(this[CallSiteFunctionKey]); var b=%FunctionGetDebugName(a); if(b){ return b; } var c=%FunctionGetScript(a); if(c&&c.compilation_type==1){ return"eval"; } return null; } function CallSiteGetMethodName(){ var a=(this[CallSiteReceiverKey]); var b=(this[CallSiteFunctionKey]); var c=b.name; if(c&&a&& (%_CallFunction(a,c,ObjectLookupGetter)===b|| %_CallFunction(a,c,ObjectLookupSetter)===b|| ((%_IsObject(a))&&%GetDataProperty(a,c)===b))){ return c; } var d=null; for(var g in a){ if(%_CallFunction(a,g,ObjectLookupGetter)===b|| %_CallFunction(a,g,ObjectLookupSetter)===b|| ((%_IsObject(a))&&%GetDataProperty(a,g)===b)){ if(d){ return null; } d=g; } } if(d){ return d; } return null; } function CallSiteGetFileName(){ var a=%FunctionGetScript((this[CallSiteFunctionKey])); return a?a.name:null; } function CallSiteGetLineNumber(){ if((this[CallSitePositionKey])==-1){ return null; } var a=%FunctionGetScript((this[CallSiteFunctionKey])); var b=null; if(a){ b=a.locationFromPosition( (this[CallSitePositionKey]),true); } return b?b.line+1:null; } function CallSiteGetColumnNumber(){ if((this[CallSitePositionKey])==-1){ return null; } var a=%FunctionGetScript((this[CallSiteFunctionKey])); var b=null; if(a){ b=a.locationFromPosition( (this[CallSitePositionKey]),true); } return b?b.column+1:null; } function CallSiteIsNative(){ var a=%FunctionGetScript((this[CallSiteFunctionKey])); return a?(a.type==0):false; } function CallSiteGetPosition(){ return(this[CallSitePositionKey]); } function CallSiteIsConstructor(){ var a=(this[CallSiteReceiverKey]); var b=(a!=null&&(%_IsObject(a))) ?%GetDataProperty(a,"constructor"):null; if(!b)return false; return(this[CallSiteFunctionKey])===b; } function CallSiteToString(){ var a; var b=""; if(this.isNative()){ b="native"; }else{ a=this.getScriptNameOrSourceURL(); if(!a&&this.isEval()){ b=this.getEvalOrigin(); b+=", "; } 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[CallSiteReceiverKey]),true); var m=this.getMethodName(); if(h){ if(l&& %_CallFunction(h,l,$stringIndexOf)!=0){ g+=l+"."; } g+=h; if(m&& (%_CallFunction(h,"."+m,$stringIndexOf)!= 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 FormatErrorString(a){ try{ return %_CallFunction(a,ErrorToString); }catch(e){ try{ return"<error: "+e+">"; }catch(ee){ return"<error>"; } } } function GetStackFrames(a){ var b=new InternalArray(); var c=a[0]; for(var d=1;d<a.length;d+=4){ var g=a[d]; var h=a[d+1]; var i=a[d+2]; var j=a[d+3]; var k=%FunctionGetPositionForOffset(i,j); c--; b.push(new CallSite(g,h,k,(c<0))); } return b; } var formatting_custom_stack_trace=false; function FormatStackTrace(a,b){ var c=GetStackFrames(b); if((%_IsFunction($Error.prepareStackTrace))&&!formatting_custom_stack_trace){ var d=[]; %MoveArrayContents(c,d); formatting_custom_stack_trace=true; var g=(void 0); try{ g=$Error.prepareStackTrace(a,d); }catch(e){ throw e; }finally{ formatting_custom_stack_trace=false; } return g; } var h=new InternalArray(); h.push(FormatErrorString(a)); for(var i=0;i<c.length;i++){ var j=c[i]; var k; try{ k=j.toString(); }catch(e){ try{ k="<error: "+e+">"; }catch(ee){ k="<error>"; } } h.push(" at "+k); } return %_CallFunction(h,"\n",ArrayJoin); } function GetTypeName(a,b){ var c=a.constructor; if(!c){ return b?null: %_CallFunction(a,NoSideEffectsObjectToString); } var d=c.name; if(!d){ return b?null: %_CallFunction(a,NoSideEffectsObjectToString); } return d; } var stack_trace_symbol; var formatted_stack_trace_symbol=(%CreatePrivateOwnSymbol("formatted stack trace")); var StackTraceGetter=function(){ var a=(void 0); var b=this; while(b){ var a= (b[formatted_stack_trace_symbol]); if((a===(void 0))){ var c=(b[stack_trace_symbol]); if((c===(void 0))){ b=%_GetPrototype(b); continue; } a=FormatStackTrace(b,c); (b[stack_trace_symbol]=(void 0)); (b[formatted_stack_trace_symbol]=a); } return a; } return(void 0); }; var StackTraceSetter=function(a){ if((%HasOwnProperty(this,stack_trace_symbol))){ (this[stack_trace_symbol]=(void 0)); (this[formatted_stack_trace_symbol]=a); } }; var captureStackTrace=function captureStackTrace(a,b){ ObjectDefineProperty(a,'stack',{get:StackTraceGetter, set:StackTraceSetter, configurable:true}); %CollectStackTrace(a,b?b:captureStackTrace); } function SetUpError(){ var a=function(b){ var c=b.name; %AddNamedProperty(global,c,b,2); %AddNamedProperty(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'); %AddNamedProperty(b.prototype,'constructor',b,2); %AddNamedProperty(b.prototype,"name",c,2); %SetCode(b,function(g){ if(%_IsConstructCall()){ try{captureStackTrace(this,b);}catch(e){} if(!(g===(void 0))){ %AddNamedProperty(this,'message',ToString(g),2); } }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; %AddNamedProperty($Error.prototype,'message','',2); var visited_errors=new InternalArray(); var cyclic_error_marker=new $Object(); function GetPropertyWithoutInvokingMonkeyGetters(a,b){ var c=a; while(c&&!%HasOwnProperty(c,b)){ c=%_GetPrototype(c); } if((c===null))return(void 0); if(!(%_IsObject(c)))return a[b]; var d=%GetOwnProperty(c,b); if(d&&d[0]){ var g=b==="name"; if(c===$ReferenceError.prototype) return g?"ReferenceError":(void 0); if(c===$SyntaxError.prototype) return g?"SyntaxError":(void 0); if(c===$TypeError.prototype) return g?"TypeError":(void 0); } return a[b]; } function ErrorToStringDetectCycle(a){ if(!%PushIfAbsent(visited_errors,a))throw cyclic_error_marker; try{ var b=GetPropertyWithoutInvokingMonkeyGetters(a,"name"); b=(b===(void 0))?"Error":((typeof(%IS_VAR(b))==='string')?b:NonStringToString(b)); var c=GetPropertyWithoutInvokingMonkeyGetters(a,"message"); c=(c===(void 0))?"":((typeof(%IS_VAR(c))==='string')?c:NonStringToString(c)); if(b==="")return c; if(c==="")return b; return b+": "+c; }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]); function SetUpStackOverflowBoilerplate(){ var a=MakeRangeError('stack_overflow',[]); %DefineAccessorPropertyUnchecked( a,'stack',StackTraceGetter,StackTraceSetter,2); return a; } var kStackOverflowBoilerplate=SetUpStackOverflowBoilerplate(); json=; "use strict"; 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((i===(void 0))){ 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((l===(void 0))){ 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(!(m===(void 0))){ 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(!(m===(void 0))){ 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 JSONStringify(a,b,c){ if(%_ArgumentsLength()==1){ return %BasicJSONStringify(a); } if((%_IsObject(c))){ if((%_ClassOf(c)==='Number')){ c=ToNumber(c); }else if((%_ClassOf(c)==='String')){ c=ToString(c); } } var d; if((typeof(c)==='number')){ c=$max(0,$min(ToInteger(c),10)); d=%_SubString(" ",0,c); }else if((typeof(c)==='string')){ if(c.length>10){ d=%_SubString(c,0,10); }else{ d=c; } }else{ d=""; } if((%_IsArray(b))){ var g=new InternalArray(); var h={__proto__:null}; var i={}; var j=b.length; for(var k=0;k<j;k++){ var l=b[k]; if((%_ClassOf(l)==='String')){ l=ToString(l); }else{ if((%_ClassOf(l)==='Number'))l=ToNumber(l); if((typeof(l)==='number'))l=%_NumberToString(l); } if((typeof(l)==='string')&&h[l]!=i){ g.push(l); h[l]=i; } } b=g; } return JSONSerialize('',{'':a},b,new InternalArray(),"",d); } function SetUpJSON(){ %CheckIsBootstrapping(); %AddNamedProperty($JSON,symbolToStringTag,"JSON",1|2); InstallFunctions($JSON,2,$Array( "parse",JSONParse, "stringify",JSONStringify )); } SetUpJSON(); function JSONSerializeAdapter(a,b){ var c={}; c[a]=b; return JSONSerialize(a,c,(void 0),new InternalArray(),"",""); } 8array-iterator? "use strict"; var arrayIteratorObjectSymbol=(%CreateGlobalPrivateOwnSymbol("ArrayIterator#object")); var arrayIteratorNextIndexSymbol=(%CreateGlobalPrivateOwnSymbol("ArrayIterator#next")); var arrayIterationKindSymbol=(%CreateGlobalPrivateOwnSymbol("ArrayIterator#kind")); function ArrayIterator(){} function CreateArrayIterator(a,b){ var c=ToObject(a); var d=new ArrayIterator; (d[arrayIteratorObjectSymbol]=c); (d[arrayIteratorNextIndexSymbol]=0); (d[arrayIterationKindSymbol]=b); return d; } function CreateIteratorResultObject(a,b){ return{value:a,done:b}; } function ArrayIteratorIterator(){ return this; } function ArrayIteratorNext(){ var a=ToObject(this); if(!(!(a[arrayIteratorNextIndexSymbol]===(void 0)))){ throw MakeTypeError('incompatible_method_receiver', ['Array Iterator.prototype.next']); } var b=(a[arrayIteratorObjectSymbol]); if((b===(void 0))){ return CreateIteratorResultObject((void 0),true); } var c=(a[arrayIteratorNextIndexSymbol]); var d=(a[arrayIterationKindSymbol]); var g=(b.length>>>0); if(c>=g){ (a[arrayIteratorObjectSymbol]=(void 0)); return CreateIteratorResultObject((void 0),true); } (a[arrayIteratorNextIndexSymbol]=c+1); if(d==2){ return CreateIteratorResultObject(b[c],false); } if(d==3){ return CreateIteratorResultObject([c,b[c]],false); } return CreateIteratorResultObject(c,false); } function ArrayEntries(){ return CreateArrayIterator(this,3); } function ArrayValues(){ return CreateArrayIterator(this,2); } function ArrayKeys(){ return CreateArrayIterator(this,1); } function SetUpArrayIterator(){ %CheckIsBootstrapping(); %FunctionSetPrototype(ArrayIterator,new $Object()); %FunctionSetInstanceClassName(ArrayIterator,'Array Iterator'); InstallFunctions(ArrayIterator.prototype,2,$Array( 'next',ArrayIteratorNext )); %FunctionSetName(ArrayIteratorIterator,'[Symbol.iterator]'); %AddNamedProperty(ArrayIterator.prototype,symbolIterator, ArrayIteratorIterator,2); %AddNamedProperty(ArrayIterator.prototype,symbolToStringTag, "Array Iterator",1|2); } SetUpArrayIterator(); function ExtendArrayPrototype(){ %CheckIsBootstrapping(); InstallFunctions($Array.prototype,2,$Array( 'entries',ArrayEntries, 'keys',ArrayKeys )); %AddNamedProperty($Array.prototype,symbolIterator,ArrayValues,2); } ExtendArrayPrototype(); function ExtendTypedArrayPrototypes(){ %CheckIsBootstrapping(); %AddNamedProperty($Uint8Array.prototype,'entries',ArrayEntries,2); %AddNamedProperty($Uint8Array.prototype,'values',ArrayValues,2); %AddNamedProperty($Uint8Array.prototype,'keys',ArrayKeys,2); %AddNamedProperty($Uint8Array.prototype,symbolIterator,ArrayValues,2); %AddNamedProperty($Int8Array.prototype,'entries',ArrayEntries,2); %AddNamedProperty($Int8Array.prototype,'values',ArrayValues,2); %AddNamedProperty($Int8Array.prototype,'keys',ArrayKeys,2); %AddNamedProperty($Int8Array.prototype,symbolIterator,ArrayValues,2); %AddNamedProperty($Uint16Array.prototype,'entries',ArrayEntries,2); %AddNamedProperty($Uint16Array.prototype,'values',ArrayValues,2); %AddNamedProperty($Uint16Array.prototype,'keys',ArrayKeys,2); %AddNamedProperty($Uint16Array.prototype,symbolIterator,ArrayValues,2); %AddNamedProperty($Int16Array.prototype,'entries',ArrayEntries,2); %AddNamedProperty($Int16Array.prototype,'values',ArrayValues,2); %AddNamedProperty($Int16Array.prototype,'keys',ArrayKeys,2); %AddNamedProperty($Int16Array.prototype,symbolIterator,ArrayValues,2); %AddNamedProperty($Uint32Array.prototype,'entries',ArrayEntries,2); %AddNamedProperty($Uint32Array.prototype,'values',ArrayValues,2); %AddNamedProperty($Uint32Array.prototype,'keys',ArrayKeys,2); %AddNamedProperty($Uint32Array.prototype,symbolIterator,ArrayValues,2); %AddNamedProperty($Int32Array.prototype,'entries',ArrayEntries,2); %AddNamedProperty($Int32Array.prototype,'values',ArrayValues,2); %AddNamedProperty($Int32Array.prototype,'keys',ArrayKeys,2); %AddNamedProperty($Int32Array.prototype,symbolIterator,ArrayValues,2); %AddNamedProperty($Float32Array.prototype,'entries',ArrayEntries,2); %AddNamedProperty($Float32Array.prototype,'values',ArrayValues,2); %AddNamedProperty($Float32Array.prototype,'keys',ArrayKeys,2); %AddNamedProperty($Float32Array.prototype,symbolIterator,ArrayValues,2); %AddNamedProperty($Float64Array.prototype,'entries',ArrayEntries,2); %AddNamedProperty($Float64Array.prototype,'values',ArrayValues,2); %AddNamedProperty($Float64Array.prototype,'keys',ArrayKeys,2); %AddNamedProperty($Float64Array.prototype,symbolIterator,ArrayValues,2); %AddNamedProperty($Uint8ClampedArray.prototype,'entries',ArrayEntries,2); %AddNamedProperty($Uint8ClampedArray.prototype,'values',ArrayValues,2); %AddNamedProperty($Uint8ClampedArray.prototype,'keys',ArrayKeys,2); %AddNamedProperty($Uint8ClampedArray.prototype,symbolIterator,ArrayValues,2); } ExtendTypedArrayPrototypes(); <string-iteratorA (function(){ "use strict"; %CheckIsBootstrapping(); var a=global.Array; var b=global.Object; var c=global.String; var d= (%CreateGlobalPrivateOwnSymbol("StringIterator#iteratedString")); var g=(%CreateGlobalPrivateOwnSymbol("StringIterator#next")); function StringIterator(){} function CreateStringIterator(h){ var i=((typeof(%IS_VAR(h))==='string')?h:NonStringToString(h)); var j=new StringIterator; (j[d]=i); (j[g]=0); return j; } function StringIteratorIterator(){ return this; } function StringIteratorNext(){ var j=ToObject(this); if(!(!(j[g]===(void 0)))){ throw MakeTypeError('incompatible_method_receiver', ['String Iterator.prototype.next']); } var i=(j[d]); if((i===(void 0))){ return CreateIteratorResultObject((void 0),true); } var k=(j[g]); var l=(i.length>>>0); if(k>=l){ (j[d]=(void 0)); return CreateIteratorResultObject((void 0),true); } var m=%_StringCharCodeAt(i,k); var o=%_StringCharFromCode(m); k++; if(m>=0xD800&&m<=0xDBFF&&k<l){ var q=%_StringCharCodeAt(i,k); if(q>=0xDC00&&q<=0xDFFF){ o+=%_StringCharFromCode(q); k++; } } (j[g]=k); return CreateIteratorResultObject(o,false); } function StringPrototypeIterator(){ return CreateStringIterator(this); } %FunctionSetPrototype(StringIterator,new b()); %FunctionSetInstanceClassName(StringIterator,'String Iterator'); InstallFunctions(StringIterator.prototype,2,a( 'next',StringIteratorNext )); %FunctionSetName(StringIteratorIterator,'[Symbol.iterator]'); %AddNamedProperty(StringIterator.prototype,symbolIterator, StringIteratorIterator,2); %AddNamedProperty(StringIterator.prototype,symbolToStringTag, "String Iterator",1|2); %FunctionSetName(StringPrototypeIterator,'[Symbol.iterator]'); %AddNamedProperty(c.prototype,symbolIterator, StringPrototypeIterator,2); })(); $templates? "use strict"; var callSiteCache=new $Map; function SameCallSiteElements(a,b){ var c=a.length; var b=b.raw; if(c!==b.length)return false; for(var d=0;d<c;++d){ if(a[d]!==b[d])return false; } return true; } function GetCachedCallSite(a,b){ var c=%MapGet(callSiteCache,b); if((c===(void 0)))return; var d=c.length; for(var g=0;g<d;++g){ if(SameCallSiteElements(a,c[g]))return c[g]; } } function SetCachedCallSite(a,b){ var c=%MapGet(callSiteCache,b); var d; if((c===(void 0))){ d=new InternalArray(1); d[0]=a; %MapSet(callSiteCache,b,d); }else{ c.push(a); } return a; } function GetTemplateCallSite(a,b,c){ var d=GetCachedCallSite(b,c); if(!(d===(void 0)))return d; %AddNamedProperty(a,"raw",%ObjectFreeze(b), 1|2|4); return SetCachedCallSite(%ObjectFreeze(a),c); } i18n? (function(){ "use strict"; %CheckIsBootstrapping(); var a=global.Date; var b=global.RegExp; var c=global.String; var d=global.undefined; var g={}; %AddNamedProperty(global,"Intl",g,2); var h=['collator', 'numberformat', 'dateformat', 'breakiterator']; var i=['NFC', 'NFD', 'NFKC', 'NFKD']; var j={ 'collator':d, 'numberformat':d, 'dateformat':d, 'breakiterator':d }; var k=d; var l=d; function GetUnicodeExtensionRE(){ if(l===d){ l=new b('-u(-[a-z0-9]{2,8})+','g'); } return l; } var m=d; function GetAnyExtensionRE(){ if(m===d){ m=new b('-[a-z0-9]{1}-.*','g'); } return m; } var o=d; function GetQuotedStringRE(){ if(o===d){ o=new b("'[^']+'",'g'); } return o; } var q=d; function GetServiceRE(){ if(q===d){ q= new b('^(collator|numberformat|dateformat|breakiterator)$'); } return q; } var r=d; function GetLanguageTagRE(){ if(r===d){ BuildLanguageTagREs(); } return r; } var t=d; function GetLanguageVariantRE(){ if(t===d){ BuildLanguageTagREs(); } return t; } var u=d; function GetLanguageSingletonRE(){ if(u===d){ BuildLanguageTagREs(); } return u; } var w=d; function GetTimezoneNameCheckRE(){ if(w===d){ w= new b('^([A-Za-z]+)/([A-Za-z]+)(?:_([A-Za-z]+))*$'); } return w; } var z={ 'gregorian':'gregory', 'japanese':'japanese', 'buddhist':'buddhist', 'roc':'roc', 'persian':'persian', 'islamic-civil':'islamicc', 'islamic':'islamic', 'hebrew':'hebrew', 'chinese':'chinese', 'indian':'indian', 'coptic':'coptic', 'ethiopic':'ethiopic', 'ethiopic-amete-alem':'ethioaa' }; var A={ 'kn':{'property':'numeric','type':'boolean'}, 'kf':{'property':'caseFirst','type':'string', 'values':['false','lower','upper']} }; var B={ 'nu':{'property':d,'type':'string'} }; var C={ 'ca':{'property':d,'type':'string'}, 'nu':{'property':d,'type':'string'} }; var D=[ 'big5han','dict','direct','ducet','gb2312','phonebk','phonetic', 'pinyin','reformed','searchjl','stroke','trad','unihan','zhuyin' ]; var E= 'Function object that\'s not a constructor was created with new'; function addBoundMethod(G,H,I,J){ function getter(){ if(!%IsInitializedIntlObject(this)){ throw new $TypeError('Method '+H+' called on a '+ 'non-object or on a wrong type of object.'); } var K='__bound'+H+'__'; if(this[K]===d){ var L=this; var M; if(J===d||J===2){ M=function(N,P){ if(%_IsConstructCall()){ throw new $TypeError(E); } return I(L,N,P); } }else if(J===1){ M=function(N){ if(%_IsConstructCall()){ throw new $TypeError(E); } return I(L,N); } }else{ M=function(){ if(%_IsConstructCall()){ throw new $TypeError(E); } if(%_ArgumentsLength()>0){ return I(L,%_Arguments(0)); }else{ return I(L); } } } %FunctionSetName(M,K); %FunctionRemovePrototype(M); %SetNativeFlag(M); this[K]=M; } return this[K]; } %FunctionSetName(getter,H); %FunctionRemovePrototype(getter); %SetNativeFlag(getter); ObjectDefineProperty(G.prototype,H,{ get:getter, enumerable:false, configurable:true }); } function supportedLocalesOf(Q,R,S){ if((Q.match(GetServiceRE())===null)){ throw new $Error('Internal error, wrong service type: '+Q); } if(S===d){ S={}; }else{ S=ToObject(S); } var T=S.localeMatcher; if(T!==d){ T=c(T); if(T!=='lookup'&&T!=='best fit'){ throw new $RangeError('Illegal value for localeMatcher:'+T); } }else{ T='best fit'; } var U=initializeLocaleList(R); if(j[Q]===d){ j[Q]=getAvailableLocalesOf(Q); } if(T==='best fit'){ return initializeLocaleList(bestFitSupportedLocalesOf( U,j[Q])); } return initializeLocaleList(lookupSupportedLocalesOf( U,j[Q])); } function lookupSupportedLocalesOf(U,W){ var X=[]; for(var Y=0;Y<U.length;++Y){ var Z=U[Y].replace(GetUnicodeExtensionRE(),''); do{ if(W[Z]!==d){ X.push(U[Y]); break; } var aa=Z.lastIndexOf('-'); if(aa===-1){ break; } Z=Z.substring(0,aa); }while(true); } return X; } function bestFitSupportedLocalesOf(U,W){ return lookupSupportedLocalesOf(U,W); } function getGetOption(S,ab){ if(S===d){ throw new $Error('Internal '+ab+' error. '+ 'Default options are missing.'); } var ac=function getOption(ad,ae,af,ag){ if(S[ad]!==d){ var ah=S[ad]; switch(ae){ case'boolean': ah=$Boolean(ah); break; case'string': ah=c(ah); break; case'number': ah=$Number(ah); break; default: throw new $Error('Internal error. Wrong value type.'); } if(af!==d&&af.indexOf(ah)===-1){ throw new $RangeError('Value '+ah+' out of range for '+ab+ ' options property '+ad); } return ah; } return ag; } return ac; } function resolveLocale(Q,U,S){ U=initializeLocaleList(U); var ac=getGetOption(S,Q); var T=ac('localeMatcher','string', ['lookup','best fit'],'best fit'); var ai; if(T==='lookup'){ ai=lookupMatcher(Q,U); }else{ ai=bestFitMatcher(Q,U); } return ai; } function lookupMatcher(Q,U){ if((Q.match(GetServiceRE())===null)){ throw new $Error('Internal error, wrong service type: '+Q); } if(j[Q]===d){ j[Q]=getAvailableLocalesOf(Q); } for(var Y=0;Y<U.length;++Y){ var Z=U[Y].replace(GetAnyExtensionRE(),''); do{ if(j[Q][Z]!==d){ var aj=U[Y].match(GetUnicodeExtensionRE()); var ak=(aj===null)?'':aj[0]; return{'locale':Z,'extension':ak,'position':Y}; } var aa=Z.lastIndexOf('-'); if(aa===-1){ break; } Z=Z.substring(0,aa); }while(true); } if(k===d){ k=%GetDefaultICULocale(); } return{'locale':k,'extension':'','position':-1}; } function bestFitMatcher(Q,U){ return lookupMatcher(Q,U); } function parseExtension(ak){ var al=ak.split('-'); if(al.length<=2|| (al[0]!==''&&al[1]!=='u')){ return{}; } var am={}; var an=d; for(var Y=2;Y<al.length;++Y){ var J=al[Y].length; var ao=al[Y]; if(J===2){ am[ao]=d; an=ao; }else if(J>=3&&J<=8&&an!==d){ am[an]=ao; an=d; }else{ return{}; } } return am; } function setOptions(ap,am,aq,ac,ar){ var ak=''; var as=function updateExtension(at,ah){ return'-'+at+'-'+c(ah); } var au=function updateProperty(ad,ae,ah){ if(ae==='boolean'&&(typeof ah==='string')){ ah=(ah==='true')?true:false; } if(ad!==d){ defineWEProperty(ar,ad,ah); } } for(var at in aq){ if(aq.hasOwnProperty(at)){ var ah=d; var av=aq[at]; if(av.property!==d){ ah=ac(av.property,av.type,av.values); } if(ah!==d){ au(av.property,av.type,ah); ak+=as(at,ah); continue; } if(am.hasOwnProperty(at)){ ah=am[at]; if(ah!==d){ au(av.property,av.type,ah); ak+=as(at,ah); }else if(av.type==='boolean'){ au(av.property,av.type,true); ak+=as(at,true); } } } } return ak===''?'':'-u'+ak; } function freezeArray(aw){ aw.forEach(function(ao,ax){ ObjectDefineProperty(aw,ax,{value:ao, configurable:false, writable:false, enumerable:true}); }); ObjectDefineProperty(aw,'length',{value:aw.length, writable:false}); return aw; } function getOptimalLanguageTag(ay,ai){ if(ay===ai){ return ay; } var R=%GetLanguageTagVariants([ay,ai]); if(R[0].maximized!==R[1].maximized){ return ai; } var az=new b('^'+R[1].base); return ai.replace(az,R[0].base); } function getAvailableLocalesOf(Q){ var aA=%AvailableLocalesOf(Q); for(var Y in aA){ if(aA.hasOwnProperty(Y)){ var aB=Y.match(/^([a-z]{2,3})-([A-Z][a-z]{3})-([A-Z]{2})$/); if(aB!==null){ aA[aB[1]+'-'+aB[3]]=null; } } } return aA; } function defineWEProperty(aC,ad,ah){ ObjectDefineProperty(aC,ad, {value:ah,writable:true,enumerable:true}); } function addWEPropertyIfDefined(aC,ad,ah){ if(ah!==d){ defineWEProperty(aC,ad,ah); } } function defineWECProperty(aC,ad,ah){ ObjectDefineProperty(aC,ad, {value:ah, writable:true, enumerable:true, configurable:true}); } function addWECPropertyIfDefined(aC,ad,ah){ if(ah!==d){ defineWECProperty(aC,ad,ah); } } function toTitleCaseWord(aD){ return aD.substr(0,1).toUpperCase()+aD.substr(1).toLowerCase(); } function canonicalizeLanguageTag(aE){ if(typeof aE!=='string'&&typeof aE!=='object'|| (aE===null)){ throw new $TypeError('Language ID should be string or object.'); } var aF=c(aE); if(isValidLanguageTag(aF)===false){ throw new $RangeError('Invalid language tag: '+aF); } var aG=%CanonicalizeLanguageTag(aF); if(aG==='invalid-tag'){ throw new $RangeError('Invalid language tag: '+aF); } return aG; } function initializeLocaleList(R){ var aH=[]; if(R===d){ aH=[]; }else{ if(typeof R==='string'){ aH.push(canonicalizeLanguageTag(R)); return freezeArray(aH); } var aI=ToObject(R); var aJ=aI.length>>>0; for(var aK=0;aK<aJ;aK++){ if(aK in aI){ var ah=aI[aK]; var aG=canonicalizeLanguageTag(ah); if(aH.indexOf(aG)===-1){ aH.push(aG); } } } } return freezeArray(aH); } function isValidLanguageTag(Z){ if(GetLanguageTagRE().test(Z)===false){ return false; } if(Z.indexOf('x-')===0){ return true; } Z=Z.split(/-x-/)[0]; var aL=[]; var aM=[]; var aB=Z.split(/-/); for(var Y=1;Y<aB.length;Y++){ var ah=aB[Y]; if(GetLanguageVariantRE().test(ah)===true&&aM.length===0){ if(aL.indexOf(ah)===-1){ aL.push(ah); }else{ return false; } } if(GetLanguageSingletonRE().test(ah)===true){ if(aM.indexOf(ah)===-1){ aM.push(ah); }else{ return false; } } } return true; } function BuildLanguageTagREs(){ var aN='[a-zA-Z]'; var aO='[0-9]'; var aP='('+aN+'|'+aO+')'; var aQ='(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|'+ 'zh-min|zh-min-nan|zh-xiang)'; var aR='(en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|'+ 'i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|'+ 'i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)'; var aS='('+aR+'|'+aQ+')'; var aT='(x(-'+aP+'{1,8})+)'; var aU='('+aO+'|[A-WY-Za-wy-z])'; u=new b('^'+aU+'$','i'); var ak='('+aU+'(-'+aP+'{2,8})+)'; var aV='('+aP+'{5,8}|('+aO+aP+'{3}))'; t=new b('^'+aV+'$','i'); var aW='('+aN+'{2}|'+aO+'{3})'; var aX='('+aN+'{4})'; var aY='('+aN+'{3}(-'+aN+'{3}){0,2})'; var aZ='('+aN+'{2,3}(-'+aY+')?|'+aN+'{4}|'+ aN+'{5,8})'; var ba=aZ+'(-'+aX+')?(-'+aW+')?(-'+ aV+')*(-'+ak+')*(-'+aT+')?'; var bb= '^('+ba+'|'+aT+'|'+aS+')$'; r=new b(bb,'i'); } function initializeCollator(bc,R,S){ if(%IsInitializedIntlObject(bc)){ throw new $TypeError('Trying to re-initialize Collator object.'); } if(S===d){ S={}; } var ac=getGetOption(S,'collator'); var bd={}; defineWEProperty(bd,'usage',ac( 'usage','string',['sort','search'],'sort')); var be=ac('sensitivity','string', ['base','accent','case','variant']); if(be===d&&bd.usage==='sort'){ be='variant'; } defineWEProperty(bd,'sensitivity',be); defineWEProperty(bd,'ignorePunctuation',ac( 'ignorePunctuation','boolean',d,false)); var Z=resolveLocale('collator',R,S); var am=parseExtension(Z.extension); setOptions( S,am,A,ac,bd); var bf='default'; var ak=''; if(am.hasOwnProperty('co')&&bd.usage==='sort'){ if(D.indexOf(am.co)!==-1){ ak='-u-co-'+am.co; bf=am.co; } }else if(bd.usage==='search'){ ak='-u-co-search'; } defineWEProperty(bd,'collation',bf); var bg=Z.locale+ak; var ai=ObjectDefineProperties({},{ caseFirst:{writable:true}, collation:{value:bd.collation,writable:true}, ignorePunctuation:{writable:true}, locale:{writable:true}, numeric:{writable:true}, requestedLocale:{value:bg,writable:true}, sensitivity:{writable:true}, strength:{writable:true}, usage:{value:bd.usage,writable:true} }); var bh=%CreateCollator(bg, bd, ai); %MarkAsInitializedIntlObjectOfType(bc,'collator',bh); ObjectDefineProperty(bc,'resolved',{value:ai}); return bc; } %AddNamedProperty(g,'Collator',function(){ var R=%_Arguments(0); var S=%_Arguments(1); if(!this||this===g){ return new g.Collator(R,S); } return initializeCollator(ToObject(this),R,S); }, 2 ); %AddNamedProperty(g.Collator.prototype,'resolvedOptions',function(){ if(%_IsConstructCall()){ throw new $TypeError(E); } if(!%IsInitializedIntlObjectOfType(this,'collator')){ throw new $TypeError('resolvedOptions method called on a non-object '+ 'or on a object that is not Intl.Collator.'); } var bi=this; var Z=getOptimalLanguageTag(bi.resolved.requestedLocale, bi.resolved.locale); return{ locale:Z, usage:bi.resolved.usage, sensitivity:bi.resolved.sensitivity, ignorePunctuation:bi.resolved.ignorePunctuation, numeric:bi.resolved.numeric, caseFirst:bi.resolved.caseFirst, collation:bi.resolved.collation }; }, 2 ); %FunctionSetName(g.Collator.prototype.resolvedOptions,'resolvedOptions'); %FunctionRemovePrototype(g.Collator.prototype.resolvedOptions); %SetNativeFlag(g.Collator.prototype.resolvedOptions); %AddNamedProperty(g.Collator,'supportedLocalesOf',function(R){ if(%_IsConstructCall()){ throw new $TypeError(E); } return supportedLocalesOf('collator',R,%_Arguments(1)); }, 2 ); %FunctionSetName(g.Collator.supportedLocalesOf,'supportedLocalesOf'); %FunctionRemovePrototype(g.Collator.supportedLocalesOf); %SetNativeFlag(g.Collator.supportedLocalesOf); function compare(bc,N,P){ return %InternalCompare(%GetImplFromInitializedIntlObject(bc), c(N),c(P)); }; addBoundMethod(g.Collator,'compare',compare,2); function isWellFormedCurrencyCode(bj){ return typeof bj=="string"&& bj.length==3&& bj.match(/[^A-Za-z]/)==null; } function getNumberOption(S,ad,bk,bl,bm){ var ah=S[ad]; if(ah!==d){ ah=$Number(ah); if($isNaN(ah)||ah<bk||ah>bl){ throw new $RangeError(ad+' value is out of range.'); } return $floor(ah); } return bm; } function initializeNumberFormat(bn,R,S){ if(%IsInitializedIntlObject(bn)){ throw new $TypeError('Trying to re-initialize NumberFormat object.'); } if(S===d){ S={}; } var ac=getGetOption(S,'numberformat'); var Z=resolveLocale('numberformat',R,S); var bd={}; defineWEProperty(bd,'style',ac( 'style','string',['decimal','percent','currency'],'decimal')); var bj=ac('currency','string'); if(bj!==d&&!isWellFormedCurrencyCode(bj)){ throw new $RangeError('Invalid currency code: '+bj); } if(bd.style==='currency'&&bj===d){ throw new $TypeError('Currency code is required with currency style.'); } var bo=ac( 'currencyDisplay','string',['code','symbol','name'],'symbol'); if(bd.style==='currency'){ defineWEProperty(bd,'currency',bj.toUpperCase()); defineWEProperty(bd,'currencyDisplay',bo); } var bp=getNumberOption(S,'minimumIntegerDigits',1,21,1); defineWEProperty(bd,'minimumIntegerDigits',bp); var bq=getNumberOption(S,'minimumFractionDigits',0,20,0); defineWEProperty(bd,'minimumFractionDigits',bq); var br=getNumberOption(S,'maximumFractionDigits',bq,20,3); defineWEProperty(bd,'maximumFractionDigits',br); var bs=S['minimumSignificantDigits']; var bt=S['maximumSignificantDigits']; if(bs!==d||bt!==d){ bs=getNumberOption(S,'minimumSignificantDigits',1,21,0); defineWEProperty(bd,'minimumSignificantDigits',bs); bt=getNumberOption(S,'maximumSignificantDigits',bs,21,21); defineWEProperty(bd,'maximumSignificantDigits',bt); } defineWEProperty(bd,'useGrouping',ac( 'useGrouping','boolean',d,true)); var am=parseExtension(Z.extension); var ak=setOptions(S,am,B, ac,bd); var bg=Z.locale+ak; var ai=ObjectDefineProperties({},{ currency:{writable:true}, currencyDisplay:{writable:true}, locale:{writable:true}, maximumFractionDigits:{writable:true}, minimumFractionDigits:{writable:true}, minimumIntegerDigits:{writable:true}, numberingSystem:{writable:true}, requestedLocale:{value:bg,writable:true}, style:{value:bd.style,writable:true}, useGrouping:{writable:true} }); if(bd.hasOwnProperty('minimumSignificantDigits')){ defineWEProperty(ai,'minimumSignificantDigits',d); } if(bd.hasOwnProperty('maximumSignificantDigits')){ defineWEProperty(ai,'maximumSignificantDigits',d); } var bu=%CreateNumberFormat(bg, bd, ai); if(bd.style==='currency'){ ObjectDefineProperty(ai,'currencyDisplay',{value:bo, writable:true}); } %MarkAsInitializedIntlObjectOfType(bn,'numberformat',bu); ObjectDefineProperty(bn,'resolved',{value:ai}); return bn; } %AddNamedProperty(g,'NumberFormat',function(){ var R=%_Arguments(0); var S=%_Arguments(1); if(!this||this===g){ return new g.NumberFormat(R,S); } return initializeNumberFormat(ToObject(this),R,S); }, 2 ); %AddNamedProperty(g.NumberFormat.prototype,'resolvedOptions',function(){ if(%_IsConstructCall()){ throw new $TypeError(E); } if(!%IsInitializedIntlObjectOfType(this,'numberformat')){ throw new $TypeError('resolvedOptions method called on a non-object'+ ' or on a object that is not Intl.NumberFormat.'); } var bv=this; var Z=getOptimalLanguageTag(bv.resolved.requestedLocale, bv.resolved.locale); var bw={ locale:Z, numberingSystem:bv.resolved.numberingSystem, style:bv.resolved.style, useGrouping:bv.resolved.useGrouping, minimumIntegerDigits:bv.resolved.minimumIntegerDigits, minimumFractionDigits:bv.resolved.minimumFractionDigits, maximumFractionDigits:bv.resolved.maximumFractionDigits, }; if(bw.style==='currency'){ defineWECProperty(bw,'currency',bv.resolved.currency); defineWECProperty(bw,'currencyDisplay', bv.resolved.currencyDisplay); } if(bv.resolved.hasOwnProperty('minimumSignificantDigits')){ defineWECProperty(bw,'minimumSignificantDigits', bv.resolved.minimumSignificantDigits); } if(bv.resolved.hasOwnProperty('maximumSignificantDigits')){ defineWECProperty(bw,'maximumSignificantDigits', bv.resolved.maximumSignificantDigits); } return bw; }, 2 ); %FunctionSetName(g.NumberFormat.prototype.resolvedOptions, 'resolvedOptions'); %FunctionRemovePrototype(g.NumberFormat.prototype.resolvedOptions); %SetNativeFlag(g.NumberFormat.prototype.resolvedOptions); %AddNamedProperty(g.NumberFormat,'supportedLocalesOf',function(R){ if(%_IsConstructCall()){ throw new $TypeError(E); } return supportedLocalesOf('numberformat',R,%_Arguments(1)); }, 2 ); %FunctionSetName(g.NumberFormat.supportedLocalesOf,'supportedLocalesOf'); %FunctionRemovePrototype(g.NumberFormat.supportedLocalesOf); %SetNativeFlag(g.NumberFormat.supportedLocalesOf); function formatNumber(bu,ah){ var bx=$Number(ah)+0; return %InternalNumberFormat(%GetImplFromInitializedIntlObject(bu), bx); } function parseNumber(bu,ah){ return %InternalNumberParse(%GetImplFromInitializedIntlObject(bu), c(ah)); } addBoundMethod(g.NumberFormat,'format',formatNumber,1); addBoundMethod(g.NumberFormat,'v8Parse',parseNumber,1); function toLDMLString(S){ var ac=getGetOption(S,'dateformat'); var by=''; var bz=ac('weekday','string',['narrow','short','long']); by+=appendToLDMLString( bz,{narrow:'EEEEE',short:'EEE',long:'EEEE'}); bz=ac('era','string',['narrow','short','long']); by+=appendToLDMLString( bz,{narrow:'GGGGG',short:'GGG',long:'GGGG'}); bz=ac('year','string',['2-digit','numeric']); by+=appendToLDMLString(bz,{'2-digit':'yy','numeric':'y'}); bz=ac('month','string', ['2-digit','numeric','narrow','short','long']); by+=appendToLDMLString(bz,{'2-digit':'MM','numeric':'M', 'narrow':'MMMMM','short':'MMM','long':'MMMM'}); bz=ac('day','string',['2-digit','numeric']); by+=appendToLDMLString( bz,{'2-digit':'dd','numeric':'d'}); var bA=ac('hour12','boolean'); bz=ac('hour','string',['2-digit','numeric']); if(bA===d){ by+=appendToLDMLString(bz,{'2-digit':'jj','numeric':'j'}); }else if(bA===true){ by+=appendToLDMLString(bz,{'2-digit':'hh','numeric':'h'}); }else{ by+=appendToLDMLString(bz,{'2-digit':'HH','numeric':'H'}); } bz=ac('minute','string',['2-digit','numeric']); by+=appendToLDMLString(bz,{'2-digit':'mm','numeric':'m'}); bz=ac('second','string',['2-digit','numeric']); by+=appendToLDMLString(bz,{'2-digit':'ss','numeric':'s'}); bz=ac('timeZoneName','string',['short','long']); by+=appendToLDMLString(bz,{short:'z',long:'zzzz'}); return by; } function appendToLDMLString(bz,bB){ if(bz!==d){ return bB[bz]; }else{ return''; } } function fromLDMLString(by){ by=by.replace(GetQuotedStringRE(),''); var S={}; var bC=by.match(/E{3,5}/g); S=appendToDateTimeObject( S,'weekday',bC,{EEEEE:'narrow',EEE:'short',EEEE:'long'}); bC=by.match(/G{3,5}/g); S=appendToDateTimeObject( S,'era',bC,{GGGGG:'narrow',GGG:'short',GGGG:'long'}); bC=by.match(/y{1,2}/g); S=appendToDateTimeObject( S,'year',bC,{y:'numeric',yy:'2-digit'}); bC=by.match(/M{1,5}/g); S=appendToDateTimeObject(S,'month',bC,{MM:'2-digit', M:'numeric',MMMMM:'narrow',MMM:'short',MMMM:'long'}); bC=by.match(/L{1,5}/g); S=appendToDateTimeObject(S,'month',bC,{LL:'2-digit', L:'numeric',LLLLL:'narrow',LLL:'short',LLLL:'long'}); bC=by.match(/d{1,2}/g); S=appendToDateTimeObject( S,'day',bC,{d:'numeric',dd:'2-digit'}); bC=by.match(/h{1,2}/g); if(bC!==null){ S['hour12']=true; } S=appendToDateTimeObject( S,'hour',bC,{h:'numeric',hh:'2-digit'}); bC=by.match(/H{1,2}/g); if(bC!==null){ S['hour12']=false; } S=appendToDateTimeObject( S,'hour',bC,{H:'numeric',HH:'2-digit'}); bC=by.match(/m{1,2}/g); S=appendToDateTimeObject( S,'minute',bC,{m:'numeric',mm:'2-digit'}); bC=by.match(/s{1,2}/g); S=appendToDateTimeObject( S,'second',bC,{s:'numeric',ss:'2-digit'}); bC=by.match(/z|zzzz/g); S=appendToDateTimeObject( S,'timeZoneName',bC,{z:'short',zzzz:'long'}); return S; } function appendToDateTimeObject(S,bz,bC,bB){ if((bC===null)){ if(!S.hasOwnProperty(bz)){ defineWEProperty(S,bz,d); } return S; } var ad=bC[0]; defineWEProperty(S,bz,bB[ad]); return S; } function toDateTimeOptions(S,bD,bE){ if(S===d){ S={}; }else{ S=((%_IsSpecObject(%IS_VAR(S)))?S:ToObject(S)); } var bF=true; if((bD==='date'||bD==='any')&& (S.weekday!==d||S.year!==d|| S.month!==d||S.day!==d)){ bF=false; } if((bD==='time'||bD==='any')&& (S.hour!==d||S.minute!==d|| S.second!==d)){ bF=false; } if(bF&&(bE==='date'||bE==='all')){ ObjectDefineProperty(S,'year',{value:'numeric', writable:true, enumerable:true, configurable:true}); ObjectDefineProperty(S,'month',{value:'numeric', writable:true, enumerable:true, configurable:true}); ObjectDefineProperty(S,'day',{value:'numeric', writable:true, enumerable:true, configurable:true}); } if(bF&&(bE==='time'||bE==='all')){ ObjectDefineProperty(S,'hour',{value:'numeric', writable:true, enumerable:true, configurable:true}); ObjectDefineProperty(S,'minute',{value:'numeric', writable:true, enumerable:true, configurable:true}); ObjectDefineProperty(S,'second',{value:'numeric', writable:true, enumerable:true, configurable:true}); } return S; } function initializeDateTimeFormat(bG,R,S){ if(%IsInitializedIntlObject(bG)){ throw new $TypeError('Trying to re-initialize DateTimeFormat object.'); } if(S===d){ S={}; } var Z=resolveLocale('dateformat',R,S); S=toDateTimeOptions(S,'any','date'); var ac=getGetOption(S,'dateformat'); var T=ac('formatMatcher','string', ['basic','best fit'],'best fit'); var by=toLDMLString(S); var bH=canonicalizeTimeZoneID(S.timeZone); var bd={}; var am=parseExtension(Z.extension); var ak=setOptions(S,am,C, ac,bd); var bg=Z.locale+ak; var ai=ObjectDefineProperties({},{ calendar:{writable:true}, day:{writable:true}, era:{writable:true}, hour12:{writable:true}, hour:{writable:true}, locale:{writable:true}, minute:{writable:true}, month:{writable:true}, numberingSystem:{writable:true}, pattern:{writable:true}, requestedLocale:{value:bg,writable:true}, second:{writable:true}, timeZone:{writable:true}, timeZoneName:{writable:true}, tz:{value:bH,writable:true}, weekday:{writable:true}, year:{writable:true} }); var bu=%CreateDateTimeFormat( bg,{skeleton:by,timeZone:bH},ai); if(bH!==d&&bH!==ai.timeZone){ throw new $RangeError('Unsupported time zone specified '+bH); } %MarkAsInitializedIntlObjectOfType(bG,'dateformat',bu); ObjectDefineProperty(bG,'resolved',{value:ai}); return bG; } %AddNamedProperty(g,'DateTimeFormat',function(){ var R=%_Arguments(0); var S=%_Arguments(1); if(!this||this===g){ return new g.DateTimeFormat(R,S); } return initializeDateTimeFormat(ToObject(this),R,S); }, 2 ); %AddNamedProperty(g.DateTimeFormat.prototype,'resolvedOptions',function(){ if(%_IsConstructCall()){ throw new $TypeError(E); } if(!%IsInitializedIntlObjectOfType(this,'dateformat')){ throw new $TypeError('resolvedOptions method called on a non-object or '+ 'on a object that is not Intl.DateTimeFormat.'); } var bv=this; var bI=fromLDMLString(bv.resolved.pattern); var bJ=z[bv.resolved.calendar]; if(bJ===d){ bJ=bv.resolved.calendar; } var Z=getOptimalLanguageTag(bv.resolved.requestedLocale, bv.resolved.locale); var bw={ locale:Z, numberingSystem:bv.resolved.numberingSystem, calendar:bJ, timeZone:bv.resolved.timeZone }; addWECPropertyIfDefined(bw,'timeZoneName',bI.timeZoneName); addWECPropertyIfDefined(bw,'era',bI.era); addWECPropertyIfDefined(bw,'year',bI.year); addWECPropertyIfDefined(bw,'month',bI.month); addWECPropertyIfDefined(bw,'day',bI.day); addWECPropertyIfDefined(bw,'weekday',bI.weekday); addWECPropertyIfDefined(bw,'hour12',bI.hour12); addWECPropertyIfDefined(bw,'hour',bI.hour); addWECPropertyIfDefined(bw,'minute',bI.minute); addWECPropertyIfDefined(bw,'second',bI.second); return bw; }, 2 ); %FunctionSetName(g.DateTimeFormat.prototype.resolvedOptions, 'resolvedOptions'); %FunctionRemovePrototype(g.DateTimeFormat.prototype.resolvedOptions); %SetNativeFlag(g.DateTimeFormat.prototype.resolvedOptions); %AddNamedProperty(g.DateTimeFormat,'supportedLocalesOf',function(R){ if(%_IsConstructCall()){ throw new $TypeError(E); } return supportedLocalesOf('dateformat',R,%_Arguments(1)); }, 2 ); %FunctionSetName(g.DateTimeFormat.supportedLocalesOf,'supportedLocalesOf'); %FunctionRemovePrototype(g.DateTimeFormat.supportedLocalesOf); %SetNativeFlag(g.DateTimeFormat.supportedLocalesOf); function formatDate(bu,bK){ var bL; if(bK===d){ bL=a.now(); }else{ bL=$Number(bK); } if(!$isFinite(bL)){ throw new $RangeError('Provided date is not in valid range.'); } return %InternalDateFormat(%GetImplFromInitializedIntlObject(bu), new a(bL)); } function parseDate(bu,ah){ return %InternalDateParse(%GetImplFromInitializedIntlObject(bu), c(ah)); } addBoundMethod(g.DateTimeFormat,'format',formatDate,0); addBoundMethod(g.DateTimeFormat,'v8Parse',parseDate,1); function canonicalizeTimeZoneID(bM){ if(bM===d){ return bM; } var bN=bM.toUpperCase(); if(bN==='UTC'||bN==='GMT'|| bN==='ETC/UTC'||bN==='ETC/GMT'){ return'UTC'; } var bC=GetTimezoneNameCheckRE().exec(bM); if((bC===null)){ throw new $RangeError('Expected Area/Location for time zone, got '+bM); } var bw=toTitleCaseWord(bC[1])+'/'+toTitleCaseWord(bC[2]); var Y=3; while(bC[Y]!==d&&Y<bC.length){ bw=bw+'_'+toTitleCaseWord(bC[Y]); Y++; } return bw; } function initializeBreakIterator(bO,R,S){ if(%IsInitializedIntlObject(bO)){ throw new $TypeError('Trying to re-initialize v8BreakIterator object.'); } if(S===d){ S={}; } var ac=getGetOption(S,'breakiterator'); var bd={}; defineWEProperty(bd,'type',ac( 'type','string',['character','word','sentence','line'],'word')); var Z=resolveLocale('breakiterator',R,S); var ai=ObjectDefineProperties({},{ requestedLocale:{value:Z.locale,writable:true}, type:{value:bd.type,writable:true}, locale:{writable:true} }); var bP=%CreateBreakIterator(Z.locale, bd, ai); %MarkAsInitializedIntlObjectOfType(bO,'breakiterator', bP); ObjectDefineProperty(bO,'resolved',{value:ai}); return bO; } %AddNamedProperty(g,'v8BreakIterator',function(){ var R=%_Arguments(0); var S=%_Arguments(1); if(!this||this===g){ return new g.v8BreakIterator(R,S); } return initializeBreakIterator(ToObject(this),R,S); }, 2 ); %AddNamedProperty(g.v8BreakIterator.prototype,'resolvedOptions', function(){ if(%_IsConstructCall()){ throw new $TypeError(E); } if(!%IsInitializedIntlObjectOfType(this,'breakiterator')){ throw new $TypeError('resolvedOptions method called on a non-object or '+ 'on a object that is not Intl.v8BreakIterator.'); } var bQ=this; var Z=getOptimalLanguageTag(bQ.resolved.requestedLocale, bQ.resolved.locale); return{ locale:Z, type:bQ.resolved.type }; }, 2 ); %FunctionSetName(g.v8BreakIterator.prototype.resolvedOptions, 'resolvedOptions'); %FunctionRemovePrototype(g.v8BreakIterator.prototype.resolvedOptions); %SetNativeFlag(g.v8BreakIterator.prototype.resolvedOptions); %AddNamedProperty(g.v8BreakIterator,'supportedLocalesOf', function(R){ if(%_IsConstructCall()){ throw new $TypeError(E); } return supportedLocalesOf('breakiterator',R,%_Arguments(1)); }, 2 ); %FunctionSetName(g.v8BreakIterator.supportedLocalesOf,'supportedLocalesOf'); %FunctionRemovePrototype(g.v8BreakIterator.supportedLocalesOf); %SetNativeFlag(g.v8BreakIterator.supportedLocalesOf); function adoptText(bO,bR){ %BreakIteratorAdoptText(%GetImplFromInitializedIntlObject(bO), c(bR)); } function first(bO){ return %BreakIteratorFirst(%GetImplFromInitializedIntlObject(bO)); } function next(bO){ return %BreakIteratorNext(%GetImplFromInitializedIntlObject(bO)); } function current(bO){ return %BreakIteratorCurrent(%GetImplFromInitializedIntlObject(bO)); } function breakType(bO){ return %BreakIteratorBreakType(%GetImplFromInitializedIntlObject(bO)); } addBoundMethod(g.v8BreakIterator,'adoptText',adoptText,1); addBoundMethod(g.v8BreakIterator,'first',first,0); addBoundMethod(g.v8BreakIterator,'next',next,0); addBoundMethod(g.v8BreakIterator,'current',current,0); addBoundMethod(g.v8BreakIterator,'breakType',breakType,0); var bS={ 'collator':g.Collator, 'numberformat':g.NumberFormat, 'dateformatall':g.DateTimeFormat, 'dateformatdate':g.DateTimeFormat, 'dateformattime':g.DateTimeFormat }; var bT={ 'collator':d, 'numberformat':d, 'dateformatall':d, 'dateformatdate':d, 'dateformattime':d, }; function cachedOrNewService(Q,R,S,bE){ var bU=(bE===d)?S:bE; if(R===d&&S===d){ if(bT[Q]===d){ bT[Q]=new bS[Q](R,bU); } return bT[Q]; } return new bS[Q](R,bU); } OverrideFunction(c.prototype,'localeCompare',function(L){ if(%_IsConstructCall()){ throw new $TypeError(E); } if((this==null)){ throw new $TypeError('Method invoked on undefined or null value.'); } var R=%_Arguments(1); var S=%_Arguments(2); var bc=cachedOrNewService('collator',R,S); return compare(bc,this,L); } ); OverrideFunction(c.prototype,'normalize',function(L){ if(%_IsConstructCall()){ throw new $TypeError(E); } if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.normalize"]); var bV=c(%_Arguments(0)||'NFC'); var bW=i.indexOf(bV); if(bW===-1){ throw new $RangeError('The normalization form should be one of ' +i.join(', ')+'.'); } return %StringNormalize(this,bW); } ); OverrideFunction($Number.prototype,'toLocaleString',function(){ if(%_IsConstructCall()){ throw new $TypeError(E); } if(!(this instanceof $Number)&&typeof(this)!=='number'){ throw new $TypeError('Method invoked on an object that is not Number.'); } var R=%_Arguments(0); var S=%_Arguments(1); var bn=cachedOrNewService('numberformat',R,S); return formatNumber(bn,this); } ); function toLocaleDateTime(bX,R,S,bD,bE,Q){ if(!(bX instanceof a)){ throw new $TypeError('Method invoked on an object that is not Date.'); } if($isNaN(bX)){ return'Invalid Date'; } var bd=toDateTimeOptions(S,bD,bE); var bG= cachedOrNewService(Q,R,S,bd); return formatDate(bG,bX); } OverrideFunction(a.prototype,'toLocaleString',function(){ if(%_IsConstructCall()){ throw new $TypeError(E); } var R=%_Arguments(0); var S=%_Arguments(1); return toLocaleDateTime( this,R,S,'any','all','dateformatall'); } ); OverrideFunction(a.prototype,'toLocaleDateString',function(){ if(%_IsConstructCall()){ throw new $TypeError(E); } var R=%_Arguments(0); var S=%_Arguments(1); return toLocaleDateTime( this,R,S,'date','date','dateformatdate'); } ); OverrideFunction(a.prototype,'toLocaleTimeString',function(){ if(%_IsConstructCall()){ throw new $TypeError(E); } var R=%_Arguments(0); var S=%_Arguments(1); return toLocaleDateTime( this,R,S,'time','time','dateformattime'); } ); })(); proxy!2 "use strict"; var $Proxy=new $Object(); function ProxyCreate(a,b){ if(!(%_IsSpecObject(a))) throw MakeTypeError("handler_non_object",["create"]) if((b===(void 0))) b=null else if(!((%_IsSpecObject(b))||(b===null))) throw MakeTypeError("proto_non_object",["create"]) return %CreateJSProxy(a,b) } function ProxyCreateFunction(a,b,c){ if(!(%_IsSpecObject(a))) throw MakeTypeError("handler_non_object",["create"]) if(!(%_ClassOf(b)==='Function')) throw MakeTypeError("trap_function_expected",["createFunction","call"]) if((c===(void 0))){ 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 SetUpProxy(){ %CheckIsBootstrapping() var a=%GlobalProxy(global); a.Proxy=$Proxy; InstallFunctions($Proxy,2,[ "create",ProxyCreate, "createFunction",ProxyCreateFunction ]) } SetUpProxy(); function DerivedConstructTrap(a){ return function(){ var b=this.prototype if(!(%_IsSpecObject(b)))b=$Object.prototype var 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((c===(void 0))){return c} if('value'in c){ return c.value }else{ if((c.get===(void 0))){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] if((typeof(d)==='symbol'))continue var e=this.getOwnPropertyDescriptor(((typeof(%IS_VAR(d))==='string')?d:NonStringToString(d))) if(!(e===(void 0))&&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] if((typeof(d)==='symbol'))continue var e=this.getPropertyDescriptor(((typeof(%IS_VAR(d))==='string')?d:NonStringToString(d))) if(!(e===(void 0))){ if(!e.configurable){ throw MakeTypeError("proxy_prop_not_configurable", [this,"getPropertyDescriptor",d]) } if(e.enumerable)b[count++]=a[c] } } return b } function ProxyEnumerate(a){ var b=%GetHandler(a) if((b.enumerate===(void 0))){ return %Apply(DerivedEnumerateTrap,b,[],0,0) }else{ return ToNameArray(b.enumerate(),"enumerate",false) } } $generatora! "use strict"; function GeneratorObjectNext(a){ if(!(%_ClassOf(this)==='Generator')){ throw MakeTypeError('incompatible_method_receiver', ['[Generator].prototype.next',this]); } var b=%GeneratorGetContinuation(this); if(b>0){ if((%_DebugIsActive()!=0))%DebugPrepareStepInIfStepping(this); try{ return %_GeneratorNext(this,a); }catch(e){ %GeneratorClose(this); throw e; } }else if(b==0){ return{value:void 0,done:true}; }else{ throw MakeTypeError('generator_running',[]); } } function GeneratorObjectThrow(a){ if(!(%_ClassOf(this)==='Generator')){ throw MakeTypeError('incompatible_method_receiver', ['[Generator].prototype.throw',this]); } var b=%GeneratorGetContinuation(this); if(b>0){ try{ return %_GeneratorThrow(this,a); }catch(e){ %GeneratorClose(this); throw e; } }else if(b==0){ throw a; }else{ throw MakeTypeError('generator_running',[]); } } function GeneratorObjectIterator(){ return this; } function GeneratorFunctionPrototypeConstructor(a){ if(%_IsConstructCall()){ throw MakeTypeError('not_constructor',['GeneratorFunctionPrototype']); } } function GeneratorFunctionConstructor(a){ return NewFunctionFromString(arguments,'function*'); } function SetUpGenerators(){ %CheckIsBootstrapping(); %NeverOptimizeFunction(GeneratorObjectNext); %NeverOptimizeFunction(GeneratorObjectThrow); var a=GeneratorFunctionPrototype.prototype; InstallFunctions(a, 2|4|1, ["next",GeneratorObjectNext, "throw",GeneratorObjectThrow]); %FunctionSetName(GeneratorObjectIterator,'[Symbol.iterator]'); %AddNamedProperty(a,symbolIterator, GeneratorObjectIterator,2|4|1); %AddNamedProperty(a,"constructor", GeneratorFunctionPrototype,2|1); %AddNamedProperty(a, symbolToStringTag,"Generator",2|1); %InternalSetPrototype(GeneratorFunctionPrototype,$Function.prototype); %AddNamedProperty(GeneratorFunctionPrototype, symbolToStringTag,"GeneratorFunction",2|1); %SetCode(GeneratorFunctionPrototype,GeneratorFunctionPrototypeConstructor); %AddNamedProperty(GeneratorFunctionPrototype,"constructor", GeneratorFunction,2|1); %InternalSetPrototype(GeneratorFunction,$Function); %SetCode(GeneratorFunction,GeneratorFunctionConstructor); } SetUpGenerators(); 4harmony-array?5 'use strict'; function ArrayFind(a){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Array.prototype.find"]); var b=ToObject(this); var c=ToInteger(b.length); if(!(%_ClassOf(a)==='Function')){ throw MakeTypeError('called_non_callable',[a]); } var d; if(%_ArgumentsLength()>1){ d=%_Arguments(1); } var e=false; if((d==null)){ d=%GetDefaultReceiver(a)||d; }else{ e=(!(%_IsSpecObject(d))&&%IsSloppyModeFunction(a)); } for(var f=0;f<c;f++){ if(f in b){ var g=b[f]; var h=e?ToObject(d):d; if(%_CallFunction(h,g,f,b,a)){ return g; } } } return; } function ArrayFindIndex(a){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Array.prototype.findIndex"]); var b=ToObject(this); var c=ToInteger(b.length); if(!(%_ClassOf(a)==='Function')){ throw MakeTypeError('called_non_callable',[a]); } var d; if(%_ArgumentsLength()>1){ d=%_Arguments(1); } var e=false; if((d==null)){ d=%GetDefaultReceiver(a)||d; }else{ e=(!(%_IsSpecObject(d))&&%IsSloppyModeFunction(a)); } for(var f=0;f<c;f++){ if(f in b){ var g=b[f]; var h=e?ToObject(d):d; if(%_CallFunction(h,g,f,b,a)){ return f; } } } return-1; } function ArrayFill(a){ if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Array.prototype.fill"]); var b=ToObject(this); var c=(b.length>>>0); var d=0; var e=c; if(%_ArgumentsLength()>1){ d=%_Arguments(1); d=(d===(void 0))?0:(%_IsSmi(%IS_VAR(d))?d:%NumberToInteger(ToNumber(d))); if(%_ArgumentsLength()>2){ e=%_Arguments(2); e=(e===(void 0))?c:(%_IsSmi(%IS_VAR(e))?e:%NumberToInteger(ToNumber(e))); } } if(d<0){ d+=c; if(d<0)d=0; }else{ if(d>c)d=c; } if(e<0){ e+=c; if(e<0)e=0; }else{ if(e>c)e=c; } if((e-d)>0&&ObjectIsFrozen(b)){ throw MakeTypeError("array_functions_on_frozen", ["Array.prototype.fill"]); } for(;d<e;d++) b[d]=a; return b; } function ArrayFrom(a,b,c){ var d=ToObject(a); var e=!(b===(void 0)); if(e){ if(!(%_ClassOf(b)==='Function')){ throw MakeTypeError('called_non_callable',[b]); }else if((c==null)){ c=%GetDefaultReceiver(b)||c; }else if(!(%_IsSpecObject(c))&&%IsSloppyModeFunction(b)){ c=ToObject(c); } } var f=GetMethod(d,symbolIterator); var g; var h; var i; var j; if(!(f===(void 0))){ h=%IsConstructor(this)?new this():[]; var k=GetIterator(d,f); g=0; while(true){ var l=k.next(); if(!(%_IsObject(l))){ throw MakeTypeError("iterator_result_not_an_object",[l]); } if(l.done){ h.length=g; return h; } j=l.value; if(e){ i=%_CallFunction(c,j,g,b); }else{ i=j; } %AddElement(h,g++,i,0); } }else{ var m=ToLength(d.length); h=%IsConstructor(this)?new this(m):new $Array(m); for(g=0;g<m;++g){ j=d[g]; if(e){ i=%_CallFunction(c,j,g,b); }else{ i=j; } %AddElement(h,g,i,0); } h.length=g; return h; } } function ArrayOf(){ var a=%_ArgumentsLength(); var b=this; var c=%IsConstructor(b)?new b(a):[]; for(var d=0;d<a;d++){ %AddElement(c,d,%_Arguments(d),0); } c.length=a; return c; } function HarmonyArrayExtendSymbolPrototype(){ %CheckIsBootstrapping(); InstallConstants(global.Symbol,$Array( "isConcatSpreadable",symbolIsConcatSpreadable )); } HarmonyArrayExtendSymbolPrototype(); function HarmonyArrayExtendArrayPrototype(){ %CheckIsBootstrapping(); %FunctionSetLength(ArrayFrom,1); InstallFunctions($Array,2,$Array( "from",ArrayFrom, "of",ArrayOf )); InstallFunctions($Array.prototype,2,$Array( "find",ArrayFind, "findIndex",ArrayFindIndex, "fill",ArrayFill )); } HarmonyArrayExtendArrayPrototype(); Xharmony-array-includes 'use strict'; function ArrayIncludes(a,b){ var c=ToObject(this); var d=ToLength(c.length); if(d===0){ return false; } var e=ToInteger(b); var f; if(e>=0){ f=e; }else{ f=d+e; if(f<0){ f=0; } } while(f<d){ var g=c[f]; if(SameValueZero(a,g)){ return true; } ++f; } return false; } function HarmonyArrayIncludesExtendArrayPrototype(){ %CheckIsBootstrapping(); %FunctionSetLength(ArrayIncludes,1); InstallFunctions($Array.prototype,2,$Array( "includes",ArrayIncludes )); } HarmonyArrayIncludesExtendArrayPrototype(); @harmony-tostring? "use strict"; DefaultObjectToString=ObjectToStringHarmony; function ObjectToStringHarmony(){ if((this===(void 0))&&!(%_IsUndetectableObject(this)))return"[object Undefined]"; if((this===null))return"[object Null]"; var a=ToObject(this); var b=%_ClassOf(a); var c=a[symbolToStringTag]; if(!(typeof(c)==='string')){ c=b; } return"[object "+c+"]"; } function HarmonyToStringExtendSymbolPrototype(){ %CheckIsBootstrapping(); InstallConstants(global.Symbol,$Array( "toStringTag",symbolToStringTag )); } HarmonyToStringExtendSymbolPrototype(); function HarmonyToStringExtendObjectPrototype(){ %CheckIsBootstrapping(); %FunctionSetName(ObjectToStringHarmony,"toString"); %FunctionRemovePrototype(ObjectToStringHarmony); %SetNativeFlag(ObjectToStringHarmony); var a=ToPropertyDescriptor({ value:ObjectToStringHarmony }); DefineOwnProperty($Object.prototype,"toString",a,false); %ToFastProperties($Object.prototype); } HarmonyToStringExtendObjectPrototype(); Hharmony-typedarray? "use strict"; function Uint8ArrayForEach(a){ if(!%IsTypedArray(this)){ throw MakeTypeError('not_typed_array',[]); } if(!(%_ClassOf(a)==='Function')){ throw MakeTypeError('called_non_callable',[a]); } var b=%_TypedArrayGetLength(this); var c; if(%_ArgumentsLength()>1){ c=%_Arguments(1); } var d=false; if((c==null)){ c=%GetDefaultReceiver(a)||c; }else{ d=(!(%_IsSpecObject(c))&&%IsSloppyModeFunction(a)); } var e=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(a); for(var g=0;g<b;g++){ var h=this[g]; if(e)%DebugPrepareStepInIfStepping(a); var i=d?ToObject(c):c; %_CallFunction(i,((%_IsSpecObject(%IS_VAR(h)))?h:ToObject(h)),g,this,a); } } function Uint8ArrayOf(){ var a=%_ArgumentsLength(); var b=new this(a); for(var c=0;c<a;c++){ b[c]=%_Arguments(c); } return b; } function Int8ArrayForEach(a){ if(!%IsTypedArray(this)){ throw MakeTypeError('not_typed_array',[]); } if(!(%_ClassOf(a)==='Function')){ throw MakeTypeError('called_non_callable',[a]); } var b=%_TypedArrayGetLength(this); var c; if(%_ArgumentsLength()>1){ c=%_Arguments(1); } var d=false; if((c==null)){ c=%GetDefaultReceiver(a)||c; }else{ d=(!(%_IsSpecObject(c))&&%IsSloppyModeFunction(a)); } var e=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(a); for(var g=0;g<b;g++){ var h=this[g]; if(e)%DebugPrepareStepInIfStepping(a); var i=d?ToObject(c):c; %_CallFunction(i,((%_IsSpecObject(%IS_VAR(h)))?h:ToObject(h)),g,this,a); } } function Int8ArrayOf(){ var a=%_ArgumentsLength(); var b=new this(a); for(var c=0;c<a;c++){ b[c]=%_Arguments(c); } return b; } function Uint16ArrayForEach(a){ if(!%IsTypedArray(this)){ throw MakeTypeError('not_typed_array',[]); } if(!(%_ClassOf(a)==='Function')){ throw MakeTypeError('called_non_callable',[a]); } var b=%_TypedArrayGetLength(this); var c; if(%_ArgumentsLength()>1){ c=%_Arguments(1); } var d=false; if((c==null)){ c=%GetDefaultReceiver(a)||c; }else{ d=(!(%_IsSpecObject(c))&&%IsSloppyModeFunction(a)); } var e=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(a); for(var g=0;g<b;g++){ var h=this[g]; if(e)%DebugPrepareStepInIfStepping(a); var i=d?ToObject(c):c; %_CallFunction(i,((%_IsSpecObject(%IS_VAR(h)))?h:ToObject(h)),g,this,a); } } function Uint16ArrayOf(){ var a=%_ArgumentsLength(); var b=new this(a); for(var c=0;c<a;c++){ b[c]=%_Arguments(c); } return b; } function Int16ArrayForEach(a){ if(!%IsTypedArray(this)){ throw MakeTypeError('not_typed_array',[]); } if(!(%_ClassOf(a)==='Function')){ throw MakeTypeError('called_non_callable',[a]); } var b=%_TypedArrayGetLength(this); var c; if(%_ArgumentsLength()>1){ c=%_Arguments(1); } var d=false; if((c==null)){ c=%GetDefaultReceiver(a)||c; }else{ d=(!(%_IsSpecObject(c))&&%IsSloppyModeFunction(a)); } var e=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(a); for(var g=0;g<b;g++){ var h=this[g]; if(e)%DebugPrepareStepInIfStepping(a); var i=d?ToObject(c):c; %_CallFunction(i,((%_IsSpecObject(%IS_VAR(h)))?h:ToObject(h)),g,this,a); } } function Int16ArrayOf(){ var a=%_ArgumentsLength(); var b=new this(a); for(var c=0;c<a;c++){ b[c]=%_Arguments(c); } return b; } function Uint32ArrayForEach(a){ if(!%IsTypedArray(this)){ throw MakeTypeError('not_typed_array',[]); } if(!(%_ClassOf(a)==='Function')){ throw MakeTypeError('called_non_callable',[a]); } var b=%_TypedArrayGetLength(this); var c; if(%_ArgumentsLength()>1){ c=%_Arguments(1); } var d=false; if((c==null)){ c=%GetDefaultReceiver(a)||c; }else{ d=(!(%_IsSpecObject(c))&&%IsSloppyModeFunction(a)); } var e=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(a); for(var g=0;g<b;g++){ var h=this[g]; if(e)%DebugPrepareStepInIfStepping(a); var i=d?ToObject(c):c; %_CallFunction(i,((%_IsSpecObject(%IS_VAR(h)))?h:ToObject(h)),g,this,a); } } function Uint32ArrayOf(){ var a=%_ArgumentsLength(); var b=new this(a); for(var c=0;c<a;c++){ b[c]=%_Arguments(c); } return b; } function Int32ArrayForEach(a){ if(!%IsTypedArray(this)){ throw MakeTypeError('not_typed_array',[]); } if(!(%_ClassOf(a)==='Function')){ throw MakeTypeError('called_non_callable',[a]); } var b=%_TypedArrayGetLength(this); var c; if(%_ArgumentsLength()>1){ c=%_Arguments(1); } var d=false; if((c==null)){ c=%GetDefaultReceiver(a)||c; }else{ d=(!(%_IsSpecObject(c))&&%IsSloppyModeFunction(a)); } var e=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(a); for(var g=0;g<b;g++){ var h=this[g]; if(e)%DebugPrepareStepInIfStepping(a); var i=d?ToObject(c):c; %_CallFunction(i,((%_IsSpecObject(%IS_VAR(h)))?h:ToObject(h)),g,this,a); } } function Int32ArrayOf(){ var a=%_ArgumentsLength(); var b=new this(a); for(var c=0;c<a;c++){ b[c]=%_Arguments(c); } return b; } function Float32ArrayForEach(a){ if(!%IsTypedArray(this)){ throw MakeTypeError('not_typed_array',[]); } if(!(%_ClassOf(a)==='Function')){ throw MakeTypeError('called_non_callable',[a]); } var b=%_TypedArrayGetLength(this); var c; if(%_ArgumentsLength()>1){ c=%_Arguments(1); } var d=false; if((c==null)){ c=%GetDefaultReceiver(a)||c; }else{ d=(!(%_IsSpecObject(c))&&%IsSloppyModeFunction(a)); } var e=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(a); for(var g=0;g<b;g++){ var h=this[g]; if(e)%DebugPrepareStepInIfStepping(a); var i=d?ToObject(c):c; %_CallFunction(i,((%_IsSpecObject(%IS_VAR(h)))?h:ToObject(h)),g,this,a); } } function Float32ArrayOf(){ var a=%_ArgumentsLength(); var b=new this(a); for(var c=0;c<a;c++){ b[c]=%_Arguments(c); } return b; } function Float64ArrayForEach(a){ if(!%IsTypedArray(this)){ throw MakeTypeError('not_typed_array',[]); } if(!(%_ClassOf(a)==='Function')){ throw MakeTypeError('called_non_callable',[a]); } var b=%_TypedArrayGetLength(this); var c; if(%_ArgumentsLength()>1){ c=%_Arguments(1); } var d=false; if((c==null)){ c=%GetDefaultReceiver(a)||c; }else{ d=(!(%_IsSpecObject(c))&&%IsSloppyModeFunction(a)); } var e=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(a); for(var g=0;g<b;g++){ var h=this[g]; if(e)%DebugPrepareStepInIfStepping(a); var i=d?ToObject(c):c; %_CallFunction(i,((%_IsSpecObject(%IS_VAR(h)))?h:ToObject(h)),g,this,a); } } function Float64ArrayOf(){ var a=%_ArgumentsLength(); var b=new this(a); for(var c=0;c<a;c++){ b[c]=%_Arguments(c); } return b; } function Uint8ClampedArrayForEach(a){ if(!%IsTypedArray(this)){ throw MakeTypeError('not_typed_array',[]); } if(!(%_ClassOf(a)==='Function')){ throw MakeTypeError('called_non_callable',[a]); } var b=%_TypedArrayGetLength(this); var c; if(%_ArgumentsLength()>1){ c=%_Arguments(1); } var d=false; if((c==null)){ c=%GetDefaultReceiver(a)||c; }else{ d=(!(%_IsSpecObject(c))&&%IsSloppyModeFunction(a)); } var e=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(a); for(var g=0;g<b;g++){ var h=this[g]; if(e)%DebugPrepareStepInIfStepping(a); var i=d?ToObject(c):c; %_CallFunction(i,((%_IsSpecObject(%IS_VAR(h)))?h:ToObject(h)),g,this,a); } } function Uint8ClampedArrayOf(){ var a=%_ArgumentsLength(); var b=new this(a); for(var c=0;c<a;c++){ b[c]=%_Arguments(c); } return b; } function HarmonyTypedArrayExtendPrototypes(){ %CheckIsBootstrapping(); InstallFunctions(global.Uint8Array,2|4|1,$Array( "of",Uint8ArrayOf )); InstallFunctions(global.Uint8Array.prototype,2,$Array( "forEach",Uint8ArrayForEach )); %CheckIsBootstrapping(); InstallFunctions(global.Int8Array,2|4|1,$Array( "of",Int8ArrayOf )); InstallFunctions(global.Int8Array.prototype,2,$Array( "forEach",Int8ArrayForEach )); %CheckIsBootstrapping(); InstallFunctions(global.Uint16Array,2|4|1,$Array( "of",Uint16ArrayOf )); InstallFunctions(global.Uint16Array.prototype,2,$Array( "forEach",Uint16ArrayForEach )); %CheckIsBootstrapping(); InstallFunctions(global.Int16Array,2|4|1,$Array( "of",Int16ArrayOf )); InstallFunctions(global.Int16Array.prototype,2,$Array( "forEach",Int16ArrayForEach )); %CheckIsBootstrapping(); InstallFunctions(global.Uint32Array,2|4|1,$Array( "of",Uint32ArrayOf )); InstallFunctions(global.Uint32Array.prototype,2,$Array( "forEach",Uint32ArrayForEach )); %CheckIsBootstrapping(); InstallFunctions(global.Int32Array,2|4|1,$Array( "of",Int32ArrayOf )); InstallFunctions(global.Int32Array.prototype,2,$Array( "forEach",Int32ArrayForEach )); %CheckIsBootstrapping(); InstallFunctions(global.Float32Array,2|4|1,$Array( "of",Float32ArrayOf )); InstallFunctions(global.Float32Array.prototype,2,$Array( "forEach",Float32ArrayForEach )); %CheckIsBootstrapping(); InstallFunctions(global.Float64Array,2|4|1,$Array( "of",Float64ArrayOf )); InstallFunctions(global.Float64Array.prototype,2,$Array( "forEach",Float64ArrayForEach )); %CheckIsBootstrapping(); InstallFunctions(global.Uint8ClampedArray,2|4|1,$Array( "of",Uint8ClampedArrayOf )); InstallFunctions(global.Uint8ClampedArray.prototype,2,$Array( "forEach",Uint8ClampedArrayForEach )); } HarmonyTypedArrayExtendPrototypes(); 8harmony-regexp 'use strict'; var $RegExp=global.RegExp; function RegExpGetFlags(){ if(!(%_IsSpecObject(this))){ throw MakeTypeError('flags_getter_non_object', [%ToString(this)]); } var a=''; if(this.global)a+='g'; if(this.ignoreCase)a+='i'; if(this.multiline)a+='m'; if(this.unicode)a+='u'; if(this.sticky)a+='y'; return a; } function ExtendRegExpPrototype(){ %CheckIsBootstrapping(); %DefineAccessorPropertyUnchecked($RegExp.prototype,'flags',RegExpGetFlags, null,2); %SetNativeFlag(RegExpGetFlags); } ExtendRegExpPrototype(); <harmony-reflect1 'use strict'; var $Reflect=global.Reflect; function SetUpReflect(){ %CheckIsBootstrapping(); InstallFunctions($Reflect,2,$Array( "apply",ReflectApply, "construct",ReflectConstruct )); } SetUpReflect();
Ms-Dos/Windows
Unix
Write backup
jsp File Browser version 1.2 by
www.vonloesch.de