• Advertisement
Sign in to follow this  

the compiler doesn't compile the script

This topic is 1502 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi

i'm making a game engine and i want to test my compiler

previously, it crashed

but with getting help, i fixed it

now, when i want to compile my script, it load's the file, and don't write's to it

the run function also crashed

now when i'm trying to run my application, it doesn't show anything

also when i'm trying to compile my application, it load's the file and it doesn't write to it

i've uploaded the code here

[attachment=18986:AGC.zip]

thanks in advance

Share this post


Link to post
Share on other sites
Advertisement

Amir,

 

please do a little bit of investigation on your own and tell us more details. Help us help you.

 

 

First of all: Did the script compile successfully? Did you check the return code from the Build call?

 

Secondly: Was the Prepare call on the context successful? Did you chek the return code?

 

 

 

 

I want to continue to help you, but I can't do all the work for you.

 

 

Regards,

Andreas

Share this post


Link to post
Share on other sites

yes, i updated the compile.cpp and moved the codes from save_byet to the compile function
i did checked the return code
this is the function:

void mainwin::compile(wxCommandEvent &evt)
{
asIScriptFunction *mainfunc=scripting::scriptengine->GetGlobalFunctionByDecl("void main()");
if(mainfunc==0)
{
scripting::scriptengine->WriteMessage(NULL, 0, 0, asMSGTYPE_ERROR, "the script should have void main() function");
}
wxString wildcard;
#ifdef __WXMSW__
wildcard="Executable Files(*.exe)|*.exe";
#else
wildcard="All Files(*.*)|*.*";
#endif // __WXMSW__
wxFileDialog *compsavedialog=new wxFileDialog(this, "compile", "", "", wildcard, wxFD_SAVE|wxFD_OVERWRITE_PROMPT, wxDefaultPosition, wxDefaultSize, "compilesavedlg");
int save_compile=compsavedialog->ShowModal();
if(save_compile==wxID_CANCEL)
{
compsavedialog->Close();
}
if(save_compile==wxID_OK)
{
wxProgressDialog *dlg=new wxProgressDialog("compiling", "please wait while the script is being compiled", 100, this, wxPD_APP_MODAL|wxPD_AUTO_HIDE);
compilerstream scriptcomp;
CScriptBuilder builder;
builder.StartNewModule(scripting::scriptengine, "build");
builder.AddSectionFromMemory("sec", txt->GetText(), txt->GetTextLength());
int r=scriptcomp.open(compsavedialog->GetPath());
r= builder.BuildModule();
if(r<0)
{
scripting::scriptengine->WriteMessage("sec", 0, 0, asMSGTYPE_ERROR, "unknown error!");
return ;
}
asIScriptModule *mod=scripting::scriptengine->GetModule("build", asGM_ONLY_IF_EXISTS);
mod->SaveByteCode(&scriptcomp);
compsavedialog->Close(true);
dlg->Pulse(wxEmptyString, false);
}
}
this is compiler.h:
#ifndef _AGC_COMPILER_H
#define _AGC_COMPILER_H
#include <angelscript.h>
#include <stdio.h>
/*
*the compiler class that is to be used for compile the scripts
*/
class compilerstream: public asIBinaryStream
{
public:
compilerstream()
{
f=NULL;
}
~compilerstream()
{
if(f)
{
fclose(f);
}
}
int open(wxString filename)
{
if(f)
{
return -1;
}
#if _MSC_VER >= 1500
fopen_s(&f, filename, "wb");
#else
f = fopen(filename, "wb");
#endif
if( f == 0 )
{
}
return -1;
return 0;
}
void Write(const void *ptr, asUINT size)
{
if( size == 0 || f == 0 )
{
return;
}
fwrite(ptr, size, 1, f);
}
void Read(void *, asUINT ) {}
private:
FILE *f;
};
#endif // _AGC_COMPILER_H
what is the problem in this code?
i want to fix it!

Share this post


Link to post
Share on other sites

The first thing you should do is organize your code logically. You're mixing everything up. It's no wonder you don't find the cause of the problem you're facing.

 

Why are you attempting to get the global function "void main()" from the engine? Unless you've registered this function from the application this will never be found. If you meant to retrieve the global function from the script, then you need to call the GetGlobalFunction method on the script module after you've built the script.

 

I see you're passing a script section from memory in the variable txt. But what exactly do you have in this variable? Are you certain the script is there?

 

Here's how I think you wanted to implement your function:

void mainwin::compile(wxCommandEvent &evt)
{
   // Ask the user where he wants to save the compiled bytecode
   wxString wildcard;
#ifdef __WXMSW__
   wildcard="Executable Files(*.exe)|*.exe";
#else
   wildcard="All Files(*.*)|*.*";
#endif // __WXMSW__
   wxFileDialog *compsavedialog=new wxFileDialog(this, "compile", "", "", wildcard, wxFD_SAVE|wxFD_OVERWRITE_PROMPT, wxDefaultPosition, wxDefaultSize, "compilesavedlg");
   int save_compile=compsavedialog->ShowModal();
   if(save_compile==wxID_CANCEL)
   {
     compsavedialog->Close();
     return;
   }
   if(save_compile==wxID_OK)
   {
     // Show an "in progress" dialog
     wxProgressDialog *dlg=new wxProgressDialog("compiling", "please wait while the script is being compiled", 100, this, wxPD_APP_MODAL|wxPD_AUTO_HIDE);
 
     // Compile the script
     CScriptBuilder builder;
     builder.StartNewModule(scripting::scriptengine, "build");
     builder.AddSectionFromMemory("sec", txt->GetText(), txt->GetTextLength());
     r = builder.BuildModule();
     if(r<0)
     {
       scripting::scriptengine->WriteMessage("sec", 0, 0, asMSGTYPE_ERROR, "The script cannot be compiled due to errors!");
       return ;
     }
 
     // Check if the script has the required main function
     asIScriptModule *mod=scripting::scriptengine->GetModule("build", asGM_ONLY_IF_EXISTS);
     asIScriptFunction *mainfunc=mod->GetGlobalFunctionByDecl("void main()");
     if(mainfunc==0)
     {
        scripting::scriptengine->WriteMessage(NULL, 0, 0, asMSGTYPE_ERROR, "the script should have void main() function");
        return;
     }
 
     // Save the bytecode to the file
     compilerstream scriptcomp;
     int r=scriptcomp.open(compsavedialog->GetPath());
     mod->SaveByteCode(&scriptcomp);
     compsavedialog->Close(true);
     dlg->Pulse(wxEmptyString, false);
  }
}

There is an error in your compilerstream::open() method. It will always return -1, even though the file was successfully opened.

Edited by Andreas Jonsson

Share this post


Link to post
Share on other sites

i updated the compile as you've sed

compiler.cpp

/*
*the compilation Process
*/
void mainwin::compile(wxCommandEvent &evt)
{
wxString wildcard;
#ifdef __WXMSW__
wildcard="Executable Files(*.exe)|*.exe";
#else
wildcard="All Files(*.*)|*.*";
#endif // __WXMSW__
wxFileDialog *compsavedialog=new wxFileDialog(this, "compile", "", "", wildcard, wxFD_SAVE|wxFD_OVERWRITE_PROMPT, wxDefaultPosition, wxDefaultSize, "compilesavedlg");
int save_compile=compsavedialog->ShowModal();
if(save_compile==wxID_CANCEL)
{
compsavedialog->Close();
}
if(save_compile==wxID_OK)
{
compilerstream scriptcomp;
CScriptBuilder builder;
int r=builder.StartNewModule(scripting::scriptengine, "build");
if(r<0)
{
scripting::scriptengine->WriteMessage("sec", 0, 0, asMSGTYPE_ERROR, "can't start compilation");
return ;
}
r=builder.AddSectionFromMemory("sec", txt->GetText(), txt->GetTextLength());
if(r<0)
{
scripting::scriptengine->WriteMessage("sec", 0, 0, asMSGTYPE_ERROR, "can't get the script!");
return ;
}
r= builder.BuildModule();
if(r<0)
{
scripting::scriptengine->WriteMessage("sec", 0, 0, asMSGTYPE_ERROR, "unknown error!");
return ;
}
r=scriptcomp.open(compsavedialog->GetPath());
if(r<0)
{
scripting::scriptengine->WriteMessage("sec", 0, 0, asMSGTYPE_ERROR, "can't Open the given file for compilation!");
return ;
}
asIScriptModule *mod=scripting::scriptengine->GetModule("build", asGM_ONLY_IF_EXISTS);
if(mod==0)
{
scripting::scriptengine->WriteMessage("sec", 0, 0, asMSGTYPE_ERROR, "can't load the compile byet code");
return ;
}
asIScriptFunction *mainfunc=mod->GetFunctionByDecl("void main()");
if(mainfunc==0)
{
scripting::scriptengine->WriteMessage("sec", 0, 0, asMSGTYPE_ERROR, "your script must have Void Main() function");
return ;
}
compsavedialog->Close(true);
wxProgressDialog *dlg=new wxProgressDialog("compiling", "please wait while the script is being compiled", 100, this, wxPD_APP_MODAL|wxPD_AUTO_HIDE);
mod->SaveByteCode(&scriptcomp);
dlg->Pulse(wxEmptyString, (bool)false);
}
}

compiler.h:

/*
*the compiler class that is to be used for compile the scripts
*/
class compilerstream: public asIBinaryStream
{
public:
compilerstream()
{
f=NULL;
}
~compilerstream()
{
if(f)
{
fclose(f);
}
}
int open(wxString filename)
{
if(f)
{
return -1;
}
#if _MSC_VER >= 1500
fopen_s(&f, filename, "wb");
#else
f = fopen(filename, "wb");
#endif
if( f == 0 )
{
return -1;
}
return 0;
}
void Write(const void *ptr, asUINT size)
{
if( size == 0 || f == 0 )
{
return;
}
fwrite(ptr, size, 1, f);
}
void Read(void *, asUINT ) {}
private:
FILE *f;
};
#endif // _AGC_COMPILER_H

i saw the samples and documentation and updated my code like those

and actually, i've removed builder.AddSectionFromMemory("sec", txt->GetText(), txt->GetTextLength());

and tested and nothing happens

now, it doesn't open the file

it doesn't give any executable, or anything

i'm working on it for 2 and a half hours!

i've checked all of the compiler.cpp and compiler.h and in my idea, no problem now

but as i see now, it doesn't compile!

this is the script that i'm debugging:

script.AGC:

void main()
{
agc_lz_compress("C:\\Dev-Cpp", "C:\\Dev-Cpp.compressed", 1024*1024);
}

it doesn't compile

no message has been occured and it work's like a working application

but the compilation and run functions don't work properly

i can update run function like that, but i don't know the compilation problem

i've debugged it

but the debugger doesn't found the problem

Share this post


Link to post
Share on other sites

I see you've added checks for all of the return codes which is good. 

 

Which of the function calls fail? What error message do you get when you run your application? 

Share this post


Link to post
Share on other sites

I downloaded the executable but it doesn't work. I'm not sure if there are any dependencies that I miss, perhaps some dlls that you need to provide together with the executable?.

Share this post


Link to post
Share on other sites

Unfortunately Windows doesn't tell me why it doesn't work. The only error I get is "This application can't be executed on your PC".

 

I'm using 64bit Windows 8.1 if that's of any help to you.

Share this post


Link to post
Share on other sites

I feel like running a random exe that requires UAC to be disabled is a terribly unsafe thing to do.

Share this post


Link to post
Share on other sites

While I agree with Jake that you must not require the users to disable UAC in order to run your software, I trust that you haven't provided any malicious software and did try it with UAC turned off. However, the result is the same after telling Windows to execute the application even though the supplier is unknown Windows gives me the error that the application cannot be executed on this PC without any further detail about why.

Share this post


Link to post
Share on other sites

I had a quick look at the exe - coz I'm so nosey and enjoy mystery .exe's smile.png it's a legit PE, I didn't check for any nasties but it's:

 

"Allegro Game Creator"

 

uses:

OpenAL

wxWidgets

OpenGL

some GCC stuff

and a few more

 

 

probably doesn't load because it uses a few .dlls

 

libgcc_s_dw2-1.dll

libgcj-13.dll

 

and it does have that function above in there:

 

int __thiscall sub_401838(void *this, int a2)
{
  int v2; // ebx@1
  int v3; // ebx@6
  int v4; // eax@6
  int v5; // ebx@16
  void (__thiscall *v6)(_DWORD, _DWORD, _DWORD); // ebx@16
  void *v8; // [sp+44h] [bp-16Ch]@1
  char v9; // [sp+48h] [bp-168h]@4
  char v10; // [sp+100h] [bp-B0h]@4
  char v11; // [sp+108h] [bp-A8h]@1
  char v12; // [sp+114h] [bp-9Ch]@1
  char v13; // [sp+120h] [bp-90h]@1
  char v14; // [sp+12Ch] [bp-84h]@1
  char v15; // [sp+138h] [bp-78h]@1
  char v16; // [sp+144h] [bp-6Ch]@6
  char v17; // [sp+150h] [bp-60h]@10
  char v18; // [sp+15Ch] [bp-54h]@16
  char v19; // [sp+168h] [bp-48h]@16
  char v20; // [sp+174h] [bp-3Ch]@16
  int v21; // [sp+180h] [bp-30h]@16
  int v22; // [sp+184h] [bp-2Ch]@14
  int v23; // [sp+188h] [bp-28h]@12
  int v24; // [sp+18Ch] [bp-24h]@4
  int v25; // [sp+190h] [bp-20h]@1
  int v26; // [sp+194h] [bp-1Ch]@1
 
  v8 = this;
  sub_90112C(&v11);
  sub_901210("Executable Files(*.exe)|*.exe");
  sub_9008CC("compile");
  sub_9008CC(&unk_9EE184);
  sub_9008CC(&unk_9EE184);
  sub_9008CC("compilesavedlg");
  v2 = sub_98D050(576);
  sub_4F5E00(v8, &v12, &v13, &v14, &v11, 6, &dword_C3CB04, &dword_C3CAFC, &v15);
  v26 = v2;
  sub_9011C0(&v15);
  sub_9011C0(&v14);
  sub_9011C0(&v13);
  sub_9011C0(&v12);
  v25 = (*(int (__thiscall **)(int))(*(_DWORD *)v26 + 956))(v26);
  if ( v25 == 5101 )
    sub_4E3A32(0);
  if ( v25 == 5100 )
  {
    sub_8B2DE8(&v10);
    sub_799F20(&v9);
    v24 = sub_79ADD0(dword_C37024, "build");
    if ( v24 >= 0 )
    {
      v3 = sub_4FB696(*((_DWORD *)v8 + 122));
      sub_4FB5CA(*((_DWORD *)v8 + 122));
      v4 = sub_92B2E0(&v16);
      v24 = sub_79C5C0("sec", v4, v3);
      sub_9011C0(&v16);
      if ( v24 >= 0 )
      {
        v24 = sub_79D9D0(&v9);
        if ( v24 >= 0 )
        {
          (*(void (__thiscall **)(char *, int))(*(_DWORD *)v26 + 1024))(&v17, v26);
          v24 = sub_8B2D50(&v17);
          sub_9011C0(&v17);
          if ( v24 >= 0 )
          {
            v23 = (*(int (__thiscall **)(int, _DWORD, _DWORD))(*(_DWORD *)dword_C37024 + 196))(dword_C37024, "build", 0);
            if ( v23 )
            {
              v22 = (*(int (__thiscall **)(int, _DWORD))(*(_DWORD *)v23 + 52))(v23, "void main()");
              if ( v22 )
              {
                sub_4E3A32(1);
                sub_9008CC("compiling");
                sub_9008CC("please wait while the script is being compiled");
                v5 = sub_98D050(588);
                sub_504D58(&v18, &v19, 100, v8, 6);
                v21 = v5;
                sub_9011C0(&v19);
                sub_9011C0(&v18);
                (*(void (__thiscall **)(int, char *, _DWORD))(*(_DWORD *)v23 + 168))(v23, &v10, 0);
                v6 = *(void (__thiscall **)(_DWORD, _DWORD, _DWORD))(*(_DWORD *)v21 + 1000);
                sub_900B20(off_9E5488);
                v6(v21, &v20, 0);
                sub_9011C0(&v20);
              }
              else
              {
                (*(void (__thiscall **)(int, char[4], _DWORD, _DWORD, _DWORD, _DWORD))(*(_DWORD *)dword_C37024 + 24))(
                  dword_C37024,
                  "sec",
                  0,
                  0,
                  0,
                  "your script must have Void Main() function");
              }
            }
            else
            {
              (*(void (__thiscall **)(int, char[4], _DWORD, _DWORD, _DWORD, _DWORD))(*(_DWORD *)dword_C37024 + 24))(
                dword_C37024,
                "sec",
                0,
                0,
                0,
                "can't load the compile byet code");
            }
          }
          else
          {
            (*(void (__thiscall **)(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD))(*(_DWORD *)dword_C37024 + 24))(
              dword_C37024,
              "sec",
              0,
              0,
              0,
              "can't Open the given file for compilation!");
          }
        }
        else
        {
          (*(void (__thiscall **)(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD))(*(_DWORD *)dword_C37024 + 24))(
            dword_C37024,
            "sec",
            0,
            0,
            0,
            "unknown error!");
        }
      }
      else
      {
        (*(void (__thiscall **)(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD))(*(_DWORD *)dword_C37024 + 24))(
          dword_C37024,
          "sec",
          0,
          0,
          0,
          "can't get the script!");
      }
    }
    else
    {
      (*(void (__thiscall **)(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD))(*(_DWORD *)dword_C37024 + 24))(
        dword_C37024,
        "sec",
        0,
        0,
        0,
        "can't start compilation");
    }
    sub_8B1590(&v9);
    sub_8B2E30(&v10);
  }
  return sub_9011C0(&v11);
}
Edited by shabtronic

Share this post


Link to post
Share on other sites

what should i do now?

i read all of them, but it didn't worked!

thank's shabronic for the information, but i don't know how to fix it!

i dis-assembled it, but nothing happens and i don't found the problem

now see that!:

i can write an operating system, but this application make's me very snappish

please help: i'm losing my eyesight for that!

Share this post


Link to post
Share on other sites

Windows used to give more information about why an application doesn't run. Especially when it is because of a missing dll. Perhaps Microsoft decided to remove this error reporting in Windows 8 due to confusing the average user. I wonder if there is a way to turn on the detailed error reporting for us developers? I'll see if I can find something.

 

Anyway, I'll try downloading the dlls that shabtronics mentioned and see if that helps.

Share this post


Link to post
Share on other sites

I downloaded Dependency Walker to see if there were any other missing dlls.

 

The dlls that are missing seems to be from Microsoft. My guess is that you're using a different version of the Platform SDK than what I have installed.

 

What version of the Platform SDK is it that you're using? 

Edited by Andreas Jonsson

Share this post


Link to post
Share on other sites

No, that had nothing to do with the problem. I ran dependency walker on my own application BMFont, and it reports the same missing dlls, yet my application runs normally.

 

There is something in AGC.exe that prevents it from running. Could it have been corrupted, e.g. by ftp as text, in the upload to your site? Have you tried downloading the executable and running it on your own machine?

Share this post


Link to post
Share on other sites

I think that posting your executable for debugging should really be a last resort when you're trying to get help like this.

 

You should really try to create a minimal program that demonstrates the essential problem. Check out a fresh working copy from version control, or copy your project's source if you're not using version control (hint: you should definitely be using version control). Start by removing third party code, and keep removing more and more code while checking that the application continues to reproduce the unwanted behaviour. Try to avoid any external dependencies, for example, try putting the script source code in a string rather than an external file (presuming Angelcode supports reading a string directly).

 

Stop when the behaviour does, or when there is no more code to take away.

 

Sometimes, in the process of reducing the problem you will actually find the source and be able to solve it yourself. In such cases, it would be nice to reply with a note here, so that others experiencing similar issues know what to look out for. During this process, you might also find that trying to remove a piece of otherwise unrelated code also removes the behaviour. This may indicate trickier issues, such as invoking undefined behaviour, For example, somewhere you might be calling a member function on a null, uninitialised or deallocated pointer. If you find this, you at least can (probably) rule out Angelcode as the culprit.

 

Another possibility is that  you end up with a relatively simple program, that fits in a single source file, with no external dependencies, that still shows the issue. Post the code to this program here, someone might be able to spot a mistake, or it could be used as a test case to demonstrate a bug in the library itself.

Share this post


Link to post
Share on other sites
i'm using MinGW's windows SDK it is w32API package of MinGW and also, MinGW doesn't have any platform SDK it has the Windows SDK and a C and C++ library and another thing that i have to say is that if you compile an application in win7, or Win XP, you can run it on win8 or vista or any version of windows because all the versions of windows are compatible and it doesn't dependent on windows SDK but, if the sdk is grator than the version of windows, the application can't be run and may require a dll or a function that is not exist's on the windows DLLS @rip-off, i've debugged and also dis-assembled it! and, it configures and run's successfully but my script can't be compiled

Share this post


Link to post
Share on other sites


i've debugged and also dis-assembled it! and, it configures and run's successfully but my script can't be compiled 

Debugging a larger program is always going to be more difficult than a smaller one. Producing a minimal example demonstrating the issue is the simplest way forward.

Edited by rip-off

Share this post


Link to post
Share on other sites

Do the samples work for you? If so, there is a difference between what you wrote and what the samples do. This difference can be discovered by producing a minimal program demonstrating the issue.

 

It might not sound like it, but this is also the fastest way forward.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement