Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLDefineFunctionBuiltin.java @ 13882:afd6fa5e8229
SL: Feedback from reviewers
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Wed, 05 Feb 2014 08:02:15 -0800 |
parents | b16ec83edc73 |
children | 89ac75425681 |
comparison
equal
deleted
inserted
replaced
13881:272a166a9574 | 13882:afd6fa5e8229 |
---|---|
20 * or visit www.oracle.com if you need additional information or have any | 20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. | 21 * questions. |
22 */ | 22 */ |
23 package com.oracle.truffle.sl.builtins; | 23 package com.oracle.truffle.sl.builtins; |
24 | 24 |
25 import com.oracle.truffle.api.CompilerDirectives.SlowPath; | |
25 import com.oracle.truffle.api.*; | 26 import com.oracle.truffle.api.*; |
26 import com.oracle.truffle.api.dsl.*; | 27 import com.oracle.truffle.api.dsl.*; |
27 import com.oracle.truffle.api.nodes.*; | 28 import com.oracle.truffle.api.nodes.*; |
28 import com.oracle.truffle.sl.parser.*; | 29 import com.oracle.truffle.sl.parser.*; |
30 import com.oracle.truffle.sl.runtime.*; | |
29 | 31 |
30 /** | 32 /** |
31 * Builtin function to define (or redefine) functions. The provided source code is parsed the same | 33 * Builtin function to define (or redefine) functions. The provided source code is parsed the same |
32 * way as the initial source of the script, so the same syntax applies. | 34 * way as the initial source of the script, so the same syntax applies. |
33 */ | 35 */ |
34 @NodeInfo(shortName = "defineFunction") | 36 @NodeInfo(shortName = "defineFunction") |
35 public abstract class SLDefineFunctionBuiltin extends SLBuiltinNode { | 37 public abstract class SLDefineFunctionBuiltin extends SLBuiltinNode { |
36 | 38 |
37 @Specialization | 39 @Specialization |
38 public String defineFunction(String code) { | 40 public String defineFunction(String code) { |
39 Source source = getContext().getSourceManager().get("[defineFunction]", code); | 41 return doDefineFunction(getContext(), code); |
42 } | |
43 | |
44 @SlowPath | |
45 private static String doDefineFunction(SLContext context, String code) { | |
46 Source source = context.getSourceManager().get("[defineFunction]", code); | |
40 /* The same parsing code as for parsing the initial source. */ | 47 /* The same parsing code as for parsing the initial source. */ |
41 Parser.parseSL(getContext(), source); | 48 Parser.parseSL(context, source); |
42 return code; | 49 return code; |
43 } | 50 } |
44 } | 51 } |