Skip to content

Commit

Permalink
Merge branch 'master' into experimental-rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
Frotty committed Jun 18, 2018
2 parents deeefb4 + eb321a6 commit 56b65e7
Show file tree
Hide file tree
Showing 120 changed files with 3,114 additions and 1,554 deletions.
21 changes: 9 additions & 12 deletions de.peeeq.wurstscript/build.gradle
Expand Up @@ -54,18 +54,13 @@ sourceSets {
}
}

// In this section you declare where to find the dependencies of your project
repositories {
// Use 'jcenter' for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
//jcenter()
mavenLocal()
mavenCentral()
maven { url 'https://jitpack.io' }
jcenter()
}

// In this section you declare the dependencies for your production and test code
dependencies {

// Antlr parsing library
Expand All @@ -81,6 +76,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 All @@ -96,14 +94,11 @@ dependencies {
// Chardet for guessing the file-encoding of a source-file
compile group: 'net.sourceforge.jchardet', name: 'jchardet', version: '1.0'

// JMPQ by Crigges for handling mpq archives
compile 'com.github.inwc3:jmpq3:1.5.9'

// Water's wc3 libs
compile 'com.github.inwc3:wc3libs:d0a470d9e3'
// Water's wc3 libs including Crigges' jmpq
compile 'com.github.inwc3:wc3libs:ccf44373c7'

// The setup tool for wurst.build handling
compile 'com.github.wurstscript:WurstSetup:7b96dfbc6c'
compile 'com.github.wurstscript:wurstsetup:cc208dcc86'

compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
Expand Down Expand Up @@ -203,6 +198,9 @@ compileJava.dependsOn gen


test {
// set minimal heap size required to run tests:
jvmArgs = ['-Xms256m']

useTestNG() {
suites 'src/test/resources/AllTestsSuite.xml'
}
Expand Down Expand Up @@ -235,4 +233,3 @@ apply from: 'deploy.gradle'




78 changes: 39 additions & 39 deletions de.peeeq.wurstscript/parserspec/wurstscript.parseq
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
@@ -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()));
}

}
Expand Up @@ -26,7 +26,7 @@ public void handleSevere(final Throwable t, final String sourcecode) {
// ignore
}

String title = "Sorry!";
String title = "Sor!";
String message = "You have encountered a bug in the Wurst Compiler.\n" +
"Your version is: " + AboutDialog.version + "\n" +
"The Error message is: " + t.getMessage() + "\n" + Utils.printExceptionWithStackTrace(t) + "\n\n" +
Expand Down
Expand Up @@ -23,6 +23,7 @@
import de.peeeq.wurstscript.jassAst.JassProg;
import de.peeeq.wurstscript.jassprinter.JassPrinter;
import de.peeeq.wurstscript.utils.Utils;
import net.moonlightflower.wc3libs.bin.GameExe;
import org.eclipse.jdt.annotation.Nullable;

import javax.swing.*;
Expand All @@ -35,6 +36,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.Objects;

import static de.peeeq.wurstio.CompiletimeFunctionRunner.FunctionFlagToRun.CompiletimeFunctions;
import static javax.swing.SwingConstants.CENTER;
Expand Down Expand Up @@ -222,7 +224,7 @@ private static void fixInstallation() throws Exception {
}

private static void copyMap() throws Exception {
String wc3Path = W3Utils.getGamePath();
String wc3Path = Objects.requireNonNull(GameExe.fromRegistry()).getFile().getParent();
WLogger.info("Wc3 Path: " + wc3Path);

String documentPath = FileSystemView.getFileSystemView().getDefaultDirectory().getPath() + File.separator + "Warcraft III";
Expand Down
@@ -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.");
}
}
}
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
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
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

0 comments on commit 56b65e7

Please sign in to comment.