Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLDefineFunctionBuiltin.java @ 13821:b16ec83edc73
Documentation and more refactoring of Simple Language
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Wed, 29 Jan 2014 20:45:43 -0800 |
parents | 7c418666c6c9 |
children | afd6fa5e8229 |
comparison
equal
deleted
inserted
replaced
13820:20e7727588e8 | 13821:b16ec83edc73 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
22 */ | 22 */ |
23 package com.oracle.truffle.sl.builtins; | 23 package com.oracle.truffle.sl.builtins; |
24 | 24 |
25 import com.oracle.truffle.api.*; | 25 import com.oracle.truffle.api.*; |
26 import com.oracle.truffle.api.dsl.*; | 26 import com.oracle.truffle.api.dsl.*; |
27 import com.oracle.truffle.api.nodes.*; | |
27 import com.oracle.truffle.sl.parser.*; | 28 import com.oracle.truffle.sl.parser.*; |
28 | 29 |
30 /** | |
31 * 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. | |
33 */ | |
34 @NodeInfo(shortName = "defineFunction") | |
29 public abstract class SLDefineFunctionBuiltin extends SLBuiltinNode { | 35 public abstract class SLDefineFunctionBuiltin extends SLBuiltinNode { |
30 | 36 |
31 @Specialization | 37 @Specialization |
32 public String defineFunction(String code) { | 38 public String defineFunction(String code) { |
33 Source source = getContext().getSourceManager().get("dynamic", code); | 39 Source source = getContext().getSourceManager().get("[defineFunction]", code); |
40 /* The same parsing code as for parsing the initial source. */ | |
34 Parser.parseSL(getContext(), source); | 41 Parser.parseSL(getContext(), source); |
35 return code; | 42 return code; |
36 } | 43 } |
37 } | 44 } |