From 1b969e34d51e9a17a0038367a29b93c2822495ed Mon Sep 17 00:00:00 2001 From: =?utf8?q?HannuNiemist=C3=B6?= Date: Sun, 9 Sep 2018 23:08:42 +0300 Subject: [PATCH] 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 --- .../common/datatypes/Constructor.java | 3 +- .../scl/compiler/compilation/Elaboration.java | 35 ++++++++++--------- .../compiler/constants/SCLConstructor.java | 26 +++++++------- .../componentaccess/ComponentAccess.java | 12 +++++++ .../componentaccess/FieldComponentAccess.java | 24 +++++++++++++ .../MethodComponentAccess.java | 30 ++++++++++++++++ .../elaboration/expressions/ERecord.java | 12 +++---- .../elaboration/modules/SCLValue.java | 1 + 8 files changed, 104 insertions(+), 39 deletions(-) create mode 100644 bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/constants/componentaccess/ComponentAccess.java create mode 100644 bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/constants/componentaccess/FieldComponentAccess.java create mode 100644 bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/constants/componentaccess/MethodComponentAccess.java 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; -- 2.47.1