0.1.2 • Published 10 years ago

ir2js v0.1.2

Weekly downloads
1
License
BSD
Repository
github
Last release
10 years ago

ir2js

ir2js converts source code written in ir syntax to JavaScript code with Google Closure annotations. ir is a statically typed language with concise grammar and focus on class design, but otherwise very similar to JavaScript.

Features of the ir language

  • Statically typed (type checking provided by the Closure compiler). Types are requierd for function parameters and class members variables.
  • Concise grammar -- much smaller than the equivalent JavaScript code with Closure annotations. Smaller code lowers refactoring barrier.
  • Explicit class system. Smaller overhead of defining a new class promotes designing code based on classes and how they interact with each other.
  • Indentations to express code blocks (as in Python) as well as data structures (like YAML). This makes the code and data structures visually clearer.

Features of the converter

  • ir2js converter itself is written in ir and runs on Node. (although there is no reason it can not run on a modern browser).
  • The conversion is per file -- one ir file gets converted to one js independently from other ir or js files.
  • The converter can read metadata to sort the output js files in the order that satisfies the inheritance dependencies.
  • The Closure compiler is required for the static type checking, but otherwise the generated js files run without further compilations.
  • The compiled js files do not require the Closure library.
  • The produced js files are reasonably readable and variable names are preserved, so one can debug on them and find the corresponding code in the original ir files easily.
  • The output js is tested on V8 (Node.js and Chrome browser).

How to use

To comple, run node.js (the command maybe different for your installation) with ir2js as the first parameter, followed by the input ir file names.

$ node ir2js --outdir=output_dir input_file1.ir input_file2.ir ...

The generated files can be loaded into HTML with tags.

<script src="output_dir/output_file1.js"></script>
<script src="output_dir/output_file2.js"></script>

Closure compiler can be used to do the static type checking on the output js files.

java -jar closure/compiler.jar \
--compilation_level ADVANCED_OPTIMIZATIONS \
--summary_detail_level 3 \
--warning_level VERBOSE \
--js_output_file compiled/_ir2js_test.js \
--js closure-library/closure/goog/base.js \
--js output_file1.js \
--js output_file2.js

See the Makeifle of ir2js for how this can be set up.

0.1.2

10 years ago

0.1.1

11 years ago

0.1.0

11 years ago