3 var kDefaultBacktraceLength=10;
5 var sourceLineBeginningSkip=/^(?:\s*(?:\/\*.*?\*\/)*)*/;
6 Debug.DebugEvent={Break:1,
15 Debug.ExceptionBreak={Caught:0,
17 Debug.StepAction={StepOut:0,
23 Debug.ScriptType={Native:0,
26 Debug.ScriptCompilationType={Host:0,
29 Debug.ScriptBreakPointType={ScriptId:0,
32 Debug.BreakPositionAlignment={
36 function ScriptTypeFlag(a){
39 var next_response_seq=0;
40 var next_break_point_number=1;
42 var script_break_points=[];
46 getValue:function(){return this.value;},
49 %SetDisableBreak(!this.value);
52 breakOnCaughtException:{
53 getValue:function(){return Debug.isBreakOnException();},
56 Debug.setBreakOnException();
58 Debug.clearBreakOnException();
62 breakOnUncaughtException:{
63 getValue:function(){return Debug.isBreakOnUncaughtException();},
66 Debug.setBreakOnUncaughtException();
68 Debug.clearBreakOnUncaughtException();
73 function MakeBreakPoint(a,b){
74 var c=new BreakPoint(a,b);
78 function BreakPoint(a,b){
79 this.source_position_=a;
81 this.script_break_point_=b;
83 this.number_=next_break_point_number++;
90 BreakPoint.prototype.number=function(){
93 BreakPoint.prototype.func=function(){
96 BreakPoint.prototype.source_position=function(){
97 return this.source_position_;
99 BreakPoint.prototype.hit_count=function(){
100 return this.hit_count_;
102 BreakPoint.prototype.active=function(){
103 if(this.script_break_point()){
104 return this.script_break_point().active();
108 BreakPoint.prototype.condition=function(){
109 if(this.script_break_point()&&this.script_break_point().condition()){
110 return this.script_break_point().condition();
112 return this.condition_;
114 BreakPoint.prototype.ignoreCount=function(){
115 return this.ignoreCount_;
117 BreakPoint.prototype.script_break_point=function(){
118 return this.script_break_point_;
120 BreakPoint.prototype.enable=function(){
123 BreakPoint.prototype.disable=function(){
126 BreakPoint.prototype.setCondition=function(a){
129 BreakPoint.prototype.setIgnoreCount=function(a){
132 BreakPoint.prototype.isTriggered=function(a){
133 if(!this.active())return false;
134 if(this.condition()){
136 var b=a.frame(0).evaluate(this.condition());
137 if(!(b instanceof ValueMirror)||!%ToBoolean(b.value_)){
145 if(this.script_break_point_){
146 this.script_break_point_.hit_count_++;
148 if(this.ignoreCount_>0){
154 function IsBreakPointTriggered(a,b){
155 return b.isTriggered(MakeExecutionState(a));
157 function ScriptBreakPoint(type,script_id_or_name,opt_line,opt_column,
158 opt_groupId,opt_position_alignment){
160 if(type==Debug.ScriptBreakPointType.ScriptId){
161 this.script_id_=script_id_or_name;
162 }else if(type==Debug.ScriptBreakPointType.ScriptName){
163 this.script_name_=script_id_or_name;
164 }else if(type==Debug.ScriptBreakPointType.ScriptRegExp){
165 this.script_regexp_object_=new RegExp(script_id_or_name);
167 throw new Error("Unexpected breakpoint type "+type);
169 this.line_=opt_line||0;
170 this.column_=opt_column;
171 this.groupId_=opt_groupId;
172 this.position_alignment_=(opt_position_alignment===(void 0))
173 ?Debug.BreakPositionAlignment.Statement:opt_position_alignment;
176 this.condition_=null;
178 this.break_points_=[];
180 ScriptBreakPoint.prototype.cloneForOtherScript=function(a){
181 var b=new ScriptBreakPoint(Debug.ScriptBreakPointType.ScriptId,
182 a.id,this.line_,this.column_,this.groupId_,
183 this.position_alignment_);
184 b.number_=next_break_point_number++;
185 script_break_points.push(b);
186 b.hit_count_=this.hit_count_;
187 b.active_=this.active_;
188 b.condition_=this.condition_;
189 b.ignoreCount_=this.ignoreCount_;
192 ScriptBreakPoint.prototype.number=function(){
195 ScriptBreakPoint.prototype.groupId=function(){
196 return this.groupId_;
198 ScriptBreakPoint.prototype.type=function(){
201 ScriptBreakPoint.prototype.script_id=function(){
202 return this.script_id_;
204 ScriptBreakPoint.prototype.script_name=function(){
205 return this.script_name_;
207 ScriptBreakPoint.prototype.script_regexp_object=function(){
208 return this.script_regexp_object_;
210 ScriptBreakPoint.prototype.line=function(){
213 ScriptBreakPoint.prototype.column=function(){
216 ScriptBreakPoint.prototype.actual_locations=function(){
218 for(var b=0;b<this.break_points_.length;b++){
219 a.push(this.break_points_[b].actual_location);
223 ScriptBreakPoint.prototype.update_positions=function(a,b){
227 ScriptBreakPoint.prototype.hit_count=function(){
228 return this.hit_count_;
230 ScriptBreakPoint.prototype.active=function(){
233 ScriptBreakPoint.prototype.condition=function(){
234 return this.condition_;
236 ScriptBreakPoint.prototype.ignoreCount=function(){
237 return this.ignoreCount_;
239 ScriptBreakPoint.prototype.enable=function(){
242 ScriptBreakPoint.prototype.disable=function(){
245 ScriptBreakPoint.prototype.setCondition=function(a){
248 ScriptBreakPoint.prototype.setIgnoreCount=function(a){
250 for(var b=0;b<this.break_points_.length;b++){
251 this.break_points_[b].setIgnoreCount(a);
254 ScriptBreakPoint.prototype.matchesScript=function(a){
255 if(this.type_==Debug.ScriptBreakPointType.ScriptId){
256 return this.script_id_==a.id;
258 if(!(a.line_offset<=this.line_&&
259 this.line_<a.line_offset+a.lineCount())){
262 if(this.type_==Debug.ScriptBreakPointType.ScriptName){
263 return this.script_name_==a.nameOrSourceURL();
264 }else if(this.type_==Debug.ScriptBreakPointType.ScriptRegExp){
265 return this.script_regexp_object_.test(a.nameOrSourceURL());
267 throw new Error("Unexpected breakpoint type "+this.type_);
271 ScriptBreakPoint.prototype.set=function(a){
275 var d=a.sourceLine(this.line());
276 if(!a.sourceColumnStart_){
277 a.sourceColumnStart_=new Array(a.lineCount());
279 if((a.sourceColumnStart_[c]===(void 0))){
280 a.sourceColumnStart_[c]=
281 d.match(sourceLineBeginningSkip)[0].length;
283 b=a.sourceColumnStart_[c];
285 var e=Debug.findScriptSourcePosition(a,this.line(),b);
286 if((e===null))return;
287 var f=MakeBreakPoint(e,this);
288 f.setIgnoreCount(this.ignoreCount());
289 var g=%SetScriptBreakPoint(a,e,
290 this.position_alignment_,
295 var h=a.locationFromPosition(g,true);
296 f.actual_location={line:h.line,
299 this.break_points_.push(f);
302 ScriptBreakPoint.prototype.clear=function(){
304 for(var b=0;b<break_points.length;b++){
305 if(break_points[b].script_break_point()&&
306 break_points[b].script_break_point()===this){
307 %ClearBreakPoint(break_points[b]);
309 a.push(break_points[b]);
313 this.break_points_=[];
315 function UpdateScriptBreakPoints(a){
316 for(var b=0;b<script_break_points.length;b++){
317 var c=script_break_points[b];
318 if((c.type()==Debug.ScriptBreakPointType.ScriptName||
319 c.type()==Debug.ScriptBreakPointType.ScriptRegExp)&&
325 function GetScriptBreakPoints(a){
327 for(var c=0;c<script_break_points.length;c++){
328 if(script_break_points[c].matchesScript(a)){
329 b.push(script_break_points[c]);
334 Debug.setListener=function(a,b){
335 if(!(%_IsFunction(a))&&!(a===(void 0))&&!(a===null)){
336 throw new Error('Parameters have wrong types.');
338 %SetDebugEventListener(a,b);
340 Debug.breakLocations=function(a,b){
341 if(!(%_IsFunction(a)))throw new Error('Parameters have wrong types.');
343 ?Debug.BreakPositionAlignment.Statement:b;
344 return %GetBreakLocations(a,c);
346 Debug.findScript=function(a){
347 if((%_IsFunction(a))){
348 return %FunctionGetScript(a);
349 }else if((%_IsRegExp(a))){
350 var b=Debug.scripts();
366 return %GetScript(a);
369 Debug.scriptSource=function(a){
370 return this.findScript(a).source;
372 Debug.source=function(a){
373 if(!(%_IsFunction(a)))throw new Error('Parameters have wrong types.');
374 return %FunctionGetSourceCode(a);
376 Debug.sourcePosition=function(a){
377 if(!(%_IsFunction(a)))throw new Error('Parameters have wrong types.');
378 return %FunctionGetScriptSourcePosition(a);
380 Debug.findFunctionSourceLocation=function(a,b,c){
381 var d=%FunctionGetScript(a);
382 var e=%FunctionGetScriptSourcePosition(a);
383 return d.locationFromLine(b,c,e);
385 Debug.findScriptSourcePosition=function(a,b,c){
386 var d=a.locationFromLine(b,c);
387 return d?d.position:null;
389 Debug.findBreakPoint=function(a,b){
391 for(var d=0;d<break_points.length;d++){
392 if(break_points[d].number()==a){
395 break_points.splice(d,1);
403 return this.findScriptBreakPoint(a,b);
406 Debug.findBreakPointActualLocations=function(a){
407 for(var b=0;b<script_break_points.length;b++){
408 if(script_break_points[b].number()==a){
409 return script_break_points[b].actual_locations();
412 for(var b=0;b<break_points.length;b++){
413 if(break_points[b].number()==a){
414 return[break_points[b].actual_location];
419 Debug.setBreakPoint=function(a,b,c,d){
420 if(!(%_IsFunction(a)))throw new Error('Parameters have wrong types.');
421 if(%FunctionIsAPIFunction(a)){
422 throw new Error('Cannot set break point in native code.');
425 this.findFunctionSourceLocation(a,b,c).position;
426 var g=e-this.sourcePosition(a);
427 var h=%FunctionGetScript(a);
428 if(h.type==Debug.ScriptType.Native){
429 throw new Error('Cannot set break point in native code.');
432 g+=%FunctionGetScriptSourcePosition(a);
433 var i=h.locationFromPosition(g,false);
434 return this.setScriptBreakPointById(h.id,
438 var j=MakeBreakPoint(g);
440 %SetFunctionBreakPoint(a,g,j);
441 k+=this.sourcePosition(a);
442 var l=h.locationFromPosition(k,true);
443 j.actual_location={line:l.line,
450 Debug.setBreakPointByScriptIdAndPosition=function(script_id,position,
452 opt_position_alignment)
454 var a=MakeBreakPoint(position);
455 a.setCondition(condition);
459 var b=this.scripts();
460 var c=(opt_position_alignment===(void 0))
461 ?Debug.BreakPositionAlignment.Statement:opt_position_alignment;
462 for(var d=0;d<b.length;d++){
463 if(script_id==b[d].id){
464 a.actual_position=%SetScriptBreakPoint(b[d],position,
471 Debug.enableBreakPoint=function(a){
472 var b=this.findBreakPoint(a,false);
477 Debug.disableBreakPoint=function(a){
478 var b=this.findBreakPoint(a,false);
483 Debug.changeBreakPointCondition=function(a,b){
484 var c=this.findBreakPoint(a,false);
487 Debug.changeBreakPointIgnoreCount=function(a,b){
489 throw new Error('Invalid argument');
491 var c=this.findBreakPoint(a,false);
494 Debug.clearBreakPoint=function(a){
495 var b=this.findBreakPoint(a,true);
497 return %ClearBreakPoint(b);
499 b=this.findScriptBreakPoint(a,true);
501 throw new Error('Invalid breakpoint');
505 Debug.clearAllBreakPoints=function(){
506 for(var a=0;a<break_points.length;a++){
507 var b=break_points[a];
512 Debug.disableAllBreakPoints=function(){
513 for(var a=1;a<next_break_point_number;a++){
514 Debug.disableBreakPoint(a);
516 %ChangeBreakOnException(Debug.ExceptionBreak.Caught,false);
517 %ChangeBreakOnException(Debug.ExceptionBreak.Uncaught,false);
519 Debug.findScriptBreakPoint=function(a,b){
521 for(var d=0;d<script_break_points.length;d++){
522 if(script_break_points[d].number()==a){
523 c=script_break_points[d];
526 script_break_points.splice(d,1);
533 Debug.setScriptBreakPoint=function(type,script_id_or_name,
534 opt_line,opt_column,opt_condition,
535 opt_groupId,opt_position_alignment){
537 new ScriptBreakPoint(type,script_id_or_name,opt_line,opt_column,
538 opt_groupId,opt_position_alignment);
539 a.number_=next_break_point_number++;
540 a.setCondition(opt_condition);
541 script_break_points.push(a);
542 var b=this.scripts();
543 for(var c=0;c<b.length;c++){
544 if(a.matchesScript(b[c])){
550 Debug.setScriptBreakPointById=function(script_id,
552 opt_condition,opt_groupId,
553 opt_position_alignment){
554 return this.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptId,
555 script_id,opt_line,opt_column,
556 opt_condition,opt_groupId,
557 opt_position_alignment);
559 Debug.setScriptBreakPointByName=function(script_name,
561 opt_condition,opt_groupId){
562 return this.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptName,
563 script_name,opt_line,opt_column,
564 opt_condition,opt_groupId);
566 Debug.setScriptBreakPointByRegExp=function(script_regexp,
568 opt_condition,opt_groupId){
569 return this.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptRegExp,
570 script_regexp,opt_line,opt_column,
571 opt_condition,opt_groupId);
573 Debug.enableScriptBreakPoint=function(a){
574 var b=this.findScriptBreakPoint(a,false);
577 Debug.disableScriptBreakPoint=function(a){
578 var b=this.findScriptBreakPoint(a,false);
581 Debug.changeScriptBreakPointCondition=function(
582 break_point_number,condition){
583 var a=this.findScriptBreakPoint(break_point_number,false);
584 a.setCondition(condition);
586 Debug.changeScriptBreakPointIgnoreCount=function(
587 break_point_number,ignoreCount){
589 throw new Error('Invalid argument');
591 var a=this.findScriptBreakPoint(break_point_number,false);
592 a.setIgnoreCount(ignoreCount);
594 Debug.scriptBreakPoints=function(){
595 return script_break_points;
597 Debug.clearStepping=function(){
600 Debug.setBreakOnException=function(){
601 return %ChangeBreakOnException(Debug.ExceptionBreak.Caught,true);
603 Debug.clearBreakOnException=function(){
604 return %ChangeBreakOnException(Debug.ExceptionBreak.Caught,false);
606 Debug.isBreakOnException=function(){
607 return!!%IsBreakOnException(Debug.ExceptionBreak.Caught);
609 Debug.setBreakOnUncaughtException=function(){
610 return %ChangeBreakOnException(Debug.ExceptionBreak.Uncaught,true);
612 Debug.clearBreakOnUncaughtException=function(){
613 return %ChangeBreakOnException(Debug.ExceptionBreak.Uncaught,false);
615 Debug.isBreakOnUncaughtException=function(){
616 return!!%IsBreakOnException(Debug.ExceptionBreak.Uncaught);
618 Debug.showBreakPoints=function(a,b,c){
619 if(!(%_IsFunction(a)))throw new Error('Parameters have wrong types.');
620 var d=b?this.scriptSource(a):this.source(a);
621 var e=b?this.sourcePosition(a):0;
622 var g=this.breakLocations(a,c);
624 g.sort(function(h,i){return h-i;});
628 for(var m=0;m<g.length;m++){
638 Debug.scripts=function(){
639 return %DebugGetLoadedScripts();
641 Debug.debuggerFlags=function(){
642 return debugger_flags;
644 Debug.MakeMirror=MakeMirror;
645 function MakeExecutionState(a){
646 return new ExecutionState(a);
648 function ExecutionState(a){
650 this.selected_frame=0;
652 ExecutionState.prototype.prepareStep=function(opt_action,opt_count,
654 var a=Debug.StepAction.StepIn;
655 if(!(opt_action===(void 0)))a=%ToNumber(opt_action);
656 var b=opt_count?%ToNumber(opt_count):1;
658 if(!(opt_callframe===(void 0))){
659 c=opt_callframe.details_.frameId();
661 return %PrepareStep(this.break_id,a,b,c);
663 ExecutionState.prototype.evaluateGlobal=function(source,disable_break,
664 opt_additional_context){
665 return MakeMirror(%DebugEvaluateGlobal(this.break_id,source,
666 Boolean(disable_break),
667 opt_additional_context));
669 ExecutionState.prototype.frameCount=function(){
670 return %GetFrameCount(this.break_id);
672 ExecutionState.prototype.threadCount=function(){
673 return %GetThreadCount(this.break_id);
675 ExecutionState.prototype.frame=function(a){
676 if(a==null)a=this.selected_frame;
677 if(a<0||a>=this.frameCount()){
678 throw new Error('Illegal frame index.');
680 return new FrameMirror(this.break_id,a);
682 ExecutionState.prototype.setSelectedFrame=function(a){
684 if(b<0||b>=this.frameCount())throw new Error('Illegal frame index.');
685 this.selected_frame=b;
687 ExecutionState.prototype.selectedFrame=function(){
688 return this.selected_frame;
690 ExecutionState.prototype.debugCommandProcessor=function(a){
691 return new DebugCommandProcessor(this,a);
693 function MakeBreakEvent(a,b){
694 return new BreakEvent(a,b);
696 function BreakEvent(a,b){
697 this.frame_=new FrameMirror(a,0);
698 this.break_points_hit_=b;
700 BreakEvent.prototype.eventType=function(){
701 return Debug.DebugEvent.Break;
703 BreakEvent.prototype.func=function(){
704 return this.frame_.func();
706 BreakEvent.prototype.sourceLine=function(){
707 return this.frame_.sourceLine();
709 BreakEvent.prototype.sourceColumn=function(){
710 return this.frame_.sourceColumn();
712 BreakEvent.prototype.sourceLineText=function(){
713 return this.frame_.sourceLineText();
715 BreakEvent.prototype.breakPointsHit=function(){
716 return this.break_points_hit_;
718 BreakEvent.prototype.toJSONProtocol=function(){
719 var a={seq:next_response_seq++,
722 body:{invocationText:this.frame_.invocationText()}
724 var b=this.func().script();
726 a.body.sourceLine=this.sourceLine(),
727 a.body.sourceColumn=this.sourceColumn(),
728 a.body.sourceLineText=this.sourceLineText(),
729 a.body.script=MakeScriptObject_(b,false);
731 if(this.breakPointsHit()){
732 a.body.breakpoints=[];
733 for(var c=0;c<this.breakPointsHit().length;c++){
734 var d=this.breakPointsHit()[c];
735 var e=d.script_break_point();
742 a.body.breakpoints.push(g);
745 return JSON.stringify(ObjectToProtocolObject_(a));
747 function MakeExceptionEvent(a,b,c,d){
748 return new ExceptionEvent(a,b,c,d);
750 function ExceptionEvent(a,b,c,d){
751 this.exec_state_=new ExecutionState(a);
756 ExceptionEvent.prototype.eventType=function(){
757 return Debug.DebugEvent.Exception;
759 ExceptionEvent.prototype.exception=function(){
760 return this.exception_;
762 ExceptionEvent.prototype.uncaught=function(){
763 return this.uncaught_;
765 ExceptionEvent.prototype.promise=function(){
766 return this.promise_;
768 ExceptionEvent.prototype.func=function(){
769 return this.exec_state_.frame(0).func();
771 ExceptionEvent.prototype.sourceLine=function(){
772 return this.exec_state_.frame(0).sourceLine();
774 ExceptionEvent.prototype.sourceColumn=function(){
775 return this.exec_state_.frame(0).sourceColumn();
777 ExceptionEvent.prototype.sourceLineText=function(){
778 return this.exec_state_.frame(0).sourceLineText();
780 ExceptionEvent.prototype.toJSONProtocol=function(){
781 var a=new ProtocolMessage();
783 a.body={uncaught:this.uncaught_,
784 exception:MakeMirror(this.exception_)
786 if(this.exec_state_.frameCount()>0){
787 a.body.sourceLine=this.sourceLine();
788 a.body.sourceColumn=this.sourceColumn();
789 a.body.sourceLineText=this.sourceLineText();
790 var b=this.func().script();
792 a.body.script=MakeScriptObject_(b,false);
795 a.body.sourceLine=-1;
797 return a.toJSONProtocol();
799 function MakeCompileEvent(a,b){
800 return new CompileEvent(a,b);
802 function CompileEvent(a,b){
803 this.script_=MakeMirror(a);
806 CompileEvent.prototype.eventType=function(){
809 CompileEvent.prototype.script=function(){
812 CompileEvent.prototype.toJSONProtocol=function(){
813 var a=new ProtocolMessage();
816 case Debug.DebugEvent.BeforeCompile:
817 a.event="beforeCompile";
819 case Debug.DebugEvent.AfterCompile:
820 a.event="afterCompile";
822 case Debug.DebugEvent.CompileError:
823 a.event="compileError";
827 a.body.script=this.script_;
828 return a.toJSONProtocol();
830 function MakeScriptObject_(a,b){
833 lineOffset:a.lineOffset(),
834 columnOffset:a.columnOffset(),
835 lineCount:a.lineCount(),
837 if(!(a.data()===(void 0))){
845 function MakePromiseEvent(a){
846 return new PromiseEvent(a);
848 function PromiseEvent(a){
849 this.promise_=a.promise;
850 this.parentPromise_=a.parentPromise;
851 this.status_=a.status;
854 PromiseEvent.prototype.promise=function(){
855 return MakeMirror(this.promise_);
857 PromiseEvent.prototype.parentPromise=function(){
858 return MakeMirror(this.parentPromise_);
860 PromiseEvent.prototype.status=function(){
863 PromiseEvent.prototype.value=function(){
864 return MakeMirror(this.value_);
866 function MakeAsyncTaskEvent(a){
867 return new AsyncTaskEvent(a);
869 function AsyncTaskEvent(a){
874 AsyncTaskEvent.prototype.type=function(){
877 AsyncTaskEvent.prototype.name=function(){
880 AsyncTaskEvent.prototype.id=function(){
883 function DebugCommandProcessor(a,b){
885 this.running_=b||false;
887 DebugCommandProcessor.prototype.processDebugRequest=function(a){
888 return this.processDebugJSONRequest(a);
890 function ProtocolMessage(a){
891 this.seq=next_response_seq++;
893 this.type='response';
894 this.request_seq=a.seq;
895 this.command=a.command;
900 this.running=undefined;
902 ProtocolMessage.prototype.setOption=function(a,b){
908 ProtocolMessage.prototype.failed=function(a,b){
912 this.error_details=b;
915 ProtocolMessage.prototype.toJSONProtocol=function(){
918 if(this.request_seq){
919 a.request_seq=this.request_seq;
926 a.command=this.command;
929 a.success=this.success;
935 var c=MakeMirrorSerializer(true,this.options_);
936 if(this.body instanceof Mirror){
937 b=c.serializeValue(this.body);
938 }else if(this.body instanceof Array){
940 for(var d=0;d<this.body.length;d++){
941 if(this.body[d]instanceof Mirror){
942 b.push(c.serializeValue(this.body[d]));
944 b.push(ObjectToProtocolObject_(this.body[d],c));
948 b=ObjectToProtocolObject_(this.body,c);
951 a.refs=c.serializeReferencedObjects();
954 a.message=this.message;
956 if(this.error_details){
957 a.error_details=this.error_details;
959 a.running=this.running;
960 return JSON.stringify(a);
962 DebugCommandProcessor.prototype.createResponse=function(a){
963 return new ProtocolMessage(a);
965 DebugCommandProcessor.prototype.processDebugJSONRequest=function(
971 a=JSON.parse(json_request);
972 b=this.createResponse(a);
974 throw new Error('Type not specified');
976 if(a.type!='request'){
977 throw new Error("Illegal type '"+a.type+"' in request");
980 throw new Error('Command not specified');
984 if(c.inlineRefs||c.compactFormat){
985 b.setOption('inlineRefs',true);
987 if(!(c.maxStringLength===(void 0))){
988 b.setOption('maxStringLength',c.maxStringLength);
991 var d=a.command.toLowerCase();
992 var e=DebugCommandProcessor.prototype.dispatch_[d];
993 if((%_IsFunction(e))){
994 %_CallFunction(this,a,b,e);
996 throw new Error('Unknown command "'+a.command+'" in request');
1000 b=this.createResponse();
1003 b.message=%ToString(e);
1006 if(!(b.running===(void 0))){
1007 this.running_=b.running;
1009 b.running=this.running_;
1010 return b.toJSONProtocol();
1012 return'{"seq":'+b.seq+','+
1013 '"request_seq":'+a.seq+','+
1014 '"type":"response",'+
1016 '"message":"Internal error: '+%ToString(e)+'"}';
1019 return'{"seq":0,"type":"response","success":false,"message":"Internal error"}';
1022 DebugCommandProcessor.prototype.continueRequest_=function(a,b){
1025 var d=Debug.StepAction.StepIn;
1026 var e=a.arguments.stepaction;
1027 var g=a.arguments.stepcount;
1031 throw new Error('Invalid stepcount argument "'+g+'".');
1036 d=Debug.StepAction.StepIn;
1038 d=Debug.StepAction.StepMin;
1039 }else if(e=='next'){
1040 d=Debug.StepAction.StepNext;
1042 d=Debug.StepAction.StepOut;
1044 throw new Error('Invalid stepaction argument "'+e+'".');
1047 this.exec_state_.prepareStep(d,c);
1051 DebugCommandProcessor.prototype.breakRequest_=function(a,b){
1053 DebugCommandProcessor.prototype.setBreakPointRequest_=
1056 b.failed('Missing arguments');
1059 var c=a.arguments.type;
1060 var d=a.arguments.target;
1061 var e=a.arguments.line;
1062 var g=a.arguments.column;
1063 var h=(a.arguments.enabled===(void 0))?
1064 true:a.arguments.enabled;
1065 var i=a.arguments.condition;
1066 var j=a.arguments.ignoreCount;
1067 var k=a.arguments.groupId;
1068 if(!c||(d===(void 0))){
1069 b.failed('Missing argument "type" or "target"');
1074 if(!(typeof(d)==='string')){
1075 b.failed('Argument "target" is not a string value');
1080 m=this.exec_state_.evaluateGlobal(d).value();
1082 b.failed('Error: "'+%ToString(e)+
1083 '" evaluating "'+d+'"');
1086 if(!(%_IsFunction(m))){
1087 b.failed('"'+d+'" does not evaluate to a function');
1090 l=Debug.setBreakPoint(m,e,g,i);
1091 }else if(c=='handle'){
1092 var n=parseInt(d,10);
1093 var o=LookupMirror(n);
1095 return b.failed('Object #'+n+'# not found');
1097 if(!o.isFunction()){
1098 return b.failed('Object #'+n+'# is not a function');
1100 l=Debug.setBreakPoint(o.value(),
1102 }else if(c=='script'){
1104 Debug.setScriptBreakPointByName(d,e,g,i,
1106 }else if(c=='scriptId'){
1108 Debug.setScriptBreakPointById(d,e,g,i,k);
1109 }else if(c=='scriptRegExp'){
1111 Debug.setScriptBreakPointByRegExp(d,e,g,i,
1114 b.failed('Illegal type "'+c+'"');
1117 var p=Debug.findBreakPoint(l);
1119 Debug.changeBreakPointIgnoreCount(l,j);
1122 Debug.disableBreakPoint(l);
1126 if(p instanceof ScriptBreakPoint){
1127 if(p.type()==Debug.ScriptBreakPointType.ScriptId){
1128 b.body.type='scriptId';
1129 b.body.script_id=p.script_id();
1130 }else if(p.type()==Debug.ScriptBreakPointType.ScriptName){
1131 b.body.type='scriptName';
1132 b.body.script_name=p.script_name();
1133 }else if(p.type()==Debug.ScriptBreakPointType.ScriptRegExp){
1134 b.body.type='scriptRegExp';
1135 b.body.script_regexp=p.script_regexp_object().source;
1137 throw new Error("Internal error: Unexpected breakpoint type: "+
1140 b.body.line=p.line();
1141 b.body.column=p.column();
1142 b.body.actual_locations=p.actual_locations();
1144 b.body.type='function';
1145 b.body.actual_locations=[p.actual_location];
1148 DebugCommandProcessor.prototype.changeBreakPointRequest_=function(
1150 if(!request.arguments){
1151 response.failed('Missing arguments');
1154 var a=%ToNumber(request.arguments.breakpoint);
1155 var b=request.arguments.enabled;
1156 var c=request.arguments.condition;
1157 var d=request.arguments.ignoreCount;
1159 response.failed('Missing argument "breakpoint"');
1162 if(!(b===(void 0))){
1164 Debug.enableBreakPoint(a);
1166 Debug.disableBreakPoint(a);
1169 if(!(c===(void 0))){
1170 Debug.changeBreakPointCondition(a,c);
1172 if(!(d===(void 0))){
1173 Debug.changeBreakPointIgnoreCount(a,d);
1176 DebugCommandProcessor.prototype.clearBreakPointGroupRequest_=function(
1178 if(!request.arguments){
1179 response.failed('Missing arguments');
1182 var a=request.arguments.groupId;
1184 response.failed('Missing argument "groupId"');
1189 for(var d=0;d<script_break_points.length;d++){
1190 var e=script_break_points[d];
1198 script_break_points=c;
1199 response.body={breakpoints:b};
1201 DebugCommandProcessor.prototype.clearBreakPointRequest_=function(
1203 if(!request.arguments){
1204 response.failed('Missing arguments');
1207 var a=%ToNumber(request.arguments.breakpoint);
1209 response.failed('Missing argument "breakpoint"');
1212 Debug.clearBreakPoint(a);
1213 response.body={breakpoint:a};
1215 DebugCommandProcessor.prototype.listBreakpointsRequest_=function(
1218 for(var b=0;b<script_break_points.length;b++){
1219 var c=script_break_points[b];
1224 groupId:c.groupId(),
1225 hit_count:c.hit_count(),
1227 condition:c.condition(),
1228 ignoreCount:c.ignoreCount(),
1229 actual_locations:c.actual_locations()
1231 if(c.type()==Debug.ScriptBreakPointType.ScriptId){
1233 d.script_id=c.script_id();
1234 }else if(c.type()==Debug.ScriptBreakPointType.ScriptName){
1235 d.type='scriptName';
1236 d.script_name=c.script_name();
1237 }else if(c.type()==Debug.ScriptBreakPointType.ScriptRegExp){
1238 d.type='scriptRegExp';
1239 d.script_regexp=c.script_regexp_object().source;
1241 throw new Error("Internal error: Unexpected breakpoint type: "+
1248 breakOnExceptions:Debug.isBreakOnException(),
1249 breakOnUncaughtExceptions:Debug.isBreakOnUncaughtException()
1252 DebugCommandProcessor.prototype.disconnectRequest_=
1254 Debug.disableAllBreakPoints();
1255 this.continueRequest_(a,b);
1257 DebugCommandProcessor.prototype.setExceptionBreakRequest_=
1260 b.failed('Missing arguments');
1263 var c=a.arguments.type;
1265 b.failed('Missing argument "type"');
1270 d=!Debug.isBreakOnException();
1271 }else if(c=='uncaught'){
1272 d=!Debug.isBreakOnUncaughtException();
1274 if(!(a.arguments.enabled===(void 0))){
1275 d=a.arguments.enabled;
1276 if((d!=true)&&(d!=false)){
1277 b.failed('Illegal value for "enabled":"'+d+'"');
1281 %ChangeBreakOnException(Debug.ExceptionBreak.Caught,d);
1282 }else if(c=='uncaught'){
1283 %ChangeBreakOnException(Debug.ExceptionBreak.Uncaught,d);
1285 b.failed('Unknown "type":"'+c+'"');
1287 b.body={'type':c,'enabled':d};
1289 DebugCommandProcessor.prototype.backtraceRequest_=function(
1291 var a=this.exec_state_.frameCount();
1299 var c=kDefaultBacktraceLength;
1300 if(request.arguments){
1301 if(request.arguments.fromFrame){
1302 b=request.arguments.fromFrame;
1304 if(request.arguments.toFrame){
1305 c=request.arguments.toFrame;
1307 if(request.arguments.bottom){
1313 return response.failed('Invalid frame number');
1318 var e='Invalid frame range';
1319 return response.failed(e);
1322 for(var h=b;h<c;h++){
1323 g.push(this.exec_state_.frame(h));
1332 DebugCommandProcessor.prototype.frameRequest_=function(a,b){
1333 if(this.exec_state_.frameCount()==0){
1334 return b.failed('No frames');
1337 var c=a.arguments.number;
1338 if(c<0||this.exec_state_.frameCount()<=c){
1339 return b.failed('Invalid frame number');
1341 this.exec_state_.setSelectedFrame(a.arguments.number);
1343 b.body=this.exec_state_.frame();
1345 DebugCommandProcessor.prototype.resolveFrameFromScopeDescription_=
1347 if(a&&!(a.frameNumber===(void 0))){
1348 var b=a.frameNumber;
1349 if(b<0||this.exec_state_.frameCount()<=b){
1350 throw new Error('Invalid frame number');
1352 return this.exec_state_.frame(b);
1354 return this.exec_state_.frame();
1357 DebugCommandProcessor.prototype.resolveScopeHolder_=
1359 if(a&&"functionHandle"in a){
1360 if(!(typeof(a.functionHandle)==='number')){
1361 throw new Error('Function handle must be a number');
1363 var b=LookupMirror(a.functionHandle);
1365 throw new Error('Failed to find function object by handle');
1367 if(!b.isFunction()){
1368 throw new Error('Value of non-function type is found by handle');
1372 if(this.exec_state_.frameCount()==0){
1373 throw new Error('No scopes');
1375 var c=this.resolveFrameFromScopeDescription_(a);
1379 DebugCommandProcessor.prototype.scopesRequest_=function(a,b){
1380 var c=this.resolveScopeHolder_(a.arguments);
1381 var d=c.scopeCount();
1383 for(var g=0;g<d;g++){
1393 DebugCommandProcessor.prototype.scopeRequest_=function(a,b){
1394 var c=this.resolveScopeHolder_(a.arguments);
1396 if(a.arguments&&!(a.arguments.number===(void 0))){
1397 d=%ToNumber(a.arguments.number);
1398 if(d<0||c.scopeCount()<=d){
1399 return b.failed('Invalid scope number');
1404 DebugCommandProcessor.resolveValue_=function(a){
1406 var b=LookupMirror(a.handle);
1408 throw new Error("Failed to resolve value by handle, ' #"+
1409 a.handle+"# not found");
1412 }else if("stringDescription"in a){
1413 if(a.type==BOOLEAN_TYPE){
1414 return Boolean(a.stringDescription);
1415 }else if(a.type==NUMBER_TYPE){
1416 return Number(a.stringDescription);
1417 }if(a.type==STRING_TYPE){
1418 return String(a.stringDescription);
1420 throw new Error("Unknown type");
1422 }else if("value"in a){
1424 }else if(a.type==UNDEFINED_TYPE){
1426 }else if(a.type==NULL_TYPE){
1429 throw new Error("Failed to parse value description");
1432 DebugCommandProcessor.prototype.setVariableValueRequest_=
1435 b.failed('Missing arguments');
1438 if((a.arguments.name===(void 0))){
1439 b.failed('Missing variable name');
1441 var c=a.arguments.name;
1442 var d=a.arguments.scope;
1443 var e=this.resolveScopeHolder_(d);
1444 if((d.number===(void 0))){
1445 b.failed('Missing scope number');
1447 var g=%ToNumber(d.number);
1450 DebugCommandProcessor.resolveValue_(a.arguments.newValue);
1451 h.setVariableValue(c,i);
1452 var j=MakeMirror(i);
1457 DebugCommandProcessor.prototype.evaluateRequest_=function(a,b){
1459 return b.failed('Missing arguments');
1461 var c=a.arguments.expression;
1462 var d=a.arguments.frame;
1463 var e=a.arguments.global;
1464 var g=a.arguments.disable_break;
1465 var h=a.arguments.additional_context;
1469 return b.failed('Failed to convert expression argument to string');
1471 if(!(d===(void 0))&&e){
1472 return b.failed('Arguments "frame" and "global" are exclusive');
1477 for(var j=0;j<h.length;j++){
1479 if(!(typeof(k.name)==='string')){
1480 return b.failed("Context element #"+j+
1481 " doesn't contain name:string property");
1483 var l=DebugCommandProcessor.resolveValue_(k);
1488 b.body=this.exec_state_.evaluateGlobal(
1495 if(this.exec_state_.frameCount()==0){
1496 return b.failed('No frames');
1498 if(!(d===(void 0))){
1500 if(m<0||m>=this.exec_state_.frameCount()){
1501 return b.failed('Invalid frame "'+d+'"');
1503 b.body=this.exec_state_.frame(m).evaluate(
1507 b.body=this.exec_state_.frame().evaluate(
1512 DebugCommandProcessor.prototype.lookupRequest_=function(a,b){
1514 return b.failed('Missing arguments');
1516 var c=a.arguments.handles;
1518 return b.failed('Argument "handles" missing');
1520 if(!(a.arguments.includeSource===(void 0))){
1521 var d=%ToBoolean(a.arguments.includeSource);
1522 b.setOption('includeSource',d);
1525 for(var g=0;g<c.length;g++){
1527 var i=LookupMirror(h);
1529 return b.failed('Object #'+h+'# not found');
1535 DebugCommandProcessor.prototype.referencesRequest_=
1538 return b.failed('Missing arguments');
1540 var c=a.arguments.type;
1541 var d=a.arguments.handle;
1543 return b.failed('Argument "type" missing');
1546 return b.failed('Argument "handle" missing');
1548 if(c!='referencedBy'&&c!='constructedBy'){
1549 return b.failed('Invalid type "'+c+'"');
1551 var e=LookupMirror(d);
1553 if(c=='referencedBy'){
1554 b.body=e.referencedBy();
1556 b.body=e.constructedBy();
1559 return b.failed('Object #'+d+'# not found');
1562 DebugCommandProcessor.prototype.sourceRequest_=function(a,b){
1563 if(this.exec_state_.frameCount()==0){
1564 return b.failed('No source');
1568 var e=this.exec_state_.frame();
1570 c=a.arguments.fromLine;
1571 d=a.arguments.toLine;
1572 if(!(a.arguments.frame===(void 0))){
1573 var g=%ToNumber(a.arguments.frame);
1574 if(g<0||g>=this.exec_state_.frameCount()){
1575 return b.failed('Invalid frame "'+e+'"');
1577 e=this.exec_state_.frame(g);
1580 var h=e.func().script();
1582 return b.failed('No source');
1584 var i=h.sourceSlice(c,d);
1586 return b.failed('Invalid line interval');
1589 b.body.source=i.sourceText();
1590 b.body.fromLine=i.from_line;
1591 b.body.toLine=i.to_line;
1592 b.body.fromPosition=i.from_position;
1593 b.body.toPosition=i.to_position;
1594 b.body.totalLines=h.lineCount();
1596 DebugCommandProcessor.prototype.scriptsRequest_=function(a,b){
1597 var c=ScriptTypeFlag(Debug.ScriptType.Normal);
1601 if(!(a.arguments.types===(void 0))){
1602 c=%ToNumber(a.arguments.types);
1604 return b.failed('Invalid types "'+
1605 a.arguments.types+'"');
1608 if(!(a.arguments.includeSource===(void 0))){
1609 d=%ToBoolean(a.arguments.includeSource);
1610 b.setOption('includeSource',d);
1612 if((%_IsArray(a.arguments.ids))){
1614 var g=a.arguments.ids;
1615 for(var h=0;h<g.length;h++){
1621 if(!(a.arguments.filter===(void 0))){
1622 var k=%ToNumber(a.arguments.filter);
1626 i=a.arguments.filter;
1629 var l=%DebugGetLoadedScripts();
1631 for(var h=0;h<l.length;h++){
1644 if(m.name&&m.name.indexOf(i)>=0){
1650 if(c&ScriptTypeFlag(l[h].type)){
1651 b.body.push(MakeMirror(l[h]));
1655 DebugCommandProcessor.prototype.threadsRequest_=function(a,b){
1656 var c=this.exec_state_.threadCount();
1658 for(var e=0;e<c;e++){
1659 var g=%GetThreadDetails(this.exec_state_.break_id,e);
1660 var h={current:g[0],
1670 DebugCommandProcessor.prototype.suspendRequest_=function(a,b){
1673 DebugCommandProcessor.prototype.versionRequest_=function(a,b){
1675 V8Version:%GetV8Version()
1678 DebugCommandProcessor.prototype.changeLiveRequest_=function(
1680 if(!request.arguments){
1681 return response.failed('Missing arguments');
1683 var a=request.arguments.script_id;
1684 var b=!!request.arguments.preview_only;
1685 var c=%DebugGetLoadedScripts();
1687 for(var e=0;e<c.length;e++){
1693 response.failed('Script not found');
1697 if(!(typeof(request.arguments.new_source)==='string')){
1698 throw"new_source argument expected";
1700 var h=request.arguments.new_source;
1703 i=Debug.LiveEdit.SetScriptSource(d,
1706 if(e instanceof Debug.LiveEdit.Failure&&"details"in e){
1707 response.failed(e.message,e.details);
1712 response.body={change_log:g,result:i};
1713 if(!b&&!this.running_&&i.stack_modified){
1714 response.body.stepin_recommended=true;
1717 DebugCommandProcessor.prototype.restartFrameRequest_=function(
1719 if(!request.arguments){
1720 return response.failed('Missing arguments');
1722 var a=request.arguments.frame;
1723 if(this.exec_state_.frameCount()==0){
1724 return response.failed('No frames');
1727 if(!(a===(void 0))){
1729 if(c<0||c>=this.exec_state_.frameCount()){
1730 return response.failed('Invalid frame "'+a+'"');
1732 b=this.exec_state_.frame(c);
1734 b=this.exec_state_.frame();
1736 var d=Debug.LiveEdit.RestartFrame(b);
1737 response.body={result:d};
1739 DebugCommandProcessor.prototype.debuggerFlagsRequest_=function(request,
1741 if(!request.arguments){
1742 response.failed('Missing arguments');
1745 var a=request.arguments.flags;
1746 response.body={flags:[]};
1747 if(!(a===(void 0))){
1748 for(var b=0;b<a.length;b++){
1750 var d=debugger_flags[c];
1755 d.setValue(a[b].value);
1757 response.body.flags.push({name:c,value:d.getValue()});
1760 for(var c in debugger_flags){
1761 var e=debugger_flags[c].getValue();
1762 response.body.flags.push({name:c,value:e});
1766 DebugCommandProcessor.prototype.v8FlagsRequest_=function(a,b){
1767 var c=a.arguments.flags;
1771 DebugCommandProcessor.prototype.gcRequest_=function(a,b){
1772 var c=a.arguments.type;
1774 var d=%GetHeapUsage();
1776 var e=%GetHeapUsage();
1777 b.body={"before":d,"after":e};
1779 DebugCommandProcessor.prototype.dispatch_=(function(){
1780 var a=DebugCommandProcessor.prototype;
1782 "continue":a.continueRequest_,
1783 "break":a.breakRequest_,
1784 "setbreakpoint":a.setBreakPointRequest_,
1785 "changebreakpoint":a.changeBreakPointRequest_,
1786 "clearbreakpoint":a.clearBreakPointRequest_,
1787 "clearbreakpointgroup":a.clearBreakPointGroupRequest_,
1788 "disconnect":a.disconnectRequest_,
1789 "setexceptionbreak":a.setExceptionBreakRequest_,
1790 "listbreakpoints":a.listBreakpointsRequest_,
1791 "backtrace":a.backtraceRequest_,
1792 "frame":a.frameRequest_,
1793 "scopes":a.scopesRequest_,
1794 "scope":a.scopeRequest_,
1795 "setvariablevalue":a.setVariableValueRequest_,
1796 "evaluate":a.evaluateRequest_,
1797 "lookup":a.lookupRequest_,
1798 "references":a.referencesRequest_,
1799 "source":a.sourceRequest_,
1800 "scripts":a.scriptsRequest_,
1801 "threads":a.threadsRequest_,
1802 "suspend":a.suspendRequest_,
1803 "version":a.versionRequest_,
1804 "changelive":a.changeLiveRequest_,
1805 "restartframe":a.restartFrameRequest_,
1806 "flags":a.debuggerFlagsRequest_,
1807 "v8flag":a.v8FlagsRequest_,
1811 DebugCommandProcessor.prototype.isRunning=function(){
1812 return this.running_;
1814 DebugCommandProcessor.prototype.systemBreak=function(a,b){
1815 return %SystemBreak();
1817 function ObjectToProtocolObject_(a,b){
1820 if(typeof d=='string'){
1821 var e=ValueToProtocolValue_(a[d],
1823 if(!(e===(void 0))){
1830 function ArrayToProtocolArray_(a,b){
1832 for(var d=0;d<a.length;d++){
1833 c.push(ValueToProtocolValue_(a[d],b));
1837 function ValueToProtocolValue_(a,b){
1841 if(a instanceof Mirror){
1842 c=b.serializeValue(a);
1843 }else if((%_IsArray(a))){
1844 c=ArrayToProtocolArray_(a,b);
1846 c=ObjectToProtocolObject_(a,b);
1863 var next_transient_handle_=-1;
1864 var mirror_cache_=[];
1865 var mirror_cache_enabled_=true;
1866 function ToggleMirrorCache(a){
1867 mirror_cache_enabled_=a;
1871 function ObjectIsPromise(a){
1873 return(%_IsSpecObject(a))&&
1874 !(%DebugGetProperty(a,builtins.$promiseStatus)===(void 0));
1879 function MakeMirror(a,b){
1881 if(!b&&mirror_cache_enabled_){
1882 for(var d in mirror_cache_){
1887 if(c.isNumber()&&isNaN(c.value())&&
1888 typeof a=='number'&&isNaN(a)){
1894 c=new UndefinedMirror();
1895 }else if((a===null)){
1897 }else if((typeof(a)==='boolean')){
1898 c=new BooleanMirror(a);
1899 }else if((typeof(a)==='number')){
1900 c=new NumberMirror(a);
1901 }else if((typeof(a)==='string')){
1902 c=new StringMirror(a);
1903 }else if((typeof(a)==='symbol')){
1904 c=new SymbolMirror(a);
1905 }else if((%_IsArray(a))){
1906 c=new ArrayMirror(a);
1907 }else if((%_ClassOf(a)==='Date')){
1908 c=new DateMirror(a);
1909 }else if((%_IsFunction(a))){
1910 c=new FunctionMirror(a);
1911 }else if((%_IsRegExp(a))){
1912 c=new RegExpMirror(a);
1913 }else if((%_ClassOf(a)==='Error')){
1914 c=new ErrorMirror(a);
1915 }else if((%_ClassOf(a)==='Script')){
1916 c=new ScriptMirror(a);
1917 }else if((%_ClassOf(a)==='Map')||(%_ClassOf(a)==='WeakMap')){
1919 }else if((%_ClassOf(a)==='Set')||(%_ClassOf(a)==='WeakSet')){
1921 }else if((%_ClassOf(a)==='Map Iterator')||(%_ClassOf(a)==='Set Iterator')){
1922 c=new IteratorMirror(a);
1923 }else if(ObjectIsPromise(a)){
1924 c=new PromiseMirror(a);
1925 }else if((%_ClassOf(a)==='Generator')){
1926 c=new GeneratorMirror(a);
1928 c=new ObjectMirror(a,OBJECT_TYPE,b);
1930 if(mirror_cache_enabled_)mirror_cache_[c.handle()]=c;
1933 function LookupMirror(a){
1934 if(!mirror_cache_enabled_)throw new Error("Mirror cache is disabled");
1935 return mirror_cache_[a];
1937 function GetUndefinedMirror(){
1938 return MakeMirror((void 0));
1940 function inherits(a,b){
1942 c.prototype=b.prototype;
1943 a.super_=b.prototype;
1944 a.prototype=new c();
1945 a.prototype.constructor=a;
1947 var UNDEFINED_TYPE='undefined';
1948 var NULL_TYPE='null';
1949 var BOOLEAN_TYPE='boolean';
1950 var NUMBER_TYPE='number';
1951 var STRING_TYPE='string';
1952 var SYMBOL_TYPE='symbol';
1953 var OBJECT_TYPE='object';
1954 var FUNCTION_TYPE='function';
1955 var REGEXP_TYPE='regexp';
1956 var ERROR_TYPE='error';
1957 var PROPERTY_TYPE='property';
1958 var INTERNAL_PROPERTY_TYPE='internalProperty';
1959 var FRAME_TYPE='frame';
1960 var SCRIPT_TYPE='script';
1961 var CONTEXT_TYPE='context';
1962 var SCOPE_TYPE='scope';
1963 var PROMISE_TYPE='promise';
1966 var ITERATOR_TYPE='iterator';
1967 var GENERATOR_TYPE='generator';
1968 var kMaxProtocolStringLength=80;
1969 var PropertyKind={};
1970 PropertyKind.Named=1;
1971 PropertyKind.Indexed=2;
1972 var PropertyType={};
1973 PropertyType.Data=0;
1974 PropertyType.DataConstant=2;
1975 PropertyType.AccessorConstant=3;
1976 var PropertyAttribute={};
1977 PropertyAttribute.None=0;
1978 PropertyAttribute.ReadOnly=1;
1979 PropertyAttribute.DontEnum=2;
1980 PropertyAttribute.DontDelete=4;
1981 var ScopeType={Global:0,
1991 Mirror.prototype.type=function(){
1994 Mirror.prototype.isValue=function(){
1995 return this instanceof ValueMirror;
1997 Mirror.prototype.isUndefined=function(){
1998 return this instanceof UndefinedMirror;
2000 Mirror.prototype.isNull=function(){
2001 return this instanceof NullMirror;
2003 Mirror.prototype.isBoolean=function(){
2004 return this instanceof BooleanMirror;
2006 Mirror.prototype.isNumber=function(){
2007 return this instanceof NumberMirror;
2009 Mirror.prototype.isString=function(){
2010 return this instanceof StringMirror;
2012 Mirror.prototype.isSymbol=function(){
2013 return this instanceof SymbolMirror;
2015 Mirror.prototype.isObject=function(){
2016 return this instanceof ObjectMirror;
2018 Mirror.prototype.isFunction=function(){
2019 return this instanceof FunctionMirror;
2021 Mirror.prototype.isUnresolvedFunction=function(){
2022 return this instanceof UnresolvedFunctionMirror;
2024 Mirror.prototype.isArray=function(){
2025 return this instanceof ArrayMirror;
2027 Mirror.prototype.isDate=function(){
2028 return this instanceof DateMirror;
2030 Mirror.prototype.isRegExp=function(){
2031 return this instanceof RegExpMirror;
2033 Mirror.prototype.isError=function(){
2034 return this instanceof ErrorMirror;
2036 Mirror.prototype.isPromise=function(){
2037 return this instanceof PromiseMirror;
2039 Mirror.prototype.isGenerator=function(){
2040 return this instanceof GeneratorMirror;
2042 Mirror.prototype.isProperty=function(){
2043 return this instanceof PropertyMirror;
2045 Mirror.prototype.isInternalProperty=function(){
2046 return this instanceof InternalPropertyMirror;
2048 Mirror.prototype.isFrame=function(){
2049 return this instanceof FrameMirror;
2051 Mirror.prototype.isScript=function(){
2052 return this instanceof ScriptMirror;
2054 Mirror.prototype.isContext=function(){
2055 return this instanceof ContextMirror;
2057 Mirror.prototype.isScope=function(){
2058 return this instanceof ScopeMirror;
2060 Mirror.prototype.isMap=function(){
2061 return this instanceof MapMirror;
2063 Mirror.prototype.isSet=function(){
2064 return this instanceof SetMirror;
2066 Mirror.prototype.isIterator=function(){
2067 return this instanceof IteratorMirror;
2069 Mirror.prototype.allocateHandle_=function(){
2070 if(mirror_cache_enabled_)this.handle_=next_handle_++;
2072 Mirror.prototype.allocateTransientHandle_=function(){
2073 this.handle_=next_transient_handle_--;
2075 Mirror.prototype.toText=function(){
2076 return"#<"+this.constructor.name+">";
2078 function ValueMirror(a,b,c){
2079 %_CallFunction(this,a,Mirror);
2082 this.allocateHandle_();
2084 this.allocateTransientHandle_();
2087 inherits(ValueMirror,Mirror);
2088 Mirror.prototype.handle=function(){
2089 return this.handle_;
2091 ValueMirror.prototype.isPrimitive=function(){
2093 return a==='undefined'||
2100 ValueMirror.prototype.value=function(){
2103 function UndefinedMirror(){
2104 %_CallFunction(this,UNDEFINED_TYPE,(void 0),ValueMirror);
2106 inherits(UndefinedMirror,ValueMirror);
2107 UndefinedMirror.prototype.toText=function(){
2110 function NullMirror(){
2111 %_CallFunction(this,NULL_TYPE,null,ValueMirror);
2113 inherits(NullMirror,ValueMirror);
2114 NullMirror.prototype.toText=function(){
2117 function BooleanMirror(a){
2118 %_CallFunction(this,BOOLEAN_TYPE,a,ValueMirror);
2120 inherits(BooleanMirror,ValueMirror);
2121 BooleanMirror.prototype.toText=function(){
2122 return this.value_?'true':'false';
2124 function NumberMirror(a){
2125 %_CallFunction(this,NUMBER_TYPE,a,ValueMirror);
2127 inherits(NumberMirror,ValueMirror);
2128 NumberMirror.prototype.toText=function(){
2129 return %_NumberToString(this.value_);
2131 function StringMirror(a){
2132 %_CallFunction(this,STRING_TYPE,a,ValueMirror);
2134 inherits(StringMirror,ValueMirror);
2135 StringMirror.prototype.length=function(){
2136 return this.value_.length;
2138 StringMirror.prototype.getTruncatedValue=function(a){
2139 if(a!=-1&&this.length()>a){
2140 return this.value_.substring(0,a)+
2141 '... (length: '+this.length()+')';
2145 StringMirror.prototype.toText=function(){
2146 return this.getTruncatedValue(kMaxProtocolStringLength);
2148 function SymbolMirror(a){
2149 %_CallFunction(this,SYMBOL_TYPE,a,ValueMirror);
2151 inherits(SymbolMirror,ValueMirror);
2152 SymbolMirror.prototype.description=function(){
2153 return %SymbolDescription(%_ValueOf(this.value_));
2155 SymbolMirror.prototype.toText=function(){
2156 return %_CallFunction(this.value_,builtins.$symbolToString);
2158 function ObjectMirror(a,b,c){
2159 %_CallFunction(this,b||OBJECT_TYPE,a,c,ValueMirror);
2161 inherits(ObjectMirror,ValueMirror);
2162 ObjectMirror.prototype.className=function(){
2163 return %_ClassOf(this.value_);
2165 ObjectMirror.prototype.constructorFunction=function(){
2166 return MakeMirror(%DebugGetProperty(this.value_,'constructor'));
2168 ObjectMirror.prototype.prototypeObject=function(){
2169 return MakeMirror(%DebugGetProperty(this.value_,'prototype'));
2171 ObjectMirror.prototype.protoObject=function(){
2172 return MakeMirror(%DebugGetPrototype(this.value_));
2174 ObjectMirror.prototype.hasNamedInterceptor=function(){
2175 var a=%GetInterceptorInfo(this.value_);
2178 ObjectMirror.prototype.hasIndexedInterceptor=function(){
2179 var a=%GetInterceptorInfo(this.value_);
2182 function TryGetPropertyNames(a){
2184 return %GetOwnPropertyNames(a,32);
2189 ObjectMirror.prototype.propertyNames=function(a,b){
2190 a=a||PropertyKind.Named|PropertyKind.Indexed;
2194 if(a&PropertyKind.Named){
2195 c=TryGetPropertyNames(this.value_);
2197 if(this.hasNamedInterceptor()&&(a&PropertyKind.Named)){
2199 %GetNamedInterceptorPropertyNames(this.value_);
2206 if(a&PropertyKind.Indexed){
2207 d=%GetOwnElementNames(this.value_);
2209 if(this.hasIndexedInterceptor()&&(a&PropertyKind.Indexed)){
2211 %GetIndexedInterceptorElementNames(this.value_);
2221 if(a&PropertyKind.Named){
2222 for(var k=0;j<b&&k<c.length;k++){
2226 if(a&PropertyKind.Indexed){
2227 for(var k=0;j<b&&k<d.length;k++){
2233 ObjectMirror.prototype.properties=function(a,b){
2234 var c=this.propertyNames(a,b);
2235 var d=new Array(c.length);
2236 for(var e=0;e<c.length;e++){
2237 d[e]=this.property(c[e]);
2241 ObjectMirror.prototype.internalProperties=function(){
2242 return ObjectMirror.GetInternalProperties(this.value_);
2244 ObjectMirror.prototype.property=function(a){
2245 var b=%DebugGetPropertyDetails(this.value_,%ToName(a));
2247 return new PropertyMirror(this,a,b);
2249 return GetUndefinedMirror();
2251 ObjectMirror.prototype.lookupProperty=function(a){
2252 var b=this.properties();
2253 for(var c=0;c<b.length;c++){
2255 if(d.propertyType()!=PropertyType.AccessorConstant){
2256 if(%_ObjectEquals(d.value_,a.value_)){
2261 return GetUndefinedMirror();
2263 ObjectMirror.prototype.referencedBy=function(a){
2264 var b=%DebugReferencedBy(this.value_,
2265 Mirror.prototype,a||0);
2266 for(var c=0;c<b.length;c++){
2267 b[c]=MakeMirror(b[c]);
2271 ObjectMirror.prototype.toText=function(){
2273 var b=this.constructorFunction();
2274 if(!b.isFunction()){
2284 ObjectMirror.GetInternalProperties=function(a){
2285 if((%_ClassOf(a)==='String')||(%_ClassOf(a)==='Number')||
2286 (%_ClassOf(a)==='Boolean')){
2288 return[new InternalPropertyMirror("[[PrimitiveValue]]",b)];
2289 }else if((%_IsFunction(a))){
2290 var c=%BoundFunctionGetBindings(a);
2292 if(c&&(%_IsArray(c))){
2293 d.push(new InternalPropertyMirror("[[TargetFunction]]",
2295 d.push(new InternalPropertyMirror("[[BoundThis]]",c[1]));
2297 for(var g=2;g<c.length;g++){
2300 d.push(new InternalPropertyMirror("[[BoundArgs]]",e));
2303 }else if((%_ClassOf(a)==='Map Iterator')||(%_ClassOf(a)==='Set Iterator')){
2304 var h=(%_ClassOf(a)==='Map Iterator')?%MapIteratorDetails(a)
2305 :%SetIteratorDetails(a);
2308 case 1:i="keys";break;
2309 case 2:i="values";break;
2310 case 3:i="entries";break;
2313 new InternalPropertyMirror("[[IteratorHasMore]]",h[0]),
2314 new InternalPropertyMirror("[[IteratorIndex]]",h[1])
2317 d.push(new InternalPropertyMirror("[[IteratorKind]]",i));
2320 }else if((%_ClassOf(a)==='Generator')){
2322 new InternalPropertyMirror("[[GeneratorStatus]]",
2323 GeneratorGetStatus_(a)),
2324 new InternalPropertyMirror("[[GeneratorFunction]]",
2325 %GeneratorGetFunction(a)),
2326 new InternalPropertyMirror("[[GeneratorReceiver]]",
2327 %GeneratorGetReceiver(a))
2329 }else if(ObjectIsPromise(a)){
2331 new InternalPropertyMirror("[[PromiseStatus]]",PromiseGetStatus_(a)),
2332 new InternalPropertyMirror("[[PromiseValue]]",PromiseGetValue_(a))
2337 function FunctionMirror(a){
2338 %_CallFunction(this,a,FUNCTION_TYPE,ObjectMirror);
2339 this.resolved_=true;
2341 inherits(FunctionMirror,ObjectMirror);
2342 FunctionMirror.prototype.resolved=function(){
2343 return this.resolved_;
2345 FunctionMirror.prototype.name=function(){
2346 return %FunctionGetName(this.value_);
2348 FunctionMirror.prototype.inferredName=function(){
2349 return %FunctionGetInferredName(this.value_);
2351 FunctionMirror.prototype.source=function(){
2352 if(this.resolved()){
2353 return builtins.FunctionSourceString(this.value_);
2356 FunctionMirror.prototype.script=function(){
2357 if(this.resolved()){
2359 return this.script_;
2361 var a=%FunctionGetScript(this.value_);
2363 return this.script_=MakeMirror(a);
2367 FunctionMirror.prototype.sourcePosition_=function(){
2368 if(this.resolved()){
2369 return %FunctionGetScriptSourcePosition(this.value_);
2372 FunctionMirror.prototype.sourceLocation=function(){
2373 if(this.resolved()){
2374 var a=this.script();
2376 return a.locationFromPosition(this.sourcePosition_(),true);
2380 FunctionMirror.prototype.constructedBy=function(a){
2381 if(this.resolved()){
2382 var b=%DebugConstructedBy(this.value_,a||0);
2383 for(var c=0;c<b.length;c++){
2384 b[c]=MakeMirror(b[c]);
2391 FunctionMirror.prototype.scopeCount=function(){
2392 if(this.resolved()){
2393 if((this.scopeCount_===(void 0))){
2394 this.scopeCount_=%GetFunctionScopeCount(this.value());
2396 return this.scopeCount_;
2401 FunctionMirror.prototype.scope=function(a){
2402 if(this.resolved()){
2403 return new ScopeMirror((void 0),this,a);
2406 FunctionMirror.prototype.toText=function(){
2407 return this.source();
2409 function UnresolvedFunctionMirror(a){
2410 %_CallFunction(this,FUNCTION_TYPE,a,ValueMirror);
2411 this.propertyCount_=0;
2412 this.elementCount_=0;
2413 this.resolved_=false;
2415 inherits(UnresolvedFunctionMirror,FunctionMirror);
2416 UnresolvedFunctionMirror.prototype.className=function(){
2419 UnresolvedFunctionMirror.prototype.constructorFunction=function(){
2420 return GetUndefinedMirror();
2422 UnresolvedFunctionMirror.prototype.prototypeObject=function(){
2423 return GetUndefinedMirror();
2425 UnresolvedFunctionMirror.prototype.protoObject=function(){
2426 return GetUndefinedMirror();
2428 UnresolvedFunctionMirror.prototype.name=function(){
2431 UnresolvedFunctionMirror.prototype.inferredName=function(){
2434 UnresolvedFunctionMirror.prototype.propertyNames=function(a,b){
2437 function ArrayMirror(a){
2438 %_CallFunction(this,a,ObjectMirror);
2440 inherits(ArrayMirror,ObjectMirror);
2441 ArrayMirror.prototype.length=function(){
2442 return this.value_.length;
2444 ArrayMirror.prototype.indexedPropertiesFromRange=function(opt_from_index,
2446 var a=opt_from_index||0;
2447 var b=opt_to_index||this.length()-1;
2448 if(a>b)return new Array();
2449 var c=new Array(b-a+1);
2450 for(var d=a;d<=b;d++){
2451 var e=%DebugGetPropertyDetails(this.value_,%ToString(d));
2454 g=new PropertyMirror(this,d,e);
2456 g=GetUndefinedMirror();
2462 function DateMirror(a){
2463 %_CallFunction(this,a,ObjectMirror);
2465 inherits(DateMirror,ObjectMirror);
2466 DateMirror.prototype.toText=function(){
2467 var a=JSON.stringify(this.value_);
2468 return a.substring(1,a.length-1);
2470 function RegExpMirror(a){
2471 %_CallFunction(this,a,REGEXP_TYPE,ObjectMirror);
2473 inherits(RegExpMirror,ObjectMirror);
2474 RegExpMirror.prototype.source=function(){
2475 return this.value_.source;
2477 RegExpMirror.prototype.global=function(){
2478 return this.value_.global;
2480 RegExpMirror.prototype.ignoreCase=function(){
2481 return this.value_.ignoreCase;
2483 RegExpMirror.prototype.multiline=function(){
2484 return this.value_.multiline;
2486 RegExpMirror.prototype.sticky=function(){
2487 return this.value_.sticky;
2489 RegExpMirror.prototype.unicode=function(){
2490 return this.value_.unicode;
2492 RegExpMirror.prototype.toText=function(){
2493 return"/"+this.source()+"/";
2495 function ErrorMirror(a){
2496 %_CallFunction(this,a,ERROR_TYPE,ObjectMirror);
2498 inherits(ErrorMirror,ObjectMirror);
2499 ErrorMirror.prototype.message=function(){
2500 return this.value_.message;
2502 ErrorMirror.prototype.toText=function(){
2505 a=%_CallFunction(this.value_,builtins.ErrorToString);
2511 function PromiseMirror(a){
2512 %_CallFunction(this,a,PROMISE_TYPE,ObjectMirror);
2514 inherits(PromiseMirror,ObjectMirror);
2515 function PromiseGetStatus_(a){
2516 var b=%DebugGetProperty(a,builtins.$promiseStatus);
2517 if(b==0)return"pending";
2518 if(b==1)return"resolved";
2521 function PromiseGetValue_(a){
2522 return %DebugGetProperty(a,builtins.$promiseValue);
2524 PromiseMirror.prototype.status=function(){
2525 return PromiseGetStatus_(this.value_);
2527 PromiseMirror.prototype.promiseValue=function(){
2528 return MakeMirror(PromiseGetValue_(this.value_));
2530 function MapMirror(a){
2531 %_CallFunction(this,a,MAP_TYPE,ObjectMirror);
2533 inherits(MapMirror,ObjectMirror);
2534 MapMirror.prototype.entries=function(a){
2536 if((%_ClassOf(this.value_)==='WeakMap')){
2537 var c=%GetWeakMapEntries(this.value_,a||0);
2538 for(var d=0;d<c.length;d+=2){
2546 var e=%_CallFunction(this.value_,builtins.$mapEntries);
2548 while((!a||b.length<a)&&
2549 !(g=e.next()).done){
2557 function SetMirror(a){
2558 %_CallFunction(this,a,SET_TYPE,ObjectMirror);
2560 inherits(SetMirror,ObjectMirror);
2561 function IteratorGetValues_(a,b,c){
2564 while((!c||d.length<c)&&
2565 !(e=%_CallFunction(a,b)).done){
2570 SetMirror.prototype.values=function(a){
2571 if((%_ClassOf(this.value_)==='WeakSet')){
2572 return %GetWeakSetValues(this.value_,a||0);
2574 var b=%_CallFunction(this.value_,builtins.$setValues);
2575 return IteratorGetValues_(b,builtins.$setIteratorNext,a);
2577 function IteratorMirror(a){
2578 %_CallFunction(this,a,ITERATOR_TYPE,ObjectMirror);
2580 inherits(IteratorMirror,ObjectMirror);
2581 IteratorMirror.prototype.preview=function(a){
2582 if((%_ClassOf(this.value_)==='Map Iterator')){
2583 return IteratorGetValues_(%MapIteratorClone(this.value_),
2584 builtins.$mapIteratorNext,
2586 }else if((%_ClassOf(this.value_)==='Set Iterator')){
2587 return IteratorGetValues_(%SetIteratorClone(this.value_),
2588 builtins.$setIteratorNext,
2592 function GeneratorMirror(a){
2593 %_CallFunction(this,a,GENERATOR_TYPE,ObjectMirror);
2595 inherits(GeneratorMirror,ObjectMirror);
2596 function GeneratorGetStatus_(a){
2597 var b=%GeneratorGetContinuation(a);
2598 if(b<0)return"running";
2599 if(b==0)return"closed";
2602 GeneratorMirror.prototype.status=function(){
2603 return GeneratorGetStatus_(this.value_);
2605 GeneratorMirror.prototype.sourcePosition_=function(){
2606 return %GeneratorGetSourcePosition(this.value_);
2608 GeneratorMirror.prototype.sourceLocation=function(){
2609 var a=this.sourcePosition_();
2610 if(!(a===(void 0))){
2611 var b=this.func().script();
2613 return b.locationFromPosition(a,true);
2617 GeneratorMirror.prototype.func=function(){
2619 this.func_=MakeMirror(%GeneratorGetFunction(this.value_));
2623 GeneratorMirror.prototype.context=function(){
2625 this.context_=new ContextMirror(%GeneratorGetContext(this.value_));
2627 return this.context_;
2629 GeneratorMirror.prototype.receiver=function(){
2630 if(!this.receiver_){
2631 this.receiver_=MakeMirror(%GeneratorGetReceiver(this.value_));
2633 return this.receiver_;
2635 function PropertyMirror(a,b,c){
2636 %_CallFunction(this,PROPERTY_TYPE,Mirror);
2641 this.is_interceptor_=c[2];
2643 this.exception_=c[3];
2648 inherits(PropertyMirror,Mirror);
2649 PropertyMirror.prototype.isReadOnly=function(){
2650 return(this.attributes()&PropertyAttribute.ReadOnly)!=0;
2652 PropertyMirror.prototype.isEnum=function(){
2653 return(this.attributes()&PropertyAttribute.DontEnum)==0;
2655 PropertyMirror.prototype.canDelete=function(){
2656 return(this.attributes()&PropertyAttribute.DontDelete)==0;
2658 PropertyMirror.prototype.name=function(){
2661 PropertyMirror.prototype.isIndexed=function(){
2662 for(var a=0;a<this.name_.length;a++){
2663 if(this.name_[a]<'0'||'9'<this.name_[a]){
2669 PropertyMirror.prototype.value=function(){
2670 return MakeMirror(this.value_,false);
2672 PropertyMirror.prototype.isException=function(){
2673 return this.exception_?true:false;
2675 PropertyMirror.prototype.attributes=function(){
2676 return %DebugPropertyAttributesFromDetails(this.details_);
2678 PropertyMirror.prototype.propertyType=function(){
2679 return %DebugPropertyTypeFromDetails(this.details_);
2681 PropertyMirror.prototype.insertionIndex=function(){
2682 return %DebugPropertyIndexFromDetails(this.details_);
2684 PropertyMirror.prototype.hasGetter=function(){
2685 return this.getter_?true:false;
2687 PropertyMirror.prototype.hasSetter=function(){
2688 return this.setter_?true:false;
2690 PropertyMirror.prototype.getter=function(){
2691 if(this.hasGetter()){
2692 return MakeMirror(this.getter_);
2694 return GetUndefinedMirror();
2697 PropertyMirror.prototype.setter=function(){
2698 if(this.hasSetter()){
2699 return MakeMirror(this.setter_);
2701 return GetUndefinedMirror();
2704 PropertyMirror.prototype.isNative=function(){
2705 return this.is_interceptor_||
2706 ((this.propertyType()==PropertyType.AccessorConstant)&&
2707 !this.hasGetter()&&!this.hasSetter());
2709 function InternalPropertyMirror(a,b){
2710 %_CallFunction(this,INTERNAL_PROPERTY_TYPE,Mirror);
2714 inherits(InternalPropertyMirror,Mirror);
2715 InternalPropertyMirror.prototype.name=function(){
2718 InternalPropertyMirror.prototype.value=function(){
2719 return MakeMirror(this.value_,false);
2721 var kFrameDetailsFrameIdIndex=0;
2722 var kFrameDetailsReceiverIndex=1;
2723 var kFrameDetailsFunctionIndex=2;
2724 var kFrameDetailsArgumentCountIndex=3;
2725 var kFrameDetailsLocalCountIndex=4;
2726 var kFrameDetailsSourcePositionIndex=5;
2727 var kFrameDetailsConstructCallIndex=6;
2728 var kFrameDetailsAtReturnIndex=7;
2729 var kFrameDetailsFlagsIndex=8;
2730 var kFrameDetailsFirstDynamicIndex=9;
2731 var kFrameDetailsNameIndex=0;
2732 var kFrameDetailsValueIndex=1;
2733 var kFrameDetailsNameValueSize=2;
2734 var kFrameDetailsFlagDebuggerFrameMask=1<<0;
2735 var kFrameDetailsFlagOptimizedFrameMask=1<<1;
2736 var kFrameDetailsFlagInlinedFrameIndexMask=7<<2;
2737 function FrameDetails(a,b){
2739 this.details_=%GetFrameDetails(a,b);
2741 FrameDetails.prototype.frameId=function(){
2742 %CheckExecutionState(this.break_id_);
2743 return this.details_[kFrameDetailsFrameIdIndex];
2745 FrameDetails.prototype.receiver=function(){
2746 %CheckExecutionState(this.break_id_);
2747 return this.details_[kFrameDetailsReceiverIndex];
2749 FrameDetails.prototype.func=function(){
2750 %CheckExecutionState(this.break_id_);
2751 return this.details_[kFrameDetailsFunctionIndex];
2753 FrameDetails.prototype.isConstructCall=function(){
2754 %CheckExecutionState(this.break_id_);
2755 return this.details_[kFrameDetailsConstructCallIndex];
2757 FrameDetails.prototype.isAtReturn=function(){
2758 %CheckExecutionState(this.break_id_);
2759 return this.details_[kFrameDetailsAtReturnIndex];
2761 FrameDetails.prototype.isDebuggerFrame=function(){
2762 %CheckExecutionState(this.break_id_);
2763 var a=kFrameDetailsFlagDebuggerFrameMask;
2764 return(this.details_[kFrameDetailsFlagsIndex]&a)==a;
2766 FrameDetails.prototype.isOptimizedFrame=function(){
2767 %CheckExecutionState(this.break_id_);
2768 var a=kFrameDetailsFlagOptimizedFrameMask;
2769 return(this.details_[kFrameDetailsFlagsIndex]&a)==a;
2771 FrameDetails.prototype.isInlinedFrame=function(){
2772 return this.inlinedFrameIndex()>0;
2774 FrameDetails.prototype.inlinedFrameIndex=function(){
2775 %CheckExecutionState(this.break_id_);
2776 var a=kFrameDetailsFlagInlinedFrameIndexMask;
2777 return(this.details_[kFrameDetailsFlagsIndex]&a)>>2;
2779 FrameDetails.prototype.argumentCount=function(){
2780 %CheckExecutionState(this.break_id_);
2781 return this.details_[kFrameDetailsArgumentCountIndex];
2783 FrameDetails.prototype.argumentName=function(a){
2784 %CheckExecutionState(this.break_id_);
2785 if(a>=0&&a<this.argumentCount()){
2786 return this.details_[kFrameDetailsFirstDynamicIndex+
2787 a*kFrameDetailsNameValueSize+
2788 kFrameDetailsNameIndex];
2791 FrameDetails.prototype.argumentValue=function(a){
2792 %CheckExecutionState(this.break_id_);
2793 if(a>=0&&a<this.argumentCount()){
2794 return this.details_[kFrameDetailsFirstDynamicIndex+
2795 a*kFrameDetailsNameValueSize+
2796 kFrameDetailsValueIndex];
2799 FrameDetails.prototype.localCount=function(){
2800 %CheckExecutionState(this.break_id_);
2801 return this.details_[kFrameDetailsLocalCountIndex];
2803 FrameDetails.prototype.sourcePosition=function(){
2804 %CheckExecutionState(this.break_id_);
2805 return this.details_[kFrameDetailsSourcePositionIndex];
2807 FrameDetails.prototype.localName=function(a){
2808 %CheckExecutionState(this.break_id_);
2809 if(a>=0&&a<this.localCount()){
2810 var b=kFrameDetailsFirstDynamicIndex+
2811 this.argumentCount()*kFrameDetailsNameValueSize;
2812 return this.details_[b+
2813 a*kFrameDetailsNameValueSize+
2814 kFrameDetailsNameIndex];
2817 FrameDetails.prototype.localValue=function(a){
2818 %CheckExecutionState(this.break_id_);
2819 if(a>=0&&a<this.localCount()){
2820 var b=kFrameDetailsFirstDynamicIndex+
2821 this.argumentCount()*kFrameDetailsNameValueSize;
2822 return this.details_[b+
2823 a*kFrameDetailsNameValueSize+
2824 kFrameDetailsValueIndex];
2827 FrameDetails.prototype.returnValue=function(){
2828 %CheckExecutionState(this.break_id_);
2830 kFrameDetailsFirstDynamicIndex+
2831 (this.argumentCount()+this.localCount())*kFrameDetailsNameValueSize;
2832 if(this.details_[kFrameDetailsAtReturnIndex]){
2833 return this.details_[a];
2836 FrameDetails.prototype.scopeCount=function(){
2837 if((this.scopeCount_===(void 0))){
2838 this.scopeCount_=%GetScopeCount(this.break_id_,this.frameId());
2840 return this.scopeCount_;
2842 FrameDetails.prototype.stepInPositionsImpl=function(){
2843 return %GetStepInPositions(this.break_id_,this.frameId());
2845 function FrameMirror(a,b){
2846 %_CallFunction(this,FRAME_TYPE,Mirror);
2849 this.details_=new FrameDetails(a,b);
2851 inherits(FrameMirror,Mirror);
2852 FrameMirror.prototype.details=function(){
2853 return this.details_;
2855 FrameMirror.prototype.index=function(){
2858 FrameMirror.prototype.func=function(){
2862 var a=this.details_.func();
2863 if((%_IsFunction(a))){
2864 return this.func_=MakeMirror(a);
2866 return new UnresolvedFunctionMirror(a);
2869 FrameMirror.prototype.receiver=function(){
2870 return MakeMirror(this.details_.receiver());
2872 FrameMirror.prototype.isConstructCall=function(){
2873 return this.details_.isConstructCall();
2875 FrameMirror.prototype.isAtReturn=function(){
2876 return this.details_.isAtReturn();
2878 FrameMirror.prototype.isDebuggerFrame=function(){
2879 return this.details_.isDebuggerFrame();
2881 FrameMirror.prototype.isOptimizedFrame=function(){
2882 return this.details_.isOptimizedFrame();
2884 FrameMirror.prototype.isInlinedFrame=function(){
2885 return this.details_.isInlinedFrame();
2887 FrameMirror.prototype.inlinedFrameIndex=function(){
2888 return this.details_.inlinedFrameIndex();
2890 FrameMirror.prototype.argumentCount=function(){
2891 return this.details_.argumentCount();
2893 FrameMirror.prototype.argumentName=function(a){
2894 return this.details_.argumentName(a);
2896 FrameMirror.prototype.argumentValue=function(a){
2897 return MakeMirror(this.details_.argumentValue(a));
2899 FrameMirror.prototype.localCount=function(){
2900 return this.details_.localCount();
2902 FrameMirror.prototype.localName=function(a){
2903 return this.details_.localName(a);
2905 FrameMirror.prototype.localValue=function(a){
2906 return MakeMirror(this.details_.localValue(a));
2908 FrameMirror.prototype.returnValue=function(){
2909 return MakeMirror(this.details_.returnValue());
2911 FrameMirror.prototype.sourcePosition=function(){
2912 return this.details_.sourcePosition();
2914 FrameMirror.prototype.sourceLocation=function(){
2919 return b.locationFromPosition(this.sourcePosition(),true);
2923 FrameMirror.prototype.sourceLine=function(){
2924 var a=this.sourceLocation();
2929 FrameMirror.prototype.sourceColumn=function(){
2930 var a=this.sourceLocation();
2935 FrameMirror.prototype.sourceLineText=function(){
2936 var a=this.sourceLocation();
2938 return a.sourceText();
2941 FrameMirror.prototype.scopeCount=function(){
2942 return this.details_.scopeCount();
2944 FrameMirror.prototype.scope=function(a){
2945 return new ScopeMirror(this,(void 0),a);
2947 FrameMirror.prototype.allScopes=function(a){
2948 var b=%GetAllScopesDetails(this.break_id_,
2949 this.details_.frameId(),
2950 this.details_.inlinedFrameIndex(),
2953 for(var d=0;d<b.length;++d){
2954 c.push(new ScopeMirror(this,(void 0),d,b[d]));
2958 FrameMirror.prototype.stepInPositions=function(){
2959 var a=this.func().script();
2960 var b=this.func().sourcePosition_();
2961 var c=this.details_.stepInPositionsImpl();
2964 for(var e=0;e<c.length;e++){
2966 var h=a.locationFromPosition(b+c[e],
2968 serializeLocationFields(h,g);
2977 FrameMirror.prototype.evaluate=function(source,disable_break,
2978 opt_context_object){
2979 return MakeMirror(%DebugEvaluate(this.break_id_,
2980 this.details_.frameId(),
2981 this.details_.inlinedFrameIndex(),
2983 Boolean(disable_break),
2984 opt_context_object));
2986 FrameMirror.prototype.invocationText=function(){
2989 var c=this.receiver();
2990 if(this.isConstructCall()){
2992 a+=b.name()?b.name():'[anonymous]';
2993 }else if(this.isDebuggerFrame()){
2997 !c.className||(c.className()!='global');
3001 var e=GetUndefinedMirror();
3004 !g.isNull()&&e.isUndefined();
3006 e=g.lookupProperty(b);
3009 if(!e.isUndefined()){
3020 if(b.name()&&b.name()!=e.name()){
3021 a+='(aka '+b.name()+')';
3027 a+=b.name()?b.name():'[anonymous]';
3030 if(!this.isDebuggerFrame()){
3032 for(var h=0;h<this.argumentCount();h++){
3034 if(this.argumentName(h)){
3035 a+=this.argumentName(h);
3038 a+=this.argumentValue(h).toText();
3042 if(this.isAtReturn()){
3044 a+=this.returnValue().toText();
3048 FrameMirror.prototype.sourceAndPositionText=function(){
3059 if(!this.isDebuggerFrame()){
3060 var d=this.sourceLocation();
3062 a+=!(d===(void 0))?(d.line+1):'?';
3064 a+=!(d===(void 0))?(d.column+1):'?';
3065 if(!(this.sourcePosition()===(void 0))){
3066 a+=' (position '+(this.sourcePosition()+1)+')';
3077 FrameMirror.prototype.localsText=function(){
3079 var b=this.localCount();
3081 for(var c=0;c<b;++c){
3083 a+=this.localName(c);
3085 a+=this.localValue(c).toText();
3091 FrameMirror.prototype.restart=function(){
3092 var a=%LiveEditRestartFrame(this.break_id_,this.index_);
3094 a="Failed to find requested frame";
3098 FrameMirror.prototype.toText=function(a){
3100 b+='#'+(this.index()<=9?'0':'')+this.index();
3102 b+=this.invocationText();
3104 b+=this.sourceAndPositionText();
3107 b+=this.localsText();
3111 var kScopeDetailsTypeIndex=0;
3112 var kScopeDetailsObjectIndex=1;
3113 function ScopeDetails(a,b,c,d){
3115 this.break_id_=a.break_id_;
3117 %GetScopeDetails(a.break_id_,
3118 a.details_.frameId(),
3119 a.details_.inlinedFrameIndex(),
3121 this.frame_id_=a.details_.frameId();
3122 this.inlined_frame_id_=a.details_.inlinedFrameIndex();
3124 this.details_=d||%GetFunctionScopeDetails(b.value(),c);
3125 this.fun_value_=b.value();
3126 this.break_id_=undefined;
3130 ScopeDetails.prototype.type=function(){
3131 if(!(this.break_id_===(void 0))){
3132 %CheckExecutionState(this.break_id_);
3134 return this.details_[kScopeDetailsTypeIndex];
3136 ScopeDetails.prototype.object=function(){
3137 if(!(this.break_id_===(void 0))){
3138 %CheckExecutionState(this.break_id_);
3140 return this.details_[kScopeDetailsObjectIndex];
3142 ScopeDetails.prototype.setVariableValueImpl=function(a,b){
3144 if(!(this.break_id_===(void 0))){
3145 %CheckExecutionState(this.break_id_);
3146 c=%SetScopeVariableValue(this.break_id_,this.frame_id_,
3147 this.inlined_frame_id_,this.index_,a,b);
3149 c=%SetScopeVariableValue(this.fun_value_,null,null,this.index_,
3153 throw new Error("Failed to set variable value");
3156 function ScopeMirror(a,b,c,d){
3157 %_CallFunction(this,SCOPE_TYPE,Mirror);
3159 this.frame_index_=a.index_;
3161 this.frame_index_=undefined;
3163 this.scope_index_=c;
3164 this.details_=new ScopeDetails(a,b,c,d);
3166 inherits(ScopeMirror,Mirror);
3167 ScopeMirror.prototype.details=function(){
3168 return this.details_;
3170 ScopeMirror.prototype.frameIndex=function(){
3171 return this.frame_index_;
3173 ScopeMirror.prototype.scopeIndex=function(){
3174 return this.scope_index_;
3176 ScopeMirror.prototype.scopeType=function(){
3177 return this.details_.type();
3179 ScopeMirror.prototype.scopeObject=function(){
3180 var a=this.scopeType()==ScopeType.Local||
3181 this.scopeType()==ScopeType.Closure||
3182 this.scopeType()==ScopeType.Script;
3183 return MakeMirror(this.details_.object(),a);
3185 ScopeMirror.prototype.setVariableValue=function(a,b){
3186 this.details_.setVariableValueImpl(a,b);
3188 function ScriptMirror(a){
3189 %_CallFunction(this,SCRIPT_TYPE,Mirror);
3191 this.context_=new ContextMirror(a.context_data);
3192 this.allocateHandle_();
3194 inherits(ScriptMirror,Mirror);
3195 ScriptMirror.prototype.value=function(){
3196 return this.script_;
3198 ScriptMirror.prototype.name=function(){
3199 return this.script_.name||this.script_.nameOrSourceURL();
3201 ScriptMirror.prototype.id=function(){
3202 return this.script_.id;
3204 ScriptMirror.prototype.source=function(){
3205 return this.script_.source;
3207 ScriptMirror.prototype.setSource=function(a){
3208 %DebugSetScriptSource(this.script_,a);
3210 ScriptMirror.prototype.lineOffset=function(){
3211 return this.script_.line_offset;
3213 ScriptMirror.prototype.columnOffset=function(){
3214 return this.script_.column_offset;
3216 ScriptMirror.prototype.data=function(){
3217 return this.script_.data;
3219 ScriptMirror.prototype.scriptType=function(){
3220 return this.script_.type;
3222 ScriptMirror.prototype.compilationType=function(){
3223 return this.script_.compilation_type;
3225 ScriptMirror.prototype.lineCount=function(){
3226 return this.script_.lineCount();
3228 ScriptMirror.prototype.locationFromPosition=function(
3229 position,include_resource_offset){
3230 return this.script_.locationFromPosition(position,include_resource_offset);
3232 ScriptMirror.prototype.sourceSlice=function(a,b){
3233 return this.script_.sourceSlice(a,b);
3235 ScriptMirror.prototype.context=function(){
3236 return this.context_;
3238 ScriptMirror.prototype.evalFromScript=function(){
3239 return MakeMirror(this.script_.eval_from_script);
3241 ScriptMirror.prototype.evalFromFunctionName=function(){
3242 return MakeMirror(this.script_.eval_from_function_name);
3244 ScriptMirror.prototype.evalFromLocation=function(){
3245 var a=this.evalFromScript();
3246 if(!a.isUndefined()){
3247 var b=this.script_.eval_from_script_position;
3248 return a.locationFromPosition(b,true);
3251 ScriptMirror.prototype.toText=function(){
3255 if(this.lineOffset()>0){
3256 a+=this.lineOffset();
3258 a+=this.lineOffset()+this.lineCount()-1;
3260 a+=this.lineCount();
3265 function ContextMirror(a){
3266 %_CallFunction(this,CONTEXT_TYPE,Mirror);
3268 this.allocateHandle_();
3270 inherits(ContextMirror,Mirror);
3271 ContextMirror.prototype.data=function(){
3274 function MakeMirrorSerializer(a,b){
3275 return new JSONProtocolSerializer(a,b);
3277 function JSONProtocolSerializer(a,b){
3282 JSONProtocolSerializer.prototype.serializeReference=function(a){
3283 return this.serialize_(a,true,true);
3285 JSONProtocolSerializer.prototype.serializeValue=function(a){
3286 var b=this.serialize_(a,false,true);
3289 JSONProtocolSerializer.prototype.serializeReferencedObjects=function(){
3291 var b=this.mirrors_.length;
3292 for(var c=0;c<b;c++){
3293 a.push(this.serialize_(this.mirrors_[c],false,false));
3297 JSONProtocolSerializer.prototype.includeSource_=function(){
3298 return this.options_&&this.options_.includeSource;
3300 JSONProtocolSerializer.prototype.inlineRefs_=function(){
3301 return this.options_&&this.options_.inlineRefs;
3303 JSONProtocolSerializer.prototype.maxStringLength_=function(){
3304 if((this.options_===(void 0))||
3305 (this.options_.maxStringLength===(void 0))){
3306 return kMaxProtocolStringLength;
3308 return this.options_.maxStringLength;
3310 JSONProtocolSerializer.prototype.add_=function(a){
3311 for(var b=0;b<this.mirrors_.length;b++){
3312 if(this.mirrors_[b]===a){
3316 this.mirrors_.push(a);
3318 JSONProtocolSerializer.prototype.serializeReferenceWithDisplayData_=
3324 case UNDEFINED_TYPE:
3331 b.value=a.getTruncatedValue(this.maxStringLength_());
3334 b.description=a.description();
3338 b.inferredName=a.inferredName();
3340 b.scriptId=a.script().id();
3348 b.className=a.className();
3353 JSONProtocolSerializer.prototype.serialize_=function(mirror,reference,
3356 (mirror.isValue()||mirror.isScript()||mirror.isContext())){
3357 if(this.inlineRefs_()&&mirror.isValue()){
3358 return this.serializeReferenceWithDisplayData_(mirror);
3361 return{'ref':mirror.handle()};
3365 if(mirror.isValue()||mirror.isScript()||mirror.isContext()){
3366 a.handle=mirror.handle();
3368 a.type=mirror.type();
3369 switch(mirror.type()){
3370 case UNDEFINED_TYPE:
3374 a.value=mirror.value();
3377 a.value=NumberToJSON_(mirror.value());
3380 if(this.maxStringLength_()!=-1&&
3381 mirror.length()>this.maxStringLength_()){
3382 var b=mirror.getTruncatedValue(this.maxStringLength_());
3385 a.toIndex=this.maxStringLength_();
3387 a.value=mirror.value();
3389 a.length=mirror.length();
3392 a.description=mirror.description();
3399 case GENERATOR_TYPE:
3400 this.serializeObject_(mirror,a,details);
3403 case INTERNAL_PROPERTY_TYPE:
3404 throw new Error('PropertyMirror cannot be serialized independently');
3407 this.serializeFrame_(mirror,a);
3410 this.serializeScope_(mirror,a);
3414 a.name=mirror.name();
3417 a.lineOffset=mirror.lineOffset();
3418 a.columnOffset=mirror.columnOffset();
3419 a.lineCount=mirror.lineCount();
3421 a.data=mirror.data();
3423 if(this.includeSource_()){
3424 a.source=mirror.source();
3426 var c=mirror.source().substring(0,80);
3429 a.sourceLength=mirror.source().length;
3430 a.scriptType=mirror.scriptType();
3431 a.compilationType=mirror.compilationType();
3432 if(mirror.compilationType()==1&&
3433 mirror.evalFromScript()){
3435 this.serializeReference(mirror.evalFromScript());
3436 var d=mirror.evalFromLocation();
3438 a.evalFromLocation={line:d.line,
3441 if(mirror.evalFromFunctionName()){
3442 a.evalFromFunctionName=mirror.evalFromFunctionName();
3445 if(mirror.context()){
3446 a.context=this.serializeReference(mirror.context());
3450 a.data=mirror.data();
3453 a.text=mirror.toText();
3456 JSONProtocolSerializer.prototype.serializeObject_=function(mirror,content,
3458 content.className=mirror.className();
3459 content.constructorFunction=
3460 this.serializeReference(mirror.constructorFunction());
3461 content.protoObject=this.serializeReference(mirror.protoObject());
3462 content.prototypeObject=this.serializeReference(mirror.prototypeObject());
3463 if(mirror.hasNamedInterceptor()){
3464 content.namedInterceptor=true;
3466 if(mirror.hasIndexedInterceptor()){
3467 content.indexedInterceptor=true;
3469 if(mirror.isFunction()){
3470 content.name=mirror.name();
3471 if(!(mirror.inferredName()===(void 0))){
3472 content.inferredName=mirror.inferredName();
3474 content.resolved=mirror.resolved();
3475 if(mirror.resolved()){
3476 content.source=mirror.source();
3478 if(mirror.script()){
3479 content.script=this.serializeReference(mirror.script());
3480 content.scriptId=mirror.script().id();
3481 serializeLocationFields(mirror.sourceLocation(),content);
3484 for(var a=0;a<mirror.scopeCount();a++){
3485 var b=mirror.scope(a);
3486 content.scopes.push({
3492 if(mirror.isGenerator()){
3493 content.status=mirror.status();
3494 content.func=this.serializeReference(mirror.func())
3495 content.receiver=this.serializeReference(mirror.receiver())
3496 serializeLocationFields(mirror.sourceLocation(),content);
3498 if(mirror.isDate()){
3499 content.value=mirror.value();
3501 if(mirror.isPromise()){
3502 content.status=mirror.status();
3503 content.promiseValue=this.serializeReference(mirror.promiseValue());
3505 var c=mirror.propertyNames(PropertyKind.Named);
3506 var d=mirror.propertyNames(PropertyKind.Indexed);
3507 var e=new Array(c.length+d.length);
3508 for(var a=0;a<c.length;a++){
3509 var g=mirror.property(c[a]);
3510 e[a]=this.serializeProperty_(g);
3512 this.add_(g.value());
3515 for(var a=0;a<d.length;a++){
3516 var g=mirror.property(d[a]);
3517 e[c.length+a]=this.serializeProperty_(g);
3519 this.add_(g.value());
3522 content.properties=e;
3523 var h=mirror.internalProperties();
3526 for(var a=0;a<h.length;a++){
3527 i.push(this.serializeInternalProperty_(h[a]));
3529 content.internalProperties=i;
3532 function serializeLocationFields(a,b){
3536 b.position=a.position;
3538 if(!(c===(void 0))){
3542 if(!(d===(void 0))){
3546 JSONProtocolSerializer.prototype.serializeProperty_=function(a){
3550 if(this.inlineRefs_()&&c.isValue()){
3551 b.value=this.serializeReferenceWithDisplayData_(c);
3553 if(a.attributes()!=PropertyAttribute.None){
3554 b.attributes=a.attributes();
3556 b.propertyType=a.propertyType();
3561 JSONProtocolSerializer.prototype.serializeInternalProperty_=
3566 if(this.inlineRefs_()&&c.isValue()){
3567 b.value=this.serializeReferenceWithDisplayData_(c);
3573 JSONProtocolSerializer.prototype.serializeFrame_=function(a,b){
3575 b.receiver=this.serializeReference(a.receiver());
3577 b.func=this.serializeReference(c);
3580 b.script=this.serializeReference(d);
3582 b.constructCall=a.isConstructCall();
3583 b.atReturn=a.isAtReturn();
3585 b.returnValue=this.serializeReference(a.returnValue());
3587 b.debuggerFrame=a.isDebuggerFrame();
3588 var e=new Array(a.argumentCount());
3589 for(var g=0;g<a.argumentCount();g++){
3591 var i=a.argumentName(g);
3595 h.value=this.serializeReference(a.argumentValue(g));
3599 var e=new Array(a.localCount());
3600 for(var g=0;g<a.localCount();g++){
3602 j.name=a.localName(g);
3603 j.value=this.serializeReference(a.localValue(g));
3607 serializeLocationFields(a.sourceLocation(),b);
3608 var k=a.sourceLineText();
3609 if(!(k===(void 0))){
3613 for(var g=0;g<a.scopeCount();g++){
3621 JSONProtocolSerializer.prototype.serializeScope_=function(a,b){
3622 b.index=a.scopeIndex();
3623 b.frameIndex=a.frameIndex();
3624 b.type=a.scopeType();
3625 b.object=this.inlineRefs_()?
3626 this.serializeValue(a.scopeObject()):
3627 this.serializeReference(a.scopeObject());
3629 function NumberToJSON_(a){
3633 if(!(%_IsSmi(%IS_VAR(a))||((a==a)&&(a!=1/0)&&(a!=-1/0)))){
3645 Debug.LiveEdit=new function(){
3647 var b="stack_update_needs_step_in";
3648 function ApplyPatchMultiChunk(script,diff_array,new_source,preview_only,
3650 var c=script.source;
3651 var d=GatherCompileInfo(c,script);
3652 var e=BuildCodeInfoTree(d);
3653 var g=new PosTranslator(diff_array);
3654 MarkChangedFunctions(e,g.GetChunks());
3655 FindLiveSharedInfos(e,script);
3658 h=GatherCompileInfo(new_source,script);
3661 new Failure("Failed to compile new version of script: "+e);
3662 if(e instanceof SyntaxError){
3664 type:"liveedit_compile_error",
3665 syntaxErrorMessage:e.message
3667 CopyErrorPositionToDetails(e,j);
3672 var k=BuildCodeInfoTree(h);
3673 FindCorrespondingFunctions(e,k);
3678 function HarvestTodo(p){
3679 function CollectDamaged(q){
3681 for(var r=0;r<q.children.length;r++){
3682 CollectDamaged(q.children[r]);
3685 function CollectNew(t){
3686 for(var r=0;r<t.length;r++){
3688 CollectNew(t[r].children);
3691 if(p.status==a.DAMAGED){
3695 if(p.status==a.UNCHANGED){
3697 }else if(p.status==a.SOURCE_CHANGED){
3699 }else if(p.status==a.CHANGED){
3701 CollectNew(p.unmatched_new_nodes);
3703 for(var r=0;r<p.children.length;r++){
3704 HarvestTodo(p.children[r]);
3708 change_tree:DescribeChangeTree(e),
3711 new_len:new_source.length,
3721 for(var r=0;r<l.length;r++){
3723 l[r].live_shared_function_infos;
3725 for(var x=0;x<w.length;x++){
3731 CheckStackActivations(v,change_log);
3732 u.stack_modified=y!=0;
3735 var z=TemporaryRemoveBreakPoints(script,change_log);
3738 %LiveEditReplaceScript(script,new_source,null);
3741 var B=CreateNameForOldScript(script);
3742 A=%LiveEditReplaceScript(script,new_source,
3745 change_log.push({linked_to_old_script:C});
3746 for(var r=0;r<m.length;r++){
3747 LinkToOldScript(m[r],A,
3750 u.created_script_name=B;
3752 for(var r=0;r<n.length;r++){
3753 %LiveEditFunctionSetScript(
3754 n[r].info.shared_function_info,script);
3756 for(var r=0;r<l.length;r++){
3757 PatchFunctionCode(l[r],change_log);
3760 change_log.push({position_patched:D});
3761 for(var r=0;r<o.length;r++){
3762 PatchPositions(o[r],diff_array,
3764 if(o[r].live_shared_function_infos){
3765 o[r].live_shared_function_infos.
3766 forEach(function(E){
3767 %LiveEditFunctionSourceUpdated(E.raw_array);
3775 this.ApplyPatchMultiChunk=ApplyPatchMultiChunk;
3776 function GatherCompileInfo(F,G){
3777 var H=%LiveEditGatherCompileInfo(G,F);
3780 for(var r=0;r<H.length;r++){
3781 var E=new FunctionCompileInfo(H[r]);
3782 %LiveEditFunctionSetScript(E.shared_function_info,(void 0));
3786 for(var r=0;r<I.length;r++){
3788 for(var x=r+1;x<I.length;x++){
3789 if(I[K].start_position>I[x].start_position){
3803 function ResetIndexes(O,P){
3806 I[N].outer_index==P){
3810 I[Q].next_sibling_index=R;
3814 ResetIndexes(R,J[R]);
3817 I[Q].next_sibling_index=-1;
3820 ResetIndexes(-1,-1);
3821 Assert(N==I.length);
3824 function PatchFunctionCode(p,S){
3825 var T=p.corresponding_node.info;
3826 if(p.live_shared_function_infos){
3827 p.live_shared_function_infos.forEach(function(U){
3828 %LiveEditReplaceFunctionCode(T.raw_array,
3830 for(var r=0;r<p.children.length;r++){
3831 if(p.children[r].corresponding_node){
3833 p.children[r].corresponding_node.info.
3834 shared_function_info;
3835 if(p.children[r].live_shared_function_infos){
3836 p.children[r].live_shared_function_infos.
3837 forEach(function(W){
3838 %LiveEditReplaceRefToNestedFunction(
3847 S.push({function_patched:T.function_name});
3849 S.push({function_patched:T.function_name,
3850 function_info_not_found:true});
3853 function LinkToOldScript(X,A,Y){
3854 if(X.live_shared_function_infos){
3855 X.live_shared_function_infos.
3856 forEach(function(E){
3857 %LiveEditFunctionSetScript(E.info,A);
3859 Y.push({name:X.info.function_name});
3862 {name:X.info.function_name,not_found:true});
3865 function TemporaryRemoveBreakPoints(Z,S){
3866 var aa=GetScriptBreakPoints(Z);
3868 S.push({break_points_update:ab});
3870 for(var r=0;r<aa.length;r++){
3873 var ae=Debug.findScriptSourcePosition(Z,
3874 ad.line(),ad.column());
3882 return function(g,ag){
3883 for(var r=0;r<aa.length;r++){
3886 var ah=ad.cloneForOtherScript(ag);
3889 type:"copied_to_old",
3897 PosTranslator.ShiftWithTopInsideChunkHandler);
3899 Z.locationFromPosition(ai,false);
3900 ad.update_positions(aj.line,aj.column);
3907 ab.push({type:"position_changed",
3909 old_positions:ac[r],
3915 function Assert(al,am){
3924 function DiffChunk(an,ao,ap,aq){
3930 function PosTranslator(ar){
3933 for(var r=0;r<ar.length;r+=3){
3938 as.push(new DiffChunk(au,av,aw-au,
3944 PosTranslator.prototype.GetChunks=function(){
3947 PosTranslator.prototype.Translate=function(ay,az){
3949 if(aA.length==0||ay<aA[0].pos1){
3955 var aD=Math.floor((aB+aC)/2);
3956 if(ay<aA[aD+1].pos1){
3963 if(ay>=aE.pos1+aE.len1){
3964 return ay+aE.pos2+aE.len2-aE.pos1-aE.len1;
3967 az=PosTranslator.DefaultInsideChunkHandler;
3971 PosTranslator.DefaultInsideChunkHandler=function(ay,aF){
3972 Assert(false,"Cannot translate position in changed area");
3974 PosTranslator.ShiftWithTopInsideChunkHandler=
3976 return ay-aF.pos1+aF.pos2;
3979 UNCHANGED:"unchanged",
3980 SOURCE_CHANGED:"source changed",
3984 function CodeInfoTreeNode(aG,aH,aI){
3987 this.array_index=aI;
3988 this.parent=(void 0);
3989 this.status=a.UNCHANGED;
3990 this.status_explanation=(void 0);
3991 this.new_start_pos=(void 0);
3992 this.new_end_pos=(void 0);
3993 this.corresponding_node=(void 0);
3994 this.unmatched_new_nodes=(void 0);
3995 this.textual_corresponding_node=(void 0);
3996 this.textually_unmatched_new_nodes=(void 0);
3997 this.live_shared_function_infos=(void 0);
3999 function BuildCodeInfoTree(aJ){
4001 function BuildNode(){
4005 while(aK<aJ.length&&
4006 aJ[aK].outer_index==aL){
4007 aM.push(BuildNode());
4009 var q=new CodeInfoTreeNode(aJ[aL],aM,
4011 for(var r=0;r<aM.length;r++){
4017 Assert(aK==aJ.length);
4020 function MarkChangedFunctions(aO,as){
4021 var aP=new function(){
4024 this.current=function(){return as[aQ];};
4025 this.next=function(){
4027 aR=aE.pos2+aE.len2-(aE.pos1+aE.len1);
4030 this.done=function(){return aQ>=as.length;};
4031 this.TranslatePos=function(ay){return ay+aR;};
4033 function ProcessInternals(aS){
4034 aS.new_start_pos=aP.TranslatePos(
4035 aS.info.start_position);
4040 aP.current().pos1<aS.info.end_position){
4041 if(aT<aS.children.length){
4042 var aW=aS.children[aT];
4043 if(aW.info.end_position<=aP.current().pos1){
4044 ProcessUnchangedChild(aW);
4047 }else if(aW.info.start_position>=
4048 aP.current().pos1+aP.current().len1){
4052 }else if(aW.info.start_position<=aP.current().pos1&&
4053 aW.info.end_position>=aP.current().pos1+
4055 ProcessInternals(aW);
4057 (aW.status!=a.UNCHANGED);
4059 (aW.status==a.DAMAGED);
4064 aW.status=a.DAMAGED;
4065 aW.status_explanation=
4066 "Text diff overlaps with function boundary";
4071 if(aP.current().pos1+aP.current().len1<=
4072 aS.info.end_position){
4073 aS.status=a.CHANGED;
4077 aS.status=a.DAMAGED;
4078 aS.status_explanation=
4079 "Text diff overlaps with function boundary";
4083 Assert("Unreachable",false);
4085 while(aT<aS.children.length){
4086 var aW=aS.children[aT];
4087 ProcessUnchangedChild(aW);
4091 aS.status=a.CHANGED;
4093 aS.status=a.SOURCE_CHANGED;
4096 aP.TranslatePos(aS.info.end_position);
4098 function ProcessUnchangedChild(q){
4099 q.new_start_pos=aP.TranslatePos(q.info.start_position);
4100 q.new_end_pos=aP.TranslatePos(q.info.end_position);
4102 ProcessInternals(aO);
4104 function FindCorrespondingFunctions(aX,aY){
4105 function ProcessNode(p,aZ){
4107 IsFunctionContextLocalsChanged(p.info,aZ.info);
4117 while(bf<bb.length){
4118 if(bb[bf].status==a.DAMAGED){
4120 }else if(bg<bc.length){
4121 if(bc[bg].info.start_position<
4122 bb[bf].new_start_pos){
4126 }else if(bc[bg].info.start_position==
4127 bb[bf].new_start_pos){
4128 if(bc[bg].info.end_position==
4129 bb[bf].new_end_pos){
4130 bb[bf].corresponding_node=
4132 bb[bf].textual_corresponding_node=
4135 bb[bf].status=a.DAMAGED;
4136 bb[bf].status_explanation=
4137 "Enclosing function is now incompatible. "+
4139 bb[bf].corresponding_node=(void 0);
4140 }else if(bb[bf].status!=
4144 if(bb[bf].status==a.DAMAGED){
4146 bb[bf].corresponding_node);
4147 bb[bf].corresponding_node=(void 0);
4152 bb[bf].status=a.DAMAGED;
4153 bb[bf].status_explanation=
4154 "No corresponding function in new script found";
4162 bb[bf].status=a.DAMAGED;
4163 bb[bf].status_explanation=
4164 "No corresponding function in new script found";
4169 bb[bf].status=a.DAMAGED;
4170 bb[bf].status_explanation=
4171 "No corresponding function in new script found";
4176 while(bg<bc.length){
4181 if(p.status==a.CHANGED){
4182 if(p.info.param_num!=aZ.info.param_num){
4184 p.status_explanation="Changed parameter number: "+
4185 p.info.param_num+" and "+aZ.info.param_num;
4188 p.unmatched_new_nodes=bd;
4189 p.textually_unmatched_new_nodes=
4193 aX.corresponding_node=aY;
4194 aX.textual_corresponding_node=aY;
4195 Assert(aX.status!=a.DAMAGED,
4196 "Script became damaged");
4198 function FindLiveSharedInfos(aX,G){
4199 var bh=%LiveEditFindSharedFunctionInfosForScript(G);
4201 for(var r=0;r<bh.length;r++){
4202 bi.push(new SharedInfoWrapper(bh[r]));
4204 function FindFunctionInfos(I){
4206 for(var r=0;r<bi.length;r++){
4208 if(bk.start_position==I.start_position&&
4209 bk.end_position==I.end_position){
4217 function TraverseTree(q){
4218 q.live_shared_function_infos=FindFunctionInfos(q.info);
4219 for(var r=0;r<q.children.length;r++){
4220 TraverseTree(q.children[r]);
4225 function FunctionCompileInfo(bl){
4226 this.function_name=bl[0];
4227 this.start_position=bl[1];
4228 this.end_position=bl[2];
4229 this.param_num=bl[3];
4231 this.code_scope_info=bl[5];
4232 this.scope_info=bl[6];
4233 this.outer_index=bl[7];
4234 this.shared_function_info=bl[8];
4235 this.next_sibling_index=null;
4238 function SharedInfoWrapper(bl){
4239 this.function_name=bl[0];
4240 this.start_position=bl[1];
4241 this.end_position=bl[2];
4245 function PatchPositions(X,ar,Y){
4246 if(X.live_shared_function_infos){
4247 X.live_shared_function_infos.forEach(function(E){
4248 %LiveEditPatchFunctionPositions(E.raw_array,
4251 Y.push({name:X.info.function_name});
4254 {name:X.info.function_name,info_not_found:true});
4257 function CreateNameForOldScript(G){
4258 return G.name+" (old)";
4260 function IsFunctionContextLocalsChanged(bm,bn){
4261 var bo=bm.scope_info;
4262 var bp=bn.scope_info;
4276 return"Variable map changed: ["+bq+
4282 function CheckStackActivations(bt,S){
4284 for(var r=0;r<bt.length;r++){
4287 var bv=%LiveEditCheckAndDropActivations(bu,true);
4289 throw new Failure(bv[bu.length]);
4293 for(var r=0;r<bu.length;r++){
4295 if(bv[r]==bs.REPLACED_ON_ACTIVE_STACK){
4296 bx.push({name:by.function_name});
4297 }else if(bv[r]!=bs.AVAILABLE_FOR_PATCH){
4299 name:by.function_name,
4300 start_pos:by.start_position,
4301 end_pos:by.end_position,
4303 bs.SymbolName(bv[r])
4309 S.push({dropped_from_stack:bx});
4312 S.push({functions_on_stack:bw});
4313 throw new Failure("Blocked by functions on stack");
4318 AVAILABLE_FOR_PATCH:1,
4319 BLOCKED_ON_ACTIVE_STACK:2,
4320 BLOCKED_ON_OTHER_STACK:3,
4321 BLOCKED_UNDER_NATIVE_CODE:4,
4322 REPLACED_ON_ACTIVE_STACK:5,
4323 BLOCKED_UNDER_GENERATOR:6,
4324 BLOCKED_ACTIVE_GENERATOR:7
4326 bs.SymbolName=function(bA){
4334 function Failure(am){
4337 this.Failure=Failure;
4338 Failure.prototype.toString=function(){
4339 return"LiveEdit Failure: "+this.message;
4341 function CopyErrorPositionToDetails(bD,j){
4342 function createPositionStruct(G,bE){
4344 var bF=G.locationFromPosition(bE,true);
4352 if(!("scriptObject"in bD)||!("startPosition"in bD)){
4355 var G=bD.scriptObject;
4357 start:createPositionStruct(G,bD.startPosition),
4358 end:createPositionStruct(G,bD.endPosition)
4362 function GetPcFromSourcePos(bH,bI){
4363 return %GetFunctionCodePositionFromSource(bH,bI);
4365 this.GetPcFromSourcePos=GetPcFromSourcePos;
4366 function SetScriptSource(G,bJ,bK,S){
4368 var bL=CompareStrings(c,bJ);
4369 return ApplyPatchMultiChunk(G,bL,bJ,bK,
4372 this.SetScriptSource=SetScriptSource;
4373 function CompareStrings(bM,bN){
4374 return %LiveEditCompareStrings(bM,bN);
4376 function ApplySingleChunkPatch(G,change_pos,change_len,new_str,
4379 var bJ=c.substring(0,change_pos)+
4380 new_str+c.substring(change_pos+change_len);
4381 return ApplyPatchMultiChunk(G,
4382 [change_pos,change_pos+change_len,change_pos+new_str.length],
4385 function DescribeChangeTree(aX){
4386 function ProcessOldNode(q){
4388 for(var r=0;r<q.children.length;r++){
4389 var aW=q.children[r];
4390 if(aW.status!=a.UNCHANGED){
4391 bO.push(ProcessOldNode(aW));
4395 if(q.textually_unmatched_new_nodes){
4396 for(var r=0;r<q.textually_unmatched_new_nodes.length;r++){
4397 var aW=q.textually_unmatched_new_nodes[r];
4398 bP.push(ProcessNewNode(aW));
4402 name:q.info.function_name,
4403 positions:DescribePositions(q),
4408 if(q.status_explanation){
4409 bQ.status_explanation=q.status_explanation;
4411 if(q.textual_corresponding_node){
4412 bQ.new_positions=DescribePositions(q.textual_corresponding_node);
4416 function ProcessNewNode(q){
4419 for(var r=0;r<q.children.length;r++){
4420 bO.push(ProcessNewNode(q.children[r]));
4424 name:q.info.function_name,
4425 positions:DescribePositions(q),
4430 function DescribePositions(q){
4432 start_position:q.info.start_position,
4433 end_position:q.info.end_position
4436 return ProcessOldNode(aX);
4438 function RestartFrame(bR){
4439 var bv=bR.restart();
4440 if((typeof(bv)==='string')){
4441 throw new Failure("Failed to restart frame: "+bv);
4447 this.RestartFrame=RestartFrame;
4449 PosTranslator:PosTranslator,
4450 CompareStrings:CompareStrings,
4451 ApplySingleChunkPatch:ApplySingleChunkPatch
4456 var $Object=global.Object;
4457 var $Array=global.Array;
4458 var $String=global.String;
4459 var $Number=global.Number;
4460 var $Function=global.Function;
4461 var $Boolean=global.Boolean;
4462 var $NaN=%GetRootNaN();
4464 if((typeof(this)==='string')&&(typeof(a)==='string'))return %StringEquals(this,a);
4467 if((typeof(b)==='number')){
4469 if((typeof(a)==='number'))return %NumberEquals(b,a);
4470 if((a==null))return 1;
4471 if((typeof(a)==='symbol'))return 1;
4472 if(!(%_IsSpecObject(a))){
4473 return %NumberEquals(b,%ToNumber(a));
4475 a=%ToPrimitive(a,0);
4477 }else if((typeof(b)==='string')){
4479 if((typeof(a)==='string'))return %StringEquals(b,a);
4480 if((typeof(a)==='symbol'))return 1;
4481 if((typeof(a)==='number'))return %NumberEquals(%ToNumber(b),a);
4482 if((typeof(a)==='boolean'))return %NumberEquals(%ToNumber(b),%ToNumber(a));
4483 if((a==null))return 1;
4484 a=%ToPrimitive(a,0);
4486 }else if((typeof(b)==='symbol')){
4487 if((typeof(a)==='symbol'))return %_ObjectEquals(b,a)?0:1;
4489 }else if((typeof(b)==='boolean')){
4490 if((typeof(a)==='boolean'))return %_ObjectEquals(b,a)?0:1;
4491 if((a==null))return 1;
4492 if((typeof(a)==='number'))return %NumberEquals(%ToNumber(b),a);
4493 if((typeof(a)==='string'))return %NumberEquals(%ToNumber(b),%ToNumber(a));
4494 if((typeof(a)==='symbol'))return 1;
4496 a=%ToPrimitive(a,0);
4497 }else if((b==null)){
4498 return(a==null)?0:1;
4500 if((%_IsSpecObject(a))){
4501 return %_ObjectEquals(b,a)?0:1;
4503 if((a==null))return 1;
4504 if((typeof(a)==='symbol'))return 1;
4505 if((typeof(a)==='boolean'))a=%ToNumber(a);
4506 b=%ToPrimitive(b,0);
4510 function STRICT_EQUALS(a){
4511 if((typeof(this)==='string')){
4512 if(!(typeof(a)==='string'))return 1;
4513 return %StringEquals(this,a);
4515 if((typeof(this)==='number')){
4516 if(!(typeof(a)==='number'))return 1;
4517 return %NumberEquals(this,a);
4519 return %_ObjectEquals(this,a)?0:1;
4521 function COMPARE(a,b){
4524 if((typeof(this)==='string')){
4525 if((typeof(a)==='string'))return %_StringCompare(this,a);
4526 if((a===(void 0)))return b;
4528 }else if((typeof(this)==='number')){
4529 if((typeof(a)==='number'))return %NumberCompare(this,a,b);
4530 if((a===(void 0)))return b;
4532 }else if((this===(void 0))){
4533 if(!(a===(void 0))){
4537 }else if((a===(void 0))){
4538 %ToPrimitive(this,1);
4541 c=%ToPrimitive(this,1);
4543 d=%ToPrimitive(a,1);
4544 if((typeof(c)==='string')&&(typeof(d)==='string')){
4545 return %_StringCompare(c,d);
4549 if((!%_IsSmi(%IS_VAR(e))&&!(e==e))||(!%_IsSmi(%IS_VAR(g))&&!(g==g)))return b;
4550 return %NumberCompare(e,g,b);
4554 if((typeof(this)==='number')&&(typeof(a)==='number'))return %NumberAdd(this,a);
4555 if((typeof(this)==='string')&&(typeof(a)==='string'))return %_StringAdd(this,a);
4556 var b=%ToPrimitive(this,0);
4557 var c=%ToPrimitive(a,0);
4558 if((typeof(b)==='string')){
4559 return %_StringAdd(b,%ToString(c));
4560 }else if((typeof(c)==='string')){
4561 return %_StringAdd(%NonStringToString(b),c);
4563 return %NumberAdd(%ToNumber(b),%ToNumber(c));
4566 function STRING_ADD_LEFT(a){
4567 if(!(typeof(a)==='string')){
4568 if((%_ClassOf(a)==='String')&&%_IsStringWrapperSafeForDefaultValueOf(a)){
4571 a=(typeof(a)==='number')
4572 ?%_NumberToString(a)
4573 :%ToString(%ToPrimitive(a,0));
4576 return %_StringAdd(this,a);
4578 function STRING_ADD_RIGHT(a){
4580 if(!(typeof(b)==='string')){
4581 if((%_ClassOf(b)==='String')&&%_IsStringWrapperSafeForDefaultValueOf(b)){
4584 b=(typeof(b)==='number')
4585 ?%_NumberToString(b)
4586 :%ToString(%ToPrimitive(b,0));
4589 return %_StringAdd(b,a);
4592 var b=(typeof(this)==='number')?this:%NonNumberToNumber(this);
4593 if(!(typeof(a)==='number'))a=%NonNumberToNumber(a);
4594 return %NumberSub(b,a);
4597 var b=(typeof(this)==='number')?this:%NonNumberToNumber(this);
4598 if(!(typeof(a)==='number'))a=%NonNumberToNumber(a);
4599 return %NumberMul(b,a);
4602 var b=(typeof(this)==='number')?this:%NonNumberToNumber(this);
4603 if(!(typeof(a)==='number'))a=%NonNumberToNumber(a);
4604 return %NumberDiv(b,a);
4607 var b=(typeof(this)==='number')?this:%NonNumberToNumber(this);
4608 if(!(typeof(a)==='number'))a=%NonNumberToNumber(a);
4609 return %NumberMod(b,a);
4612 var b=(typeof(this)==='number')?this:%NonNumberToNumber(this);
4613 if(!(typeof(a)==='number'))a=%NonNumberToNumber(a);
4614 return %NumberOr(b,a);
4616 function BIT_AND(a){
4618 if((typeof(this)==='number')){
4620 if(!(typeof(a)==='number'))a=%NonNumberToNumber(a);
4622 b=%NonNumberToNumber(this);
4623 if(!(typeof(a)==='number'))a=%NonNumberToNumber(a);
4624 if((!%_IsSmi(%IS_VAR(b))&&!(b==b)))return 0;
4626 return %NumberAnd(b,a);
4628 function BIT_XOR(a){
4629 var b=(typeof(this)==='number')?this:%NonNumberToNumber(this);
4630 if(!(typeof(a)==='number'))a=%NonNumberToNumber(a);
4631 return %NumberXor(b,a);
4634 var b=(typeof(this)==='number')?this:%NonNumberToNumber(this);
4635 if(!(typeof(a)==='number'))a=%NonNumberToNumber(a);
4636 return %NumberShl(b,a);
4640 if((typeof(this)==='number')){
4642 if(!(typeof(a)==='number'))a=%NonNumberToNumber(a);
4644 b=%NonNumberToNumber(this);
4645 if(!(typeof(a)==='number'))a=%NonNumberToNumber(a);
4646 if((!%_IsSmi(%IS_VAR(b))&&!(b==b)))return 0;
4648 return %NumberSar(b,a);
4651 var b=(typeof(this)==='number')?this:%NonNumberToNumber(this);
4652 if(!(typeof(a)==='number'))a=%NonNumberToNumber(a);
4653 return %NumberShr(b,a);
4655 function DELETE(a,b){
4656 return %DeleteProperty(%ToObject(this),%ToName(a),b);
4659 if(!(%_IsSpecObject(a))){
4660 throw %MakeTypeError(11,this,a);
4662 if(%_IsNonNegativeSmi(this)){
4663 if((%_IsArray(a))&&%_HasFastPackedElements(a)){
4664 return this<a.length;
4666 return %HasElement(a,this);
4668 return %HasProperty(a,%ToName(this));
4670 function INSTANCE_OF(a){
4672 if(!(%_ClassOf(a)==='Function')){
4673 throw %MakeTypeError(9,a);
4675 if(!(%_IsSpecObject(b))){
4678 var c=%BoundFunctionGetBindings(a);
4683 if(!(%_IsSpecObject(d))){
4684 throw %MakeTypeError(10,d);
4686 return %IsInPrototypeChain(d,b)?0:1;
4688 function FILTER_KEY(a){
4690 if(%HasProperty(this,b))return b;
4693 function CALL_NON_FUNCTION(){
4694 var a=%GetFunctionDelegate(this);
4695 if(!(%_IsFunction(a))){
4696 var b=%RenderCallSite();
4697 if(b=="")b=typeof this;
4698 throw %MakeTypeError(2,b);
4700 return %Apply(a,this,arguments,0,%_ArgumentsLength());
4702 function CALL_NON_FUNCTION_AS_CONSTRUCTOR(){
4703 var a=%GetConstructorDelegate(this);
4704 if(!(%_IsFunction(a))){
4705 var b=%RenderCallSite();
4706 if(b=="")b=typeof this;
4707 throw %MakeTypeError(2,b);
4709 return %Apply(a,this,arguments,0,%_ArgumentsLength());
4711 function CALL_FUNCTION_PROXY(){
4712 var a=%_ArgumentsLength()-1;
4713 var b=%_Arguments(a);
4714 var c=%GetCallTrap(b);
4715 return %Apply(c,this,arguments,0,a);
4717 function CALL_FUNCTION_PROXY_AS_CONSTRUCTOR(){
4719 var b=%GetConstructTrap(a);
4720 return %Apply(b,this,arguments,0,%_ArgumentsLength());
4722 function APPLY_PREPARE(a){
4726 if(%_IsSmi(b)&&b>=0&&b<0x800000&&
4727 (%_ClassOf(this)==='Function')){
4731 b=(a==null)?0:%ToUint32(a.length);
4732 if(b>0x800000)throw %MakeRangeError(39);
4733 if(!(%_ClassOf(this)==='Function')){
4734 throw %MakeTypeError(1,%ToString(this),typeof this);
4736 if(a!=null&&!(%_IsSpecObject(a))){
4737 throw %MakeTypeError(36,"Function.prototype.apply");
4741 function REFLECT_APPLY_PREPARE(a){
4745 if(%_IsSmi(b)&&b>=0&&b<0x800000&&
4746 (%_ClassOf(this)==='Function')){
4750 if(!(%_ClassOf(this)==='Function')){
4751 throw %MakeTypeError(2,%ToString(this));
4753 if(!(%_IsSpecObject(a))){
4754 throw %MakeTypeError(36,"Reflect.apply");
4756 b=%ToLength(a.length);
4757 if(b>0x800000)throw %MakeRangeError(39);
4760 function REFLECT_CONSTRUCT_PREPARE(a,b){
4762 var d=(%_ClassOf(this)==='Function')&&%IsConstructor(this);
4763 var e=(%_ClassOf(b)==='Function')&&%IsConstructor(b);
4766 if(%_IsSmi(c)&&c>=0&&c<0x800000&&
4772 if(!(%_ClassOf(this)==='Function')){
4773 throw %MakeTypeError(2,%ToString(this));
4775 throw %MakeTypeError(13,%ToString(this));
4779 if(!(%_ClassOf(b)==='Function')){
4780 throw %MakeTypeError(2,%ToString(b));
4782 throw %MakeTypeError(13,%ToString(b));
4785 if(!(%_IsSpecObject(a))){
4786 throw %MakeTypeError(36,"Reflect.construct");
4788 c=%ToLength(a.length);
4789 if(c>0x800000)throw %MakeRangeError(39);
4792 function STACK_OVERFLOW(a){
4793 throw %MakeRangeError(39);
4795 function TO_OBJECT(){
4796 return %ToObject(this);
4798 function TO_NUMBER(){
4799 return %ToNumber(this);
4801 function TO_STRING(){
4802 return %ToString(this);
4805 return %ToName(this);
4807 function ToPrimitive(a,b){
4808 if((typeof(a)==='string'))return a;
4809 if(!(%_IsSpecObject(a)))return a;
4810 if((%_ClassOf(a)==='Symbol'))throw MakeTypeError(30);
4811 if(b==0)b=((%_ClassOf(a)==='Date'))?2:1;
4812 return(b==1)?%DefaultNumber(a):%DefaultString(a);
4814 function ToBoolean(a){
4815 if((typeof(a)==='boolean'))return a;
4816 if((typeof(a)==='string'))return a.length!=0;
4817 if(a==null)return false;
4818 if((typeof(a)==='number'))return!((a==0)||(!%_IsSmi(%IS_VAR(a))&&!(a==a)));
4821 function ToNumber(a){
4822 if((typeof(a)==='number'))return a;
4823 if((typeof(a)==='string')){
4824 return %_HasCachedArrayIndex(a)?%_GetCachedArrayIndex(a)
4825 :%StringToNumber(a);
4827 if((typeof(a)==='boolean'))return a?1:0;
4828 if((a===(void 0)))return $NaN;
4829 if((typeof(a)==='symbol'))throw MakeTypeError(31);
4830 return((a===null))?0:ToNumber(%DefaultNumber(a));
4832 function NonNumberToNumber(a){
4833 if((typeof(a)==='string')){
4834 return %_HasCachedArrayIndex(a)?%_GetCachedArrayIndex(a)
4835 :%StringToNumber(a);
4837 if((typeof(a)==='boolean'))return a?1:0;
4838 if((a===(void 0)))return $NaN;
4839 if((typeof(a)==='symbol'))throw MakeTypeError(31);
4840 return((a===null))?0:ToNumber(%DefaultNumber(a));
4842 function ToString(a){
4843 if((typeof(a)==='string'))return a;
4844 if((typeof(a)==='number'))return %_NumberToString(a);
4845 if((typeof(a)==='boolean'))return a?'true':'false';
4846 if((a===(void 0)))return'undefined';
4847 if((typeof(a)==='symbol'))throw %MakeTypeError(32);
4848 return((a===null))?'null':%ToString(%DefaultString(a));
4850 function NonStringToString(a){
4851 if((typeof(a)==='number'))return %_NumberToString(a);
4852 if((typeof(a)==='boolean'))return a?'true':'false';
4853 if((a===(void 0)))return'undefined';
4854 if((typeof(a)==='symbol'))throw %MakeTypeError(32);
4855 return((a===null))?'null':%ToString(%DefaultString(a));
4858 return(typeof(a)==='symbol')?a:%ToString(a);
4860 function ToObject(a){
4861 if((typeof(a)==='string'))return new $String(a);
4862 if((typeof(a)==='number'))return new $Number(a);
4863 if((typeof(a)==='boolean'))return new $Boolean(a);
4864 if((typeof(a)==='symbol'))return %NewSymbolWrapper(a);
4865 if((a==null)&&!(%_IsUndetectableObject(a))){
4866 throw %MakeTypeError(33);
4870 function ToInteger(a){
4871 if(%_IsSmi(a))return a;
4872 return %NumberToInteger(ToNumber(a));
4874 function ToLength(a){
4877 return a<$Number.MAX_SAFE_INTEGER?a:$Number.MAX_SAFE_INTEGER;
4879 function ToUint32(a){
4880 if(%_IsSmi(a)&&a>=0)return a;
4881 return %NumberToJSUint32(ToNumber(a));
4883 function ToInt32(a){
4884 if(%_IsSmi(a))return a;
4885 return %NumberToJSInt32(ToNumber(a));
4887 function SameValue(a,b){
4888 if(typeof a!=typeof b)return false;
4889 if((typeof(a)==='number')){
4890 if((!%_IsSmi(%IS_VAR(a))&&!(a==a))&&(!%_IsSmi(%IS_VAR(b))&&!(b==b)))return true;
4891 if(a===0&&b===0&&%_IsMinusZero(a)!=%_IsMinusZero(b)){
4897 function SameValueZero(a,b){
4898 if(typeof a!=typeof b)return false;
4899 if((typeof(a)==='number')){
4900 if((!%_IsSmi(%IS_VAR(a))&&!(a==a))&&(!%_IsSmi(%IS_VAR(b))&&!(b==b)))return true;
4904 function IsPrimitive(a){
4905 return!(%_IsSpecObject(a));
4907 function IsConcatSpreadable(a){
4908 if(!(%_IsSpecObject(a)))return false;
4909 var b=a[symbolIsConcatSpreadable];
4910 if((b===(void 0)))return(%_IsArray(a));
4911 return ToBoolean(b);
4913 function DefaultNumber(a){
4914 if(!(%_ClassOf(a)==='Symbol')){
4916 if((%_ClassOf(b)==='Function')){
4917 var c=%_CallFunction(a,b);
4918 if(%IsPrimitive(c))return c;
4921 if((%_ClassOf(d)==='Function')){
4922 var e=%_CallFunction(a,d);
4923 if(%IsPrimitive(e))return e;
4926 throw %MakeTypeError(4);
4928 function DefaultString(a){
4929 if(!(%_ClassOf(a)==='Symbol')){
4931 if((%_ClassOf(b)==='Function')){
4932 var c=%_CallFunction(a,b);
4933 if(%IsPrimitive(c))return c;
4936 if((%_ClassOf(d)==='Function')){
4937 var e=%_CallFunction(a,d);
4938 if(%IsPrimitive(e))return e;
4941 throw %MakeTypeError(4);
4943 function ToPositiveInteger(a,b){
4944 var c=(%_IsSmi(%IS_VAR(a))?a:%NumberToIntegerMapMinusZero(ToNumber(a)));
4945 if(c<0)throw MakeRangeError(b);
4948 %FunctionSetPrototype($Array,new $Array(0));
4949 function STRING_LENGTH_STUB(a){
4951 return %_StringGetLength(%_JSValueGetValue(b));
4955 var $isNaN=GlobalIsNaN;
4956 var $isFinite=GlobalIsFinite;
4957 function InstallFunctions(a,b,c){
4959 %OptimizeObjectForAddingMultipleProperties(a,c.length>>1);
4961 for(var d=0;d<c.length;d+=2){
4964 %FunctionSetName(g,e);
4965 %FunctionRemovePrototype(g);
4966 %AddNamedProperty(a,e,g,b);
4969 %ToFastProperties(a);
4971 function OverrideFunction(a,b,c){
4972 ObjectDefineProperty(a,b,{value:c,
4976 %FunctionSetName(c,b);
4977 %FunctionRemovePrototype(c);
4980 function InstallGetter(a,b,c,d){
4981 if(typeof d=="undefined"){
4984 %FunctionSetName(c,b);
4985 %FunctionRemovePrototype(c);
4986 %DefineAccessorPropertyUnchecked(a,b,c,null,d);
4989 function InstallGetterSetter(a,b,c,d){
4990 %FunctionSetName(c,b);
4991 %FunctionSetName(d,b);
4992 %FunctionRemovePrototype(c);
4993 %FunctionRemovePrototype(d);
4994 %DefineAccessorPropertyUnchecked(a,b,c,d,2);
4998 function InstallConstants(a,b){
5000 %OptimizeObjectForAddingMultipleProperties(a,b.length>>1);
5003 for(var d=0;d<b.length;d+=2){
5006 %AddNamedProperty(a,e,g,c);
5008 %ToFastProperties(a);
5010 function SetUpLockedPrototype(a,b,c){
5011 %CheckIsBootstrapping();
5013 var e=(c.length>>1)+(b?b.length:0);
5015 %OptimizeObjectForAddingMultipleProperties(d,e);
5018 for(var g=0;g<b.length;g++){
5019 %AddNamedProperty(d,b[g],
5023 for(var g=0;g<c.length;g+=2){
5026 %AddNamedProperty(d,h,i,2|4|1);
5029 %InternalSetPrototype(d,null);
5030 %ToFastProperties(d);
5032 function GlobalIsNaN(a){
5033 if(!(typeof(a)==='number'))a=NonNumberToNumber(a);
5034 return(!%_IsSmi(%IS_VAR(a))&&!(a==a));
5036 function GlobalIsFinite(a){
5037 if(!(typeof(a)==='number'))a=NonNumberToNumber(a);
5038 return(%_IsSmi(%IS_VAR(a))||((a==a)&&(a!=1/0)&&(a!=-1/0)));
5040 function GlobalParseInt(a,b){
5041 if((b===(void 0))||b===10||b===0){
5042 if(%_IsSmi(a))return a;
5043 if((typeof(a)==='number')&&
5045 (-1e9<a&&a<-0.01))){
5048 a=((typeof(%IS_VAR(a))==='string')?a:NonStringToString(a));
5051 a=((typeof(%IS_VAR(a))==='string')?a:NonStringToString(a));
5052 b=(%_IsSmi(%IS_VAR(b))?b:(b>>0));
5053 if(!(b==0||(2<=b&&b<=36))){
5057 if(%_HasCachedArrayIndex(a)&&
5059 return %_GetCachedArrayIndex(a);
5061 return %StringParseInt(a,b);
5063 function GlobalParseFloat(a){
5064 a=((typeof(%IS_VAR(a))==='string')?a:NonStringToString(a));
5065 if(%_HasCachedArrayIndex(a))return %_GetCachedArrayIndex(a);
5066 return %StringParseFloat(a);
5068 function GlobalEval(a){
5069 if(!(typeof(a)==='string'))return a;
5070 var b=%GlobalProxy(global);
5071 var c=%CompileString(a,false);
5072 if(!(%_IsFunction(c)))return c;
5073 return %_CallFunction(b,c);
5075 function SetUpGlobal(){
5076 %CheckIsBootstrapping();
5078 %AddNamedProperty(global,"NaN",$NaN,a);
5079 %AddNamedProperty(global,"Infinity",(1/0),a);
5080 %AddNamedProperty(global,"undefined",(void 0),a);
5081 InstallFunctions(global,2,[
5082 "isNaN",GlobalIsNaN,
5083 "isFinite",GlobalIsFinite,
5084 "parseInt",GlobalParseInt,
5085 "parseFloat",GlobalParseFloat,
5090 function NoSideEffectsObjectToString(){
5091 if((this===(void 0))&&!(%_IsUndetectableObject(this)))return"[object Undefined]";
5092 if((this===null))return"[object Null]";
5093 return"[object "+%_ClassOf(((%_IsSpecObject(%IS_VAR(this)))?this:ToObject(this)))+"]";
5095 function ObjectToString(){
5096 if((this===(void 0))&&!(%_IsUndetectableObject(this)))return"[object Undefined]";
5097 if((this===null))return"[object Null]";
5098 var a=((%_IsSpecObject(%IS_VAR(this)))?this:ToObject(this));
5101 if(harmony_tostring){
5102 var c=a[symbolToStringTag];
5103 if(!(typeof(c)==='string')){
5109 return`[object ${c}]`;
5111 function ObjectToLocaleString(){
5112 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Object.prototype.toLocaleString"]);
5113 return this.toString();
5115 function ObjectValueOf(){
5116 return((%_IsSpecObject(%IS_VAR(this)))?this:ToObject(this));
5118 function ObjectHasOwnProperty(a){
5119 if(%_IsJSProxy(this)){
5120 if((typeof(a)==='symbol'))return false;
5121 var b=%GetHandler(this);
5122 return CallTrap1(b,"hasOwn",$proxyDerivedHasOwnTrap,ToName(a));
5124 return %HasOwnProperty(((%_IsSpecObject(%IS_VAR(this)))?this:ToObject(this)),ToName(a));
5126 function ObjectIsPrototypeOf(a){
5127 if(!(%_IsSpecObject(a)))return false;
5128 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Object.prototype.isPrototypeOf"]);
5129 return %IsInPrototypeChain(this,a);
5131 function ObjectPropertyIsEnumerable(a){
5133 if(%_IsJSProxy(this)){
5134 if((typeof(a)==='symbol'))return false;
5135 var c=GetOwnPropertyJS(this,b);
5136 return(c===(void 0))?false:c.isEnumerable();
5138 return %IsPropertyEnumerable(((%_IsSpecObject(%IS_VAR(this)))?this:ToObject(this)),b);
5140 function ObjectDefineGetter(a,b){
5142 if(c==null&&!(%_IsUndetectableObject(c))){
5143 c=%GlobalProxy(global);
5145 if(!(%_ClassOf(b)==='Function')){
5146 throw MakeTypeError(16);
5148 var d=new PropertyDescriptor();
5150 d.setEnumerable(true);
5151 d.setConfigurable(true);
5152 DefineOwnProperty(((%_IsSpecObject(%IS_VAR(c)))?c:ToObject(c)),ToName(a),d,false);
5154 function ObjectLookupGetter(a){
5156 if(b==null&&!(%_IsUndetectableObject(b))){
5157 b=%GlobalProxy(global);
5159 return %LookupAccessor(((%_IsSpecObject(%IS_VAR(b)))?b:ToObject(b)),ToName(a),0);
5161 function ObjectDefineSetter(a,b){
5163 if(c==null&&!(%_IsUndetectableObject(c))){
5164 c=%GlobalProxy(global);
5166 if(!(%_ClassOf(b)==='Function')){
5167 throw MakeTypeError(18);
5169 var d=new PropertyDescriptor();
5171 d.setEnumerable(true);
5172 d.setConfigurable(true);
5173 DefineOwnProperty(((%_IsSpecObject(%IS_VAR(c)))?c:ToObject(c)),ToName(a),d,false);
5175 function ObjectLookupSetter(a){
5177 if(b==null&&!(%_IsUndetectableObject(b))){
5178 b=%GlobalProxy(global);
5180 return %LookupAccessor(((%_IsSpecObject(%IS_VAR(b)))?b:ToObject(b)),ToName(a),1);
5182 function ObjectKeys(a){
5183 a=((%_IsSpecObject(%IS_VAR(a)))?a:ToObject(a));
5185 var b=%GetHandler(a);
5186 var c=CallTrap0(b,"keys",$proxyDerivedKeysTrap);
5187 return ToNameArray(c,"keys",false);
5191 function IsAccessorDescriptor(a){
5192 if((a===(void 0)))return false;
5193 return a.hasGetter()||a.hasSetter();
5195 function IsDataDescriptor(a){
5196 if((a===(void 0)))return false;
5197 return a.hasValue()||a.hasWritable();
5199 function IsGenericDescriptor(a){
5200 if((a===(void 0)))return false;
5201 return!(IsAccessorDescriptor(a)||IsDataDescriptor(a));
5203 function IsInconsistentDescriptor(a){
5204 return IsAccessorDescriptor(a)&&IsDataDescriptor(a);
5206 function FromPropertyDescriptor(a){
5207 if((a===(void 0)))return a;
5208 if(IsDataDescriptor(a)){
5209 return{value:a.getValue(),
5210 writable:a.isWritable(),
5211 enumerable:a.isEnumerable(),
5212 configurable:a.isConfigurable()};
5214 return{get:a.getGet(),
5216 enumerable:a.isEnumerable(),
5217 configurable:a.isConfigurable()};
5219 function FromGenericPropertyDescriptor(a){
5220 if((a===(void 0)))return a;
5221 var b=new $Object();
5223 %AddNamedProperty(b,"value",a.getValue(),0);
5225 if(a.hasWritable()){
5226 %AddNamedProperty(b,"writable",a.isWritable(),0);
5229 %AddNamedProperty(b,"get",a.getGet(),0);
5232 %AddNamedProperty(b,"set",a.getSet(),0);
5234 if(a.hasEnumerable()){
5235 %AddNamedProperty(b,"enumerable",a.isEnumerable(),0);
5237 if(a.hasConfigurable()){
5238 %AddNamedProperty(b,"configurable",a.isConfigurable(),0);
5242 function ToPropertyDescriptor(a){
5243 if(!(%_IsSpecObject(a)))throw MakeTypeError(20,a);
5244 var b=new PropertyDescriptor();
5245 if("enumerable"in a){
5246 b.setEnumerable(ToBoolean(a.enumerable));
5248 if("configurable"in a){
5249 b.setConfigurable(ToBoolean(a.configurable));
5252 b.setValue(a.value);
5255 b.setWritable(ToBoolean(a.writable));
5259 if(!(c===(void 0))&&!(%_ClassOf(c)==='Function')){
5260 throw MakeTypeError(17,c);
5266 if(!(d===(void 0))&&!(%_ClassOf(d)==='Function')){
5267 throw MakeTypeError(19,d);
5271 if(IsInconsistentDescriptor(b)){
5272 throw MakeTypeError(34,a);
5276 function ToCompletePropertyDescriptor(a){
5277 var b=ToPropertyDescriptor(a);
5278 if(IsGenericDescriptor(b)||IsDataDescriptor(b)){
5279 if(!b.hasValue())b.setValue((void 0));
5280 if(!b.hasWritable())b.setWritable(false);
5282 if(!b.hasGetter())b.setGet((void 0));
5283 if(!b.hasSetter())b.setSet((void 0));
5285 if(!b.hasEnumerable())b.setEnumerable(false);
5286 if(!b.hasConfigurable())b.setConfigurable(false);
5289 function PropertyDescriptor(){
5290 this.value_=(void 0);
5291 this.hasValue_=false;
5292 this.writable_=false;
5293 this.hasWritable_=false;
5294 this.enumerable_=false;
5295 this.hasEnumerable_=false;
5296 this.configurable_=false;
5297 this.hasConfigurable_=false;
5299 this.hasGetter_=false;
5301 this.hasSetter_=false;
5303 SetUpLockedPrototype(PropertyDescriptor,[
5317 "toString",function PropertyDescriptor_ToString(){
5318 return"[object PropertyDescriptor]";
5320 "setValue",function PropertyDescriptor_SetValue(a){
5322 this.hasValue_=true;
5324 "getValue",function PropertyDescriptor_GetValue(){
5327 "hasValue",function PropertyDescriptor_HasValue(){
5328 return this.hasValue_;
5330 "setEnumerable",function PropertyDescriptor_SetEnumerable(a){
5332 this.hasEnumerable_=true;
5334 "isEnumerable",function PropertyDescriptor_IsEnumerable(){
5335 return this.enumerable_;
5337 "hasEnumerable",function PropertyDescriptor_HasEnumerable(){
5338 return this.hasEnumerable_;
5340 "setWritable",function PropertyDescriptor_SetWritable(a){
5342 this.hasWritable_=true;
5344 "isWritable",function PropertyDescriptor_IsWritable(){
5345 return this.writable_;
5347 "hasWritable",function PropertyDescriptor_HasWritable(){
5348 return this.hasWritable_;
5351 function PropertyDescriptor_SetConfigurable(a){
5352 this.configurable_=a;
5353 this.hasConfigurable_=true;
5355 "hasConfigurable",function PropertyDescriptor_HasConfigurable(){
5356 return this.hasConfigurable_;
5358 "isConfigurable",function PropertyDescriptor_IsConfigurable(){
5359 return this.configurable_;
5361 "setGet",function PropertyDescriptor_SetGetter(a){
5363 this.hasGetter_=true;
5365 "getGet",function PropertyDescriptor_GetGetter(){
5368 "hasGetter",function PropertyDescriptor_HasGetter(){
5369 return this.hasGetter_;
5371 "setSet",function PropertyDescriptor_SetSetter(a){
5373 this.hasSetter_=true;
5375 "getSet",function PropertyDescriptor_GetSetter(){
5378 "hasSetter",function PropertyDescriptor_HasSetter(){
5379 return this.hasSetter_;
5382 function ConvertDescriptorArrayToDescriptor(a){
5386 var b=new PropertyDescriptor();
5392 b.setWritable(a[4]);
5394 b.setEnumerable(a[5]);
5395 b.setConfigurable(a[6]);
5398 function GetTrap(a,b,c){
5402 throw MakeTypeError(24,a,b);
5405 }else if(!(%_ClassOf(d)==='Function')){
5406 throw MakeTypeError(25,a,b);
5410 function CallTrap0(a,b,c){
5411 return %_CallFunction(a,GetTrap(a,b,c));
5413 function CallTrap1(a,b,c,d){
5414 return %_CallFunction(a,d,GetTrap(a,b,c));
5416 function CallTrap2(a,b,c,d,e){
5417 return %_CallFunction(a,d,e,GetTrap(a,b,c));
5419 function GetOwnPropertyJS(a,b){
5422 if((typeof(b)==='symbol'))return(void 0);
5423 var d=%GetHandler(a);
5425 d,"getOwnPropertyDescriptor",(void 0),c);
5426 if((e===(void 0)))return e;
5427 var g=ToCompletePropertyDescriptor(e);
5428 if(!g.isConfigurable()){
5429 throw MakeTypeError(28,
5430 d,c,"getOwnPropertyDescriptor");
5434 var h=%GetOwnProperty(((%_IsSpecObject(%IS_VAR(a)))?a:ToObject(a)),c);
5435 return ConvertDescriptorArrayToDescriptor(h);
5437 function Delete(a,b,c){
5438 var d=GetOwnPropertyJS(a,b);
5439 if((d===(void 0)))return true;
5440 if(d.isConfigurable()){
5441 %DeleteProperty(a,b,0);
5444 throw MakeTypeError(5,b);
5449 function GetMethod(a,b){
5451 if((c==null))return(void 0);
5452 if((%_ClassOf(c)==='Function'))return c;
5453 throw MakeTypeError(2,typeof c);
5455 function DefineProxyProperty(a,b,c,d){
5456 if((typeof(b)==='symbol'))return false;
5457 var e=%GetHandler(a);
5458 var g=CallTrap2(e,"defineProperty",(void 0),b,c);
5461 throw MakeTypeError(23,
5462 e,"false","defineProperty");
5469 function DefineObjectProperty(a,b,c,d){
5470 var e=%GetOwnProperty(a,ToName(b));
5471 var g=ConvertDescriptorArrayToDescriptor(e);
5472 var h=%IsExtensible(a);
5473 if((g===(void 0))&&!h){
5475 throw MakeTypeError(5,b);
5480 if(!(g===(void 0))){
5481 if((IsGenericDescriptor(c)||
5482 IsDataDescriptor(c)==IsDataDescriptor(g))&&
5483 (!c.hasEnumerable()||
5484 SameValue(c.isEnumerable(),g.isEnumerable()))&&
5485 (!c.hasConfigurable()||
5486 SameValue(c.isConfigurable(),g.isConfigurable()))&&
5488 SameValue(c.isWritable(),g.isWritable()))&&
5490 SameValue(c.getValue(),g.getValue()))&&
5492 SameValue(c.getGet(),g.getGet()))&&
5494 SameValue(c.getSet(),g.getSet()))){
5497 if(!g.isConfigurable()){
5498 if(c.isConfigurable()||
5499 (c.hasEnumerable()&&
5500 c.isEnumerable()!=g.isEnumerable())){
5502 throw MakeTypeError(29,b);
5507 if(!IsGenericDescriptor(c)){
5508 if(IsDataDescriptor(g)!=IsDataDescriptor(c)){
5510 throw MakeTypeError(29,b);
5515 if(IsDataDescriptor(g)&&IsDataDescriptor(c)){
5516 if(!g.isWritable()&&c.isWritable()){
5518 throw MakeTypeError(29,b);
5523 if(!g.isWritable()&&c.hasValue()&&
5524 !SameValue(c.getValue(),g.getValue())){
5526 throw MakeTypeError(29,b);
5532 if(IsAccessorDescriptor(c)&&IsAccessorDescriptor(g)){
5533 if(c.hasSetter()&&!SameValue(c.getSet(),g.getSet())){
5535 throw MakeTypeError(29,b);
5540 if(c.hasGetter()&&!SameValue(c.getGet(),g.getGet())){
5542 throw MakeTypeError(29,b);
5552 if(c.hasEnumerable()){
5553 i|=c.isEnumerable()?0:2;
5554 }else if(!(g===(void 0))){
5555 i|=g.isEnumerable()?0:2;
5559 if(c.hasConfigurable()){
5560 i|=c.isConfigurable()?0:4;
5561 }else if(!(g===(void 0))){
5562 i|=g.isConfigurable()?0:4;
5565 if(IsDataDescriptor(c)||
5566 (IsGenericDescriptor(c)&&
5567 ((g===(void 0))||IsDataDescriptor(g)))){
5568 if(c.hasWritable()){
5569 i|=c.isWritable()?0:1;
5570 }else if(!(g===(void 0))){
5571 i|=g.isWritable()?0:1;
5578 }else if(!(g===(void 0))&&IsDataDescriptor(g)){
5581 %DefineDataPropertyUnchecked(a,b,j,i);
5586 }else if(IsAccessorDescriptor(g)&&g.hasGetter()){
5592 }else if(IsAccessorDescriptor(g)&&g.hasSetter()){
5595 %DefineAccessorPropertyUnchecked(a,b,k,l,i);
5599 function DefineArrayProperty(a,b,c,d){
5604 return DefineObjectProperty(a,"length",c,d);
5606 var h=ToUint32(c.getValue());
5607 if(h!=ToNumber(c.getValue())){
5608 throw MakeRangeError(37);
5610 var i=GetOwnPropertyJS(a,"length");
5611 if(h!=e&&!i.isWritable()){
5613 throw MakeTypeError(29,b);
5619 var k=%IsObserved(a)&&h!==g;
5622 $observeBeginPerformSplice(a);
5630 var n=GetOwnPropertyJS(a,m);
5632 l[e-h]=n.getValue();
5634 if(!Delete(a,m,false)){
5640 j=!DefineObjectProperty(a,"length",c,d)||j;
5642 $observeEndPerformSplice(a);
5643 $observeEnqueueSpliceRecord(a,
5650 throw MakeTypeError(29,b);
5657 if(!(typeof(b)==='symbol')){
5660 if(ToString(m)==b&&m!=4294967295){
5662 if(m>=e&&%IsObserved(a)){
5664 $observeBeginPerformSplice(a);
5666 var i=GetOwnPropertyJS(a,"length");
5667 if((m>=e&&!i.isWritable())||
5668 !DefineObjectProperty(a,b,c,true)){
5670 $observeEndPerformSplice(a);
5672 throw MakeTypeError(5,b);
5681 $observeEndPerformSplice(a);
5682 $observeEnqueueSpliceRecord(a,e,[],m+1-e);
5687 return DefineObjectProperty(a,b,c,d);
5689 function DefineOwnProperty(a,b,c,d){
5691 if((typeof(b)==='symbol'))return false;
5692 var e=FromGenericPropertyDescriptor(c);
5693 return DefineProxyProperty(a,b,e,d);
5694 }else if((%_IsArray(a))){
5695 return DefineArrayProperty(a,b,c,d);
5697 return DefineObjectProperty(a,b,c,d);
5700 function ObjectGetPrototypeOf(a){
5701 return %_GetPrototype(((%_IsSpecObject(%IS_VAR(a)))?a:ToObject(a)));
5703 function ObjectSetPrototypeOf(a,b){
5704 if((a==null)&&!(%_IsUndetectableObject(a)))throw MakeTypeError('called_on_null_or_undefined',["Object.setPrototypeOf"]);
5705 if(b!==null&&!(%_IsSpecObject(b))){
5706 throw MakeTypeError(22,b);
5708 if((%_IsSpecObject(a))){
5713 function ObjectGetOwnPropertyDescriptor(a,b){
5714 var c=GetOwnPropertyJS(((%_IsSpecObject(%IS_VAR(a)))?a:ToObject(a)),b);
5715 return FromPropertyDescriptor(c);
5717 function ToNameArray(a,b,c){
5718 if(!(%_IsSpecObject(a))){
5719 throw MakeTypeError(26,b,a);
5721 var d=ToUint32(a.length);
5722 var e=new $Array(d);
5724 var h={__proto__:null};
5725 for(var i=0;i<d;i++){
5727 if((typeof(j)==='symbol')&&!c)continue;
5728 if(%HasOwnProperty(h,j)){
5729 throw MakeTypeError(27,b,j);
5738 function ObjectGetOwnPropertyKeys(a,b){
5739 var c=new InternalArray();
5741 var d=%GetInterceptorInfo(a);
5743 var e=%GetOwnElementNames(a);
5744 for(var g=0;g<e.length;++g){
5745 e[g]=%_NumberToString(e[g]);
5749 var h=%GetIndexedInterceptorElementNames(a);
5750 if(!(h===(void 0))){
5755 c.push(%GetOwnPropertyNames(a,b));
5758 %GetNamedInterceptorPropertyNames(a);
5759 if(!(i===(void 0))){
5764 %Apply(InternalArray.prototype.concat,
5765 c[0],c,1,c.length-1);
5767 var k={__proto__:null};
5769 for(var g=0;g<j.length;++g){
5771 if((typeof(m)==='symbol')){
5772 if((b&16)||(%SymbolIsPrivate(m))){
5787 function ObjectGetOwnPropertyNames(a){
5788 a=((%_IsSpecObject(%IS_VAR(a)))?a:ToObject(a));
5790 var b=%GetHandler(a);
5791 var c=CallTrap0(b,"getOwnPropertyNames",(void 0));
5792 return ToNameArray(c,"getOwnPropertyNames",false);
5794 return ObjectGetOwnPropertyKeys(a,16);
5796 function ObjectCreate(a,b){
5797 if(!(%_IsSpecObject(a))&&a!==null){
5798 throw MakeTypeError(22,a);
5801 %InternalSetPrototype(c,a);
5802 if(!(b===(void 0)))ObjectDefineProperties(c,b);
5805 function ObjectDefineProperty(a,b,c){
5806 if(!(%_IsSpecObject(a))){
5807 throw MakeTypeError(3,"Object.defineProperty");
5811 var e={__proto__:null};
5815 DefineProxyProperty(a,d,e,true);
5817 var h=ToPropertyDescriptor(c);
5818 DefineOwnProperty(a,d,h,true);
5822 function GetOwnEnumerablePropertyNames(a){
5823 var b=new InternalArray();
5825 if(%HasOwnProperty(a,c)){
5830 var e=%GetOwnPropertyNames(a,d);
5831 for(var g=0;g<e.length;++g){
5833 if((typeof(h)==='symbol')){
5834 var i=ObjectGetOwnPropertyDescriptor(a,h);
5835 if(i.enumerable)b.push(h);
5840 function ObjectDefineProperties(a,b){
5841 if(!(%_IsSpecObject(a))){
5842 throw MakeTypeError(3,"Object.defineProperties");
5844 var c=((%_IsSpecObject(%IS_VAR(b)))?b:ToObject(b));
5845 var d=GetOwnEnumerablePropertyNames(c);
5846 var e=new InternalArray();
5847 for(var g=0;g<d.length;g++){
5848 e.push(ToPropertyDescriptor(c[d[g]]));
5850 for(var g=0;g<d.length;g++){
5851 DefineOwnProperty(a,d[g],e[g],true);
5855 function ProxyFix(a){
5856 var b=%GetHandler(a);
5857 var c=CallTrap0(b,"fix",(void 0));
5859 throw MakeTypeError(23,b,"undefined","fix");
5861 if(%IsJSFunctionProxy(a)){
5862 var d=%GetCallTrap(a);
5863 var e=%GetConstructTrap(a);
5864 var g=$proxyDelegateCallAndConstruct(d,e);
5867 var h=new $Object();
5868 $Object.defineProperty(h,"constructor",
5869 {value:a,writable:true,enumerable:false,configurable:true});
5870 %FunctionSetPrototype(a,h);
5875 ObjectDefineProperties(a,c);
5877 function ObjectSealJS(a){
5878 if(!(%_IsSpecObject(a))){
5879 throw MakeTypeError(3,"Object.seal");
5881 var b=%_IsJSProxy(a);
5882 if(b||%HasSloppyArgumentsElements(a)||%IsObserved(a)){
5886 var c=ObjectGetOwnPropertyNames(a);
5887 for(var d=0;d<c.length;d++){
5889 var g=GetOwnPropertyJS(a,e);
5890 if(g.isConfigurable()){
5891 g.setConfigurable(false);
5892 DefineOwnProperty(a,e,g,true);
5895 %PreventExtensions(a);
5901 function ObjectFreezeJS(a){
5902 if(!(%_IsSpecObject(a))){
5903 throw MakeTypeError(3,"Object.freeze");
5905 var b=%_IsJSProxy(a);
5906 if(b||%HasSloppyArgumentsElements(a)||%IsObserved(a)){
5910 var c=ObjectGetOwnPropertyNames(a);
5911 for(var d=0;d<c.length;d++){
5913 var g=GetOwnPropertyJS(a,e);
5914 if(g.isWritable()||g.isConfigurable()){
5915 if(IsDataDescriptor(g))g.setWritable(false);
5916 g.setConfigurable(false);
5917 DefineOwnProperty(a,e,g,true);
5920 %PreventExtensions(a);
5926 function ObjectPreventExtension(a){
5927 if(!(%_IsSpecObject(a))){
5928 throw MakeTypeError(3,"Object.preventExtension");
5933 %PreventExtensions(a);
5936 function ObjectIsSealed(a){
5937 if(!(%_IsSpecObject(a))){
5938 throw MakeTypeError(3,"Object.isSealed");
5943 if(%IsExtensible(a)){
5946 var b=ObjectGetOwnPropertyNames(a);
5947 for(var c=0;c<b.length;c++){
5949 var e=GetOwnPropertyJS(a,d);
5950 if(e.isConfigurable()){
5956 function ObjectIsFrozen(a){
5957 if(!(%_IsSpecObject(a))){
5958 throw MakeTypeError(3,"Object.isFrozen");
5963 if(%IsExtensible(a)){
5966 var b=ObjectGetOwnPropertyNames(a);
5967 for(var c=0;c<b.length;c++){
5969 var e=GetOwnPropertyJS(a,d);
5970 if(IsDataDescriptor(e)&&e.isWritable())return false;
5971 if(e.isConfigurable())return false;
5975 function ObjectIsExtensible(a){
5976 if(!(%_IsSpecObject(a))){
5977 throw MakeTypeError(3,"Object.isExtensible");
5982 return %IsExtensible(a);
5984 function ObjectIs(a,b){
5985 return SameValue(a,b);
5987 function ObjectGetProto(){
5988 return %_GetPrototype(((%_IsSpecObject(%IS_VAR(this)))?this:ToObject(this)));
5990 function ObjectSetProto(a){
5991 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Object.prototype.__proto__"]);
5992 if(((%_IsSpecObject(a))||(a===null))&&(%_IsSpecObject(this))){
5993 %SetPrototype(this,a);
5996 function ObjectConstructor(a){
5997 if(%_IsConstructCall()){
5998 if(a==null)return this;
5999 return((%_IsSpecObject(%IS_VAR(a)))?a:ToObject(a));
6001 if(a==null)return{};
6002 return((%_IsSpecObject(%IS_VAR(a)))?a:ToObject(a));
6005 function SetUpObject(){
6006 %CheckIsBootstrapping();
6007 %SetNativeFlag($Object);
6008 %SetCode($Object,ObjectConstructor);
6009 %AddNamedProperty($Object.prototype,"constructor",$Object,2);
6010 InstallFunctions($Object.prototype,2,[
6011 "toString",ObjectToString,
6012 "toLocaleString",ObjectToLocaleString,
6013 "valueOf",ObjectValueOf,
6014 "hasOwnProperty",ObjectHasOwnProperty,
6015 "isPrototypeOf",ObjectIsPrototypeOf,
6016 "propertyIsEnumerable",ObjectPropertyIsEnumerable,
6017 "__defineGetter__",ObjectDefineGetter,
6018 "__lookupGetter__",ObjectLookupGetter,
6019 "__defineSetter__",ObjectDefineSetter,
6020 "__lookupSetter__",ObjectLookupSetter
6022 InstallGetterSetter($Object.prototype,"__proto__",
6023 ObjectGetProto,ObjectSetProto);
6024 InstallFunctions($Object,2,[
6026 "create",ObjectCreate,
6027 "defineProperty",ObjectDefineProperty,
6028 "defineProperties",ObjectDefineProperties,
6029 "freeze",ObjectFreezeJS,
6030 "getPrototypeOf",ObjectGetPrototypeOf,
6031 "setPrototypeOf",ObjectSetPrototypeOf,
6032 "getOwnPropertyDescriptor",ObjectGetOwnPropertyDescriptor,
6033 "getOwnPropertyNames",ObjectGetOwnPropertyNames,
6035 "isExtensible",ObjectIsExtensible,
6036 "isFrozen",ObjectIsFrozen,
6037 "isSealed",ObjectIsSealed,
6038 "preventExtensions",ObjectPreventExtension,
6043 function BooleanConstructor(a){
6044 if(%_IsConstructCall()){
6045 %_SetValueOf(this,ToBoolean(a));
6047 return ToBoolean(a);
6050 function BooleanToString(){
6052 if(!(typeof(a)==='boolean')){
6053 if(!(%_ClassOf(a)==='Boolean')){
6054 throw MakeTypeError(14,'Boolean.prototype.toString');
6058 return a?'true':'false';
6060 function BooleanValueOf(){
6061 if(!(typeof(this)==='boolean')&&!(%_ClassOf(this)==='Boolean')){
6062 throw MakeTypeError(14,'Boolean.prototype.valueOf');
6064 return %_ValueOf(this);
6066 function SetUpBoolean(){
6067 %CheckIsBootstrapping();
6068 %SetCode($Boolean,BooleanConstructor);
6069 %FunctionSetPrototype($Boolean,new $Boolean(false));
6070 %AddNamedProperty($Boolean.prototype,"constructor",$Boolean,2);
6071 InstallFunctions($Boolean.prototype,2,[
6072 "toString",BooleanToString,
6073 "valueOf",BooleanValueOf
6077 function NumberConstructor(a){
6078 var b=%_ArgumentsLength()==0?0:ToNumber(a);
6079 if(%_IsConstructCall()){
6080 %_SetValueOf(this,b);
6085 function NumberToStringJS(a){
6087 if(!(typeof(this)==='number')){
6088 if(!(%_ClassOf(this)==='Number')){
6089 throw MakeTypeError(14,'Number.prototype.toString');
6093 if((a===(void 0))||a===10){
6094 return %_NumberToString(b);
6096 a=(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a)));
6098 throw new $RangeError('toString() radix argument must be between 2 and 36');
6100 return %NumberToRadixString(b,a);
6102 function NumberToLocaleString(){
6103 return %_CallFunction(this,NumberToStringJS);
6105 function NumberValueOf(){
6106 if(!(typeof(this)==='number')&&!(%_ClassOf(this)==='Number')){
6107 throw MakeTypeError(14,'Number.prototype.valueOf');
6109 return %_ValueOf(this);
6111 function NumberToFixedJS(a){
6113 if(!(typeof(this)==='number')){
6114 if(!(%_ClassOf(this)==='Number')){
6115 throw MakeTypeError(8,
6116 "Number.prototype.toFixed",this);
6120 var c=(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a)));
6122 throw MakeRangeError(38,"toFixed() digits");
6124 if((!%_IsSmi(%IS_VAR(b))&&!(b==b)))return"NaN";
6125 if(b==(1/0))return"Infinity";
6126 if(b==-(1/0))return"-Infinity";
6127 return %NumberToFixed(b,c);
6129 function NumberToExponentialJS(a){
6131 if(!(typeof(this)==='number')){
6132 if(!(%_ClassOf(this)==='Number')){
6133 throw MakeTypeError(8,
6134 "Number.prototype.toExponential",this);
6138 var c=(a===(void 0))?(void 0):(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a)));
6139 if((!%_IsSmi(%IS_VAR(b))&&!(b==b)))return"NaN";
6140 if(b==(1/0))return"Infinity";
6141 if(b==-(1/0))return"-Infinity";
6144 }else if(c<0||c>20){
6145 throw MakeRangeError(38,"toExponential()");
6147 return %NumberToExponential(b,c);
6149 function NumberToPrecisionJS(a){
6151 if(!(typeof(this)==='number')){
6152 if(!(%_ClassOf(this)==='Number')){
6153 throw MakeTypeError(8,
6154 "Number.prototype.toPrecision",this);
6158 if((a===(void 0)))return ToString(%_ValueOf(this));
6159 var c=(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a)));
6160 if((!%_IsSmi(%IS_VAR(b))&&!(b==b)))return"NaN";
6161 if(b==(1/0))return"Infinity";
6162 if(b==-(1/0))return"-Infinity";
6164 throw MakeRangeError(40);
6166 return %NumberToPrecision(b,c);
6168 function NumberIsFinite(a){
6169 return(typeof(a)==='number')&&(%_IsSmi(%IS_VAR(a))||((a==a)&&(a!=1/0)&&(a!=-1/0)));
6171 function NumberIsInteger(a){
6172 return NumberIsFinite(a)&&(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a)))==a;
6174 function NumberIsNaN(a){
6175 return(typeof(a)==='number')&&(!%_IsSmi(%IS_VAR(a))&&!(a==a));
6177 function NumberIsSafeInteger(a){
6178 if(NumberIsFinite(a)){
6179 var b=(%_IsSmi(%IS_VAR(a))?a:%NumberToInteger(ToNumber(a)));
6180 if(b==a)return $abs(b)<=$Number.MAX_SAFE_INTEGER;
6184 function SetUpNumber(){
6185 %CheckIsBootstrapping();
6186 %SetCode($Number,NumberConstructor);
6187 %FunctionSetPrototype($Number,new $Number(0));
6188 %OptimizeObjectForAddingMultipleProperties($Number.prototype,8);
6189 %AddNamedProperty($Number.prototype,"constructor",$Number,2);
6190 InstallConstants($Number,[
6191 "MAX_VALUE",1.7976931348623157e+308,
6194 "NEGATIVE_INFINITY",-(1/0),
6195 "POSITIVE_INFINITY",(1/0),
6196 "MAX_SAFE_INTEGER",%_MathPow(2,53)-1,
6197 "MIN_SAFE_INTEGER",-%_MathPow(2,53)+1,
6198 "EPSILON",%_MathPow(2,-52)
6200 InstallFunctions($Number.prototype,2,[
6201 "toString",NumberToStringJS,
6202 "toLocaleString",NumberToLocaleString,
6203 "valueOf",NumberValueOf,
6204 "toFixed",NumberToFixedJS,
6205 "toExponential",NumberToExponentialJS,
6206 "toPrecision",NumberToPrecisionJS
6208 InstallFunctions($Number,2,[
6209 "isFinite",NumberIsFinite,
6210 "isInteger",NumberIsInteger,
6211 "isNaN",NumberIsNaN,
6212 "isSafeInteger",NumberIsSafeInteger,
6213 "parseInt",GlobalParseInt,
6214 "parseFloat",GlobalParseFloat
6216 %SetInlineBuiltinFlag(NumberIsNaN);
6219 function FunctionSourceString(a){
6220 while(%IsJSFunctionProxy(a)){
6223 if(!(%_IsFunction(a))){
6224 throw MakeTypeError(14,'Function.prototype.toString');
6226 var b=%ClassGetSourceCode(a);
6227 if((typeof(b)==='string')){
6230 var c=%FunctionGetSourceCode(a);
6231 if(!(typeof(c)==='string')||%FunctionIsBuiltin(a)){
6232 var d=%FunctionGetName(a);
6234 return'function '+d+'() { [native code] }';
6236 return'function () { [native code] }';
6239 if(%FunctionIsArrow(a)){
6242 var d=%FunctionNameShouldPrintAsAnonymous(a)
6244 :%FunctionGetName(a);
6245 var e=%FunctionIsGenerator(a);
6246 var g=%FunctionIsConciseMethod(a)
6248 :(e?'function* ':'function ');
6251 function FunctionToString(){
6252 return FunctionSourceString(this);
6254 function FunctionBind(a){
6255 if(!(%_ClassOf(this)==='Function'))throw MakeTypeError(7);
6258 if(%_IsConstructCall()){
6259 return %NewObjectFromBound(b);
6261 var c=%BoundFunctionGetBindings(b);
6262 var d=%_ArgumentsLength();
6264 return %Apply(c[0],c[1],c,2,c.length-2);
6267 return %Apply(c[0],c[1],arguments,0,d);
6270 var g=new InternalArray(e+d);
6271 for(var h=0;h<e;h++){
6274 for(var i=0;i<d;i++){
6275 g[h++]=%_Arguments(i);
6277 return %Apply(c[0],c[1],g,0,e+d);
6281 if((typeof k==="number")&&
6283 var d=%_ArgumentsLength();
6288 var l=%FunctionBindArguments(b,this,
6292 function NewFunctionString(a,b){
6297 for(var e=1;e<c-1;e++){
6298 d+=','+ToString(a[e]);
6300 if(%_CallFunction(d,')',$stringIndexOf)!=-1){
6301 throw MakeSyntaxError(41);
6305 var g=(c>0)?ToString(a[c-1]):'';
6306 return'('+b+'('+d+') {\n'+g+'\n})';
6308 function FunctionConstructor(a){
6309 var b=NewFunctionString(arguments,'function');
6310 var c=%GlobalProxy(global);
6311 var d=%_CallFunction(c,%CompileString(b,true));
6312 %FunctionMarkNameShouldPrintAsAnonymous(d);
6315 function SetUpFunction(){
6316 %CheckIsBootstrapping();
6317 %SetCode($Function,FunctionConstructor);
6318 %AddNamedProperty($Function.prototype,"constructor",$Function,2);
6319 InstallFunctions($Function.prototype,2,[
6320 "bind",FunctionBind,
6321 "toString",FunctionToString
6325 function GetIterator(a,b){
6327 b=a[symbolIterator];
6329 if(!(%_ClassOf(b)==='Function')){
6330 throw MakeTypeError(15,a);
6332 var c=%_CallFunction(a,b);
6333 if(!(%_IsSpecObject(c))){
6334 throw MakeTypeError(12,c);
6340 var $symbolToString;
6343 %CheckIsBootstrapping();
6344 var a=global.Object;
6345 var b=global.Symbol;
6346 function SymbolConstructor(c){
6347 if(%_IsConstructCall())throw MakeTypeError(13,"Symbol");
6348 return %CreateSymbol((c===(void 0))?c:ToString(c));
6350 function SymbolToString(){
6351 if(!((typeof(this)==='symbol')||(%_ClassOf(this)==='Symbol'))){
6352 throw MakeTypeError(8,
6353 "Symbol.prototype.toString",this);
6355 var d=%SymbolDescription(%_ValueOf(this));
6356 return"Symbol("+((d===(void 0))?"":d)+")";
6358 function SymbolValueOf(){
6359 if(!((typeof(this)==='symbol')||(%_ClassOf(this)==='Symbol'))){
6360 throw MakeTypeError(8,
6361 "Symbol.prototype.valueOf",this);
6363 return %_ValueOf(this);
6365 function SymbolFor(e){
6366 e=((typeof(%IS_VAR(e))==='string')?e:NonStringToString(e));
6367 var g=%SymbolRegistry();
6368 if((g.for[e]===(void 0))){
6369 var h=%CreateSymbol(e);
6375 function SymbolKeyFor(h){
6376 if(!(typeof(h)==='symbol'))throw MakeTypeError("not_a_symbol",[h]);
6377 return %SymbolRegistry().keyFor[h];
6379 function ObjectGetOwnPropertySymbols(i){
6381 return ObjectGetOwnPropertyKeys(i,8);
6383 %SetCode(b,SymbolConstructor);
6384 %FunctionSetPrototype(b,new a());
6385 InstallConstants(b,[
6386 "iterator",symbolIterator,
6387 "unscopables",symbolUnscopables
6389 InstallFunctions(b,2,[
6391 "keyFor",SymbolKeyFor
6394 b.prototype,"constructor",b,2);
6396 b.prototype,symbolToStringTag,"Symbol",2|1);
6397 InstallFunctions(b.prototype,2,[
6398 "toString",SymbolToString,
6399 "valueOf",SymbolValueOf
6401 InstallFunctions(a,2,[
6402 "getOwnPropertySymbols",ObjectGetOwnPropertySymbols
6404 $symbolToString=SymbolToString;
6418 %CheckIsBootstrapping();
6420 var b=new InternalArray();
6421 function GetSortedArrayKeys(c,d){
6422 var e=new InternalArray();
6423 if((typeof(d)==='number')){
6425 for(var h=0;h<g;++h){
6427 if(!(i===(void 0))||h in c){
6433 for(var k=0;k<j;++k){
6435 if(!(l===(void 0))){
6437 if(!(i===(void 0))||l in c){
6442 %_CallFunction(e,function(m,n){return m-n;},ArraySort);
6446 function SparseJoinWithSeparatorJS(c,o,q,r){
6447 var e=GetSortedArrayKeys(c,%GetArrayKeys(c,o));
6449 var u=new InternalArray(e.length*2);
6451 for(var h=0;h<e.length;h++){
6455 if(!(typeof(i)==='string'))i=q(i);
6461 return %SparseJoinWithSeparator(u,o,r);
6463 function SparseJoin(c,o,q){
6464 var e=GetSortedArrayKeys(c,%GetArrayKeys(c,o));
6467 var u=new InternalArray(A);
6469 for(var h=0;h<A;h++){
6473 if(!(typeof(i)==='string'))i=q(i);
6478 return %StringBuilderConcat(u,B,'');
6480 function UseSparseVariant(c,j,C,D){
6481 if(!C||j<1000||%IsObserved(c)||
6482 %HasComplexElements(c)){
6489 var G=%EstimateNumberOfElements(c);
6493 function Join(c,j,r,q){
6495 var C=(%_IsArray(c));
6497 if(!%PushIfAbsent(b,c))return'';
6500 if(UseSparseVariant(c,j,C,j)){
6501 %NormalizeElements(c);
6503 return SparseJoin(c,j,q);
6505 return SparseJoinWithSeparatorJS(c,j,q,r);
6510 if((typeof(i)==='string'))return i;
6513 var u=new InternalArray(j);
6516 for(var h=0;h<j;h++){
6518 if(!(typeof(i)==='string'))i=q(i);
6522 var H=%_FastOneByteArrayJoin(u,'');
6523 if(!(H===(void 0)))return H;
6524 return %StringBuilderConcat(u,B,'');
6526 if(!(typeof(c[0])==='number')){
6527 for(var h=0;h<j;h++){
6529 if(!(typeof(i)==='string'))i=q(i);
6533 for(var h=0;h<j;h++){
6535 if((typeof(i)==='number')){
6536 i=%_NumberToString(i);
6537 }else if(!(typeof(i)==='string')){
6543 var H=%_FastOneByteArrayJoin(u,r);
6544 if(!(H===(void 0)))return H;
6545 return %StringBuilderJoin(u,j,r);
6547 if(C)b.length=b.length-1;
6550 function ConvertToString(I){
6551 if((typeof(I)==='number'))return %_NumberToString(I);
6552 if((typeof(I)==='boolean'))return I?'true':'false';
6553 return((I==null))?'':%ToString(%DefaultString(I));
6555 function ConvertToLocaleString(i){
6560 return %ToString(J.toLocaleString());
6563 function SparseSlice(c,K,L,o,M){
6564 var d=%GetArrayKeys(c,K+L);
6565 if((typeof(d)==='number')){
6567 for(var h=K;h<g;++h){
6569 if(!(N===(void 0))||h in c){
6570 %AddElement(M,h-K,N,0);
6575 for(var k=0;k<j;++k){
6577 if(!(l===(void 0))){
6580 if(!(N===(void 0))||l in c){
6581 %AddElement(M,l-K,N,0);
6588 function SparseMove(c,K,L,o,P){
6590 var Q=new InternalArray(
6591 $min(o-L+P,0xffffffff));
6593 var d=%GetArrayKeys(c,o);
6594 if((typeof(d)==='number')){
6596 for(var h=0;h<K&&h<g;++h){
6598 if(!(N===(void 0))||h in c){
6602 for(var h=K+L;h<g;++h){
6604 if(!(N===(void 0))||h in c){
6610 for(var k=0;k<j;++k){
6612 if(!(l===(void 0))){
6615 if(!(N===(void 0))||l in c){
6620 if(!(N===(void 0))||l in c){
6624 R=R||new InternalArray();
6632 %MoveArrayContents(Q,c);
6633 if(!(R===(void 0))){
6635 for(var h=0;h<j;++h){
6641 function SimpleSlice(c,K,L,o,M){
6642 var C=(%_IsArray(c));
6643 for(var h=0;h<L;h++){
6645 if(((C&&%_HasFastPackedElements(%IS_VAR(c)))?(T<c.length):(T in c))){
6647 %AddElement(M,h,N,0);
6651 function SimpleMove(c,K,L,o,P){
6652 var C=(%_IsArray(c));
6655 for(var h=o-L;h>K;h--){
6658 if(((C&&%_HasFastPackedElements(%IS_VAR(c)))?(U<c.length):(U in c))){
6665 for(var h=K;h<o-L;h++){
6668 if(((C&&%_HasFastPackedElements(%IS_VAR(c)))?(U<c.length):(U in c))){
6674 for(var h=o;h>o-L+P;h--){
6680 function ArrayToString(){
6683 if((%_IsArray(this))){
6686 return Join(this,this.length,',',ConvertToString);
6693 if(!(%_ClassOf(X)==='Function')){
6694 return %_CallFunction(c,ObjectToString);
6696 return %_CallFunction(c,X);
6698 function ArrayToLocaleString(){
6699 var c=ToObject(this);
6703 return Join(c,o,',',ConvertToLocaleString);
6705 function ArrayJoin(r){
6706 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Array.prototype.join"]);
6707 var c=((%_IsSpecObject(%IS_VAR(this)))?this:ToObject(this));
6708 var j=(c.length>>>0);
6711 }else if(!(typeof(r)==='string')){
6712 r=NonStringToString(r);
6714 var H=%_FastOneByteArrayJoin(c,r);
6715 if(!(H===(void 0)))return H;
6718 if((typeof(i)==='string'))return i;
6719 if((i==null))return'';
6720 return NonStringToString(i);
6722 return Join(c,j,r,ConvertToString);
6724 function ObservedArrayPop(Z){
6728 $observeBeginPerformSplice(this);
6732 $observeEndPerformSplice(this);
6733 $observeEnqueueSpliceRecord(this,Z,[aa],0);
6737 function ArrayPop(){
6738 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Array.prototype.pop"]);
6739 var c=((%_IsSpecObject(%IS_VAR(this)))?this:ToObject(this));
6740 var Z=(c.length>>>0);
6746 return ObservedArrayPop.call(c,Z);
6749 Delete(c,ToName(Z),true);
6753 function ObservedArrayPush(){
6754 var Z=(this.length>>>0);
6755 var ab=%_ArgumentsLength();
6757 $observeBeginPerformSplice(this);
6758 for(var h=0;h<ab;h++){
6759 this[h+Z]=%_Arguments(h);
6764 $observeEndPerformSplice(this);
6765 $observeEnqueueSpliceRecord(this,Z,[],ab);
6769 function ArrayPush(){
6770 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Array.prototype.push"]);
6771 if(%IsObserved(this))
6772 return ObservedArrayPush.apply(this,arguments);
6773 var c=((%_IsSpecObject(%IS_VAR(this)))?this:ToObject(this));
6774 var Z=(c.length>>>0);
6775 var ab=%_ArgumentsLength();
6776 for(var h=0;h<ab;h++){
6777 c[h+Z]=%_Arguments(h);
6783 function ArrayConcatJS(ad){
6784 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Array.prototype.concat"]);
6785 var c=ToObject(this);
6786 var ae=%_ArgumentsLength();
6787 var af=new InternalArray(1+ae);
6789 for(var h=0;h<ae;h++){
6790 af[h+1]=%_Arguments(h);
6792 return %ArrayConcat(af);
6794 function SparseReverse(c,o){
6795 var e=GetSortedArrayKeys(c,%GetArrayKeys(c,o));
6805 while(e[--ag]==ai){}
6814 if(!(am===(void 0))||ak in c){
6816 if(!(an===(void 0))||al in c){
6825 if(!(an===(void 0))||al in c){
6832 function ArrayReverse(){
6833 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Array.prototype.reverse"]);
6834 var c=((%_IsSpecObject(%IS_VAR(this)))?this:ToObject(this));
6835 var o=(c.length>>>0);
6836 if(UseSparseVariant(c,o,(%_IsArray(c)),o)){
6837 %NormalizeElements(c);
6842 for(var h=0;h<ai;h++,ai--){
6844 if(!(am===(void 0))||h in c){
6846 if(!(an===(void 0))||ai in c){
6855 if(!(an===(void 0))||ai in c){
6863 function ObservedArrayShift(o){
6866 $observeBeginPerformSplice(this);
6867 SimpleMove(this,0,1,o,0);
6870 $observeEndPerformSplice(this);
6871 $observeEnqueueSpliceRecord(this,0,[ao],0);
6875 function ArrayShift(){
6876 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Array.prototype.shift"]);
6877 var c=((%_IsSpecObject(%IS_VAR(this)))?this:ToObject(this));
6878 var o=(c.length>>>0);
6883 if(ObjectIsSealed(c)){
6884 throw MakeTypeError("array_functions_change_sealed",
6885 ["Array.prototype.shift"]);
6888 return ObservedArrayShift.call(c,o);
6890 if(UseSparseVariant(c,o,(%_IsArray(c)),o)){
6891 SparseMove(c,0,1,o,0);
6893 SimpleMove(c,0,1,o,0);
6898 function ObservedArrayUnshift(){
6899 var o=(this.length>>>0);
6900 var ap=%_ArgumentsLength();
6902 $observeBeginPerformSplice(this);
6903 SimpleMove(this,0,0,o,ap);
6904 for(var h=0;h<ap;h++){
6905 this[h]=%_Arguments(h);
6910 $observeEndPerformSplice(this);
6911 $observeEnqueueSpliceRecord(this,0,[],ap);
6915 function ArrayUnshift(ad){
6916 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Array.prototype.unshift"]);
6917 if(%IsObserved(this))
6918 return ObservedArrayUnshift.apply(this,arguments);
6919 var c=((%_IsSpecObject(%IS_VAR(this)))?this:ToObject(this));
6920 var o=(c.length>>>0);
6921 var ap=%_ArgumentsLength();
6922 if(o>0&&UseSparseVariant(c,o,(%_IsArray(c)),o)&&
6923 !ObjectIsSealed(c)){
6924 SparseMove(c,0,0,o,ap);
6926 SimpleMove(c,0,0,o,ap);
6928 for(var h=0;h<ap;h++){
6929 c[h]=%_Arguments(h);
6935 function ArraySlice(aq,ar){
6936 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Array.prototype.slice"]);
6937 var c=((%_IsSpecObject(%IS_VAR(this)))?this:ToObject(this));
6938 var o=(c.length>>>0);
6939 var K=(%_IsSmi(%IS_VAR(aq))?aq:%NumberToInteger(ToNumber(aq)));
6941 if(!(ar===(void 0)))as=(%_IsSmi(%IS_VAR(ar))?ar:%NumberToInteger(ToNumber(ar)));
6956 if(UseSparseVariant(c,o,(%_IsArray(c)),as-K)){
6957 %NormalizeElements(c);
6958 %NormalizeElements(H);
6959 SparseSlice(c,K,as-K,o,H);
6961 SimpleSlice(c,K,as-K,o,H);
6966 function ComputeSpliceStartIndex(K,o){
6973 function ComputeSpliceDeleteCount(at,ap,o,K){
6977 L=(%_IsSmi(%IS_VAR(at))?at:%NumberToInteger(ToNumber(at)));
6984 function ObservedArraySplice(aq,at){
6985 var ap=%_ArgumentsLength();
6986 var o=(this.length>>>0);
6987 var K=ComputeSpliceStartIndex((%_IsSmi(%IS_VAR(aq))?aq:%NumberToInteger(ToNumber(aq))),o);
6988 var L=ComputeSpliceDeleteCount(at,ap,o,
6994 $observeBeginPerformSplice(this);
6995 SimpleSlice(this,K,L,o,M);
6996 SimpleMove(this,K,L,o,au);
6999 var aw=%_ArgumentsLength();
7001 this[h++]=%_Arguments(av++);
7005 $observeEndPerformSplice(this);
7007 $observeEnqueueSpliceRecord(this,
7015 function ArraySplice(aq,at){
7016 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Array.prototype.splice"]);
7017 if(%IsObserved(this))
7018 return ObservedArraySplice.apply(this,arguments);
7019 var ap=%_ArgumentsLength();
7020 var c=((%_IsSpecObject(%IS_VAR(this)))?this:ToObject(this));
7021 var o=(c.length>>>0);
7022 var K=ComputeSpliceStartIndex((%_IsSmi(%IS_VAR(aq))?aq:%NumberToInteger(ToNumber(aq))),o);
7023 var L=ComputeSpliceDeleteCount(at,ap,o,
7028 if(L!=au&&ObjectIsSealed(c)){
7029 throw MakeTypeError("array_functions_change_sealed",
7030 ["Array.prototype.splice"]);
7031 }else if(L>0&&ObjectIsFrozen(c)){
7032 throw MakeTypeError("array_functions_on_frozen",
7033 ["Array.prototype.splice"]);
7039 if(UseSparseVariant(c,o,(%_IsArray(c)),ax)){
7040 %NormalizeElements(c);
7041 %NormalizeElements(M);
7042 SparseSlice(c,K,L,o,M);
7043 SparseMove(c,K,L,o,au);
7045 SimpleSlice(c,K,L,o,M);
7046 SimpleMove(c,K,L,o,au);
7050 var aw=%_ArgumentsLength();
7052 c[h++]=%_Arguments(av++);
7057 function ArraySort(ay){
7058 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Array.prototype.sort"]);
7059 if(!(%_ClassOf(ay)==='Function')){
7062 if(%_IsSmi(I)&&%_IsSmi(az)){
7063 return %SmiLexicographicCompare(I,az);
7068 else return I<az?-1:1;
7071 var aA=%GetDefaultReceiver(ay);
7072 var aB=function InsertionSort(m,aC,aD){
7073 for(var h=aC+1;h<aD;h++){
7075 for(var ai=h-1;ai>=aC;ai--){
7077 var aG=%_CallFunction(aA,aF,aE,ay);
7087 var aH=function(m,aC,aD){
7089 var aJ=200+((aD-aC)&15);
7090 for(var h=aC+1,ai=0;h<aD-1;h+=aJ,ai++){
7093 %_CallFunction(aI,function(m,n){
7094 return %_CallFunction(aA,m[1],n[1],ay);
7096 var aK=aI[aI.length>>1][0];
7099 var aL=function QuickSort(m,aC,aD){
7114 var aP=%_CallFunction(aA,aM,aN,ay);
7120 var aQ=%_CallFunction(aA,aM,aO,ay);
7127 var aR=%_CallFunction(aA,aN,aO,ay);
7141 partition:for(var h=aT+1;h<aU;h++){
7143 var aG=%_CallFunction(aA,aE,aS,ay);
7151 if(aU==h)break partition;
7153 aG=%_CallFunction(aA,aV,aS,ay);
7174 var aW=function CopyFromPrototype(aX,j){
7176 for(var aZ=%_GetPrototype(aX);aZ;aZ=%_GetPrototype(aZ)){
7177 var d=%GetArrayKeys(aZ,j);
7178 if((typeof(d)==='number')){
7180 for(var h=0;h<ba;h++){
7181 if(!(%_CallFunction(aX,h,ObjectHasOwnProperty))&&(%_CallFunction(aZ,h,ObjectHasOwnProperty))){
7187 for(var h=0;h<d.length;h++){
7189 if(!(T===(void 0))&&!(%_CallFunction(aX,T,ObjectHasOwnProperty))
7190 &&(%_CallFunction(aZ,T,ObjectHasOwnProperty))){
7199 var bb=function(aX,aC,aD){
7200 for(var aZ=%_GetPrototype(aX);aZ;aZ=%_GetPrototype(aZ)){
7201 var d=%GetArrayKeys(aZ,aD);
7202 if((typeof(d)==='number')){
7204 for(var h=aC;h<ba;h++){
7205 if((%_CallFunction(aZ,h,ObjectHasOwnProperty))){
7210 for(var h=0;h<d.length;h++){
7212 if(!(T===(void 0))&&aC<=T&&
7213 (%_CallFunction(aZ,T,ObjectHasOwnProperty))){
7220 var bc=function SafeRemoveArrayHoles(aX){
7226 !(aX[bd]===(void 0))){
7229 if(!(%_CallFunction(aX,bd,ObjectHasOwnProperty))){
7233 (aX[be]===(void 0))){
7234 if(!(%_CallFunction(aX,be,ObjectHasOwnProperty))){
7244 if(!(aX[bd]===(void 0)))bd++;
7246 for(h=bd;h<j-bf;h++){
7249 for(h=j-bf;h<j;h++){
7250 if(h in %_GetPrototype(aX)){
7258 var j=(this.length>>>0);
7260 var C=(%_IsArray(this));
7265 var bh=%RemoveArrayHoles(this,j);
7275 function ArrayFilter(bi,aA){
7276 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Array.prototype.filter"]);
7277 var c=ToObject(this);
7278 var j=ToUint32(c.length);
7279 if(!(%_ClassOf(bi)==='Function'))throw MakeTypeError(2,bi);
7282 aA=%GetDefaultReceiver(bi)||aA;
7284 bj=(!(%_IsSpecObject(aA))&&%IsSloppyModeFunction(bi));
7287 var bk=new InternalArray();
7289 var C=(%_IsArray(c));
7290 var bm=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(bi);
7291 for(var h=0;h<j;h++){
7292 if(((C&&%_HasFastPackedElements(%IS_VAR(c)))?(h<c.length):(h in c))){
7294 if(bm)%DebugPrepareStepInIfStepping(bi);
7295 var bn=bj?ToObject(aA):aA;
7296 if(%_CallFunction(bn,aE,h,c,bi)){
7301 %MoveArrayContents(bk,H);
7304 function ArrayForEach(bi,aA){
7305 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Array.prototype.forEach"]);
7306 var c=ToObject(this);
7307 var j=(c.length>>>0);
7308 if(!(%_ClassOf(bi)==='Function'))throw MakeTypeError(2,bi);
7311 aA=%GetDefaultReceiver(bi)||aA;
7313 bj=(!(%_IsSpecObject(aA))&&%IsSloppyModeFunction(bi));
7315 var C=(%_IsArray(c));
7316 var bm=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(bi);
7317 for(var h=0;h<j;h++){
7318 if(((C&&%_HasFastPackedElements(%IS_VAR(c)))?(h<c.length):(h in c))){
7320 if(bm)%DebugPrepareStepInIfStepping(bi);
7321 var bn=bj?ToObject(aA):aA;
7322 %_CallFunction(bn,aE,h,c,bi);
7326 function ArraySome(bi,aA){
7327 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Array.prototype.some"]);
7328 var c=ToObject(this);
7329 var j=(c.length>>>0);
7330 if(!(%_ClassOf(bi)==='Function'))throw MakeTypeError(2,bi);
7333 aA=%GetDefaultReceiver(bi)||aA;
7335 bj=(!(%_IsSpecObject(aA))&&%IsSloppyModeFunction(bi));
7337 var C=(%_IsArray(c));
7338 var bm=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(bi);
7339 for(var h=0;h<j;h++){
7340 if(((C&&%_HasFastPackedElements(%IS_VAR(c)))?(h<c.length):(h in c))){
7342 if(bm)%DebugPrepareStepInIfStepping(bi);
7343 var bn=bj?ToObject(aA):aA;
7344 if(%_CallFunction(bn,aE,h,c,bi))return true;
7349 function ArrayEvery(bi,aA){
7350 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Array.prototype.every"]);
7351 var c=ToObject(this);
7352 var j=(c.length>>>0);
7353 if(!(%_ClassOf(bi)==='Function'))throw MakeTypeError(2,bi);
7356 aA=%GetDefaultReceiver(bi)||aA;
7358 bj=(!(%_IsSpecObject(aA))&&%IsSloppyModeFunction(bi));
7360 var C=(%_IsArray(c));
7361 var bm=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(bi);
7362 for(var h=0;h<j;h++){
7363 if(((C&&%_HasFastPackedElements(%IS_VAR(c)))?(h<c.length):(h in c))){
7365 if(bm)%DebugPrepareStepInIfStepping(bi);
7366 var bn=bj?ToObject(aA):aA;
7367 if(!%_CallFunction(bn,aE,h,c,bi))return false;
7372 function ArrayMap(bi,aA){
7373 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Array.prototype.map"]);
7374 var c=ToObject(this);
7375 var j=(c.length>>>0);
7376 if(!(%_ClassOf(bi)==='Function'))throw MakeTypeError(2,bi);
7379 aA=%GetDefaultReceiver(bi)||aA;
7381 bj=(!(%_IsSpecObject(aA))&&%IsSloppyModeFunction(bi));
7384 var bk=new InternalArray(j);
7385 var C=(%_IsArray(c));
7386 var bm=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(bi);
7387 for(var h=0;h<j;h++){
7388 if(((C&&%_HasFastPackedElements(%IS_VAR(c)))?(h<c.length):(h in c))){
7390 if(bm)%DebugPrepareStepInIfStepping(bi);
7391 var bn=bj?ToObject(aA):aA;
7392 bk[h]=%_CallFunction(bn,aE,h,c,bi);
7395 %MoveArrayContents(bk,H);
7398 function ArrayIndexOf(aE,T){
7399 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Array.prototype.indexOf"]);
7400 var j=(this.length>>>0);
7405 T=(%_IsSmi(%IS_VAR(T))?T:%NumberToInteger(ToNumber(T)));
7413 if(UseSparseVariant(this,j,(%_IsArray(this)),aY-bo)){
7414 %NormalizeElements(this);
7415 var d=%GetArrayKeys(this,j);
7416 if((typeof(d)==='number')){
7419 if(d.length==0)return-1;
7420 var bp=GetSortedArrayKeys(this,d);
7423 while(h<Z&&bp[h]<T)h++;
7426 if(!(l===(void 0))&&this[l]===aE)return l;
7432 if(!(aE===(void 0))){
7433 for(var h=bo;h<aY;h++){
7434 if(this[h]===aE)return h;
7438 for(var h=bo;h<aY;h++){
7439 if((this[h]===(void 0))&&h in this){
7445 function ArrayLastIndexOf(aE,T){
7446 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Array.prototype.lastIndexOf"]);
7447 var j=(this.length>>>0);
7449 if(%_ArgumentsLength()<2){
7452 T=(%_IsSmi(%IS_VAR(T))?T:%NumberToInteger(ToNumber(T)));
7459 if(UseSparseVariant(this,j,(%_IsArray(this)),T)){
7460 %NormalizeElements(this);
7461 var d=%GetArrayKeys(this,T+1);
7462 if((typeof(d)==='number')){
7465 if(d.length==0)return-1;
7466 var bp=GetSortedArrayKeys(this,d);
7470 if(!(l===(void 0))&&this[l]===aE)return l;
7476 if(!(aE===(void 0))){
7477 for(var h=aY;h>=bo;h--){
7478 if(this[h]===aE)return h;
7482 for(var h=aY;h>=bo;h--){
7483 if((this[h]===(void 0))&&h in this){
7489 function ArrayReduce(bq,N){
7490 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Array.prototype.reduce"]);
7491 var c=ToObject(this);
7492 var j=ToUint32(c.length);
7493 if(!(%_ClassOf(bq)==='Function')){
7494 throw MakeTypeError(2,bq);
7496 var C=(%_IsArray(c));
7498 find_initial:if(%_ArgumentsLength()<2){
7500 if(((C&&%_HasFastPackedElements(%IS_VAR(c)))?(h<c.length):(h in c))){
7505 throw MakeTypeError('reduce_no_initial',[]);
7507 var aA=%GetDefaultReceiver(bq);
7508 var bm=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(bq);
7510 if(((C&&%_HasFastPackedElements(%IS_VAR(c)))?(h<c.length):(h in c))){
7512 if(bm)%DebugPrepareStepInIfStepping(bq);
7513 N=%_CallFunction(aA,N,aE,h,c,bq);
7518 function ArrayReduceRight(bq,N){
7519 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Array.prototype.reduceRight"]);
7520 var c=ToObject(this);
7521 var j=ToUint32(c.length);
7522 if(!(%_ClassOf(bq)==='Function')){
7523 throw MakeTypeError(2,bq);
7525 var C=(%_IsArray(c));
7527 find_initial:if(%_ArgumentsLength()<2){
7529 if(((C&&%_HasFastPackedElements(%IS_VAR(c)))?(h<c.length):(h in c))){
7534 throw MakeTypeError('reduce_no_initial',[]);
7536 var aA=%GetDefaultReceiver(bq);
7537 var bm=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(bq);
7539 if(((C&&%_HasFastPackedElements(%IS_VAR(c)))?(h<c.length):(h in c))){
7541 if(bm)%DebugPrepareStepInIfStepping(bq);
7542 N=%_CallFunction(aA,N,aE,h,c,bq);
7547 function ArrayIsArray(aX){
7548 return(%_IsArray(aX));
7550 %AddNamedProperty(a.prototype,"constructor",a,
7561 %AddNamedProperty(a.prototype,symbolUnscopables,br,
7563 InstallFunctions(a,2,[
7564 "isArray",ArrayIsArray
7566 var bs=%SpecialArrayFunctions();
7567 var bt=function(bu,bv,o){
7569 if(bs.hasOwnProperty(bu)){
7572 if(!(o===(void 0))){
7573 %FunctionSetLength(bi,o);
7577 InstallFunctions(a.prototype,2,[
7578 "toString",bt("toString",ArrayToString),
7579 "toLocaleString",bt("toLocaleString",ArrayToLocaleString),
7580 "join",bt("join",ArrayJoin),
7581 "pop",bt("pop",ArrayPop),
7582 "push",bt("push",ArrayPush,1),
7583 "concat",bt("concat",ArrayConcatJS,1),
7584 "reverse",bt("reverse",ArrayReverse),
7585 "shift",bt("shift",ArrayShift),
7586 "unshift",bt("unshift",ArrayUnshift,1),
7587 "slice",bt("slice",ArraySlice,2),
7588 "splice",bt("splice",ArraySplice,2),
7589 "sort",bt("sort",ArraySort),
7590 "filter",bt("filter",ArrayFilter,1),
7591 "forEach",bt("forEach",ArrayForEach,1),
7592 "some",bt("some",ArraySome,1),
7593 "every",bt("every",ArrayEvery,1),
7594 "map",bt("map",ArrayMap,1),
7595 "indexOf",bt("indexOf",ArrayIndexOf,1),
7596 "lastIndexOf",bt("lastIndexOf",ArrayLastIndexOf,1),
7597 "reduce",bt("reduce",ArrayReduce,1),
7598 "reduceRight",bt("reduceRight",ArrayReduceRight,1)
7600 %FinishArrayPrototypeSetup(a.prototype);
7601 SetUpLockedPrototype(InternalArray,a(),[
7602 "concat",bt("concat",ArrayConcatJS),
7603 "indexOf",bt("indexOf",ArrayIndexOf),
7604 "join",bt("join",ArrayJoin),
7605 "pop",bt("pop",ArrayPop),
7606 "push",bt("push",ArrayPush),
7607 "splice",bt("splice",ArraySplice)
7609 SetUpLockedPrototype(InternalPackedArray,a(),[
7610 "join",bt("join",ArrayJoin),
7611 "pop",bt("pop",ArrayPop),
7612 "push",bt("push",ArrayPush)
7614 $arrayConcat=ArrayConcatJS;
7615 $arrayJoin=ArrayJoin;
7616 $arrayPush=ArrayPush;
7618 $arrayShift=ArrayShift;
7619 $arraySlice=ArraySlice;
7620 $arraySplice=ArraySplice;
7621 $arrayUnshift=ArrayUnshift;
7627 var $stringSubstring;
7629 %CheckIsBootstrapping();
7630 var a=global.RegExp;
7631 var b=global.String;
7632 function StringConstructor(c){
7633 if(%_ArgumentsLength()==0)c='';
7634 if(%_IsConstructCall()){
7635 %_SetValueOf(this,((typeof(%IS_VAR(c))==='string')?c:NonStringToString(c)));
7637 return(typeof(c)==='symbol')?
7638 %_CallFunction(c,$symbolToString):((typeof(%IS_VAR(c))==='string')?c:NonStringToString(c));
7641 function StringToString(){
7642 if(!(typeof(this)==='string')&&!(%_ClassOf(this)==='String')){
7643 throw MakeTypeError(14,'String.prototype.toString');
7645 return %_ValueOf(this);
7647 function StringValueOf(){
7648 if(!(typeof(this)==='string')&&!(%_ClassOf(this)==='String')){
7649 throw MakeTypeError(14,'String.prototype.valueOf');
7651 return %_ValueOf(this);
7653 function StringCharAtJS(d){
7654 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.charAt"]);
7655 var e=%_StringCharAt(this,d);
7657 e=%_StringCharAt(((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)),(%_IsSmi(%IS_VAR(d))?d:%NumberToInteger(ToNumber(d))));
7661 function StringCharCodeAtJS(d){
7662 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.charCodeAt"]);
7663 var e=%_StringCharCodeAt(this,d);
7665 e=%_StringCharCodeAt(((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)),(%_IsSmi(%IS_VAR(d))?d:%NumberToInteger(ToNumber(d))));
7669 function StringConcat(g){
7670 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.concat"]);
7671 var h=%_ArgumentsLength();
7672 var i=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this));
7674 return i+((typeof(%IS_VAR(g))==='string')?g:NonStringToString(g));
7676 var j=new InternalArray(h+1);
7678 for(var k=0;k<h;k++){
7679 var l=%_Arguments(k);
7680 j[k+1]=((typeof(%IS_VAR(l))==='string')?l:NonStringToString(l));
7682 return %StringBuilderConcat(j,h+1,"");
7684 function StringIndexOfJS(m){
7685 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.indexOf"]);
7686 var n=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this));
7687 m=((typeof(%IS_VAR(m))==='string')?m:NonStringToString(m));
7689 if(%_ArgumentsLength()>1){
7691 o=(%_IsSmi(%IS_VAR(o))?o:%NumberToInteger(ToNumber(o)));
7693 if(o>n.length)o=n.length;
7695 return %StringIndexOf(n,m,o);
7697 function StringLastIndexOfJS(q){
7698 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.lastIndexOf"]);
7699 var r=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this));
7701 var q=((typeof(%IS_VAR(q))==='string')?q:NonStringToString(q));
7704 if(%_ArgumentsLength()>1){
7705 var w=ToNumber(%_Arguments(1));
7706 if(!(!%_IsSmi(%IS_VAR(w))&&!(w==w))){
7707 w=(%_IsSmi(%IS_VAR(w))?w:%NumberToInteger(ToNumber(w)));
7719 return %StringLastIndexOf(r,q,o);
7721 function StringLocaleCompareJS(g){
7722 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.localeCompare"]);
7723 return %StringLocaleCompare(((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)),
7724 ((typeof(%IS_VAR(g))==='string')?g:NonStringToString(g)));
7726 function StringMatchJS(z){
7727 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.match"]);
7728 var n=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this));
7729 if((%_IsRegExp(z))){
7731 (%_IsSmi(%IS_VAR(A))?A:ToNumber(A));
7732 if(!z.global)return $regexpExecNoTests(z,n,0);
7733 var e=%StringMatch(n,z,$regexpLastMatchInfo);
7734 if(e!==null)$regexpLastMatchInfoOverride=null;
7739 return $regexpExecNoTests(z,n,0);
7741 var B=['NFC','NFD','NFKC','NFKD'];
7742 function StringNormalizeJS(C){
7743 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.normalize"]);
7744 var C=C?((typeof(%IS_VAR(C))==='string')?C:NonStringToString(C)):'NFC';
7747 throw new $RangeError('The normalization form should be one of '
7750 return %_ValueOf(this);
7752 var E=[2,"","",-1,-1];
7753 function StringReplace(G,H){
7754 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.replace"]);
7755 var n=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this));
7756 if((%_IsRegExp(G))){
7758 (%_IsSmi(%IS_VAR(A))?A:ToNumber(A));
7759 if(!(%_ClassOf(H)==='Function')){
7760 H=((typeof(%IS_VAR(H))==='string')?H:NonStringToString(H));
7762 var I=$regexpExec(G,n,0);
7768 return %_SubString(n,0,I[3])+
7769 %_SubString(n,I[4],n.length)
7771 return ExpandReplacement(H,n,$regexpLastMatchInfo,
7772 %_SubString(n,0,I[3]))+
7773 %_SubString(n,I[4],n.length);
7776 if($regexpLastMatchInfoOverride==null){
7777 return %StringReplaceGlobalRegExpWithString(
7778 n,G,H,$regexpLastMatchInfo);
7780 var J=$regexpLastMatchInfo[1];
7781 $regexpLastMatchInfo[1]=0;
7782 var K=%StringReplaceGlobalRegExpWithString(
7783 n,G,H,$regexpLastMatchInfo);
7784 if(%_IsSmi($regexpLastMatchInfo[1])){
7785 $regexpLastMatchInfo[1]=J;
7787 $regexpLastMatchInfoOverride=null;
7793 return StringReplaceGlobalRegExpWithFunction(n,G,H);
7795 return StringReplaceNonGlobalRegExpWithFunction(n,G,H);
7797 G=((typeof(%IS_VAR(G))==='string')?G:NonStringToString(G));
7800 (typeof(H)==='string')&&
7801 %StringIndexOf(H,'$',0)<0){
7802 return %StringReplaceOneCharWithString(n,G,H);
7804 var L=%StringIndexOf(n,G,0);
7807 var e=%_SubString(n,0,L);
7808 if((%_ClassOf(H)==='Function')){
7809 var N=%GetDefaultReceiver(H);
7810 e+=%_CallFunction(N,G,L,n,H);
7814 e=ExpandReplacement(((typeof(%IS_VAR(H))==='string')?H:NonStringToString(H)),
7819 return e+%_SubString(n,M,n.length);
7821 function ExpandReplacement(P,n,Q,e){
7823 var S=%StringIndexOf(P,'$',0);
7828 if(S>0)e+=%_SubString(P,0,S);
7833 var U=%_StringCharCodeAt(P,w);
7840 %_SubString(n,Q[3],Q[4]);
7843 e+=%_SubString(n,0,Q[3]);
7846 e+=%_SubString(n,Q[4],n.length);
7847 }else if(U>=48&&U<=57){
7852 var S=%_StringCharCodeAt(P,w+1);
7854 var Z=W*10+((S-48)<<1);
7865 %_SubString(n,L,Q[(3+(W+1))]);
7877 S=%StringIndexOf(P,'$',w);
7880 e+=%_SubString(P,w,R);
7885 e+=%_SubString(P,w,S);
7890 function CaptureString(P,aa,o){
7894 var M=aa[(3+(ab+1))];
7895 return %_SubString(P,L,M);
7897 var ac=new InternalArray(16);
7898 function StringReplaceGlobalRegExpWithFunction(n,z,H){
7903 ad=new InternalArray(16);
7905 var ae=%RegExpExecMultiple(z,
7907 $regexpLastMatchInfo,
7915 if((($regexpLastMatchInfo)[0])==2){
7917 var ag=new InternalPackedArray(null,0,n);
7918 var N=%GetDefaultReceiver(H);
7919 for(var k=0;k<h;k++){
7923 af=(ah>>11)+(ah&0x7ff);
7930 $regexpLastMatchInfoOverride=ag;
7932 %_CallFunction(N,ah,af,n,H);
7933 ae[k]=((typeof(%IS_VAR(ai))==='string')?ai:NonStringToString(ai));
7938 var N=%GetDefaultReceiver(H);
7939 for(var k=0;k<h;k++){
7942 $regexpLastMatchInfoOverride=ah;
7943 var ai=%Apply(H,N,ah,0,ah.length);
7944 ae[k]=((typeof(%IS_VAR(ai))==='string')?ai:NonStringToString(ai));
7948 var e=%StringBuilderConcat(ae,ae.length,n);
7953 function StringReplaceNonGlobalRegExpWithFunction(n,z,H){
7954 var Q=$regexpExec(z,n,0);
7960 var e=%_SubString(n,0,o);
7964 var N=%GetDefaultReceiver(H);
7966 var am=%_SubString(n,o,aj);
7967 al=%_CallFunction(N,am,o,n,H);
7969 var an=new InternalArray(ak+2);
7970 for(var ao=0;ao<ak;ao++){
7971 an[ao]=CaptureString(n,Q,ao);
7975 al=%Apply(H,N,an,0,ao+2);
7978 return e+%_SubString(n,aj,n.length);
7980 function StringSearch(ap){
7981 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.search"]);
7983 if((typeof(ap)==='string')){
7984 z=%_GetFromCache(0,ap);
7985 }else if((%_IsRegExp(ap))){
7990 var I=$regexpExec(z,((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)),0);
7996 function StringSlice(L,M){
7997 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.slice"]);
7998 var am=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this));
8000 var ar=(%_IsSmi(%IS_VAR(L))?L:%NumberToInteger(ToNumber(L)));
8002 if(!(M===(void 0))){
8003 as=(%_IsSmi(%IS_VAR(M))?M:%NumberToInteger(ToNumber(M)));
8028 return %_SubString(am,ar,as);
8030 function StringSplitJS(at,au){
8031 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.split"]);
8032 var n=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this));
8033 au=((au===(void 0)))?0xffffffff:(au>>>0);
8035 if(!(%_IsRegExp(at))){
8036 var av=((typeof(%IS_VAR(at))==='string')?at:NonStringToString(at));
8038 if((at===(void 0)))return[n];
8040 if(aw===0)return %StringToArray(n,au);
8041 var e=%StringSplit(n,av,au);
8045 return StringSplitOnRegExp(n,at,au,R);
8047 function StringSplitOnRegExp(n,at,au,R){
8049 if($regexpExec(at,n,0,0)!=null){
8057 var e=new InternalArray();
8061 e[e.length]=%_SubString(n,ax,R);
8064 var Q=$regexpExec(at,n,ay);
8065 if(Q==null||R===(az=Q[3])){
8066 e[e.length]=%_SubString(n,ax,R);
8070 if(ay===aA&&aA===ax){
8074 e[e.length]=%_SubString(n,ax,az);
8075 if(e.length===au)break;
8077 for(var k=3+2;k<aB;){
8081 e[e.length]=%_SubString(n,L,M);
8083 e[e.length]=(void 0);
8085 if(e.length===au)break outer_loop;
8090 %MoveArrayContents(e,aC);
8093 function StringSubstring(L,M){
8094 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.subString"]);
8095 var am=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this));
8097 var ar=(%_IsSmi(%IS_VAR(L))?L:%NumberToInteger(ToNumber(L)));
8104 if(!(M===(void 0))){
8105 as=(%_IsSmi(%IS_VAR(M))?M:%NumberToInteger(ToNumber(M)));
8117 return %_SubString(am,ar,as);
8119 function StringSubstr(L,aE){
8120 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.substr"]);
8121 var am=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this));
8123 if((aE===(void 0))){
8126 h=(%_IsSmi(%IS_VAR(aE))?aE:%NumberToInteger(ToNumber(aE)));
8132 L=(%_IsSmi(%IS_VAR(L))?L:%NumberToInteger(ToNumber(L)));
8133 if(L>=am.length)return'';
8140 if(M>am.length)M=am.length;
8141 return %_SubString(am,L,M);
8143 function StringToLowerCaseJS(){
8144 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.toLowerCase"]);
8145 return %StringToLowerCase(((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)));
8147 function StringToLocaleLowerCase(){
8148 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.toLocaleLowerCase"]);
8149 return %StringToLowerCase(((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)));
8151 function StringToUpperCaseJS(){
8152 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.toUpperCase"]);
8153 return %StringToUpperCase(((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)));
8155 function StringToLocaleUpperCase(){
8156 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.toLocaleUpperCase"]);
8157 return %StringToUpperCase(((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)));
8159 function StringTrimJS(){
8160 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.trim"]);
8161 return %StringTrim(((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)),true,true);
8163 function StringTrimLeft(){
8164 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.trimLeft"]);
8165 return %StringTrim(((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)),true,false);
8167 function StringTrimRight(){
8168 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.trimRight"]);
8169 return %StringTrim(((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this)),false,true);
8171 function StringFromCharCode(aF){
8172 var aE=%_ArgumentsLength();
8174 if(!%_IsSmi(aF))aF=ToNumber(aF);
8175 return %_StringCharFromCode(aF&0xffff);
8177 var aG=%NewString(aE,true);
8180 var aF=%_Arguments(k);
8181 if(!%_IsSmi(aF))aF=ToNumber(aF)&0xffff;
8182 if(aF<0)aF=aF&0xffff;
8184 %_OneByteSeqStringSetChar(k,aF,aG);
8187 aG=%TruncateString(aG,k);
8188 var aH=%NewString(aE-k,false);
8189 for(var ao=0;k<aE;k++,ao++){
8190 var aF=%_Arguments(k);
8191 if(!%_IsSmi(aF))aF=ToNumber(aF)&0xffff;
8192 %_TwoByteSeqStringSetChar(ao,aF,aH);
8196 function HtmlEscape(aI){
8197 return((typeof(%IS_VAR(aI))==='string')?aI:NonStringToString(aI)).replace(/"/g,""");
8199 function StringAnchor(aJ){
8200 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.anchor"]);
8201 return"<a name=\""+HtmlEscape(aJ)+"\">"+this+"</a>";
8203 function StringBig(){
8204 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.big"]);
8205 return"<big>"+this+"</big>";
8207 function StringBlink(){
8208 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.blink"]);
8209 return"<blink>"+this+"</blink>";
8211 function StringBold(){
8212 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.bold"]);
8213 return"<b>"+this+"</b>";
8215 function StringFixed(){
8216 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.fixed"]);
8217 return"<tt>"+this+"</tt>";
8219 function StringFontcolor(aK){
8220 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.fontcolor"]);
8221 return"<font color=\""+HtmlEscape(aK)+"\">"+this+"</font>";
8223 function StringFontsize(aL){
8224 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.fontsize"]);
8225 return"<font size=\""+HtmlEscape(aL)+"\">"+this+"</font>";
8227 function StringItalics(){
8228 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.italics"]);
8229 return"<i>"+this+"</i>";
8231 function StringLink(am){
8232 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.link"]);
8233 return"<a href=\""+HtmlEscape(am)+"\">"+this+"</a>";
8235 function StringSmall(){
8236 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.small"]);
8237 return"<small>"+this+"</small>";
8239 function StringStrike(){
8240 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.strike"]);
8241 return"<strike>"+this+"</strike>";
8243 function StringSub(){
8244 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.sub"]);
8245 return"<sub>"+this+"</sub>";
8247 function StringSup(){
8248 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.sup"]);
8249 return"<sup>"+this+"</sup>";
8251 function StringRepeat(aM){
8252 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.repeat"]);
8253 var am=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this));
8254 var aE=ToInteger(aM);
8255 if(aE<0||aE>%_MaxSmi()){
8256 throw MakeRangeError("invalid_count_value",[]);
8262 if(aE===0)return aN;
8266 function StringStartsWith(aO){
8267 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.startsWith"]);
8268 var am=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this));
8269 if((%_IsRegExp(aO))){
8270 throw MakeTypeError("first_argument_not_regexp",
8271 ["String.prototype.startsWith"]);
8273 var aP=((typeof(%IS_VAR(aO))==='string')?aO:NonStringToString(aO));
8275 if(%_ArgumentsLength()>1){
8280 var L=$min($max(d,0),aq);
8285 return %StringIndexOf(am,aP,L)===L;
8287 function StringEndsWith(aO){
8288 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.endsWith"]);
8289 var am=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this));
8290 if((%_IsRegExp(aO))){
8291 throw MakeTypeError("first_argument_not_regexp",
8292 ["String.prototype.endsWith"]);
8294 var aP=((typeof(%IS_VAR(aO))==='string')?aO:NonStringToString(aO));
8297 if(%_ArgumentsLength()>1){
8298 var aR=%_Arguments(1);
8299 if(!(aR===(void 0))){
8303 var M=$min($max(d,0),aq);
8309 return %StringLastIndexOf(am,aP,L)===L;
8311 function StringIncludes(aO){
8312 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.includes"]);
8313 var am=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this));
8314 if((%_IsRegExp(aO))){
8315 throw MakeTypeError("first_argument_not_regexp",
8316 ["String.prototype.includes"]);
8318 var aP=((typeof(%IS_VAR(aO))==='string')?aO:NonStringToString(aO));
8320 if(%_ArgumentsLength()>1){
8325 var L=$min($max(d,0),aq);
8330 return %StringIndexOf(am,aP,L)!==-1;
8332 function StringCodePointAt(d){
8333 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.codePointAt"]);
8334 var P=((typeof(%IS_VAR(this))==='string')?this:NonStringToString(this));
8336 d=(%_IsSmi(%IS_VAR(d))?d:%NumberToInteger(ToNumber(d)));
8340 var aS=%_StringCharCodeAt(P,d);
8341 if(aS<0xD800||aS>0xDBFF||d+1==aL){
8344 var aT=%_StringCharCodeAt(P,d+1);
8345 if(aT<0xDC00||aT>0xDFFF){
8348 return(aS-0xD800)*0x400+aT+0x2400;
8350 function StringFromCodePoint(aU){
8352 var R=%_ArgumentsLength();
8360 if(aF<0||aF>0x10FFFF||aF!==(%_IsSmi(%IS_VAR(aF))?aF:%NumberToInteger(ToNumber(aF)))){
8361 throw MakeRangeError("invalid_code_point",[aF]);
8364 e+=%_StringCharFromCode(aF);
8367 e+=%_StringCharFromCode((aF>>>10)&0x3FF|0xD800);
8368 e+=%_StringCharFromCode(aF&0x3FF|0xDC00);
8373 function StringRaw(aV){
8374 var aW=%_ArgumentsLength();
8375 var aX=ToObject(aV);
8376 var aY=ToObject(aX.raw);
8377 var aZ=ToLength(aY.length);
8379 var e=ToString(aY[0]);
8380 for(var k=1;k<aZ;++k){
8382 e+=ToString(%_Arguments(k));
8388 %SetCode(b,StringConstructor);
8389 %FunctionSetPrototype(b,new b());
8391 b.prototype,"constructor",b,2);
8392 InstallFunctions(b,2,[
8393 "fromCharCode",StringFromCharCode,
8394 "fromCodePoint",StringFromCodePoint,
8397 InstallFunctions(b.prototype,2,[
8398 "valueOf",StringValueOf,
8399 "toString",StringToString,
8400 "charAt",StringCharAtJS,
8401 "charCodeAt",StringCharCodeAtJS,
8402 "codePointAt",StringCodePointAt,
8403 "concat",StringConcat,
8404 "endsWith",StringEndsWith,
8405 "includes",StringIncludes,
8406 "indexOf",StringIndexOfJS,
8407 "lastIndexOf",StringLastIndexOfJS,
8408 "localeCompare",StringLocaleCompareJS,
8409 "match",StringMatchJS,
8410 "normalize",StringNormalizeJS,
8411 "repeat",StringRepeat,
8412 "replace",StringReplace,
8413 "search",StringSearch,
8414 "slice",StringSlice,
8415 "split",StringSplitJS,
8416 "substring",StringSubstring,
8417 "substr",StringSubstr,
8418 "startsWith",StringStartsWith,
8419 "toLowerCase",StringToLowerCaseJS,
8420 "toLocaleLowerCase",StringToLocaleLowerCase,
8421 "toUpperCase",StringToUpperCaseJS,
8422 "toLocaleUpperCase",StringToLocaleUpperCase,
8423 "trim",StringTrimJS,
8424 "trimLeft",StringTrimLeft,
8425 "trimRight",StringTrimRight,
8427 "anchor",StringAnchor,
8428 "fontcolor",StringFontcolor,
8429 "fontsize",StringFontsize,
8431 "blink",StringBlink,
8433 "fixed",StringFixed,
8434 "italics",StringItalics,
8435 "small",StringSmall,
8436 "strike",StringStrike,
8440 $stringCharAt=StringCharAtJS;
8441 $stringIndexOf=StringIndexOfJS;
8442 $stringSubstring=StringSubstring;
8448 %CheckIsBootstrapping();
8449 var a=global.Object;
8451 function HexValueOf(c){
8452 if(c>=48&&c<=57)return c-48;
8453 if(c>=65&&c<=70)return c-55;
8454 if(c>=97&&c<=102)return c-87;
8457 function isAlphaNumeric(d){
8458 if(97<=d&&d<=122)return true;
8459 if(65<=d&&d<=90)return true;
8460 if(48<=d&&d<=57)return true;
8464 function URIAddEncodedOctetToBuffer(g,h,i){
8470 function URIEncodeOctets(j,h,i){
8472 e=[48,49,50,51,52,53,54,55,56,57,
8475 i=URIAddEncodedOctetToBuffer(j[0],h,i);
8476 if(j[1])i=URIAddEncodedOctetToBuffer(j[1],h,i);
8477 if(j[2])i=URIAddEncodedOctetToBuffer(j[2],h,i);
8478 if(j[3])i=URIAddEncodedOctetToBuffer(j[3],h,i);
8481 function URIEncodeSingle(d,h,i){
8488 }else if(d<=0x07FF){
8496 return URIEncodeOctets(j,h,i);
8498 function URIEncodePair(n,o,h,i){
8499 var q=((n>>6)&0xF)+1;
8506 j[1]=(((q&3)<<4)|r)+128;
8507 j[2]=((k<<4)|l)+128;
8509 return URIEncodeOctets(j,h,i);
8511 function URIHexCharsToCharCode(t,u){
8512 var w=HexValueOf(t);
8513 var z=HexValueOf(u);
8515 throw new $URIError("URI malformed");
8519 function URIDecodeOctets(j,h,i){
8525 throw new $URIError("URI malformed");
8530 if((C<0x80)||(C>0xbf)){
8531 throw new $URIError("URI malformed");
8535 if(A<0x80||A>0x7ff){
8536 throw new $URIError("URI malformed");
8542 if((C<0x80)||(C>0xbf)){
8543 throw new $URIError("URI malformed");
8546 if((G<0x80)||(G>0xbf)){
8547 throw new $URIError("URI malformed");
8551 if((A<0x800)||(A>0xffff)){
8552 throw new $URIError("URI malformed");
8558 if((C<0x80)||(C>0xbf)){
8559 throw new $URIError("URI malformed");
8562 if((G<0x80)||(G>0xbf)){
8563 throw new $URIError("URI malformed");
8566 if((I<0x80)||(I>0xbf)){
8567 throw new $URIError("URI malformed");
8570 A=(D<<18)+(E<<12)+(H<<6)+J;
8571 if((A<0x10000)||(A>0x10ffff)){
8572 throw new $URIError("URI malformed");
8575 throw new $URIError("URI malformed");
8580 if(0xD800<=A&&A<=0xDFFF){
8581 throw new $URIError("URI malformed");
8584 %_TwoByteSeqStringSetChar(i++,A,h);
8586 %_TwoByteSeqStringSetChar(i++,(A>>10)+0xd7c0,h);
8587 %_TwoByteSeqStringSetChar(i++,(A&0x3ff)+0xdc00,h);
8591 function Encode(K,L){
8593 var N=new InternalArray(M);
8595 for(var P=0;P<M;P++){
8596 var n=K.charCodeAt(P);
8600 if(n>=0xDC00&&n<=0xDFFF)throw new $URIError("URI malformed");
8601 if(n<0xD800||n>0xDBFF){
8602 i=URIEncodeSingle(n,N,i);
8605 if(P==M)throw new $URIError("URI malformed");
8606 var o=K.charCodeAt(P);
8607 if(o<0xDC00||o>0xDFFF)throw new $URIError("URI malformed");
8608 i=URIEncodePair(n,o,N,i);
8612 var h=%NewString(N.length,true);
8613 for(var Q=0;Q<N.length;Q++){
8614 %_OneByteSeqStringSetChar(Q,N[Q],h);
8618 function Decode(K,R){
8620 var S=%NewString(M,true);
8624 var c=K.charCodeAt(P);
8626 if(P+2>=M)throw new $URIError("URI malformed");
8627 var d=URIHexCharsToCharCode(K.charCodeAt(P+1),K.charCodeAt(P+2));
8630 %_OneByteSeqStringSetChar(i++,37,S);
8631 %_OneByteSeqStringSetChar(i++,K.charCodeAt(P+1),S);
8632 %_OneByteSeqStringSetChar(i++,K.charCodeAt(P+2),S);
8634 %_OneByteSeqStringSetChar(i++,d,S);
8639 %_OneByteSeqStringSetChar(i++,c,S);
8642 S=%TruncateString(S,i);
8644 var T=%NewString(M-P,false);
8647 var c=K.charCodeAt(P);
8649 if(P+2>=M)throw new $URIError("URI malformed");
8650 var d=URIHexCharsToCharCode(K.charCodeAt(++P),K.charCodeAt(++P));
8653 while(((d<<++U)&0x80)!=0){}
8654 if(U==1||U>4)throw new $URIError("URI malformed");
8657 if(P+3*(U-1)>=M)throw new $URIError("URI malformed");
8658 for(var Q=1;Q<U;Q++){
8659 if(K.charAt(++P)!='%')throw new $URIError("URI malformed");
8660 j[Q]=URIHexCharsToCharCode(K.charCodeAt(++P),
8663 i=URIDecodeOctets(j,T,i);
8665 %_TwoByteSeqStringSetChar(i++,37,T);
8666 %_TwoByteSeqStringSetChar(i++,K.charCodeAt(P-1),T);
8667 %_TwoByteSeqStringSetChar(i++,K.charCodeAt(P),T);
8669 %_TwoByteSeqStringSetChar(i++,d,T);
8672 %_TwoByteSeqStringSetChar(i++,c,T);
8675 T=%TruncateString(T,i);
8678 function URIEscapeJS(W){
8680 return %URIEscape(X);
8682 function URIUnescapeJS(W){
8684 return %URIUnescape(X);
8686 function URIDecode(K){
8688 if(35<=d&&d<=36)return true;
8689 if(d==38)return true;
8690 if(43<=d&&d<=44)return true;
8691 if(d==47)return true;
8692 if(58<=d&&d<=59)return true;
8693 if(d==61)return true;
8694 if(63<=d&&d<=64)return true;
8700 function URIDecodeComponent(aa){
8701 var Y=function(d){return false;};
8705 function URIEncode(K){
8707 if(isAlphaNumeric(d))return true;
8708 if(d==33)return true;
8709 if(35<=d&&d<=36)return true;
8710 if(38<=d&&d<=47)return true;
8711 if(58<=d&&d<=59)return true;
8712 if(d==61)return true;
8713 if(63<=d&&d<=64)return true;
8714 if(d==95)return true;
8715 if(d==126)return true;
8719 return Encode(Z,ab);
8721 function URIEncodeComponent(aa){
8723 if(isAlphaNumeric(d))return true;
8724 if(d==33)return true;
8725 if(39<=d&&d<=42)return true;
8726 if(45<=d&&d<=46)return true;
8727 if(d==95)return true;
8728 if(d==126)return true;
8732 return Encode(Z,ab);
8734 InstallFunctions(global,2,[
8735 "escape",URIEscapeJS,
8736 "unescape",URIUnescapeJS,
8737 "decodeURI",URIDecode,
8738 "decodeURIComponent",URIDecodeComponent,
8739 "encodeURI",URIEncode,
8740 "encodeURIComponent",URIEncodeComponent
8753 %CheckIsBootstrapping();
8754 var a=global.Object;
8755 function MathAbs(b){
8759 function MathAcosJS(b){
8760 return %_MathAcos(+b);
8762 function MathAsinJS(b){
8763 return %_MathAsin(+b);
8765 function MathAtanJS(b){
8766 return %_MathAtan(+b);
8768 function MathAtan2JS(c,b){
8771 return %_MathAtan2(c,b);
8773 function MathCeil(b){
8774 return-%_MathFloor(-b);
8776 function MathExp(b){
8777 return %MathExpRT(((typeof(%IS_VAR(b))==='number')?b:NonNumberToNumber(b)));
8779 function MathFloorJS(b){
8780 return %_MathFloor(+b);
8782 function MathLog(b){
8783 return %_MathLogRT(((typeof(%IS_VAR(b))==='number')?b:NonNumberToNumber(b)));
8785 function MathMax(d,e){
8786 var g=%_ArgumentsLength();
8788 d=((typeof(%IS_VAR(d))==='number')?d:NonNumberToNumber(d));
8789 e=((typeof(%IS_VAR(e))==='number')?e:NonNumberToNumber(e));
8793 return(d===0&&%_IsMinusZero(d))?e:d;
8798 for(var i=0;i<g;i++){
8799 var j=%_Arguments(i);
8800 if(!(typeof(j)==='number'))j=NonNumberToNumber(j);
8801 if((!%_IsSmi(%IS_VAR(j))&&!(j==j))||j>h||(h===0&&j===0&&%_IsMinusZero(h))){
8807 function MathMin(d,e){
8808 var g=%_ArgumentsLength();
8810 d=((typeof(%IS_VAR(d))==='number')?d:NonNumberToNumber(d));
8811 e=((typeof(%IS_VAR(e))==='number')?e:NonNumberToNumber(e));
8815 return(d===0&&%_IsMinusZero(d))?d:e;
8820 for(var i=0;i<g;i++){
8821 var j=%_Arguments(i);
8822 if(!(typeof(j)==='number'))j=NonNumberToNumber(j);
8823 if((!%_IsSmi(%IS_VAR(j))&&!(j==j))||j<h||(h===0&&j===0&&%_IsMinusZero(j))){
8829 function MathPowJS(b,c){
8830 return %_MathPow(((typeof(%IS_VAR(b))==='number')?b:NonNumberToNumber(b)),((typeof(%IS_VAR(c))==='number')?c:NonNumberToNumber(c)));
8832 function MathRandom(){
8833 var k=(MathImul(18030,rngstate[0]&0xFFFF)+(rngstate[0]>>>16))|0;
8835 var l=(MathImul(36969,rngstate[1]&0xFFFF)+(rngstate[1]>>>16))|0;
8837 var b=((k<<16)+(l&0xFFFF))|0;
8838 return(b<0?(b+0x100000000):b)*2.3283064365386962890625e-10;
8840 function MathRound(b){
8841 return %RoundNumber(((typeof(%IS_VAR(b))==='number')?b:NonNumberToNumber(b)));
8843 function MathSqrtJS(b){
8844 return %_MathSqrt(+b);
8846 function MathImul(b,c){
8847 return %NumberImul(((typeof(%IS_VAR(b))==='number')?b:NonNumberToNumber(b)),((typeof(%IS_VAR(c))==='number')?c:NonNumberToNumber(c)));
8849 function MathSign(b){
8855 function MathTrunc(b){
8857 if(b>0)return %_MathFloor(b);
8858 if(b<0)return-%_MathFloor(-b);
8861 function MathTanh(b){
8862 if(!(typeof(b)==='number'))b=NonNumberToNumber(b);
8864 if(!(%_IsSmi(%IS_VAR(b))||((b==b)&&(b!=1/0)&&(b!=-1/0))))return MathSign(b);
8869 function MathAsinh(b){
8870 if(!(typeof(b)==='number'))b=NonNumberToNumber(b);
8871 if(b===0||!(%_IsSmi(%IS_VAR(b))||((b==b)&&(b!=1/0)&&(b!=-1/0))))return b;
8872 if(b>0)return MathLog(b+%_MathSqrt(b*b+1));
8873 return-MathLog(-b+%_MathSqrt(b*b+1));
8875 function MathAcosh(b){
8876 if(!(typeof(b)==='number'))b=NonNumberToNumber(b);
8878 if(!(%_IsSmi(%IS_VAR(b))||((b==b)&&(b!=1/0)&&(b!=-1/0))))return b;
8879 return MathLog(b+%_MathSqrt(b+1)*%_MathSqrt(b-1));
8881 function MathAtanh(b){
8882 if(!(typeof(b)==='number'))b=NonNumberToNumber(b);
8884 if(!(%_IsSmi(%IS_VAR(b))||((b==b)&&(b!=1/0)&&(b!=-1/0))))return $NaN;
8885 return 0.5*MathLog((1+b)/(1-b));
8887 function MathHypot(b,c){
8888 var g=%_ArgumentsLength();
8889 var o=new InternalArray(g);
8891 for(var i=0;i<g;i++){
8892 var j=%_Arguments(i);
8893 if(!(typeof(j)==='number'))j=NonNumberToNumber(j);
8894 if(j===(1/0)||j===-(1/0))return(1/0);
8902 for(var i=0;i<g;i++){
8909 return %_MathSqrt(r)*q;
8911 function MathFroundJS(b){
8912 return %MathFround(((typeof(%IS_VAR(b))==='number')?b:NonNumberToNumber(b)));
8914 function MathClz32JS(b){
8915 return %_MathClz32(b>>>0);
8917 function MathCbrt(b){
8918 if(!(typeof(b)==='number'))b=NonNumberToNumber(b);
8919 if(b==0||!(%_IsSmi(%IS_VAR(b))||((b==b)&&(b!=1/0)&&(b!=-1/0))))return b;
8920 return b>=0?CubeRoot(b):-CubeRoot(-b);
8922 function CubeRoot(b){
8923 var z=MathFloorJS(%_DoubleHi(b)/3)+0x2A9F7893;
8924 var A=%_ConstructDouble(z,0);
8925 A=(1.0/3.0)*(b/(A*A)+2*A);
8927 A=(1.0/3.0)*(b/(A*A)+2*A);
8929 A=(1.0/3.0)*(b/(A*A)+2*A);
8931 return(1.0/3.0)*(b/(A*A)+2*A);
8934 function MathConstructor(){}
8935 var B=new MathConstructor();
8936 %InternalSetPrototype(B,a.prototype);
8937 %AddNamedProperty(global,"Math",B,2);
8938 %FunctionSetInstanceClassName(MathConstructor,'Math');
8939 %AddNamedProperty(B,symbolToStringTag,"Math",1|2);
8940 InstallConstants(B,[
8941 "E",2.7182818284590452354,
8942 "LN10",2.302585092994046,
8943 "LN2",0.6931471805599453,
8944 "LOG2E",1.4426950408889634,
8945 "LOG10E",0.4342944819032518,
8946 "PI",3.1415926535897932,
8947 "SQRT1_2",0.7071067811865476,
8948 "SQRT2",1.4142135623730951
8950 InstallFunctions(B,2,[
8951 "random",MathRandom,
8958 "floor",MathFloorJS,
8962 "atan2",MathAtan2JS,
8974 "fround",MathFroundJS,
8975 "clz32",MathClz32JS,
8978 %SetInlineBuiltinFlag(MathAbs);
8979 %SetInlineBuiltinFlag(MathAcosJS);
8980 %SetInlineBuiltinFlag(MathAsinJS);
8981 %SetInlineBuiltinFlag(MathAtanJS);
8982 %SetInlineBuiltinFlag(MathAtan2JS);
8983 %SetInlineBuiltinFlag(MathCeil);
8984 %SetInlineBuiltinFlag(MathClz32JS);
8985 %SetInlineBuiltinFlag(MathFloorJS);
8986 %SetInlineBuiltinFlag(MathRandom);
8987 %SetInlineBuiltinFlag(MathSign);
8988 %SetInlineBuiltinFlag(MathSqrtJS);
8989 %SetInlineBuiltinFlag(MathTrunc);
9002 %CheckIsBootstrapping();
9025 function KernelTan(b,c,d){
9028 var h=%_DoubleHi(b);
9031 if(((i|%_DoubleLo(b))|(d+1))==0){
9038 var e=%_ConstructDouble(%_DoubleHi(g),0);
9041 var l=%_ConstructDouble(%_DoubleHi(k),0);
9067 var j=e*(kMath[19+2]
9081 return(1-((h>>30)&2))*
9082 (d-2.0*(b-(g*g/(g+d)-n)));
9087 e=%_ConstructDouble(%_DoubleHi(g),0);
9090 var l=%_ConstructDouble(%_DoubleHi(k),0);
9095 function MathSinSlow(b){
9097 var h=%_DoubleHi(b);
9123 }else if(i<=0x413921fb){
9125 o=(l*kMath[0]+0.5)|0;
9129 if(i-(%_DoubleHi(q)&0x7ff00000)>0x1000000){
9133 g=o*kMath[4]-((l-n)-g);
9135 if(i-(%_DoubleHi(q)&0x7ff00000)>0x3100000){
9139 g=o*kMath[6]-((l-n)-g);
9150 o=%RemPiO2(b,rempio2result);
9157 var i=%_DoubleHi(q)&0x7fffffff;
9159 var n=e*(4.16666666666666019037e-02+e*(-1.38888888888741095749e-03+e*(2.48015872894767294178e-05+e*(-2.75573143513906633035e-07+e*(2.08757232129817482790e-09+e*-1.13596475577881948265e-11)))));
9161 return(1-(0.5*e-(e*n-q*r)))*t;
9167 u=%_ConstructDouble(%_DoubleHi(0.25*q),0);
9170 return(1-u-(w-(e*n-q*r)))*t;
9176 var n=8.33333333332248946124e-03+e*(-1.98412698298579493134e-04+e*(2.75573137070700676789e-06+e*(-2.50507602534068634195e-08+e*1.58969099521155010221e-10)));
9177 return(q-((e*(0.5*r-j*n)-r)-j*-1.66666666666666324348e-01))*t;
9181 function MathCosSlow(b){
9183 var h=%_DoubleHi(b);
9209 }else if(i<=0x413921fb){
9211 o=(l*kMath[0]+0.5)|0;
9215 if(i-(%_DoubleHi(q)&0x7ff00000)>0x1000000){
9219 g=o*kMath[4]-((l-n)-g);
9221 if(i-(%_DoubleHi(q)&0x7ff00000)>0x3100000){
9225 g=o*kMath[6]-((l-n)-g);
9236 o=%RemPiO2(b,rempio2result);
9245 var n=8.33333333332248946124e-03+e*(-1.98412698298579493134e-04+e*(2.75573137070700676789e-06+e*(-2.50507602534068634195e-08+e*1.58969099521155010221e-10)));
9246 return(q-((e*(0.5*r-j*n)-r)-j*-1.66666666666666324348e-01))*t;
9250 var i=%_DoubleHi(q)&0x7fffffff;
9252 var n=e*(4.16666666666666019037e-02+e*(-1.38888888888741095749e-03+e*(2.48015872894767294178e-05+e*(-2.75573143513906633035e-07+e*(2.08757232129817482790e-09+e*-1.13596475577881948265e-11)))));
9254 return(1-(0.5*e-(e*n-q*r)))*t;
9260 u=%_ConstructDouble(%_DoubleHi(0.25*q),0);
9263 return(1-u-(w-(e*n-q*r)))*t;
9268 function MathSin(b){
9270 if((%_DoubleHi(b)&0x7fffffff)<=0x3fe921fb){
9273 var n=8.33333333332248946124e-03+e*(-1.98412698298579493134e-04+e*(2.75573137070700676789e-06+e*(-2.50507602534068634195e-08+e*1.58969099521155010221e-10)));
9274 return(b-((e*(0.5*0-j*n)-0)-j*-1.66666666666666324348e-01));
9277 return+MathSinSlow(b);
9279 function MathCos(b){
9281 if((%_DoubleHi(b)&0x7fffffff)<=0x3fe921fb){
9282 var i=%_DoubleHi(b)&0x7fffffff;
9284 var n=e*(4.16666666666666019037e-02+e*(-1.38888888888741095749e-03+e*(2.48015872894767294178e-05+e*(-2.75573143513906633035e-07+e*(2.08757232129817482790e-09+e*-1.13596475577881948265e-11)))));
9286 return(1-(0.5*e-(e*n-b*0)));
9292 u=%_ConstructDouble(%_DoubleHi(0.25*b),0);
9295 return(1-u-(w-(e*n-b*0)));
9299 return+MathCosSlow(b);
9301 function MathTan(b){
9303 if((%_DoubleHi(b)&0x7fffffff)<=0x3fe921fb){
9304 return KernelTan(b,0,1);
9307 var h=%_DoubleHi(b);
9333 }else if(i<=0x413921fb){
9335 o=(l*kMath[0]+0.5)|0;
9339 if(i-(%_DoubleHi(q)&0x7ff00000)>0x1000000){
9343 g=o*kMath[4]-((l-n)-g);
9345 if(i-(%_DoubleHi(q)&0x7ff00000)>0x3100000){
9349 g=o*kMath[6]-((l-n)-g);
9360 o=%RemPiO2(b,rempio2result);
9365 return KernelTan(q,r,(o&1)?-1:1);
9371 function MathLog1p(b){
9373 var h=%_DoubleHi(b);
9387 }else if(z<0x3c900000){
9389 }else if(z<0x3e200000){
9392 if((h>0)||(h<=-0x402D413D)){
9396 if(h>=0x7ff00000)return b;
9402 D=(A>0)?1-(E-b):b-(E-1);
9410 E=%_ConstructDouble(C|0x3ff00000,%_DoubleLo(E));
9413 E=%_ConstructDouble(C|0x3fe00000,%_DoubleLo(E));
9414 C=(0x00100000-C)>>2;
9424 return A*kMath[34]+(D+A*kMath[35]);
9427 var H=G*(1-kMath[36]*B);
9431 return A*kMath[34]-((H-(A*kMath[35]+D))-B);
9436 var H=e*((kMath[37+0])
9447 return B-(G-m*(G+H));
9449 return A*kMath[34]-((G-(m*(G+H)+(A*kMath[35]+D)))-B);
9454 function MathExpm1(b){
9462 var h=%_DoubleHi(b);
9469 return(b===-(1/0))?-1:b;
9471 if(b>kMath[44])return(1/0);
9487 A=(kMath[45]*b+((K===0)?0.5:-0.5))|0;
9494 }else if(h<0x3c900000){
9501 var N=1+M*((kMath[46+0])
9509 var P=M*((N-l)/(6-b*l));
9515 if(A===-1)return 0.5*(b-P)-0.5;
9517 if(b<-0.25)return-2*(P-(b+0.5));
9522 c=%_ConstructDouble(%_DoubleHi(c)+(A<<20),%_DoubleLo(c));
9526 l=%_ConstructDouble(0x3ff00000-(0x200000>>A),0);
9528 c=%_ConstructDouble(%_DoubleHi(c)+(A<<20),%_DoubleLo(c));
9530 l=%_ConstructDouble((0x3ff-A)<<20,0);
9533 c=%_ConstructDouble(%_DoubleHi(c)+(A<<20),%_DoubleLo(c));
9541 function MathSinh(b){
9543 var Q=(b<0)?-0.5:0.5;
9546 if(z<3.725290298461914e-9)return b;
9548 if(z<1)return Q*(2*l-l*l/(l+1));
9549 return Q*(l+l/(l+1));
9551 if(z<709.7822265625)return Q*$exp(z);
9560 function MathCosh(b){
9562 var i=%_DoubleHi(b)&0x7fffffff;
9564 var l=MathExpm1($abs(b));
9566 if(i<0x3c800000)return g;
9567 return 1+(l*l)/(g+g);
9570 var l=$exp($abs(b));
9573 if(i<0x40862e42)return 0.5*$exp($abs(b));
9574 if($abs(b)<=kMath[51]){
9575 var g=$exp(0.5*$abs(b));
9579 if((!%_IsSmi(%IS_VAR(b))&&!(b==b)))return b;
9585 function MathLog10(b){
9587 var h=%_DoubleHi(b);
9588 var R=%_DoubleLo(b);
9591 if(((h&0x7fffffff)|R)===0)return-(1/0);
9594 b*=18014398509481984;
9598 if(h>=0x7ff00000)return b;
9600 var S=(A&0x80000000)>>>31;
9601 h=(h&0x000fffff)|((0x3ff-S)<<20);
9603 b=%_ConstructDouble(h,R);
9604 var e=c*kMath[54]+kMath[52]*%_MathLogRT(b);
9605 return e+c*kMath[53];
9613 function MathLog2(b){
9616 var h=%_DoubleHi(b);
9617 var R=%_DoubleLo(b);
9619 if((i|R)==0)return-(1/0);
9621 if(i>=0x7ff00000)return b;
9624 z*=9007199254740992;
9644 z=%_ConstructDouble(i,%_DoubleLo(z));
9648 var Z=%_ConstructDouble(%_DoubleHi(Y),0);
9649 var aa=%_ConstructDouble(%_DoubleHi(z+U),0)
9651 var ac=j*((E-Z*aa)-Z*ab);
9653 var n=ad*ad*((kMath[55+0])
9663 aa=%_ConstructDouble(%_DoubleHi(3.0+ad+n),0);
9667 p_h=%_ConstructDouble(%_DoubleHi(E+j),0);
9670 z_l=kMath[63]*p_h+p_l*kMath[61]+X;
9672 var ae=%_ConstructDouble(%_DoubleHi(((z_h+z_l)+W)+l),0);
9673 var af=z_l-(((ae-l)-W)-z_h);
9676 InstallFunctions(a,2,[
9687 %SetInlineBuiltinFlag(MathSin);
9688 %SetInlineBuiltinFlag(MathCos);
9695 %CheckIsBootstrapping();
9697 function ThrowDateTypeError(){
9698 throw new $TypeError('this is not a Date object.');
9702 function LocalTimezone(d){
9703 if((!%_IsSmi(%IS_VAR(d))&&!(d==d)))return"";
9704 CheckDateCacheCurrent();
9708 var e=%DateLocalTimezone(d);
9714 if((!%_IsSmi(%IS_VAR(g))&&!(g==g)))return g;
9715 return %DateToUTC(g);
9717 function MakeTime(h,i,j,k){
9718 if(!$isFinite(h))return $NaN;
9719 if(!$isFinite(i))return $NaN;
9720 if(!$isFinite(j))return $NaN;
9721 if(!$isFinite(k))return $NaN;
9722 return(%_IsSmi(%IS_VAR(h))?h:%NumberToInteger(ToNumber(h)))*3600000
9723 +(%_IsSmi(%IS_VAR(i))?i:%NumberToInteger(ToNumber(i)))*60000
9724 +(%_IsSmi(%IS_VAR(j))?j:%NumberToInteger(ToNumber(j)))*1000
9725 +(%_IsSmi(%IS_VAR(k))?k:%NumberToInteger(ToNumber(k)));
9727 function TimeInYear(l){
9728 return DaysInYear(l)*86400000;
9730 function MakeDay(l,m,n){
9731 if(!$isFinite(l)||!$isFinite(m)||!$isFinite(n))return $NaN;
9732 l=(%_IsSmi(%IS_VAR(l))?l:%NumberToIntegerMapMinusZero(ToNumber(l)));
9733 m=(%_IsSmi(%IS_VAR(m))?m:%NumberToIntegerMapMinusZero(ToNumber(m)));
9734 n=(%_IsSmi(%IS_VAR(n))?n:%NumberToIntegerMapMinusZero(ToNumber(n)));
9735 if(l<-1000000||l>1000000||
9736 m<-10000000||m>10000000){
9739 return %DateMakeDay(l|0,m|0)+n-1;
9741 function MakeDate(o,g){
9743 if($abs(g)>8640002592000000)return $NaN;
9746 function TimeClip(g){
9747 if(!$isFinite(g))return $NaN;
9748 if($abs(g)>8640000000000000)return $NaN;
9749 return(%_IsSmi(%IS_VAR(g))?g:%NumberToInteger(ToNumber(g)));
9755 function DateConstructor(l,m,n,r,t,u,k){
9756 if(!%_IsConstructCall()){
9757 return(new a()).toString();
9759 var w=%_ArgumentsLength();
9762 z=%DateCurrentTime();
9763 (%DateSetValue(this,z,1));
9765 if((typeof(l)==='number')){
9767 }else if((typeof(l)==='string')){
9768 CheckDateCacheCurrent();
9774 if(!(!%_IsSmi(%IS_VAR(z))&&!(z==z))){
9780 var g=ToPrimitive(l,1);
9781 z=(typeof(g)==='string')?DateParse(g):ToNumber(g);
9783 (%DateSetValue(this,z,1));
9787 n=w>2?ToNumber(n):1;
9788 r=w>3?ToNumber(r):0;
9789 t=w>4?ToNumber(t):0;
9790 u=w>5?ToNumber(u):0;
9791 k=w>6?ToNumber(k):0;
9792 l=(!(!%_IsSmi(%IS_VAR(l))&&!(l==l))&&
9793 0<=(%_IsSmi(%IS_VAR(l))?l:%NumberToInteger(ToNumber(l)))&&
9794 (%_IsSmi(%IS_VAR(l))?l:%NumberToInteger(ToNumber(l)))<=99)?1900+(%_IsSmi(%IS_VAR(l))?l:%NumberToInteger(ToNumber(l))):l;
9795 var o=MakeDay(l,m,n);
9796 var g=MakeTime(r,t,u,k);
9798 (%DateSetValue(this,z,0));
9801 var B=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
9802 var C=['Jan','Feb','Mar','Apr','May','Jun',
9803 'Jul','Aug','Sep','Oct','Nov','Dec'];
9804 function TwoDigitString(z){
9805 return z<10?"0"+z:""+z;
9807 function DateString(n){
9808 return B[(%_DateField(n,4))]+' '
9809 +C[(%_DateField(n,2))]+' '
9810 +TwoDigitString((%_DateField(n,3)))+' '
9811 +(%_DateField(n,1));
9813 var D=['Sunday','Monday','Tuesday','Wednesday',
9814 'Thursday','Friday','Saturday'];
9815 var E=['January','February','March','April','May','June',
9816 'July','August','September','October','November','December'];
9817 function LongDateString(n){
9818 return D[(%_DateField(n,4))]+', '
9819 +E[(%_DateField(n,2))]+' '
9820 +TwoDigitString((%_DateField(n,3)))+', '
9821 +(%_DateField(n,1));
9823 function TimeString(n){
9824 return TwoDigitString((%_DateField(n,5)))+':'
9825 +TwoDigitString((%_DateField(n,6)))+':'
9826 +TwoDigitString((%_DateField(n,7)));
9828 function TimeStringUTC(n){
9829 return TwoDigitString((%_DateField(n,15)))+':'
9830 +TwoDigitString((%_DateField(n,16)))+':'
9831 +TwoDigitString((%_DateField(n,17)));
9833 function LocalTimezoneString(n){
9834 var e=LocalTimezone((%_DateField(n,0)));
9835 var G=-(%_DateField(n,21));
9837 var r=$floor((H*G)/60);
9838 var i=$floor((H*G)%60);
9839 var I=' GMT'+((H==1)?'+':'-')+
9840 TwoDigitString(r)+TwoDigitString(i);
9841 return I+' ('+e+')';
9843 function DatePrintString(n){
9844 return DateString(n)+' '+TimeString(n);
9846 var J=new InternalArray(8);
9847 function DateParse(K){
9848 var L=%DateParseString(ToString(K),J);
9849 if((L===null))return $NaN;
9850 var o=MakeDay(L[0],L[1],L[2]);
9851 var g=MakeTime(L[3],L[4],L[5],L[6]);
9852 var n=MakeDate(o,g);
9854 return TimeClip(UTC(n));
9856 return TimeClip(n-L[7]*1000);
9859 function DateUTC(l,m,n,r,t,u,k){
9862 var w=%_ArgumentsLength();
9863 n=w>2?ToNumber(n):1;
9864 r=w>3?ToNumber(r):0;
9865 t=w>4?ToNumber(t):0;
9866 u=w>5?ToNumber(u):0;
9867 k=w>6?ToNumber(k):0;
9868 l=(!(!%_IsSmi(%IS_VAR(l))&&!(l==l))&&
9869 0<=(%_IsSmi(%IS_VAR(l))?l:%NumberToInteger(ToNumber(l)))&&
9870 (%_IsSmi(%IS_VAR(l))?l:%NumberToInteger(ToNumber(l)))<=99)?1900+(%_IsSmi(%IS_VAR(l))?l:%NumberToInteger(ToNumber(l))):l;
9871 var o=MakeDay(l,m,n);
9872 var g=MakeTime(r,t,u,k);
9873 return TimeClip(MakeDate(o,g));
9876 return %DateCurrentTime();
9878 function DateToString(){
9879 var d=(%_DateField(this,0))
9880 if((!%_IsSmi(%IS_VAR(d))&&!(d==d)))return'Invalid Date';
9881 var M=LocalTimezoneString(this)
9882 return DatePrintString(this)+M;
9884 function DateToDateString(){
9885 var d=(%_DateField(this,0));
9886 if((!%_IsSmi(%IS_VAR(d))&&!(d==d)))return'Invalid Date';
9887 return DateString(this);
9889 function DateToTimeString(){
9890 var d=(%_DateField(this,0));
9891 if((!%_IsSmi(%IS_VAR(d))&&!(d==d)))return'Invalid Date';
9892 var M=LocalTimezoneString(this);
9893 return TimeString(this)+M;
9895 function DateToLocaleString(){
9896 return %_CallFunction(this,DateToString);
9898 function DateToLocaleDateString(){
9899 var d=(%_DateField(this,0));
9900 if((!%_IsSmi(%IS_VAR(d))&&!(d==d)))return'Invalid Date';
9901 return LongDateString(this);
9903 function DateToLocaleTimeString(){
9904 var d=(%_DateField(this,0));
9905 if((!%_IsSmi(%IS_VAR(d))&&!(d==d)))return'Invalid Date';
9906 return TimeString(this);
9908 function DateValueOf(){
9909 return(%_DateField(this,0));
9911 function DateGetTime(){
9912 return(%_DateField(this,0));
9914 function DateGetFullYear(){
9915 return(%_DateField(this,1));
9917 function DateGetUTCFullYear(){
9918 return(%_DateField(this,11));
9920 function DateGetMonth(){
9921 return(%_DateField(this,2));
9923 function DateGetUTCMonth(){
9924 return(%_DateField(this,12));
9926 function DateGetDate(){
9927 return(%_DateField(this,3));
9929 function DateGetUTCDate(){
9930 return(%_DateField(this,13));
9932 function DateGetDay(){
9933 return(%_DateField(this,4));
9935 function DateGetUTCDay(){
9936 return(%_DateField(this,14));
9938 function DateGetHours(){
9939 return(%_DateField(this,5));
9941 function DateGetUTCHours(){
9942 return(%_DateField(this,15));
9944 function DateGetMinutes(){
9945 return(%_DateField(this,6));
9947 function DateGetUTCMinutes(){
9948 return(%_DateField(this,16));
9950 function DateGetSeconds(){
9951 return(%_DateField(this,7));
9953 function DateGetUTCSeconds(){
9954 return(%_DateField(this,17))
9956 function DateGetMilliseconds(){
9957 return(%_DateField(this,8));
9959 function DateGetUTCMilliseconds(){
9960 return(%_DateField(this,18));
9962 function DateGetTimezoneOffset(){
9963 return(%_DateField(this,21));
9965 function DateSetTime(k){
9966 if(%_ClassOf(this)!=='Date')ThrowDateTypeError();
9967 (%DateSetValue(this,ToNumber(k),1));
9968 return(%_DateField(this,0));
9970 function DateSetMilliseconds(k){
9971 var d=(%_DateField(this,0)+%_DateField(this,21));
9973 var g=MakeTime((%_DateField(this,5)),(%_DateField(this,6)),(%_DateField(this,7)),k);
9974 return(%DateSetValue(this,MakeDate((%_DateField(this,9)),g),0));
9976 function DateSetUTCMilliseconds(k){
9977 var d=(%_DateField(this,0));
9979 var g=MakeTime((%_DateField(this,15)),
9980 (%_DateField(this,16)),
9981 (%_DateField(this,17)),
9983 return(%DateSetValue(this,MakeDate((%_DateField(this,19)),g),1));
9985 function DateSetSeconds(j,k){
9986 var d=(%_DateField(this,0)+%_DateField(this,21));
9988 k=%_ArgumentsLength()<2?(%_DateField(this,8)):ToNumber(k);
9989 var g=MakeTime((%_DateField(this,5)),(%_DateField(this,6)),j,k);
9990 return(%DateSetValue(this,MakeDate((%_DateField(this,9)),g),0));
9992 function DateSetUTCSeconds(j,k){
9993 var d=(%_DateField(this,0));
9995 k=%_ArgumentsLength()<2?(%_DateField(this,18)):ToNumber(k);
9996 var g=MakeTime((%_DateField(this,15)),(%_DateField(this,16)),j,k);
9997 return(%DateSetValue(this,MakeDate((%_DateField(this,19)),g),1));
9999 function DateSetMinutes(i,j,k){
10000 var d=(%_DateField(this,0)+%_DateField(this,21));
10002 var w=%_ArgumentsLength();
10003 j=w<2?(%_DateField(this,7)):ToNumber(j);
10004 k=w<3?(%_DateField(this,8)):ToNumber(k);
10005 var g=MakeTime((%_DateField(this,5)),i,j,k);
10006 return(%DateSetValue(this,MakeDate((%_DateField(this,9)),g),0));
10008 function DateSetUTCMinutes(i,j,k){
10009 var d=(%_DateField(this,0));
10011 var w=%_ArgumentsLength();
10012 j=w<2?(%_DateField(this,17)):ToNumber(j);
10013 k=w<3?(%_DateField(this,18)):ToNumber(k);
10014 var g=MakeTime((%_DateField(this,15)),i,j,k);
10015 return(%DateSetValue(this,MakeDate((%_DateField(this,19)),g),1));
10017 function DateSetHours(h,i,j,k){
10018 var d=(%_DateField(this,0)+%_DateField(this,21));
10020 var w=%_ArgumentsLength();
10021 i=w<2?(%_DateField(this,6)):ToNumber(i);
10022 j=w<3?(%_DateField(this,7)):ToNumber(j);
10023 k=w<4?(%_DateField(this,8)):ToNumber(k);
10024 var g=MakeTime(h,i,j,k);
10025 return(%DateSetValue(this,MakeDate((%_DateField(this,9)),g),0));
10027 function DateSetUTCHours(h,i,j,k){
10028 var d=(%_DateField(this,0));
10030 var w=%_ArgumentsLength();
10031 i=w<2?(%_DateField(this,16)):ToNumber(i);
10032 j=w<3?(%_DateField(this,17)):ToNumber(j);
10033 k=w<4?(%_DateField(this,18)):ToNumber(k);
10034 var g=MakeTime(h,i,j,k);
10035 return(%DateSetValue(this,MakeDate((%_DateField(this,19)),g),1));
10037 function DateSetDate(n){
10038 var d=(%_DateField(this,0)+%_DateField(this,21));
10040 var o=MakeDay((%_DateField(this,1)),(%_DateField(this,2)),n);
10041 return(%DateSetValue(this,MakeDate(o,(%_DateField(this,10))),0));
10043 function DateSetUTCDate(n){
10044 var d=(%_DateField(this,0));
10046 var o=MakeDay((%_DateField(this,11)),(%_DateField(this,12)),n);
10047 return(%DateSetValue(this,MakeDate(o,(%_DateField(this,20))),1));
10049 function DateSetMonth(m,n){
10050 var d=(%_DateField(this,0)+%_DateField(this,21));
10052 n=%_ArgumentsLength()<2?(%_DateField(this,3)):ToNumber(n);
10053 var o=MakeDay((%_DateField(this,1)),m,n);
10054 return(%DateSetValue(this,MakeDate(o,(%_DateField(this,10))),0));
10056 function DateSetUTCMonth(m,n){
10057 var d=(%_DateField(this,0));
10059 n=%_ArgumentsLength()<2?(%_DateField(this,13)):ToNumber(n);
10060 var o=MakeDay((%_DateField(this,11)),m,n);
10061 return(%DateSetValue(this,MakeDate(o,(%_DateField(this,20))),1));
10063 function DateSetFullYear(l,m,n){
10064 var d=(%_DateField(this,0)+%_DateField(this,21));
10066 var w=%_ArgumentsLength();
10068 if((!%_IsSmi(%IS_VAR(d))&&!(d==d))){
10069 m=w<2?0:ToNumber(m);
10070 n=w<3?1:ToNumber(n);
10073 m=w<2?(%_DateField(this,2)):ToNumber(m);
10074 n=w<3?(%_DateField(this,3)):ToNumber(n);
10075 g=(%_DateField(this,10));
10077 var o=MakeDay(l,m,n);
10078 return(%DateSetValue(this,MakeDate(o,g),0));
10080 function DateSetUTCFullYear(l,m,n){
10081 var d=(%_DateField(this,0));
10083 var w=%_ArgumentsLength();
10085 if((!%_IsSmi(%IS_VAR(d))&&!(d==d))){
10086 m=w<2?0:ToNumber(m);
10087 n=w<3?1:ToNumber(n);
10090 m=w<2?(%_DateField(this,12)):ToNumber(m);
10091 n=w<3?(%_DateField(this,13)):ToNumber(n);
10092 g=(%_DateField(this,20));
10094 var o=MakeDay(l,m,n);
10095 return(%DateSetValue(this,MakeDate(o,g),1));
10097 function DateToUTCString(){
10098 var d=(%_DateField(this,0));
10099 if((!%_IsSmi(%IS_VAR(d))&&!(d==d)))return'Invalid Date';
10100 return B[(%_DateField(this,14))]+', '
10101 +TwoDigitString((%_DateField(this,13)))+' '
10102 +C[(%_DateField(this,12))]+' '
10103 +(%_DateField(this,11))+' '
10104 +TimeStringUTC(this)+' GMT';
10106 function DateGetYear(){
10107 return(%_DateField(this,1))-1900;
10109 function DateSetYear(l){
10110 if(%_ClassOf(this)!=='Date')ThrowDateTypeError();
10112 if((!%_IsSmi(%IS_VAR(l))&&!(l==l)))return(%DateSetValue(this,$NaN,1));
10113 l=(0<=(%_IsSmi(%IS_VAR(l))?l:%NumberToInteger(ToNumber(l)))&&(%_IsSmi(%IS_VAR(l))?l:%NumberToInteger(ToNumber(l)))<=99)
10114 ?1900+(%_IsSmi(%IS_VAR(l))?l:%NumberToInteger(ToNumber(l))):l;
10115 var d=(%_DateField(this,0)+%_DateField(this,21));
10117 if((!%_IsSmi(%IS_VAR(d))&&!(d==d))){
10122 m=(%_DateField(this,2));
10123 n=(%_DateField(this,3));
10124 g=(%_DateField(this,10));
10126 var o=MakeDay(l,m,n);
10127 return(%DateSetValue(this,MakeDate(o,g),0));
10129 function DateToGMTString(){
10130 return %_CallFunction(this,DateToUTCString);
10132 function PadInt(N,P){
10134 return N<%_MathPow(10,P-1)?'0'+PadInt(N,P-1):N;
10136 function DateToISOString(){
10137 var d=(%_DateField(this,0));
10138 if((!%_IsSmi(%IS_VAR(d))&&!(d==d)))throw MakeRangeError("invalid_time_value",[]);
10139 var l=this.getUTCFullYear();
10145 Q="-"+PadInt(-l,6);
10151 '-'+PadInt(this.getUTCMonth()+1,2)+
10152 '-'+PadInt(this.getUTCDate(),2)+
10153 'T'+PadInt(this.getUTCHours(),2)+
10154 ':'+PadInt(this.getUTCMinutes(),2)+
10155 ':'+PadInt(this.getUTCSeconds(),2)+
10156 '.'+PadInt(this.getUTCMilliseconds(),3)+
10159 function DateToJSON(R){
10160 var S=ToObject(this);
10161 var T=DefaultNumber(S);
10162 if((typeof(T)==='number')&&!(%_IsSmi(%IS_VAR(T))||((T==T)&&(T!=1/0)&&(T!=-1/0)))){
10165 return S.toISOString();
10169 function CheckDateCacheCurrent(){
10171 U=%DateCacheVersion();
10183 function CreateDate(g){
10188 %SetCode(a,DateConstructor);
10189 %FunctionSetPrototype(a,new a($NaN));
10190 InstallFunctions(a,2,[
10195 %AddNamedProperty(a.prototype,"constructor",a,2);
10196 InstallFunctions(a.prototype,2,[
10197 "toString",DateToString,
10198 "toDateString",DateToDateString,
10199 "toTimeString",DateToTimeString,
10200 "toLocaleString",DateToLocaleString,
10201 "toLocaleDateString",DateToLocaleDateString,
10202 "toLocaleTimeString",DateToLocaleTimeString,
10203 "valueOf",DateValueOf,
10204 "getTime",DateGetTime,
10205 "getFullYear",DateGetFullYear,
10206 "getUTCFullYear",DateGetUTCFullYear,
10207 "getMonth",DateGetMonth,
10208 "getUTCMonth",DateGetUTCMonth,
10209 "getDate",DateGetDate,
10210 "getUTCDate",DateGetUTCDate,
10211 "getDay",DateGetDay,
10212 "getUTCDay",DateGetUTCDay,
10213 "getHours",DateGetHours,
10214 "getUTCHours",DateGetUTCHours,
10215 "getMinutes",DateGetMinutes,
10216 "getUTCMinutes",DateGetUTCMinutes,
10217 "getSeconds",DateGetSeconds,
10218 "getUTCSeconds",DateGetUTCSeconds,
10219 "getMilliseconds",DateGetMilliseconds,
10220 "getUTCMilliseconds",DateGetUTCMilliseconds,
10221 "getTimezoneOffset",DateGetTimezoneOffset,
10222 "setTime",DateSetTime,
10223 "setMilliseconds",DateSetMilliseconds,
10224 "setUTCMilliseconds",DateSetUTCMilliseconds,
10225 "setSeconds",DateSetSeconds,
10226 "setUTCSeconds",DateSetUTCSeconds,
10227 "setMinutes",DateSetMinutes,
10228 "setUTCMinutes",DateSetUTCMinutes,
10229 "setHours",DateSetHours,
10230 "setUTCHours",DateSetUTCHours,
10231 "setDate",DateSetDate,
10232 "setUTCDate",DateSetUTCDate,
10233 "setMonth",DateSetMonth,
10234 "setUTCMonth",DateSetUTCMonth,
10235 "setFullYear",DateSetFullYear,
10236 "setUTCFullYear",DateSetUTCFullYear,
10237 "toGMTString",DateToGMTString,
10238 "toUTCString",DateToUTCString,
10239 "getYear",DateGetYear,
10240 "setYear",DateSetYear,
10241 "toISOString",DateToISOString,
10242 "toJSON",DateToJSON
10244 $createDate=CreateDate;
10249 var $regexpExecNoTests;
10250 var $regexpLastMatchInfo;
10251 var $regexpLastMatchInfoOverride;
10252 var harmony_regexps=false;
10253 var harmony_unicode_regexps=false;
10255 %CheckIsBootstrapping();
10256 var a=global.RegExp;
10257 $regexpLastMatchInfo=new InternalPackedArray(
10264 $regexpLastMatchInfoOverride=null;
10265 function DoConstructRegExp(b,c,d){
10266 if((%_IsRegExp(c))){
10267 if(!(d===(void 0))){
10268 throw MakeTypeError('regexp_flags',[]);
10270 d=(c.global?'g':'')
10271 +(c.ignoreCase?'i':'')
10272 +(c.multiline?'m':'');
10273 if(harmony_unicode_regexps)
10274 d+=(c.unicode?'u':'');
10275 if(harmony_regexps)
10276 d+=(c.sticky?'y':'');
10279 c=(c===(void 0))?'':ToString(c);
10280 d=(d===(void 0))?'':ToString(d);
10281 %RegExpInitializeAndCompile(b,c,d);
10283 function RegExpConstructor(c,d){
10284 if(%_IsConstructCall()){
10285 DoConstructRegExp(this,c,d);
10287 if((%_IsRegExp(c))&&(d===(void 0))){
10293 function RegExpCompileJS(c,d){
10294 if(this==a.prototype){
10295 throw MakeTypeError(8,
10296 'RegExp.prototype.compile',this);
10298 if((c===(void 0))&&%_ArgumentsLength()!=0){
10299 DoConstructRegExp(this,'undefined',d);
10301 DoConstructRegExp(this,c,d);
10304 function DoRegExpExec(e,g,h){
10305 var i=%_RegExpExec(e,g,h,$regexpLastMatchInfo);
10306 if(i!==null)$regexpLastMatchInfoOverride=null;
10309 function RegExpExecNoTests(e,g,j){
10310 var k=%_RegExpExec(e,g,j,$regexpLastMatchInfo);
10312 $regexpLastMatchInfoOverride=null;
10316 var n=%_SubString(g,j,m);
10317 var i=%_RegExpConstructResult(l,j,g);
10321 for(var q=1;q<l;q++){
10325 i[q]=%_SubString(g,j,m);
10335 function RegExpExecJS(g){
10336 if(!(%_IsRegExp(this))){
10337 throw MakeTypeError(8,
10338 'RegExp.prototype.exec',this);
10340 g=((typeof(%IS_VAR(g))==='string')?g:NonStringToString(g));
10341 var r=this.lastIndex;
10342 var q=(%_IsSmi(%IS_VAR(r))?r:%NumberToInteger(ToNumber(r)));
10343 var t=this.global||(harmony_regexps&&this.sticky);
10345 if(q<0||q>g.length){
10352 var u=%_RegExpExec(this,g,q,$regexpLastMatchInfo);
10357 $regexpLastMatchInfoOverride=null;
10359 this.lastIndex=$regexpLastMatchInfo[4];
10364 var n=%_SubString(g,j,m);
10365 var i=%_RegExpConstructResult(l,j,g);
10369 for(var q=1;q<l;q++){
10373 i[q]=%_SubString(g,j,m);
10382 function RegExpTest(g){
10383 if(!(%_IsRegExp(this))){
10384 throw MakeTypeError(8,
10385 'RegExp.prototype.test',this);
10387 g=((typeof(%IS_VAR(g))==='string')?g:NonStringToString(g));
10388 var r=this.lastIndex;
10389 var q=(%_IsSmi(%IS_VAR(r))?r:%NumberToInteger(ToNumber(r)));
10390 if(this.global||(harmony_regexps&&this.sticky)){
10391 if(q<0||q>g.length){
10395 var u=%_RegExpExec(this,g,q,$regexpLastMatchInfo);
10400 $regexpLastMatchInfoOverride=null;
10401 this.lastIndex=$regexpLastMatchInfo[4];
10405 if(e.source.length>=3&&
10406 %_StringCharCodeAt(e.source,0)==46&&
10407 %_StringCharCodeAt(e.source,1)==42&&
10408 %_StringCharCodeAt(e.source,2)!=63){
10411 var u=%_RegExpExec(e,g,0,$regexpLastMatchInfo);
10416 $regexpLastMatchInfoOverride=null;
10420 function TrimRegExp(e){
10421 if(!%_ObjectEquals(w,e)){
10424 new a(%_SubString(e.source,2,e.source.length),
10425 (e.ignoreCase?e.multiline?"im":"i"
10426 :e.multiline?"m":""));
10430 function RegExpToString(){
10431 if(!(%_IsRegExp(this))){
10432 throw MakeTypeError(8,
10433 'RegExp.prototype.toString',this);
10435 var i='/'+this.source+'/';
10436 if(this.global)i+='g';
10437 if(this.ignoreCase)i+='i';
10438 if(this.multiline)i+='m';
10439 if(harmony_unicode_regexps&&this.unicode)i+='u';
10440 if(harmony_regexps&&this.sticky)i+='y';
10443 function RegExpGetLastMatch(){
10444 if($regexpLastMatchInfoOverride!==null){
10445 return(($regexpLastMatchInfoOverride)[0]);
10447 var A=(($regexpLastMatchInfo)[1]);
10448 return %_SubString(A,
10449 $regexpLastMatchInfo[3],
10450 $regexpLastMatchInfo[4]);
10452 function RegExpGetLastParen(){
10453 if($regexpLastMatchInfoOverride){
10454 var B=$regexpLastMatchInfoOverride;
10455 if(B.length<=3)return'';
10456 return B[B.length-3];
10458 var C=(($regexpLastMatchInfo)[0]);
10460 var A=(($regexpLastMatchInfo)[1]);
10461 var j=$regexpLastMatchInfo[(3+(C-2))];
10462 var m=$regexpLastMatchInfo[(3+(C-1))];
10464 return %_SubString(A,j,m);
10468 function RegExpGetLeftContext(){
10471 if(!$regexpLastMatchInfoOverride){
10472 D=$regexpLastMatchInfo[3];
10473 E=(($regexpLastMatchInfo)[1]);
10475 var B=$regexpLastMatchInfoOverride;
10476 D=((B)[(B).length-2]);
10477 E=((B)[(B).length-1]);
10479 return %_SubString(E,0,D);
10481 function RegExpGetRightContext(){
10484 if(!$regexpLastMatchInfoOverride){
10485 D=$regexpLastMatchInfo[4];
10486 E=(($regexpLastMatchInfo)[1]);
10488 var B=$regexpLastMatchInfoOverride;
10489 E=((B)[(B).length-1]);
10491 D=((B)[(B).length-2])+G.length;
10493 return %_SubString(E,D,E.length);
10495 function RegExpMakeCaptureGetter(H){
10496 return function foo(){
10497 if($regexpLastMatchInfoOverride){
10498 if(H<$regexpLastMatchInfoOverride.length-2){
10499 return(($regexpLastMatchInfoOverride)[(H)]);
10504 if(h>=(($regexpLastMatchInfo)[0]))return'';
10505 var I=$regexpLastMatchInfo[(3+(h))];
10506 var J=$regexpLastMatchInfo[(3+(h+1))];
10507 if(I==-1||J==-1)return'';
10508 return %_SubString((($regexpLastMatchInfo)[1]),I,J);
10511 %FunctionSetInstanceClassName(a,'RegExp');
10513 a.prototype,'constructor',a,2);
10514 %SetCode(a,RegExpConstructor);
10515 InstallFunctions(a.prototype,2,[
10516 "exec",RegExpExecJS,
10518 "toString",RegExpToString,
10519 "compile",RegExpCompileJS
10521 %FunctionSetLength(a.prototype.compile,1);
10523 var L=(($regexpLastMatchInfo)[2]);
10524 return(L===(void 0))?"":L;
10527 (($regexpLastMatchInfo)[2])=ToString(g);
10529 %OptimizeObjectForAddingMultipleProperties(a,22);
10530 %DefineAccessorPropertyUnchecked(a,'input',K,
10532 %DefineAccessorPropertyUnchecked(a,'$_',K,
10535 var P=function(){return N;};
10536 var Q=function(R){N=R?true:false;};
10537 %DefineAccessorPropertyUnchecked(a,'multiline',P,
10539 %DefineAccessorPropertyUnchecked(a,'$*',P,
10542 var S=function(T){};
10543 %DefineAccessorPropertyUnchecked(a,'lastMatch',RegExpGetLastMatch,
10545 %DefineAccessorPropertyUnchecked(a,'$&',RegExpGetLastMatch,
10547 %DefineAccessorPropertyUnchecked(a,'lastParen',RegExpGetLastParen,
10549 %DefineAccessorPropertyUnchecked(a,'$+',RegExpGetLastParen,
10551 %DefineAccessorPropertyUnchecked(a,'leftContext',
10552 RegExpGetLeftContext,S,
10554 %DefineAccessorPropertyUnchecked(a,'$`',RegExpGetLeftContext,
10556 %DefineAccessorPropertyUnchecked(a,'rightContext',
10557 RegExpGetRightContext,S,
10559 %DefineAccessorPropertyUnchecked(a,"$'",RegExpGetRightContext,
10561 for(var q=1;q<10;++q){
10562 %DefineAccessorPropertyUnchecked(a,'$'+q,
10563 RegExpMakeCaptureGetter(q),S,
10566 %ToFastProperties(a);
10567 $regexpExecNoTests=RegExpExecNoTests;
10568 $regexpExec=DoRegExpExec;
10574 %CheckIsBootstrapping();
10575 var a=global.ArrayBuffer;
10576 var b=global.Object;
10577 function ArrayBufferConstructor(c){
10578 if(%_IsConstructCall()){
10579 var d=ToPositiveInteger(c,'invalid_array_buffer_length');
10580 %ArrayBufferInitialize(this,d);
10582 throw MakeTypeError('constructor_not_function',["ArrayBuffer"]);
10585 function ArrayBufferGetByteLen(){
10586 if(!(%_ClassOf(this)==='ArrayBuffer')){
10587 throw MakeTypeError(8,
10588 'ArrayBuffer.prototype.byteLength',this);
10590 return %_ArrayBufferGetByteLength(this);
10592 function ArrayBufferSlice(e,g){
10593 if(!(%_ClassOf(this)==='ArrayBuffer')){
10594 throw MakeTypeError(8,
10595 'ArrayBuffer.prototype.slice',this);
10597 var h=(%_IsSmi(%IS_VAR(e))?e:%NumberToInteger(ToNumber(e)));
10598 if(!(g===(void 0))){
10599 g=(%_IsSmi(%IS_VAR(g))?g:%NumberToInteger(ToNumber(g)));
10602 var j=%_ArrayBufferGetByteLength(this);
10608 var k=(g===(void 0))?j:g;
10620 %ArrayBufferSliceImpl(this,n,i);
10623 function ArrayBufferIsViewJS(o){
10624 return %ArrayBufferIsView(o);
10626 %SetCode(a,ArrayBufferConstructor);
10627 %FunctionSetPrototype(a,new b());
10629 a.prototype,"constructor",a,2);
10630 %AddNamedProperty(a.prototype,
10631 symbolToStringTag,"ArrayBuffer",2|1);
10632 InstallGetter(a.prototype,"byteLength",ArrayBufferGetByteLen);
10633 InstallFunctions(a,2,[
10634 "isView",ArrayBufferIsViewJS
10636 InstallFunctions(a.prototype,2,[
10637 "slice",ArrayBufferSlice
10644 %CheckIsBootstrapping();
10645 var a=global.Array;
10646 var b=global.ArrayBuffer;
10647 function Uint8ArrayConstructByArrayBuffer(c,d,e,g){
10648 if(!(e===(void 0))){
10650 ToPositiveInteger(e,"invalid_typed_array_length");
10652 if(!(g===(void 0))){
10653 g=ToPositiveInteger(g,"invalid_typed_array_length");
10655 var h=%_ArrayBufferGetByteLength(d);
10657 if((e===(void 0))){
10662 throw MakeRangeError("invalid_typed_array_alignment",
10663 ["start offset","Uint8Array",1]);
10666 throw MakeRangeError("invalid_typed_array_offset");
10671 if((g===(void 0))){
10673 throw MakeRangeError("invalid_typed_array_alignment",
10674 ["byte length","Uint8Array",1]);
10684 throw MakeRangeError("invalid_typed_array_length");
10686 %_TypedArrayInitialize(c,1,d,i,j);
10688 function Uint8ArrayConstructByLength(c,g){
10689 var l=(g===(void 0))?
10690 0:ToPositiveInteger(g,"invalid_typed_array_length");
10692 throw MakeRangeError("invalid_typed_array_length");
10695 if(m>%_TypedArrayMaxSizeInHeap()){
10697 %_TypedArrayInitialize(c,1,d,0,m);
10699 %_TypedArrayInitialize(c,1,null,0,m);
10702 function Uint8ArrayConstructByArrayLike(c,n){
10704 var l=ToPositiveInteger(g,"invalid_typed_array_length");
10706 throw MakeRangeError("invalid_typed_array_length");
10708 if(!%TypedArrayInitializeFromArrayLike(c,1,n,l)){
10709 for(var o=0;o<l;o++){
10714 function Uint8ArrayConstructor(q,r,t){
10715 if(%_IsConstructCall()){
10716 if((%_ClassOf(q)==='ArrayBuffer')){
10717 Uint8ArrayConstructByArrayBuffer(this,q,r,t);
10718 }else if((typeof(q)==='number')||(typeof(q)==='string')||
10719 (typeof(q)==='boolean')||(q===(void 0))){
10720 Uint8ArrayConstructByLength(this,q);
10722 Uint8ArrayConstructByArrayLike(this,q);
10725 throw MakeTypeError("constructor_not_function",["Uint8Array"])
10728 function Uint8Array_GetBuffer(){
10729 if(!(%_ClassOf(this)==='Uint8Array')){
10730 throw MakeTypeError(8,"Uint8Array.buffer",this);
10732 return %TypedArrayGetBuffer(this);
10734 function Uint8Array_GetByteLength(){
10735 if(!(%_ClassOf(this)==='Uint8Array')){
10736 throw MakeTypeError(8,"Uint8Array.byteLength",this);
10738 return %_ArrayBufferViewGetByteLength(this);
10740 function Uint8Array_GetByteOffset(){
10741 if(!(%_ClassOf(this)==='Uint8Array')){
10742 throw MakeTypeError(8,"Uint8Array.byteOffset",this);
10744 return %_ArrayBufferViewGetByteOffset(this);
10746 function Uint8Array_GetLength(){
10747 if(!(%_ClassOf(this)==='Uint8Array')){
10748 throw MakeTypeError(8,"Uint8Array.length",this);
10750 return %_TypedArrayGetLength(this);
10752 var u=global.Uint8Array;
10753 function Uint8ArraySubArray(w,z){
10754 if(!(%_ClassOf(this)==='Uint8Array')){
10755 throw MakeTypeError(8,"Uint8Array.subarray",this);
10757 var A=(%_IsSmi(%IS_VAR(w))?w:%NumberToInteger(ToNumber(w)));
10758 if(!(z===(void 0))){
10759 z=(%_IsSmi(%IS_VAR(z))?z:%NumberToInteger(ToNumber(z)));
10761 var B=%_TypedArrayGetLength(this);
10767 var C=(z===(void 0))?B:z;
10778 %_ArrayBufferViewGetByteOffset(this)+A*1;
10779 return new u(%TypedArrayGetBuffer(this),
10783 function Int8ArrayConstructByArrayBuffer(c,d,e,g){
10784 if(!(e===(void 0))){
10786 ToPositiveInteger(e,"invalid_typed_array_length");
10788 if(!(g===(void 0))){
10789 g=ToPositiveInteger(g,"invalid_typed_array_length");
10791 var h=%_ArrayBufferGetByteLength(d);
10793 if((e===(void 0))){
10798 throw MakeRangeError("invalid_typed_array_alignment",
10799 ["start offset","Int8Array",1]);
10802 throw MakeRangeError("invalid_typed_array_offset");
10807 if((g===(void 0))){
10809 throw MakeRangeError("invalid_typed_array_alignment",
10810 ["byte length","Int8Array",1]);
10820 throw MakeRangeError("invalid_typed_array_length");
10822 %_TypedArrayInitialize(c,2,d,i,j);
10824 function Int8ArrayConstructByLength(c,g){
10825 var l=(g===(void 0))?
10826 0:ToPositiveInteger(g,"invalid_typed_array_length");
10828 throw MakeRangeError("invalid_typed_array_length");
10831 if(m>%_TypedArrayMaxSizeInHeap()){
10833 %_TypedArrayInitialize(c,2,d,0,m);
10835 %_TypedArrayInitialize(c,2,null,0,m);
10838 function Int8ArrayConstructByArrayLike(c,n){
10840 var l=ToPositiveInteger(g,"invalid_typed_array_length");
10842 throw MakeRangeError("invalid_typed_array_length");
10844 if(!%TypedArrayInitializeFromArrayLike(c,2,n,l)){
10845 for(var o=0;o<l;o++){
10850 function Int8ArrayConstructor(q,r,t){
10851 if(%_IsConstructCall()){
10852 if((%_ClassOf(q)==='ArrayBuffer')){
10853 Int8ArrayConstructByArrayBuffer(this,q,r,t);
10854 }else if((typeof(q)==='number')||(typeof(q)==='string')||
10855 (typeof(q)==='boolean')||(q===(void 0))){
10856 Int8ArrayConstructByLength(this,q);
10858 Int8ArrayConstructByArrayLike(this,q);
10861 throw MakeTypeError("constructor_not_function",["Int8Array"])
10864 function Int8Array_GetBuffer(){
10865 if(!(%_ClassOf(this)==='Int8Array')){
10866 throw MakeTypeError(8,"Int8Array.buffer",this);
10868 return %TypedArrayGetBuffer(this);
10870 function Int8Array_GetByteLength(){
10871 if(!(%_ClassOf(this)==='Int8Array')){
10872 throw MakeTypeError(8,"Int8Array.byteLength",this);
10874 return %_ArrayBufferViewGetByteLength(this);
10876 function Int8Array_GetByteOffset(){
10877 if(!(%_ClassOf(this)==='Int8Array')){
10878 throw MakeTypeError(8,"Int8Array.byteOffset",this);
10880 return %_ArrayBufferViewGetByteOffset(this);
10882 function Int8Array_GetLength(){
10883 if(!(%_ClassOf(this)==='Int8Array')){
10884 throw MakeTypeError(8,"Int8Array.length",this);
10886 return %_TypedArrayGetLength(this);
10888 var E=global.Int8Array;
10889 function Int8ArraySubArray(w,z){
10890 if(!(%_ClassOf(this)==='Int8Array')){
10891 throw MakeTypeError(8,"Int8Array.subarray",this);
10893 var A=(%_IsSmi(%IS_VAR(w))?w:%NumberToInteger(ToNumber(w)));
10894 if(!(z===(void 0))){
10895 z=(%_IsSmi(%IS_VAR(z))?z:%NumberToInteger(ToNumber(z)));
10897 var B=%_TypedArrayGetLength(this);
10903 var C=(z===(void 0))?B:z;
10914 %_ArrayBufferViewGetByteOffset(this)+A*1;
10915 return new E(%TypedArrayGetBuffer(this),
10919 function Uint16ArrayConstructByArrayBuffer(c,d,e,g){
10920 if(!(e===(void 0))){
10922 ToPositiveInteger(e,"invalid_typed_array_length");
10924 if(!(g===(void 0))){
10925 g=ToPositiveInteger(g,"invalid_typed_array_length");
10927 var h=%_ArrayBufferGetByteLength(d);
10929 if((e===(void 0))){
10934 throw MakeRangeError("invalid_typed_array_alignment",
10935 ["start offset","Uint16Array",2]);
10938 throw MakeRangeError("invalid_typed_array_offset");
10943 if((g===(void 0))){
10945 throw MakeRangeError("invalid_typed_array_alignment",
10946 ["byte length","Uint16Array",2]);
10956 throw MakeRangeError("invalid_typed_array_length");
10958 %_TypedArrayInitialize(c,3,d,i,j);
10960 function Uint16ArrayConstructByLength(c,g){
10961 var l=(g===(void 0))?
10962 0:ToPositiveInteger(g,"invalid_typed_array_length");
10964 throw MakeRangeError("invalid_typed_array_length");
10967 if(m>%_TypedArrayMaxSizeInHeap()){
10969 %_TypedArrayInitialize(c,3,d,0,m);
10971 %_TypedArrayInitialize(c,3,null,0,m);
10974 function Uint16ArrayConstructByArrayLike(c,n){
10976 var l=ToPositiveInteger(g,"invalid_typed_array_length");
10978 throw MakeRangeError("invalid_typed_array_length");
10980 if(!%TypedArrayInitializeFromArrayLike(c,3,n,l)){
10981 for(var o=0;o<l;o++){
10986 function Uint16ArrayConstructor(q,r,t){
10987 if(%_IsConstructCall()){
10988 if((%_ClassOf(q)==='ArrayBuffer')){
10989 Uint16ArrayConstructByArrayBuffer(this,q,r,t);
10990 }else if((typeof(q)==='number')||(typeof(q)==='string')||
10991 (typeof(q)==='boolean')||(q===(void 0))){
10992 Uint16ArrayConstructByLength(this,q);
10994 Uint16ArrayConstructByArrayLike(this,q);
10997 throw MakeTypeError("constructor_not_function",["Uint16Array"])
11000 function Uint16Array_GetBuffer(){
11001 if(!(%_ClassOf(this)==='Uint16Array')){
11002 throw MakeTypeError(8,"Uint16Array.buffer",this);
11004 return %TypedArrayGetBuffer(this);
11006 function Uint16Array_GetByteLength(){
11007 if(!(%_ClassOf(this)==='Uint16Array')){
11008 throw MakeTypeError(8,"Uint16Array.byteLength",this);
11010 return %_ArrayBufferViewGetByteLength(this);
11012 function Uint16Array_GetByteOffset(){
11013 if(!(%_ClassOf(this)==='Uint16Array')){
11014 throw MakeTypeError(8,"Uint16Array.byteOffset",this);
11016 return %_ArrayBufferViewGetByteOffset(this);
11018 function Uint16Array_GetLength(){
11019 if(!(%_ClassOf(this)==='Uint16Array')){
11020 throw MakeTypeError(8,"Uint16Array.length",this);
11022 return %_TypedArrayGetLength(this);
11024 var G=global.Uint16Array;
11025 function Uint16ArraySubArray(w,z){
11026 if(!(%_ClassOf(this)==='Uint16Array')){
11027 throw MakeTypeError(8,"Uint16Array.subarray",this);
11029 var A=(%_IsSmi(%IS_VAR(w))?w:%NumberToInteger(ToNumber(w)));
11030 if(!(z===(void 0))){
11031 z=(%_IsSmi(%IS_VAR(z))?z:%NumberToInteger(ToNumber(z)));
11033 var B=%_TypedArrayGetLength(this);
11039 var C=(z===(void 0))?B:z;
11050 %_ArrayBufferViewGetByteOffset(this)+A*2;
11051 return new G(%TypedArrayGetBuffer(this),
11055 function Int16ArrayConstructByArrayBuffer(c,d,e,g){
11056 if(!(e===(void 0))){
11058 ToPositiveInteger(e,"invalid_typed_array_length");
11060 if(!(g===(void 0))){
11061 g=ToPositiveInteger(g,"invalid_typed_array_length");
11063 var h=%_ArrayBufferGetByteLength(d);
11065 if((e===(void 0))){
11070 throw MakeRangeError("invalid_typed_array_alignment",
11071 ["start offset","Int16Array",2]);
11074 throw MakeRangeError("invalid_typed_array_offset");
11079 if((g===(void 0))){
11081 throw MakeRangeError("invalid_typed_array_alignment",
11082 ["byte length","Int16Array",2]);
11092 throw MakeRangeError("invalid_typed_array_length");
11094 %_TypedArrayInitialize(c,4,d,i,j);
11096 function Int16ArrayConstructByLength(c,g){
11097 var l=(g===(void 0))?
11098 0:ToPositiveInteger(g,"invalid_typed_array_length");
11100 throw MakeRangeError("invalid_typed_array_length");
11103 if(m>%_TypedArrayMaxSizeInHeap()){
11105 %_TypedArrayInitialize(c,4,d,0,m);
11107 %_TypedArrayInitialize(c,4,null,0,m);
11110 function Int16ArrayConstructByArrayLike(c,n){
11112 var l=ToPositiveInteger(g,"invalid_typed_array_length");
11114 throw MakeRangeError("invalid_typed_array_length");
11116 if(!%TypedArrayInitializeFromArrayLike(c,4,n,l)){
11117 for(var o=0;o<l;o++){
11122 function Int16ArrayConstructor(q,r,t){
11123 if(%_IsConstructCall()){
11124 if((%_ClassOf(q)==='ArrayBuffer')){
11125 Int16ArrayConstructByArrayBuffer(this,q,r,t);
11126 }else if((typeof(q)==='number')||(typeof(q)==='string')||
11127 (typeof(q)==='boolean')||(q===(void 0))){
11128 Int16ArrayConstructByLength(this,q);
11130 Int16ArrayConstructByArrayLike(this,q);
11133 throw MakeTypeError("constructor_not_function",["Int16Array"])
11136 function Int16Array_GetBuffer(){
11137 if(!(%_ClassOf(this)==='Int16Array')){
11138 throw MakeTypeError(8,"Int16Array.buffer",this);
11140 return %TypedArrayGetBuffer(this);
11142 function Int16Array_GetByteLength(){
11143 if(!(%_ClassOf(this)==='Int16Array')){
11144 throw MakeTypeError(8,"Int16Array.byteLength",this);
11146 return %_ArrayBufferViewGetByteLength(this);
11148 function Int16Array_GetByteOffset(){
11149 if(!(%_ClassOf(this)==='Int16Array')){
11150 throw MakeTypeError(8,"Int16Array.byteOffset",this);
11152 return %_ArrayBufferViewGetByteOffset(this);
11154 function Int16Array_GetLength(){
11155 if(!(%_ClassOf(this)==='Int16Array')){
11156 throw MakeTypeError(8,"Int16Array.length",this);
11158 return %_TypedArrayGetLength(this);
11160 var H=global.Int16Array;
11161 function Int16ArraySubArray(w,z){
11162 if(!(%_ClassOf(this)==='Int16Array')){
11163 throw MakeTypeError(8,"Int16Array.subarray",this);
11165 var A=(%_IsSmi(%IS_VAR(w))?w:%NumberToInteger(ToNumber(w)));
11166 if(!(z===(void 0))){
11167 z=(%_IsSmi(%IS_VAR(z))?z:%NumberToInteger(ToNumber(z)));
11169 var B=%_TypedArrayGetLength(this);
11175 var C=(z===(void 0))?B:z;
11186 %_ArrayBufferViewGetByteOffset(this)+A*2;
11187 return new H(%TypedArrayGetBuffer(this),
11191 function Uint32ArrayConstructByArrayBuffer(c,d,e,g){
11192 if(!(e===(void 0))){
11194 ToPositiveInteger(e,"invalid_typed_array_length");
11196 if(!(g===(void 0))){
11197 g=ToPositiveInteger(g,"invalid_typed_array_length");
11199 var h=%_ArrayBufferGetByteLength(d);
11201 if((e===(void 0))){
11206 throw MakeRangeError("invalid_typed_array_alignment",
11207 ["start offset","Uint32Array",4]);
11210 throw MakeRangeError("invalid_typed_array_offset");
11215 if((g===(void 0))){
11217 throw MakeRangeError("invalid_typed_array_alignment",
11218 ["byte length","Uint32Array",4]);
11228 throw MakeRangeError("invalid_typed_array_length");
11230 %_TypedArrayInitialize(c,5,d,i,j);
11232 function Uint32ArrayConstructByLength(c,g){
11233 var l=(g===(void 0))?
11234 0:ToPositiveInteger(g,"invalid_typed_array_length");
11236 throw MakeRangeError("invalid_typed_array_length");
11239 if(m>%_TypedArrayMaxSizeInHeap()){
11241 %_TypedArrayInitialize(c,5,d,0,m);
11243 %_TypedArrayInitialize(c,5,null,0,m);
11246 function Uint32ArrayConstructByArrayLike(c,n){
11248 var l=ToPositiveInteger(g,"invalid_typed_array_length");
11250 throw MakeRangeError("invalid_typed_array_length");
11252 if(!%TypedArrayInitializeFromArrayLike(c,5,n,l)){
11253 for(var o=0;o<l;o++){
11258 function Uint32ArrayConstructor(q,r,t){
11259 if(%_IsConstructCall()){
11260 if((%_ClassOf(q)==='ArrayBuffer')){
11261 Uint32ArrayConstructByArrayBuffer(this,q,r,t);
11262 }else if((typeof(q)==='number')||(typeof(q)==='string')||
11263 (typeof(q)==='boolean')||(q===(void 0))){
11264 Uint32ArrayConstructByLength(this,q);
11266 Uint32ArrayConstructByArrayLike(this,q);
11269 throw MakeTypeError("constructor_not_function",["Uint32Array"])
11272 function Uint32Array_GetBuffer(){
11273 if(!(%_ClassOf(this)==='Uint32Array')){
11274 throw MakeTypeError(8,"Uint32Array.buffer",this);
11276 return %TypedArrayGetBuffer(this);
11278 function Uint32Array_GetByteLength(){
11279 if(!(%_ClassOf(this)==='Uint32Array')){
11280 throw MakeTypeError(8,"Uint32Array.byteLength",this);
11282 return %_ArrayBufferViewGetByteLength(this);
11284 function Uint32Array_GetByteOffset(){
11285 if(!(%_ClassOf(this)==='Uint32Array')){
11286 throw MakeTypeError(8,"Uint32Array.byteOffset",this);
11288 return %_ArrayBufferViewGetByteOffset(this);
11290 function Uint32Array_GetLength(){
11291 if(!(%_ClassOf(this)==='Uint32Array')){
11292 throw MakeTypeError(8,"Uint32Array.length",this);
11294 return %_TypedArrayGetLength(this);
11296 var I=global.Uint32Array;
11297 function Uint32ArraySubArray(w,z){
11298 if(!(%_ClassOf(this)==='Uint32Array')){
11299 throw MakeTypeError(8,"Uint32Array.subarray",this);
11301 var A=(%_IsSmi(%IS_VAR(w))?w:%NumberToInteger(ToNumber(w)));
11302 if(!(z===(void 0))){
11303 z=(%_IsSmi(%IS_VAR(z))?z:%NumberToInteger(ToNumber(z)));
11305 var B=%_TypedArrayGetLength(this);
11311 var C=(z===(void 0))?B:z;
11322 %_ArrayBufferViewGetByteOffset(this)+A*4;
11323 return new I(%TypedArrayGetBuffer(this),
11327 function Int32ArrayConstructByArrayBuffer(c,d,e,g){
11328 if(!(e===(void 0))){
11330 ToPositiveInteger(e,"invalid_typed_array_length");
11332 if(!(g===(void 0))){
11333 g=ToPositiveInteger(g,"invalid_typed_array_length");
11335 var h=%_ArrayBufferGetByteLength(d);
11337 if((e===(void 0))){
11342 throw MakeRangeError("invalid_typed_array_alignment",
11343 ["start offset","Int32Array",4]);
11346 throw MakeRangeError("invalid_typed_array_offset");
11351 if((g===(void 0))){
11353 throw MakeRangeError("invalid_typed_array_alignment",
11354 ["byte length","Int32Array",4]);
11364 throw MakeRangeError("invalid_typed_array_length");
11366 %_TypedArrayInitialize(c,6,d,i,j);
11368 function Int32ArrayConstructByLength(c,g){
11369 var l=(g===(void 0))?
11370 0:ToPositiveInteger(g,"invalid_typed_array_length");
11372 throw MakeRangeError("invalid_typed_array_length");
11375 if(m>%_TypedArrayMaxSizeInHeap()){
11377 %_TypedArrayInitialize(c,6,d,0,m);
11379 %_TypedArrayInitialize(c,6,null,0,m);
11382 function Int32ArrayConstructByArrayLike(c,n){
11384 var l=ToPositiveInteger(g,"invalid_typed_array_length");
11386 throw MakeRangeError("invalid_typed_array_length");
11388 if(!%TypedArrayInitializeFromArrayLike(c,6,n,l)){
11389 for(var o=0;o<l;o++){
11394 function Int32ArrayConstructor(q,r,t){
11395 if(%_IsConstructCall()){
11396 if((%_ClassOf(q)==='ArrayBuffer')){
11397 Int32ArrayConstructByArrayBuffer(this,q,r,t);
11398 }else if((typeof(q)==='number')||(typeof(q)==='string')||
11399 (typeof(q)==='boolean')||(q===(void 0))){
11400 Int32ArrayConstructByLength(this,q);
11402 Int32ArrayConstructByArrayLike(this,q);
11405 throw MakeTypeError("constructor_not_function",["Int32Array"])
11408 function Int32Array_GetBuffer(){
11409 if(!(%_ClassOf(this)==='Int32Array')){
11410 throw MakeTypeError(8,"Int32Array.buffer",this);
11412 return %TypedArrayGetBuffer(this);
11414 function Int32Array_GetByteLength(){
11415 if(!(%_ClassOf(this)==='Int32Array')){
11416 throw MakeTypeError(8,"Int32Array.byteLength",this);
11418 return %_ArrayBufferViewGetByteLength(this);
11420 function Int32Array_GetByteOffset(){
11421 if(!(%_ClassOf(this)==='Int32Array')){
11422 throw MakeTypeError(8,"Int32Array.byteOffset",this);
11424 return %_ArrayBufferViewGetByteOffset(this);
11426 function Int32Array_GetLength(){
11427 if(!(%_ClassOf(this)==='Int32Array')){
11428 throw MakeTypeError(8,"Int32Array.length",this);
11430 return %_TypedArrayGetLength(this);
11432 var J=global.Int32Array;
11433 function Int32ArraySubArray(w,z){
11434 if(!(%_ClassOf(this)==='Int32Array')){
11435 throw MakeTypeError(8,"Int32Array.subarray",this);
11437 var A=(%_IsSmi(%IS_VAR(w))?w:%NumberToInteger(ToNumber(w)));
11438 if(!(z===(void 0))){
11439 z=(%_IsSmi(%IS_VAR(z))?z:%NumberToInteger(ToNumber(z)));
11441 var B=%_TypedArrayGetLength(this);
11447 var C=(z===(void 0))?B:z;
11458 %_ArrayBufferViewGetByteOffset(this)+A*4;
11459 return new J(%TypedArrayGetBuffer(this),
11463 function Float32ArrayConstructByArrayBuffer(c,d,e,g){
11464 if(!(e===(void 0))){
11466 ToPositiveInteger(e,"invalid_typed_array_length");
11468 if(!(g===(void 0))){
11469 g=ToPositiveInteger(g,"invalid_typed_array_length");
11471 var h=%_ArrayBufferGetByteLength(d);
11473 if((e===(void 0))){
11478 throw MakeRangeError("invalid_typed_array_alignment",
11479 ["start offset","Float32Array",4]);
11482 throw MakeRangeError("invalid_typed_array_offset");
11487 if((g===(void 0))){
11489 throw MakeRangeError("invalid_typed_array_alignment",
11490 ["byte length","Float32Array",4]);
11500 throw MakeRangeError("invalid_typed_array_length");
11502 %_TypedArrayInitialize(c,7,d,i,j);
11504 function Float32ArrayConstructByLength(c,g){
11505 var l=(g===(void 0))?
11506 0:ToPositiveInteger(g,"invalid_typed_array_length");
11508 throw MakeRangeError("invalid_typed_array_length");
11511 if(m>%_TypedArrayMaxSizeInHeap()){
11513 %_TypedArrayInitialize(c,7,d,0,m);
11515 %_TypedArrayInitialize(c,7,null,0,m);
11518 function Float32ArrayConstructByArrayLike(c,n){
11520 var l=ToPositiveInteger(g,"invalid_typed_array_length");
11522 throw MakeRangeError("invalid_typed_array_length");
11524 if(!%TypedArrayInitializeFromArrayLike(c,7,n,l)){
11525 for(var o=0;o<l;o++){
11530 function Float32ArrayConstructor(q,r,t){
11531 if(%_IsConstructCall()){
11532 if((%_ClassOf(q)==='ArrayBuffer')){
11533 Float32ArrayConstructByArrayBuffer(this,q,r,t);
11534 }else if((typeof(q)==='number')||(typeof(q)==='string')||
11535 (typeof(q)==='boolean')||(q===(void 0))){
11536 Float32ArrayConstructByLength(this,q);
11538 Float32ArrayConstructByArrayLike(this,q);
11541 throw MakeTypeError("constructor_not_function",["Float32Array"])
11544 function Float32Array_GetBuffer(){
11545 if(!(%_ClassOf(this)==='Float32Array')){
11546 throw MakeTypeError(8,"Float32Array.buffer",this);
11548 return %TypedArrayGetBuffer(this);
11550 function Float32Array_GetByteLength(){
11551 if(!(%_ClassOf(this)==='Float32Array')){
11552 throw MakeTypeError(8,"Float32Array.byteLength",this);
11554 return %_ArrayBufferViewGetByteLength(this);
11556 function Float32Array_GetByteOffset(){
11557 if(!(%_ClassOf(this)==='Float32Array')){
11558 throw MakeTypeError(8,"Float32Array.byteOffset",this);
11560 return %_ArrayBufferViewGetByteOffset(this);
11562 function Float32Array_GetLength(){
11563 if(!(%_ClassOf(this)==='Float32Array')){
11564 throw MakeTypeError(8,"Float32Array.length",this);
11566 return %_TypedArrayGetLength(this);
11568 var K=global.Float32Array;
11569 function Float32ArraySubArray(w,z){
11570 if(!(%_ClassOf(this)==='Float32Array')){
11571 throw MakeTypeError(8,"Float32Array.subarray",this);
11573 var A=(%_IsSmi(%IS_VAR(w))?w:%NumberToInteger(ToNumber(w)));
11574 if(!(z===(void 0))){
11575 z=(%_IsSmi(%IS_VAR(z))?z:%NumberToInteger(ToNumber(z)));
11577 var B=%_TypedArrayGetLength(this);
11583 var C=(z===(void 0))?B:z;
11594 %_ArrayBufferViewGetByteOffset(this)+A*4;
11595 return new K(%TypedArrayGetBuffer(this),
11599 function Float64ArrayConstructByArrayBuffer(c,d,e,g){
11600 if(!(e===(void 0))){
11602 ToPositiveInteger(e,"invalid_typed_array_length");
11604 if(!(g===(void 0))){
11605 g=ToPositiveInteger(g,"invalid_typed_array_length");
11607 var h=%_ArrayBufferGetByteLength(d);
11609 if((e===(void 0))){
11614 throw MakeRangeError("invalid_typed_array_alignment",
11615 ["start offset","Float64Array",8]);
11618 throw MakeRangeError("invalid_typed_array_offset");
11623 if((g===(void 0))){
11625 throw MakeRangeError("invalid_typed_array_alignment",
11626 ["byte length","Float64Array",8]);
11636 throw MakeRangeError("invalid_typed_array_length");
11638 %_TypedArrayInitialize(c,8,d,i,j);
11640 function Float64ArrayConstructByLength(c,g){
11641 var l=(g===(void 0))?
11642 0:ToPositiveInteger(g,"invalid_typed_array_length");
11644 throw MakeRangeError("invalid_typed_array_length");
11647 if(m>%_TypedArrayMaxSizeInHeap()){
11649 %_TypedArrayInitialize(c,8,d,0,m);
11651 %_TypedArrayInitialize(c,8,null,0,m);
11654 function Float64ArrayConstructByArrayLike(c,n){
11656 var l=ToPositiveInteger(g,"invalid_typed_array_length");
11658 throw MakeRangeError("invalid_typed_array_length");
11660 if(!%TypedArrayInitializeFromArrayLike(c,8,n,l)){
11661 for(var o=0;o<l;o++){
11666 function Float64ArrayConstructor(q,r,t){
11667 if(%_IsConstructCall()){
11668 if((%_ClassOf(q)==='ArrayBuffer')){
11669 Float64ArrayConstructByArrayBuffer(this,q,r,t);
11670 }else if((typeof(q)==='number')||(typeof(q)==='string')||
11671 (typeof(q)==='boolean')||(q===(void 0))){
11672 Float64ArrayConstructByLength(this,q);
11674 Float64ArrayConstructByArrayLike(this,q);
11677 throw MakeTypeError("constructor_not_function",["Float64Array"])
11680 function Float64Array_GetBuffer(){
11681 if(!(%_ClassOf(this)==='Float64Array')){
11682 throw MakeTypeError(8,"Float64Array.buffer",this);
11684 return %TypedArrayGetBuffer(this);
11686 function Float64Array_GetByteLength(){
11687 if(!(%_ClassOf(this)==='Float64Array')){
11688 throw MakeTypeError(8,"Float64Array.byteLength",this);
11690 return %_ArrayBufferViewGetByteLength(this);
11692 function Float64Array_GetByteOffset(){
11693 if(!(%_ClassOf(this)==='Float64Array')){
11694 throw MakeTypeError(8,"Float64Array.byteOffset",this);
11696 return %_ArrayBufferViewGetByteOffset(this);
11698 function Float64Array_GetLength(){
11699 if(!(%_ClassOf(this)==='Float64Array')){
11700 throw MakeTypeError(8,"Float64Array.length",this);
11702 return %_TypedArrayGetLength(this);
11704 var L=global.Float64Array;
11705 function Float64ArraySubArray(w,z){
11706 if(!(%_ClassOf(this)==='Float64Array')){
11707 throw MakeTypeError(8,"Float64Array.subarray",this);
11709 var A=(%_IsSmi(%IS_VAR(w))?w:%NumberToInteger(ToNumber(w)));
11710 if(!(z===(void 0))){
11711 z=(%_IsSmi(%IS_VAR(z))?z:%NumberToInteger(ToNumber(z)));
11713 var B=%_TypedArrayGetLength(this);
11719 var C=(z===(void 0))?B:z;
11730 %_ArrayBufferViewGetByteOffset(this)+A*8;
11731 return new L(%TypedArrayGetBuffer(this),
11735 function Uint8ClampedArrayConstructByArrayBuffer(c,d,e,g){
11736 if(!(e===(void 0))){
11738 ToPositiveInteger(e,"invalid_typed_array_length");
11740 if(!(g===(void 0))){
11741 g=ToPositiveInteger(g,"invalid_typed_array_length");
11743 var h=%_ArrayBufferGetByteLength(d);
11745 if((e===(void 0))){
11750 throw MakeRangeError("invalid_typed_array_alignment",
11751 ["start offset","Uint8ClampedArray",1]);
11754 throw MakeRangeError("invalid_typed_array_offset");
11759 if((g===(void 0))){
11761 throw MakeRangeError("invalid_typed_array_alignment",
11762 ["byte length","Uint8ClampedArray",1]);
11772 throw MakeRangeError("invalid_typed_array_length");
11774 %_TypedArrayInitialize(c,9,d,i,j);
11776 function Uint8ClampedArrayConstructByLength(c,g){
11777 var l=(g===(void 0))?
11778 0:ToPositiveInteger(g,"invalid_typed_array_length");
11780 throw MakeRangeError("invalid_typed_array_length");
11783 if(m>%_TypedArrayMaxSizeInHeap()){
11785 %_TypedArrayInitialize(c,9,d,0,m);
11787 %_TypedArrayInitialize(c,9,null,0,m);
11790 function Uint8ClampedArrayConstructByArrayLike(c,n){
11792 var l=ToPositiveInteger(g,"invalid_typed_array_length");
11794 throw MakeRangeError("invalid_typed_array_length");
11796 if(!%TypedArrayInitializeFromArrayLike(c,9,n,l)){
11797 for(var o=0;o<l;o++){
11802 function Uint8ClampedArrayConstructor(q,r,t){
11803 if(%_IsConstructCall()){
11804 if((%_ClassOf(q)==='ArrayBuffer')){
11805 Uint8ClampedArrayConstructByArrayBuffer(this,q,r,t);
11806 }else if((typeof(q)==='number')||(typeof(q)==='string')||
11807 (typeof(q)==='boolean')||(q===(void 0))){
11808 Uint8ClampedArrayConstructByLength(this,q);
11810 Uint8ClampedArrayConstructByArrayLike(this,q);
11813 throw MakeTypeError("constructor_not_function",["Uint8ClampedArray"])
11816 function Uint8ClampedArray_GetBuffer(){
11817 if(!(%_ClassOf(this)==='Uint8ClampedArray')){
11818 throw MakeTypeError(8,"Uint8ClampedArray.buffer",this);
11820 return %TypedArrayGetBuffer(this);
11822 function Uint8ClampedArray_GetByteLength(){
11823 if(!(%_ClassOf(this)==='Uint8ClampedArray')){
11824 throw MakeTypeError(8,"Uint8ClampedArray.byteLength",this);
11826 return %_ArrayBufferViewGetByteLength(this);
11828 function Uint8ClampedArray_GetByteOffset(){
11829 if(!(%_ClassOf(this)==='Uint8ClampedArray')){
11830 throw MakeTypeError(8,"Uint8ClampedArray.byteOffset",this);
11832 return %_ArrayBufferViewGetByteOffset(this);
11834 function Uint8ClampedArray_GetLength(){
11835 if(!(%_ClassOf(this)==='Uint8ClampedArray')){
11836 throw MakeTypeError(8,"Uint8ClampedArray.length",this);
11838 return %_TypedArrayGetLength(this);
11840 var M=global.Uint8ClampedArray;
11841 function Uint8ClampedArraySubArray(w,z){
11842 if(!(%_ClassOf(this)==='Uint8ClampedArray')){
11843 throw MakeTypeError(8,"Uint8ClampedArray.subarray",this);
11845 var A=(%_IsSmi(%IS_VAR(w))?w:%NumberToInteger(ToNumber(w)));
11846 if(!(z===(void 0))){
11847 z=(%_IsSmi(%IS_VAR(z))?z:%NumberToInteger(ToNumber(z)));
11849 var B=%_TypedArrayGetLength(this);
11855 var C=(z===(void 0))?B:z;
11866 %_ArrayBufferViewGetByteOffset(this)+A*1;
11867 return new M(%TypedArrayGetBuffer(this),
11872 function TypedArraySetFromArrayLike(N,P,Q,i){
11874 for(var o=0;o<Q;o++){
11879 for(var o=0;o<Q;o++){
11884 function TypedArraySetFromOverlappingTypedArray(N,P,i){
11885 var R=P.BYTES_PER_ELEMENT;
11886 var S=N.BYTES_PER_ELEMENT;
11888 function CopyLeftPart(){
11889 var T=N.byteOffset+(i+1)*S;
11890 var U=P.byteOffset;
11900 var W=CopyLeftPart();
11901 function CopyRightPart(){
11903 N.byteOffset+(i+Q-1)*S;
11915 var X=CopyRightPart();
11916 var Y=new a(X+1-W);
11917 for(var o=W;o<=X;o++){
11924 function TypedArraySet(c,i){
11925 var Z=(i===(void 0))?0:(%_IsSmi(%IS_VAR(i))?i:%NumberToInteger(ToNumber(i)));
11927 throw MakeTypeError("typed_array_set_negative_offset");
11930 throw MakeRangeError("typed_array_set_source_too_large");
11932 switch(%TypedArraySetFastCases(this,c,Z)){
11936 TypedArraySetFromOverlappingTypedArray(this,c,Z);
11939 TypedArraySetFromArrayLike(this,c,c.length,Z);
11943 if((l===(void 0))){
11944 if((typeof(c)==='number')){
11945 throw MakeTypeError("invalid_argument");
11949 if(Z+l>this.length){
11950 throw MakeRangeError("typed_array_set_source_too_large");
11952 TypedArraySetFromArrayLike(this,c,l,Z);
11956 function TypedArrayGetToStringTag(){
11957 if(!%IsTypedArray(this))return;
11958 var aa=%_ClassOf(this);
11959 if((aa===(void 0)))return;
11962 %SetCode(global.Uint8Array,Uint8ArrayConstructor);
11963 %FunctionSetPrototype(global.Uint8Array,new $Object());
11964 %AddNamedProperty(global.Uint8Array,"BYTES_PER_ELEMENT",1,
11966 %AddNamedProperty(global.Uint8Array.prototype,
11967 "constructor",global.Uint8Array,2);
11968 %AddNamedProperty(global.Uint8Array.prototype,
11969 "BYTES_PER_ELEMENT",1,
11971 InstallGetter(global.Uint8Array.prototype,"buffer",Uint8Array_GetBuffer);
11972 InstallGetter(global.Uint8Array.prototype,"byteOffset",Uint8Array_GetByteOffset,
11974 InstallGetter(global.Uint8Array.prototype,"byteLength",Uint8Array_GetByteLength,
11976 InstallGetter(global.Uint8Array.prototype,"length",Uint8Array_GetLength,
11978 InstallGetter(global.Uint8Array.prototype,symbolToStringTag,
11979 TypedArrayGetToStringTag);
11980 InstallFunctions(global.Uint8Array.prototype,2,[
11981 "subarray",Uint8ArraySubArray,
11982 "set",TypedArraySet
11985 %SetCode(global.Int8Array,Int8ArrayConstructor);
11986 %FunctionSetPrototype(global.Int8Array,new $Object());
11987 %AddNamedProperty(global.Int8Array,"BYTES_PER_ELEMENT",1,
11989 %AddNamedProperty(global.Int8Array.prototype,
11990 "constructor",global.Int8Array,2);
11991 %AddNamedProperty(global.Int8Array.prototype,
11992 "BYTES_PER_ELEMENT",1,
11994 InstallGetter(global.Int8Array.prototype,"buffer",Int8Array_GetBuffer);
11995 InstallGetter(global.Int8Array.prototype,"byteOffset",Int8Array_GetByteOffset,
11997 InstallGetter(global.Int8Array.prototype,"byteLength",Int8Array_GetByteLength,
11999 InstallGetter(global.Int8Array.prototype,"length",Int8Array_GetLength,
12001 InstallGetter(global.Int8Array.prototype,symbolToStringTag,
12002 TypedArrayGetToStringTag);
12003 InstallFunctions(global.Int8Array.prototype,2,[
12004 "subarray",Int8ArraySubArray,
12005 "set",TypedArraySet
12008 %SetCode(global.Uint16Array,Uint16ArrayConstructor);
12009 %FunctionSetPrototype(global.Uint16Array,new $Object());
12010 %AddNamedProperty(global.Uint16Array,"BYTES_PER_ELEMENT",2,
12012 %AddNamedProperty(global.Uint16Array.prototype,
12013 "constructor",global.Uint16Array,2);
12014 %AddNamedProperty(global.Uint16Array.prototype,
12015 "BYTES_PER_ELEMENT",2,
12017 InstallGetter(global.Uint16Array.prototype,"buffer",Uint16Array_GetBuffer);
12018 InstallGetter(global.Uint16Array.prototype,"byteOffset",Uint16Array_GetByteOffset,
12020 InstallGetter(global.Uint16Array.prototype,"byteLength",Uint16Array_GetByteLength,
12022 InstallGetter(global.Uint16Array.prototype,"length",Uint16Array_GetLength,
12024 InstallGetter(global.Uint16Array.prototype,symbolToStringTag,
12025 TypedArrayGetToStringTag);
12026 InstallFunctions(global.Uint16Array.prototype,2,[
12027 "subarray",Uint16ArraySubArray,
12028 "set",TypedArraySet
12031 %SetCode(global.Int16Array,Int16ArrayConstructor);
12032 %FunctionSetPrototype(global.Int16Array,new $Object());
12033 %AddNamedProperty(global.Int16Array,"BYTES_PER_ELEMENT",2,
12035 %AddNamedProperty(global.Int16Array.prototype,
12036 "constructor",global.Int16Array,2);
12037 %AddNamedProperty(global.Int16Array.prototype,
12038 "BYTES_PER_ELEMENT",2,
12040 InstallGetter(global.Int16Array.prototype,"buffer",Int16Array_GetBuffer);
12041 InstallGetter(global.Int16Array.prototype,"byteOffset",Int16Array_GetByteOffset,
12043 InstallGetter(global.Int16Array.prototype,"byteLength",Int16Array_GetByteLength,
12045 InstallGetter(global.Int16Array.prototype,"length",Int16Array_GetLength,
12047 InstallGetter(global.Int16Array.prototype,symbolToStringTag,
12048 TypedArrayGetToStringTag);
12049 InstallFunctions(global.Int16Array.prototype,2,[
12050 "subarray",Int16ArraySubArray,
12051 "set",TypedArraySet
12054 %SetCode(global.Uint32Array,Uint32ArrayConstructor);
12055 %FunctionSetPrototype(global.Uint32Array,new $Object());
12056 %AddNamedProperty(global.Uint32Array,"BYTES_PER_ELEMENT",4,
12058 %AddNamedProperty(global.Uint32Array.prototype,
12059 "constructor",global.Uint32Array,2);
12060 %AddNamedProperty(global.Uint32Array.prototype,
12061 "BYTES_PER_ELEMENT",4,
12063 InstallGetter(global.Uint32Array.prototype,"buffer",Uint32Array_GetBuffer);
12064 InstallGetter(global.Uint32Array.prototype,"byteOffset",Uint32Array_GetByteOffset,
12066 InstallGetter(global.Uint32Array.prototype,"byteLength",Uint32Array_GetByteLength,
12068 InstallGetter(global.Uint32Array.prototype,"length",Uint32Array_GetLength,
12070 InstallGetter(global.Uint32Array.prototype,symbolToStringTag,
12071 TypedArrayGetToStringTag);
12072 InstallFunctions(global.Uint32Array.prototype,2,[
12073 "subarray",Uint32ArraySubArray,
12074 "set",TypedArraySet
12077 %SetCode(global.Int32Array,Int32ArrayConstructor);
12078 %FunctionSetPrototype(global.Int32Array,new $Object());
12079 %AddNamedProperty(global.Int32Array,"BYTES_PER_ELEMENT",4,
12081 %AddNamedProperty(global.Int32Array.prototype,
12082 "constructor",global.Int32Array,2);
12083 %AddNamedProperty(global.Int32Array.prototype,
12084 "BYTES_PER_ELEMENT",4,
12086 InstallGetter(global.Int32Array.prototype,"buffer",Int32Array_GetBuffer);
12087 InstallGetter(global.Int32Array.prototype,"byteOffset",Int32Array_GetByteOffset,
12089 InstallGetter(global.Int32Array.prototype,"byteLength",Int32Array_GetByteLength,
12091 InstallGetter(global.Int32Array.prototype,"length",Int32Array_GetLength,
12093 InstallGetter(global.Int32Array.prototype,symbolToStringTag,
12094 TypedArrayGetToStringTag);
12095 InstallFunctions(global.Int32Array.prototype,2,[
12096 "subarray",Int32ArraySubArray,
12097 "set",TypedArraySet
12100 %SetCode(global.Float32Array,Float32ArrayConstructor);
12101 %FunctionSetPrototype(global.Float32Array,new $Object());
12102 %AddNamedProperty(global.Float32Array,"BYTES_PER_ELEMENT",4,
12104 %AddNamedProperty(global.Float32Array.prototype,
12105 "constructor",global.Float32Array,2);
12106 %AddNamedProperty(global.Float32Array.prototype,
12107 "BYTES_PER_ELEMENT",4,
12109 InstallGetter(global.Float32Array.prototype,"buffer",Float32Array_GetBuffer);
12110 InstallGetter(global.Float32Array.prototype,"byteOffset",Float32Array_GetByteOffset,
12112 InstallGetter(global.Float32Array.prototype,"byteLength",Float32Array_GetByteLength,
12114 InstallGetter(global.Float32Array.prototype,"length",Float32Array_GetLength,
12116 InstallGetter(global.Float32Array.prototype,symbolToStringTag,
12117 TypedArrayGetToStringTag);
12118 InstallFunctions(global.Float32Array.prototype,2,[
12119 "subarray",Float32ArraySubArray,
12120 "set",TypedArraySet
12123 %SetCode(global.Float64Array,Float64ArrayConstructor);
12124 %FunctionSetPrototype(global.Float64Array,new $Object());
12125 %AddNamedProperty(global.Float64Array,"BYTES_PER_ELEMENT",8,
12127 %AddNamedProperty(global.Float64Array.prototype,
12128 "constructor",global.Float64Array,2);
12129 %AddNamedProperty(global.Float64Array.prototype,
12130 "BYTES_PER_ELEMENT",8,
12132 InstallGetter(global.Float64Array.prototype,"buffer",Float64Array_GetBuffer);
12133 InstallGetter(global.Float64Array.prototype,"byteOffset",Float64Array_GetByteOffset,
12135 InstallGetter(global.Float64Array.prototype,"byteLength",Float64Array_GetByteLength,
12137 InstallGetter(global.Float64Array.prototype,"length",Float64Array_GetLength,
12139 InstallGetter(global.Float64Array.prototype,symbolToStringTag,
12140 TypedArrayGetToStringTag);
12141 InstallFunctions(global.Float64Array.prototype,2,[
12142 "subarray",Float64ArraySubArray,
12143 "set",TypedArraySet
12146 %SetCode(global.Uint8ClampedArray,Uint8ClampedArrayConstructor);
12147 %FunctionSetPrototype(global.Uint8ClampedArray,new $Object());
12148 %AddNamedProperty(global.Uint8ClampedArray,"BYTES_PER_ELEMENT",1,
12150 %AddNamedProperty(global.Uint8ClampedArray.prototype,
12151 "constructor",global.Uint8ClampedArray,2);
12152 %AddNamedProperty(global.Uint8ClampedArray.prototype,
12153 "BYTES_PER_ELEMENT",1,
12155 InstallGetter(global.Uint8ClampedArray.prototype,"buffer",Uint8ClampedArray_GetBuffer);
12156 InstallGetter(global.Uint8ClampedArray.prototype,"byteOffset",Uint8ClampedArray_GetByteOffset,
12158 InstallGetter(global.Uint8ClampedArray.prototype,"byteLength",Uint8ClampedArray_GetByteLength,
12160 InstallGetter(global.Uint8ClampedArray.prototype,"length",Uint8ClampedArray_GetLength,
12162 InstallGetter(global.Uint8ClampedArray.prototype,symbolToStringTag,
12163 TypedArrayGetToStringTag);
12164 InstallFunctions(global.Uint8ClampedArray.prototype,2,[
12165 "subarray",Uint8ClampedArraySubArray,
12166 "set",TypedArraySet
12170 var ab=global.DataView;
12171 function DataViewConstructor(d,e,m){
12172 if(%_IsConstructCall()){
12173 if(!(%_ClassOf(d)==='ArrayBuffer')){
12174 throw MakeTypeError('data_view_not_array_buffer',[]);
12176 if(!(e===(void 0))){
12177 e=ToPositiveInteger(e,'invalid_data_view_offset');
12179 if(!(m===(void 0))){
12180 m=(%_IsSmi(%IS_VAR(m))?m:%NumberToInteger(ToNumber(m)));
12182 var h=%_ArrayBufferGetByteLength(d);
12183 var i=(e===(void 0))?0:e;
12185 throw MakeRangeError('invalid_data_view_offset');
12187 var g=(m===(void 0))
12191 throw new MakeRangeError('invalid_data_view_length');
12193 %_DataViewInitialize(this,d,i,g);
12195 throw MakeTypeError('constructor_not_function',["DataView"]);
12198 function DataViewGetBufferJS(){
12199 if(!(%_ClassOf(this)==='DataView')){
12200 throw MakeTypeError(8,'DataView.buffer',this);
12202 return %DataViewGetBuffer(this);
12204 function DataViewGetByteOffset(){
12205 if(!(%_ClassOf(this)==='DataView')){
12206 throw MakeTypeError(8,
12207 'DataView.byteOffset',this);
12209 return %_ArrayBufferViewGetByteOffset(this);
12211 function DataViewGetByteLength(){
12212 if(!(%_ClassOf(this)==='DataView')){
12213 throw MakeTypeError(8,
12214 'DataView.byteLength',this);
12216 return %_ArrayBufferViewGetByteLength(this);
12218 function ToPositiveDataViewOffset(i){
12219 return ToPositiveInteger(i,'invalid_data_view_accessor_offset');
12221 function DataViewGetInt8JS(i,ac){
12222 if(!(%_ClassOf(this)==='DataView')){
12223 throw MakeTypeError(8,
12224 'DataView.getInt8',this);
12226 if(%_ArgumentsLength()<1){
12227 throw MakeTypeError('invalid_argument');
12229 return %DataViewGetInt8(this,
12230 ToPositiveDataViewOffset(i),
12233 function DataViewSetInt8JS(i,ad,ac){
12234 if(!(%_ClassOf(this)==='DataView')){
12235 throw MakeTypeError(8,
12236 'DataView.setInt8',this);
12238 if(%_ArgumentsLength()<2){
12239 throw MakeTypeError('invalid_argument');
12241 %DataViewSetInt8(this,
12242 ToPositiveDataViewOffset(i),
12243 ((typeof(%IS_VAR(ad))==='number')?ad:NonNumberToNumber(ad)),
12247 function DataViewGetUint8JS(i,ac){
12248 if(!(%_ClassOf(this)==='DataView')){
12249 throw MakeTypeError(8,
12250 'DataView.getUint8',this);
12252 if(%_ArgumentsLength()<1){
12253 throw MakeTypeError('invalid_argument');
12255 return %DataViewGetUint8(this,
12256 ToPositiveDataViewOffset(i),
12259 function DataViewSetUint8JS(i,ad,ac){
12260 if(!(%_ClassOf(this)==='DataView')){
12261 throw MakeTypeError(8,
12262 'DataView.setUint8',this);
12264 if(%_ArgumentsLength()<2){
12265 throw MakeTypeError('invalid_argument');
12267 %DataViewSetUint8(this,
12268 ToPositiveDataViewOffset(i),
12269 ((typeof(%IS_VAR(ad))==='number')?ad:NonNumberToNumber(ad)),
12273 function DataViewGetInt16JS(i,ac){
12274 if(!(%_ClassOf(this)==='DataView')){
12275 throw MakeTypeError(8,
12276 'DataView.getInt16',this);
12278 if(%_ArgumentsLength()<1){
12279 throw MakeTypeError('invalid_argument');
12281 return %DataViewGetInt16(this,
12282 ToPositiveDataViewOffset(i),
12285 function DataViewSetInt16JS(i,ad,ac){
12286 if(!(%_ClassOf(this)==='DataView')){
12287 throw MakeTypeError(8,
12288 'DataView.setInt16',this);
12290 if(%_ArgumentsLength()<2){
12291 throw MakeTypeError('invalid_argument');
12293 %DataViewSetInt16(this,
12294 ToPositiveDataViewOffset(i),
12295 ((typeof(%IS_VAR(ad))==='number')?ad:NonNumberToNumber(ad)),
12299 function DataViewGetUint16JS(i,ac){
12300 if(!(%_ClassOf(this)==='DataView')){
12301 throw MakeTypeError(8,
12302 'DataView.getUint16',this);
12304 if(%_ArgumentsLength()<1){
12305 throw MakeTypeError('invalid_argument');
12307 return %DataViewGetUint16(this,
12308 ToPositiveDataViewOffset(i),
12311 function DataViewSetUint16JS(i,ad,ac){
12312 if(!(%_ClassOf(this)==='DataView')){
12313 throw MakeTypeError(8,
12314 'DataView.setUint16',this);
12316 if(%_ArgumentsLength()<2){
12317 throw MakeTypeError('invalid_argument');
12319 %DataViewSetUint16(this,
12320 ToPositiveDataViewOffset(i),
12321 ((typeof(%IS_VAR(ad))==='number')?ad:NonNumberToNumber(ad)),
12325 function DataViewGetInt32JS(i,ac){
12326 if(!(%_ClassOf(this)==='DataView')){
12327 throw MakeTypeError(8,
12328 'DataView.getInt32',this);
12330 if(%_ArgumentsLength()<1){
12331 throw MakeTypeError('invalid_argument');
12333 return %DataViewGetInt32(this,
12334 ToPositiveDataViewOffset(i),
12337 function DataViewSetInt32JS(i,ad,ac){
12338 if(!(%_ClassOf(this)==='DataView')){
12339 throw MakeTypeError(8,
12340 'DataView.setInt32',this);
12342 if(%_ArgumentsLength()<2){
12343 throw MakeTypeError('invalid_argument');
12345 %DataViewSetInt32(this,
12346 ToPositiveDataViewOffset(i),
12347 ((typeof(%IS_VAR(ad))==='number')?ad:NonNumberToNumber(ad)),
12351 function DataViewGetUint32JS(i,ac){
12352 if(!(%_ClassOf(this)==='DataView')){
12353 throw MakeTypeError(8,
12354 'DataView.getUint32',this);
12356 if(%_ArgumentsLength()<1){
12357 throw MakeTypeError('invalid_argument');
12359 return %DataViewGetUint32(this,
12360 ToPositiveDataViewOffset(i),
12363 function DataViewSetUint32JS(i,ad,ac){
12364 if(!(%_ClassOf(this)==='DataView')){
12365 throw MakeTypeError(8,
12366 'DataView.setUint32',this);
12368 if(%_ArgumentsLength()<2){
12369 throw MakeTypeError('invalid_argument');
12371 %DataViewSetUint32(this,
12372 ToPositiveDataViewOffset(i),
12373 ((typeof(%IS_VAR(ad))==='number')?ad:NonNumberToNumber(ad)),
12377 function DataViewGetFloat32JS(i,ac){
12378 if(!(%_ClassOf(this)==='DataView')){
12379 throw MakeTypeError(8,
12380 'DataView.getFloat32',this);
12382 if(%_ArgumentsLength()<1){
12383 throw MakeTypeError('invalid_argument');
12385 return %DataViewGetFloat32(this,
12386 ToPositiveDataViewOffset(i),
12389 function DataViewSetFloat32JS(i,ad,ac){
12390 if(!(%_ClassOf(this)==='DataView')){
12391 throw MakeTypeError(8,
12392 'DataView.setFloat32',this);
12394 if(%_ArgumentsLength()<2){
12395 throw MakeTypeError('invalid_argument');
12397 %DataViewSetFloat32(this,
12398 ToPositiveDataViewOffset(i),
12399 ((typeof(%IS_VAR(ad))==='number')?ad:NonNumberToNumber(ad)),
12403 function DataViewGetFloat64JS(i,ac){
12404 if(!(%_ClassOf(this)==='DataView')){
12405 throw MakeTypeError(8,
12406 'DataView.getFloat64',this);
12408 if(%_ArgumentsLength()<1){
12409 throw MakeTypeError('invalid_argument');
12411 return %DataViewGetFloat64(this,
12412 ToPositiveDataViewOffset(i),
12415 function DataViewSetFloat64JS(i,ad,ac){
12416 if(!(%_ClassOf(this)==='DataView')){
12417 throw MakeTypeError(8,
12418 'DataView.setFloat64',this);
12420 if(%_ArgumentsLength()<2){
12421 throw MakeTypeError('invalid_argument');
12423 %DataViewSetFloat64(this,
12424 ToPositiveDataViewOffset(i),
12425 ((typeof(%IS_VAR(ad))==='number')?ad:NonNumberToNumber(ad)),
12430 %SetCode(ab,DataViewConstructor);
12431 %FunctionSetPrototype(ab,new $Object);
12432 %AddNamedProperty(ab.prototype,"constructor",ab,2);
12434 ab.prototype,symbolToStringTag,"DataView",1|2);
12435 InstallGetter(ab.prototype,"buffer",DataViewGetBufferJS);
12436 InstallGetter(ab.prototype,"byteOffset",DataViewGetByteOffset);
12437 InstallGetter(ab.prototype,"byteLength",DataViewGetByteLength);
12438 InstallFunctions(ab.prototype,2,[
12439 "getInt8",DataViewGetInt8JS,
12440 "setInt8",DataViewSetInt8JS,
12441 "getUint8",DataViewGetUint8JS,
12442 "setUint8",DataViewSetUint8JS,
12443 "getInt16",DataViewGetInt16JS,
12444 "setInt16",DataViewSetInt16JS,
12445 "getUint16",DataViewGetUint16JS,
12446 "setUint16",DataViewSetUint16JS,
12447 "getInt32",DataViewGetInt32JS,
12448 "setInt32",DataViewSetInt32JS,
12449 "getUint32",DataViewGetUint32JS,
12450 "setUint32",DataViewSetUint32JS,
12451 "getFloat32",DataViewGetFloat32JS,
12452 "setFloat32",DataViewSetFloat32JS,
12453 "getFloat64",DataViewGetFloat64JS,
12454 "setFloat64",DataViewSetFloat64JS
12461 %CheckIsBootstrapping();
12462 var a=global.Function;
12463 function GeneratorObjectNext(b){
12464 if(!(%_ClassOf(this)==='Generator')){
12465 throw MakeTypeError(8,
12466 '[Generator].prototype.next',this);
12468 var c=%GeneratorGetContinuation(this);
12470 if((%_DebugIsActive()!=0))%DebugPrepareStepInIfStepping(this);
12472 return %_GeneratorNext(this,b);
12474 %GeneratorClose(this);
12478 return{value:void 0,done:true};
12480 throw MakeTypeError(6);
12483 function GeneratorObjectThrow(d){
12484 if(!(%_ClassOf(this)==='Generator')){
12485 throw MakeTypeError(8,
12486 '[Generator].prototype.throw',this);
12488 var c=%GeneratorGetContinuation(this);
12491 return %_GeneratorThrow(this,d);
12493 %GeneratorClose(this);
12499 throw MakeTypeError(6);
12502 function GeneratorObjectIterator(){
12505 function GeneratorFunctionConstructor(e){
12506 var g=NewFunctionString(arguments,'function*');
12507 var h=%GlobalProxy(global);
12508 var i=%_CallFunction(h,%CompileString(g,true));
12509 %FunctionMarkNameShouldPrintAsAnonymous(i);
12512 %NeverOptimizeFunction(GeneratorObjectNext);
12513 %NeverOptimizeFunction(GeneratorObjectThrow);
12514 var j=GeneratorFunctionPrototype.prototype;
12515 InstallFunctions(j,
12517 ["next",GeneratorObjectNext,
12518 "throw",GeneratorObjectThrow]);
12519 %FunctionSetName(GeneratorObjectIterator,'[Symbol.iterator]');
12520 %AddNamedProperty(j,symbolIterator,
12521 GeneratorObjectIterator,2|4|1);
12522 %AddNamedProperty(j,"constructor",
12523 GeneratorFunctionPrototype,2|1);
12524 %AddNamedProperty(j,
12525 symbolToStringTag,"Generator",2|1);
12526 %InternalSetPrototype(GeneratorFunctionPrototype,a.prototype);
12527 %AddNamedProperty(GeneratorFunctionPrototype,
12528 symbolToStringTag,"GeneratorFunction",2|1);
12529 %AddNamedProperty(GeneratorFunctionPrototype,"constructor",
12530 GeneratorFunction,2|1);
12531 %InternalSetPrototype(GeneratorFunction,a);
12532 %SetCode(GeneratorFunction,GeneratorFunctionConstructor);
12536 var $observeNotifyChange;
12537 var $observeEnqueueSpliceRecord;
12538 var $observeBeginPerformSplice;
12539 var $observeEndPerformSplice;
12540 var $observeNativeObjectObserve;
12541 var $observeNativeObjectGetNotifier;
12542 var $observeNativeObjectNotifierPerformChange;
12545 %CheckIsBootstrapping();
12546 var a=global.Array;
12547 var b=global.Object;
12550 function GetObservationStateJS(){
12551 if((c===(void 0))){
12552 c=%GetObservationState();
12554 if((c.callbackInfoMap===(void 0))){
12555 c.callbackInfoMap=%ObservationWeakMapCreate();
12556 c.objectInfoMap=%ObservationWeakMapCreate();
12557 c.notifierObjectInfoMap=%ObservationWeakMapCreate();
12558 c.pendingObservers=null;
12559 c.nextCallbackPriority=0;
12560 c.lastMicrotaskId=0;
12564 function GetPendingObservers(){
12565 return GetObservationStateJS().pendingObservers;
12567 function SetPendingObservers(e){
12568 GetObservationStateJS().pendingObservers=e;
12570 function GetNextCallbackPriority(){
12571 return GetObservationStateJS().nextCallbackPriority++;
12573 function nullProtoObject(){
12574 return{__proto__:null};
12576 function TypeMapCreate(){
12577 return nullProtoObject();
12579 function TypeMapAddType(g,h,i){
12580 g[h]=i?1:(g[h]||0)+1;
12582 function TypeMapRemoveType(g,h){
12585 function TypeMapCreateFromList(j,k){
12586 var g=TypeMapCreate();
12587 for(var l=0;l<k;l++){
12588 TypeMapAddType(g,j[l],true);
12592 function TypeMapHasType(g,h){
12595 function TypeMapIsDisjointFrom(m,n){
12599 if(TypeMapHasType(m,h)&&TypeMapHasType(n,h))
12611 'preventExtensions'
12613 return TypeMapCreateFromList(q,q.length);
12615 function ObserverCreate(r,t){
12618 var u=nullProtoObject();
12623 function ObserverGetCallback(u){
12624 return(%_ClassOf(u)==='Function')?u:u.callback;
12626 function ObserverGetAcceptTypes(u){
12627 return(%_ClassOf(u)==='Function')?o:u.accept;
12629 function ObserverIsActive(u,w){
12630 return TypeMapIsDisjointFrom(ObjectInfoGetPerformingTypes(w),
12631 ObserverGetAcceptTypes(u));
12633 function ObjectInfoGetOrCreate(z){
12634 var w=ObjectInfoGet(z);
12635 if((w===(void 0))){
12636 if(!%_IsJSProxy(z)){
12641 changeObservers:null,
12646 %WeakCollectionSet(GetObservationStateJS().objectInfoMap,
12651 function ObjectInfoGet(z){
12652 return %WeakCollectionGet(GetObservationStateJS().objectInfoMap,z);
12654 function ObjectInfoGetFromNotifier(A){
12655 return %WeakCollectionGet(GetObservationStateJS().notifierObjectInfoMap,
12658 function ObjectInfoGetNotifier(w){
12659 if((w.notifier===null)){
12660 w.notifier={__proto__:d};
12661 %WeakCollectionSet(GetObservationStateJS().notifierObjectInfoMap,
12666 function ChangeObserversIsOptimized(B){
12667 return(%_ClassOf(B)==='Function')||
12668 (%_ClassOf(B.callback)==='Function');
12670 function ObjectInfoNormalizeChangeObservers(w){
12671 if(ChangeObserversIsOptimized(w.changeObservers)){
12672 var u=w.changeObservers;
12673 var r=ObserverGetCallback(u);
12674 var C=CallbackInfoGet(r);
12675 var D=CallbackInfoGetPriority(C);
12676 w.changeObservers=nullProtoObject();
12677 w.changeObservers[D]=u;
12680 function ObjectInfoAddObserver(w,r,t){
12681 var C=CallbackInfoGetOrCreate(r);
12682 var u=ObserverCreate(r,t);
12683 if(!w.changeObservers){
12684 w.changeObservers=u;
12687 ObjectInfoNormalizeChangeObservers(w);
12688 var D=CallbackInfoGetPriority(C);
12689 w.changeObservers[D]=u;
12691 function ObjectInfoRemoveObserver(w,r){
12692 if(!w.changeObservers)
12694 if(ChangeObserversIsOptimized(w.changeObservers)){
12695 if(r===ObserverGetCallback(w.changeObservers))
12696 w.changeObservers=null;
12699 var C=CallbackInfoGet(r);
12700 var D=CallbackInfoGetPriority(C);
12701 w.changeObservers[D]=null;
12703 function ObjectInfoHasActiveObservers(w){
12704 if((w===(void 0))||!w.changeObservers)
12706 if(ChangeObserversIsOptimized(w.changeObservers))
12707 return ObserverIsActive(w.changeObservers,w);
12708 for(var D in w.changeObservers){
12709 var u=w.changeObservers[D];
12710 if(!(u===null)&&ObserverIsActive(u,w))
12715 function ObjectInfoAddPerformingType(w,h){
12716 w.performing=w.performing||TypeMapCreate();
12717 TypeMapAddType(w.performing,h);
12718 w.performingCount++;
12720 function ObjectInfoRemovePerformingType(w,h){
12721 w.performingCount--;
12722 TypeMapRemoveType(w.performing,h);
12724 function ObjectInfoGetPerformingTypes(w){
12725 return w.performingCount>0?w.performing:null;
12727 function ConvertAcceptListToTypeMap(E){
12730 if(!(%_IsSpecObject(E)))
12731 throw MakeTypeError("observe_invalid_accept");
12732 var G=ToInteger(E.length);
12734 return TypeMapCreateFromList(E,G);
12736 function CallbackInfoGet(r){
12737 return %WeakCollectionGet(GetObservationStateJS().callbackInfoMap,r);
12739 function CallbackInfoSet(r,C){
12740 %WeakCollectionSet(GetObservationStateJS().callbackInfoMap,
12743 function CallbackInfoGetOrCreate(r){
12744 var C=CallbackInfoGet(r);
12745 if(!(C===(void 0)))
12747 var D=GetNextCallbackPriority();
12748 CallbackInfoSet(r,D);
12751 function CallbackInfoGetPriority(C){
12752 if((typeof(C)==='number'))
12757 function CallbackInfoNormalize(r){
12758 var C=CallbackInfoGet(r);
12759 if((typeof(C)==='number')){
12761 C=new InternalArray;
12763 CallbackInfoSet(r,C);
12767 function ObjectObserve(z,r,t){
12768 if(!(%_IsSpecObject(z)))
12769 throw MakeTypeError("observe_non_object",["observe"]);
12770 if(%IsJSGlobalProxy(z))
12771 throw MakeTypeError("observe_global_proxy",["observe"]);
12772 if(!(%_ClassOf(r)==='Function'))
12773 throw MakeTypeError("observe_non_function",["observe"]);
12774 if(ObjectIsFrozen(r))
12775 throw MakeTypeError("observe_callback_frozen");
12776 var H=%GetObjectContextObjectObserve(z);
12779 function NativeObjectObserve(z,r,t){
12780 var w=ObjectInfoGetOrCreate(z);
12781 var j=ConvertAcceptListToTypeMap(t);
12782 ObjectInfoAddObserver(w,r,j);
12785 function ObjectUnobserve(z,r){
12786 if(!(%_IsSpecObject(z)))
12787 throw MakeTypeError("observe_non_object",["unobserve"]);
12788 if(%IsJSGlobalProxy(z))
12789 throw MakeTypeError("observe_global_proxy",["unobserve"]);
12790 if(!(%_ClassOf(r)==='Function'))
12791 throw MakeTypeError("observe_non_function",["unobserve"]);
12792 var w=ObjectInfoGet(z);
12795 ObjectInfoRemoveObserver(w,r);
12798 function ArrayObserve(z,r){
12799 return ObjectObserve(z,r,['add',
12804 function ArrayUnobserve(z,r){
12805 return ObjectUnobserve(z,r);
12807 function ObserverEnqueueIfActive(u,w,I){
12808 if(!ObserverIsActive(u,w)||
12809 !TypeMapHasType(ObserverGetAcceptTypes(u),I.type)){
12812 var r=ObserverGetCallback(u);
12813 if(!%ObserverObjectAndRecordHaveSameOrigin(r,I.object,
12817 var C=CallbackInfoNormalize(r);
12818 if((GetPendingObservers()===null)){
12819 SetPendingObservers(nullProtoObject());
12820 if((%_DebugIsActive()!=0)){
12821 var J=++GetObservationStateJS().lastMicrotaskId;
12822 var K="Object.observe";
12823 %EnqueueMicrotask(function(){
12824 %DebugAsyncTaskEvent({type:"willHandle",id:J,name:K});
12825 ObserveMicrotaskRunner();
12826 %DebugAsyncTaskEvent({type:"didHandle",id:J,name:K});
12828 %DebugAsyncTaskEvent({type:"enqueue",id:J,name:K});
12830 %EnqueueMicrotask(ObserveMicrotaskRunner);
12833 GetPendingObservers()[C.priority]=r;
12836 function ObjectInfoEnqueueExternalChangeRecord(w,I,h){
12837 if(!ObjectInfoHasActiveObservers(w))
12839 var L=!(h===(void 0));
12841 {object:w.object,type:h}:
12844 if(N==='object'||(L&&N==='type'))continue;
12845 %DefineDataPropertyUnchecked(
12849 ObjectInfoEnqueueInternalChangeRecord(w,M);
12851 function ObjectInfoEnqueueInternalChangeRecord(w,I){
12852 if((typeof(I.name)==='symbol'))return;
12853 if(ChangeObserversIsOptimized(w.changeObservers)){
12854 var u=w.changeObservers;
12855 ObserverEnqueueIfActive(u,w,I);
12858 for(var D in w.changeObservers){
12859 var u=w.changeObservers[D];
12862 ObserverEnqueueIfActive(u,w,I);
12865 function BeginPerformSplice(P){
12866 var w=ObjectInfoGet(P);
12867 if(!(w===(void 0)))
12868 ObjectInfoAddPerformingType(w,'splice');
12870 function EndPerformSplice(P){
12871 var w=ObjectInfoGet(P);
12872 if(!(w===(void 0)))
12873 ObjectInfoRemovePerformingType(w,'splice');
12875 function EnqueueSpliceRecord(P,Q,R,S){
12876 var w=ObjectInfoGet(P);
12877 if(!ObjectInfoHasActiveObservers(w))
12887 ObjectFreezeJS(I.removed);
12888 ObjectInfoEnqueueInternalChangeRecord(w,I);
12890 function NotifyChange(h,z,K,T){
12891 var w=ObjectInfoGet(z);
12892 if(!ObjectInfoHasActiveObservers(w))
12895 if(arguments.length==2){
12896 I={type:h,object:z};
12897 }else if(arguments.length==3){
12898 I={type:h,object:z,name:K};
12908 ObjectInfoEnqueueInternalChangeRecord(w,I);
12910 function ObjectNotifierNotify(I){
12911 if(!(%_IsSpecObject(this)))
12912 throw MakeTypeError(3,"notify");
12913 var w=ObjectInfoGetFromNotifier(this);
12915 throw MakeTypeError("observe_notify_non_notifier");
12916 if(!(typeof(I.type)==='string'))
12917 throw MakeTypeError("observe_type_non_string");
12918 ObjectInfoEnqueueExternalChangeRecord(w,I);
12920 function ObjectNotifierPerformChange(U,W){
12921 if(!(%_IsSpecObject(this)))
12922 throw MakeTypeError(3,"performChange");
12923 var w=ObjectInfoGetFromNotifier(this);
12925 throw MakeTypeError("observe_notify_non_notifier");
12926 if(!(typeof(U)==='string'))
12927 throw MakeTypeError("observe_perform_non_string");
12928 if(!(%_ClassOf(W)==='Function'))
12929 throw MakeTypeError("observe_perform_non_function");
12930 var X=%GetObjectContextNotifierPerformChange(w);
12933 function NativeObjectNotifierPerformChange(w,U,W){
12934 ObjectInfoAddPerformingType(w,U);
12937 I=%_CallFunction((void 0),W);
12939 ObjectInfoRemovePerformingType(w,U);
12941 if((%_IsSpecObject(I)))
12942 ObjectInfoEnqueueExternalChangeRecord(w,I,U);
12944 function ObjectGetNotifier(z){
12945 if(!(%_IsSpecObject(z)))
12946 throw MakeTypeError("observe_non_object",["getNotifier"]);
12947 if(%IsJSGlobalProxy(z))
12948 throw MakeTypeError("observe_global_proxy",["getNotifier"]);
12949 if(ObjectIsFrozen(z))return null;
12950 if(!%ObjectWasCreatedInCurrentOrigin(z))return null;
12951 var Y=%GetObjectContextObjectGetNotifier(z);
12954 function NativeObjectGetNotifier(z){
12955 var w=ObjectInfoGetOrCreate(z);
12956 return ObjectInfoGetNotifier(w);
12958 function CallbackDeliverPending(r){
12959 var C=CallbackInfoGet(r);
12960 if((C===(void 0))||(typeof(C)==='number'))
12963 CallbackInfoSet(r,D);
12964 var e=GetPendingObservers();
12968 %MoveArrayContents(C,Z);
12969 %DeliverObservationChangeRecords(r,Z);
12972 function ObjectDeliverChangeRecords(r){
12973 if(!(%_ClassOf(r)==='Function'))
12974 throw MakeTypeError("observe_non_function",["deliverChangeRecords"]);
12975 while(CallbackDeliverPending(r)){}
12977 function ObserveMicrotaskRunner(){
12978 var e=GetPendingObservers();
12980 SetPendingObservers(null);
12982 CallbackDeliverPending(e[l]);
12986 InstallFunctions(b,2,[
12987 "deliverChangeRecords",ObjectDeliverChangeRecords,
12988 "getNotifier",ObjectGetNotifier,
12989 "observe",ObjectObserve,
12990 "unobserve",ObjectUnobserve
12992 InstallFunctions(a,2,[
12993 "observe",ArrayObserve,
12994 "unobserve",ArrayUnobserve
12996 InstallFunctions(d,2,[
12997 "notify",ObjectNotifierNotify,
12998 "performChange",ObjectNotifierPerformChange
13000 $observeNotifyChange=NotifyChange;
13001 $observeEnqueueSpliceRecord=EnqueueSpliceRecord;
13002 $observeBeginPerformSplice=BeginPerformSplice;
13003 $observeEndPerformSplice=EndPerformSplice;
13004 $observeNativeObjectObserve=NativeObjectObserve;
13005 $observeNativeObjectGetNotifier=NativeObjectGetNotifier;
13006 $observeNativeObjectNotifierPerformChange=NativeObjectNotifierPerformChange;
13012 %CheckIsBootstrapping();
13014 var b=global.Object;
13016 function HashToEntry(d,e,g){
13018 return((%_FixedArrayGet(d,(3+(h))|0)));
13020 %SetInlineBuiltinFlag(HashToEntry);
13021 function SetFindEntry(d,g,i,e){
13022 var j=NumberIsNaN(i);
13023 for(var k=HashToEntry(d,e,g);
13025 k=((%_FixedArrayGet(d,((3+(g)+((k)<<1))+1)|0)))){
13026 var l=((%_FixedArrayGet(d,((3+(g)+((k)<<1)))|0)));
13030 if(j&&NumberIsNaN(l)){
13036 %SetInlineBuiltinFlag(SetFindEntry);
13037 function MapFindEntry(d,g,i,e){
13038 var j=NumberIsNaN(i);
13039 for(var k=HashToEntry(d,e,g);
13041 k=((%_FixedArrayGet(d,((3+(g)+((k)*3))+2)|0)))){
13042 var l=((%_FixedArrayGet(d,((3+(g)+((k)*3)))|0)));
13046 if(j&&NumberIsNaN(l)){
13052 %SetInlineBuiltinFlag(MapFindEntry);
13053 function ComputeIntegerHash(i,m){
13064 %SetInlineBuiltinFlag(ComputeIntegerHash);
13065 function GetHash(i){
13067 return ComputeIntegerHash(i,0);
13069 if((typeof(i)==='string')){
13070 var n=%_StringGetRawHashField(i);
13075 return %GenericHash(i);
13077 %SetInlineBuiltinFlag(GetHash);
13078 function SetConstructor(o){
13079 if(!%_IsConstructCall()){
13080 throw MakeTypeError('constructor_not_function',['Set']);
13082 %_SetInitialize(this);
13085 if(!(%_ClassOf(q)==='Function')){
13086 throw MakeTypeError(21,'add',this);
13089 %_CallFunction(this,r,q);
13093 function SetAdd(i){
13094 if(!(%_ClassOf(this)==='Set')){
13095 throw MakeTypeError(8,'Set.prototype.add',this);
13100 var d=%_JSCollectionGetTable(this);
13101 var g=((%_FixedArrayGet(d,(0)|0)));
13103 if(SetFindEntry(d,g,i,e)!==-1)return this;
13104 var t=((%_FixedArrayGet(d,(1)|0)));
13105 var u=((%_FixedArrayGet(d,(2)|0)));
13109 d=%_JSCollectionGetTable(this);
13110 g=((%_FixedArrayGet(d,(0)|0)));
13111 t=((%_FixedArrayGet(d,(1)|0)));
13112 u=((%_FixedArrayGet(d,(2)|0)));
13115 var z=(3+(g)+((k)<<1));
13117 var A=((%_FixedArrayGet(d,(3+(h))|0)));
13118 ((%_FixedArraySet(d,(3+(h))|0,k)));
13119 (((%_FixedArraySet(d,(1)|0,(t+1)|0))));
13120 (%_FixedArraySet(d,(z)|0,i));
13121 ((%_FixedArraySet(d,(z+1)|0,(A)|0)));
13124 function SetHas(i){
13125 if(!(%_ClassOf(this)==='Set')){
13126 throw MakeTypeError(8,'Set.prototype.has',this);
13128 var d=%_JSCollectionGetTable(this);
13129 var g=((%_FixedArrayGet(d,(0)|0)));
13131 return SetFindEntry(d,g,i,e)!==-1;
13133 function SetDelete(i){
13134 if(!(%_ClassOf(this)==='Set')){
13135 throw MakeTypeError(8,
13136 'Set.prototype.delete',this);
13138 var d=%_JSCollectionGetTable(this);
13139 var g=((%_FixedArrayGet(d,(0)|0)));
13141 var k=SetFindEntry(d,g,i,e);
13142 if(k===-1)return false;
13143 var t=((%_FixedArrayGet(d,(1)|0)))-1;
13144 var u=((%_FixedArrayGet(d,(2)|0)))+1;
13145 var z=(3+(g)+((k)<<1));
13146 (%_FixedArraySet(d,(z)|0,%_TheHole()));
13147 (((%_FixedArraySet(d,(1)|0,(t)|0))));
13148 (((%_FixedArraySet(d,(2)|0,(u)|0))));
13149 if(t<(g>>>1))%SetShrink(this);
13152 function SetGetSize(){
13153 if(!(%_ClassOf(this)==='Set')){
13154 throw MakeTypeError(8,
13155 'Set.prototype.size',this);
13157 var d=%_JSCollectionGetTable(this);
13158 return((%_FixedArrayGet(d,(1)|0)));
13160 function SetClearJS(){
13161 if(!(%_ClassOf(this)==='Set')){
13162 throw MakeTypeError(8,
13163 'Set.prototype.clear',this);
13167 function SetForEach(B,C){
13168 if(!(%_ClassOf(this)==='Set')){
13169 throw MakeTypeError(8,
13170 'Set.prototype.forEach',this);
13172 if(!(%_ClassOf(B)==='Function'))throw MakeTypeError(2,B);
13175 C=%GetDefaultReceiver(B)||C;
13177 D=(!(%_IsSpecObject(C))&&%IsSloppyModeFunction(B));
13179 var E=new SetIterator(this,2);
13181 var G=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(B);
13183 while(%SetIteratorNext(E,H)){
13184 if(G)%DebugPrepareStepInIfStepping(B);
13186 var I=D?ToObject(C):C;
13187 %_CallFunction(I,i,i,this,B);
13190 %SetCode(c,SetConstructor);
13191 %FunctionSetLength(c,0);
13192 %FunctionSetPrototype(c,new b());
13193 %AddNamedProperty(c.prototype,"constructor",c,2);
13194 %AddNamedProperty(c.prototype,symbolToStringTag,"Set",
13196 %FunctionSetLength(SetForEach,1);
13197 InstallGetter(c.prototype,"size",SetGetSize);
13198 InstallFunctions(c.prototype,2,[
13201 "delete",SetDelete,
13202 "clear",SetClearJS,
13203 "forEach",SetForEach
13205 function MapConstructor(o){
13206 if(!%_IsConstructCall()){
13207 throw MakeTypeError('constructor_not_function',['Map']);
13209 %_MapInitialize(this);
13212 if(!(%_ClassOf(q)==='Function')){
13213 throw MakeTypeError(21,'set',this);
13216 if(!(%_IsSpecObject(J))){
13217 throw MakeTypeError('iterator_value_not_an_object',[J]);
13219 %_CallFunction(this,J[0],J[1],q);
13223 function MapGet(i){
13224 if(!(%_ClassOf(this)==='Map')){
13225 throw MakeTypeError(8,
13226 'Map.prototype.get',this);
13228 var d=%_JSCollectionGetTable(this);
13229 var g=((%_FixedArrayGet(d,(0)|0)));
13231 var k=MapFindEntry(d,g,i,e);
13232 if(k===-1)return(void 0);
13233 return((%_FixedArrayGet(d,((3+(g)+((k)*3))+1)|0)));
13235 function MapSet(i,r){
13236 if(!(%_ClassOf(this)==='Map')){
13237 throw MakeTypeError(8,
13238 'Map.prototype.set',this);
13243 var d=%_JSCollectionGetTable(this);
13244 var g=((%_FixedArrayGet(d,(0)|0)));
13246 var k=MapFindEntry(d,g,i,e);
13248 var K=(3+(g)+((k)*3));
13249 (%_FixedArraySet(d,(K+1)|0,r));
13252 var t=((%_FixedArrayGet(d,(1)|0)));
13253 var u=((%_FixedArrayGet(d,(2)|0)));
13257 d=%_JSCollectionGetTable(this);
13258 g=((%_FixedArrayGet(d,(0)|0)));
13259 t=((%_FixedArrayGet(d,(1)|0)));
13260 u=((%_FixedArrayGet(d,(2)|0)));
13263 var z=(3+(g)+((k)*3));
13265 var A=((%_FixedArrayGet(d,(3+(h))|0)));
13266 ((%_FixedArraySet(d,(3+(h))|0,k)));
13267 (((%_FixedArraySet(d,(1)|0,(t+1)|0))));
13268 (%_FixedArraySet(d,(z)|0,i));
13269 (%_FixedArraySet(d,(z+1)|0,r));
13270 (%_FixedArraySet(d,(z+2)|0,A));
13273 function MapHas(i){
13274 if(!(%_ClassOf(this)==='Map')){
13275 throw MakeTypeError(8,
13276 'Map.prototype.has',this);
13278 var d=%_JSCollectionGetTable(this);
13279 var g=((%_FixedArrayGet(d,(0)|0)));
13281 return MapFindEntry(d,g,i,e)!==-1;
13283 function MapDelete(i){
13284 if(!(%_ClassOf(this)==='Map')){
13285 throw MakeTypeError(8,
13286 'Map.prototype.delete',this);
13288 var d=%_JSCollectionGetTable(this);
13289 var g=((%_FixedArrayGet(d,(0)|0)));
13291 var k=MapFindEntry(d,g,i,e);
13292 if(k===-1)return false;
13293 var t=((%_FixedArrayGet(d,(1)|0)))-1;
13294 var u=((%_FixedArrayGet(d,(2)|0)))+1;
13295 var z=(3+(g)+((k)*3));
13296 (%_FixedArraySet(d,(z)|0,%_TheHole()));
13297 (%_FixedArraySet(d,(z+1)|0,%_TheHole()));
13298 (((%_FixedArraySet(d,(1)|0,(t)|0))));
13299 (((%_FixedArraySet(d,(2)|0,(u)|0))));
13300 if(t<(g>>>1))%MapShrink(this);
13303 function MapGetSize(){
13304 if(!(%_ClassOf(this)==='Map')){
13305 throw MakeTypeError(8,
13306 'Map.prototype.size',this);
13308 var d=%_JSCollectionGetTable(this);
13309 return((%_FixedArrayGet(d,(1)|0)));
13311 function MapClearJS(){
13312 if(!(%_ClassOf(this)==='Map')){
13313 throw MakeTypeError(8,
13314 'Map.prototype.clear',this);
13318 function MapForEach(B,C){
13319 if(!(%_ClassOf(this)==='Map')){
13320 throw MakeTypeError(8,
13321 'Map.prototype.forEach',this);
13323 if(!(%_ClassOf(B)==='Function'))throw MakeTypeError(2,B);
13326 C=%GetDefaultReceiver(B)||C;
13328 D=(!(%_IsSpecObject(C))&&%IsSloppyModeFunction(B));
13330 var E=new MapIterator(this,3);
13331 var G=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(B);
13332 var H=[(void 0),(void 0)];
13333 while(%MapIteratorNext(E,H)){
13334 if(G)%DebugPrepareStepInIfStepping(B);
13335 var I=D?ToObject(C):C;
13336 %_CallFunction(I,H[1],H[0],this,B);
13339 %SetCode(a,MapConstructor);
13340 %FunctionSetLength(a,0);
13341 %FunctionSetPrototype(a,new b());
13342 %AddNamedProperty(a.prototype,"constructor",a,2);
13344 a.prototype,symbolToStringTag,"Map",2|1);
13345 %FunctionSetLength(MapForEach,1);
13346 InstallGetter(a.prototype,"size",MapGetSize);
13347 InstallFunctions(a.prototype,2,[
13351 "delete",MapDelete,
13352 "clear",MapClearJS,
13353 "forEach",MapForEach
13357 <weak-collection
\81-
13360 %CheckIsBootstrapping();
13361 var a=global.Object;
13362 var b=global.WeakMap;
13363 var c=global.WeakSet;
13364 function WeakMapConstructor(d){
13365 if(!%_IsConstructCall()){
13366 throw MakeTypeError('constructor_not_function',['WeakMap']);
13368 %WeakCollectionInitialize(this);
13371 if(!(%_ClassOf(e)==='Function')){
13372 throw MakeTypeError(21,'set',this);
13375 if(!(%_IsSpecObject(g))){
13376 throw MakeTypeError('iterator_value_not_an_object',[g]);
13378 %_CallFunction(this,g[0],g[1],e);
13382 function WeakMapGet(h){
13383 if(!(%_ClassOf(this)==='WeakMap')){
13384 throw MakeTypeError(8,
13385 'WeakMap.prototype.get',this);
13387 if(!(%_IsSpecObject(h)))return(void 0);
13388 return %WeakCollectionGet(this,h);
13390 function WeakMapSet(h,i){
13391 if(!(%_ClassOf(this)==='WeakMap')){
13392 throw MakeTypeError(8,
13393 'WeakMap.prototype.set',this);
13395 if(!(%_IsSpecObject(h))){
13396 throw %MakeTypeError('invalid_weakmap_key',[this,h]);
13398 return %WeakCollectionSet(this,h,i);
13400 function WeakMapHas(h){
13401 if(!(%_ClassOf(this)==='WeakMap')){
13402 throw MakeTypeError(8,
13403 'WeakMap.prototype.has',this);
13405 if(!(%_IsSpecObject(h)))return false;
13406 return %WeakCollectionHas(this,h);
13408 function WeakMapDelete(h){
13409 if(!(%_ClassOf(this)==='WeakMap')){
13410 throw MakeTypeError(8,
13411 'WeakMap.prototype.delete',this);
13413 if(!(%_IsSpecObject(h)))return false;
13414 return %WeakCollectionDelete(this,h);
13416 %SetCode(b,WeakMapConstructor);
13417 %FunctionSetLength(b,0);
13418 %FunctionSetPrototype(b,new a());
13419 %AddNamedProperty(b.prototype,"constructor",b,
13421 %AddNamedProperty(b.prototype,symbolToStringTag,"WeakMap",
13423 InstallFunctions(b.prototype,2,[
13427 "delete",WeakMapDelete
13429 function WeakSetConstructor(d){
13430 if(!%_IsConstructCall()){
13431 throw MakeTypeError('constructor_not_function',['WeakSet']);
13433 %WeakCollectionInitialize(this);
13436 if(!(%_ClassOf(e)==='Function')){
13437 throw MakeTypeError(21,'add',this);
13440 %_CallFunction(this,i,e);
13444 function WeakSetAdd(i){
13445 if(!(%_ClassOf(this)==='WeakSet')){
13446 throw MakeTypeError(8,
13447 'WeakSet.prototype.add',this);
13449 if(!(%_IsSpecObject(i))){
13450 throw %MakeTypeError('invalid_weakset_value',[this,i]);
13452 return %WeakCollectionSet(this,i,true);
13454 function WeakSetHas(i){
13455 if(!(%_ClassOf(this)==='WeakSet')){
13456 throw MakeTypeError(8,
13457 'WeakSet.prototype.has',this);
13459 if(!(%_IsSpecObject(i)))return false;
13460 return %WeakCollectionHas(this,i);
13462 function WeakSetDelete(i){
13463 if(!(%_ClassOf(this)==='WeakSet')){
13464 throw MakeTypeError(8,
13465 'WeakSet.prototype.delete',this);
13467 if(!(%_IsSpecObject(i)))return false;
13468 return %WeakCollectionDelete(this,i);
13470 %SetCode(c,WeakSetConstructor);
13471 %FunctionSetLength(c,0);
13472 %FunctionSetPrototype(c,new a());
13473 %AddNamedProperty(c.prototype,"constructor",c,
13475 %AddNamedProperty(c.prototype,symbolToStringTag,"WeakSet",
13477 InstallFunctions(c.prototype,2,[
13480 "delete",WeakSetDelete
13484 Lcollection-iterator
\8d1
13486 var $mapIteratorNext;
13487 var $setIteratorNext;
13491 %CheckIsBootstrapping();
13493 var b=global.Object;
13495 function SetIteratorConstructor(d,e){
13496 %SetIteratorInitialize(this,d,e);
13498 function SetIteratorNextJS(){
13499 if(!(%_ClassOf(this)==='Set Iterator')){
13500 throw MakeTypeError(8,
13501 'Set Iterator.prototype.next',this);
13503 var g=[(void 0),(void 0)];
13504 var h={value:g,done:false};
13505 switch(%SetIteratorNext(this,g)){
13519 function SetIteratorSymbolIterator(){
13522 function SetEntries(){
13523 if(!(%_ClassOf(this)==='Set')){
13524 throw MakeTypeError(8,
13525 'Set.prototype.entries',this);
13527 return new SetIterator(this,3);
13529 function SetValues(){
13530 if(!(%_ClassOf(this)==='Set')){
13531 throw MakeTypeError(8,
13532 'Set.prototype.values',this);
13534 return new SetIterator(this,2);
13536 %SetCode(SetIterator,SetIteratorConstructor);
13537 %FunctionSetPrototype(SetIterator,new b());
13538 %FunctionSetInstanceClassName(SetIterator,'Set Iterator');
13539 InstallFunctions(SetIterator.prototype,2,[
13540 'next',SetIteratorNextJS
13542 %FunctionSetName(SetIteratorSymbolIterator,'[Symbol.iterator]');
13543 %AddNamedProperty(SetIterator.prototype,symbolIterator,
13544 SetIteratorSymbolIterator,2);
13545 %AddNamedProperty(SetIterator.prototype,symbolToStringTag,
13546 "Set Iterator",1|2);
13547 InstallFunctions(c.prototype,2,[
13548 'entries',SetEntries,
13552 %AddNamedProperty(c.prototype,symbolIterator,SetValues,2);
13553 $setIteratorNext=SetIteratorNextJS;
13554 $setValues=SetValues;
13555 function MapIteratorConstructor(i,e){
13556 %MapIteratorInitialize(this,i,e);
13558 function MapIteratorSymbolIterator(){
13561 function MapIteratorNextJS(){
13562 if(!(%_ClassOf(this)==='Map Iterator')){
13563 throw MakeTypeError(8,
13564 'Map Iterator.prototype.next',this);
13566 var g=[(void 0),(void 0)];
13567 var h={value:g,done:false};
13568 switch(%MapIteratorNext(this,g)){
13582 function MapEntries(){
13583 if(!(%_ClassOf(this)==='Map')){
13584 throw MakeTypeError(8,
13585 'Map.prototype.entries',this);
13587 return new MapIterator(this,3);
13589 function MapKeys(){
13590 if(!(%_ClassOf(this)==='Map')){
13591 throw MakeTypeError(8,
13592 'Map.prototype.keys',this);
13594 return new MapIterator(this,1);
13596 function MapValues(){
13597 if(!(%_ClassOf(this)==='Map')){
13598 throw MakeTypeError(8,
13599 'Map.prototype.values',this);
13601 return new MapIterator(this,2);
13603 %SetCode(MapIterator,MapIteratorConstructor);
13604 %FunctionSetPrototype(MapIterator,new b());
13605 %FunctionSetInstanceClassName(MapIterator,'Map Iterator');
13606 InstallFunctions(MapIterator.prototype,2,[
13607 'next',MapIteratorNextJS
13609 %FunctionSetName(MapIteratorSymbolIterator,'[Symbol.iterator]');
13610 %AddNamedProperty(MapIterator.prototype,symbolIterator,
13611 MapIteratorSymbolIterator,2);
13612 %AddNamedProperty(MapIterator.prototype,symbolToStringTag,
13613 "Map Iterator",1|2);
13614 InstallFunctions(a.prototype,2,[
13615 'entries',MapEntries,
13619 %AddNamedProperty(a.prototype,symbolIterator,MapEntries,2);
13620 $mapEntries=MapEntries;
13621 $mapIteratorNext=MapIteratorNextJS;
13625 var $promiseCreate;
13626 var $promiseResolve;
13627 var $promiseReject;
13631 var $promiseHasUserDefinedRejectHandler;
13632 var $promiseStatus;
13636 %CheckIsBootstrapping();
13637 var a=(%CreateGlobalPrivateOwnSymbol("Promise#status"));
13638 var b=(%CreateGlobalPrivateOwnSymbol("Promise#value"));
13639 var c=(%CreateGlobalPrivateOwnSymbol("Promise#onResolve"));
13640 var d=(%CreateGlobalPrivateOwnSymbol("Promise#onReject"));
13641 var e=(%CreateGlobalPrivateOwnSymbol("Promise#raw"));
13642 var g=%PromiseHasHandlerSymbol();
13644 var i=function Promise(j){
13646 if(!%_IsConstructCall())throw MakeTypeError('not_a_promise',[this]);
13647 if(!(%_ClassOf(j)==='Function'))
13648 throw MakeTypeError('resolver_not_a_function',[j]);
13649 var k=PromiseInit(this);
13651 %DebugPushPromise(k,Promise);
13652 j(function(l){PromiseResolve(k,l)},
13653 function(m){PromiseReject(k,m)});
13655 PromiseReject(k,e);
13657 %DebugPopPromise();
13660 function PromiseSet(k,n,o,q,r){
13665 if((%_DebugIsActive()!=0)){
13666 %DebugPromiseEvent({promise:k,status:n,value:o});
13670 function PromiseCreateAndSet(n,o){
13672 if((%_DebugIsActive()!=0))PromiseSet(k,0,(void 0));
13673 return PromiseSet(k,n,o);
13675 function PromiseInit(k){
13677 k,0,(void 0),new InternalArray,new InternalArray)
13679 function PromiseDone(k,n,o,t){
13682 if(u.length)PromiseEnqueue(o,u,n);
13686 function PromiseCoerce(w,l){
13687 if(!IsPromise(l)&&(%_IsSpecObject(l))){
13692 return %_CallFunction(w,m,PromiseRejected);
13694 if((%_ClassOf(z)==='Function')){
13695 var A=%_CallFunction(w,PromiseDeferred);
13697 %_CallFunction(l,A.resolve,A.reject,z);
13706 function PromiseHandle(o,B,A){
13708 %DebugPushPromise(A.promise,PromiseHandle);
13709 if((%_DebugIsActive()!=0&&%DebugCallbackSupportsStepping(B)))%DebugPrepareStepInIfStepping(B);
13712 throw MakeTypeError('promise_cyclic',[C]);
13713 else if(IsPromise(C))
13714 %_CallFunction(C,A.resolve,A.reject,PromiseChain);
13718 try{A.reject(exception);}catch(e){}
13720 %DebugPopPromise();
13723 function PromiseEnqueue(o,u,n){
13724 var D,E,G=(%_DebugIsActive()!=0);
13725 %EnqueueMicrotask(function(){
13727 %DebugAsyncTaskEvent({type:"willHandle",id:D,name:E});
13729 for(var H=0;H<u.length;H+=2){
13730 PromiseHandle(o,u[H],u[H+1])
13733 %DebugAsyncTaskEvent({type:"didHandle",id:D,name:E});
13738 E=n>0?"Promise.resolve":"Promise.reject";
13739 %DebugAsyncTaskEvent({type:"enqueue",id:D,name:E});
13742 function PromiseIdResolveHandler(l){return l}
13743 function PromiseIdRejectHandler(m){throw m}
13744 function PromiseNopResolver(){}
13745 function IsPromise(l){
13746 return(%_IsSpecObject(l))&&(!(l[a]===(void 0)));
13748 function PromiseCreate(){
13749 return new i(PromiseNopResolver)
13751 function PromiseResolve(k,l){
13752 PromiseDone(k,+1,l,c)
13754 function PromiseReject(k,m){
13756 var I=(%_DebugIsActive()!=0);
13757 if(I||!(!(k[g]===(void 0)))){
13758 %PromiseRejectEvent(k,m,I);
13761 PromiseDone(k,-1,m,d)
13763 function PromiseDeferred(){
13765 var k=PromiseInit(new i(e));
13768 resolve:function(l){PromiseResolve(k,l)},
13769 reject:function(m){PromiseReject(k,m)}
13773 C.promise=new this(function(J,K){
13780 function PromiseResolved(l){
13782 return PromiseCreateAndSet(+1,l);
13784 return new this(function(J,K){J(l)});
13787 function PromiseRejected(m){
13790 k=PromiseCreateAndSet(-1,m);
13791 %PromiseRejectEvent(k,m,false);
13793 k=new this(function(J,K){K(m)});
13797 function PromiseChain(q,r){
13798 q=(q===(void 0))?PromiseIdResolveHandler:q;
13799 r=(r===(void 0))?PromiseIdRejectHandler:r;
13800 var A=%_CallFunction(this.constructor,PromiseDeferred);
13803 throw MakeTypeError('not_a_promise',[this]);
13805 (this[c]).push(q,A);
13806 (this[d]).push(r,A);
13809 PromiseEnqueue((this[b]),
13814 if(!(!(this[g]===(void 0)))){
13815 %PromiseRevokeReject(this);
13817 PromiseEnqueue((this[b]),
13823 if((%_DebugIsActive()!=0)){
13824 %DebugPromiseEvent({promise:A.promise,parentPromise:this});
13828 function PromiseCatch(r){
13829 return this.then((void 0),r);
13831 function PromiseThen(q,r){
13832 q=(%_ClassOf(q)==='Function')?q
13833 :PromiseIdResolveHandler;
13834 r=(%_ClassOf(r)==='Function')?r
13835 :PromiseIdRejectHandler;
13837 var w=this.constructor;
13838 return %_CallFunction(
13841 l=PromiseCoerce(w,l);
13843 if((%_DebugIsActive()!=0&&%DebugCallbackSupportsStepping(r)))%DebugPrepareStepInIfStepping(r);
13844 return r(MakeTypeError('promise_cyclic',[l]));
13845 }else if(IsPromise(l)){
13846 return l.then(q,r);
13848 if((%_DebugIsActive()!=0&&%DebugCallbackSupportsStepping(q)))%DebugPrepareStepInIfStepping(q);
13856 function PromiseCast(l){
13857 return IsPromise(l)?l:new this(function(J){J(l)});
13859 function PromiseAll(M){
13860 var A=%_CallFunction(this,PromiseDeferred);
13866 this.resolve(o).then(
13868 return function(l){
13870 if(--P===0)A.resolve(N);
13873 function(m){A.reject(m);});
13885 function PromiseRace(M){
13886 var A=%_CallFunction(this,PromiseDeferred);
13889 this.resolve(o).then(
13890 function(l){A.resolve(l)},
13891 function(m){A.reject(m)});
13898 function PromiseHasUserDefinedRejectHandlerRecursive(k){
13900 if((Q===(void 0)))return false;
13901 for(var H=0;H<Q.length;H+=2){
13902 if(Q[H]!=PromiseIdRejectHandler)return true;
13903 if(PromiseHasUserDefinedRejectHandlerRecursive(Q[H+1].promise)){
13909 function PromiseHasUserDefinedRejectHandler(){
13910 return PromiseHasUserDefinedRejectHandlerRecursive(this);
13912 %AddNamedProperty(global,'Promise',i,2);
13913 %AddNamedProperty(i.prototype,symbolToStringTag,"Promise",
13915 InstallFunctions(i,2,[
13916 "defer",PromiseDeferred,
13917 "accept",PromiseResolved,
13918 "reject",PromiseRejected,
13920 "race",PromiseRace,
13921 "resolve",PromiseCast
13923 InstallFunctions(i.prototype,2,[
13924 "chain",PromiseChain,
13925 "then",PromiseThen,
13926 "catch",PromiseCatch
13928 $promiseCreate=PromiseCreate;
13929 $promiseResolve=PromiseResolve;
13930 $promiseReject=PromiseReject;
13931 $promiseChain=PromiseChain;
13932 $promiseCatch=PromiseCatch;
13933 $promiseThen=PromiseThen;
13934 $promiseHasUserDefinedRejectHandler=PromiseHasUserDefinedRejectHandler;
13941 constructor_is_generator:["Class constructor may not be a generator"],
13942 constructor_is_accessor:["Class constructor may not be an accessor"],
13943 unexpected_token:["Unexpected token ","%0"],
13944 unexpected_token_number:["Unexpected number"],
13945 unexpected_token_string:["Unexpected string"],
13946 unexpected_token_identifier:["Unexpected identifier"],
13947 unexpected_reserved:["Unexpected reserved word"],
13948 unexpected_strict_reserved:["Unexpected strict mode reserved word"],
13949 unexpected_eos:["Unexpected end of input"],
13950 unexpected_template_string:["Unexpected template string"],
13951 malformed_regexp:["Invalid regular expression: /","%0","/: ","%1"],
13952 malformed_regexp_flags:["Invalid regular expression flags"],
13953 unterminated_regexp:["Invalid regular expression: missing /"],
13954 unterminated_template:["Unterminated template literal"],
13955 unterminated_template_expr:["Missing } in template expression"],
13956 unterminated_arg_list:["missing ) after argument list"],
13957 regexp_flags:["Cannot supply flags when constructing one RegExp from another"],
13958 multiple_defaults_in_switch:["More than one default clause in switch statement"],
13959 newline_after_throw:["Illegal newline after throw"],
13960 label_redeclaration:["Label '","%0","' has already been declared"],
13961 var_redeclaration:["Identifier '","%0","' has already been declared"],
13962 duplicate_template_property:["Object template has duplicate property '","%0","'"],
13963 no_catch_or_finally:["Missing catch or finally after try"],
13964 unknown_label:["Undefined label '","%0","'"],
13965 uncaught_exception:["Uncaught ","%0"],
13966 undefined_method:["Object ","%1"," has no method '","%0","'"],
13967 not_defined:["%0"," is not defined"],
13968 non_method:["'super' is referenced from non-method"],
13969 unsupported_super:["Unsupported reference to 'super'"],
13970 non_object_property_load:["Cannot read property '","%0","' of ","%1"],
13971 non_object_property_store:["Cannot set property '","%0","' of ","%1"],
13972 illegal_invocation:["Illegal invocation"],
13973 no_setter_in_callback:["Cannot set property ","%0"," of ","%1"," which has only a getter"],
13974 flags_getter_non_object:["RegExp.prototype.flags getter called on non-object ","%0"],
13975 reduce_no_initial:["Reduce of empty array with no initial value"],
13976 value_and_accessor:["Invalid property. A property cannot both have accessors and be writable or have a value, ","%0"],
13977 proto_object_or_null:["Object prototype may only be an Object or null: ","%0"],
13978 non_extensible_proto:["%0"," is not extensible"],
13979 handler_non_object:["Proxy.","%0"," called with non-object as handler"],
13980 proto_non_object:["Proxy.","%0"," called with non-object as prototype"],
13981 trap_function_expected:["Proxy.","%0"," called with non-function for '","%1","' trap"],
13982 proxy_repeated_prop_name:["Trap '","%1","' returned repeated property name '","%2","'"],
13983 invalid_weakmap_key:["Invalid value used as weak map key"],
13984 invalid_weakset_value:["Invalid value used in weak set"],
13985 not_date_object:["this is not a Date object."],
13986 observe_non_object:["Object.","%0"," cannot ","%0"," non-object"],
13987 observe_non_function:["Object.","%0"," cannot deliver to non-function"],
13988 observe_callback_frozen:["Object.observe cannot deliver to a frozen function object"],
13989 observe_invalid_accept:["Third argument to Object.observe must be an array of strings."],
13990 observe_type_non_string:["Invalid changeRecord with non-string 'type' property"],
13991 observe_perform_non_string:["Invalid non-string changeType"],
13992 observe_perform_non_function:["Cannot perform non-function"],
13993 observe_notify_non_notifier:["notify called on non-notifier object"],
13994 observe_global_proxy:["%0"," cannot be called on the global proxy object"],
13995 not_typed_array:["this is not a typed array."],
13996 invalid_argument:["invalid_argument"],
13997 data_view_not_array_buffer:["First argument to DataView constructor must be an ArrayBuffer"],
13998 constructor_not_function:["Constructor ","%0"," requires 'new'"],
13999 not_a_symbol:["%0"," is not a symbol"],
14000 not_a_promise:["%0"," is not a promise"],
14001 resolver_not_a_function:["Promise resolver ","%0"," is not a function"],
14002 promise_cyclic:["Chaining cycle detected for promise ","%0"],
14003 array_functions_on_frozen:["Cannot modify frozen array elements"],
14004 array_functions_change_sealed:["Cannot add/remove sealed array elements"],
14005 first_argument_not_regexp:["First argument to ","%0"," must not be a regular expression"],
14006 iterator_result_not_an_object:["Iterator result ","%0"," is not an object"],
14007 iterator_value_not_an_object:["Iterator value ","%0"," is not an entry object"],
14008 invalid_array_length:["Invalid array length"],
14009 invalid_array_buffer_length:["Invalid array buffer length"],
14010 invalid_string_length:["Invalid string length"],
14011 invalid_typed_array_offset:["Start offset is too large:"],
14012 invalid_typed_array_length:["Invalid typed array length"],
14013 invalid_typed_array_alignment:["%0"," of ","%1"," should be a multiple of ","%2"],
14014 typed_array_set_source_too_large:
14015 ["Source is too large"],
14016 typed_array_set_negative_offset:
14017 ["Start offset is negative"],
14018 invalid_data_view_offset:["Start offset is outside the bounds of the buffer"],
14019 invalid_data_view_length:["Invalid data view length"],
14020 invalid_data_view_accessor_offset:
14021 ["Offset is outside the bounds of the DataView"],
14022 invalid_time_value:["Invalid time value"],
14023 invalid_count_value:["Invalid count value"],
14024 invalid_code_point:["Invalid code point ","%0"],
14025 invalid_lhs_in_assignment:["Invalid left-hand side in assignment"],
14026 invalid_lhs_in_for:["Invalid left-hand side in for-loop"],
14027 invalid_lhs_in_postfix_op:["Invalid left-hand side expression in postfix operation"],
14028 invalid_lhs_in_prefix_op:["Invalid left-hand side expression in prefix operation"],
14029 not_isvar:["builtin %IS_VAR: not a variable"],
14030 single_function_literal:["Single function literal required"],
14031 invalid_regexp_flags:["Invalid flags supplied to RegExp constructor '","%0","'"],
14032 invalid_regexp:["Invalid RegExp pattern /","%0","/"],
14033 illegal_break:["Illegal break statement"],
14034 illegal_continue:["Illegal continue statement"],
14035 illegal_return:["Illegal return statement"],
14036 error_loading_debugger:["Error loading debugger"],
14037 circular_structure:["Converting circular structure to JSON"],
14038 called_on_null_or_undefined:["%0"," called on null or undefined"],
14039 array_indexof_not_defined:["Array.getIndexOf: Argument undefined"],
14040 object_not_extensible:["Can't add property ","%0",", object is not extensible"],
14041 illegal_access:["Illegal access"],
14042 static_prototype:["Classes may not have static property named prototype"],
14043 strict_mode_with:["Strict mode code may not include a with statement"],
14044 strict_eval_arguments:["Unexpected eval or arguments in strict mode"],
14045 too_many_arguments:["Too many arguments in function call (only 65535 allowed)"],
14046 too_many_parameters:["Too many parameters in function definition (only 65535 allowed)"],
14047 too_many_variables:["Too many variables declared (only 4194303 allowed)"],
14048 strict_param_dupe:["Strict mode function may not have duplicate parameter names"],
14049 strict_octal_literal:["Octal literals are not allowed in strict mode."],
14050 template_octal_literal:["Octal literals are not allowed in template strings."],
14051 strict_delete:["Delete of an unqualified identifier in strict mode."],
14052 strict_delete_property:["Cannot delete property '","%0","' of ","%1"],
14053 strict_function:["In strict mode code, functions can only be declared at top level or immediately within another function."],
14054 strict_read_only_property:["Cannot assign to read only property '","%0","' of ","%1"],
14055 strict_cannot_assign:["Cannot assign to read only '","%0","' in strict mode"],
14056 restricted_function_properties:["'caller' and 'arguments' are restricted function properties and cannot be accessed in this context."],
14057 strict_poison_pill:["'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them"],
14058 strict_caller:["Illegal access to a strict mode caller function."],
14059 strong_ellision:["In strong mode, arrays with holes are deprecated, use maps instead"],
14060 strong_arguments:["In strong mode, 'arguments' is deprecated, use '...args' instead"],
14061 strong_undefined:["In strong mode, binding or assigning to 'undefined' is deprecated"],
14062 strong_direct_eval:["In strong mode, direct calls to eval are deprecated"],
14063 strong_switch_fallthrough:["In strong mode, switch fall-through is deprecated, terminate each case with 'break', 'continue', 'return' or 'throw'"],
14064 strong_equal:["In strong mode, '==' and '!=' are deprecated, use '===' and '!==' instead"],
14065 strong_delete:["In strong mode, 'delete' is deprecated, use maps or sets instead"],
14066 strong_var:["In strong mode, 'var' is deprecated, use 'let' or 'const' instead"],
14067 strong_for_in:["In strong mode, 'for'-'in' loops are deprecated, use 'for'-'of' instead"],
14068 strong_empty:["In strong mode, empty sub-statements are deprecated, make them explicit with '{}' instead"],
14069 strong_use_before_declaration:["In strong mode, declaring variable '","%0","' before its use is required"],
14070 strong_unbound_global:["In strong mode, using an undeclared global variable '","%0","' is not allowed"],
14071 strong_super_call_missing:["In strong mode, invoking the super constructor in a subclass is required"],
14072 strong_super_call_duplicate:["In strong mode, invoking the super constructor multiple times is deprecated"],
14073 strong_super_call_misplaced:["In strong mode, the super constructor must be invoked before any assignment to 'this'"],
14074 strong_constructor_super:["In strong mode, 'super' can only be used to invoke the super constructor, and cannot be nested inside another statement or expression"],
14075 strong_constructor_this:["In strong mode, 'this' can only be used to initialize properties, and cannot be nested inside another statement or expression"],
14076 strong_constructor_return_value:["In strong mode, returning a value from a constructor is deprecated"],
14077 strong_constructor_return_misplaced:["In strong mode, returning from a constructor before its super constructor invocation or all assignments to 'this' is deprecated"],
14078 sloppy_lexical:["Block-scoped declarations (let, const, function, class) not yet supported outside strict mode"],
14079 malformed_arrow_function_parameter_list:["Malformed arrow function parameter list"],
14080 cant_prevent_ext_external_array_elements:["Cannot prevent extension of an object with external array elements"],
14081 redef_external_array_element:["Cannot redefine a property of an object with external array elements"],
14082 const_assign:["Assignment to constant variable."],
14083 module_export_undefined:["Export '","%0","' is not defined in module"],
14084 duplicate_export:["Duplicate export of '","%0","'"],
14085 unexpected_super:["'super' keyword unexpected here"],
14086 extends_value_not_a_function:["Class extends value ","%0"," is not a function or null"],
14087 prototype_parent_not_an_object:["Class extends value does not have valid prototype property ","%0"],
14088 duplicate_constructor:["A class may only have one constructor"],
14089 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."],
14090 duplicate_proto:["Duplicate __proto__ fields are not allowed in object literals"],
14091 param_after_rest:["Rest parameter must be last formal parameter"],
14092 constructor_noncallable:["Class constructors cannot be invoked without 'new'"],
14093 array_not_subclassable:["Subclassing Arrays is not currently supported."],
14094 for_in_loop_initializer:["for-in loop variable declaration may not have an initializer."],
14095 for_of_loop_initializer:["for-of loop variable declaration may not have an initializer."],
14096 for_inof_loop_multi_bindings:["Invalid left-hand side in ","%0"," loop: Must have a single binding."],
14097 bad_getter_arity:["Getter must not have any formal parameters."],
14098 bad_setter_arity:["Setter must have exactly one formal parameter."],
14099 this_formal_parameter:["'this' is not a valid formal parameter name"],
14100 duplicate_arrow_function_formal_parameter:["Arrow function may not have duplicate parameter names"]
14102 function FormatString(a,b){
14105 for(var e=0;e<a.length;e++){
14107 if(g.length==2&&%_StringCharCodeAt(g,0)==0x25){
14108 var d=(%_StringCharCodeAt(g,1)-0x30)>>>0;
14111 g=NoSideEffectToString(b[d]);
14113 if(%IsJSModule(b[d]))
14115 else if((%_IsSpecObject(b[d])))
14126 function NoSideEffectToString(a){
14127 if((typeof(a)==='string'))return a;
14128 if((typeof(a)==='number'))return %_NumberToString(a);
14129 if((typeof(a)==='boolean'))return a?'true':'false';
14130 if((a===(void 0)))return'undefined';
14131 if((a===null))return'null';
14132 if((%_IsFunction(a))){
14133 var b=%_CallFunction(a,FunctionToString);
14135 b=%_SubString(b,0,111)+"...<omitted>..."+
14136 %_SubString(b,b.length-2,b.length);
14140 if((typeof(a)==='symbol'))return %_CallFunction(a,$symbolToString);
14142 &&%GetDataProperty(a,"toString")===ObjectToString){
14143 var c=%GetDataProperty(a,"constructor");
14144 if(typeof c=="function"){
14146 if((typeof(d)==='string')&&d!==""){
14151 if(CanBeSafelyTreatedAsAnErrorObject(a)){
14152 return %_CallFunction(a,ErrorToString);
14154 return %_CallFunction(a,NoSideEffectsObjectToString);
14156 function CanBeSafelyTreatedAsAnErrorObject(a){
14157 switch(%_ClassOf(a)){
14161 case'ReferenceError':
14167 var b=%GetDataProperty(a,"toString");
14168 return a instanceof $Error&&b===ErrorToString;
14170 function ToStringCheckErrorObject(a){
14171 if(CanBeSafelyTreatedAsAnErrorObject(a)){
14172 return %_CallFunction(a,ErrorToString);
14174 return ToString(a);
14177 function ToDetailString(a){
14178 if(a!=null&&(%_IsObject(a))&&a.toString===ObjectToString){
14179 var b=a.constructor;
14180 if(typeof b=="function"){
14182 if((typeof(c)==='string')&&c!==""){
14187 return ToStringCheckErrorObject(a);
14189 function MakeGenericError(a,b,c,d,e){
14190 if((c===(void 0))&&(typeof(b)==='string'))c=[];
14191 return new a(FormatMessage(b,c,d,e));
14193 %FunctionSetInstanceClassName(Script,'Script');
14194 %AddNamedProperty(Script.prototype,'constructor',Script,
14196 %SetCode(Script,function(a){
14197 throw new $Error("Not supported");
14199 function FormatMessage(a,b,c,d){
14200 if((typeof(a)==='number')){
14201 var b=NoSideEffectToString(b);
14202 var c=NoSideEffectToString(c);
14203 var d=NoSideEffectToString(d);
14205 return %FormatMessageString(a,b,c,d);
14210 var e=kMessages[a];
14211 if(!e)return"<unknown message "+a+">";
14212 return FormatString(e,b);
14214 function GetLineNumber(a){
14215 var b=%MessageGetStartPosition(a);
14217 var c=%MessageGetScript(a);
14218 var d=c.locationFromPosition(b,true);
14219 if(d==null)return 0;
14222 function GetSourceLine(a){
14223 var b=%MessageGetScript(a);
14224 var c=%MessageGetStartPosition(a);
14225 var d=b.locationFromPosition(c,true);
14226 if(d==null)return"";
14227 return d.sourceText();
14229 function MakeError(a,b,c,d){
14230 return MakeGenericError($Error,a,b,c,d);
14232 function MakeTypeError(a,b,c,d){
14233 return MakeGenericError($TypeError,a,b,c,d);
14235 function MakeRangeError(a,b,c,d){
14236 return MakeGenericError($RangeError,a,b,c,d);
14238 function MakeSyntaxError(a,b,c,d){
14239 return MakeGenericError($SyntaxError,a,b,c,d);
14241 function MakeReferenceError(a,b,c,d){
14242 return MakeGenericError($ReferenceError,a,b,c,d);
14244 function MakeEvalError(a,b,c,d){
14245 return MakeGenericError($EvalError,a,b,c,d);
14247 function MakeTypeErrorEmbedded(a,b){
14248 return MakeGenericError($TypeError,a,[b]);
14250 function MakeSyntaxErrorEmbedded(a,b){
14251 return MakeGenericError($SyntaxError,a,[b]);
14253 function MakeReferenceErrorEmbedded(a,b){
14254 return MakeGenericError($ReferenceError,a,[b]);
14256 function ScriptLineFromPosition(a){
14258 var c=this.lineCount()-1;
14259 var d=this.line_ends;
14270 }else if(a<=d[e-1]){
14278 function ScriptLocationFromPosition(position,
14279 include_resource_offset){
14280 var a=this.lineFromPosition(position);
14281 if(a==-1)return null;
14282 var b=this.line_ends;
14283 var c=a==0?0:b[a-1]+1;
14285 if(d>0&&%_CallFunction(this.source,d-1,$stringCharAt)=='\r'){
14289 if(include_resource_offset){
14290 a+=this.line_offset;
14291 if(a==this.line_offset){
14292 e+=this.column_offset;
14295 return new SourceLocation(this,position,a,e,c,d);
14297 function ScriptLocationFromLine(a,b,c){
14299 if(!(a===(void 0))){
14300 d=a-this.line_offset;
14304 e-=this.column_offset;
14307 if(d<0||e<0||g<0)return null;
14309 return this.locationFromPosition(g+e,false);
14311 var h=this.lineFromPosition(g);
14312 if(h==-1||h+d>=this.lineCount()){
14315 return this.locationFromPosition(
14316 this.line_ends[h+d-1]+1+e);
14319 function ScriptSourceSlice(a,b){
14320 var c=(a===(void 0))?this.line_offset
14322 var d=(b===(void 0))?this.line_offset+this.lineCount()
14324 c-=this.line_offset;
14325 d-=this.line_offset;
14327 if(d>this.lineCount())d=this.lineCount();
14328 if(c>=this.lineCount()||
14333 var e=this.line_ends;
14334 var g=c==0?0:e[c-1]+1;
14335 var h=d==0?0:e[d-1]+1;
14336 return new SourceSlice(this,
14337 c+this.line_offset,
14338 d+this.line_offset,
14341 function ScriptSourceLine(a){
14343 if(!(a===(void 0))){
14344 b=a-this.line_offset;
14346 if(b<0||this.lineCount()<=b){
14349 var c=this.line_ends;
14350 var d=b==0?0:c[b-1]+1;
14352 return %_CallFunction(this.source,d,e,$stringSubstring);
14354 function ScriptLineCount(){
14355 return this.line_ends.length;
14357 function ScriptNameOrSourceURL(){
14358 if(this.source_url)return this.source_url;
14361 SetUpLockedPrototype(Script,[
14365 "source_mapping_url",
14370 "lineFromPosition",ScriptLineFromPosition,
14371 "locationFromPosition",ScriptLocationFromPosition,
14372 "locationFromLine",ScriptLocationFromLine,
14373 "sourceSlice",ScriptSourceSlice,
14374 "sourceLine",ScriptSourceLine,
14375 "lineCount",ScriptLineCount,
14376 "nameOrSourceURL",ScriptNameOrSourceURL
14379 function SourceLocation(a,b,c,d,e,g){
14387 function SourceLocationSourceText(){
14388 return %_CallFunction(this.script.source,
14393 SetUpLockedPrototype(SourceLocation,
14394 ["script","position","line","column","start","end"],
14395 ["sourceText",SourceLocationSourceText]
14397 function SourceSlice(a,b,c,d,e){
14401 this.from_position=d;
14402 this.to_position=e;
14404 function SourceSliceSourceText(){
14405 return %_CallFunction(this.script.source,
14406 this.from_position,
14410 SetUpLockedPrototype(SourceSlice,
14411 ["script","from_line","to_line","from_position","to_position"],
14412 ["sourceText",SourceSliceSourceText]
14414 function GetPositionInLine(a){
14415 var b=%MessageGetScript(a);
14416 var c=%MessageGetStartPosition(a);
14417 var d=b.locationFromPosition(c,false);
14418 if(d==null)return-1;
14421 function GetStackTraceLine(a,b,c,d){
14422 return new CallSite(a,b,c,false).toString();
14424 var CallSiteReceiverKey=(%CreatePrivateOwnSymbol("CallSite#receiver"));
14425 var CallSiteFunctionKey=(%CreatePrivateOwnSymbol("CallSite#function"));
14426 var CallSitePositionKey=(%CreatePrivateOwnSymbol("CallSite#position"));
14427 var CallSiteStrictModeKey=(%CreatePrivateOwnSymbol("CallSite#strict_mode"));
14428 function CallSite(a,b,c,d){
14429 (this[CallSiteReceiverKey]=a);
14430 (this[CallSiteFunctionKey]=b);
14431 (this[CallSitePositionKey]=c);
14432 (this[CallSiteStrictModeKey]=d);
14434 function CallSiteGetThis(){
14435 return(this[CallSiteStrictModeKey])
14436 ?(void 0):(this[CallSiteReceiverKey]);
14438 function CallSiteGetTypeName(){
14439 return GetTypeName((this[CallSiteReceiverKey]),false);
14441 function CallSiteIsToplevel(){
14442 if((this[CallSiteReceiverKey])==null){
14445 return(%_ClassOf((this[CallSiteReceiverKey]))==='global');
14447 function CallSiteIsEval(){
14448 var a=%FunctionGetScript((this[CallSiteFunctionKey]));
14449 return a&&a.compilation_type==1;
14451 function CallSiteGetEvalOrigin(){
14452 var a=%FunctionGetScript((this[CallSiteFunctionKey]));
14453 return FormatEvalOrigin(a);
14455 function CallSiteGetScriptNameOrSourceURL(){
14456 var a=%FunctionGetScript((this[CallSiteFunctionKey]));
14457 return a?a.nameOrSourceURL():null;
14459 function CallSiteGetFunction(){
14460 return(this[CallSiteStrictModeKey])
14461 ?(void 0):(this[CallSiteFunctionKey]);
14463 function CallSiteGetFunctionName(){
14464 var a=(this[CallSiteFunctionKey]);
14465 var b=%FunctionGetDebugName(a);
14469 var c=%FunctionGetScript(a);
14470 if(c&&c.compilation_type==1){
14475 function CallSiteGetMethodName(){
14476 var a=(this[CallSiteReceiverKey]);
14477 var b=(this[CallSiteFunctionKey]);
14480 (%_CallFunction(a,c,ObjectLookupGetter)===b||
14481 %_CallFunction(a,c,ObjectLookupSetter)===b||
14482 ((%_IsObject(a))&&%GetDataProperty(a,c)===b))){
14487 if(%_CallFunction(a,e,ObjectLookupGetter)===b||
14488 %_CallFunction(a,e,ObjectLookupSetter)===b||
14489 ((%_IsObject(a))&&%GetDataProperty(a,e)===b)){
14501 function CallSiteGetFileName(){
14502 var a=%FunctionGetScript((this[CallSiteFunctionKey]));
14503 return a?a.name:null;
14505 function CallSiteGetLineNumber(){
14506 if((this[CallSitePositionKey])==-1){
14509 var a=%FunctionGetScript((this[CallSiteFunctionKey]));
14512 b=a.locationFromPosition(
14513 (this[CallSitePositionKey]),true);
14515 return b?b.line+1:null;
14517 function CallSiteGetColumnNumber(){
14518 if((this[CallSitePositionKey])==-1){
14521 var a=%FunctionGetScript((this[CallSiteFunctionKey]));
14524 b=a.locationFromPosition(
14525 (this[CallSitePositionKey]),true);
14527 return b?b.column+1:null;
14529 function CallSiteIsNative(){
14530 var a=%FunctionGetScript((this[CallSiteFunctionKey]));
14531 return a?(a.type==0):false;
14533 function CallSiteGetPosition(){
14534 return(this[CallSitePositionKey]);
14536 function CallSiteIsConstructor(){
14537 var a=(this[CallSiteReceiverKey]);
14538 var b=(a!=null&&(%_IsObject(a)))
14539 ?%GetDataProperty(a,"constructor"):null;
14540 if(!b)return false;
14541 return(this[CallSiteFunctionKey])===b;
14543 function CallSiteToString(){
14546 if(this.isNative()){
14549 a=this.getScriptNameOrSourceURL();
14550 if(!a&&this.isEval()){
14551 b=this.getEvalOrigin();
14559 var c=this.getLineNumber();
14562 var d=this.getColumnNumber();
14569 var g=this.getFunctionName();
14571 var i=this.isConstructor();
14572 var j=!(this.isToplevel()||i);
14574 var k=GetTypeName((this[CallSiteReceiverKey]),true);
14575 var l=this.getMethodName();
14578 %_CallFunction(g,k,$stringIndexOf)!=0){
14583 (%_CallFunction(g,"."+l,$stringIndexOf)!=
14584 g.length-l.length-1)){
14588 e+=k+"."+(l||"<anonymous>");
14591 e+="new "+(g||"<anonymous>");
14603 SetUpLockedPrototype(CallSite,["receiver","fun","pos"],[
14604 "getThis",CallSiteGetThis,
14605 "getTypeName",CallSiteGetTypeName,
14606 "isToplevel",CallSiteIsToplevel,
14607 "isEval",CallSiteIsEval,
14608 "getEvalOrigin",CallSiteGetEvalOrigin,
14609 "getScriptNameOrSourceURL",CallSiteGetScriptNameOrSourceURL,
14610 "getFunction",CallSiteGetFunction,
14611 "getFunctionName",CallSiteGetFunctionName,
14612 "getMethodName",CallSiteGetMethodName,
14613 "getFileName",CallSiteGetFileName,
14614 "getLineNumber",CallSiteGetLineNumber,
14615 "getColumnNumber",CallSiteGetColumnNumber,
14616 "isNative",CallSiteIsNative,
14617 "getPosition",CallSiteGetPosition,
14618 "isConstructor",CallSiteIsConstructor,
14619 "toString",CallSiteToString
14621 function FormatEvalOrigin(a){
14622 var b=a.nameOrSourceURL();
14627 if(a.eval_from_function_name){
14628 c+=a.eval_from_function_name;
14632 var d=a.eval_from_script;
14634 if(d.compilation_type==1){
14635 c+=" ("+FormatEvalOrigin(d)+")";
14639 var e=d.locationFromPosition(
14640 a.eval_from_script_position,true);
14643 c+=":"+(e.column+1);
14647 c+=" (unknown source)";
14653 function FormatErrorString(a){
14655 return %_CallFunction(a,ErrorToString);
14658 return"<error: "+e+">";
14664 function GetStackFrames(a){
14665 var b=new InternalArray();
14667 for(var d=1;d<a.length;d+=4){
14672 var j=%FunctionGetPositionForOffset(h,i);
14674 b.push(new CallSite(e,g,j,(c<0)));
14678 var formatting_custom_stack_trace=false;
14679 function FormatStackTrace(a,b){
14680 var c=GetStackFrames(b);
14681 if((%_IsFunction($Error.prepareStackTrace))&&!formatting_custom_stack_trace){
14683 %MoveArrayContents(c,d);
14684 formatting_custom_stack_trace=true;
14687 e=$Error.prepareStackTrace(a,d);
14691 formatting_custom_stack_trace=false;
14695 var g=new InternalArray();
14696 g.push(FormatErrorString(a));
14697 for(var h=0;h<c.length;h++){
14704 j="<error: "+e+">";
14711 return %_CallFunction(g,"\n",$arrayJoin);
14713 function GetTypeName(a,b){
14714 var c=a.constructor;
14717 %_CallFunction(a,NoSideEffectsObjectToString);
14722 %_CallFunction(a,NoSideEffectsObjectToString);
14726 var stack_trace_symbol;
14727 var formatted_stack_trace_symbol=(%CreatePrivateOwnSymbol("formatted stack trace"));
14728 var StackTraceGetter=function(){
14733 (b[formatted_stack_trace_symbol]);
14734 if((a===(void 0))){
14735 var c=(b[stack_trace_symbol]);
14736 if((c===(void 0))){
14737 b=%_GetPrototype(b);
14740 a=FormatStackTrace(b,c);
14741 (b[stack_trace_symbol]=(void 0));
14742 (b[formatted_stack_trace_symbol]=a);
14748 var StackTraceSetter=function(a){
14749 if((%HasOwnProperty(this,stack_trace_symbol))){
14750 (this[stack_trace_symbol]=(void 0));
14751 (this[formatted_stack_trace_symbol]=a);
14754 var captureStackTrace=function captureStackTrace(a,b){
14755 ObjectDefineProperty(a,'stack',{get:StackTraceGetter,
14756 set:StackTraceSetter,
14757 configurable:true});
14758 %CollectStackTrace(a,b?b:captureStackTrace);
14760 function SetUpError(){
14763 %AddNamedProperty(global,c,b,2);
14764 %AddNamedProperty(builtins,'$'+c,b,
14767 var d=function(){};
14768 %FunctionSetPrototype(d,$Object.prototype);
14769 %FunctionSetInstanceClassName(d,'Error');
14770 %FunctionSetPrototype(b,new d());
14772 %FunctionSetPrototype(b,new $Error());
14773 %InternalSetPrototype(b,$Error);
14775 %FunctionSetInstanceClassName(b,'Error');
14776 %AddNamedProperty(b.prototype,'constructor',b,2);
14777 %AddNamedProperty(b.prototype,'name',c,2);
14778 %SetCode(b,function(e){
14779 if(%_IsConstructCall()){
14780 try{captureStackTrace(this,b);}catch(e){}
14781 if(!(e===(void 0))){
14782 %AddNamedProperty(this,'message',ToString(e),2);
14790 a(function Error(){});
14791 a(function TypeError(){});
14792 a(function RangeError(){});
14793 a(function SyntaxError(){});
14794 a(function ReferenceError(){});
14795 a(function EvalError(){});
14796 a(function URIError(){});
14799 $Error.captureStackTrace=captureStackTrace;
14800 %AddNamedProperty($Error.prototype,'message','',2);
14801 var visited_errors=new InternalArray();
14802 var cyclic_error_marker=new $Object();
14803 function GetPropertyWithoutInvokingMonkeyGetters(a,b){
14805 while(c&&!%HasOwnProperty(c,b)){
14806 c=%_GetPrototype(c);
14808 if((c===null))return(void 0);
14809 if(!(%_IsObject(c)))return a[b];
14810 var d=%GetOwnProperty(c,b);
14813 if(c===$ReferenceError.prototype)
14814 return e?"ReferenceError":(void 0);
14815 if(c===$SyntaxError.prototype)
14816 return e?"SyntaxError":(void 0);
14817 if(c===$TypeError.prototype)
14818 return e?"TypeError":(void 0);
14822 function ErrorToStringDetectCycle(a){
14823 if(!%PushIfAbsent(visited_errors,a))throw cyclic_error_marker;
14825 var b=GetPropertyWithoutInvokingMonkeyGetters(a,"name");
14826 b=(b===(void 0))?"Error":((typeof(%IS_VAR(b))==='string')?b:NonStringToString(b));
14827 var c=GetPropertyWithoutInvokingMonkeyGetters(a,"message");
14828 c=(c===(void 0))?"":((typeof(%IS_VAR(c))==='string')?c:NonStringToString(c));
14829 if(b==="")return c;
14830 if(c==="")return b;
14833 visited_errors.length=visited_errors.length-1;
14836 function ErrorToString(){
14837 if(!(%_IsSpecObject(this))){
14838 throw MakeTypeError(3,"Error.prototype.toString");
14841 return ErrorToStringDetectCycle(this);
14843 if(e===cyclic_error_marker){
14849 InstallFunctions($Error.prototype,2,['toString',ErrorToString]);
14850 function SetUpStackOverflowBoilerplate(){
14851 var a=MakeRangeError(39);
14852 %DefineAccessorPropertyUnchecked(
14853 a,'stack',StackTraceGetter,StackTraceSetter,2);
14856 var kStackOverflowBoilerplate=SetUpStackOverflowBoilerplate();
14859 var $jsonSerializeAdapter;
14862 %CheckIsBootstrapping();
14864 function Revive(b,c,d){
14866 if((%_IsObject(e))){
14867 if((%_IsArray(e))){
14869 for(var h=0;h<g;h++){
14870 var i=Revive(e,%_NumberToString(h),d);
14875 if(%_CallFunction(e,j,ObjectHasOwnProperty)){
14876 var i=Revive(e,j,d);
14877 if((i===(void 0))){
14886 return %_CallFunction(b,c,e,d);
14888 function JSONParse(k,d){
14889 var l=%ParseJson(((typeof(%IS_VAR(k))==='string')?k:NonStringToString(k)));
14890 if((%_ClassOf(d)==='Function')){
14891 return Revive({'':l},'',d);
14896 function SerializeArray(m,n,o,q,r){
14897 if(!%PushIfAbsent(o,m)){
14898 throw MakeTypeError('circular_structure',[]);
14902 var u=new InternalArray();
14904 for(var h=0;h<w;h++){
14905 var z=JSONSerialize(%_NumberToString(h),m,n,o,
14907 if((z===(void 0))){
14914 A="["+u.join(",")+"]";
14915 }else if(u.length>0){
14917 A="[\n"+q+u.join(B)+"\n"+
14925 function SerializeObject(m,n,o,q,r){
14926 if(!%PushIfAbsent(o,m)){
14927 throw MakeTypeError('circular_structure',[]);
14931 var u=new InternalArray();
14932 if((%_IsArray(n))){
14934 for(var h=0;h<g;h++){
14935 if(%_CallFunction(n,h,ObjectHasOwnProperty)){
14937 var z=JSONSerialize(j,m,n,o,q,r);
14938 if(!(z===(void 0))){
14939 var C=%QuoteJSONString(j)+":";
14948 if(%_CallFunction(m,j,ObjectHasOwnProperty)){
14949 var z=JSONSerialize(j,m,n,o,q,r);
14950 if(!(z===(void 0))){
14951 var C=%QuoteJSONString(j)+":";
14961 A="{"+u.join(",")+"}";
14962 }else if(u.length>0){
14964 A="{\n"+q+u.join(B)+"\n"+
14972 function JSONSerialize(D,b,n,o,q,r){
14974 if((%_IsSpecObject(m))){
14976 if((%_ClassOf(E)==='Function')){
14977 m=%_CallFunction(m,D,E);
14980 if((%_ClassOf(n)==='Function')){
14981 m=%_CallFunction(b,D,m,n);
14983 if((typeof(m)==='string')){
14984 return %QuoteJSONString(m);
14985 }else if((typeof(m)==='number')){
14986 return((%_IsSmi(%IS_VAR(m))||m-m==0)?%_NumberToString(m):"null");
14987 }else if((typeof(m)==='boolean')){
14988 return m?"true":"false";
14989 }else if((m===null)){
14991 }else if((%_IsSpecObject(m))&&!(typeof m=="function")){
14992 if((%_IsArray(m))){
14993 return SerializeArray(m,n,o,q,r);
14994 }else if((%_ClassOf(m)==='Number')){
14996 return((%_IsSmi(%IS_VAR(m))||m-m==0)?%_NumberToString(m):"null");
14997 }else if((%_ClassOf(m)==='String')){
14998 return %QuoteJSONString(ToString(m));
14999 }else if((%_ClassOf(m)==='Boolean')){
15000 return %_ValueOf(m)?"true":"false";
15002 return SerializeObject(m,n,o,q,r);
15007 function JSONStringify(m,n,G){
15008 if(%_ArgumentsLength()==1){
15009 return %BasicJSONStringify(m);
15011 if((%_IsObject(G))){
15012 if((%_ClassOf(G)==='Number')){
15014 }else if((%_ClassOf(G)==='String')){
15019 if((typeof(G)==='number')){
15020 G=$max(0,$min(ToInteger(G),10));
15021 r=%_SubString(" ",0,G);
15022 }else if((typeof(G)==='string')){
15024 r=%_SubString(G,0,10);
15031 if((%_IsArray(n))){
15032 var H=new InternalArray();
15033 var I={__proto__:null};
15036 for(var h=0;h<g;h++){
15038 if((%_ClassOf(K)==='String')){
15041 if((%_ClassOf(K)==='Number'))K=ToNumber(K);
15042 if((typeof(K)==='number'))K=%_NumberToString(K);
15044 if((typeof(K)==='string')&&I[K]!=J){
15051 return JSONSerialize('',{'':m},n,new InternalArray(),"",r);
15053 %AddNamedProperty(a,symbolToStringTag,"JSON",1|2);
15054 InstallFunctions(a,2,[
15056 "stringify",JSONStringify
15058 $jsonSerializeAdapter=function(D,L){
15061 return JSONSerialize(D,b,(void 0),new InternalArray(),"","");
15066 var $iteratorCreateResultObject;
15070 %CheckIsBootstrapping();
15071 var a=global.Array;
15072 var b=global.Object;
15073 var c=global.Uint8Array;
15075 var d=global.Int8Array;
15077 var e=global.Uint16Array;
15079 var g=global.Int16Array;
15081 var h=global.Uint32Array;
15083 var i=global.Int32Array;
15085 var j=global.Float32Array;
15087 var k=global.Float64Array;
15089 var l=global.Uint8ClampedArray;
15092 var m=(%CreateGlobalPrivateOwnSymbol("ArrayIterator#object"));
15093 var n=(%CreateGlobalPrivateOwnSymbol("ArrayIterator#next"));
15094 var o=(%CreateGlobalPrivateOwnSymbol("ArrayIterator#kind"));
15095 function ArrayIterator(){}
15096 function CreateArrayIterator(q,r){
15098 var u=new ArrayIterator;
15104 function CreateIteratorResultObject(w,z){
15105 return{value:w,done:z};
15107 function ArrayIteratorIterator(){
15110 function ArrayIteratorNext(){
15111 var u=ToObject(this);
15112 if(!(!(u[n]===(void 0)))){
15113 throw MakeTypeError(8,
15114 'Array Iterator.prototype.next',this);
15117 if((q===(void 0))){
15118 return CreateIteratorResultObject((void 0),true);
15122 var C=(q.length>>>0);
15125 return CreateIteratorResultObject((void 0),true);
15129 return CreateIteratorResultObject(q[A],false);
15132 return CreateIteratorResultObject([A,q[A]],false);
15134 return CreateIteratorResultObject(A,false);
15136 function ArrayEntries(){
15137 return CreateArrayIterator(this,3);
15139 function ArrayValues(){
15140 return CreateArrayIterator(this,2);
15142 function ArrayKeys(){
15143 return CreateArrayIterator(this,1);
15145 %FunctionSetPrototype(ArrayIterator,new b());
15146 %FunctionSetInstanceClassName(ArrayIterator,'Array Iterator');
15147 InstallFunctions(ArrayIterator.prototype,2,[
15148 'next',ArrayIteratorNext
15150 %FunctionSetName(ArrayIteratorIterator,'[Symbol.iterator]');
15151 %AddNamedProperty(ArrayIterator.prototype,symbolIterator,
15152 ArrayIteratorIterator,2);
15153 %AddNamedProperty(ArrayIterator.prototype,symbolToStringTag,
15154 "Array Iterator",1|2);
15155 InstallFunctions(a.prototype,2,[
15156 'entries',ArrayEntries,
15159 %AddNamedProperty(a.prototype,symbolIterator,ArrayValues,
15161 %AddNamedProperty(c.prototype,'entries',ArrayEntries,2);
15162 %AddNamedProperty(c.prototype,'values',ArrayValues,2);
15163 %AddNamedProperty(c.prototype,'keys',ArrayKeys,2);
15164 %AddNamedProperty(c.prototype,symbolIterator,ArrayValues,
15167 %AddNamedProperty(d.prototype,'entries',ArrayEntries,2);
15168 %AddNamedProperty(d.prototype,'values',ArrayValues,2);
15169 %AddNamedProperty(d.prototype,'keys',ArrayKeys,2);
15170 %AddNamedProperty(d.prototype,symbolIterator,ArrayValues,
15173 %AddNamedProperty(e.prototype,'entries',ArrayEntries,2);
15174 %AddNamedProperty(e.prototype,'values',ArrayValues,2);
15175 %AddNamedProperty(e.prototype,'keys',ArrayKeys,2);
15176 %AddNamedProperty(e.prototype,symbolIterator,ArrayValues,
15179 %AddNamedProperty(g.prototype,'entries',ArrayEntries,2);
15180 %AddNamedProperty(g.prototype,'values',ArrayValues,2);
15181 %AddNamedProperty(g.prototype,'keys',ArrayKeys,2);
15182 %AddNamedProperty(g.prototype,symbolIterator,ArrayValues,
15185 %AddNamedProperty(h.prototype,'entries',ArrayEntries,2);
15186 %AddNamedProperty(h.prototype,'values',ArrayValues,2);
15187 %AddNamedProperty(h.prototype,'keys',ArrayKeys,2);
15188 %AddNamedProperty(h.prototype,symbolIterator,ArrayValues,
15191 %AddNamedProperty(i.prototype,'entries',ArrayEntries,2);
15192 %AddNamedProperty(i.prototype,'values',ArrayValues,2);
15193 %AddNamedProperty(i.prototype,'keys',ArrayKeys,2);
15194 %AddNamedProperty(i.prototype,symbolIterator,ArrayValues,
15197 %AddNamedProperty(j.prototype,'entries',ArrayEntries,2);
15198 %AddNamedProperty(j.prototype,'values',ArrayValues,2);
15199 %AddNamedProperty(j.prototype,'keys',ArrayKeys,2);
15200 %AddNamedProperty(j.prototype,symbolIterator,ArrayValues,
15203 %AddNamedProperty(k.prototype,'entries',ArrayEntries,2);
15204 %AddNamedProperty(k.prototype,'values',ArrayValues,2);
15205 %AddNamedProperty(k.prototype,'keys',ArrayKeys,2);
15206 %AddNamedProperty(k.prototype,symbolIterator,ArrayValues,
15209 %AddNamedProperty(l.prototype,'entries',ArrayEntries,2);
15210 %AddNamedProperty(l.prototype,'values',ArrayValues,2);
15211 %AddNamedProperty(l.prototype,'keys',ArrayKeys,2);
15212 %AddNamedProperty(l.prototype,symbolIterator,ArrayValues,
15216 $iteratorCreateResultObject=CreateIteratorResultObject;
15217 $arrayValues=ArrayValues;
15220 <string-iterator}
\1a
15223 %CheckIsBootstrapping();
15224 var a=global.Object;
15225 var b=global.String;
15227 (%CreateGlobalPrivateOwnSymbol("StringIterator#iteratedString"));
15228 var d=(%CreateGlobalPrivateOwnSymbol("StringIterator#next"));
15229 function StringIterator(){}
15230 function CreateStringIterator(e){
15231 var g=((typeof(%IS_VAR(e))==='string')?e:NonStringToString(e));
15232 var h=new StringIterator;
15237 function StringIteratorIterator(){
15240 function StringIteratorNext(){
15241 var h=ToObject(this);
15242 if(!(!(h[d]===(void 0)))){
15243 throw MakeTypeError(8,
15244 'String Iterator.prototype.next');
15247 if((g===(void 0))){
15248 return $iteratorCreateResultObject((void 0),true);
15251 var j=(g.length>>>0);
15254 return $iteratorCreateResultObject((void 0),true);
15256 var k=%_StringCharCodeAt(g,i);
15257 var l=%_StringCharFromCode(k);
15259 if(k>=0xD800&&k<=0xDBFF&&i<j){
15260 var m=%_StringCharCodeAt(g,i);
15261 if(m>=0xDC00&&m<=0xDFFF){
15262 l+=%_StringCharFromCode(m);
15267 return $iteratorCreateResultObject(l,false);
15269 function StringPrototypeIterator(){
15270 return CreateStringIterator(this);
15272 %FunctionSetPrototype(StringIterator,new a());
15273 %FunctionSetInstanceClassName(StringIterator,'String Iterator');
15274 InstallFunctions(StringIterator.prototype,2,[
15275 'next',StringIteratorNext
15277 %FunctionSetName(StringIteratorIterator,'[Symbol.iterator]');
15278 %AddNamedProperty(StringIterator.prototype,symbolIterator,
15279 StringIteratorIterator,2);
15280 %AddNamedProperty(StringIterator.prototype,symbolToStringTag,
15281 "String Iterator",1|2);
15282 %FunctionSetName(StringPrototypeIterator,'[Symbol.iterator]');
15283 %AddNamedProperty(b.prototype,symbolIterator,
15284 StringPrototypeIterator,2);
15288 var $getTemplateCallSite;
15291 %CheckIsBootstrapping();
15292 var a=new global.Map;
15293 var b=global.Map.prototype.get;
15294 var c=global.Map.prototype.set;
15295 function SameCallSiteElements(d,e){
15298 if(g!==e.length)return false;
15299 for(var h=0;h<g;++h){
15300 if(d[h]!==e[h])return false;
15304 function GetCachedCallSite(i,j){
15305 var k=%_CallFunction(a,j,b);
15306 if((k===(void 0)))return;
15308 for(var h=0;h<g;++h){
15309 if(SameCallSiteElements(i,k[h]))return k[h];
15312 function SetCachedCallSite(i,j){
15313 var k=%_CallFunction(a,j,b);
15315 if((k===(void 0))){
15316 l=new InternalArray(1);
15318 %_CallFunction(a,j,l,c);
15324 $getTemplateCallSite=function(i,d,j){
15325 var m=GetCachedCallSite(d,j);
15326 if(!(m===(void 0)))return m;
15327 %AddNamedProperty(i,"raw",%ObjectFreeze(d),
15329 return SetCachedCallSite(%ObjectFreeze(i),j);
15336 %CheckIsBootstrapping();
15337 var a=global.Boolean;
15339 var c=global.Number;
15340 var d=global.RegExp;
15341 var e=global.String;
15342 var g=global.undefined;
15344 %AddNamedProperty(global,"Intl",h,2);
15361 function GetUnicodeExtensionRE(){
15363 m=new d('-u(-[a-z0-9]{2,8})+','g');
15368 function GetAnyExtensionRE(){
15370 n=new d('-[a-z0-9]{1}-.*','g');
15375 function GetQuotedStringRE(){
15377 o=new d("'[^']+'",'g');
15382 function GetServiceRE(){
15385 new d('^(collator|numberformat|dateformat|breakiterator)$');
15390 function GetLanguageTagRE(){
15392 BuildLanguageTagREs();
15397 function GetLanguageVariantRE(){
15399 BuildLanguageTagREs();
15404 function GetLanguageSingletonRE(){
15406 BuildLanguageTagREs();
15411 function GetTimezoneNameCheckRE(){
15414 new d('^([A-Za-z]+)/([A-Za-z]+)(?:_([A-Za-z]+))*$');
15419 'gregorian':'gregory',
15420 'japanese':'japanese',
15421 'buddhist':'buddhist',
15423 'persian':'persian',
15424 'islamic-civil':'islamicc',
15425 'islamic':'islamic',
15427 'chinese':'chinese',
15430 'ethiopic':'ethiopic',
15431 'ethiopic-amete-alem':'ethioaa'
15434 'kn':{'property':'numeric','type':'boolean'},
15435 'kf':{'property':'caseFirst','type':'string',
15436 'values':['false','lower','upper']}
15439 'nu':{'property':g,'type':'string'}
15442 'ca':{'property':g,'type':'string'},
15443 'nu':{'property':g,'type':'string'}
15446 'big5han','dict','direct','ducet','gb2312','phonebk','phonetic',
15447 'pinyin','reformed','searchjl','stroke','trad','unihan','zhuyin'
15450 'Function object that\'s not a constructor was created with new';
15451 function addBoundMethod(G,H,I,J){
15453 if(!%IsInitializedIntlObject(this)){
15454 throw new $TypeError('Method '+H+' called on a '+
15455 'non-object or on a wrong type of object.');
15457 var K='__bound'+H+'__';
15463 if(%_IsConstructCall()){
15464 throw new $TypeError(E);
15470 if(%_IsConstructCall()){
15471 throw new $TypeError(E);
15477 if(%_IsConstructCall()){
15478 throw new $TypeError(E);
15480 if(%_ArgumentsLength()>0){
15481 return I(L,%_Arguments(0));
15487 %FunctionSetName(M,K);
15488 %FunctionRemovePrototype(M);
15494 %FunctionSetName(getter,H);
15495 %FunctionRemovePrototype(getter);
15496 %SetNativeFlag(getter);
15497 ObjectDefineProperty(G.prototype,H,{
15503 function supportedLocalesOf(Q,R,S){
15504 if((Q.match(GetServiceRE())===null)){
15505 throw new $Error('Internal error, wrong service type: '+Q);
15512 var T=S.localeMatcher;
15515 if(T!=='lookup'&&T!=='best fit'){
15516 throw new $RangeError('Illegal value for localeMatcher:'+T);
15521 var U=initializeLocaleList(R);
15523 k[Q]=getAvailableLocalesOf(Q);
15525 if(T==='best fit'){
15526 return initializeLocaleList(bestFitSupportedLocalesOf(
15529 return initializeLocaleList(lookupSupportedLocalesOf(
15532 function lookupSupportedLocalesOf(U,W){
15534 for(var Y=0;Y<U.length;++Y){
15535 var Z=U[Y].replace(GetUnicodeExtensionRE(),'');
15541 var aa=Z.lastIndexOf('-');
15545 Z=Z.substring(0,aa);
15550 function bestFitSupportedLocalesOf(U,W){
15551 return lookupSupportedLocalesOf(U,W);
15553 function getGetOption(S,ab){
15555 throw new $Error('Internal '+ab+' error. '+
15556 'Default options are missing.');
15558 var ac=function getOption(ad,ae,af,ag){
15572 throw new $Error('Internal error. Wrong value type.');
15574 if(af!==g&&af.indexOf(ah)===-1){
15575 throw new $RangeError('Value '+ah+' out of range for '+ab+
15576 ' options property '+ad);
15584 function resolveLocale(Q,U,S){
15585 U=initializeLocaleList(U);
15586 var ac=getGetOption(S,Q);
15587 var T=ac('localeMatcher','string',
15588 ['lookup','best fit'],'best fit');
15591 ai=lookupMatcher(Q,U);
15593 ai=bestFitMatcher(Q,U);
15597 function lookupMatcher(Q,U){
15598 if((Q.match(GetServiceRE())===null)){
15599 throw new $Error('Internal error, wrong service type: '+Q);
15602 k[Q]=getAvailableLocalesOf(Q);
15604 for(var Y=0;Y<U.length;++Y){
15605 var Z=U[Y].replace(GetAnyExtensionRE(),'');
15608 var aj=U[Y].match(GetUnicodeExtensionRE());
15609 var ak=(aj===null)?'':aj[0];
15610 return{'locale':Z,'extension':ak,'position':Y};
15612 var aa=Z.lastIndexOf('-');
15616 Z=Z.substring(0,aa);
15620 l=%GetDefaultICULocale();
15622 return{'locale':l,'extension':'','position':-1};
15624 function bestFitMatcher(Q,U){
15625 return lookupMatcher(Q,U);
15627 function parseExtension(ak){
15628 var al=ak.split('-');
15630 (al[0]!==''&&al[1]!=='u')){
15635 for(var Y=2;Y<al.length;++Y){
15636 var J=al[Y].length;
15641 }else if(J>=3&&J<=8&&an!==g){
15650 function setOptions(ap,am,aq,ac,ar){
15652 var as=function updateExtension(at,ah){
15653 return'-'+at+'-'+e(ah);
15655 var au=function updateProperty(ad,ae,ah){
15656 if(ae==='boolean'&&(typeof ah==='string')){
15657 ah=(ah==='true')?true:false;
15660 defineWEProperty(ar,ad,ah);
15664 if(aq.hasOwnProperty(at)){
15667 if(av.property!==g){
15668 ah=ac(av.property,av.type,av.values);
15671 au(av.property,av.type,ah);
15675 if(am.hasOwnProperty(at)){
15678 au(av.property,av.type,ah);
15680 }else if(av.type==='boolean'){
15681 au(av.property,av.type,true);
15687 return ak===''?'':'-u'+ak;
15689 function freezeArray(aw){
15690 aw.forEach(function(ao,ax){
15691 ObjectDefineProperty(aw,ax,{value:ao,
15692 configurable:false,
15696 ObjectDefineProperty(aw,'length',{value:aw.length,
15700 function getOptimalLanguageTag(ay,ai){
15704 var R=%GetLanguageTagVariants([ay,ai]);
15705 if(R[0].maximized!==R[1].maximized){
15708 var az=new d('^'+R[1].base);
15709 return ai.replace(az,R[0].base);
15711 function getAvailableLocalesOf(Q){
15712 var aA=%AvailableLocalesOf(Q);
15714 if(aA.hasOwnProperty(Y)){
15715 var aB=Y.match(/^([a-z]{2,3})-([A-Z][a-z]{3})-([A-Z]{2})$/);
15717 aA[aB[1]+'-'+aB[3]]=null;
15723 function defineWEProperty(aC,ad,ah){
15724 ObjectDefineProperty(aC,ad,
15725 {value:ah,writable:true,enumerable:true});
15727 function addWEPropertyIfDefined(aC,ad,ah){
15729 defineWEProperty(aC,ad,ah);
15732 function defineWECProperty(aC,ad,ah){
15733 ObjectDefineProperty(aC,ad,
15737 configurable:true});
15739 function addWECPropertyIfDefined(aC,ad,ah){
15741 defineWECProperty(aC,ad,ah);
15744 function toTitleCaseWord(aD){
15745 return aD.substr(0,1).toUpperCase()+aD.substr(1).toLowerCase();
15747 function canonicalizeLanguageTag(aE){
15748 if(typeof aE!=='string'&&typeof aE!=='object'||
15750 throw new $TypeError('Language ID should be string or object.');
15753 if(isValidLanguageTag(aF)===false){
15754 throw new $RangeError('Invalid language tag: '+aF);
15756 var aG=%CanonicalizeLanguageTag(aF);
15757 if(aG==='invalid-tag'){
15758 throw new $RangeError('Invalid language tag: '+aF);
15762 function initializeLocaleList(R){
15767 if(typeof R==='string'){
15768 aH.push(canonicalizeLanguageTag(R));
15769 return freezeArray(aH);
15771 var aI=ToObject(R);
15772 var aJ=aI.length>>>0;
15773 for(var aK=0;aK<aJ;aK++){
15776 var aG=canonicalizeLanguageTag(ah);
15777 if(aH.indexOf(aG)===-1){
15783 return freezeArray(aH);
15785 function isValidLanguageTag(Z){
15786 if(GetLanguageTagRE().test(Z)===false){
15789 if(Z.indexOf('x-')===0){
15792 Z=Z.split(/-x-/)[0];
15795 var aB=Z.split(/-/);
15796 for(var Y=1;Y<aB.length;Y++){
15798 if(GetLanguageVariantRE().test(ah)===true&&aM.length===0){
15799 if(aL.indexOf(ah)===-1){
15805 if(GetLanguageSingletonRE().test(ah)===true){
15806 if(aM.indexOf(ah)===-1){
15815 function BuildLanguageTagREs(){
15818 var aP='('+aN+'|'+aO+')';
15819 var aQ='(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|'+
15820 'zh-min|zh-min-nan|zh-xiang)';
15821 var aR='(en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|'+
15822 'i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|'+
15823 'i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)';
15824 var aS='('+aR+'|'+aQ+')';
15825 var aT='(x(-'+aP+'{1,8})+)';
15826 var aU='('+aO+'|[A-WY-Za-wy-z])';
15827 u=new d('^'+aU+'$','i');
15828 var ak='('+aU+'(-'+aP+'{2,8})+)';
15829 var aV='('+aP+'{5,8}|('+aO+aP+'{3}))';
15830 t=new d('^'+aV+'$','i');
15831 var aW='('+aN+'{2}|'+aO+'{3})';
15832 var aX='('+aN+'{4})';
15833 var aY='('+aN+'{3}(-'+aN+'{3}){0,2})';
15834 var aZ='('+aN+'{2,3}(-'+aY+')?|'+aN+'{4}|'+
15836 var ba=aZ+'(-'+aX+')?(-'+aW+')?(-'+
15837 aV+')*(-'+ak+')*(-'+aT+')?';
15839 '^('+ba+'|'+aT+'|'+aS+')$';
15842 function initializeCollator(bc,R,S){
15843 if(%IsInitializedIntlObject(bc)){
15844 throw new $TypeError('Trying to re-initialize Collator object.');
15849 var ac=getGetOption(S,'collator');
15851 defineWEProperty(bd,'usage',ac(
15852 'usage','string',['sort','search'],'sort'));
15853 var be=ac('sensitivity','string',
15854 ['base','accent','case','variant']);
15855 if(be===g&&bd.usage==='sort'){
15858 defineWEProperty(bd,'sensitivity',be);
15859 defineWEProperty(bd,'ignorePunctuation',ac(
15860 'ignorePunctuation','boolean',g,false));
15861 var Z=resolveLocale('collator',R,S);
15862 var am=parseExtension(Z.extension);
15867 if(am.hasOwnProperty('co')&&bd.usage==='sort'){
15868 if(D.indexOf(am.co)!==-1){
15872 }else if(bd.usage==='search'){
15875 defineWEProperty(bd,'collation',bf);
15876 var bg=Z.locale+ak;
15877 var ai=ObjectDefineProperties({},{
15878 caseFirst:{writable:true},
15879 collation:{value:bd.collation,writable:true},
15880 ignorePunctuation:{writable:true},
15881 locale:{writable:true},
15882 numeric:{writable:true},
15883 requestedLocale:{value:bg,writable:true},
15884 sensitivity:{writable:true},
15885 strength:{writable:true},
15886 usage:{value:bd.usage,writable:true}
15888 var bh=%CreateCollator(bg,
15891 %MarkAsInitializedIntlObjectOfType(bc,'collator',bh);
15892 ObjectDefineProperty(bc,'resolved',{value:ai});
15895 %AddNamedProperty(h,'Collator',function(){
15896 var R=%_Arguments(0);
15897 var S=%_Arguments(1);
15898 if(!this||this===h){
15899 return new h.Collator(R,S);
15901 return initializeCollator(ToObject(this),R,S);
15905 %AddNamedProperty(h.Collator.prototype,'resolvedOptions',function(){
15906 if(%_IsConstructCall()){
15907 throw new $TypeError(E);
15909 if(!%IsInitializedIntlObjectOfType(this,'collator')){
15910 throw new $TypeError('resolvedOptions method called on a non-object '+
15911 'or on a object that is not Intl.Collator.');
15914 var Z=getOptimalLanguageTag(bi.resolved.requestedLocale,
15915 bi.resolved.locale);
15918 usage:bi.resolved.usage,
15919 sensitivity:bi.resolved.sensitivity,
15920 ignorePunctuation:bi.resolved.ignorePunctuation,
15921 numeric:bi.resolved.numeric,
15922 caseFirst:bi.resolved.caseFirst,
15923 collation:bi.resolved.collation
15928 %FunctionSetName(h.Collator.prototype.resolvedOptions,'resolvedOptions');
15929 %FunctionRemovePrototype(h.Collator.prototype.resolvedOptions);
15930 %SetNativeFlag(h.Collator.prototype.resolvedOptions);
15931 %AddNamedProperty(h.Collator,'supportedLocalesOf',function(R){
15932 if(%_IsConstructCall()){
15933 throw new $TypeError(E);
15935 return supportedLocalesOf('collator',R,%_Arguments(1));
15939 %FunctionSetName(h.Collator.supportedLocalesOf,'supportedLocalesOf');
15940 %FunctionRemovePrototype(h.Collator.supportedLocalesOf);
15941 %SetNativeFlag(h.Collator.supportedLocalesOf);
15942 function compare(bc,N,P){
15943 return %InternalCompare(%GetImplFromInitializedIntlObject(bc),
15946 addBoundMethod(h.Collator,'compare',compare,2);
15947 function isWellFormedCurrencyCode(bj){
15948 return typeof bj=="string"&&
15950 bj.match(/[^A-Za-z]/)==null;
15952 function getNumberOption(S,ad,bk,bl,bm){
15956 if($isNaN(ah)||ah<bk||ah>bl){
15957 throw new $RangeError(ad+' value is out of range.');
15963 function initializeNumberFormat(bn,R,S){
15964 if(%IsInitializedIntlObject(bn)){
15965 throw new $TypeError('Trying to re-initialize NumberFormat object.');
15970 var ac=getGetOption(S,'numberformat');
15971 var Z=resolveLocale('numberformat',R,S);
15973 defineWEProperty(bd,'style',ac(
15974 'style','string',['decimal','percent','currency'],'decimal'));
15975 var bj=ac('currency','string');
15976 if(bj!==g&&!isWellFormedCurrencyCode(bj)){
15977 throw new $RangeError('Invalid currency code: '+bj);
15979 if(bd.style==='currency'&&bj===g){
15980 throw new $TypeError('Currency code is required with currency style.');
15983 'currencyDisplay','string',['code','symbol','name'],'symbol');
15984 if(bd.style==='currency'){
15985 defineWEProperty(bd,'currency',bj.toUpperCase());
15986 defineWEProperty(bd,'currencyDisplay',bo);
15988 var bp=getNumberOption(S,'minimumIntegerDigits',1,21,1);
15989 defineWEProperty(bd,'minimumIntegerDigits',bp);
15990 var bq=getNumberOption(S,'minimumFractionDigits',0,20,0);
15991 defineWEProperty(bd,'minimumFractionDigits',bq);
15992 var br=getNumberOption(S,'maximumFractionDigits',bq,20,3);
15993 defineWEProperty(bd,'maximumFractionDigits',br);
15994 var bs=S['minimumSignificantDigits'];
15995 var bt=S['maximumSignificantDigits'];
15996 if(bs!==g||bt!==g){
15997 bs=getNumberOption(S,'minimumSignificantDigits',1,21,0);
15998 defineWEProperty(bd,'minimumSignificantDigits',bs);
15999 bt=getNumberOption(S,'maximumSignificantDigits',bs,21,21);
16000 defineWEProperty(bd,'maximumSignificantDigits',bt);
16002 defineWEProperty(bd,'useGrouping',ac(
16003 'useGrouping','boolean',g,true));
16004 var am=parseExtension(Z.extension);
16005 var ak=setOptions(S,am,B,
16007 var bg=Z.locale+ak;
16008 var ai=ObjectDefineProperties({},{
16009 currency:{writable:true},
16010 currencyDisplay:{writable:true},
16011 locale:{writable:true},
16012 maximumFractionDigits:{writable:true},
16013 minimumFractionDigits:{writable:true},
16014 minimumIntegerDigits:{writable:true},
16015 numberingSystem:{writable:true},
16016 requestedLocale:{value:bg,writable:true},
16017 style:{value:bd.style,writable:true},
16018 useGrouping:{writable:true}
16020 if(bd.hasOwnProperty('minimumSignificantDigits')){
16021 defineWEProperty(ai,'minimumSignificantDigits',g);
16023 if(bd.hasOwnProperty('maximumSignificantDigits')){
16024 defineWEProperty(ai,'maximumSignificantDigits',g);
16026 var bu=%CreateNumberFormat(bg,
16029 if(bd.style==='currency'){
16030 ObjectDefineProperty(ai,'currencyDisplay',{value:bo,
16033 %MarkAsInitializedIntlObjectOfType(bn,'numberformat',bu);
16034 ObjectDefineProperty(bn,'resolved',{value:ai});
16037 %AddNamedProperty(h,'NumberFormat',function(){
16038 var R=%_Arguments(0);
16039 var S=%_Arguments(1);
16040 if(!this||this===h){
16041 return new h.NumberFormat(R,S);
16043 return initializeNumberFormat(ToObject(this),R,S);
16047 %AddNamedProperty(h.NumberFormat.prototype,'resolvedOptions',function(){
16048 if(%_IsConstructCall()){
16049 throw new $TypeError(E);
16051 if(!%IsInitializedIntlObjectOfType(this,'numberformat')){
16052 throw new $TypeError('resolvedOptions method called on a non-object'+
16053 ' or on a object that is not Intl.NumberFormat.');
16056 var Z=getOptimalLanguageTag(bv.resolved.requestedLocale,
16057 bv.resolved.locale);
16060 numberingSystem:bv.resolved.numberingSystem,
16061 style:bv.resolved.style,
16062 useGrouping:bv.resolved.useGrouping,
16063 minimumIntegerDigits:bv.resolved.minimumIntegerDigits,
16064 minimumFractionDigits:bv.resolved.minimumFractionDigits,
16065 maximumFractionDigits:bv.resolved.maximumFractionDigits,
16067 if(bw.style==='currency'){
16068 defineWECProperty(bw,'currency',bv.resolved.currency);
16069 defineWECProperty(bw,'currencyDisplay',
16070 bv.resolved.currencyDisplay);
16072 if(bv.resolved.hasOwnProperty('minimumSignificantDigits')){
16073 defineWECProperty(bw,'minimumSignificantDigits',
16074 bv.resolved.minimumSignificantDigits);
16076 if(bv.resolved.hasOwnProperty('maximumSignificantDigits')){
16077 defineWECProperty(bw,'maximumSignificantDigits',
16078 bv.resolved.maximumSignificantDigits);
16084 %FunctionSetName(h.NumberFormat.prototype.resolvedOptions,
16085 'resolvedOptions');
16086 %FunctionRemovePrototype(h.NumberFormat.prototype.resolvedOptions);
16087 %SetNativeFlag(h.NumberFormat.prototype.resolvedOptions);
16088 %AddNamedProperty(h.NumberFormat,'supportedLocalesOf',function(R){
16089 if(%_IsConstructCall()){
16090 throw new $TypeError(E);
16092 return supportedLocalesOf('numberformat',R,%_Arguments(1));
16096 %FunctionSetName(h.NumberFormat.supportedLocalesOf,'supportedLocalesOf');
16097 %FunctionRemovePrototype(h.NumberFormat.supportedLocalesOf);
16098 %SetNativeFlag(h.NumberFormat.supportedLocalesOf);
16099 function formatNumber(bu,ah){
16101 return %InternalNumberFormat(%GetImplFromInitializedIntlObject(bu),
16104 function parseNumber(bu,ah){
16105 return %InternalNumberParse(%GetImplFromInitializedIntlObject(bu),
16108 addBoundMethod(h.NumberFormat,'format',formatNumber,1);
16109 addBoundMethod(h.NumberFormat,'v8Parse',parseNumber,1);
16110 function toLDMLString(S){
16111 var ac=getGetOption(S,'dateformat');
16113 var bz=ac('weekday','string',['narrow','short','long']);
16114 by+=appendToLDMLString(
16115 bz,{narrow:'EEEEE',short:'EEE',long:'EEEE'});
16116 bz=ac('era','string',['narrow','short','long']);
16117 by+=appendToLDMLString(
16118 bz,{narrow:'GGGGG',short:'GGG',long:'GGGG'});
16119 bz=ac('year','string',['2-digit','numeric']);
16120 by+=appendToLDMLString(bz,{'2-digit':'yy','numeric':'y'});
16121 bz=ac('month','string',
16122 ['2-digit','numeric','narrow','short','long']);
16123 by+=appendToLDMLString(bz,{'2-digit':'MM','numeric':'M',
16124 'narrow':'MMMMM','short':'MMM','long':'MMMM'});
16125 bz=ac('day','string',['2-digit','numeric']);
16126 by+=appendToLDMLString(
16127 bz,{'2-digit':'dd','numeric':'d'});
16128 var bA=ac('hour12','boolean');
16129 bz=ac('hour','string',['2-digit','numeric']);
16131 by+=appendToLDMLString(bz,{'2-digit':'jj','numeric':'j'});
16132 }else if(bA===true){
16133 by+=appendToLDMLString(bz,{'2-digit':'hh','numeric':'h'});
16135 by+=appendToLDMLString(bz,{'2-digit':'HH','numeric':'H'});
16137 bz=ac('minute','string',['2-digit','numeric']);
16138 by+=appendToLDMLString(bz,{'2-digit':'mm','numeric':'m'});
16139 bz=ac('second','string',['2-digit','numeric']);
16140 by+=appendToLDMLString(bz,{'2-digit':'ss','numeric':'s'});
16141 bz=ac('timeZoneName','string',['short','long']);
16142 by+=appendToLDMLString(bz,{short:'z',long:'zzzz'});
16145 function appendToLDMLString(bz,bB){
16152 function fromLDMLString(by){
16153 by=by.replace(GetQuotedStringRE(),'');
16155 var bC=by.match(/E{3,5}/g);
16156 S=appendToDateTimeObject(
16157 S,'weekday',bC,{EEEEE:'narrow',EEE:'short',EEEE:'long'});
16158 bC=by.match(/G{3,5}/g);
16159 S=appendToDateTimeObject(
16160 S,'era',bC,{GGGGG:'narrow',GGG:'short',GGGG:'long'});
16161 bC=by.match(/y{1,2}/g);
16162 S=appendToDateTimeObject(
16163 S,'year',bC,{y:'numeric',yy:'2-digit'});
16164 bC=by.match(/M{1,5}/g);
16165 S=appendToDateTimeObject(S,'month',bC,{MM:'2-digit',
16166 M:'numeric',MMMMM:'narrow',MMM:'short',MMMM:'long'});
16167 bC=by.match(/L{1,5}/g);
16168 S=appendToDateTimeObject(S,'month',bC,{LL:'2-digit',
16169 L:'numeric',LLLLL:'narrow',LLL:'short',LLLL:'long'});
16170 bC=by.match(/d{1,2}/g);
16171 S=appendToDateTimeObject(
16172 S,'day',bC,{d:'numeric',dd:'2-digit'});
16173 bC=by.match(/h{1,2}/g);
16177 S=appendToDateTimeObject(
16178 S,'hour',bC,{h:'numeric',hh:'2-digit'});
16179 bC=by.match(/H{1,2}/g);
16183 S=appendToDateTimeObject(
16184 S,'hour',bC,{H:'numeric',HH:'2-digit'});
16185 bC=by.match(/m{1,2}/g);
16186 S=appendToDateTimeObject(
16187 S,'minute',bC,{m:'numeric',mm:'2-digit'});
16188 bC=by.match(/s{1,2}/g);
16189 S=appendToDateTimeObject(
16190 S,'second',bC,{s:'numeric',ss:'2-digit'});
16191 bC=by.match(/z|zzzz/g);
16192 S=appendToDateTimeObject(
16193 S,'timeZoneName',bC,{z:'short',zzzz:'long'});
16196 function appendToDateTimeObject(S,bz,bC,bB){
16198 if(!S.hasOwnProperty(bz)){
16199 defineWEProperty(S,bz,g);
16204 defineWEProperty(S,bz,bB[ad]);
16207 function toDateTimeOptions(S,bD,bE){
16211 S=((%_IsSpecObject(%IS_VAR(S)))?S:ToObject(S));
16214 if((bD==='date'||bD==='any')&&
16215 (S.weekday!==g||S.year!==g||
16216 S.month!==g||S.day!==g)){
16219 if((bD==='time'||bD==='any')&&
16220 (S.hour!==g||S.minute!==g||
16224 if(bF&&(bE==='date'||bE==='all')){
16225 ObjectDefineProperty(S,'year',{value:'numeric',
16228 configurable:true});
16229 ObjectDefineProperty(S,'month',{value:'numeric',
16232 configurable:true});
16233 ObjectDefineProperty(S,'day',{value:'numeric',
16236 configurable:true});
16238 if(bF&&(bE==='time'||bE==='all')){
16239 ObjectDefineProperty(S,'hour',{value:'numeric',
16242 configurable:true});
16243 ObjectDefineProperty(S,'minute',{value:'numeric',
16246 configurable:true});
16247 ObjectDefineProperty(S,'second',{value:'numeric',
16250 configurable:true});
16254 function initializeDateTimeFormat(bG,R,S){
16255 if(%IsInitializedIntlObject(bG)){
16256 throw new $TypeError('Trying to re-initialize DateTimeFormat object.');
16261 var Z=resolveLocale('dateformat',R,S);
16262 S=toDateTimeOptions(S,'any','date');
16263 var ac=getGetOption(S,'dateformat');
16264 var T=ac('formatMatcher','string',
16265 ['basic','best fit'],'best fit');
16266 var by=toLDMLString(S);
16267 var bH=canonicalizeTimeZoneID(S.timeZone);
16269 var am=parseExtension(Z.extension);
16270 var ak=setOptions(S,am,C,
16272 var bg=Z.locale+ak;
16273 var ai=ObjectDefineProperties({},{
16274 calendar:{writable:true},
16275 day:{writable:true},
16276 era:{writable:true},
16277 hour12:{writable:true},
16278 hour:{writable:true},
16279 locale:{writable:true},
16280 minute:{writable:true},
16281 month:{writable:true},
16282 numberingSystem:{writable:true},
16283 pattern:{writable:true},
16284 requestedLocale:{value:bg,writable:true},
16285 second:{writable:true},
16286 timeZone:{writable:true},
16287 timeZoneName:{writable:true},
16288 tz:{value:bH,writable:true},
16289 weekday:{writable:true},
16290 year:{writable:true}
16292 var bu=%CreateDateTimeFormat(
16293 bg,{skeleton:by,timeZone:bH},ai);
16294 if(bH!==g&&bH!==ai.timeZone){
16295 throw new $RangeError('Unsupported time zone specified '+bH);
16297 %MarkAsInitializedIntlObjectOfType(bG,'dateformat',bu);
16298 ObjectDefineProperty(bG,'resolved',{value:ai});
16301 %AddNamedProperty(h,'DateTimeFormat',function(){
16302 var R=%_Arguments(0);
16303 var S=%_Arguments(1);
16304 if(!this||this===h){
16305 return new h.DateTimeFormat(R,S);
16307 return initializeDateTimeFormat(ToObject(this),R,S);
16311 %AddNamedProperty(h.DateTimeFormat.prototype,'resolvedOptions',function(){
16312 if(%_IsConstructCall()){
16313 throw new $TypeError(E);
16315 if(!%IsInitializedIntlObjectOfType(this,'dateformat')){
16316 throw new $TypeError('resolvedOptions method called on a non-object or '+
16317 'on a object that is not Intl.DateTimeFormat.');
16320 var bI=fromLDMLString(bv.resolved.pattern);
16321 var bJ=z[bv.resolved.calendar];
16323 bJ=bv.resolved.calendar;
16325 var Z=getOptimalLanguageTag(bv.resolved.requestedLocale,
16326 bv.resolved.locale);
16329 numberingSystem:bv.resolved.numberingSystem,
16331 timeZone:bv.resolved.timeZone
16333 addWECPropertyIfDefined(bw,'timeZoneName',bI.timeZoneName);
16334 addWECPropertyIfDefined(bw,'era',bI.era);
16335 addWECPropertyIfDefined(bw,'year',bI.year);
16336 addWECPropertyIfDefined(bw,'month',bI.month);
16337 addWECPropertyIfDefined(bw,'day',bI.day);
16338 addWECPropertyIfDefined(bw,'weekday',bI.weekday);
16339 addWECPropertyIfDefined(bw,'hour12',bI.hour12);
16340 addWECPropertyIfDefined(bw,'hour',bI.hour);
16341 addWECPropertyIfDefined(bw,'minute',bI.minute);
16342 addWECPropertyIfDefined(bw,'second',bI.second);
16347 %FunctionSetName(h.DateTimeFormat.prototype.resolvedOptions,
16348 'resolvedOptions');
16349 %FunctionRemovePrototype(h.DateTimeFormat.prototype.resolvedOptions);
16350 %SetNativeFlag(h.DateTimeFormat.prototype.resolvedOptions);
16351 %AddNamedProperty(h.DateTimeFormat,'supportedLocalesOf',function(R){
16352 if(%_IsConstructCall()){
16353 throw new $TypeError(E);
16355 return supportedLocalesOf('dateformat',R,%_Arguments(1));
16359 %FunctionSetName(h.DateTimeFormat.supportedLocalesOf,'supportedLocalesOf');
16360 %FunctionRemovePrototype(h.DateTimeFormat.supportedLocalesOf);
16361 %SetNativeFlag(h.DateTimeFormat.supportedLocalesOf);
16362 function formatDate(bu,bK){
16369 if(!$isFinite(bL)){
16370 throw new $RangeError('Provided date is not in valid range.');
16372 return %InternalDateFormat(%GetImplFromInitializedIntlObject(bu),
16375 function parseDate(bu,ah){
16376 return %InternalDateParse(%GetImplFromInitializedIntlObject(bu),
16379 addBoundMethod(h.DateTimeFormat,'format',formatDate,0);
16380 addBoundMethod(h.DateTimeFormat,'v8Parse',parseDate,1);
16381 function canonicalizeTimeZoneID(bM){
16385 var bN=bM.toUpperCase();
16386 if(bN==='UTC'||bN==='GMT'||
16387 bN==='ETC/UTC'||bN==='ETC/GMT'){
16390 var bC=GetTimezoneNameCheckRE().exec(bM);
16392 throw new $RangeError('Expected Area/Location for time zone, got '+bM);
16394 var bw=toTitleCaseWord(bC[1])+'/'+toTitleCaseWord(bC[2]);
16396 while(bC[Y]!==g&&Y<bC.length){
16397 bw=bw+'_'+toTitleCaseWord(bC[Y]);
16402 function initializeBreakIterator(bO,R,S){
16403 if(%IsInitializedIntlObject(bO)){
16404 throw new $TypeError('Trying to re-initialize v8BreakIterator object.');
16409 var ac=getGetOption(S,'breakiterator');
16411 defineWEProperty(bd,'type',ac(
16412 'type','string',['character','word','sentence','line'],'word'));
16413 var Z=resolveLocale('breakiterator',R,S);
16414 var ai=ObjectDefineProperties({},{
16415 requestedLocale:{value:Z.locale,writable:true},
16416 type:{value:bd.type,writable:true},
16417 locale:{writable:true}
16419 var bP=%CreateBreakIterator(Z.locale,
16422 %MarkAsInitializedIntlObjectOfType(bO,'breakiterator',
16424 ObjectDefineProperty(bO,'resolved',{value:ai});
16427 %AddNamedProperty(h,'v8BreakIterator',function(){
16428 var R=%_Arguments(0);
16429 var S=%_Arguments(1);
16430 if(!this||this===h){
16431 return new h.v8BreakIterator(R,S);
16433 return initializeBreakIterator(ToObject(this),R,S);
16437 %AddNamedProperty(h.v8BreakIterator.prototype,'resolvedOptions',
16439 if(%_IsConstructCall()){
16440 throw new $TypeError(E);
16442 if(!%IsInitializedIntlObjectOfType(this,'breakiterator')){
16443 throw new $TypeError('resolvedOptions method called on a non-object or '+
16444 'on a object that is not Intl.v8BreakIterator.');
16447 var Z=getOptimalLanguageTag(bQ.resolved.requestedLocale,
16448 bQ.resolved.locale);
16451 type:bQ.resolved.type
16456 %FunctionSetName(h.v8BreakIterator.prototype.resolvedOptions,
16457 'resolvedOptions');
16458 %FunctionRemovePrototype(h.v8BreakIterator.prototype.resolvedOptions);
16459 %SetNativeFlag(h.v8BreakIterator.prototype.resolvedOptions);
16460 %AddNamedProperty(h.v8BreakIterator,'supportedLocalesOf',
16462 if(%_IsConstructCall()){
16463 throw new $TypeError(E);
16465 return supportedLocalesOf('breakiterator',R,%_Arguments(1));
16469 %FunctionSetName(h.v8BreakIterator.supportedLocalesOf,'supportedLocalesOf');
16470 %FunctionRemovePrototype(h.v8BreakIterator.supportedLocalesOf);
16471 %SetNativeFlag(h.v8BreakIterator.supportedLocalesOf);
16472 function adoptText(bO,bR){
16473 %BreakIteratorAdoptText(%GetImplFromInitializedIntlObject(bO),
16476 function first(bO){
16477 return %BreakIteratorFirst(%GetImplFromInitializedIntlObject(bO));
16480 return %BreakIteratorNext(%GetImplFromInitializedIntlObject(bO));
16482 function current(bO){
16483 return %BreakIteratorCurrent(%GetImplFromInitializedIntlObject(bO));
16485 function breakType(bO){
16486 return %BreakIteratorBreakType(%GetImplFromInitializedIntlObject(bO));
16488 addBoundMethod(h.v8BreakIterator,'adoptText',adoptText,1);
16489 addBoundMethod(h.v8BreakIterator,'first',first,0);
16490 addBoundMethod(h.v8BreakIterator,'next',next,0);
16491 addBoundMethod(h.v8BreakIterator,'current',current,0);
16492 addBoundMethod(h.v8BreakIterator,'breakType',breakType,0);
16494 'collator':h.Collator,
16495 'numberformat':h.NumberFormat,
16496 'dateformatall':h.DateTimeFormat,
16497 'dateformatdate':h.DateTimeFormat,
16498 'dateformattime':h.DateTimeFormat
16504 'dateformatdate':g,
16505 'dateformattime':g,
16507 function cachedOrNewService(Q,R,S,bE){
16508 var bU=(bE===g)?S:bE;
16511 bT[Q]=new bS[Q](R,bU);
16515 return new bS[Q](R,bU);
16517 OverrideFunction(e.prototype,'localeCompare',function(L){
16518 if(%_IsConstructCall()){
16519 throw new $TypeError(E);
16522 throw new $TypeError('Method invoked on undefined or null value.');
16524 var R=%_Arguments(1);
16525 var S=%_Arguments(2);
16526 var bc=cachedOrNewService('collator',R,S);
16527 return compare(bc,this,L);
16530 OverrideFunction(e.prototype,'normalize',function(L){
16531 if(%_IsConstructCall()){
16532 throw new $TypeError(E);
16534 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["String.prototype.normalize"]);
16535 var bV=e(%_Arguments(0)||'NFC');
16536 var bW=j.indexOf(bV);
16538 throw new $RangeError('The normalization form should be one of '
16539 +j.join(', ')+'.');
16541 return %StringNormalize(this,bW);
16544 OverrideFunction(c.prototype,'toLocaleString',function(){
16545 if(%_IsConstructCall()){
16546 throw new $TypeError(E);
16548 if(!(this instanceof c)&&typeof(this)!=='number'){
16549 throw new $TypeError('Method invoked on an object that is not Number.');
16551 var R=%_Arguments(0);
16552 var S=%_Arguments(1);
16553 var bn=cachedOrNewService('numberformat',R,S);
16554 return formatNumber(bn,this);
16557 function toLocaleDateTime(bX,R,S,bD,bE,Q){
16558 if(!(bX instanceof b)){
16559 throw new $TypeError('Method invoked on an object that is not Date.');
16562 return'Invalid Date';
16564 var bd=toDateTimeOptions(S,bD,bE);
16566 cachedOrNewService(Q,R,S,bd);
16567 return formatDate(bG,bX);
16569 OverrideFunction(b.prototype,'toLocaleString',function(){
16570 if(%_IsConstructCall()){
16571 throw new $TypeError(E);
16573 var R=%_Arguments(0);
16574 var S=%_Arguments(1);
16575 return toLocaleDateTime(
16576 this,R,S,'any','all','dateformatall');
16579 OverrideFunction(b.prototype,'toLocaleDateString',function(){
16580 if(%_IsConstructCall()){
16581 throw new $TypeError(E);
16583 var R=%_Arguments(0);
16584 var S=%_Arguments(1);
16585 return toLocaleDateTime(
16586 this,R,S,'date','date','dateformatdate');
16589 OverrideFunction(b.prototype,'toLocaleTimeString',function(){
16590 if(%_IsConstructCall()){
16591 throw new $TypeError(E);
16593 var R=%_Arguments(0);
16594 var S=%_Arguments(1);
16595 return toLocaleDateTime(
16596 this,R,S,'time','time','dateformattime');
16602 var $proxyDelegateCallAndConstruct;
16603 var $proxyDerivedGetTrap;
16604 var $proxyDerivedHasTrap;
16605 var $proxyDerivedHasOwnTrap;
16606 var $proxyDerivedKeysTrap;
16607 var $proxyDerivedSetTrap;
16608 var $proxyEnumerate;
16611 %CheckIsBootstrapping();
16612 var a=global.Function;
16613 var b=global.Object;
16614 function ProxyCreate(c,d){
16615 if(!(%_IsSpecObject(c)))
16616 throw MakeTypeError("handler_non_object",["create"])
16619 else if(!((%_IsSpecObject(d))||(d===null)))
16620 throw MakeTypeError("proto_non_object",["create"])
16621 return %CreateJSProxy(c,d)
16623 function ProxyCreateFunction(c,e,f){
16624 if(!(%_IsSpecObject(c)))
16625 throw MakeTypeError("handler_non_object",["create"])
16626 if(!(%_ClassOf(e)==='Function'))
16627 throw MakeTypeError("trap_function_expected",["createFunction","call"])
16628 if((f===(void 0))){
16629 f=DerivedConstructTrap(e)
16630 }else if((%_ClassOf(f)==='Function')){
16633 return %Apply(g,(void 0),arguments,0,%_ArgumentsLength());
16636 throw MakeTypeError("trap_function_expected",
16637 ["createFunction","construct"])
16639 return %CreateJSFunctionProxy(
16642 function DerivedConstructTrap(e){
16644 var d=this.prototype
16645 if(!(%_IsSpecObject(d)))d=b.prototype
16646 var h={__proto__:d};
16647 var i=%Apply(e,h,arguments,0,%_ArgumentsLength());
16648 return(%_IsSpecObject(i))?i:h
16651 function DelegateCallAndConstruct(e,f){
16653 return %Apply(%_IsConstructCall()?f:e,
16654 this,arguments,0,%_ArgumentsLength())
16657 function DerivedGetTrap(j,k){
16658 var l=this.getPropertyDescriptor(k)
16659 if((l===(void 0))){return l}
16663 if((l.get===(void 0))){return l.get}
16664 return %_CallFunction(j,l.get)
16667 function DerivedSetTrap(j,k,m){
16668 var l=this.getOwnPropertyDescriptor(k)
16670 if('writable'in l){
16673 this.defineProperty(k,l)
16680 %_CallFunction(j,m,l.set)
16687 l=this.getPropertyDescriptor(k)
16689 if('writable'in l){
16696 %_CallFunction(j,m,l.set)
16703 this.defineProperty(k,{
16707 configurable:true});
16710 function DerivedHasTrap(k){
16711 return!!this.getPropertyDescriptor(k)
16713 function DerivedHasOwnTrap(k){
16714 return!!this.getOwnPropertyDescriptor(k)
16716 function DerivedKeysTrap(){
16717 var n=this.getOwnPropertyNames()
16719 for(var p=0,count=0;p<n.length;++p){
16721 if((typeof(k)==='symbol'))continue
16722 var l=this.getOwnPropertyDescriptor(((typeof(%IS_VAR(k))==='string')?k:NonStringToString(k)))
16723 if(!(l===(void 0))&&l.enumerable){
16729 function DerivedEnumerateTrap(){
16730 var n=this.getPropertyNames()
16732 for(var p=0,count=0;p<n.length;++p){
16734 if((typeof(k)==='symbol'))continue
16735 var l=this.getPropertyDescriptor(((typeof(%IS_VAR(k))==='string')?k:NonStringToString(k)))
16736 if(!(l===(void 0))){
16737 if(!l.configurable){
16738 throw MakeTypeError(28,
16739 this,k,"getPropertyDescriptor")
16741 if(l.enumerable)o[count++]=n[p]
16746 function ProxyEnumerate(q){
16747 var c=%GetHandler(q)
16748 if((c.enumerate===(void 0))){
16749 return %Apply(DerivedEnumerateTrap,c,[],0,0)
16751 return ToNameArray(c.enumerate(),"enumerate",false)
16755 %AddNamedProperty(global,"Proxy",r,2);
16756 InstallFunctions(r,2,[
16757 "create",ProxyCreate,
16758 "createFunction",ProxyCreateFunction
16760 $proxyDelegateCallAndConstruct=DelegateCallAndConstruct;
16761 $proxyDerivedGetTrap=DerivedGetTrap;
16762 $proxyDerivedHasTrap=DerivedHasTrap;
16763 $proxyDerivedHasOwnTrap=DerivedHasOwnTrap;
16764 $proxyDerivedKeysTrap=DerivedKeysTrap;
16765 $proxyDerivedSetTrap=DerivedSetTrap;
16766 $proxyEnumerate=ProxyEnumerate;
16772 %CheckIsBootstrapping();
16773 var a=global.Function;
16774 function GeneratorObjectNext(b){
16775 if(!(%_ClassOf(this)==='Generator')){
16776 throw MakeTypeError(8,
16777 '[Generator].prototype.next',this);
16779 var c=%GeneratorGetContinuation(this);
16781 if((%_DebugIsActive()!=0))%DebugPrepareStepInIfStepping(this);
16783 return %_GeneratorNext(this,b);
16785 %GeneratorClose(this);
16789 return{value:void 0,done:true};
16791 throw MakeTypeError(6);
16794 function GeneratorObjectThrow(d){
16795 if(!(%_ClassOf(this)==='Generator')){
16796 throw MakeTypeError(8,
16797 '[Generator].prototype.throw',this);
16799 var c=%GeneratorGetContinuation(this);
16802 return %_GeneratorThrow(this,d);
16804 %GeneratorClose(this);
16810 throw MakeTypeError(6);
16813 function GeneratorObjectIterator(){
16816 function GeneratorFunctionConstructor(e){
16817 var f=NewFunctionString(arguments,'function*');
16818 var g=%GlobalProxy(global);
16819 var h=%_CallFunction(g,%CompileString(f,true));
16820 %FunctionMarkNameShouldPrintAsAnonymous(h);
16823 %NeverOptimizeFunction(GeneratorObjectNext);
16824 %NeverOptimizeFunction(GeneratorObjectThrow);
16825 var i=GeneratorFunctionPrototype.prototype;
16826 InstallFunctions(i,
16828 ["next",GeneratorObjectNext,
16829 "throw",GeneratorObjectThrow]);
16830 %FunctionSetName(GeneratorObjectIterator,'[Symbol.iterator]');
16831 %AddNamedProperty(i,symbolIterator,
16832 GeneratorObjectIterator,2|4|1);
16833 %AddNamedProperty(i,"constructor",
16834 GeneratorFunctionPrototype,2|1);
16835 %AddNamedProperty(i,
16836 symbolToStringTag,"Generator",2|1);
16837 %InternalSetPrototype(GeneratorFunctionPrototype,a.prototype);
16838 %AddNamedProperty(GeneratorFunctionPrototype,
16839 symbolToStringTag,"GeneratorFunction",2|1);
16840 %AddNamedProperty(GeneratorFunctionPrototype,"constructor",
16841 GeneratorFunction,2|1);
16842 %InternalSetPrototype(GeneratorFunction,a);
16843 %SetCode(GeneratorFunction,GeneratorFunctionConstructor);
16849 %CheckIsBootstrapping();
16850 var a=global.Array;
16851 var b=global.Symbol;
16852 function ArrayFind(c){
16853 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Array.prototype.find"]);
16854 var d=ToObject(this);
16855 var e=ToInteger(d.length);
16856 if(!(%_ClassOf(c)==='Function')){
16857 throw MakeTypeError(2,c);
16860 if(%_ArgumentsLength()>1){
16865 f=%GetDefaultReceiver(c)||f;
16867 g=(!(%_IsSpecObject(f))&&%IsSloppyModeFunction(c));
16869 for(var h=0;h<e;h++){
16872 var j=g?ToObject(f):f;
16873 if(%_CallFunction(j,i,h,d,c)){
16880 function ArrayFindIndex(c){
16881 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Array.prototype.findIndex"]);
16882 var d=ToObject(this);
16883 var e=ToInteger(d.length);
16884 if(!(%_ClassOf(c)==='Function')){
16885 throw MakeTypeError(2,c);
16888 if(%_ArgumentsLength()>1){
16893 f=%GetDefaultReceiver(c)||f;
16895 g=(!(%_IsSpecObject(f))&&%IsSloppyModeFunction(c));
16897 for(var h=0;h<e;h++){
16900 var j=g?ToObject(f):f;
16901 if(%_CallFunction(j,i,h,d,c)){
16908 function ArrayFill(k){
16909 if((this==null)&&!(%_IsUndetectableObject(this)))throw MakeTypeError('called_on_null_or_undefined',["Array.prototype.fill"]);
16910 var d=ToObject(this);
16911 var e=(d.length>>>0);
16914 if(%_ArgumentsLength()>1){
16916 h=(h===(void 0))?0:(%_IsSmi(%IS_VAR(h))?h:%NumberToInteger(ToNumber(h)));
16917 if(%_ArgumentsLength()>2){
16919 l=(l===(void 0))?e:(%_IsSmi(%IS_VAR(l))?l:%NumberToInteger(ToNumber(l)));
16934 if((l-h)>0&&ObjectIsFrozen(d)){
16935 throw MakeTypeError("array_functions_on_frozen",
16936 ["Array.prototype.fill"]);
16942 function ArrayFrom(m,n,o){
16944 var q=!(n===(void 0));
16946 if(!(%_ClassOf(n)==='Function')){
16947 throw MakeTypeError(2,n);
16948 }else if((o==null)){
16949 o=%GetDefaultReceiver(n)||o;
16950 }else if(!(%_IsSpecObject(o))&&%IsSloppyModeFunction(n)){
16954 var r=GetMethod(p,symbolIterator);
16959 if(!(r===(void 0))){
16960 t=%IsConstructor(this)?new this():[];
16961 var w=GetIterator(p,r);
16965 if(!(%_IsObject(x))){
16966 throw MakeTypeError("iterator_result_not_an_object",[x]);
16974 u=%_CallFunction(o,v,s,n);
16978 %AddElement(t,s++,u,0);
16981 var y=ToLength(p.length);
16982 t=%IsConstructor(this)?new this(y):new $Array(y);
16986 u=%_CallFunction(o,v,s,n);
16990 %AddElement(t,s,u,0);
16996 function ArrayOf(){
16997 var e=%_ArgumentsLength();
16999 var d=%IsConstructor(z)?new z(e):[];
17000 for(var h=0;h<e;h++){
17001 %AddElement(d,h,%_Arguments(h),0);
17006 InstallConstants(b,[
17007 "isConcatSpreadable",symbolIsConcatSpreadable
17009 %FunctionSetLength(ArrayFrom,1);
17010 InstallFunctions(a,2,[
17014 InstallFunctions(a.prototype,2,[
17016 "findIndex",ArrayFindIndex,
17021 Xharmony-array-includesí
\ 6
17024 %CheckIsBootstrapping();
17025 var a=global.Array;
17026 function ArrayIncludes(b,c){
17027 var d=ToObject(this);
17028 var e=ToLength(d.length);
17032 var f=ToInteger(c);
17044 if(SameValueZero(b,h)){
17051 %FunctionSetLength(ArrayIncludes,1);
17052 InstallFunctions(a.prototype,2,[
17053 "includes",ArrayIncludes
17057 @harmony-tostring)
\ 2
17060 %CheckIsBootstrapping();
17061 var a=global.Symbol;
17062 InstallConstants(a,[
17063 "toStringTag",symbolToStringTag
17067 Hharmony-typedarrayi~
17070 %CheckIsBootstrapping();
17071 function Uint8ArrayForEach(a){
17072 if(!%IsTypedArray(this)){
17073 throw MakeTypeError('not_typed_array',[]);
17075 if(!(%_ClassOf(a)==='Function'))throw MakeTypeError(2,a);
17076 var b=%_TypedArrayGetLength(this);
17078 if(%_ArgumentsLength()>1){
17083 c=%GetDefaultReceiver(a)||c;
17085 d=(!(%_IsSpecObject(c))&&%IsSloppyModeFunction(a));
17087 var e=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(a);
17088 for(var f=0;f<b;f++){
17090 if(e)%DebugPrepareStepInIfStepping(a);
17091 var h=d?ToObject(c):c;
17092 %_CallFunction(h,((%_IsSpecObject(%IS_VAR(g)))?g:ToObject(g)),f,this,a);
17095 function Uint8ArrayOf(){
17096 var b=%_ArgumentsLength();
17098 for(var f=0;f<b;f++){
17099 i[f]=%_Arguments(f);
17104 function Int8ArrayForEach(a){
17105 if(!%IsTypedArray(this)){
17106 throw MakeTypeError('not_typed_array',[]);
17108 if(!(%_ClassOf(a)==='Function'))throw MakeTypeError(2,a);
17109 var b=%_TypedArrayGetLength(this);
17111 if(%_ArgumentsLength()>1){
17116 c=%GetDefaultReceiver(a)||c;
17118 d=(!(%_IsSpecObject(c))&&%IsSloppyModeFunction(a));
17120 var e=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(a);
17121 for(var f=0;f<b;f++){
17123 if(e)%DebugPrepareStepInIfStepping(a);
17124 var h=d?ToObject(c):c;
17125 %_CallFunction(h,((%_IsSpecObject(%IS_VAR(g)))?g:ToObject(g)),f,this,a);
17128 function Int8ArrayOf(){
17129 var b=%_ArgumentsLength();
17131 for(var f=0;f<b;f++){
17132 i[f]=%_Arguments(f);
17137 function Uint16ArrayForEach(a){
17138 if(!%IsTypedArray(this)){
17139 throw MakeTypeError('not_typed_array',[]);
17141 if(!(%_ClassOf(a)==='Function'))throw MakeTypeError(2,a);
17142 var b=%_TypedArrayGetLength(this);
17144 if(%_ArgumentsLength()>1){
17149 c=%GetDefaultReceiver(a)||c;
17151 d=(!(%_IsSpecObject(c))&&%IsSloppyModeFunction(a));
17153 var e=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(a);
17154 for(var f=0;f<b;f++){
17156 if(e)%DebugPrepareStepInIfStepping(a);
17157 var h=d?ToObject(c):c;
17158 %_CallFunction(h,((%_IsSpecObject(%IS_VAR(g)))?g:ToObject(g)),f,this,a);
17161 function Uint16ArrayOf(){
17162 var b=%_ArgumentsLength();
17164 for(var f=0;f<b;f++){
17165 i[f]=%_Arguments(f);
17170 function Int16ArrayForEach(a){
17171 if(!%IsTypedArray(this)){
17172 throw MakeTypeError('not_typed_array',[]);
17174 if(!(%_ClassOf(a)==='Function'))throw MakeTypeError(2,a);
17175 var b=%_TypedArrayGetLength(this);
17177 if(%_ArgumentsLength()>1){
17182 c=%GetDefaultReceiver(a)||c;
17184 d=(!(%_IsSpecObject(c))&&%IsSloppyModeFunction(a));
17186 var e=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(a);
17187 for(var f=0;f<b;f++){
17189 if(e)%DebugPrepareStepInIfStepping(a);
17190 var h=d?ToObject(c):c;
17191 %_CallFunction(h,((%_IsSpecObject(%IS_VAR(g)))?g:ToObject(g)),f,this,a);
17194 function Int16ArrayOf(){
17195 var b=%_ArgumentsLength();
17197 for(var f=0;f<b;f++){
17198 i[f]=%_Arguments(f);
17203 function Uint32ArrayForEach(a){
17204 if(!%IsTypedArray(this)){
17205 throw MakeTypeError('not_typed_array',[]);
17207 if(!(%_ClassOf(a)==='Function'))throw MakeTypeError(2,a);
17208 var b=%_TypedArrayGetLength(this);
17210 if(%_ArgumentsLength()>1){
17215 c=%GetDefaultReceiver(a)||c;
17217 d=(!(%_IsSpecObject(c))&&%IsSloppyModeFunction(a));
17219 var e=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(a);
17220 for(var f=0;f<b;f++){
17222 if(e)%DebugPrepareStepInIfStepping(a);
17223 var h=d?ToObject(c):c;
17224 %_CallFunction(h,((%_IsSpecObject(%IS_VAR(g)))?g:ToObject(g)),f,this,a);
17227 function Uint32ArrayOf(){
17228 var b=%_ArgumentsLength();
17230 for(var f=0;f<b;f++){
17231 i[f]=%_Arguments(f);
17236 function Int32ArrayForEach(a){
17237 if(!%IsTypedArray(this)){
17238 throw MakeTypeError('not_typed_array',[]);
17240 if(!(%_ClassOf(a)==='Function'))throw MakeTypeError(2,a);
17241 var b=%_TypedArrayGetLength(this);
17243 if(%_ArgumentsLength()>1){
17248 c=%GetDefaultReceiver(a)||c;
17250 d=(!(%_IsSpecObject(c))&&%IsSloppyModeFunction(a));
17252 var e=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(a);
17253 for(var f=0;f<b;f++){
17255 if(e)%DebugPrepareStepInIfStepping(a);
17256 var h=d?ToObject(c):c;
17257 %_CallFunction(h,((%_IsSpecObject(%IS_VAR(g)))?g:ToObject(g)),f,this,a);
17260 function Int32ArrayOf(){
17261 var b=%_ArgumentsLength();
17263 for(var f=0;f<b;f++){
17264 i[f]=%_Arguments(f);
17269 function Float32ArrayForEach(a){
17270 if(!%IsTypedArray(this)){
17271 throw MakeTypeError('not_typed_array',[]);
17273 if(!(%_ClassOf(a)==='Function'))throw MakeTypeError(2,a);
17274 var b=%_TypedArrayGetLength(this);
17276 if(%_ArgumentsLength()>1){
17281 c=%GetDefaultReceiver(a)||c;
17283 d=(!(%_IsSpecObject(c))&&%IsSloppyModeFunction(a));
17285 var e=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(a);
17286 for(var f=0;f<b;f++){
17288 if(e)%DebugPrepareStepInIfStepping(a);
17289 var h=d?ToObject(c):c;
17290 %_CallFunction(h,((%_IsSpecObject(%IS_VAR(g)))?g:ToObject(g)),f,this,a);
17293 function Float32ArrayOf(){
17294 var b=%_ArgumentsLength();
17296 for(var f=0;f<b;f++){
17297 i[f]=%_Arguments(f);
17302 function Float64ArrayForEach(a){
17303 if(!%IsTypedArray(this)){
17304 throw MakeTypeError('not_typed_array',[]);
17306 if(!(%_ClassOf(a)==='Function'))throw MakeTypeError(2,a);
17307 var b=%_TypedArrayGetLength(this);
17309 if(%_ArgumentsLength()>1){
17314 c=%GetDefaultReceiver(a)||c;
17316 d=(!(%_IsSpecObject(c))&&%IsSloppyModeFunction(a));
17318 var e=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(a);
17319 for(var f=0;f<b;f++){
17321 if(e)%DebugPrepareStepInIfStepping(a);
17322 var h=d?ToObject(c):c;
17323 %_CallFunction(h,((%_IsSpecObject(%IS_VAR(g)))?g:ToObject(g)),f,this,a);
17326 function Float64ArrayOf(){
17327 var b=%_ArgumentsLength();
17329 for(var f=0;f<b;f++){
17330 i[f]=%_Arguments(f);
17335 function Uint8ClampedArrayForEach(a){
17336 if(!%IsTypedArray(this)){
17337 throw MakeTypeError('not_typed_array',[]);
17339 if(!(%_ClassOf(a)==='Function'))throw MakeTypeError(2,a);
17340 var b=%_TypedArrayGetLength(this);
17342 if(%_ArgumentsLength()>1){
17347 c=%GetDefaultReceiver(a)||c;
17349 d=(!(%_IsSpecObject(c))&&%IsSloppyModeFunction(a));
17351 var e=(%_DebugIsActive()!=0)&&%DebugCallbackSupportsStepping(a);
17352 for(var f=0;f<b;f++){
17354 if(e)%DebugPrepareStepInIfStepping(a);
17355 var h=d?ToObject(c):c;
17356 %_CallFunction(h,((%_IsSpecObject(%IS_VAR(g)))?g:ToObject(g)),f,this,a);
17359 function Uint8ClampedArrayOf(){
17360 var b=%_ArgumentsLength();
17362 for(var f=0;f<b;f++){
17363 i[f]=%_Arguments(f);
17369 InstallFunctions(global.Uint8Array,2|4|1,[
17372 InstallFunctions(global.Uint8Array.prototype,2,[
17373 "forEach",Uint8ArrayForEach
17376 InstallFunctions(global.Int8Array,2|4|1,[
17379 InstallFunctions(global.Int8Array.prototype,2,[
17380 "forEach",Int8ArrayForEach
17383 InstallFunctions(global.Uint16Array,2|4|1,[
17386 InstallFunctions(global.Uint16Array.prototype,2,[
17387 "forEach",Uint16ArrayForEach
17390 InstallFunctions(global.Int16Array,2|4|1,[
17393 InstallFunctions(global.Int16Array.prototype,2,[
17394 "forEach",Int16ArrayForEach
17397 InstallFunctions(global.Uint32Array,2|4|1,[
17400 InstallFunctions(global.Uint32Array.prototype,2,[
17401 "forEach",Uint32ArrayForEach
17404 InstallFunctions(global.Int32Array,2|4|1,[
17407 InstallFunctions(global.Int32Array.prototype,2,[
17408 "forEach",Int32ArrayForEach
17411 InstallFunctions(global.Float32Array,2|4|1,[
17412 "of",Float32ArrayOf
17414 InstallFunctions(global.Float32Array.prototype,2,[
17415 "forEach",Float32ArrayForEach
17418 InstallFunctions(global.Float64Array,2|4|1,[
17419 "of",Float64ArrayOf
17421 InstallFunctions(global.Float64Array.prototype,2,[
17422 "forEach",Float64ArrayForEach
17425 InstallFunctions(global.Uint8ClampedArray,2|4|1,[
17426 "of",Uint8ClampedArrayOf
17428 InstallFunctions(global.Uint8ClampedArray.prototype,2,[
17429 "forEach",Uint8ClampedArrayForEach
17438 %CheckIsBootstrapping();
17439 var a=global.RegExp;
17440 function RegExpGetFlags(){
17441 if(!(%_IsSpecObject(this))){
17442 throw MakeTypeError('flags_getter_non_object',
17443 [%ToString(this)]);
17446 if(this.global)b+='g';
17447 if(this.ignoreCase)b+='i';
17448 if(this.multiline)b+='m';
17449 if(this.unicode)b+='u';
17450 if(this.sticky)b+='y';
17453 %DefineAccessorPropertyUnchecked(a.prototype,'flags',
17454 RegExpGetFlags,null,2);
17455 %SetNativeFlag(RegExpGetFlags);
17458 <harmony-reflect
\89\ 2
17461 %CheckIsBootstrapping();
17462 var a=global.Reflect;
17463 InstallFunctions(a,2,[
17464 "apply",$reflectApply,
17465 "construct",$reflectConstruct
17470 var $spreadArguments;
17471 var $spreadIterable;
17474 function SpreadArguments(){
17475 var a=%_ArgumentsLength();
17476 var b=new InternalArray();
17477 for(var c=0;c<a;++c){
17478 var d=%_Arguments(c);
17480 for(var f=0;f<e;++f){
17486 function SpreadIterable(g){
17488 throw MakeTypeError(15,g);
17490 var b=new InternalArray();
17496 $spreadArguments=SpreadArguments;
17497 $spreadIterable=SpreadIterable;