@@ -35,19 +35,6 @@ export function PyCSEResultPromise(context: PyContext, value: Value): Promise<Re
3535 } ) ;
3636}
3737
38- function mapOperatorToPyOperator ( operatorToken : Token ) : TokenType | string {
39- switch ( operatorToken . type ) {
40- case TokenType . PLUS : return '__py_adder' ;
41- case TokenType . MINUS : return '__py_minuser' ;
42- case TokenType . STAR : return '__py_multiplier' ;
43- case TokenType . SLASH : return '__py_divider' ;
44- case TokenType . PERCENT : return '__py_modder' ;
45- case TokenType . DOUBLESTAR : return '__py_powerer' ;
46- // Add other arithmetic operators as needed
47- default : return operatorToken . type ; // For comparison and unary operators
48- }
49- }
50-
5138export function PyEvaluate ( code : string , program : StmtNS . Stmt , context : PyContext , options : IOptions ) : Value {
5239 context . control = new PyControl ( program ) ;
5340 context . runtime . isRunning = true ;
@@ -131,8 +118,7 @@ const pyCmdEvaluators: { [type: string]: CmdEvaluator } = {
131118
132119 'Binary' : ( command , context , control ) => {
133120 const binary = command as ExprNS . Binary ;
134- const opStr = mapOperatorToPyOperator ( binary . operator ) ;
135- const op_instr = instr . binOpInstr ( opStr , binary ) ;
121+ const op_instr = instr . binOpInstr ( binary . operator . type , binary ) ;
136122 control . push ( op_instr ) ;
137123 control . push ( binary . right ) ;
138124 control . push ( binary . left ) ;
@@ -167,8 +153,7 @@ const pyCmdEvaluators: { [type: string]: CmdEvaluator } = {
167153 'Compare' : ( command , context , control , stash , isPrelude ) => {
168154 const compareNode = command as ExprNS . Compare ;
169155 // For now, we only handle simple, single comparisons.
170- const opStr = mapOperatorToPyOperator ( compareNode . operator ) ;
171- const op_instr = instr . binOpInstr ( opStr , compareNode ) ;
156+ const op_instr = instr . binOpInstr ( compareNode . operator . type , compareNode ) ;
172157 control . push ( op_instr ) ;
173158 control . push ( compareNode . right ) ;
174159 control . push ( compareNode . left ) ;
0 commit comments