LexicalScope.java

  1. /*
  2.  * Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved. This
  3.  * code is released under a tri EPL/GPL/LGPL license. You can use it,
  4.  * redistribute it and/or modify it under the terms of the:
  5.  *
  6.  * Eclipse Public License version 1.0
  7.  * GNU General Public License version 2
  8.  * GNU Lesser General Public License version 2.1
  9.  */
  10. package org.jruby.truffle.runtime;

  11. import org.jruby.truffle.runtime.core.RubyModule;

  12. public class LexicalScope {
  13.     public static final LexicalScope NONE = null;

  14.     private final LexicalScope parent;
  15.     private RubyModule liveModule;

  16.     public LexicalScope(LexicalScope parent, RubyModule liveModule) {
  17.         this.parent = parent;
  18.         this.liveModule = liveModule;
  19.     }

  20.     public LexicalScope(LexicalScope parent) {
  21.         this(parent, null);
  22.     }

  23.     public LexicalScope getParent() {
  24.         return parent;
  25.     }

  26.     public RubyModule getLiveModule() {
  27.         return liveModule;
  28.     }

  29.     public void setLiveModule(RubyModule liveModule) {
  30.         this.liveModule = liveModule;
  31.     }

  32.     @Override
  33.     public String toString() {
  34.         return " :: " + liveModule + (parent == null ? "" : parent.toString());
  35.     }
  36. }