Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLFunctionBodyNode.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. |
22 */ | 22 */ |
23 package com.oracle.truffle.sl.nodes.controlflow; | 23 package com.oracle.truffle.sl.nodes.controlflow; |
24 | 24 |
25 import com.oracle.truffle.api.frame.*; | 25 import com.oracle.truffle.api.frame.*; |
26 import com.oracle.truffle.api.nodes.*; | 26 import com.oracle.truffle.api.nodes.*; |
27 import com.oracle.truffle.api.utilities.*; | |
27 import com.oracle.truffle.sl.nodes.*; | 28 import com.oracle.truffle.sl.nodes.*; |
28 import com.oracle.truffle.sl.runtime.*; | 29 import com.oracle.truffle.sl.runtime.*; |
29 | 30 |
31 @NodeInfo(shortName = "body") | |
30 public class SLFunctionBodyNode extends SLExpressionNode { | 32 public class SLFunctionBodyNode extends SLExpressionNode { |
31 | 33 |
32 @Child private SLStatementNode body; | 34 @Child private SLStatementNode bodyNode; |
33 | 35 |
34 private FrameDescriptor frameDescriptor; | 36 private final BranchProfile exceptionTaken = new BranchProfile(); |
37 private final BranchProfile nullTaken = new BranchProfile(); | |
35 | 38 |
36 public SLFunctionBodyNode(FrameDescriptor frameDescriptor, SLStatementNode body) { | 39 public SLFunctionBodyNode(SLStatementNode bodyNode) { |
37 this.frameDescriptor = frameDescriptor; | 40 this.bodyNode = adoptChild(bodyNode); |
38 this.body = adoptChild(body); | |
39 } | 41 } |
40 | 42 |
41 @Override | 43 @Override |
42 public Object executeGeneric(VirtualFrame frame) { | 44 public Object executeGeneric(VirtualFrame frame) { |
43 try { | 45 try { |
44 body.executeVoid(frame); | 46 bodyNode.executeVoid(frame); |
45 } catch (SLReturnException ex) { | 47 } catch (SLReturnException ex) { |
48 exceptionTaken.enter(); | |
46 return ex.getResult(); | 49 return ex.getResult(); |
47 } | 50 } |
48 return SLNull.INSTANCE; | 51 nullTaken.enter(); |
49 } | 52 return SLNull.SINGLETON; |
50 | |
51 @Override | |
52 public Node copy() { | |
53 SLFunctionBodyNode copy = (SLFunctionBodyNode) super.copy(); | |
54 copy.frameDescriptor = frameDescriptor.shallowCopy(); | |
55 return copy; | |
56 } | |
57 | |
58 public FrameDescriptor getFrameDescriptor() { | |
59 return frameDescriptor; | |
60 } | 53 } |
61 } | 54 } |