@@ -441,6 +441,7 @@ impl TryFrom<ScalarExpr> for Expr {
441441 Err ( InvalidExprError :: BoundedSymbolAccess ( expr. span ( ) ) )
442442 }
443443 ScalarExpr :: Let ( expr) => Ok ( Self :: Let ( expr) ) ,
444+ ScalarExpr :: BusOperation ( _) => todo ! ( ) ,
444445 }
445446 }
446447}
@@ -489,6 +490,8 @@ pub enum ScalarExpr {
489490 /// binary expressions or function calls to a block of statements, and only when the result
490491 /// of evaluating the `let` produces a valid scalar expression.
491492 Let ( Box < Let > ) ,
493+ /// A bus operation
494+ BusOperation ( BusOperation ) ,
492495}
493496impl ScalarExpr {
494497 /// Returns true if this is a constant value
@@ -523,6 +526,7 @@ impl ScalarExpr {
523526 } ,
524527 Self :: Call ( ref expr) => Ok ( expr. ty ) ,
525528 Self :: Let ( ref expr) => Ok ( expr. ty ( ) ) ,
529+ Self :: BusOperation ( _) => todo ! ( ) ,
526530 }
527531 }
528532}
@@ -579,6 +583,7 @@ impl fmt::Debug for ScalarExpr {
579583 Self :: Binary ( ref expr) => f. debug_tuple ( "Binary" ) . field ( expr) . finish ( ) ,
580584 Self :: Call ( ref expr) => f. debug_tuple ( "Call" ) . field ( expr) . finish ( ) ,
581585 Self :: Let ( ref expr) => write ! ( f, "{:#?}" , expr) ,
586+ Self :: BusOperation ( ref expr) => f. debug_tuple ( "BusOp" ) . field ( expr) . finish ( ) ,
582587 }
583588 }
584589}
@@ -598,6 +603,7 @@ impl fmt::Display for ScalarExpr {
598603 } ;
599604 write ! ( f, "{display}" )
600605 }
606+ Self :: BusOperation ( ref expr) => write ! ( f, "{}" , expr) ,
601607 }
602608 }
603609}
@@ -1256,6 +1262,53 @@ impl fmt::Display for ListComprehension {
12561262 }
12571263}
12581264
1265+ #[ derive( Clone , Spanned ) ]
1266+ pub struct BusOperation {
1267+ #[ span]
1268+ pub span : SourceSpan ,
1269+ pub bus : ResolvableIdentifier ,
1270+ pub op : BusOperator ,
1271+ pub args : Vec < Expr > ,
1272+ }
1273+
1274+ impl BusOperation {
1275+ pub fn new ( span : SourceSpan , bus : Identifier , op : BusOperator , args : Vec < Expr > ) -> Self {
1276+ Self {
1277+ span,
1278+ bus : ResolvableIdentifier :: Unresolved ( NamespacedIdentifier :: Bus ( bus) ) ,
1279+ op,
1280+ args,
1281+ }
1282+ }
1283+ }
1284+
1285+ impl Eq for BusOperation { }
1286+ impl PartialEq for BusOperation {
1287+ fn eq ( & self , other : & Self ) -> bool {
1288+ self . bus == other. bus && self . args == other. args && self . op == other. op
1289+ }
1290+ }
1291+ impl fmt:: Debug for BusOperation {
1292+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1293+ f. debug_struct ( "BusOperation" )
1294+ . field ( "bus" , & self . bus )
1295+ . field ( "op" , & self . op )
1296+ . field ( "args" , & self . args )
1297+ . finish ( )
1298+ }
1299+ }
1300+ impl fmt:: Display for BusOperation {
1301+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1302+ write ! (
1303+ f,
1304+ "{}{}{}" ,
1305+ self . bus,
1306+ self . op,
1307+ DisplayTuple ( self . args. as_slice( ) )
1308+ )
1309+ }
1310+ }
1311+
12591312/// Represents a function call (either a pure function or an evaluator).
12601313///
12611314/// Calls are permitted in a scalar expression context, but arguments to the
0 commit comments