Commit c20e6c77 authored by Lubomir Bulej's avatar Lubomir Bulej

ArgProcessor, ArgProcessorMethod: cleaned up formatting before subsequent merges.

parent 3b61d3d2
......@@ -6,30 +6,47 @@ import ch.usi.dag.disl.exception.ReflectionException;
import ch.usi.dag.disl.exception.StaticContextGenException;
import ch.usi.dag.disl.localvar.LocalVars;
/**
* Argument processor is a collection of argument processor methods. Each method
* is similar to a snippet and can be specialized for a particular method
* parameter or a type of method parameters.
*/
public class ArgProcessor {
private String name;
private List<ArgProcessorMethod> methods;
public ArgProcessor(String name, List<ArgProcessorMethod> methods) {
super();
this.name = name;
this.methods = methods;
}
public String getName() {
return name;
}
public List<ArgProcessorMethod> getMethods() {
return methods;
}
public void init(LocalVars allLVs) throws StaticContextGenException,
ReflectionException {
for(ArgProcessorMethod method : methods) {
method.init(allLVs);
}
}
/**
* Canonical name of the argument processor class.
*/
private final String __className;
private final List <ArgProcessorMethod> __methods;
//
public ArgProcessor (final String name, final List <ArgProcessorMethod> methods) {
__className = name;
__methods = methods;
}
/**
* @return canonical name of the argument processor class.
*/
public String getName () {
return __className;
}
public List <ArgProcessorMethod> getMethods () {
return __methods;
}
public void init (final LocalVars localVars)
throws StaticContextGenException, ReflectionException {
for (final ArgProcessorMethod method : __methods) {
method.init (localVars);
}
}
}
package ch.usi.dag.disl.processor;
import java.lang.reflect.Method;
import java.util.EnumSet;
import java.util.Set;
import ch.usi.dag.disl.annotation.ArgumentProcessor;
import ch.usi.dag.disl.exception.ReflectionException;
import ch.usi.dag.disl.exception.StaticContextGenException;
import ch.usi.dag.disl.localvar.LocalVars;
import ch.usi.dag.disl.snippet.Snippet;
/**
* Represents an {@link ArgumentProcessor} method, which is analogous to a
* {@link Snippet} in a DiSL class.
*/
public class ArgProcessorMethod {
private String originClassName;
private String originMethodName;
private EnumSet<ArgProcessorKind> types;
private Method guard;
private ProcUnprocessedCode unprocessedCode;
private ProcCode code;
public ArgProcessorMethod(String originClassName, String originMethodName,
EnumSet<ArgProcessorKind> types, Method guard,
ProcUnprocessedCode unprocessedCode) {
super();
this.originClassName = originClassName;
this.originMethodName = originMethodName;
this.types = types;
this.guard = guard;
this.unprocessedCode = unprocessedCode;
}
public String getOriginClassName() {
return originClassName;
}
public String getOriginMethodName() {
return originMethodName;
}
public EnumSet<ArgProcessorKind> getTypes() {
return types;
}
public Method getGuard() {
return guard;
}
public ProcCode getCode() {
return code;
}
public void init(LocalVars allLVs) throws StaticContextGenException,
ReflectionException {
code = unprocessedCode.process(allLVs);
unprocessedCode = null;
}
private final String __originClassName;
private final String __originMethodName;
private final Set <ArgProcessorKind> __types;
private final Method __guard;
private final ProcUnprocessedCode __templateCode;
private ProcCode __expandedCode;
//
public ArgProcessorMethod (
final String originClassName, final String originMethodName,
final Set <ArgProcessorKind> types, final Method guard,
final ProcUnprocessedCode templateCode
) {
__originClassName = originClassName;
__originMethodName = originMethodName;
__types = types;
__guard = guard;
__templateCode = templateCode;
}
//
/**
* @return the canonical name of the class in which the argument processor
* was defined.
*/
public String getOriginClassName () {
return __originClassName;
}
/**
* @return the name of the method representing the argument processor.
*/
public String getOriginMethodName () {
return __originMethodName;
}
/**
* @return a fully qualified method name representing the argument processor.
*/
public String getOriginName () {
return __originClassName +"."+ __originMethodName;
}
//
public Set <ArgProcessorKind> getTypes () {
return __types;
}
public Method getGuard () {
return __guard;
}
public ProcCode getCode () {
return __expandedCode;
}
//
public void init (final LocalVars localVars)
throws StaticContextGenException, ReflectionException {
__expandedCode = __templateCode.process (localVars);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment