编译文本节点

@param {ANode} aNode 节点对象
@param {CompileSourceBuffer} sourceBuffer 编译源码的中间buffer
498993
function (aNode, sourceBuffer) {
        if (aNode.textExpr.original) {
            sourceBuffer.joinString(serializeStump('text'));
        }

        if (aNode.textExpr.value != null) {
            sourceBuffer.joinString(aNode.textExpr.segs[0].literal);
        }
        else {
            sourceBuffer.joinExpr(aNode.textExpr);
        }

        if (aNode.textExpr.original) {
            sourceBuffer.joinString(serializeStumpEnd('text'));
        }
    }
65909
public final void write (@Nonnull final NODETYPE aNode, @Nonnull @WillNotClose final Writer aWriter)
  {
    final XMLEmitter aXMLWriter = createXMLEmitter (aWriter, m_aSettings);
    // No parent node
    // No previous and no next sibling
    emitNode (aXMLWriter, null, null, aNode, null);
    // Flush is important for Writer!
    StreamHelper.flush (aWriter);
  }
1192863
function isOneLiner(node) {
            const first = sourceCode.getFirstToken(node),
                last = sourceCode.getLastToken(node);

            return first.loc.start.line === last.loc.end.line;
        }
267002
function addLineNumbers(ast, source) {
  var i;
  var sourcePosition = 0;
  var sourceLine = 1;
  var sourceColumn = 1;
  var prevBreak = false;
  walk(ast, function (node) {
    if (typeof node.pos !== 'undefined') {
      if (node.pos < sourcePosition) {
        sourcePosition = 0;
        sourceLine = 1;
        sourceColumn = 1;
      }
      for (i = sourcePosition; i < node.pos; i++) {
        var c = source.charAt(i);
        if (c === "\n") {
          if (!prevBreak) {
            sourceLine++;
          }
          sourceColumn = 1;
          prevBreak = false;
        } else if (c === "\r" || c === "\u2028" || c === "\u2029") {
          sourceLine++;
          sourceColumn = 1;
          prevBreak = true;
        } else {
          sourceColumn++;
          prevBreak = false;
        }
      }
      node.line = sourceLine;
      node.column = sourceColumn;
      sourcePosition = i;
    }
  });
}
1322418
private String toSource(Node n, SourceMap sourceMap, boolean firstOutput) {
    CodePrinter.Builder builder = new CodePrinter.Builder(n);
    builder.setTypeRegistry(getTypeRegistry());
    builder.setCompilerOptions(options);
    builder.setSourceMap(sourceMap);
    builder.setTagAsTypeSummary(!n.isFromExterns() && options.shouldGenerateTypedExterns());
    builder.setTagAsStrict(firstOutput && options.shouldEmitUseStrict());
    return builder.build();
  }
168192
private void pushContentSource(char[] newBuffer) {
        nextContentSource = new ContentSource(nextContentSource, buffer, position, limit);
        buffer = newBuffer;
        position = 0;
        limit = newBuffer.length;
    }
1039518
function compileComponentSource(sourceBuffer, ComponentClass, contextId) {
    ComponentClass.ssrContext = ComponentClass.ssrContext || {};
    var componentIdInContext = ComponentClass.ssrContext[contextId];

    if (!componentIdInContext) {
        componentIdInContext = genSSRId();
        ComponentClass.ssrContext[contextId] = componentIdInContext;

        // 先初始化个实例，让模板编译成 ANode，并且能获得初始化数据
        var component = new ComponentClass();
        component.ssrContextId = contextId;

        if (component.components) {
            Object.keys(component.components).forEach(
                function (key) {
                    var CmptClass = component.components[key];
                    if (CmptClass instanceof ComponentLoader) {
                        CmptClass = CmptClass.placeholder;
                    }

                    if (CmptClass) {
                        compileComponentSource(sourceBuffer, CmptClass, contextId);
                    }
                }
            );
        }

        sourceBuffer.addRaw('componentRenderers.' + componentIdInContext + ' = componentRenderers.'
            + componentIdInContext + '|| ' + componentIdInContext + ';');

        sourceBuffer.addRaw('var ' + componentIdInContext + 'Proto = ' + genComponentProtoCode(component));
        sourceBuffer.addRaw('function ' + componentIdInContext
            + '(data, noDataOutput, parentCtx, tagName, sourceSlots) {');
        sourceBuffer.addRaw('var html = "";');

        sourceBuffer.addRaw(genComponentContextCode(component, componentIdInContext));


        // init data
        var defaultData = component.data.get();
        sourceBuffer.addRaw('if (data) {');
        Object.keys(defaultData).forEach(function (key) {
            sourceBuffer.addRaw('componentCtx.data["' + key + '"] = componentCtx.data["' + key + '"] || '
                + stringifier.any(defaultData[key]) + ';');
        });
        sourceBuffer.addRaw('}');

        // calc computed
        sourceBuffer.addRaw('var computedNames = componentCtx.proto.computedNames;');
        sourceBuffer.addRaw('for (var $i = 0; $i < computedNames.length; $i++) {');
        sourceBuffer.addRaw('  var $computedName = computedNames[$i];');
        sourceBuffer.addRaw('  data[$computedName] = componentCtx.proto.computed[$computedName](componentCtx);');
        sourceBuffer.addRaw('}');


        var ifDirective = component.aNode.directives['if']; // eslint-disable-line dot-notation
        if (ifDirective) {
            sourceBuffer.addRaw('if (' + compileExprSource.expr(ifDirective.value) + ') {');
        }

        elementSourceCompiler.tagStart(sourceBuffer, component.aNode, 'tagName');


        sourceBuffer.addRaw('if (!noDataOutput) {');
        sourceBuffer.joinDataStringify();
        sourceBuffer.addRaw('}');


        elementSourceCompiler.inner(sourceBuffer, component.aNode, component);
        elementSourceCompiler.tagEnd(sourceBuffer, component.aNode, 'tagName');

        if (ifDirective) {
            sourceBuffer.addRaw('}');
        }

        sourceBuffer.addRaw('return html;');
        sourceBuffer.addRaw('};');
    }

    return componentIdInContext;
}
752794
function () {
            var self = this, l = self.length, needClone = self.length > 1, originArgs = util.makeArray(arguments);
            var cfg = originArgs[0];
            var AnimConstructor = Anim;
            if (cfg.to) {
                AnimConstructor = cfg.Anim || Anim;
            } else {
                cfg = originArgs[1];
                if (cfg) {
                    AnimConstructor = cfg.Anim || Anim;
                }
            }
            for (var i = 0; i < l; i++) {
                var elem = self[i];
                var args = needClone ? util.clone(originArgs) : originArgs, arg0 = args[0];
                if (arg0.to) {
                    arg0.node = elem;
                    new AnimConstructor(arg0).run();
                } else {
                    AnimConstructor.apply(undefined, [elem].concat(args)).run();
                }
            }
            return self;
        }
204782
function (input, readCallback) {
    if (compileStandard !== null) {
      return compileStandard(input, readCallback);
    }

    function formatFatalError (message) {
      return JSON.stringify({
        errors: [
          {
            'type': 'SOLCError',
            'component': 'dsolcjs',
            'severity': 'error',
            'message': message,
            'formattedMessage': 'Error: ' + message
          }
        ]
      });
    }

    if (readCallback !== undefined && typeof readCallback !== 'function') {
      return formatFatalError('Invalid import callback supplied');
    }

    try {
      input = JSON.parse(input);
    } catch (e) {
      return formatFatalError('Invalid JSON supplied: ' + e.message);
    }

    if (input['language'] !== 'Solidity') {
      return formatFatalError('Only Solidity sources are supported');
    }

    // NOTE: this is deliberately `== null`
    if (input['sources'] == null || input['sources'].length === 0) {
      return formatFatalError('No input specified');
    }

    // Bail out early
    if ((input['sources'].length > 1) && (compileJSONMulti === null)) {
      return formatFatalError('Multiple sources provided, but compiler only supports single input');
    }

    function isOptimizerEnabled (input) {
      return input['settings'] && input['settings']['optimizer'] && input['settings']['optimizer']['enabled'];
    }

    function translateSources (input) {
      var sources = {};
      for (var source in input['sources']) {
        if (input['sources'][source]['content'] !== null) {
          sources[source] = input['sources'][source]['content'];
        } else {
          // force failure
          return null;
        }
      }
      return sources;
    }

    function librariesSupplied (input) {
      if (input['settings'] !== null) {
        return input['settings']['libraries'];
      }
    }

    function translateOutput (output, libraries) {
      try {
        output = JSON.parse(output);
      } catch (e) {
        return formatFatalError('Compiler returned invalid JSON: ' + e.message);
      }
      output = translate.translateJsonCompilerOutput(output, libraries);
      if (output == null) {
        return formatFatalError('Failed to process output');
      }
      return JSON.stringify(output);
    }

    var sources = translateSources(input);
    if (sources === null || Object.keys(sources).length === 0) {
      return formatFatalError('Failed to process sources');
    }

    // Try linking if libraries were supplied
    var libraries = librariesSupplied(input);

    // Try to wrap around old versions
    if (compileJSONCallback !== null) {
      return translateOutput(compileJSONCallback(JSON.stringify({ 'sources': sources }), isOptimizerEnabled(input), readCallback), libraries);
    }

    if (compileJSONMulti !== null) {
      return translateOutput(compileJSONMulti(JSON.stringify({ 'sources': sources }), isOptimizerEnabled(input)), libraries);
    }

    // Try our luck with an ancient compiler
    if (compileJSON !== null) {
      return translateOutput(compileJSON(sources[Object.keys(sources)[0]], isOptimizerEnabled(input)), libraries);
    }

    return formatFatalError('Compiler does not support any known interface.');
  }
1052544
@Override
    protected void initInputSource(WstxInputSource newInput, boolean isExt, String entityId)
        throws XMLStreamException
    {
        if (mFlattenWriter != null) {
            // Anything to flush from previous buffer contents?
            mFlattenWriter.flush(mInputBuffer, mInputPtr);
            mFlattenWriter.disableOutput();
            try {
                /* Then let's let base class do the 'real' input source setup;
                 * this includes skipping of optional XML declaration that we
                 * do NOT want to output
                 */
                super.initInputSource(newInput, isExt, entityId);
            } finally {
                // This will effectively skip declaration
                mFlattenWriter.enableOutput(mInputPtr);
            }
        } else {
            super.initInputSource(newInput, isExt, entityId);
        }
    }
260612
function toNodeStream (renderer) {
  let sourceIsReady = true;

  const read = () => {
    // If source is not ready, defer any reads until the promise resolves.
    if (!sourceIsReady) { return false; }

    sourceIsReady = false;
    const pull = pullBatch(renderer, stream);

    return pull.then(result => {
      sourceIsReady = true;
      if (result === EXHAUSTED) {
        return stream.push(null);
      } else {
        if (result !== INCOMPLETE) {
          stream.push(result);
        }
        return read();
      }
    }).catch(err => {
      return stream.emit("error", err);
    });
  };

  const stream = new Readable({ read });

  return stream;
}
495059
function integrateAttr(aNode, name, value, options) {
    var prefixIndex = name.indexOf('-');
    var realName;
    var prefix;

    if (prefixIndex > 0) {
        prefix = name.slice(0, prefixIndex);
        realName = name.slice(prefixIndex + 1);
    }

    switch (prefix) {
        case 'on':
            var event = {
                name: realName,
                modifier: {}
            };
            aNode.events.push(event);

            var colonIndex;
            while ((colonIndex = value.indexOf(':')) > 0) {
                var modifier = value.slice(0, colonIndex);

                // eventHandler("dd:aa") 这种情况不能算modifier，需要辨识
                if (!/^[a-z]+$/i.test(modifier)) {
                    break;
                }

                event.modifier[modifier] = true;
                value = value.slice(colonIndex + 1);
            }

            event.expr = parseCall(value, [
                createAccessor([
                    {type: ExprType.STRING, value: '$event'}
                ])
            ]);
            break;

        case 'san':
        case 's':
            parseDirective(aNode, realName, value, options);
            break;

        case 'prop':
            integrateProp(aNode, realName, value, options);
            break;

        case 'var':
            if (!aNode.vars) {
                aNode.vars = [];
            }

            realName = kebab2camel(realName);
            aNode.vars.push({
                name: realName,
                expr: parseExpr(value.replace(/(^\{\{|\}\}$)/g, ''))
            });
            break;

        default:
            integrateProp(aNode, name, value, options);
    }
}
146058
function bufferCount(bufferSize, startBufferEvery) {
    if (startBufferEvery === void 0) {
        startBufferEvery = null;
    }
    return function bufferCountOperatorFunction(source) {
        return source.lift(new BufferCountOperator(bufferSize, startBufferEvery));
    };
}
739084
function compile( src ) {
    var watch  = arguments.length <= 1 || arguments[1] === void 0 ? true : arguments[1];
    var parent = arguments.length <= 2 || arguments[2] === void 0 ? null : arguments[2];

    var script = new SourceScript( src, parent );

    if( watch ) {
        script.watch();
    }

    return script;
}
790800
function ( source ) {

		var comment = false;
		var chapters = [];
		var chapter = null;
		var sections = [];
		var section = null;
		var marker = new Showdown.converter ();

		function nextchapter ( title ) {
			if ( chapter ) {
				chapter.sections = sections.map ( function ( section, i ) {
					section.desc = marker.makeHtml ( section.desc );
					return section;
				});
				chapters.push ( chapter );
			}
			chapter = new dox.Chapter ({
				title : title || null
			});
			sections = [];
		}

		function nextsection ( line ) {
			if ( section && section.code ) {
				sections.push ( section );
			}
			section = new dox.Block ({
				line : line || 0,
				tags : [],
				desc : "",
				code : ""
			});
		}

		nextsection ();
		nextchapter ();
		source.split ( "\n" ).forEach ( function ( line, index ) {
			var md, trim = line.trim ();
			if ( comment ) {
				if ( trim.startsWith ( "*/" )) {
					comment = false;
				} else {
					if ( trim === "*" ) {
						section.desc += "\n\n";
					} else {
						md = line.replace ( this._GUTTER, "" );
						switch ( md [ 0 ]) {
							case "@" :
								section.tags.push ( new dox.Tag ({
									text : this._encode ( md )
								}));
								break;
							case "#" :
								//chapter.title = md.replace ( this._HEADER, "" );
								section.desc += "\n" + md + "\n\n";
								break;
							default :
								if ( !md.match ( this._LETTER )) {
									section.desc += "\n";
								}
								section.desc += this._encode ( md );
								break;
						}
					}
				}
			} else {
				if ( line.match ( this._CHAPTER )) {
					var title = this._TITLE.exec ( line );
					nextsection ( index );
					nextchapter ( title ? title [ 0 ] : null );
					section.code += this._HELLO.exec ( line );
				} else {
					if ( trim.startsWith ( "/**" )) {
						comment = true;
						nextsection ( index );
					} else {
						section.code += line + "\n";
					}
				}
			}
		}, this );
		nextsection ();
		nextchapter ();
		return chapters;
	}
536103
function (aNode, sourceBuffer, owner) {
        var forElementANode = {
            children: aNode.children,
            props: aNode.props,
            events: aNode.events,
            tagName: aNode.tagName,
            directives: extend({}, aNode.directives),
            hotspot: aNode.hotspot
        };
        forElementANode.directives['for'] = null;

        var forDirective = aNode.directives['for']; // eslint-disable-line dot-notation
        var itemName = forDirective.item;
        var indexName = forDirective.index || genSSRId();
        var listName = genSSRId();


        sourceBuffer.addRaw('var ' + listName + ' = ' + compileExprSource.expr(forDirective.value) + ';');
        sourceBuffer.addRaw('if (' + listName + ' instanceof Array) {');

        // for array
        sourceBuffer.addRaw('for ('
            + 'var ' + indexName + ' = 0; '
            + indexName + ' < ' + listName + '.length; '
            + indexName + '++) {'
        );
        sourceBuffer.addRaw('componentCtx.data.' + indexName + '=' + indexName + ';');
        sourceBuffer.addRaw('componentCtx.data.' + itemName + '= ' + listName + '[' + indexName + '];');
        sourceBuffer.addRaw(
            aNodeCompiler.compile(
                forElementANode,
                sourceBuffer,
                owner
            )
        );
        sourceBuffer.addRaw('}');

        sourceBuffer.addRaw('} else if (typeof ' + listName + ' === "object") {');

        // for object
        sourceBuffer.addRaw('for (var ' + indexName + ' in ' + listName + ') {');
        sourceBuffer.addRaw('if (' + listName + '[' + indexName + '] != null) {');
        sourceBuffer.addRaw('componentCtx.data.' + indexName + '=' + indexName + ';');
        sourceBuffer.addRaw('componentCtx.data.' + itemName + '= ' + listName + '[' + indexName + '];');
        sourceBuffer.addRaw(
            aNodeCompiler.compile(
                forElementANode,
                sourceBuffer,
                owner
            )
        );
        sourceBuffer.addRaw('}');
        sourceBuffer.addRaw('}');

        sourceBuffer.addRaw('}');
    }
1103189
function (sourceBuffer, aNode, tagNameVariable) {
        var props = aNode.props;
        var bindDirective = aNode.directives.bind;
        var tagName = aNode.tagName;

        if (tagName) {
            sourceBuffer.joinString('<' + tagName);
        }
        else if (tagNameVariable) {
            sourceBuffer.joinString('<');
            sourceBuffer.joinRaw(tagNameVariable + ' || "div"');
        }
        else {
            sourceBuffer.joinString('<div');
        }

        // index list
        var propsIndex = {};
        each(props, function (prop) {
            propsIndex[prop.name] = prop;

            if (prop.name !== 'slot' && prop.expr.value != null) {
                sourceBuffer.joinString(' ' + prop.name + '="' + prop.expr.segs[0].literal + '"');
            }
        });

        each(props, function (prop) {
            if (prop.name === 'slot' || prop.expr.value != null) {
                return;
            }

            if (prop.name === 'value') {
                switch (tagName) {
                    case 'textarea':
                        return;

                    case 'select':
                        sourceBuffer.addRaw('$selectValue = '
                            + compileExprSource.expr(prop.expr)
                            + ' || "";'
                        );
                        return;

                    case 'option':
                        sourceBuffer.addRaw('$optionValue = '
                            + compileExprSource.expr(prop.expr)
                            + ';'
                        );
                        // value
                        sourceBuffer.addRaw('if ($optionValue != null) {');
                        sourceBuffer.joinRaw('" value=\\"" + $optionValue + "\\""');
                        sourceBuffer.addRaw('}');

                        // selected
                        sourceBuffer.addRaw('if ($optionValue === $selectValue) {');
                        sourceBuffer.joinString(' selected');
                        sourceBuffer.addRaw('}');
                        return;
                }
            }

            switch (prop.name) {
                case 'readonly':
                case 'disabled':
                case 'multiple':
                    if (prop.raw === '') {
                        sourceBuffer.joinString(' ' + prop.name);
                    }
                    else {
                        sourceBuffer.joinRaw('boolAttrFilter("' + prop.name + '", '
                            + compileExprSource.expr(prop.expr)
                            + ')'
                        );
                    }
                    break;

                case 'checked':
                    if (tagName === 'input') {
                        var valueProp = propsIndex.value;
                        var valueCode = compileExprSource.expr(valueProp.expr);

                        if (valueProp) {
                            switch (propsIndex.type.raw) {
                                case 'checkbox':
                                    sourceBuffer.addRaw('if (contains('
                                        + compileExprSource.expr(prop.expr)
                                        + ', '
                                        + valueCode
                                        + ')) {'
                                    );
                                    sourceBuffer.joinString(' checked');
                                    sourceBuffer.addRaw('}');
                                    break;

                                case 'radio':
                                    sourceBuffer.addRaw('if ('
                                        + compileExprSource.expr(prop.expr)
                                        + ' === '
                                        + valueCode
                                        + ') {'
                                    );
                                    sourceBuffer.joinString(' checked');
                                    sourceBuffer.addRaw('}');
                                    break;
                            }
                        }
                    }
                    break;

                default:
                    var onlyOneAccessor = false;
                    var preCondExpr;

                    if (prop.expr.type === ExprType.ACCESSOR) {
                        onlyOneAccessor = true;
                        preCondExpr = prop.expr;
                    }
                    else if (prop.expr.segs.length === 1) {
                        var interpExpr = prop.expr.segs[0];
                        var interpFilters = interpExpr.filters;

                        if (!interpFilters.length
                            || interpFilters.length === 1 && interpFilters[0].args.length === 0
                        ) {
                            onlyOneAccessor = true;
                            preCondExpr = prop.expr.segs[0].expr;
                        }
                    }

                    if (onlyOneAccessor) {
                        sourceBuffer.addRaw('if (' + compileExprSource.expr(preCondExpr) + ') {');
                    }

                    sourceBuffer.joinRaw('attrFilter("' + prop.name + '", '
                        + (prop.x ? 'escapeHTML(' : '')
                        + compileExprSource.expr(prop.expr)
                        + (prop.x ? ')' : '')
                        + ')'
                    );

                    if (onlyOneAccessor) {
                        sourceBuffer.addRaw('}');
                    }

                    break;
            }
        });

        if (bindDirective) {
            sourceBuffer.addRaw(
                '(function ($bindObj) {for (var $key in $bindObj) {'
                + 'var $value = $bindObj[$key];'
            );

            if (tagName === 'textarea') {
                sourceBuffer.addRaw(
                    'if ($key === "value") {'
                    + 'continue;'
                    + '}'
                );
            }

            sourceBuffer.addRaw('switch ($key) {\n'
                + 'case "readonly":\n'
                + 'case "disabled":\n'
                + 'case "multiple":\n'
                + 'case "multiple":\n'
                + 'html += boolAttrFilter($key, escapeHTML($value));\n'
                + 'break;\n'
                + 'default:\n'
                + 'html += attrFilter($key, escapeHTML($value));'
                + '}'
            );

            sourceBuffer.addRaw(
                '}})('
                + compileExprSource.expr(bindDirective.value)
                + ');'
            );
        }

        sourceBuffer.joinString('>');
    }