| /******************************************************************************* |
| * Copyright (c) 2004-2008 Andras Schmidt, Andras Balogh, Istvan Rath and Daniel Varro |
| * 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: |
| * Andras Schmidt, Andras Balogh, Istvan Rath - initial API and implementation |
| *******************************************************************************/ |
| |
| package org.eclipse.viatra2.natives; |
| |
| import java.util.HashMap; |
| |
| /** |
| * @author Andras Balogh |
| * |
| * |
| * |
| */ |
| public class NativeFunctionManager implements INativeFunctionManager { |
| |
| private HashMap<String, ASMNativeFunction> funs = new HashMap<String, ASMNativeFunction>(); |
| |
| public void addAllFunction(ASMNativeFunction[] a) { |
| for (ASMNativeFunction function : a) { |
| addFunction(function); |
| } |
| } |
| |
| public void addFunction(ASMNativeFunction a) { |
| funs.put(a.getName(), a); |
| } |
| |
| // Returns a native function for the given class name
|
| public ASMNativeFunction getNativeFunctionForName(String name) { |
| Object o = funs.get(name); |
| if ((o != null) && (o instanceof ASMNativeFunction)) { |
| return (ASMNativeFunction) o; |
| } |
| return null; |
| } |
| |
| public ASMNativeFunction[] getAllNativeFunctions() { |
| return funs.values().toArray(new ASMNativeFunction[0]); |
| } |
| |
| } |