All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hisrc.jsonix.compilation.ModulesCompiler Maven / Gradle / Ivy

There is a newer version: 2.3.9
Show newest version
package org.hisrc.jsonix.compilation;

import org.apache.commons.lang3.Validate;
import org.hisrc.jscm.codemodel.JSCodeModel;
import org.hisrc.jscm.codemodel.JSProgram;
import org.hisrc.jscm.codemodel.impl.CodeModelImpl;
import org.hisrc.jsonix.definition.Module;
import org.hisrc.jsonix.definition.Modules;
import org.hisrc.jsonix.definition.Output;

public class ModulesCompiler {

	private final Modules modules;

	public ModulesCompiler(Modules modules) {
		Validate.notNull(modules);
		this.modules = modules;
	}

	public void compile(ProgramWriter programWriter) {
		final JSCodeModel codeModel = new CodeModelImpl();

		for (Module module : this.modules.getModules()) {
			if (!module.isEmpty()) {
				for (Output output : module.getOutputs()) {
					final ModuleCompiler moduleCompiler = new ModuleCompiler(
							codeModel, modules, module, output);

					final JSProgram program = moduleCompiler.compile();
					programWriter.writeProgram(module, program, output);
				}
			}
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy