Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/WriteLocalNode.java @ 7503:31da1716950f
Updated truffle-sl for the changed operation code generation.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Fri, 18 Jan 2013 13:29:14 +0100 |
parents | |
children | 5e3d1a68664e |
comparison
equal
deleted
inserted
replaced
7502:6343a09b2ec1 | 7503:31da1716950f |
---|---|
1 /* | |
2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
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 | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 package com.oracle.truffle.sl.nodes; | |
24 | |
25 import java.math.*; | |
26 | |
27 import com.oracle.truffle.api.codegen.*; | |
28 import com.oracle.truffle.api.frame.*; | |
29 | |
30 public abstract class WriteLocalNode extends FrameSlotNode { | |
31 | |
32 @Child protected TypedNode rightNode; | |
33 | |
34 public WriteLocalNode(FrameSlot slot, TypedNode right) { | |
35 super(slot); | |
36 this.rightNode = adoptChild(right); | |
37 } | |
38 | |
39 public WriteLocalNode(WriteLocalNode node) { | |
40 this(node.slot, node.rightNode); | |
41 } | |
42 | |
43 @Specialization | |
44 public int doInteger(VirtualFrame frame, int right) { | |
45 frame.setInt(slot, right); | |
46 return right; | |
47 } | |
48 | |
49 @Specialization | |
50 public BigInteger doBigInteger(VirtualFrame frame, BigInteger right) { | |
51 frame.setObject(slot, right); | |
52 return right; | |
53 } | |
54 | |
55 @Specialization | |
56 public boolean doBoolean(VirtualFrame frame, boolean right) { | |
57 frame.setBoolean(slot, right); | |
58 return right; | |
59 } | |
60 | |
61 @Specialization | |
62 public String doString(VirtualFrame frame, String right) { | |
63 frame.setObject(slot, right); | |
64 return right; | |
65 } | |
66 | |
67 @Generic | |
68 public Object doGeneric(VirtualFrame frame, Object right) { | |
69 frame.setObject(slot, right); | |
70 return right; | |
71 } | |
72 | |
73 @SpecializationListener | |
74 protected void onSpecialize(VirtualFrame frame, Object value) { | |
75 slot.setType(value.getClass()); | |
76 frame.updateToLatestVersion(); | |
77 } | |
78 | |
79 @Override | |
80 protected FrameSlotNode specialize(Class< ? > clazz) { | |
81 return WriteLocalNodeFactory.createSpecialized(this, clazz); | |
82 } | |
83 | |
84 } |