inspectedObjects: function() { return inspectedObjectLiteral( `<UniqueIdentifierHandle preferredName: '${Caf.toString( this.preferredName )}', scopeSet: ${Caf.toString( !!this.scope )}, _identifier: ${Caf.toString(inspect(this._identifier))}>` ); },
(initializer, identifier) => isString(initializer) ? `${Caf.toString(identifier)} = ${Caf.toString( initializer )}` : initializer.toJsExpression != null ? `${Caf.toString(identifier)} = ${Caf.toString( initializer.toJsExpression() )}` : identifier,
(() => { while ( blockedIndentifiers[ (name = `${Caf.toString(preferredName)}${Caf.toString( (count += 1) )}`) ] ) { name; } })(),
this.resolveOperatorPrecidence = ( operators, operands, combinerOverride ) => { if (!(operands.length === operators.length + 1)) { throw new Error( `expecting: operands.length:${Caf.toString( operands.length )} == operators.length:${Caf.toString(operators.length)} + 1` ); } while (operators.length > 0) { let lowestPrecidence, firstOccurance, lastOccurance, p, opIndexToResolve, opsBefore, operandsBefore, op, operandA, operandB, combiner; lowestPrecidence = this.getOpPrecidence(operators[0]); firstOccurance = lastOccurance = 0; p = null; Caf.each2(operators, (op, i) => lowestPrecidence > (p = this.getOpPrecidence(op)) ? ((firstOccurance = lastOccurance = i), (lowestPrecidence = p)) : lowestPrecidence === p ? (lastOccurance = i) : undefined ); opIndexToResolve = this.getPrecidenceLevelIsLeftAssociative(p) ? firstOccurance : lastOccurance; opsBefore = operators; operandsBefore = operands; op = operators[opIndexToResolve]; operandA = operands[opIndexToResolve]; operandB = operands[opIndexToResolve + 1]; operators = arrayWithout(operators, opIndexToResolve); operands = arrayWithout(operands, opIndexToResolve); combiner = combinerOverride || this.operatorMap[op] || infix; operands[opIndexToResolve] = combiner(operandA, operandB, op); } if (!(operands.length === 1)) { throw new Error(); } return operands[0]; };
return (() => { throw new Error( `toSourceNode not overridden in ${Caf.toString( this.class.name )}. Falling back to old toJs().` ); })();
? (() => { throw new Error( `Scope must be fully updated. ${Caf.toString( this.className )}` ); })()
autoLets: function() { let identifiers; this.bindAllUniqueIdentifiersRequested(); return this._identifiersAssigned && (identifiers = this.requiredIdentifierLets).length > 0 ? `let ${Caf.toString(identifiers.join(", "))}` : undefined; }
this.getOpPrecidence = op => { let p; if (!((p = this.opsToPrecidence[op]) != null)) { throw new Error( `OperatorHelper: operator '${Caf.toString(op)}' not defined` ); } return p; };
this.validateOperator = validateOperator = operator => { if (!this.opsToPrecidence[operator]) { throw new Error( `OperatorHelper: operator '${Caf.toString( operator )}' is not defined` ); } return operator; };
inspectedObjects: function() { let label, props, name, a; ({ label } = this); props = this.getInspectedProps(); name = this.class.getName(); if (label) { name = `${Caf.toString(label)}.${Caf.toString(name)}`; } return { [`${Caf.toString(name)}`]: this.children.length === 0 ? toInspectedObjects(props) : ((a = []), objectKeyCount(props) > 0 ? a.push(props) : undefined, a.concat( Caf.array(this.children, c => c.inspectedObjects) )) }; },
this.prototype.toSourceNode = function(options) { let out; out = supportedOperatorsRegExp.test(this.operator) ? this.createSourceNode( this.lValue.toSourceNode(), ` ${Caf.toString(this.operator)}= `, this.rValue.toSourceNode({ expression: true }) ) : this.createSourceNode( this.lValue.toSourceNode({ expression: true }), ` ${Caf.toString(this.operator)} `, this.lValue.toSourceNode(), " = ", this.rValue.toSourceNode({ expression: true }) ); return (Caf.exists(options) && options.dotBase) || (Caf.exists(options) && options.subExpression) ? this.createSourceNode("(", out, ")") : out; };
this.prototype.getBareInitializers = function() { let identifiers; this.bindAllUniqueIdentifiersRequested(); return this._identifiersAssigned && (identifiers = this.requiredIdentifierLets).length > 0 ? ((identifiers = Caf.array(identifiers, null, identifier => identifier.match(/=/) )), identifiers.length > 0 ? `${Caf.toString(identifiers.join("; "))}` : undefined) : undefined; };
"?": function(a, b) { return a.match(/^@?[_a-z0-9]+$/i) ? `${Caf.toString(a)} != null ? ${Caf.toString( a )} : ${Caf.toString(b)}` : `${Caf.toString(CoffeeScriptGlobal)}.existsOr(${Caf.toString( a )}, (() => {return ${Caf.toString(b)}})())`; }
constructor(props, children) { super(...arguments); this.operator = props.operator || ""; this.lValue = children[0]; this.rValue = children[1]; if (!(this.lValue && this.rValue)) { throw new Error( `AssignmentStn: expected lValue and rValue: ${Caf.toString( formattedInspect({ operator: this.operator, lValue: this.lValue, rValue: this.rValue }) )}` ); } }
this.infix = infix = function(a, b, op) { return `${Caf.toString(a)} ${Caf.toString(op)} ${Caf.toString(b)}`; };
isnt: function(a, b) { return `!${Caf.toString(CoffeeScriptGlobal)}.is(${Caf.toString( a )}, ${Caf.toString(b)})`; },
"%%": function(a, b) { return `${Caf.toString(CoffeeScriptGlobal)}.mod(${Caf.toString( a )}, ${Caf.toString(b)})`; },
return function() { this.rule({ doubleQuote: /"/, singleQuote: /'/, interpolationStart: /\#\{/, interpolationEnd: /\}/, dqStringMiddle: /([^"\\#]|\u[0-9a-f]{4}|\u\{[0-9a-f]+\}|\x[0-9a-f]{2}|\\(?:[1-7][0-7]{0,2}|[0-7]{2,3})|\\.|\#(?!\{))*/, sqStringMiddle: /([^'\\#]|\u[0-9a-f]{4}|\u\{[0-9a-f]+\}|\x[0-9a-f]{2}|\\(?:[1-7][0-7]{0,2}|[0-7]{2,3})|\\.|\#(?!\{))*/, blockStringMiddle: /([^\\#]|\u[0-9a-f]{4}|\u\{[0-9a-f]+\}|\x[0-9a-f]{2}|\\(?:[1-7][0-7]{0,2}|[0-7]{2,3})|\\.|\#(?!\{))*/ }); this.rule({ stringLiteral: [ { pattern: `/""/ tripple:/"/? &/${Caf.toString( blockStringStartChar.source )}/ stringBlock`, getStn: function() { let ret; ret = this.stringBlock.getStn(); if (!this.tripple) { Caf.isF(ret.compactNewLines) && ret.compactNewLines(); Caf.isF(ret.trimLeft) && ret.trimLeft(); } Caf.isF(ret.trimRight) && ret.trimRight(); return ret; } }, { pattern: "/''/ tripple:/'/? &/ +[^ \\n]| *\\n/ unparsedBlock", getStn: function() { let ret; ret = StringStn({ parseTreeNode: this, value: this.unparsedBlock.toString() }); if (!this.tripple) { ret.compactNewLines(); } return ret; } }, { pattern: "/\"\"\"|'''/", getStn: function() { return StringStn({ parseTreeNode: this, value: "" }); } }, { pattern: RegExp(`:(?!:)${Caf.toString(wordStringChar.source)}+`), getStn: function() { return StringStn({ parseTreeNode: this, value: this.toString().slice(1) }); } }, { pattern: /#[$\w\u007f-\uffff]+/, getStn: function() { return StringStn({ parseTreeNode: this, value: this.toString() }); } }, { pattern: /[-+]?(?!00)[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?[$\w\u007f-\uffff]+/, getStn: function() { return StringStn({ parseTreeNode: this, value: this.toString() }); } } ], stringBlock: Extensions.IndentBlocks.getPropsToSubparseToEolAndBlock({ rule: "stringBlockBody" }) }); this.rule( { stringLiteral: [ "bracketStart:doubleQuote mid:dqStringMiddle interpolation:dqStringInterpolation? doubleQuote", "bracketStart:singleQuote mid:sqStringMiddle interpolation:sqStringInterpolation? singleQuote" ], stringBlockBody: "/ *\n/? mid:blockStringMiddle interpolation:blockStringInterpolation?" }, { getStnChildren: function(appendTo = []) { let base; if (this.mid.matchLength > 0) { appendTo.push( StringStn({ parseTreeNode: this, value: this.mid.toString() }) ); } Caf.exists((base = this.interpolation)) && base.getStnChildren(appendTo); return appendTo; }, getStn: function() { let ret; ret = this.interpolation ? InterpolatedStringStn(this.getStnChildren()) : StringStn({ parseTreeNode: this, value: this.mid.toString() }); if (this.bracketStart) { ret.compactNewLines(true, true); } return ret; } } ); this.rule({ interpolation: [ "interpolationStart interpolationEnd expression:toEolAndBlock", "interpolationStart _OrEnd interpolationEnd", "interpolationStart _? expression:root interpolationEnd", "interpolationStart expression:block end? interpolationEnd" ] }); return this.rule( { dqStringInterpolation: "interpolation mid:dqStringMiddle interpolationContinues:dqStringInterpolation?", sqStringInterpolation: "interpolation mid:sqStringMiddle interpolationContinues:sqStringInterpolation?", blockStringInterpolation: "interpolation mid:blockStringMiddle interpolationContinues:blockStringInterpolation?" }, { getStnChildren: function(appendTo = []) { let expression, base; if ((expression = this.interpolation.expression)) { appendTo.push(expression.getStn()); } if (this.mid.matchLength > 0) { appendTo.push( StringStn({ parseTreeNode: this, value: this.mid.toString() }) ); } Caf.exists((base = this.interpolationContinues)) && base.getStnChildren(appendTo); return appendTo; } } ); };
return (() => { switch (operand) { case "**": return [ `${Caf.toString(CoffeeScriptGlobal)}.pow(`, a, ", ", b, ")" ]; case "//": return [ `${Caf.toString(CoffeeScriptGlobal)}.div(`, a, ", ", b, ")" ]; case "%%": return [ `${Caf.toString(CoffeeScriptGlobal)}.mod(`, a, ", ", b, ")" ]; case "in": return [ `${Caf.toString(CoffeeScriptGlobal)}.in(`, a, ", ", b, ")" ]; case "is": return [ `${Caf.toString(CoffeeScriptGlobal)}.is(`, a, ", ", b, ")" ]; case "isnt": return [ `!${Caf.toString(CoffeeScriptGlobal)}.is(`, a, ", ", b, ")" ]; case "?": return (() => { switch (aStn.type) { case "This": case "Identifier": case "Reference": return [a, " != null ? ", a, " : ", b]; default: return [ CoffeeScriptGlobal, ".existsOr(", a, ", (() => {return ", b, "})())" ]; } })(); default: return [a, ` ${Caf.toString(operand)} `, b]; } })();