Mercurial > hg > graal-compiler
view graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/local/SLReadLocalVariableNode.java @ 13943:89ac75425681
SL: small cleanups
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Wed, 12 Feb 2014 10:30:42 -0800 |
parents | afd6fa5e8229 |
children | abe7128ca473 |
line wrap: on
line source
/* * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.oracle.truffle.sl.nodes.local; import com.oracle.truffle.api.dsl.*; import com.oracle.truffle.api.frame.*; import com.oracle.truffle.sl.nodes.*; /** * Node to read a local variable from a function's {@link VirtualFrame frame}. The Truffle frame API * allows to store primitive values of all Java primitive types, and Object values. This means that * all SL types that are objects are handled by the {@link #readObject} method. When a local * variable changes its type, the frame access method throws an {@link FrameSlotTypeException}, * which causes not rewriting. The rewriting code is generated by the Truffle DSL. */ @NodeField(name = "slot", type = FrameSlot.class) public abstract class SLReadLocalVariableNode extends SLExpressionNode { /** * Returns the descriptor of the accessed local variable. The implementation of this method is * created by the Truffle DSL based on the {@link NodeField} annotation on the class. */ protected abstract FrameSlot getSlot(); @Specialization(rewriteOn = FrameSlotTypeException.class) protected long readLong(VirtualFrame frame) throws FrameSlotTypeException { return frame.getLong(getSlot()); } @Specialization(rewriteOn = FrameSlotTypeException.class) protected boolean readBoolean(VirtualFrame frame) throws FrameSlotTypeException { return frame.getBoolean(getSlot()); } @Specialization(order = 1, rewriteOn = FrameSlotTypeException.class) protected Object readObject(VirtualFrame frame) throws FrameSlotTypeException { return frame.getObject(getSlot()); } /** * This is the generic case that always succeeds. Since we already have another specialization * with the same signature above, we need to order them explicitly with the order attribute. */ @Specialization(order = 2) protected Object read(VirtualFrame frame) { return frame.getValue(getSlot()); } }