compiler, runtime, common, documentation: Refactor Type System
The type system (and the value system) now include attributes for each type (things like direction, const-ness). Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
@@ -214,7 +214,7 @@ extension VariableDeclarationStatement: CompilableStatement {
|
||||
return .Error(maybe_parsed_rvalue.error()!)
|
||||
}
|
||||
|
||||
if parsed_rvalue.type().eq(rhs: declaration_p4_type) {
|
||||
if parsed_rvalue.type().eq(declaration_p4_type) {
|
||||
initializer = parsed_rvalue
|
||||
} else {
|
||||
return Result.Error(
|
||||
@@ -231,8 +231,9 @@ extension VariableDeclarationStatement: CompilableStatement {
|
||||
// Context with updated names to include the newly declared name.
|
||||
context.update(
|
||||
newInstances: context.instances.declare(
|
||||
identifier: parsed_variablename, withValue: P4TypeAttributed(declaration_p4_type, [])))
|
||||
))
|
||||
identifier: parsed_variablename, withValue: declaration_p4_type))
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,7 +312,7 @@ extension ReturnStatement: CompilableStatement {
|
||||
|
||||
return switch Expression.Compile(node: expression_node, withContext: context) {
|
||||
case .Ok(let result):
|
||||
if result.type().eq(rhs: context.expected_type!) {
|
||||
if result.type().eq(context.expected_type!) {
|
||||
.Ok((ReturnStatement(result), context))
|
||||
} else {
|
||||
.Error(
|
||||
|
||||
Reference in New Issue
Block a user