42
42
import org .truffleruby .language .RubyNode ;
43
43
import org .truffleruby .language .RubyRootNode ;
44
44
import org .truffleruby .language .RubyTopLevelRootNode ;
45
- import org .truffleruby .language .SourceIndexLength ;
46
45
import org .truffleruby .language .arguments .EmptyArgumentsDescriptor ;
47
46
import org .truffleruby .language .arguments .ProfileArgumentNodeGen ;
48
47
import org .truffleruby .language .arguments .ReadSelfNode ;
117
116
import java .util .Deque ;
118
117
import java .util .List ;
119
118
120
- // NOTE: we should avoid SourceIndexLength in YARPTranslator, instead pass a Nodes.Node as location,
121
- // because that's inefficient and there is typically no need for such an object since YARP location info is correct.
119
+ // NOTE: we should avoid SourceIndexLength in YARPTranslator, instead pass a Nodes.Node as location, because
120
+ // * it does not copy the newline flag properly,
121
+ // * it is inefficient,
122
+ // * there is typically no need for such an object since YARP location info is correct.
122
123
123
124
/** Translate (or convert) AST provided by a parser (YARP parser) to Truffle AST */
124
125
public final class YARPTranslator extends AbstractNodeVisitor <RubyNode > {
@@ -1017,24 +1018,23 @@ public RubyNode visitLocalVariableOperatorWriteNode(Nodes.LocalVariableOperatorW
1017
1018
}
1018
1019
1019
1020
public RubyNode visitLocalVariableReadNode (Nodes .LocalVariableReadNode node ) {
1020
- final SourceIndexLength sourceSection = new SourceIndexLength (node .startOffset , node .length );
1021
1021
final String name = toString (node );
1022
1022
1023
- final RubyNode rubyNode = environment .findLocalVarNode (name , sourceSection );
1023
+ final RubyNode rubyNode = environment .findLocalVarNode (name , null );
1024
1024
assert rubyNode != null : name ;
1025
1025
1026
+ assignNodePositionInSource (node , rubyNode );
1026
1027
return rubyNode ;
1027
1028
}
1028
1029
1029
1030
public RubyNode visitLocalVariableWriteNode (Nodes .LocalVariableWriteNode node ) {
1030
- final SourceIndexLength sourceSection = new SourceIndexLength (node .startOffset , node .length );
1031
1031
final String name = toString (node .name_loc );
1032
1032
1033
1033
if (environment .getNeverAssignInParentScope ()) {
1034
1034
environment .declareVar (name );
1035
1035
}
1036
1036
1037
- ReadLocalNode lhs = environment .findLocalVarNode (name , sourceSection );
1037
+ ReadLocalNode lhs = environment .findLocalVarNode (name , null );
1038
1038
1039
1039
// TODO: it should always be present if we use byte[][] locals
1040
1040
if (lhs == null ) {
@@ -1044,7 +1044,7 @@ public RubyNode visitLocalVariableWriteNode(Nodes.LocalVariableWriteNode node) {
1044
1044
}
1045
1045
environmentToDeclareIn .declareVar (name );
1046
1046
1047
- lhs = environment .findLocalVarNode (name , sourceSection );
1047
+ lhs = environment .findLocalVarNode (name , null );
1048
1048
1049
1049
if (lhs == null ) {
1050
1050
throw CompilerDirectives .shouldNotReachHere ();
0 commit comments