From af6589aac9c99c0e25f9ac15aa677157c1620d14 Mon Sep 17 00:00:00 2001 From: Julian Oppermann Date: Tue, 7 Mar 2023 18:37:39 +0800 Subject: [PATCH 1/4] Limited support for register field initializers. --- .../coredsl/analysis/CoreDslAnalyzer.xtend | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/com.minres.coredsl/src/com/minres/coredsl/analysis/CoreDslAnalyzer.xtend b/com.minres.coredsl/src/com/minres/coredsl/analysis/CoreDslAnalyzer.xtend index 6ceff879..8341774e 100644 --- a/com.minres.coredsl/src/com/minres/coredsl/analysis/CoreDslAnalyzer.xtend +++ b/com.minres.coredsl/src/com/minres/coredsl/analysis/CoreDslAnalyzer.xtend @@ -625,6 +625,25 @@ class CoreDslAnalyzer { ctx.acceptError("Cannot implicitly convert " + valueType + " to " + type, declarator, CoreDslPackage.Literals.DECLARATOR__TEQUALS, -1, IssueCodes.InvalidAssignmentType); } + } else if(type.isArrayType) { + val listInitializer = initializer as ListInitializer; + val arrayType = type as ArrayType; + if (arrayType.count != listInitializer.initializers.size) + ctx.acceptError("List initializer size does not match array size", declarator, + CoreDslPackage.Literals.DECLARATOR__TEQUALS, -1, IssueCodes.InvalidAssignmentType); + for (subInitializer : listInitializer.initializers) { + if(subInitializer instanceof ExpressionInitializer) { + val expressionInitializer = subInitializer as ExpressionInitializer; + val valueType = analyzeExpression(ctx, expressionInitializer.value); + if(!CoreDslTypeProvider.canImplicitlyConvert(valueType, arrayType.elementType)) { + ctx.acceptError("Cannot implicitly convert " + valueType + " to " + arrayType.elementType, declarator, + CoreDslPackage.Literals.DECLARATOR__TEQUALS, -1, IssueCodes.InvalidAssignmentType); + } + } else { + ctx.acceptError("Nested listed initializers are currently unsupported", declarator, + CoreDslPackage.Literals.DECLARATOR__TEQUALS, -1, IssueCodes.UnsupportedLanguageFeature); + } + } } else if(type.isStructType) { // TODO list initializers ctx.acceptError("List initializers are currently unsupported ", declarator, From 22daf4d0fae82e373ff3f205a4300537bf789632 Mon Sep 17 00:00:00 2001 From: Julian Oppermann Date: Thu, 9 Mar 2023 14:07:16 +0100 Subject: [PATCH 2/4] Update summary of checks. --- .../src/com/minres/coredsl/analysis/CoreDslAnalyzer.xtend | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/com.minres.coredsl/src/com/minres/coredsl/analysis/CoreDslAnalyzer.xtend b/com.minres.coredsl/src/com/minres/coredsl/analysis/CoreDslAnalyzer.xtend index 8341774e..4d70b56f 100644 --- a/com.minres.coredsl/src/com/minres/coredsl/analysis/CoreDslAnalyzer.xtend +++ b/com.minres.coredsl/src/com/minres/coredsl/analysis/CoreDslAnalyzer.xtend @@ -559,7 +559,9 @@ class CoreDslAnalyzer { /** * 1. Const declarators must be initialized. (UninitializedConstant)
* 2. Alias declarators must fulfill additional requirements.
- * 3. If the declarator uses an expression initializer, the expression's type must be implicitly convertible to the declarator's type. (InvalidAssignmentType)
+ * 3a. If the declarator uses an expression initializer, the expression's type must be implicitly convertible to the declarator's type. (InvalidAssignmentType)
+ * 3b. If an array declarator uses an list initializer, the number of elements in the array type must match the number of elements in the initializer, + * and all elements must be implicitly convertible to array's element type. (InvalidAssignmentType)
* 4. ISA parameters must not be declared as arrays. (InvalidIsaParameterDeclaration)
* 5. Array dimension specifiers must be non-negative constant values. (InvalidArraySize)
* 6. [Warning] Array dimension specifiers should not be zero. (InvalidArraySize) From 1f332395af1b43c037849a015622781ca53b2208 Mon Sep 17 00:00:00 2001 From: Julian Oppermann Date: Tue, 14 Mar 2023 09:03:22 +0100 Subject: [PATCH 3/4] Update com.minres.coredsl/src/com/minres/coredsl/analysis/CoreDslAnalyzer.xtend Co-authored-by: AtomCrafty --- .../src/com/minres/coredsl/analysis/CoreDslAnalyzer.xtend | 3 +++ 1 file changed, 3 insertions(+) diff --git a/com.minres.coredsl/src/com/minres/coredsl/analysis/CoreDslAnalyzer.xtend b/com.minres.coredsl/src/com/minres/coredsl/analysis/CoreDslAnalyzer.xtend index 4d70b56f..def57034 100644 --- a/com.minres.coredsl/src/com/minres/coredsl/analysis/CoreDslAnalyzer.xtend +++ b/com.minres.coredsl/src/com/minres/coredsl/analysis/CoreDslAnalyzer.xtend @@ -641,6 +641,9 @@ class CoreDslAnalyzer { ctx.acceptError("Cannot implicitly convert " + valueType + " to " + arrayType.elementType, declarator, CoreDslPackage.Literals.DECLARATOR__TEQUALS, -1, IssueCodes.InvalidAssignmentType); } + if(isIsaStateElement) { + CoreDslConstantExpressionEvaluator.evaluate(ctx, subInitializer.value); + } } else { ctx.acceptError("Nested listed initializers are currently unsupported", declarator, CoreDslPackage.Literals.DECLARATOR__TEQUALS, -1, IssueCodes.UnsupportedLanguageFeature); From 9dc9fad756f9895d3ebbd6792fcb2d1c614c7978 Mon Sep 17 00:00:00 2001 From: Julian Oppermann Date: Tue, 14 Mar 2023 09:25:04 +0100 Subject: [PATCH 4/4] Nits. --- .../src/com/minres/coredsl/analysis/CoreDslAnalyzer.xtend | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/com.minres.coredsl/src/com/minres/coredsl/analysis/CoreDslAnalyzer.xtend b/com.minres.coredsl/src/com/minres/coredsl/analysis/CoreDslAnalyzer.xtend index def57034..a0dc44b8 100644 --- a/com.minres.coredsl/src/com/minres/coredsl/analysis/CoreDslAnalyzer.xtend +++ b/com.minres.coredsl/src/com/minres/coredsl/analysis/CoreDslAnalyzer.xtend @@ -560,7 +560,7 @@ class CoreDslAnalyzer { * 1. Const declarators must be initialized. (UninitializedConstant)
* 2. Alias declarators must fulfill additional requirements.
* 3a. If the declarator uses an expression initializer, the expression's type must be implicitly convertible to the declarator's type. (InvalidAssignmentType)
- * 3b. If an array declarator uses an list initializer, the number of elements in the array type must match the number of elements in the initializer, + * 3b. If an array declarator uses a list initializer, the number of elements in the array type must match the number of elements in the initializer, * and all elements must be implicitly convertible to array's element type. (InvalidAssignmentType)
* 4. ISA parameters must not be declared as arrays. (InvalidIsaParameterDeclaration)
* 5. Array dimension specifiers must be non-negative constant values. (InvalidArraySize)
@@ -635,8 +635,7 @@ class CoreDslAnalyzer { CoreDslPackage.Literals.DECLARATOR__TEQUALS, -1, IssueCodes.InvalidAssignmentType); for (subInitializer : listInitializer.initializers) { if(subInitializer instanceof ExpressionInitializer) { - val expressionInitializer = subInitializer as ExpressionInitializer; - val valueType = analyzeExpression(ctx, expressionInitializer.value); + val valueType = analyzeExpression(ctx, subInitializer.value); if(!CoreDslTypeProvider.canImplicitlyConvert(valueType, arrayType.elementType)) { ctx.acceptError("Cannot implicitly convert " + valueType + " to " + arrayType.elementType, declarator, CoreDslPackage.Literals.DECLARATOR__TEQUALS, -1, IssueCodes.InvalidAssignmentType); @@ -645,7 +644,7 @@ class CoreDslAnalyzer { CoreDslConstantExpressionEvaluator.evaluate(ctx, subInitializer.value); } } else { - ctx.acceptError("Nested listed initializers are currently unsupported", declarator, + ctx.acceptError("Nested list initializers are unsupported", declarator, CoreDslPackage.Literals.DECLARATOR__TEQUALS, -1, IssueCodes.UnsupportedLanguageFeature); } }