Class: ExecJS::GraalJSRuntime

Inherits:
Runtime
  • Object
show all
Defined in:
lib/execjs/graaljs_runtime.rb

Defined Under Namespace

Classes: Context

Instance Method Summary collapse

Methods inherited from Runtime

#compile, #context_class, #deprecated?, #eval, #exec

Instance Method Details

#available?Boolean

Returns:

  • (Boolean)


125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/execjs/graaljs_runtime.rb', line 125

def available?
  return @available if defined?(@available)

  unless RUBY_ENGINE == "truffleruby"
    return @available = false
  end

  unless defined?(Polyglot::InnerContext)
    warn "TruffleRuby #{RUBY_ENGINE_VERSION} does not have support for inner contexts, use a more recent version", uplevel: 0 if $VERBOSE
    return @available = false
  end

  unless Polyglot.languages.include? "js"
    warn "The language 'js' is not available, you likely need to `export TRUFFLERUBYOPT='--jvm --polyglot'`", uplevel: 0 if $VERBOSE
    warn "You also need to install the 'js' component with 'gu install js' on GraalVM 22.2+", uplevel: 0 if $VERBOSE
    warn "Note that you need TruffleRuby+GraalVM and not just the TruffleRuby standalone to use #{self.class}", uplevel: 0 if $VERBOSE
    return @available = false
  end

  @available = true
end

#nameObject



121
122
123
# File 'lib/execjs/graaljs_runtime.rb', line 121

def name
  "GraalVM (Graal.js)"
end