Commit a1e5c923 authored by Lukáš Marek's avatar Lukáš Marek
Browse files

Fixed bug with empty guards

Processor package cleanup
parent 05c88b79
......@@ -28,13 +28,13 @@ import ch.usi.dag.disl.exception.StaticContextGenException;
import ch.usi.dag.disl.guard.GuardHelper;
import ch.usi.dag.disl.localvar.SyntheticLocalVar;
import ch.usi.dag.disl.localvar.ThreadLocalVar;
import ch.usi.dag.disl.processor.Proc;
import ch.usi.dag.disl.processor.generator.PIResolver;
import ch.usi.dag.disl.processor.generator.ProcGenerator;
import ch.usi.dag.disl.processor.generator.ProcInstance;
import ch.usi.dag.disl.processor.generator.ProcMethodInstance;
import ch.usi.dag.disl.snippet.Shadow;
import ch.usi.dag.disl.snippet.Snippet;
import ch.usi.dag.disl.snippet.processor.Proc;
import ch.usi.dag.disl.staticcontext.generator.SCGenerator;
import ch.usi.dag.disl.weaver.TLVInserter;
import ch.usi.dag.disl.weaver.Weaver;
......
......@@ -20,8 +20,8 @@ import ch.usi.dag.disl.exception.ScopeParserException;
import ch.usi.dag.disl.exception.SnippetParserException;
import ch.usi.dag.disl.exception.StaticContextGenException;
import ch.usi.dag.disl.localvar.LocalVars;
import ch.usi.dag.disl.processor.Proc;
import ch.usi.dag.disl.snippet.Snippet;
import ch.usi.dag.disl.snippet.processor.Proc;
public class ClassParser {
......
......@@ -26,11 +26,11 @@ import ch.usi.dag.disl.exception.ProcessorParserException;
import ch.usi.dag.disl.exception.ReflectionException;
import ch.usi.dag.disl.exception.StaticContextGenException;
import ch.usi.dag.disl.guard.GuardHelper;
import ch.usi.dag.disl.processor.Proc;
import ch.usi.dag.disl.processor.ProcArgType;
import ch.usi.dag.disl.processor.ProcMethod;
import ch.usi.dag.disl.processor.ProcUnprocessedCode;
import ch.usi.dag.disl.processorcontext.ArgumentContext;
import ch.usi.dag.disl.snippet.processor.Proc;
import ch.usi.dag.disl.snippet.processor.ProcArgType;
import ch.usi.dag.disl.snippet.processor.ProcMethod;
import ch.usi.dag.disl.snippet.processor.ProcUnprocessedCode;
import ch.usi.dag.disl.staticcontext.StaticContext;
import ch.usi.dag.disl.util.AsmHelper;
import ch.usi.dag.disl.util.Constants;
......
......@@ -20,6 +20,10 @@ class GuardContextImpl implements GuardContext {
public boolean invoke(Class<?> guardClass) {
if(guardClass == null) {
throw new NullPointerException("Guard class cannot be null");
}
try {
return GuardHelper.invokeGuard(guardClass, shadow, ac);
} catch (GuardException e) {
......
......@@ -24,6 +24,10 @@ public abstract class GuardHelper {
public static Method findAndValidateGuardMethod(Class<?> guardClass,
Set<Class<?>> validArgs) throws GuardException {
if(guardClass == null) {
return null;
}
Method guardMethod = findGuardMethod(guardClass);
validateGuardMethod(guardMethod, validArgs);
return guardMethod;
......@@ -148,6 +152,10 @@ public abstract class GuardHelper {
// invoke guard method for snippet guard
public static boolean guardApplicable(Method guardMethod, Shadow shadow) {
if(guardMethod == null) {
return true;
}
// no method validation needed - already validated
return invokeGuardMethod(guardMethod, shadow, null);
}
......@@ -156,6 +164,10 @@ public abstract class GuardHelper {
public static boolean guardApplicable(Method guardMethod, Shadow shadow,
int position, String typeDescriptor, int totalCount) {
if(guardMethod == null) {
return true;
}
// no method validation needed - already validated
return invokeGuardMethod(guardMethod, shadow,
new ArgumentContextImpl(position, typeDescriptor, totalCount));
......
package ch.usi.dag.disl.snippet.processor;
package ch.usi.dag.disl.processor;
import java.util.List;
......
package ch.usi.dag.disl.snippet.processor;
package ch.usi.dag.disl.processor;
import org.objectweb.asm.Type;
......
package ch.usi.dag.disl.snippet.processor;
package ch.usi.dag.disl.processor;
import java.util.HashSet;
import java.util.List;
......
package ch.usi.dag.disl.snippet.processor;
package ch.usi.dag.disl.processor;
import java.lang.reflect.Method;
import java.util.EnumSet;
......
package ch.usi.dag.disl.snippet.processor;
package ch.usi.dag.disl.processor;
import java.util.List;
import java.util.Set;
......
......@@ -13,13 +13,13 @@ import org.objectweb.asm.tree.MethodInsnNode;
import ch.usi.dag.disl.exception.DiSLFatalException;
import ch.usi.dag.disl.exception.ProcessorException;
import ch.usi.dag.disl.guard.GuardHelper;
import ch.usi.dag.disl.processor.Proc;
import ch.usi.dag.disl.processor.ProcArgType;
import ch.usi.dag.disl.processor.ProcMethod;
import ch.usi.dag.disl.processorcontext.ProcessorMode;
import ch.usi.dag.disl.snippet.ProcInvocation;
import ch.usi.dag.disl.snippet.Shadow;
import ch.usi.dag.disl.snippet.Snippet;
import ch.usi.dag.disl.snippet.processor.Proc;
import ch.usi.dag.disl.snippet.processor.ProcArgType;
import ch.usi.dag.disl.snippet.processor.ProcMethod;
public class ProcGenerator {
......@@ -183,10 +183,6 @@ public class ProcGenerator {
private boolean isPMGuardApplicable(Method guard, Shadow shadow,
ProcMethodInstance pmi) {
if(guard == null) {
return true;
}
// evaluate processor method guard
return GuardHelper.guardApplicable(guard, shadow, pmi.getArgPos(),
pmi.getArgTypeDesc(), pmi.getArgsCount());
......
package ch.usi.dag.disl.processor.generator;
import ch.usi.dag.disl.snippet.processor.ProcArgType;
import ch.usi.dag.disl.snippet.processor.ProcCode;
import ch.usi.dag.disl.processor.ProcArgType;
import ch.usi.dag.disl.processor.ProcCode;
public class ProcMethodInstance {
......
package ch.usi.dag.disl.snippet;
import ch.usi.dag.disl.processor.Proc;
import ch.usi.dag.disl.processorcontext.ProcessorMode;
import ch.usi.dag.disl.snippet.processor.Proc;
public class ProcInvocation {
......
......@@ -10,8 +10,8 @@ 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.marker.Marker;
import ch.usi.dag.disl.processor.Proc;
import ch.usi.dag.disl.scope.Scope;
import ch.usi.dag.disl.snippet.processor.Proc;
public class Snippet implements Comparable<Snippet> {
......
......@@ -25,9 +25,9 @@ import ch.usi.dag.disl.exception.StaticContextGenException;
import ch.usi.dag.disl.localvar.LocalVars;
import ch.usi.dag.disl.marker.BytecodeMarker;
import ch.usi.dag.disl.marker.Marker;
import ch.usi.dag.disl.processor.Proc;
import ch.usi.dag.disl.processorcontext.ProcessorContext;
import ch.usi.dag.disl.processorcontext.ProcessorMode;
import ch.usi.dag.disl.snippet.processor.Proc;
import ch.usi.dag.jborat.runtime.DynamicBypass;
public class SnippetUnprocessedCode extends UnprocessedCode {
......@@ -146,6 +146,8 @@ public class SnippetUnprocessedCode extends UnprocessedCode {
AbstractInsnNode secondParam = instr.getPrevious();
AbstractInsnNode firstParam = secondParam.getPrevious();
// NOTE: object parameter is ignored - will be removed by weaver
// first parameter has to be loaded by LDC
if (firstParam == null || firstParam.getOpcode() != Opcodes.LDC) {
throw new ProcessorException("In snippet " + className + "."
......
......@@ -9,11 +9,11 @@ import java.util.Set;
import ch.usi.dag.disl.coderep.StaticContextMethod;
import ch.usi.dag.disl.exception.ReflectionException;
import ch.usi.dag.disl.exception.StaticContextGenException;
import ch.usi.dag.disl.processor.ProcMethod;
import ch.usi.dag.disl.runtimecache.StConCache;
import ch.usi.dag.disl.snippet.ProcInvocation;
import ch.usi.dag.disl.snippet.Shadow;
import ch.usi.dag.disl.snippet.Snippet;
import ch.usi.dag.disl.snippet.processor.ProcMethod;
import ch.usi.dag.disl.staticcontext.StaticContext;
import ch.usi.dag.disl.util.Constants;
......
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