/* * 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 imports = new HashMap<>(); protected static HashMap loaded = new HashMap<>(); protected static HashMap 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 imports() { return imports; } }