Mercurial > hg > graal-compiler
diff graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLFunctionRegistry.java @ 13761:7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Fri, 24 Jan 2014 18:16:24 -0800 |
parents | 71991b7a0f14 |
children | b16ec83edc73 |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLFunctionRegistry.java Fri Jan 24 18:13:38 2014 -0800 +++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLFunctionRegistry.java Fri Jan 24 18:16:24 2014 -0800 @@ -28,17 +28,23 @@ public final class SLFunctionRegistry { - private Map<String, CallTarget> map = new HashMap<>(); + private final Map<String, SLFunction> functions = new HashMap<>(); - public void register(String name, CallTarget target) { - if (map.containsKey(name)) { - throw new IllegalArgumentException(String.format("Function with name '%s' already exists.", name)); + public SLFunction lookup(String name) { + SLFunction result = functions.get(name); + if (result == null) { + result = new SLFunction(name); + functions.put(name, result); } - map.put(name, target); + return result; } - public CallTarget lookup(String name) { - return map.get(name); + public void register(String name, RootCallTarget callTarget) { + SLFunction function = lookup(name); + function.setCallTarget(callTarget); } + public Collection<SLFunction> getFunctions() { + return functions.values(); + } }