File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -9,15 +9,30 @@ class Context
9
9
def initialize ( runtime , source = "" , options = { } )
10
10
end
11
11
12
+ # Evaluates the +source+ in the context of a function body and returns the
13
+ # returned value.
14
+ #
15
+ # context.exec("return 1") # => 1
16
+ # context.exec("1") # => nil (nothing was returned)
12
17
def exec ( source , options = { } )
13
18
raise NotImplementedError
14
19
end
15
20
21
+ # Evaluates the +source+ as an expression and returns the result.
22
+ #
23
+ # context.eval("1") # => 1
24
+ # context.eval("return 1") # => Raises SyntaxError
16
25
def eval ( source , options = { } )
17
26
raise NotImplementedError
18
27
end
19
28
20
- def call ( properties , *args )
29
+ # Evaluates +source+ as an expression (which should be of type
30
+ # +function+), and calls the function with the given arguments.
31
+ # The function will be evaluated with the global object as +this+.
32
+ #
33
+ # context.call("function(a, b) { return a + b }", 1, 1) # => 2
34
+ # context.call("CoffeeScript.compile", "1 + 1")
35
+ def call ( source , *args )
21
36
raise NotImplementedError
22
37
end
23
38
end
You can’t perform that action at this time.
0 commit comments