All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.snapscript.core.module.ModuleScopeBinder Maven / Gradle / Ivy

package org.snapscript.core.module;

import org.snapscript.core.Context;
import org.snapscript.core.function.Function;
import org.snapscript.core.scope.Scope;
import org.snapscript.core.stack.ThreadStack;
import org.snapscript.core.type.Type;

public class ModuleScopeBinder {

   public ModuleScopeBinder() {
      super();
   }

   public Scope bind(Scope scope) {
      Module module = scope.getModule();
      Context context = module.getContext();
      ThreadStack stack = context.getStack();
      Function function = stack.current(); // we can determine the function type
      
      if(function != null) {
         Type source = function.getSource();
         
         if(source != null) {
            Scope current = source.getScope();
            
            if(current != null) {
               return current;
            }
         }
      }
      return scope;
   }  
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy