Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Grammar] Types #44

Merged
merged 3 commits into from
May 4, 2022
Merged

[Grammar] Types #44

merged 3 commits into from
May 4, 2022

Conversation

AtomCrafty
Copy link
Contributor

Implements suggestions 10, 11, and 12 from #39 and fixes #23.

Structure Changes

  • User types can no longer be defined within a type specifier
    • They are instead declared within the architectural_state section
    • 6 relevant classes: {Struct|Union|Enum}TypeSpecifier pointing to {Struct|Union|Enum}TypeDeclaration
  • Simplified function declaration grammar
    • It is now syntactically valid to specify extern on a function with body, or omit the body of a non-extern function
    • Attributes are now valid on extern functions
  • Removed support for designated initializers

Name Changes

Old Class Old Field New Class New Field
CoreDef contributingType CoreDef providedInstructionSets
FunctionDefinition type FunctionDefinition returnType
ExpressionInitializer expr ExpressionInitializer value
BitField left BitField startIndex
BitField right BitField endIndex
Field EncodingField

@@ -481,7 +496,7 @@ class Visualizer {
}

private def dispatch VisualNode genNode(StringLiteral node) {
return makeImmediateLiteral(node.value)
return makeImmediateLiteral(node.value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine for now, but a point for #10 -- Consistent use of semicolons in Xtend code.

Comment on lines -215 to +223
def dispatch Iterable<Declarator> directDeclarations(CompositeTypeSpecifier spec) {
if (spec.declarations.size > 0)
spec.declarations.directDeclarations
else {
val specifier = spec.eContainer.findCompositeType([
CompositeTypeSpecifier d|d.name!==null?d.name==spec.name:false
])
specifier===null?#[]:specifier.declarations.directDeclarations
}
def dispatch Iterable<Declarator> directDeclarations(UserTypeSpecifier spec) {
switch(spec) {
case StructTypeSpecifier: return (spec as StructTypeSpecifier).target.members.flatMap[it.declarators]
case UnionTypeSpecifier: return (spec as UnionTypeSpecifier).target.members.flatMap[it.declarators]
case EnumTypeSpecifier: return #[]
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much appreciated code simplification here.

@jopperm jopperm merged commit 469721d into Minres:develop May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants