refactor.
This commit is contained in:
@@ -5,18 +5,15 @@ import com.google.dart.compiler.backend.js.ast.JsNameRef;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.types.JetStandardLibrary;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
//TODO: implement aliases stack for this
|
||||
//TODO: implement aliases stack for this need TESTS
|
||||
public class Aliaser {
|
||||
|
||||
public static Aliaser aliasesForStandardClasses(@NotNull JetStandardLibrary standardLibrary,
|
||||
@NotNull Namer namer) {
|
||||
Aliaser aliaser = new Aliaser();
|
||||
return aliaser;
|
||||
public static Aliaser newInstance() {
|
||||
return new Aliaser();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -79,18 +79,17 @@ public final class Declarations {
|
||||
}
|
||||
|
||||
/*package*/ void putScope(@NotNull DeclarationDescriptor descriptor, @NotNull NamingScope scope) {
|
||||
// assert !descriptorToScopeMap.containsKey(descriptor) : "Already contains that key!";
|
||||
assert !descriptorToScopeMap.containsKey(descriptor) : "Already contains that key!";
|
||||
descriptorToScopeMap.put(descriptor, scope);
|
||||
}
|
||||
|
||||
//TODO: decide what to do about function overriding
|
||||
/*package*/ void putName(@NotNull DeclarationDescriptor descriptor, @NotNull JsName name) {
|
||||
// assert !descriptorToNameMap.containsKey(descriptor) : "Already contains that key!";
|
||||
assert !descriptorToNameMap.containsKey(descriptor) : "Already contains that key!";
|
||||
descriptorToNameMap.put(descriptor, name);
|
||||
}
|
||||
|
||||
/*package*/ void putQualifier(@NotNull DeclarationDescriptor descriptor, @Nullable JsNameRef qualifier) {
|
||||
// assert !descriptorToQualifierMap.containsKey(descriptor) : "Already contains that key!";
|
||||
assert !descriptorToQualifierMap.containsKey(descriptor) : "Already contains that key!";
|
||||
descriptorToQualifierMap.put(descriptor, qualifier);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ public class DynamicContext {
|
||||
return new DynamicContext(namingScope.innerScope(scope), currentBlock);
|
||||
}
|
||||
|
||||
//TODO:
|
||||
@NotNull
|
||||
public DynamicContext innerBlock(@NotNull JsBlock block) {
|
||||
return new DynamicContext(namingScope, block);
|
||||
|
||||
@@ -10,11 +10,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @author Talanov Pavel
|
||||
*/
|
||||
|
||||
/*
|
||||
* This class is a dummy and should completely change in the future
|
||||
*/
|
||||
//TODO: rework into stateful class and include into context
|
||||
|
||||
public final class Namer {
|
||||
|
||||
private static final String INITIALIZE_METHOD_NAME = "initialize";
|
||||
@@ -32,11 +27,6 @@ public final class Namer {
|
||||
return AstUtil.newQualifiedNameRef(INITIALIZE_METHOD_NAME);
|
||||
}
|
||||
|
||||
// @NotNull
|
||||
// public static JsNameRef superMethodReference() {
|
||||
// return AstUtil.newQualifiedNameRef(SUPER_METHOD_NAME);
|
||||
// }
|
||||
|
||||
@NotNull
|
||||
public static String superMethodName() {
|
||||
return SUPER_METHOD_NAME;
|
||||
@@ -124,17 +114,6 @@ public final class Namer {
|
||||
return reference;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JsName libraryObject(@NotNull String name) {
|
||||
return kotlinScope.declareName(name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JsName libraryMethod(@NotNull String name) {
|
||||
//TODO: Create scopes for library methods
|
||||
return kotlinScope.declareName(name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JsNameRef kotlinObject() {
|
||||
return kotlinName.makeRef();
|
||||
|
||||
@@ -18,7 +18,7 @@ public class StaticContext {
|
||||
JsProgram program = new JsProgram("main");
|
||||
JsRootScope jsRootScope = program.getRootScope();
|
||||
Namer namer = Namer.newInstance(jsRootScope);
|
||||
Aliaser aliaser = Aliaser.aliasesForStandardClasses(library, namer);
|
||||
Aliaser aliaser = Aliaser.newInstance();
|
||||
NamingScope scope = NamingScope.rootScope(jsRootScope);
|
||||
Declarations declarations = Declarations.newInstance(scope);
|
||||
Intrinsics intrinsics = Intrinsics.standardLibraryIntrinsics(library);
|
||||
|
||||
@@ -128,14 +128,6 @@ public final class TranslationContext {
|
||||
return getNameForDescriptor(descriptor);
|
||||
}
|
||||
|
||||
public boolean isDeclared(@NotNull DeclarationDescriptor descriptor) {
|
||||
if (dynamicContext.isDeclared(descriptor)) {
|
||||
return true;
|
||||
} else {
|
||||
return staticContext.isDeclared(descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isStandardObject(@NotNull DeclarationDescriptor descriptor) {
|
||||
return standardClasses().isStandardObject(descriptor);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user