Forums

problem instanciating the compiler

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

problem instanciating the compiler

Postby gauthier » Wed Dec 17, 2008 9:38 am

Can anyone help with this problem:

class Test
def main is shared
cobra = Compiler()


compiling with

Code: Select all
cobra -ref:cobra.exe -ref:Cobra.Lang.dll test.cobra


generate an internal error:
Code: Select all
(empty)(1): error: COBRA INTERNAL ERROR / RequireException / ; sourceSite = C:\home\dev\src\dotnet\projects\cobralanguage\Source\Container.cobra:148 in NameSpace.addDecl for object NameSpace-sh(5236, name=Lang, didBindInh=false, didBindInt=false, didBindImp=false, token=Token.empty, subCount=0, isUnified=true, didBindUse=false, superNameSpace=NameSpace-mi(5234, name=Cobra, didBindInh=false, didBindInt=false, didBindImp=false, token=Token.empty, subCount=1, isUnified=true, didBindUse=false, 5234), unifiedNameSpace=nil, 5236); info       = nil; this       = NameSpace-de(5236, name=Lang, didBindInh=false, didBindInt=false, didBindImp=false, token=Token.empty, subCount=0, isUnified=true, didBindUse=false, superNameSpace=NameSpace-mi(5234, name=Cobra, didBindInh=false, didBindInt=false, didBindImp=false, token=Token.empty, subCount=1, isUnified=true, didBindUse=false, 5234), unifiedNameSpace=nil, declsInOrder=['Class'-'sh'(5237, 'name'='CobraCore', 'didBindInh'=false, 'didBindInt'=false, 'didBindImp'=false, 'token'='Token.empty', 'd
Compilation failed - 1 error, 0 warnings
Not running due to errors above.


Thanks!
gauthier
 
Posts: 116

Re: problem instanciating the compiler

Postby Charles » Wed Dec 17, 2008 10:23 am

I tried a few things and had problems as well, though not necessarily the same as you show here. I'll have to look at it more later.

In the mean time, can you get along with CobraCore.runCobraExe? Search for "def runCobra" in <workspace>\Cobra.Lang\CobraCore.cobra.

What were you planning on doing with the compiler, once you got it? :-)
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: problem instanciating the compiler

Postby gauthier » Wed Dec 17, 2008 10:35 am

Thanks I'll try that.

I'm working on the CodeDom provider for cobra (in cobra), (first peek at CodeDom here), I'm currently getting aspx code "almost" generated and I would like to trig the compiler to complete the pipeline before committing to write test for what fails.

I think I will have some basic issues with member name "cobraification" as well as with everything I've left "almost" done during the initial implementation (well a whole bunch for now ;))
gauthier
 
Posts: 116

Re: problem instanciating the compiler

Postby Charles » Wed Dec 17, 2008 10:51 am

Well if you need direct access to a compiler instance, we can prioritize that. So let me know if invoking through "CobraCore.runCobraExe" is a problem.

Regarding naming, see Utils.cobra for some interesting methods like .cobraNameForSharpMemberName and .toIdentifier.

Note that in Cobra, when you define a method called "fooBar" the name will be "FooBar" in the generated code. The purpose of "FooBar" is to produce a .dll/.exe that VB and C# programmers will be comfortable consuming. VB is case insensitive, but names affect IntelliSense in Visual Studio.

HTH
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: problem instanciating the compiler

Postby gauthier » Tue Dec 23, 2008 4:07 pm

Currently, I have "Access is denied"
Code: Select all
[Win32Exception (0x80004005): Access is denied]
   System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) +2097
   System.Diagnostics.Process.Start() +140
   Cobra.Lang.CobraImp.RunAndCaptureAllOutput(Process proc, Boolean verbose) +372
   Cobra.Lang.CobraImp.RunAndCaptureAllOutput(Object process) +53
   Cobra.Lang.CobraCore.RunCobraExe(String cobraExePath, String args, Process& process) +149
   Cobra.CodeDom.CobraCodeCompiler.CompileAssemblyFromFileBatch(CompilerParameters parameters, String[] batches) in src\cobra.codedom\CobraCodeCompiler.cobra:54
   System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromFile(CompilerParameters options, String[] fileNames) +23


this is either with IIS 5.1 (as ASPNET account) or with webdev.webserver.exe (as local administrator)

Any idea what could I do?
gauthier
 
Posts: 116

Re: problem instanciating the compiler

Postby Charles » Tue Dec 23, 2008 5:41 pm

This is a general .NET problem. Ultimately you're using System.Diagnostics.Process and it is throwing a Win32Exception "Access is denied". For these types of problems, you can use the large body of .NET knowledge that is out there. For example, you can search:

http://www.google.com/search?hl=en&q=as ... +denied%22

Usually I get really good results, but in this case the discussions I found weren't very promising!

You can try some more searching. But perhaps Cobra needs to be available as a .dll you can reference? A Cobra.Compiler.dll with everything in it.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: problem instanciating the compiler

Postby Charles » Tue Dec 23, 2008 6:02 pm

I took a crack at creating Cobra.Compiler.dll and ran into a couple problems. I think I can take care of them this week (tonight if it goes well).

In the mean time you could cheat by putting your files in Cobra-Workspace\Source and compiling it all together. The comp.bat script takes command line arguments, so if you have files A B C you could issue:

comp -out:foo.dll A B C

You would end up with a foo.dll with the Cobra compiler and your files all wrapped up together. Let me know if you have problems with that.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: problem instanciating the compiler

Postby Charles » Sat Dec 27, 2008 9:43 pm

Thanks for bringing up this issue. I've got this working now.

From within the Source directory, you can invoke a new .bat file:

comp-compiler-dll

whose definition is:

comp -t:lib -namespace:Cobra.Lang.Compiler -out:Cobra.Lang.Compiler.dll %*

So it's very close to making cobra.exe, but the target is a .dll and the namespace "Cobra.Lang.Compiler" is wrapped around everything. The end result is this file:

12/27/2008 08:34 PM 1,171,456 Cobra.Lang.Compiler.dll

Then here is a program that instantiates the compiler:
use Cobra.Lang.Compiler

class P

def main is shared
c = Cobra.Lang.Compiler.Compiler()
print c


One dangerous part of this is that *all* the classes and interfaces of the Cobra compiler are public. And most of their methods. So you can use just about anything in any way. That's great for flexibility, but please be warned that since the compiler is still under development, things could change. One way to mitigate this problem is to communicate back to me how you are using it (preferably by sharing the relevant source code) so I can either preserve those APIs or give you a warning if they are going to change.

Finally, after some further testing and feedback, I will make the build and registration of Cobra.Lang.Compiler.dll part of the standard install-from-workspace so that any Cobra program can easily use the compiler as a library.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: problem instanciating the compiler

Postby gauthier » Sun Dec 28, 2008 5:35 am

Thanks, I'll give it a try

I think I'll release the WIP code for CodeDOM shortly (as the NAnt task)
gauthier
 
Posts: 116

Re: problem instanciating the compiler

Postby gauthier » Fri Jun 19, 2009 8:01 pm

Just to let you know that Cobra.CodeDom project initiated here:

http://code.google.com/p/cobra-codedom/

any help / test / support is welcome :)
gauthier
 
Posts: 116


Return to Discussion

Who is online

Users browsing this forum: No registered users and 43 guests