File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed
src/Application/HydraScript.Application.CodeGeneration/Visitors Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -232,17 +232,25 @@ public AddressedInstructions Visit(IfStatement visitable)
232232
233233 public AddressedInstructions Visit ( PrintStatement visitable )
234234 {
235- AddressedInstructions result = [ ] ;
236-
237235 if ( visitable . Expression is PrimaryExpression prim )
238- result . Add ( new AsString ( _valueFactory . Create ( prim . ToValueDto ( ) ) ) ) ;
239- else
240236 {
241- result . AddRange ( visitable . Expression . Accept ( _expressionVisitor ) ) ;
242- var name = result . OfType < Simple > ( ) . Last ( ) . Left ! ;
243- result . Add ( new AsString ( name ) ) ;
237+ var valueDto = prim . ToValueDto ( ) ;
238+ var printedValue = _valueFactory . Create ( valueDto ) ;
239+ IExecutableInstruction instruction = valueDto is { Type : ValueDtoType . Env } or { Type : ValueDtoType . Constant , Value : string }
240+ ? new Print ( printedValue )
241+ : new AsString ( printedValue ) ;
242+ AddressedInstructions shortResult = [ instruction ] ;
243+ if ( instruction is AsString asString )
244+ shortResult . Add ( new Print ( asString . Left ! ) ) ;
245+ return shortResult ;
244246 }
245247
248+ AddressedInstructions result = [ ] ;
249+
250+ result . AddRange ( visitable . Expression . Accept ( _expressionVisitor ) ) ;
251+ var name = result . OfType < Simple > ( ) . Last ( ) . Left ! ;
252+ result . Add ( new AsString ( name ) ) ;
253+
246254 result . Add ( new Print ( ( result [ result . End ] as AsString ) ! . Left ! ) ) ;
247255
248256 return result ;
You can’t perform that action at this time.
0 commit comments