org.jruby.embed.variable
Class VariableInterceptor

java.lang.Object
  extended by org.jruby.embed.variable.VariableInterceptor

public class VariableInterceptor
extends java.lang.Object

This class is responsible to local variable behavior dependent processing.

Author:
Yoko Harada

Constructor Summary
VariableInterceptor()
           
 
Method Summary
static BiVariable getVariableInstance(LocalVariableBehavior behavior, RubyObject receiver, java.lang.String name, java.lang.Object... value)
          Returns an appropriate type of a variable instance to the specified local variable behavior.
static void inject(BiVariableMap map, Ruby runtime, ManyVarsDynamicScope scope, int depth, IRubyObject receiver)
          Injects variable values from Java to Ruby just before an evaluation or method invocation.
static boolean isKindOfRubyVariable(LocalVariableBehavior behavior, java.lang.String name)
          Checks the given name is whether a legal Ruby variable/constant name or not.
static void retrieve(LocalVariableBehavior behavior, BiVariableMap map, RubyObject receiver)
          Retrieves variable/constant names and values after the evaluation or method invocation.
static void terminateGlobalVariables(LocalVariableBehavior behavior, java.util.List<BiVariable> variables, Ruby runtime)
          Clears global variable values from Ruby runtime to behave the same as JSR 223 reference implementation.
static void terminateLocalVariables(LocalVariableBehavior behavior, java.util.List<java.lang.String> varNames, java.util.List<BiVariable> variables)
          Clears local variables form the variable map so that old local variable name-value pairs are not to be used in successive evaluations.
static void tryLazyRetrieval(LocalVariableBehavior behavior, BiVariableMap map, IRubyObject receiver, java.lang.Object key)
          Retrieves specified variable/constant name and value after the evaluation or method invocation only when it is requested.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VariableInterceptor

public VariableInterceptor()
Method Detail

getVariableInstance

public static BiVariable getVariableInstance(LocalVariableBehavior behavior,
                                             RubyObject receiver,
                                             java.lang.String name,
                                             java.lang.Object... value)
Returns an appropriate type of a variable instance to the specified local variable behavior.

Parameters:
runtime - Ruby runtime
name - variable name
value - variable value
Returns:
an appropriate type of the variable instance.

inject

public static void inject(BiVariableMap map,
                          Ruby runtime,
                          ManyVarsDynamicScope scope,
                          int depth,
                          IRubyObject receiver)
Injects variable values from Java to Ruby just before an evaluation or method invocation.

Parameters:
map - a variable map that has name-value pairs to be injected
runtime - Ruby runtime
scope - scope to inject local variable values
depth - depth of a frame to inject local variable values
receiver - a receiver when the script has been evaluated once

retrieve

public static void retrieve(LocalVariableBehavior behavior,
                            BiVariableMap map,
                            RubyObject receiver)
Retrieves variable/constant names and values after the evaluation or method invocation.

Parameters:
map - variable map that holds retrieved name-value pairs.
runtime - Ruby runtime
receiver - a receiver when the script has been evaluated once

tryLazyRetrieval

public static void tryLazyRetrieval(LocalVariableBehavior behavior,
                                    BiVariableMap map,
                                    IRubyObject receiver,
                                    java.lang.Object key)
Retrieves specified variable/constant name and value after the evaluation or method invocation only when it is requested.

Parameters:
map - variable map that holds retrieved name-value pairs.
runtime - Ruby runtime
receiver - a receiver when the script has been evaluated once

terminateGlobalVariables

public static void terminateGlobalVariables(LocalVariableBehavior behavior,
                                            java.util.List<BiVariable> variables,
                                            Ruby runtime)
Clears global variable values from Ruby runtime to behave the same as JSR 223 reference implementation.

Parameters:
variables - a variable list to be cleared from Ruby runtime
runtime - Ruby runtime

terminateLocalVariables

public static void terminateLocalVariables(LocalVariableBehavior behavior,
                                           java.util.List<java.lang.String> varNames,
                                           java.util.List<BiVariable> variables)
Clears local variables form the variable map so that old local variable name-value pairs are not to be used in successive evaluations.

Parameters:
varNames - variable name list to be cleared
variables - variable value list to be cleared

isKindOfRubyVariable

public static boolean isKindOfRubyVariable(LocalVariableBehavior behavior,
                                           java.lang.String name)
Checks the given name is whether a legal Ruby variable/constant name or not.

Parameters:
name - a given name to be checked
Returns:
true when the name is a legal Ruby variable/constant name, otherwise false.


Copyright © 2002-2009 JRuby Team. All Rights Reserved.