コード例 #1
0
ファイル: TryNode.java プロジェクト: godfat/jruby
 public TryNode(
     RubyContext context,
     SourceSection sourceSection,
     ExceptionTranslatingNode tryPart,
     RescueNode[] rescueParts,
     RubyNode elsePart) {
   super(context, sourceSection);
   this.tryPart = tryPart;
   this.rescueParts = rescueParts;
   this.elsePart = elsePart;
   clearExceptionVariableNode =
       new WriteInstanceVariableNode(
           context,
           sourceSection,
           "$!",
           new ObjectLiteralNode(
               context, sourceSection, context.getCoreLibrary().getGlobalVariablesObject()),
           new ObjectLiteralNode(context, sourceSection, context.getCoreLibrary().getNilObject()),
           true);
 }
コード例 #2
0
ファイル: SequenceNode.java プロジェクト: godfat/jruby
  public static RubyNode sequence(
      RubyContext context, SourceSection sourceSection, List<RubyNode> sequence) {
    final List<RubyNode> flattened = flatten(sequence, true);

    if (flattened.isEmpty()) {
      return new ObjectLiteralNode(context, sourceSection, context.getCoreLibrary().getNilObject());
    } else if (flattened.size() == 1) {
      return flattened.get(0);
    } else {
      return new SequenceNode(
          context, sourceSection, flattened.toArray(new RubyNode[flattened.size()]));
    }
  }