Modified InstanceOf to use Pattern
This commit is contained in:
parent
6119bc92ed
commit
1df354d5f1
@ -1,12 +1,12 @@
|
||||
package de.dhbwstuttgart.syntaxtree.statement;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
|
||||
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
public class Block extends Statement {
|
||||
public Block(List<Statement> statements, Token offset) {
|
||||
|
@ -7,26 +7,28 @@ import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
|
||||
public class InstanceOf extends BinaryExpr {
|
||||
private RefTypeOrTPHOrWildcardOrGeneric reftype;
|
||||
private String name = null;
|
||||
private Pattern pattern;
|
||||
|
||||
public InstanceOf(Expression expr, RefTypeOrTPHOrWildcardOrGeneric reftype, Token offset) {
|
||||
super(BinaryExpr.Operator.INSTOF, TypePlaceholder.fresh(offset), expr, new LocalVar("", reftype, reftype.getOffset()), offset);
|
||||
this.reftype = reftype;
|
||||
this.pattern = new Pattern(null, reftype, offset);
|
||||
}
|
||||
|
||||
public InstanceOf(Expression expr, Pattern pattern, Token offset) {
|
||||
super(BinaryExpr.Operator.INSTOF, TypePlaceholder.fresh(offset), expr, new LocalVar(pattern.getName(), pattern.getType(), pattern.getOffset()), offset);
|
||||
this.reftype = pattern.getType();
|
||||
this.name = pattern.getName();
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
public RefTypeOrTPHOrWildcardOrGeneric getReftype() {
|
||||
return reftype;
|
||||
return pattern.getType();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
return pattern.getName();
|
||||
}
|
||||
|
||||
public Pattern gPattern() {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -7,6 +7,9 @@ import static org.junit.Assert.fail;
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
@ -14,6 +17,7 @@ import org.junit.Test;
|
||||
|
||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter;
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user