private void EmitEntryPoint(Seq <JST.Statement> body) { var entryPoint = assmEnv.Assembly.EntryPoint; if (entryPoint != null) { var methEnv = entryPoint.EnterMethod(assmEnv); if (!methEnv.Method.IsStatic) { throw new InvalidOperationException("instance methods cannot be an entry point"); } if (methEnv.Method.IsConstructor) { throw new InvalidOperationException("constructors cannot be an entry point"); } if (methEnv.Type.Arity > 0) { throw new InvalidOperationException("methods of higher-kinded types cannot be an entry point"); } if (methEnv.Method.TypeArity > 0) { throw new InvalidOperationException("polymorphic methods cannot be an entry point"); } if (methEnv.Method.Arity > 0) { throw new InvalidOperationException("entry point method cannot accept arguments"); } var innerNameSupply = NameSupply.Fork(); var func = new JST.FunctionExpression (null, new JST.Statements(new JST.ExpressionStatement (MethodCallExpression(entryPoint, innerNameSupply, false, new Seq <JST.Expression>())))); if (Env.DebugMode) { body.Add(new JST.CommentStatement("Assembly entry point")); } body.Add(JST.Statement.DotAssignment(assemblyId.ToE(), Constants.AssemblyEntryPoint, func)); } }
public TypeCompilerEnvironment EnterFunction() { var res = new TypeCompilerEnvironment (Global, SkolemDefs, Assembly, Type, TypeBoundArguments, env, NameSupply.Fork(), rootId, assemblyId, typeId, TypeBoundTypeParameterIds, typeTrace); res.InheritBindings(this); return(res); }