// 注册类里面的函数 public static void Import(Type type, VM vm) { var methods = type.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); foreach (var method in methods) { foreach (var attr in method.GetCustomAttributes <ExtFuncAttribute>()) { var f = new ExtFuncWrap(method, attr); Register(f, vm); } } // todo }
public static void Register(ExtFuncWrap func_wrap, VM vm) { var that_type = func_wrap.that_type; if (that_type == null) { // global, todo split name vm.global_table[func_wrap.name] = func_wrap; } else { ExtContain contain; if (ext_types.TryGetValue(func_wrap.that_type, out contain) == false) { contain = new ExtContain(func_wrap.that_type); ext_types.Add(func_wrap.that_type, contain); } contain.Register(func_wrap.name, func_wrap); } }