Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
f198ddf
type refactoring wip
peq May 12, 2018
09911a8
type refactor wip
peq May 16, 2018
6903cc1
Merge branch 'master' into type-refactor
peq May 19, 2018
f1e7987
type refactor wip
peq May 19, 2018
df50dde
type-refactor wip
peq May 24, 2018
40a12cb
Merge branch 'master' into type-refactor
peq Jun 2, 2018
c8fca3b
Merge branch 'master' into type-refactor
peq Jun 4, 2018
7ec9c51
type-refactor wip
peq Jun 4, 2018
8b0b5ce
type refactor wip: compiling, 149 failing tests
peq Jun 5, 2018
fd9f76b
Merge branch 'master' into type-refactor
peq Jun 6, 2018
a3dad66
type refactor wip, down to 90 failing tests
peq Jun 6, 2018
ff55285
Merge branch 'master' into type-refactor
peq Jun 7, 2018
7db1411
type-refactor wip
peq Jun 7, 2018
d970992
type refactor wip
peq Jun 8, 2018
942215c
type refactor wip - down to 70 failing
peq Jun 8, 2018
fb52399
type refactor wip, 65 failing tests
peq Jun 9, 2018
7f33d90
type-refactor wip -- 56 failing tests
peq Jun 10, 2018
27e1a49
type-refactor modules -- 28 failing
peq Jun 10, 2018
c3e6350
type-refactor varargs -- 15 failing
peq Jun 10, 2018
c1cf6e6
type-refactor wip -- 8 failing tests
peq Jun 10, 2018
7637c35
fixed NPE
peq Jun 10, 2018
abad653
fixed other NPE
peq Jun 10, 2018
f8bb6d5
fixed private/protected (1 failing test left)
peq Jun 10, 2018
c1814ff
type-refactor all tests passed
peq Jun 11, 2018
42f532c
Merge branch 'master' into type-refactor
peq Jun 11, 2018
9a4667f
updated StdLib for tests
peq Jun 11, 2018
47fab30
stdlib update
peq Jun 11, 2018
bea8c13
adapted tests to changes in Stdlib
peq Jun 11, 2018
4bfcb85
fixed problem with implicit conversions
peq Jun 12, 2018
6aa0464
test for generic function overload #628
peq Jun 12, 2018
047d71d
Merge remote-tracking branch 'origin/master' into type-refactor
peq Jun 12, 2018
b204938
fixed finding error function
peq Jun 12, 2018
07c2e8c
fixed implicit conversions problem
peq Jun 12, 2018
cfc0142
fixed exponential runtime in optimizer
peq Jun 12, 2018
aa93317
update StdLib version for tests
peq Jun 12, 2018
48e16f2
add import (travis did not find name??)
peq Jun 13, 2018
48e5c09
test for #655
peq Jun 13, 2018
68f200e
test for #657
peq Jun 13, 2018
e17d6fb
test for #668
peq Jun 13, 2018
cce1ab0
fixed hover/go to definition bug mentioned in #668
peq Jun 13, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions de.peeeq.wurstscript/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ dependencies {
// Google guava
compile 'com.google.guava:guava:21.0'

// Functional data structures:
compile group: 'org.functionaljava', name: 'functionaljava', version: '4.7'

// Support for the vscode language server protocol
compile group: 'org.eclipse.lsp4j', name: 'org.eclipse.lsp4j', version: '0.4.0'

Expand Down
78 changes: 39 additions & 39 deletions de.peeeq.wurstscript/parserspec/wurstscript.parseq
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,10 @@ Expr.attrExpectedTyp "try to guess what type is expected here"
returns de.peeeq.wurstscript.types.WurstType
implemented by de.peeeq.wurstscript.attributes.AttrExprExpectedType.normalizedType

Expr.attrExpectedTypAfterOverloading() "more precise expected type, after overloading"
returns de.peeeq.wurstscript.types.WurstType
implemented by de.peeeq.wurstscript.attributes.AttrExprExpectedType.afterOverloading

ExprClosure.attrClosureAbstractMethod
returns de.peeeq.wurstscript.attributes.names.FuncLink
implemented by de.peeeq.wurstscript.attributes.AttrClosureAbstractMethod.calculate
Expand All @@ -438,6 +442,15 @@ NameDef.attrTyp
returns de.peeeq.wurstscript.types.WurstType
implemented by de.peeeq.wurstscript.attributes.AttrVarDefType.calculate

ClassDef.attrTypC
returns de.peeeq.wurstscript.types.WurstTypeClass
implemented by de.peeeq.wurstscript.attributes.AttrVarDefType.calculate

InterfaceDef.attrTypI
returns de.peeeq.wurstscript.types.WurstTypeInterface
implemented by de.peeeq.wurstscript.attributes.AttrVarDefType.calculate


FunctionLike.attrReturnType
returns de.peeeq.wurstscript.types.WurstType
implemented by de.peeeq.wurstscript.attributes.AttrVarDefType.calculate
Expand Down Expand Up @@ -616,26 +629,6 @@ Element.attrErrorPos() "returns the position where errors are marked"
implemented by de.peeeq.wurstscript.attributes.AttrPos.getErrorPos


HasTypeArgs.attrTypeParameterBindings
returns com.google.common.collect.ImmutableMap<TypeParamDef, de.peeeq.wurstscript.types.WurstTypeBoundTypeParam>
implemented by de.peeeq.wurstscript.attributes.Generics.getTypeParameterBindings





InterfaceDef.attrExtendedInterfaces
returns com.google.common.collect.ImmutableCollection<de.peeeq.wurstscript.types.WurstTypeInterface>
implemented by de.peeeq.wurstscript.attributes.InterfaceInstances.getExtendedInterfaces

ClassDef.attrExtendedClass
returns ClassDef
implemented by de.peeeq.wurstscript.attributes.SubClasses.getExtendedClass

ClassDef.attrExtendedClassType
returns de.peeeq.wurstscript.types.WurstType
implemented by de.peeeq.wurstscript.attributes.SubClasses.getExtendedClassType

ClassDef.isInnerClass()
returns boolean
implemented by de.peeeq.wurstscript.attributes.InnerClasses.isInnerClass
Expand Down Expand Up @@ -749,11 +742,6 @@ StmtForEach.attrCloseFunc
returns void
implemented by de.peeeq.wurstscript.translation.imtranslation.FuncSkeleton.create

ClassDef.attrImplementedInterfaces
returns com.google.common.collect.ImmutableCollection<de.peeeq.wurstscript.types.WurstTypeInterface>
implemented by de.peeeq.wurstscript.attributes.InterfaceInstances.getImplementedInterfaces



Element.addError(String msg)
returns void
Expand All @@ -775,27 +763,39 @@ FunctionLike.attrHasEmptyBody()

// Naming:

NameRef.attrNameDef
returns @Nullable NameDef
NameRef.attrNameLink
returns de.peeeq.wurstscript.attributes.names.NameLink
implemented by de.peeeq.wurstscript.attributes.AttrNameDef.calculate

NameRef.attrNameDef
returns NameDef
implemented by de.peeeq.wurstscript.attributes.AttrNameDef.calculateDef

FuncRef.attrPossibleFuncDefs
returns com.google.common.collect.ImmutableCollection<FunctionDefinition>
returns com.google.common.collect.ImmutableCollection<de.peeeq.wurstscript.attributes.names.FuncLink>
implemented by de.peeeq.wurstscript.attributes.PossibleFuncDefs.calculate


FuncRef.attrFuncDef
returns @Nullable FunctionDefinition
FuncRef.attrFuncLink
returns de.peeeq.wurstscript.attributes.names.FuncLink
implemented by de.peeeq.wurstscript.attributes.AttrFuncDef.calculate

FuncRef.attrFuncDef()
returns FunctionDefinition
implemented by de.peeeq.wurstscript.attributes.AttrFuncDef.calculateDef

ExprNewObject.attrConstructorDef
returns @Nullable ConstructorDef
implemented by de.peeeq.wurstscript.attributes.AttrConstructorDef.calculate

ExprBinary.attrFuncDef
returns @Nullable FunctionDefinition
ExprBinary.attrFuncLink
returns de.peeeq.wurstscript.attributes.names.FuncLink
implemented by de.peeeq.wurstscript.attributes.AttrFuncDef.calculate

ExprBinary.attrFuncDef()
returns FunctionDefinition
implemented by de.peeeq.wurstscript.attributes.AttrFuncDef.calculateDef


FunctionDefinition.attrRealFuncDef "returns the function definition which overrides this definition"
returns @Nullable FunctionDefinition
Expand Down Expand Up @@ -873,19 +873,19 @@ Element.lookupType(String name, boolean showErrors)
implemented by de.peeeq.wurstscript.attributes.names.NameResolution.lookupType

Element.lookupPackage(String name, boolean showErrors)
returns @Nullable WPackage
returns de.peeeq.wurstscript.attributes.names.PackageLink
implemented by de.peeeq.wurstscript.attributes.names.NameResolution.lookupPackage

Element.lookupVar(String name, boolean showErrors)
returns @Nullable NameDef
returns de.peeeq.wurstscript.attributes.names.NameLink
implemented by de.peeeq.wurstscript.attributes.names.NameResolution.lookupVar

Element.lookupVarNoConfig(String name, boolean showErrors)
returns @Nullable NameDef
returns de.peeeq.wurstscript.attributes.names.NameLink
implemented by de.peeeq.wurstscript.attributes.names.NameResolution.lookupVarNoConfig

Element.lookupMemberVar(de.peeeq.wurstscript.types.WurstType receiverType, String name, boolean showErrors)
returns @Nullable NameDef
returns de.peeeq.wurstscript.attributes.names.NameLink
implemented by de.peeeq.wurstscript.attributes.names.NameResolution.lookupMemberVar

Element.lookupFuncs(String name, boolean showErrors)
Expand All @@ -906,15 +906,15 @@ Element.lookupType(String name)
implemented by de.peeeq.wurstscript.attributes.names.NameResolution.lookupTypeShort

Element.lookupPackage(String name)
returns @Nullable WPackage
returns de.peeeq.wurstscript.attributes.names.PackageLink
implemented by de.peeeq.wurstscript.attributes.names.NameResolution.lookupPackageShort

Element.lookupVar(String name)
returns @Nullable NameDef
returns de.peeeq.wurstscript.attributes.names.NameLink
implemented by de.peeeq.wurstscript.attributes.names.NameResolution.lookupVarShort

Element.lookupMemberVar(de.peeeq.wurstscript.types.WurstType receiverType, String name)
returns @Nullable NameDef
returns de.peeeq.wurstscript.attributes.names.NameLink
implemented by de.peeeq.wurstscript.attributes.names.NameResolution.lookupMemberVarShort

Element.lookupFuncs(String name)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package de.peeeq.datastructures;

import java.util.Optional;
import java.util.function.Function;
import java.util.function.Supplier;

/**
* Compute something lazily.
*
* At the moment, this is used to avoid cyclic dependencies.
* This should be improved with a better design.
*/
public class Deferred<T> {
private Supplier<T> supplier;
private T value;

public Deferred(Supplier<T> supplier) {
this.supplier = supplier;
}
public Deferred(T value) {
this.value = value;
}

public T get() {
if (supplier != null) {
value = supplier.get();
supplier = null;
}
return value;
}

public <S> Deferred<S> map(Function<T, S> f) {
if (supplier == null) {
S newValue = f.apply(value);
if (newValue == value) {
//noinspection unchecked
return (Deferred<S>) this;
} else {
return new Deferred<>(newValue);
}
}
return new Deferred<>(() -> f.apply(get()));
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package de.peeeq.wurstio;

import java.io.File;

public class UtilsIO {

public static void sleep(int i) {
Expand Down Expand Up @@ -31,12 +33,18 @@ public static String getMethodName(final int depth) {
public static String getMethodName(String currentClass) {
StackTraceElement[] ste = Thread.currentThread().getStackTrace();
for (int i = 2; i < ste.length; i++) {
if (!ste[i].getClassName().equals(currentClass)) {
if (!ste[i].getClassName().startsWith(currentClass)) {
return ste[i].getMethodName();
}
}
return "";
}


public static void mkdirs(File dir) {
boolean res = dir.mkdirs();
if (!res) {
throw new RuntimeException("Directory " + dir + " could not be created.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public InterpreterException(Element trace, String msg) {
this.trace = trace;
}

public InterpreterException(Element trace, String msg, Exception e) {
public InterpreterException(Element trace, String msg, Throwable e) {
super(msg, e);
this.trace = trace;
}
Expand All @@ -36,8 +36,6 @@ public String toString() {
if (trace == null) {
return getMessage();
}
System.err.println(trace);
System.err.println(trace.attrSource());
WPos pos = trace.attrSource();
return "at " + pos.print() + ":\n" + getMessage()
+ (stackTrace != null ? "\nStack trace:\n" + stackTrace : "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ public ILconstInt GetPlayerId(IlConstHandle p) {
return p != null ? ((PlayerMock) p.getObj()).id : ILconstInt.create(-1);
}

public ILconstInt GetPlayerNeutralPassive() {
// fake value
return new ILconstInt(31);
}

public ILconstInt GetPlayerNeutralAggressive() {
// fake value
return new ILconstInt(30);
}


public IlConstHandle GetLocalPlayer() {
return new IlConstHandle("Local Player", "local player");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ public void buildProject() {
}
}

private void processWurstFiles(File dir) throws IOException {
for (File f : dir.listFiles()) {
private void processWurstFiles(File dir) {
for (File f : getFiles(dir)) {
if (f.isDirectory()) {
processWurstFiles(f);
} else if (f.getName().endsWith(".wurst") || f.getName().endsWith(".jurst") || f.getName().endsWith(".j")) {
Expand All @@ -130,7 +130,15 @@ private void processWurstFiles(File dir) throws IOException {
}
}

private void processWurstFile(WFile f) throws IOException {
private File[] getFiles(File dir) {
File[] res = dir.listFiles();
if (res == null) {
return new File[0];
}
return res;
}

private void processWurstFile(WFile f) {
WLogger.info("processing file " + f);
replaceCompilationUnit(f);
}
Expand Down Expand Up @@ -602,7 +610,7 @@ public synchronized Set<File> getDependencyWurstFiles() {

private void addDependencyWurstFiles(Set<File> result, File file) {
if (file.isDirectory()) {
for (File child : file.listFiles()) {
for (File child : getFiles(file)) {
addDependencyWurstFiles(result, child);
}
} else if (Utils.isWurstFile(file)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import de.peeeq.wurstscript.WLogger;
import de.peeeq.wurstscript.ast.*;
import de.peeeq.wurstscript.attributes.names.DefLink;
import de.peeeq.wurstscript.attributes.names.FuncLink;
import de.peeeq.wurstscript.attributes.names.NameLink;
import de.peeeq.wurstscript.attributes.names.TypeLink;
import de.peeeq.wurstscript.types.WurstType;
Expand Down Expand Up @@ -62,14 +63,14 @@ public List<Command> execute(ModelManager modelManager) {
}
} else if (e instanceof FuncRef) {
FuncRef fr = (FuncRef) e;
FunctionDefinition fd = fr.attrFuncDef();
FuncLink fd = fr.attrFuncLink();
if (fd == null) {
return handleMissingFunction(modelManager, fr);
}

} else if (e instanceof NameRef) {
NameRef nr = (NameRef) e;
NameDef nd = nr.attrNameDef();
NameLink nd = nr.attrNameLink();
if (nd == null) {
return handleMissingName(modelManager, nr);
}
Expand Down
Loading