Added support for MACRO-10 literal collapsing; it's not super-aggressive, but it's more than adequate for what DEC's diagnostics require

This commit is contained in:
Jeff 2017-03-28 15:22:17 -07:00 committed by Jeff Parsons
commit d5c48df9bc
10 changed files with 1242 additions and 1144 deletions

View file

@ -719,8 +719,8 @@ Vx.prototype.Cg=function(a,b,c){if(b)if(a){0>this.A&&this.C.length&&(this.A=0);i
function Wx(a,b,c){var d=a;b=b||32;if(c)if(32==b)d=a>>>0;else if(32>b)d=a&(1<<b)-1;else{if(b=Math.pow(2,b),0>a||a>=b)d=a%b,0>d&&(d+=b)}else 32>=b?d=a|0:(b=Math.pow(2,b-1),a<-b?(a<2*-b&&(d=a%(2*b)),d+=2*b):d>=b&&(a>=2*b&&(d=a%(2*b)),d-=2*b));a!=d&&(a=d);return a}
function Xx(a,b,c){for(c=void 0===c?-1:c;c--&&b.length;){var d=b.pop();if(2>a.length)return!1;var e,f=a.pop();e=a.pop();switch(d){case "*":e*=f;break;case "/":if(!f)return!1;e=Math.trunc(e/f);break;case "%":if(!f)return!1;e%=f;break;case "+":e+=f;break;case "-":e-=f;break;case "<<":e<<=f;break;case ">>":e>>=f;break;case ">>>":e>>>=f;break;case "<":e=e<f?1:0;break;case "<=":e=e<=f?1:0;break;case ">":e=e>f?1:0;break;case ">=":e=e>=f?1:0;break;case "==":e=e==f?1:0;break;case "!=":e=e!=f?1:0;break;case "&":e&=
f;break;case "!":case "|":e|=f;break;case "^!":e|=f;break;case "&&":e=e&&f?1:0;break;case "||":e=e||f?1:0;break;case "_":case "^_":"^_"==d&&(f=35-(f&255));f&&(e=Wx(e,0,!0),e=0<f?e*Math.pow(2,f):Math.trunc(e/Math.pow(2,-f)));break;default:return!1}a.push(Wx(e))}return!0}
function Yx(a,b,c,d,e,f){var g,h,k,m=!1,p=0,v=[],u=[],E=a.F;for(a.F=e;c<d;){h=b[c++].trim();k=c<d?b[c++]:"";if(h)p=Zx(a,h,null,f,p);else if("{"==k){h=1;for(p=c;c<d;)if(c++,k=c<b.length?b[c++]:"","{"==k)h++;else if("}"==k&&!--h)break;p=Yx(a,b,p,c-1,a.F,f);h=c<d?b[c++].trim():"";k=c<d?b[c++]:""}else{if("^B"==k){a.F=2;continue}if("^O"==k){a.F=8;continue}if("^D"==k){a.F=10;continue}if(!(p&-1073741824)){if("+"==k)continue;if("-"==k){p=p<<2|1;continue}if("~"==k||"^-"==k){p=p<<2|2;continue}if("^L"==k){p=
p<<2|3;continue}}m=!0;break}if(void 0===p)if(null==a.Ha&&f)a.Ha=h,p=0;else{m=!0;f=!f;break}v.push(Wx(p));if(!k)break;if(" "==k){m=!0;break}u.length&&$x[k]<$x[u[u.length-1]]&&Xx(v,u,1);u.push(k);a.F="^_"==k?10:e;p=0}if(m||!Xx(v,u)||1!=v.length)m=!0;m?!1===f&&a.P("parse error ("+(h||k)+")"):g=v.pop();a.F=E;return g}
function Yx(a,b,c,d,e,f){var g,h,k,m=!1,p=0,v=[],u=[],E=a.F;for(a.F=e;c<d;){h=b[c++].trim();k=c<d?b[c++]:"";if(h)p=Zx(a,h,null,f,p);else if("{"==k){h=1;for(p=c;c<d;)if(c++,k=c<b.length?b[c++]:"","{"==k)h++;else if("}"==k&&!--h)break;p=Yx(a,b,p,c-1,a.F,f);h=c<d?b[c++].trim():"";k=c<d?b[c++]:""}else{if(" "==k)continue;if("^B"==k){a.F=2;continue}if("^O"==k){a.F=8;continue}if("^D"==k){a.F=10;continue}if(!(p&-1073741824)){if("+"==k)continue;if("-"==k){p=p<<2|1;continue}if("~"==k||"^-"==k){p=p<<2|2;continue}if("^L"==
k){p=p<<2|3;continue}}m=!0;break}if(void 0===p)if(null==a.Ha&&f)a.Ha=h,p=0;else{m=!0;f=!f;break}v.push(Wx(p));if(" "==k)if(c<b.length-1&&!b[c])c++,k=b[c++];else{m=!0;break}if(!k)break;u.length&&$x[k]<=$x[u[u.length-1]]&&Xx(v,u,1);u.push(k);a.F="^_"==k?10:e;p=0}if(m||!Xx(v,u)||1!=v.length)m=!0;m?!1===f&&a.P("parse error ("+(h||k)+")"):g=v.pop();a.F=E;return g}
function ay(a,b,c,d,e,f){for(var g;0<=(g=b.indexOf(c));){for(var h=0,k=g+1,m=e;k<b.length;){var p=b[k++];if(p==c){m=-1;break}if(!m)break;m--;p=p.charCodeAt(0);7==d?p&=127:p=p-32&63;h=Wx(h*Math.pow(2,d)+p,d*e,!0)}if(0<=m){!1===f&&a.P("parse error ("+b+")");break}else b=b.substr(0,g)+by(a,h,-1)+b.substr(k)}return b}
function cy(a,b,c){var d=void 0;a.Ha=null;if(b){"{"!=a.qa[0]&&(b=b.split(a.qa[0]).join("{").split(a.qa[1]).join("}"));b=ay(a,b,'"',7,5,c);if(!b)return d;b=ay(a,b,"'",6,6,c);if(!b)return d;b=b.replace(/(^|[^A-Z0-9$%.])([0-9]+)B/,"$1$2^_").replace(/\s+/g," ");b=b.split(/(\{|}|\|\||&&|\||\^!|\^B|\^O|\^D|\^L|\^-|~|\^_|_|&|!=|!|==|>=|>>>|>>|>|<=|<<|<|-|\+|%|\/|\*| )/);d=Yx(a,b,0,b.length,a.F,c);void 0!==d&&!1===c&&dy(a,null,d)}return d}
function ey(a,b){var c,d=a.qa[0],e=a.qa[1];c="("==d||"{"==d||"["==d?"\\":"";for(var f="["==d?"\\":"",f=new RegExp(c+d+"([^"+f+d+f+e+"]+)"+c+e);c=b.match(f);){var g=cy(a,c[1]);if(void 0===g)return;b=b.replace(d+c[1]+e,null!=g?by(a,g):"undefined")}if(a.Aa.length)for(d=a.Aa[0],e=a.Aa[1],c="("==d||"{"==d||"["==d?"\\":"",f="["==d?"\\":"",f=new RegExp(c+d+"([^"+f+d+f+e+"]+)"+c+e);c=b.match(f);)b=a.Pk(b,c[1]);for(;d=b.match(/\$([a-z]+)/i);){e=null;switch(d[1].toLowerCase()){case "ops":e=a.Y-a.ha}if(null==