Beispiel #1
0
        /// <summary>
        /// call式のコンパイル
        /// </summary>
        /// <param name="ilgen">IL Generator</param>
        /// <param name="expr">call式</param>
        static void CompileCallStaticExpr(ILGenerator ilgen, MCallStaticExpr expr)
        {
            foreach (var arg in expr.Args)
            {
                CompileExpr(ilgen, arg);
            }

            ilgen.Emit(OpCodes.Call, expr.MethodInfo);
        }
Beispiel #2
0
        /// <summary>
        /// call式の型推論
        /// </summary>
        /// <param name="expr">call式</param>
        static void TypeinfCallStaticExpr(MCallStaticExpr expr)
        {
            foreach (var arg in expr.Args)
            {
                TypeinfExpr(arg);
            }

            var _runtime_dir = RuntimeEnvironment.GetRuntimeDirectory();
            var dll = Assembly.LoadFrom(Path.Combine(_runtime_dir, "mscorlib.dll"));
            var type = dll.GetType(expr.ClassName);

            var arg_types = new List<Type>();
            foreach (var arg in expr.Args)
            {
                arg_types.Add(arg.Type.Reduce());
            }
            var method = type.GetMethod(expr.MethodName, arg_types.ToArray());

            expr.MethodInfo = method;
            expr.Type = new DotNetType(method.ReturnType);
        }