root/trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/values/Constructor.java

Revision 3998, 26.7 KB (checked in by EricAllen, 4 months ago)

Cleaned up some code formatting.

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.interpreter.evaluator.values;
19
20import com.sun.fortress.compiler.WellKnownNames;
21import static com.sun.fortress.exceptions.InterpreterBug.bug;
22import static com.sun.fortress.exceptions.ProgramError.error;
23import static com.sun.fortress.exceptions.ProgramError.errorMsg;
24import com.sun.fortress.interpreter.env.BetterEnv;
25import com.sun.fortress.interpreter.evaluator.BuildEnvironments;
26import com.sun.fortress.interpreter.evaluator.Environment;
27import com.sun.fortress.interpreter.evaluator.EvalType;
28import com.sun.fortress.interpreter.evaluator.EvalVarsEnvironment;
29import com.sun.fortress.interpreter.evaluator.types.*;
30import com.sun.fortress.interpreter.glue.NativeApp;
31import com.sun.fortress.nodes.*;
32import com.sun.fortress.nodes_util.NodeFactory;
33import com.sun.fortress.nodes_util.NodeUtil;
34import com.sun.fortress.useful.*;
35import edu.rice.cs.plt.tuple.Option;
36
37import java.util.*;
38
39public class Constructor extends NonPrimitive {
40
41    // TODO need to be more organized about all the names
42    // that get rewritten.
43    //   public HashSet<String> parameterNames = new HashSet<String>();
44
45    private HasAt at;
46    protected FTypeObject selfType;
47
48    @Override
49    public HasAt getAt() {
50        return at;
51    }
52
53    public String stringName() {
54        return "Constructor for " + selfType;
55    }
56
57    public boolean seqv(FValue v) {
58        return false;
59    }
60
61    boolean finished = false;
62
63    IdOrOpOrAnonymousName cfn;
64    List<Decl> defs;
65    Option<List<Param>> params;
66
67    MultiMap<FTraitOrObject, SingleFcn> traitsToMethodSets = new MultiMap<FTraitOrObject, SingleFcn>();
68
69    MultiMap<String, MethodClosure> namesToSignatureSets = new MultiMap<String, MethodClosure>();
70
71    MultiMap<FTraitOrObject, String> traitsToNamesReferenced = new MultiMap<FTraitOrObject, String>();
72
73    // sets of strings (can't be explicit due to erasure)
74    Set<?>[] traitNameReferenceArray;
75
76    FTraitOrObject[] traitArray;
77    MethodClosure[] methodsArray;
78    MethodClosure[] closuresArray;
79    int[] traitIndexForMethod; // 0 = object
80    int[] overloadMembership;  // 0 = no overload
81    int overloadCount = 0; // first overload is indexed at 1.
82
83    Environment methodsEnv;
84
85    public Constructor(Environment env, FTypeObject selfType, ObjectConstructor def) {
86        this(env,
87             selfType,
88             (HasAt) def,
89             NodeFactory.makeConstructorFnName(def),
90             NodeUtil.getDecls(def),
91             NodeUtil.getParams(def));
92        //       addParamsToCollection(def, parameterNames);
93    }
94
95    public Constructor(Environment env, FTypeObject selfType, ObjectConstructor def, Option<List<Param>> params) {
96        this(env, selfType, (HasAt) def, NodeFactory.makeConstructorFnName(def), NodeUtil.getDecls(def), params);
97        //       addParamsToCollection(def, parameterNames);
98    }
99
100
101    /**
102     * @param def
103     */
104    //    static public void addParamsToCollection(
105    //          HasParams def, Collection<String> parameterNames) {
106    //        addParamsToCollection(def.getParams(), parameterNames);
107    //
108    //    }
109    //    static public void addParamsToCollection(
110    //          Option<List<Param>> opt_params, Collection<String> parameterNames) {
111    //        if (opt_params.isSome()) {
112    //            addParamsToCollection(opt_params.unwrap(), parameterNames);
113    //        }
114    //    }
115    //    static public void addParamsToCollection(
116    //          List<Param> params, Collection<String> parameterNames) {
117    //        for (Param p : params) {
118    //                if (!NodeUtil.isTransient(p))
119    //                    parameterNames.add(p.getName().getId().getText());
120    //       }
121    //    }
122    //    static public void removeParamsFromCollection(
123    //          ObjectDecl def, Collection<String> parameterNames) {
124    //        removeParamsFromCollection(def.getParams(), parameterNames);
125    //
126    //    }
127    //    static public void removeParamsFromCollection(
128    //          Option<List<Param>> opt_params, Collection<String> parameterNames) {
129    //        if (opt_params.isSome()) {
130    //            removeParamsFromCollection(opt_params.unwrap(), parameterNames);
131    //        }
132    //    }
133    //    static public void removeParamsFromCollection(
134    //          List<Param> params,Collection<String> parameterNames) {
135    //        for (Param p : params) {
136    //            if (!NodeUtil.isTransient(p))
137    //                parameterNames.remove(p.getName().getId().getText());
138    //   }
139    //}
140
141    // TODO need to copy the field names
142    public Constructor(Environment env,
143                       FTypeObject selfType,
144                       HasAt def,
145                       IdOrOpOrAnonymousName name,
146                       List<Decl> defs,
147                       Option<List<Param>> params) {
148        super(env); // TODO verify that this is the proper env.
149        this.selfType = selfType;
150        this.at = def;
151        this.cfn = name;
152        this.defs = defs;
153        this.params = params;
154    }
155
156    /**
157     * Figure out the methods inherited from the super-traits.
158     */
159    public void finishInitializing() {
160        // Next build a bogus environment to help us figure out
161        // overloading, shadowing, etc.  First puts win.
162        if (params.isSome()) {
163            List<Parameter> fparams = EvalType.paramsToParameters(getWithin(), params.unwrap());
164            setParams(fparams);
165        } else {
166            setParams(Collections.<Parameter>emptyList());
167        }
168
169        Environment bte = selfType.getMethodExecutionEnv(); // new BetterEnv(getWithin(), getAt());
170        selfType.getMembers(); // has initializing side-effect.
171        finishInitializing(bte);
172    }
173
174    private void finishInitializing(Environment bte) {
175
176        // HashSet<String> fields = new HashSet<String>();
177        // HashMap<String, String> com.sun.fortress.interpreter.rewrite =
178        //  new HashMap<String, String>();
179
180        //  BuildObjectEnvironment bt =
181        //      new BuildObjectEnvironment(bte, selfType.getWithin(), selfType, fields);
182
183        // Inject methods into this environment
184        // This should create new MethodClosures
185        // visitDefs(bt);
186
187        GHashMap<SingleFcn, FTraitOrObject> signaturesToTraitsContainingMethods =
188                new GHashMap<SingleFcn, FTraitOrObject>(SingleFcn.signatureEquivalence);
189
190        MultiMap<String, GenericMethod> generics = new MultiMap<String, GenericMethod>();
191
192        // TODO deal with ORDER and ambiguity.  TransitiveExtends returns
193        // a topological sort, which is close, but not perfect.
194        //
195        List<FType> extendedTraits = selfType.getProperTransitiveExtends();
196
197        // First process all the generics, so we can form generic functions
198        // TODO this is approximate; add generics in reversed order.
199        for (FType t : new ReversedList<FType>(extendedTraits)) {
200            FTypeTrait ft = (FTypeTrait) t;
201            BetterEnv e = ft.getMembers(); // This is correct, it enumerates the methods.
202            accumulateGenericMethods(generics, ft, e);
203        }
204
205        // This also enumerates the methods.
206        accumulateGenericMethods(generics, selfType, bte);
207
208        // For each set of generic methods (with same name and signature)
209        // create a list of symbolic values to substitute for the type
210        // parameters so that the methods may be pseudo-instantiated
211        // and plugged into the trait/object and overloading definition
212        // machinery.
213        Map<String, List<FType>> genericArgs = new HashMap<String, List<FType>>();
214        for (String s : generics.keySet()) {
215            // All the methods are similarly parameterized, so the
216            // first generic in the set (generics is a multimap)
217            // is as good as any other for this purpose.
218            GenericMethod g = generics.get(s).iterator().next();
219
220            Applicable ap = g.getDef();
221            List<FType> instantiationTypes = SingleFcn.createSymbolicInstantiation(bte, ap, getAt());
222            genericArgs.put(s, instantiationTypes);
223        }
224
225        final Set<String> overridden = new HashSet<String>();
226        //        final NodeVisitor_void overrideFinder = new NodeAbstractVisitor_void() {
227        //
228        //            FnDecl current;
229        //
230        //            public void forModifierOverride(ModifierOverride mo) {
231        //                overridden.add(current.stringName());
232        //                System.err.println("Override of " + current.stringName());
233        //            }
234        //
235        //            @Override
236        //            public void forFnDecl(FnDecl that) {
237        //                current = that;
238        //                for (Modifier m : that.getMods()) {
239        //                    m.accept(this);
240        //                }
241        //            }
242        //
243        //        };
244
245
246        //  Find all the methods in selfType, using the containing environment
247        // to give them meaning.
248        accumulateEnvMethods(null,
249                             overridden,
250                             signaturesToTraitsContainingMethods,
251                             generics,
252                             genericArgs,
253                             selfType,
254                             bte);
255
256        //        for (AbsDeclOrDecl d : defs ) {
257        //            d.accept(overrideFinder);
258        //        }
259        // Accumulate all the trait methods, evaluated against their
260        // trait environments.
261        // TODO The signature map uses EQUALITY, and that might be wrong,
262        // if the object can implement with a more general signature.
263        for (FType t : extendedTraits) {
264            FTypeTrait ft = (FTypeTrait) t;
265            BetterEnv e = ft.getMembers();
266            accumulateEnvMethods(overridden, null, signaturesToTraitsContainingMethods, generics, genericArgs, ft, e);
267        }
268
269        // Check that all methods are defined, also check to see
270        // if the object defines any of them.
271        boolean objectDefinesAny = false;
272        for (Map.Entry<SingleFcn, FTraitOrObject> ent : (Set<Map.Entry<SingleFcn, FTraitOrObject>>) signaturesToTraitsContainingMethods
273                .entrySet()) {
274            SingleFcn sf = ent.getKey();
275            FTraitOrObject too = ent.getValue();
276
277            if (too instanceof FTypeObject) objectDefinesAny = true;
278            checkForDef(sf, too);
279        }
280
281        // Plan to iterate over traits at instantiation, and form closures
282        // for methods defined there based on the trait environment and
283        // a filter of the object environment into that trait.
284        // Duplication of symbols into the per-method environements is
285        // ok because the symbols duplicated are immutably bound (are
286        // methods).
287        traitsToMethodSets.addInverse(signaturesToTraitsContainingMethods);
288
289        // Count traits and create an array of trait types, so that
290        // the constructor can build things without thinking.
291        // int traitCount = traitsToMethodSets.size() + (objectDefinesAny ? 0 : 1);
292        int traitCount = traitsToNamesReferenced.size() + (objectDefinesAny ? 0 : 1);
293
294        HashMap<FTraitOrObject, Integer> traitToIndex = new HashMap<FTraitOrObject, Integer>();
295
296        traitArray = new FTraitOrObject[traitCount];
297        traitNameReferenceArray = new Set<?>[traitCount];
298
299        traitArray[0] = selfType;
300        traitToIndex.put(selfType, Integer.valueOf(0));
301        int trait_i = 1;
302        for (FTraitOrObject too : traitsToNamesReferenced.keySet()) { // was traitsToMethodSets.keySet()
303            if (too != selfType) {
304                traitArray[trait_i] = too;
305                traitToIndex.put(too, Integer.valueOf(trait_i));
306                traitNameReferenceArray[trait_i] = traitsToNamesReferenced.get(too);
307                trait_i++;
308            }
309        }
310
311        /* At construction time,
312          1) create an array of environments (one per trait)
313          2) iterate over the methods, and assign each of them the appropriate
314             environment to form closures, setting the results aside.
315          3) then form any overloads necessary
316          4) then iterate over the traits, binding names to method values.
317         */
318        int signatureCount = signaturesToTraitsContainingMethods.size() + 1;
319        methodsArray = new MethodClosure[signatureCount];
320        closuresArray = new MethodClosure[signatureCount];
321        HashMap<MethodClosure, Integer> methodsIndex = new HashMap<MethodClosure, Integer>();
322
323        traitIndexForMethod = new int[signatureCount];
324        overloadMembership = new int[signatureCount];
325
326        // Iterate over the signatures to create a map from names to sets
327        // of functions, for use by overloading.  Also create indexing
328        // for methods, and initialize arrays from method (signature)
329        // index to partially defined method (carries base environment),
330        // and trait index.
331        int sig_i = 1;
332
333        for (Map.Entry<SingleFcn, FTraitOrObject> ent : (Set<Map.Entry<SingleFcn, FTraitOrObject>>) signaturesToTraitsContainingMethods
334                .entrySet()) {
335
336            SingleFcn sf = ent.getKey();
337            /*
338             * This is a moderate hack.  Because the methods for any
339             * particular trait must obey the overloading rules individually,
340             * overloaded things also get bound "as methods".  However, the
341             * the rules for binding methods to actual objects behave as-if the
342             * overloaded method is dismantled and separately overridden.  To
343             * take advantage of the SingleFcn-specific machinery in
344             * OverloadedFunctions, the type signature of the "early" data
345             * structures in this process allow SingleFcn's to appear, but
346             * now (right here) they had better be gone.
347             *
348             */
349            if (!(sf instanceof MethodClosure)) {
350                bug(errorMsg("Internal error, non-method ", sf));
351            }
352            MethodClosure mc = (MethodClosure) sf;
353            FTraitOrObject too = ent.getValue();
354
355            Set<MethodClosure> s = namesToSignatureSets.putItem(sf.asMethodName(), mc);
356            if (s.size() == 2) overloadCount++;
357            methodsArray[sig_i] = mc;
358            methodsIndex.put(mc, Integer.valueOf(sig_i));
359            traitIndexForMethod[sig_i] = traitToIndex.get(too).intValue();
360
361            sig_i++;
362        }
363
364        // If the same method name is defined with more than one signature,
365        // then it is overloaded.  If a method is part of an overload,
366        // record its membership in the overloadIndex array.
367        int overloadIndex = 1;
368        for (Map.Entry<String, Set<MethodClosure>> ent : namesToSignatureSets.entrySet()) {
369            Set<MethodClosure> s = ent.getValue();
370            if (s.size() > 1) {
371                // This will pop an error if the set of defined functions is
372                // a bad overload.  Discard the value.
373                new OverloadedMethod(ent.getKey(), s, getWithin());
374
375                for (MethodClosure m : s) {
376                    overloadMembership[methodsIndex.get(m).intValue()] = overloadIndex;
377                }
378                overloadIndex++;
379            }
380        }
381
382        // Experimental early computation of this information.
383        for (int i = 1; i < methodsArray.length; i++) {
384            // Closure cl = methodsArray[i].completeClosure(trait_envs[traitIndexForMethod[i]]);
385            MethodClosure cl = methodsArray[i];
386            // .completeClosure(traitArray[traitIndexForMethod[i]].getEnv());
387            closuresArray[i] = cl;
388        }
389
390
391        methodsEnv = within.extend();
392        addMethodsToEnv(methodsEnv);
393        methodsEnv.bless();
394
395        finished = true;
396    }
397
398    /**
399     * Checks for definition of sf from supertrait too, fails if absent.
400     *
401     * @param sf
402     * @param too
403     * @return
404     */
405    private void checkForDef(SingleFcn sf, FTraitOrObject too) {
406        if (too instanceof FTypeObject) return;
407        if (sf instanceof MethodClosure) {
408            MethodClosure pdm = (MethodClosure) sf;
409            Applicable a = pdm.getDef();
410            if (a instanceof FnDecl || a instanceof NativeApp) return;
411            if (a.at().equals(sf.at())) {
412                error(cfn, errorMsg("Object ",
413                                    cfn.stringName(),
414                                    " does not define an abstract method declared in type ",
415                                    too.getName(),
416                                    ":\n",
417                                    sf.getString()));
418            } else {
419                error(cfn, errorMsg("Object ",
420                                    cfn.stringName(),
421                                    " does not define an abstract method declared in type ",
422                                    too.getName(),
423                                    ":\n",
424                                    sf.getString(),
425                                    "\n Instead found: \n",
426                                    a.at(),
427                                    ": ",
428                                    a));
429            }
430        }
431        bug(errorMsg("Unexpected symbolic method binding ", sf));
432        return;
433    }
434
435    /**
436     * Iterates over the youngest (innermost) scope of e to determine
437     * what things are defined there, and record the relationship
438     * from signature to containing trait, and from trait to names
439     * referenced.
440     *
441     * @param signaturesToTraitsContainingMethods
442     *
443     * @param genericArgs
444     * @param ft
445     * @param e
446     */
447    private void accumulateEnvMethods(Set<String> alreadyOverridden,
448                                      Set<String> newOverrides,
449                                      GHashMap<SingleFcn, FTraitOrObject> signaturesToTraitsContainingMethods,
450                                      MultiMap<String, GenericMethod> generics,
451                                      Map<String, List<FType>> genericArgs,
452                                      FTraitOrObject ft,
453                                      Environment e) {
454        for (String s : e.youngestFrame()) {
455            FValue fv = e.getLeafValue(s);
456            if (alreadyOverridden == null || !alreadyOverridden.contains(s)) {
457
458                // This has got to be wrong...
459                if (fv instanceof OverloadedFunction) {
460                    // Treat the overloaded function as a bag of separate
461                    // definitions.
462                    List<Overload> overloads = ((OverloadedFunction) fv).getOverloads();
463                    for (Overload ov : overloads) {
464                        SingleFcn sfcn = ov.getFn();
465                        if (newOverrides != null && sfcn.isOverride()) newOverrides.add(s);
466                        // extract below as method, call it here.
467                        signaturesToTraitsContainingMethods.putIfAbsent(sfcn, ft);
468                    }
469                } else if (fv instanceof GenericMethod) {
470                    GenericMethod gfv = (GenericMethod) fv;
471                    if (newOverrides != null && gfv.isOverride()) newOverrides.add(s);
472
473                    MethodClosure sfcn = gfv.make(genericArgs.get(s), gfv.getAt());
474
475                    signaturesToTraitsContainingMethods.putIfAbsent(sfcn, ft);
476
477                } else if (fv instanceof MethodClosure) {
478                    MethodClosure mc = (MethodClosure) fv;
479                    signaturesToTraitsContainingMethods.putIfAbsent(mc, ft);
480                    if (newOverrides != null && mc.isOverride()) newOverrides.add(s);
481                } else {
482                    bug(errorMsg("Don't handle ", fv, " yet"));
483                }
484            }
485            // Record the name to ensure that it is defined somewhere.
486            // The name of the overloaded function goes wrong, if it is a functional method.
487            traitsToNamesReferenced.putItem(ft, s);// ((Fcn)fv).asMethodName());
488        }
489    }
490
491    private void accumulateGenericMethods(MultiMap<String, GenericMethod> generics, FTraitOrObject ft, Environment e) {
492        for (String s : e.youngestFrame()) {
493            FValue fv = e.getLeafValue(s);
494            if (fv instanceof GenericMethod) {
495                // TODO This is VERY approximate
496                generics.putItem(s, (GenericMethod) fv);
497            } else {
498                // do nothing
499            }
500        }
501    }
502
503    public String getString() {
504        return cfn.stringName();
505    }
506
507    public String toString() {
508        String name = getFnName().toString();
509        List<FType> l = null;
510        try {
511            l = getDomain();
512        }
513        catch (Throwable th) {
514            ; /* do nothing */
515        }
516        return (s(selfType)) + (l == null ? "(DOMAIN_ERROR null)" : Useful.listInParens(l)) + cfn.at();
517    }
518
519    public IdOrOpOrAnonymousName getFnName() {
520        return cfn;
521    }
522
523    @Override
524    public FValue applyInnerPossiblyGeneric(List<FValue> args) {
525        return applyConstructor(args);
526    }
527
528    /**
529     * Apply a constructor.  This method allows separate specification
530     * of the lexical environment; this is done to simplify implementation
531     * of object expressions.
532     */
533    public FValue applyConstructor(List<FValue> args) {
534        // Problem -- we need to detach self-env from other env.
535        if (methodsEnv == null) bug("Null methods env for " + this);
536
537        Environment self_env = buildEnvFromEnvAndParams(methodsEnv, args);
538
539        Environment lex_env = getWithin();
540        FObject theObject = makeAnObject(lex_env, self_env);
541
542        self_env.putValueRaw(WellKnownNames.secretSelfName, theObject);
543
544        // TODO this is WRONG.  The vars need to be inserted into self, but
545        // get evaluated against the larger (lexical) environment.  Arrrrrrrggggggh.
546
547        self_env.bless(); // HACK we add to this later.
548        // This should go wrong if one of the vars has closure value
549        // or objectExpr value.
550
551        if (defs.size() > 0) {
552            // Minor optimization, avoid this if no defs to eval.
553            EvalVarsEnvironment eve = new EvalVarsEnvironment(lex_env.extend(self_env), self_env);
554            visitDefs(eve); // HACK here's where we add to self_env.
555        }
556
557        return stripTransient(theObject);
558    }
559
560    private FObject stripTransient(FObject original) {
561        Environment selfEnv = original.getSelfEnv();
562        return makeAnObject(original.getLexicalEnv(), selfEnv);
563    }
564
565    public FValue applyOEConstructor(HasAt loc, Environment lex_env) {
566        // Problem -- we need to detach self-env from other env.
567        Environment self_env = methodsEnv.extendAt(loc);
568
569        // TODO This is a problem -- the level is not determined
570        FValue surroundSelf = lex_env.getLeafValueNull(WellKnownNames.secretSelfName);
571        if (surroundSelf != null) self_env.putValueRaw(WellKnownNames.secretParentName, surroundSelf);
572
573        FObject theObject = makeAnObject(lex_env, self_env);
574
575        self_env.putValueRaw(WellKnownNames.secretSelfName, theObject);
576
577        // TODO this is WRONG.  The vars need to be inserted into self, but
578        // get evaluated against the larger (lexical) environment.  Arrrrrrrggggggh.
579
580        self_env.bless(); // HACK we add to this later.
581        // This should go wrong if one of the vars has closure value
582        // or objectExpr value.
583
584        if (defs.size() > 0) {
585            // Minor optimization, avoid this if no defs to eval.
586            EvalVarsEnvironment eve = new EvalVarsEnvironment(lex_env.extend(self_env), self_env);
587            visitDefs(eve); // HACK here's where we add to self_env.
588        }
589
590        return theObject;
591    }
592
593    private void addMethodsToEnv(Environment self_env) {
594        OverloadedMethod[] overloads = new OverloadedMethod[overloadCount + 1];
595
596        // First initialize an array of environments.
597        //        for (int i = 1; i < trait_envs.length; i++) {
598        //            trait_envs[i] = new ImmutableSpineEnv(traitArray[i].getEnv(), loc);
599        //        }
600
601        // For each method, attach the appropriate environment from the array
602        for (int i = 1; i < methodsArray.length; i++) {
603            // Closure cl = methodsArray[i].completeClosure(trait_envs[traitIndexForMethod[i]]);
604            FunctionClosure cl =
605                    closuresArray[i]; // methodsArray[i].completeClosure(traitArray[traitIndexForMethod[i]].getEnv());
606            int j = overloadMembership[i];
607            // Check to see if the new closure should be bound now or
608            // placed in an overload.
609            if (j != 0) {
610                OverloadedMethod of = overloads[j];
611                if (of == null) {
612                    // Overload in self_env
613                    of = new OverloadedMethod(cl.asMethodName(), self_env);
614                    self_env.putValue(cl.asMethodName(), of);
615                    overloads[j] = of;
616                }
617                of.addOverload(cl);
618            } else {
619                // Assertion -- by construction, illegal shadowing won't occur,
620                // because it is processed/detected in the overloading code.
621                self_env.putValueRaw(cl.asMethodName(), cl);
622            }
623        }
624
625        // By construction, all the overloads are already ok.
626        // Bless them to avoid the overhad of checking what we
627        // "know" to be true.
628        for (int i = 1; i < overloads.length; i++) {
629            overloads[i].bless();
630        }
631    }
632
633    protected FObject makeAnObject(Environment lex_env, Environment self_env) {
634        return new FOrdinaryObject(selfType, lex_env, self_env);
635    }
636
637    /**
638     * @param be
639     */
640    protected void visitDefs(BuildEnvironments be) {
641        be.doDefs1234(defs);
642        //        be.secondPass();
643        //
644        //        be.doDefs(defs);
645        //        be.getBindingEnv().bless();
646        //
647        //        be.thirdPass();
648        //        be.doDefs(defs);
649        //
650        //        be.fourthPass();
651        //        be.doDefs(defs);
652
653    }
654
655    @Override
656    protected void setValueType() {
657        // TODO Constructors aren't exposed, do they have a type?
658        // yes, they are exposed, and they do.
659        setFtype(FTypeArrow.make(getDomain(), selfType));
660    }
661
662    @Override
663    boolean getFinished() {
664        // TODO Auto-generated method stub
665        return finished;
666    }
667
668}
Note: See TracBrowser for help on using the browser.