Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce external trait decorators and implement rudimentary externa…
…l struct system
- Loading branch information
Matthew Ross Rachar
committed
Sep 2, 2019
1 parent
7d14c58
commit 956a427
Showing
24 changed files
with
302 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// Created by matthewross on 31/08/19. | ||
// | ||
|
||
import Foundation | ||
import AST | ||
|
||
extension TraitDeclaration { | ||
var moduleAddress: String? { | ||
guard let argument: FunctionArgument = decorators.first(where: { $0.identifier.name == "module" })?.arguments[0], | ||
let name = argument.identifier?.name, | ||
name == "address", | ||
case .literal(let token) = argument.expression, | ||
case .literal(.address(let address)) = token.kind else { | ||
return nil | ||
} | ||
return address | ||
} | ||
|
||
var isModule: Bool { | ||
return decorators.contains(where: { $0.identifier.name == "module" }) | ||
} | ||
|
||
var associatedModule: String? { | ||
guard let argument = decorators.first(where: { $0.identifier.name == "associated" })?.arguments[0], | ||
let name = argument.identifier?.name, | ||
name == "", | ||
case .identifier(let identifier) = argument.expression else { | ||
return nil | ||
} | ||
return identifier.name | ||
} | ||
|
||
var isStruct: Bool { | ||
return decorators.contains(where: { $0.identifier.name == "data" }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.