123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package API;
- import compiler.IvannosysCompiler;
- import java.util.HashMap;
- /**
- *
- * @author Eugenio
- */
- public class Imports {
- protected static HashMap<String, String> imports = new HashMap<>();
- protected static HashMap<String, Boolean> loaded = new HashMap<>();
- protected static HashMap<String, Boolean> used = new HashMap<>();
- protected static IvannosysCompiler compiler;
- public static void _init(IvannosysCompiler compiler) {
- Imports.compiler = compiler;
- }
- public static void Add(String path) throws Exception {
- Imports.Add(path, "");
- }
- public static boolean Load(String alias) throws Exception {
- if (!imports.containsKey(alias)) {
- return false;
- }
- if (!loaded.containsKey(alias)) {
- compiler.LoadPackage(alias, imports.get(alias));
- loaded.put(alias, true);
- }
- return true;
- }
- public static void Add(String path, String alias) throws Exception {
- if (alias.equals("")) {
- String[] parts = path.split("/");
- alias = parts[parts.length - 1];
- }
- if (!imports.containsKey(alias)) {
- imports.put(alias, path);
- }
- Load(alias);
- }
- public static HashMap<String, String> imports() {
- return imports;
- }
- }
|