class Mint::Compiler::Js

Overview

This class is resposible for creating a tree of JS code.

Defined in:

compiler/js.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(optimize : Bool) #

[View source]

Class Method Detail

def self.async?(items : Array(Compiled)) #

[View source]
def self.async?(items : Compiled) #

[View source]
def self.async?(item : Item) #

[View source]

Instance Method Detail

def array(items : Array(Compiled)) : Compiled #

Renders an array.


[View source]
def arrow_function(arguments : Array(Compiled) = [] of Compiled, &) : Compiled #

Renders an arrow function.


[View source]
def assign(name : Item | Compiled, value : Compiled) : Compiled #

Renders an assignment.


[View source]
def call(name : Item | Compiled, arguments : Array(Compiled)) : Compiled #

Renders a call.


[View source]
def const(name : Item | Compiled, value : Compiled) : Compiled #

Renders a const assignment.


[View source]
def consts(items : Array(Tuple(Ast::Node, Id, Compiled))) : Compiled #

Renders multiple const assignments (as one).


[View source]
def for(variables : Compiled, subject : Compiled, &) : Compiled #

Renders a for statement.


[View source]
def if(condition : Compiled, body : Compiled) : Compiled #

Renders an if statement.


[View source]
def iif(&) : Compiled #

Renders an immediately invoked function.


[View source]
def let(name : Item | Compiled, value : Compiled) : Compiled #

Renders a let assignment.


[View source]
def let(variables : Array(Variable)) : Compiled #

Renders a let assignment with multiple variables.


[View source]
def new(name : Item | Compiled, items : Array(Compiled) = [] of Compiled) : Compiled #

Renders an initializer.


[View source]
def null : Compiled #

Renders #null.


[View source]
def object(items : Hash(Item, Compiled)) : Compiled #

Renders an object. The key can be any item but it's usually a string or an identifier.


[View source]
def object_destructuring(items : Array(Compiled)) : Compiled #

Renders an object destructuring.


[View source]
def optimize? : Bool #

Whether or not to optimize the output.


[View source]
def return(item : Compiled) : Compiled #

Renders a return statement.


[View source]
def statements(items : Array(Compiled)) : Compiled #

Renders statements.


[View source]
def string(value : String) : Compiled #

Renders a string using a template literal (``).

TODO Check if a simple string is enough?


[View source]
def tenary(condition : Compiled, truthy : Compiled, falsy : Compiled) : Compiled #

Renders an tenary operator.


[View source]