comparison graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLBuiltinNode.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 64c77f0577bb
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.
24 24
25 import com.oracle.truffle.api.dsl.*; 25 import com.oracle.truffle.api.dsl.*;
26 import com.oracle.truffle.sl.nodes.*; 26 import com.oracle.truffle.sl.nodes.*;
27 import com.oracle.truffle.sl.runtime.*; 27 import com.oracle.truffle.sl.runtime.*;
28 28
29 /**
30 * Base class for all builtin functions. It contains the Truffle DSL annotation {@link NodeChild}
31 * that defines the function arguments.<br>
32 * Builtin functions need access to the {@link SLContext}. Instead of defining a Java field manually
33 * and setting it in a constructor, we use the Truffle DSL annotation {@link NodeField} that
34 * generates the field and constructor automatically.
35 * <p>
36 * The builitin functions are registered in {@link SLContext#installBuiltins}. Every builtin node
37 * subclass is instantiated there, wrapped into a function, and added to the
38 * {@link SLFunctionRegistry}. This ensures that builtin functions can be called like user-defined
39 * functions; there is no special function lookup or call node for builtin functions.
40 */
41 @NodeChild(value = "arguments", type = SLExpressionNode[].class)
29 @NodeField(name = "context", type = SLContext.class) 42 @NodeField(name = "context", type = SLContext.class)
30 @NodeChild(value = "arguments", type = SLExpressionNode[].class)
31 public abstract class SLBuiltinNode extends SLExpressionNode { 43 public abstract class SLBuiltinNode extends SLExpressionNode {
32 44
45 /**
46 * Accessor for the {@link SLContext}. The implementation of this method is generated
47 * automatically based on the {@link NodeField} annotation on the class.
48 */
33 public abstract SLContext getContext(); 49 public abstract SLContext getContext();
34
35 public abstract SLExpressionNode[] getArguments();
36
37 } 50 }