From 061c839a33063ffb10ec32b5d42e7344aa69c86e Mon Sep 17 00:00:00 2001 From: Jeff Parsons Date: Thu, 29 Jun 2017 08:38:02 -0700 Subject: [PATCH] The Component printBuffer should only be used by Component static functions --- docs/pcx86/examples/pcx86-dbg.js | 2 +- docs/pcx86/examples/pcx86.js | 2 +- modules/c1pjs/lib/debugger.js | 8 +- modules/shared/lib/component.js | 69 +++++++------ versions/c1pjs/1.35.2/c1p-dbg.map | 2 +- versions/c1pjs/1.35.2/c1p-uncompiled.js | 101 +++++++++++--------- versions/c1pjs/1.35.2/c1p.map | 2 +- versions/pc8080/1.35.2/pc8080-dbg.js | 3 +- versions/pc8080/1.35.2/pc8080-dbg.map | 6 +- versions/pc8080/1.35.2/pc8080-uncompiled.js | 93 ++++++++++-------- versions/pc8080/1.35.2/pc8080.js | 2 +- versions/pc8080/1.35.2/pc8080.map | 4 +- versions/pcx86/1.35.2/pcx86-dbg.js | 2 +- versions/pcx86/1.35.2/pcx86-dbg.map | 4 +- versions/pcx86/1.35.2/pcx86-uncompiled.js | 93 ++++++++++-------- versions/pcx86/1.35.2/pcx86.js | 2 +- versions/pcx86/1.35.2/pcx86.map | 4 +- versions/pdpjs/1.35.2/pdp10-dbg.js | 2 +- versions/pdpjs/1.35.2/pdp10-dbg.map | 4 +- versions/pdpjs/1.35.2/pdp10-uncompiled.js | 93 ++++++++++-------- versions/pdpjs/1.35.2/pdp10.js | 2 +- versions/pdpjs/1.35.2/pdp10.map | 4 +- versions/pdpjs/1.35.2/pdp11-dbg.js | 2 +- versions/pdpjs/1.35.2/pdp11-dbg.map | 4 +- versions/pdpjs/1.35.2/pdp11-uncompiled.js | 93 ++++++++++-------- versions/pdpjs/1.35.2/pdp11.js | 2 +- versions/pdpjs/1.35.2/pdp11.map | 4 +- 27 files changed, 344 insertions(+), 265 deletions(-) diff --git a/docs/pcx86/examples/pcx86-dbg.js b/docs/pcx86/examples/pcx86-dbg.js index 16afc7d0f..ed3f915c2 100644 --- a/docs/pcx86/examples/pcx86-dbg.js +++ b/docs/pcx86/examples/pcx86-dbg.js @@ -79,7 +79,7 @@ l.toString=function(){return this.name?this.name:this.id||this.type}; l.Cb=function(a,b,c){switch(b){case "clear":return this.na[b]||(this.na[b]=c,c.onclick=function(a){return function(){a.na.print&&(a.na.print.value="")}}(this)),!0;case "print":return this.na[b]||(this.na[b]=c,this.Ca=function(a){this.O(a,this.type);return!0},c.value="",this.print=function(a){return function(b){wb(a,b)}}(c),this.O=function(a,b){return function(a,c){a||(a="");c!=Lb.Ce||"..."!=a.slice(-3)?(c&&(a=c+": "+a),wb(b,a+"\n")):xb(b,a,a+".")}}(this,c)),!0;default:return!1}};l.log=function(){}; l.print=function(){};l.O=function(){};l.status=function(a){this.O(this.type+": "+a)};l.Ca=function(a,b,c){if(!b){var d=zb("Computer",this.id);if(d&&d.ca.Tf)return console.log("ignoring notice during unload: "+a),!1}c=c||this.type;b||lb((c?c+": ":"")+a);return!0};function Mb(a,b){a.ca.error=!0;a.Ca(b)}function Nb(a,b){b&&(a.ca.ready?b():a.rg=b);return a.ca.ready}function Ob(a,b){a.ca.error||(a.ca.ready=!1!==b,a.ca.ready&&(b=a.rg,a.rg=null,b&&b()))} function Pb(a,b){a.ca.qf&&(b?a.ca.eh=!0:void 0===b&&a.O(a.toString()+" busy"));return a.ca.qf}function Qb(a,b){if(a.ca.eh)return a.ca.qf=!1,a.ca.eh=!1;if(a.ca.error)return a.O(a.toString()+" error"),!1;a.ca.qf=b;return a.ca.qf}l.Xb=function(){return this.ca.dc=!0};l.Wb=function(a,b){b&&(this.ca.dc=!1);return!0};function t(a,b){if(a.ba){a===a.ba?b|=0:b=b||a.ic;var c=a.ba.ic&b;return!!b&&c===b||!!(c&a.ba.zl)}return!1}function Rb(a,b,c,d){a.ba&&(!0===c||t(a,c|0))&&a.ba.message(b,d)} -function w(a,b,c,d,e,f,g){a.ba&&(!0===g?g=0:null==g&&(g=a.ic),Sb(a.ba,a,b,c,d,e,f,g))}var Lb={Vp:"notice",gq:"warning",ERROR:"error",Ce:"progress"};window&&(window.PCjs||(window.PCjs={}),window.PCjs.Machines||(window.PCjs.Machines={}),window.PCjs.Components||(window.PCjs.Components=[]),window.PCjs.Commands||(window.PCjs.Commands={})); +function w(a,b,c,d,e,f,g){a.ba&&(!0===g?g=0:null==g&&(g=a.ic),Sb(a.ba,a,b,c,d,e,f,g))}var Lb={ERROR:"error",Vp:"notice",Ce:"progress",SCRIPT:"script",gq:"warning"};window&&(window.PCjs||(window.PCjs={}),window.PCjs.Machines||(window.PCjs.Machines={}),window.PCjs.Components||(window.PCjs.Components=[]),window.PCjs.Commands||(window.PCjs.Commands={})); var ub=window?window.PCjs.Machines:{},rb=window?window.PCjs.Components:[],Gb=window?window.PCjs.Commands:{},Ib=["hold","sleep","wait"],Jb={alert:function(a){lb(a);return!0},sleep:function(a,b){setTimeout(a,+b);return!1}},Kb={select:function(a,b,c){var d=!1;if(a=a.bindings[b])for(b=0;b 0x100) { /* - * Limiting the amount of disassembled code to 1 page in non-DEBUG builds is partly to - * prevent the user from wedging their browser, but also a recognition that, in non-DEBUG builds, - * Component.println() also keeps its output buffer truncated to 8K, which is only enough for - * about 2 pages of disassembled code anyway. + * Limiting the amount of disassembled code to one "memory page" in non-DEBUG builds is partly + * to prevent the user from wedging their browser, but also a recognition that, in non-DEBUG builds, + * the println() output buffer is truncated to 8K, which is only enough for about two pages of + * disassembled code anyway. */ this.println("range too large"); return; diff --git a/modules/shared/lib/component.js b/modules/shared/lib/component.js index 2bc101829..2e1b91cbc 100644 --- a/modules/shared/lib/component.js +++ b/modules/shared/lib/component.js @@ -271,14 +271,34 @@ class Component { } } + /** + * Component.print(s) + * + * Components that inherit from this class should use this.print(), rather than Component.print(), because + * if a Control Panel is loaded, it will override only the instance method, not the class method (overriding the + * class method would improperly affect any other machines loaded on the same page). + * + * @this {Component} + * @param {string} s + */ + static print(s) + { + if (!COMPILED) { + var i = s.lastIndexOf('\n'); + if (i >= 0) { + Component.println(s.substr(0, i)); + s = s.substr(i + 1); + } + Component.printBuffer += s; + } + } + /** * Component.println(s, type, id) * - * For non-diagnostic messages, which components may override to control the destination/appearance of their output. - * - * Components that inherit from this class should use the instance method, this.println(), rather than Component.println(), - * because if a Control Panel is loaded, it will override only the instance method, not the class method (overriding the class - * method would improperly affect any other machines loaded on the same page). + * Components that inherit from this class should use this.println(), rather than Component.println(), because + * if a Control Panel is loaded, it will override only the instance method, not the class method (overriding the + * class method would improperly affect any other machines loaded on the same page). * * @param {string} [s] is the message text * @param {string} [type] is the message type @@ -287,7 +307,9 @@ class Component { static println(s, type, id) { if (!COMPILED) { + s = Component.printBuffer + (s || ""); Component.log((id? (id + ": ") : "") + (s? ("\"" + s + "\"") : ""), type); + Component.printBuffer = ""; } } @@ -409,9 +431,6 @@ class Component { */ static replaceControl(control, sSearch, sReplace) { - /* - * Prevent the