Examples of DStrNode


Examples of org.jruby.ast.DStrNode

        context.createNewRegexp(createStringCallback, dregexpNode.getOptions());
    }

    public void compileDStr(Node node, BodyCompiler context) {
        final DStrNode dstrNode = (DStrNode) node;

        ArrayCallback dstrCallback = new ArrayCallback() {

                    public void nextValue(BodyCompiler context, Object sourceArray,
                            int index) {
                        compile(dstrNode.get(index), context);
                    }
                };
        context.createNewString(dstrCallback, dstrNode.size());
    }
View Full Code Here

Examples of org.jruby.ast.DStrNode

              }
  break;
case 372:
          // line 1362 "DefaultRubyParser.y"
  {
                  yyVal = ((Node)yyVals[0+yyTop]) instanceof EvStrNode ? new DStrNode(getPosition(((Node)yyVals[0+yyTop]))).add(((Node)yyVals[0+yyTop])) : ((Node)yyVals[0+yyTop]);
        }
  break;
case 374:
          // line 1368 "DefaultRubyParser.y"
  {
                  yyVal = support.literal_concat(getPosition(((Node)yyVals[-1+yyTop])), ((Node)yyVals[-1+yyTop]), ((Node)yyVals[0+yyTop]));
              }
  break;
case 375:
          // line 1373 "DefaultRubyParser.y"
  {
                  yyVal = ((Node)yyVals[-1+yyTop]);
                  ((ISourcePositionHolder)yyVal).setPosition(support.union(((Token)yyVals[-2+yyTop]), ((Token)yyVals[0+yyTop])));
      int extraLength = ((String) ((Token)yyVals[-2+yyTop]).getValue()).length() - 1;

                  /* We may need to subtract addition offset off of first */
      /* string fragment (we optimistically take one off in*/
      /* ParserSupport.literal_concat).  Check token length*/
      /* and subtract as neeeded.*/
      if ((((Node)yyVals[-1+yyTop]) instanceof DStrNode) && extraLength > 0) {
         Node strNode = ((DStrNode)((Node)yyVals[-1+yyTop])).get(0);
         assert strNode != null;
         strNode.getPosition().adjustStartOffset(-extraLength);
      }
              }
  break;
case 376:
          // line 1390 "DefaultRubyParser.y"
  {
                  ISourcePosition position = support.union(((Token)yyVals[-2+yyTop]), ((Token)yyVals[0+yyTop]));

      if (((Node)yyVals[-1+yyTop]) == null) {
          yyVal = new XStrNode(position, null);
      } else if (((Node)yyVals[-1+yyTop]) instanceof StrNode) {
                      yyVal = new XStrNode(position, (ByteList) ((StrNode)yyVals[-1+yyTop]).getValue().clone());
      } else if (((Node)yyVals[-1+yyTop]) instanceof DStrNode) {
                      yyVal = new DXStrNode(position, ((DStrNode)yyVals[-1+yyTop]));

                      ((Node)yyVal).setPosition(position);
                  } else {
                      yyVal = new DXStrNode(position).add(((Node)yyVals[-1+yyTop]));
      }
              }
  break;
case 377:
          // line 1407 "DefaultRubyParser.y"
  {
      int options = ((RegexpNode)yyVals[0+yyTop]).getOptions();
      Node node = ((Node)yyVals[-1+yyTop]);

      if (node == null) {
                      yyVal = new RegexpNode(getPosition(((Token)yyVals[-2+yyTop])), ByteList.create(""), options & ~ReOptions.RE_OPTION_ONCE);
      } else if (node instanceof StrNode) {
                      yyVal = new RegexpNode(((Node)yyVals[-1+yyTop]).getPosition(), (ByteList) ((StrNode) node).getValue().clone(), options & ~ReOptions.RE_OPTION_ONCE);
      } else if (node instanceof DStrNode) {
                      yyVal = new DRegexpNode(getPosition(((Token)yyVals[-2+yyTop])), (DStrNode) node, options, (options & ReOptions.RE_OPTION_ONCE) != 0);
      } else {
          yyVal = new DRegexpNode(getPosition(((Token)yyVals[-2+yyTop])), options, (options & ReOptions.RE_OPTION_ONCE) != 0).add(node);
                  }
         }
  break;
case 378:
          // line 1423 "DefaultRubyParser.y"
  {
                   yyVal = new ZArrayNode(support.union(((Token)yyVals[-2+yyTop]), ((Token)yyVals[0+yyTop])));
         }
  break;
case 379:
          // line 1426 "DefaultRubyParser.y"
  {
       yyVal = ((ListNode)yyVals[-1+yyTop]);
                   ((ISourcePositionHolder)yyVal).setPosition(support.union(((Token)yyVals[-2+yyTop]), ((Token)yyVals[0+yyTop])));
         }
  break;
case 380:
          // line 1432 "DefaultRubyParser.y"
  {
                   yyVal = new ArrayNode(getPosition(null));
         }
  break;
case 381:
          // line 1435 "DefaultRubyParser.y"
  {
                   yyVal = ((ListNode)yyVals[-2+yyTop]).add(((Node)yyVals[-1+yyTop]) instanceof EvStrNode ? new DStrNode(getPosition(((ListNode)yyVals[-2+yyTop]))).add(((Node)yyVals[-1+yyTop])) : ((Node)yyVals[-1+yyTop]));
         }
  break;
case 383:
          // line 1440 "DefaultRubyParser.y"
  {
View Full Code Here

Examples of org.jruby.ast.DStrNode

    public Node literal_concat(ISourcePosition position, Node head, Node tail) {
        if (head == null) return tail;
        if (tail == null) return head;
       
        if (head instanceof EvStrNode) {
            head = new DStrNode(union(head.getPosition(), position)).add(head);
        }

        if (tail instanceof StrNode) {
            if (head instanceof StrNode) {
              return new StrNode(union(head, tail), (StrNode) head, (StrNode) tail);
            }
            head.setPosition(union(head, tail));
            return ((ListNode) head).add(tail);
         
        } else if (tail instanceof DStrNode) {
            if (head instanceof StrNode){
                ((DStrNode)tail).prepend(head);
                return tail;
            }

            return ((ListNode) head).addAll(tail);
        }

        // tail must be EvStrNode at this point
        if (head instanceof StrNode) {
         
            //Do not add an empty string node
            if(((StrNode) head).getValue().length() == 0) {
                head = new DStrNode(head.getPosition());
            } else {
                // All first element StrNode's do not include syntacical sugar.
                head.getPosition().adjustStartOffset(-1);
                head = new DStrNode(head.getPosition()).add(head);
            }
        }
        return ((DStrNode) head).add(tail);
    }
View Full Code Here

Examples of org.jruby.ast.DStrNode

            }
        }
    }

    public void compileDStr(Node node, BodyCompiler context, boolean expr) {
        final DStrNode dstrNode = (DStrNode) node;

        ArrayCallback dstrCallback = new ArrayCallback() {

                    public void nextValue(BodyCompiler context, Object sourceArray,
                            int index) {
                        compile(dstrNode.get(index), context, true);
                    }
                };

        if (expr) {
            context.createNewString(dstrCallback, dstrNode.size());
        } else {
            // not an expression, only compile the elements
            for (Node nextNode : dstrNode.childNodes()) {
                compile(nextNode, context, false);
            }
        }
    }
View Full Code Here

Examples of org.jruby.ast.DStrNode

                "identifier " + (String) lhs.getValue() + " is not valid to set", lhs.getValue());
    }

    @Override
    public DStrNode createDStrNode(ISourcePosition position) {
        return new DStrNode(position, lexer.getEncoding());
    }
View Full Code Here

Examples of org.jruby.ast.DStrNode

    public void setLexer(RubyYaccLexer lexer) {
        this.lexer = lexer;
    }

    public DStrNode createDStrNode(ISourcePosition position) {
        return new DStrNode(position);
    }
View Full Code Here

Examples of org.jruby.ast.DStrNode

            ByteList meat = (ByteList) ((StrNode) contents).getValue().clone();
            regexpFragmentCheck(end, meat);
            checkRegexpSyntax(meat, options.withoutOnce());
            return new RegexpNode(contents.getPosition(), meat, options.withoutOnce());
        } else if (contents instanceof DStrNode) {
            DStrNode dStrNode = (DStrNode) contents;

            for (Node fragment: dStrNode.childNodes()) {
                if (fragment instanceof StrNode) {
                    regexpFragmentCheck(end, ((StrNode) fragment).getValue());
                }
            }
           
View Full Code Here

Examples of org.jruby.ast.DStrNode

                "identifier " + (String) lhs.getValue() + " is not valid to set", lhs.getValue());
    }

    @Override
    public DStrNode createDStrNode(ISourcePosition position) {
        return new DStrNode(position, lexer.getEncoding());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.