Multi-Stage JavaScript

07/04/2018
by   Anthony Savidis, et al.
0

Multi-stage languages support generative metaprogramming via macros evaluated in a process preceding the actual interpretation or compilation of the program in which they are used. Macros update the source of their hosting program by emitting code that takes their place in the file, while their code may also be produced, fully or partially, by nested macros. All macros at the same nesting belong to the same stage, with the outer stage collecting the macros affect-ing only the main program. We extended JavaScript with staging annotations and implemented them in Spider Monkey, emitting pure JavaScript code as the final outcome of stage computation. We discuss how the original Spider Monkey system is minimally affected with extensions in the syntax, parser and internal AST structures, and the addition of an unparser, a staging loop, some library functions and a debugger backend component for AST inspection. Since stages have a generative metaprogramming role we do not foresee any interplay with the browser DOM, and thus there is no reason to repeat their evalua-tion on every page load. Hence, such JavaScript extensions are meant only for development-time, emitting pure JavaScript code that can be run in any browser. Finally, to enable debugging stages in any browser we implemented a pure JavaScript client, communicating with the extended Spider Monkey, and offering the necessary AST display and unparsing that a browser debugger does not provide.

READ FULL TEXT
research
08/02/2018

Debugging Native Extensions of Dynamic Languages

Many dynamic programming languages such as Ruby and Python enable develo...
research
02/22/2018

Investigating the Evolvability of Web Page Load Time

Client-side Javascript execution environments (browsers) allow anonymous...
research
06/17/2022

Evaluating the Impact of Source Code Parsers on ML4SE Models

As researchers and practitioners apply Machine Learning to increasingly ...
research
09/19/2011

The SeaLion has Landed: An IDE for Answer-Set Programming---Preliminary Report

We report about the current state and designated features of the tool Se...
research
02/19/2018

CalcuList: a Functional Language Extended with Imperative Features

CalcuList (Calculator with List manipulation), is an educational languag...
research
07/27/2017

Providing Self-Aware Systems with Reflexivity

We propose a new type of self-aware systems inspired by ideas from highe...
research
06/08/2021

Dynamic Software Updates for Unmodified Browsers through Multi-Version Execution

In this paper, we present the design, implementation, and evaluation of ...

Please sign up or login with your details

Forgot password? Click here to reset