public static void AddMethod( this IEnv env, ValueSymbol klass, string selectorName, IValueFunc func ) { env.AddMethod( klass, ValueSymbol.Intern(selectorName), func ); }
public static void DefineMethod( this IEnv env, ValueSymbol klass, ValueSymbol selector, IValueFunc func, SourceInfo info ) { /*if (env.ContainsMethod(klass, selector)) { throw new RheaException( string.Format( "method is already defined: {0}:{1}", klass.Name.ToIdentifier(), selector.Name.ToIdentifier() ), info ); } env.AddMethod(klass, selector, func);*/ env[klass, selector] = func; }
public bool TryGetMethod(ValueSymbol klass, ValueSymbol selector, out IValueFunc func) { return mInnerEnv.TryGetMethod(klass, selector, out func); }
public void AddMethod(ValueSymbol klass, ValueSymbol selector, IValueFunc func) { mInnerEnv.AddMethod(klass, selector, func); }
public bool TryGetMethod(ValueSymbol klass, ValueSymbol selector, out IValueFunc func) { return mMethods.TryGetValue(MakePair(klass, selector), out func); }
public void AddMethod(ValueSymbol klass, ValueSymbol selector, IValueFunc func) { mMethods.Add(MakePair(klass, selector), func); }
public static IValue SetMethod( this IEnv env, ValueSymbol klass, ValueSymbol selector, IValueFunc func, SourceInfo info ) { while (!env.IsGlobal()) { if (env.ContainsMethod(klass, selector)) { env[klass, selector] = func; return func; } env = env.OuterEnv; } if (env.ContainsMethod(klass, selector)) { env[klass, selector] = func; return func; } throw new RheaException( string.Format( "method is not defined: {0}:{1}", klass.Name.ToIdentifier(), selector.Name.ToIdentifier() ), info ); }
public static bool LookupMethod( this IEnv env, ValueSymbol klass, ValueSymbol selector, out IValueFunc func ) { while (!env.IsGlobal()) { if (env.TryGetMethod(klass, selector, out func)) { return true; } env = env.OuterEnv; } if (env.TryGetMethod(klass, selector, out func)) { return true; } return false; }