Skip to main content
summaryrefslogtreecommitdiffstats
blob: 9ef69bf0a8fd311f61b1c6bcf06531092186998d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
Copyright (c) 2008 Arno Haase.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html

Contributors:
    Arno Haase - initial API and implementation
 */
package org.eclipse.xtend.backend.common;

import java.util.Collection;
import java.util.List;


/**
 * A FunctionDefContext is roughly the backend representation of a compilation unit - it stands for all
 *  functions that are visible from a given point in the code, and every function knows the FunctionDefContext
 *  that is valid within its body.
 *  
 * @author Arno Haase (http://www.haase-consulting.com)
 */
public interface FunctionDefContext {
    Object invoke (ExecutionContext ctx, String functionName, List<? extends Object> params);
    
    /**
     * for reflection. This method returns all functions, both those separately registered and those "built into" the
     *  type.
     */
    Collection<NamedFunction> getByFirstParameterType (BackendType firstParameterType); 
    
    /**
     * for reflection. This method returns all functions, both those built-into the types and those
     *  registered separately.
     */
    Function getMatch (ExecutionContext ctx, String name, List<BackendType> params);
    
    /**
     * for dynamic matching, e.g. to determine if a function should be called on a collection itself or
     *  on all of its members. This method matches against all functions, both those built into the
     *  types and those registered separately.
     */
    boolean hasMatch (ExecutionContext ctx, String functionName, List<? extends Object> params);
    
    Collection<NamedFunction> getPublicFunctions ();
}

Back to the top