Exemple #1
0
 public static void AddMethod(
     this IEnv env,
     ValueSymbol klass,
     string selectorName,
     IValueFunc func
 )
 {
     env.AddMethod(
         klass, ValueSymbol.Intern(selectorName), func
     );
 }
Exemple #2
0
 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;
 }
Exemple #3
0
 public bool TryGetMethod(ValueSymbol klass, ValueSymbol selector, out IValueFunc func)
 {
     return mInnerEnv.TryGetMethod(klass, selector, out func);
 }
Exemple #4
0
 public void AddMethod(ValueSymbol klass, ValueSymbol selector, IValueFunc func)
 {
     mInnerEnv.AddMethod(klass, selector, func);
 }
Exemple #5
0
 public bool TryGetMethod(ValueSymbol klass, ValueSymbol selector, out IValueFunc func)
 {
     return mMethods.TryGetValue(MakePair(klass, selector), out func);
 }
Exemple #6
0
 public void AddMethod(ValueSymbol klass, ValueSymbol selector, IValueFunc func)
 {
     mMethods.Add(MakePair(klass, selector), func);
 }
Exemple #7
0
 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
     );
 }
Exemple #8
0
 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;
 }