root/trunk/ProjectFortress/src/com/sun/fortress/compiler/index/FieldGetterMethod.java @ 3915

Revision 3915, 2.6 KB (checked in by jrhil47, 5 months ago)

[index] Changed all Functional indices to store a thunk to get the return types, since during type checking the return types might need to be lazily evaluated. Also changed Functional indices to yield an Option for return types.
[type checker] Started implementing extraction of bindings from nodes for type environments.

Line 
1/*******************************************************************************
2    Copyright 2009 Sun Microsystems, Inc.,
3    4150 Network Circle, Santa Clara, California 95054, U.S.A.
4    All rights reserved.
5
6    U.S. Government Rights - Commercial software.
7    Government users are subject to the Sun Microsystems, Inc. standard
8    license agreement and applicable provisions of the FAR and its supplements.
9
10    Use is subject to license terms.
11
12    This distribution may include materials developed by third parties.
13
14    Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
15    trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
16 ******************************************************************************/
17
18package com.sun.fortress.compiler.index;
19
20import java.util.Collections;
21import java.util.List;
22
23import com.sun.fortress.compiler.Types;
24import com.sun.fortress.nodes.ArrowType;
25import com.sun.fortress.nodes.BaseType;
26import com.sun.fortress.nodes.Expr;
27import com.sun.fortress.nodes.Binding;
28import com.sun.fortress.nodes.Id;
29import com.sun.fortress.nodes.NodeUpdateVisitor;
30import com.sun.fortress.nodes.Param;
31import com.sun.fortress.nodes.StaticArg;
32import com.sun.fortress.nodes.StaticParam;
33import com.sun.fortress.nodes.Type;
34import com.sun.fortress.nodes_util.NodeUtil;
35import com.sun.fortress.nodes_util.Span;
36import com.sun.fortress.useful.NI;
37
38import edu.rice.cs.plt.lambda.SimpleBox;
39import edu.rice.cs.plt.tuple.Option;
40
41public class FieldGetterMethod extends Method {
42
43    private final Binding _ast;
44    private final Id _declaringTrait;
45
46    public FieldGetterMethod(Binding ast, Id declaringTrait) {
47        _ast = ast;
48        _declaringTrait = declaringTrait;
49        putThunk(SimpleBox.make(_ast.getIdType()));
50    }
51
52    public Binding ast() { return _ast; }
53
54    @Override
55    public Span getSpan() { return NodeUtil.getSpan(_ast); }
56
57        @Override
58        public Option<Expr> body() {
59                return Option.none();
60        }
61
62        @Override
63        public List<Param> parameters() {
64                return Collections.emptyList();
65        }
66
67        @Override
68        public List<StaticParam> staticParameters() {
69                return Collections.emptyList();
70        }
71
72        @Override
73        public List<BaseType> thrownTypes() {
74                return Collections.emptyList();
75        }
76
77        @Override
78        public Functional instantiate(List<StaticParam> params, List<StaticArg> args) {
79                return this;
80        }
81
82        @Override
83        public Id getDeclaringTrait() {
84                return this._declaringTrait;
85        }
86
87        @Override
88        public Functional acceptNodeUpdateVisitor(NodeUpdateVisitor visitor) {
89                return new FieldGetterMethod((Binding)this._ast.accept(visitor), this._declaringTrait);
90        }
91
92
93}
Note: See TracBrowser for help on using the browser.