Hehe, "competition is good for the business"... buts really let's focus on
the debugging part here, as VanillaSDK is not yet really a big code base to
compile.

> Clever use of comment to

Looks like something's missing there?

What do you think it would take to introduce source maps to FalconJx?
I guess Falcon already keeps the source code file positions (line/column)
in the AST nodes, e.g. for error messages?
>From my experiment, I have a simple class
PositionTrackingWriter<https://github.com/CoreMedia/jangaroo-tools/blob/source-maps/jangaroo/jangaroo-compiler/src/main/java/net/jangaroo/jooc/util/PositionTrackingWriter.java>
which
extends java.io.Writer and simply counts characters and new lines while
outputting them, so always knows the current line / column.
Then, the Google source maps API (part of closure.jar) can be used along
the lines of

import com.google.debugging.sourcemap.SourceMapFormat;
import com.google.debugging.sourcemap.SourceMapGenerator;
import com.google.debugging.sourcemap.SourceMapGeneratorFactory;

SourceMapGenerator sourceMapGenerator =
SourceMapGeneratorFactory.getInstance(SourceMapFormat.V3);

  // for each generated piece of code:
  sourceMapGenerator.addMapping(
                    sourceFilename,
                    null,
                    sourceFilePosition,
                    outputFileStartPosition, outputFileEndPosition);

sourceMapGenerator.appendTo(new FileWriter(outFile.getAbsolutePath() +
".map.json"), outFile.getName());
codeSuffix = "//@ sourceMappingURL=" + outFile.getName() + ".map.json";

Simple enough, isn't it?

Greetings
-Frank-

Reply via email to