Commit c4872b0c authored by Vít Kabele's avatar Vít Kabele

Classparser package flattened and unnecessary public modifiers removed.

parent e7ebc8c3
Pipeline #3284 passed with stages
in 3 minutes and 58 seconds
......@@ -5,6 +5,7 @@
<classpathentry kind="src" output="output/build/util" path="src-util"/>
<classpathentry kind="src" output="output/build/test" path="src-test"/>
<classpathentry kind="src" output="output/build/shvm-dispatch" path="src-shvm-dispatch"/>
<classpathentry kind="src" path="disl/src-classparser"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="output/lib/disl-bypass.jar"/>
<classpathentry kind="lib" path="lib/disl/log4j.jar" sourcepath="lib/devel/log4j-source.jar"/>
......
......@@ -5,7 +5,9 @@ lib.test.dir=${lib.dir}/test
lib.devel.dir=${lib.dir}/devel
src.bin=bin
src.disl.prefix=disl
src.disl=src-disl
src.disl.classparser=src-classparser
src.disl.bypass=src-disl-bypass
src.disl.agent=src-disl-agent
src.shvm=src-shvm
......
......@@ -474,7 +474,9 @@
<target name="compile-disl" depends="compile-util,compile-disl-bypass">
<mkdir dir="${build.disl}"/>
<javac destdir="${build.disl}" srcdir="${src.disl}" debug="true">
<javac destdir="${build.disl}" debug="true">
<src path="${src.disl}"/>
<src path="${src.disl.prefix}/${src.disl.classparser}"/>
<classpath>
<path refid="disl.bypass.classpath"/>
<path refid="util.classpath"/>
......
package ch.usi.dag.disl.classparser;
package ch.usi.dag.disl;
import java.util.Collections;
import java.util.Iterator;
......@@ -22,7 +22,6 @@ import org.objectweb.asm.tree.VarInsnNode;
import org.objectweb.asm.tree.analysis.Frame;
import org.objectweb.asm.tree.analysis.SourceValue;
import ch.usi.dag.disl.InitializationException;
import ch.usi.dag.disl.annotation.SyntheticLocal;
import ch.usi.dag.disl.annotation.SyntheticLocal.Initialize;
import ch.usi.dag.disl.annotation.ThreadLocal;
......
package ch.usi.dag.disl.classparser;
package ch.usi.dag.disl;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.function.BiConsumer;
import java.util.function.Predicate;
import java.util.regex.Pattern;
import java.util.stream.Stream;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.Opcodes;
......@@ -59,10 +55,10 @@ final class AnnotationMapper {
)).getValue ();
}
public AnnotationMapper processDefaults () {
AnnotationMapper processDefaults () {
__consumers.keySet ().stream ()
.filter (ac -> ac.isAnnotation ())
.forEach (ac -> __accept (ac));
.filter (Class::isAnnotation)
.forEach (this::__accept);
return this;
}
......@@ -94,10 +90,10 @@ final class AnnotationMapper {
public AnnotationMapper accept (final MethodNode mn) {
Arrays.asList (mn.visibleAnnotations, mn.invisibleAnnotations).stream ()
.filter (l -> l != null)
.flatMap (l -> l.stream ())
.forEach (an -> accept (an));
Stream.of (mn.visibleAnnotations, mn.invisibleAnnotations)
.filter (Objects::nonNull)
.flatMap (Collection::stream)
.forEach (this::accept);
return this;
}
......
package ch.usi.dag.disl.classparser;
package ch.usi.dag.disl;
import java.lang.reflect.Method;
import java.util.EnumSet;
......@@ -36,7 +36,7 @@ class ArgProcessorParser extends AbstractParser {
private final Map <Type, ArgProcessor> __processors = new HashMap <> ();
public Map <Type, ArgProcessor> initProcessors (final LocalVars localVars) {
Map <Type, ArgProcessor> initProcessors (final LocalVars localVars) {
__processors.values ().stream ().unordered ()
.forEach (processor -> processor.init (localVars));
......@@ -46,7 +46,7 @@ class ArgProcessorParser extends AbstractParser {
//
// NOTE: this method can be called many times
public void parse (final ClassNode dislClass) throws ParserException {
void parse (final ClassNode dislClass) throws ParserException {
processLocalVars (dislClass);
//
......@@ -213,7 +213,7 @@ class ArgProcessorParser extends AbstractParser {
//
public static AnnotationData parse (final MethodNode method) {
static AnnotationData parse (final MethodNode method) {
final AnnotationData result = new AnnotationData ();
new AnnotationMapper ()
......
package ch.usi.dag.disl.classparser;
package ch.usi.dag.disl;
import java.util.HashMap;
import java.util.Map;
......@@ -58,7 +58,7 @@ public enum ContextKind {
//
private ContextKind (final Class <?> itfClass) {
ContextKind (final Class <?> itfClass) {
_itfClass = itfClass;
_itfType = Type.getType (_itfClass);
}
......
......@@ -4,7 +4,7 @@
* Author: Vit Kabele <vit@kabele.me>
* Created on the 26/10/2018
*/
package ch.usi.dag.disl.classparser;
package ch.usi.dag.disl;
import ch.usi.dag.disl.snippet.Snippet;
......
package ch.usi.dag.disl.classparser;
package ch.usi.dag.disl;
import ch.usi.dag.disl.DiSL.CodeOption;
import ch.usi.dag.disl.InitializationException;
import ch.usi.dag.disl.annotation.ArgumentProcessor;
import ch.usi.dag.disl.exception.ParserException;
import ch.usi.dag.disl.exception.ProcessorException;
......
......@@ -6,10 +6,8 @@
* Author: Vit Kabele <vit@kabele.me>
* Created on the 26/10/2018
*/
package ch.usi.dag.disl.classparser;
package ch.usi.dag.disl;
import ch.usi.dag.disl.DiSL;
import ch.usi.dag.disl.InitializationException;
import ch.usi.dag.disl.annotation.ArgumentProcessor;
import ch.usi.dag.disl.exception.ParserException;
import ch.usi.dag.disl.exception.ProcessorException;
......@@ -43,7 +41,7 @@ public class IsolatedDislClasses implements DislClasses {
* @throws ProcessorException
* @throws ReflectionException
*/
public IsolatedDislClasses(final Set<DiSL.CodeOption> options, List<ClassNode> classNodes)
IsolatedDislClasses(final Set<DiSL.CodeOption> options, List<ClassNode> classNodes)
throws ParserException, ProcessorException, ReflectionException {
if (classNodes.isEmpty ()) {
......
package ch.usi.dag.disl.classparser;
package ch.usi.dag.disl;
@SuppressWarnings ("serial")
class ParserRuntimeException extends RuntimeException {
public ParserRuntimeException (final String message) {
ParserRuntimeException (final String message) {
super (message);
}
public ParserRuntimeException (final Throwable cause) {
ParserRuntimeException (final Throwable cause) {
super (cause);
}
public ParserRuntimeException (
ParserRuntimeException (
final String format, final Object... args
) {
super (String.format (format, args));
}
public ParserRuntimeException (
ParserRuntimeException (
final Throwable cause, final String format, final Object... args
) {
super (String.format (format, args), cause);
......
package ch.usi.dag.disl.classparser;
package ch.usi.dag.disl;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;
import java.util.stream.Collectors;
......@@ -54,7 +53,7 @@ class SnippetParser extends AbstractParser {
//
// NOTE: this method can be called many times
public void parse (final ClassNode dislClass) throws ParserException {
void parse (final ClassNode dislClass) throws ParserException {
processLocalVars (dislClass);
//
......@@ -63,7 +62,7 @@ class SnippetParser extends AbstractParser {
final String className = AsmHelper.typeName (dislClass);
snippets.addAll (dislClass.methods.parallelStream ().unordered ()
.filter (m -> __isSnippetCandidate (m))
.filter (this::__isSnippetCandidate)
.map (m -> __parseSnippetWrapper (className, m))
.collect (Collectors.toList ())
);
......
package ch.usi.dag.disl;
import ch.usi.dag.disl.classparser.DislClasses;
import ch.usi.dag.disl.classparser.DislClassesImpl;
import ch.usi.dag.disl.classparser.IsolatedDislClasses;
import ch.usi.dag.disl.exception.DiSLException;
import ch.usi.dag.disl.exception.DiSLInMethodException;
import ch.usi.dag.disl.localvar.SyntheticLocalVar;
......
......@@ -8,7 +8,7 @@ import java.util.Set;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.MethodNode;
import ch.usi.dag.disl.classparser.ContextKind;
import ch.usi.dag.disl.ContextKind;
/**
......
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