public static void ImportStaticMembers(this BindingSourceTable targets, Type fromType)
        {
            var members = fromType.GetMembers(BindingFlags.Public | BindingFlags.Static);

            foreach (var member in members)
            {
                if (targets.ContainsKey(member.Name))
                {
                    //do not import overloaded methods several times
                    continue;
                }
                switch (member.MemberType)
                {
                case MemberTypes.Method:
                    targets.Add(member.Name, new ClrMethodBindingTargetInfo(fromType, member.Name));
                    break;

                case MemberTypes.Property:
                    targets.Add(member.Name, new ClrPropertyBindingTargetInfo(member as PropertyInfo, null));
                    break;

                case MemberTypes.Field:
                    targets.Add(member.Name, new ClrFieldBindingTargetInfo(member as FieldInfo, null));
                    break;
                }
            }
        }
        //Method for adding methods to BuiltIns table in Runtime
        public static BindingTargetInfo AddSpecialForm(this BindingSourceTable targets, SpecialForm form, string formName,
                                                       int minChildCount = 0, int maxChildCount = 0, string parameterNames = null)
        {
            var formInfo = new SpecialFormBindingInfo(formName, form, minChildCount, maxChildCount, parameterNames);

            targets.Add(formName, formInfo);
            return(formInfo);
        }
Beispiel #3
0
        public static BindingTargetInfo AddMethod(this BindingSourceTable targets, BuiltInMethod method, string methodName,
                                                  int minParamCount = 0, int maxParamCount = 0, string parameterNames = null)
        {
            var callTarget = new BuiltInCallTarget(method, methodName, minParamCount, maxParamCount, parameterNames);
            var targetInfo = new BuiltInCallableTargetInfo(callTarget);

            targets.Add(methodName, targetInfo);
            return(targetInfo);
        }