From: HannuNiemistö Date: Sun, 9 Sep 2018 20:08:42 +0000 (+0300) Subject: Minor refactorings related to SCL constructors X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=4b6e9795a71944720051b8822ff65c02f6c849e4;p=simantics%2Fplatform.git Minor refactorings related to SCL constructors * Moved recordFieldNames from SCLConstructor to SCLValue and renamed as parameterNames * Replaced String array fieldNames in SCLConstructor and Constructor by more generic ComponentAcces array and renamed as componentAccesses. gitlab #114 Change-Id: I4f8d59a2f028717b6777949c8d8fc6ec6d3b16e9 --- diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/common/datatypes/Constructor.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/common/datatypes/Constructor.java index 88a45558f..7e57d3d14 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/common/datatypes/Constructor.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/common/datatypes/Constructor.java @@ -1,6 +1,7 @@ package org.simantics.scl.compiler.common.datatypes; import org.simantics.scl.compiler.common.names.Name; +import org.simantics.scl.compiler.constants.componentaccess.ComponentAccess; import org.simantics.scl.compiler.elaboration.modules.TypeConstructor; import org.simantics.scl.compiler.internal.codegen.utils.ClassBuilder; import org.simantics.scl.compiler.types.TVar; @@ -21,7 +22,7 @@ public class Constructor implements Typed { public final TVar[] typeVariables; public final Type type; - public String[] fieldNames; + public ComponentAccess[] componentAccesses; public String[] recordFieldNames; diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/Elaboration.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/Elaboration.java index c59df828d..56e8eb3b6 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/Elaboration.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/Elaboration.java @@ -12,11 +12,12 @@ import org.simantics.scl.compiler.constants.Constant; import org.simantics.scl.compiler.constants.JavaTypeInstanceConstructor; import org.simantics.scl.compiler.constants.SCLConstructor; import org.simantics.scl.compiler.constants.StringConstant; +import org.simantics.scl.compiler.constants.componentaccess.ComponentAccess; +import org.simantics.scl.compiler.constants.componentaccess.FieldComponentAccess; import org.simantics.scl.compiler.constants.generic.CallJava; import org.simantics.scl.compiler.constants.generic.ClassRef; import org.simantics.scl.compiler.constants.generic.ConvertToListFilter; import org.simantics.scl.compiler.constants.generic.MethodRef; -import org.simantics.scl.compiler.constants.generic.MethodRef.FieldRef; import org.simantics.scl.compiler.constants.generic.OutputFilter; import org.simantics.scl.compiler.constants.generic.ParameterStackItem; import org.simantics.scl.compiler.constants.generic.Pop2OutputFilter; @@ -79,7 +80,6 @@ import org.simantics.scl.compiler.internal.deriving.InstanceDerivers; import org.simantics.scl.compiler.internal.elaboration.profiling.BranchPointInjector; import org.simantics.scl.compiler.internal.elaboration.utils.StronglyConnectedComponents; import org.simantics.scl.compiler.internal.header.ModuleHeader; -import org.simantics.scl.compiler.internal.parsing.Token; import org.simantics.scl.compiler.internal.parsing.declarations.ConstructorAst; import org.simantics.scl.compiler.internal.parsing.declarations.DAnnotationAst; import org.simantics.scl.compiler.internal.parsing.declarations.DClassAst; @@ -96,7 +96,6 @@ import org.simantics.scl.compiler.internal.parsing.declarations.DTypeAst; import org.simantics.scl.compiler.internal.parsing.declarations.DValueAst; import org.simantics.scl.compiler.internal.parsing.declarations.DValueTypeAst; import org.simantics.scl.compiler.internal.parsing.exceptions.SCLSyntaxErrorException; -import org.simantics.scl.compiler.internal.parsing.parser.SCLTerminals; import org.simantics.scl.compiler.internal.parsing.translation.ProcessedDClassAst; import org.simantics.scl.compiler.internal.parsing.translation.ProcessedDInstanceAst; import org.simantics.scl.compiler.internal.parsing.translation.RelationRepository; @@ -109,7 +108,6 @@ import org.simantics.scl.compiler.module.ModuleUtils; import org.simantics.scl.compiler.module.debug.ModuleDebugInfo; import org.simantics.scl.compiler.module.repository.ImportFailure; import org.simantics.scl.compiler.module.repository.ImportFailureException; -import org.simantics.scl.compiler.top.SCLCompilerConfiguration; import org.simantics.scl.compiler.types.TCon; import org.simantics.scl.compiler.types.TForAll; import org.simantics.scl.compiler.types.TFun; @@ -399,7 +397,7 @@ public class Elaboration { parameterTypes[i] = context.toType(constructor.parameters[i]); String javaName = constructors.length == 1 ? className : compilationContext.namingPolicy.getConstructorClassName(name); - String[] fieldNames = null; + ComponentAccess[] componentAccesses = null; for(DAnnotationAst annotation : constructor.annotations) if(annotation.id.text.equals("@JavaType")) { try { @@ -412,24 +410,24 @@ public class Elaboration { else if(annotation.id.text.equals("@FieldNames")) { try { EListLiteral literal = (EListLiteral)annotation.parameters[0]; - fieldNames = new String[literal.getComponents().length]; - for(int i=0;i properties = new ArrayList(2); public String documentation; public long definitionLocation = Locations.NO_LOCATION; + public String[] parameterNames; public SCLValue(Name name) { this.name = name;