This project is read-only.

Interesting Error?

Sep 27, 2011 at 10:58 PM
Edited Sep 27, 2011 at 11:20 PM

Hello All Cosmos users. Man I have not been here a while! But its good to be back and see whats all been going on. I am building a new os of mine "PearOs AEE Engine" While I was away I was working on a advanced from scratch engine that would be able to handle the power of a lot of the trhings I want my os to have. Anyway I was working with my scripting engine I am writing and I got a error in the compiler 

 

Error:

System.Exception: Plug needed. System.Void  System.Threading.Thread.BeginCriticalRegion()   at Cosmos.IL2CPU.ILScanner.ScanMethod(MethodBase aMethod, Boolean aIsPlug)   at Cosmos.IL2CPU.ILScanner.ScanQueue()   at Cosmos.IL2CPU.ILScanner.Execute(MethodBase aStartMethod)   at Cosmos.Compiler.Builder.Builder.RunEngine(Object aParam)

 

I am using These imports I wonder if this could cause it

using System;using

System.Collections;

using System.Text;

 

The code uses a foreach event to loop through code but I dont think this is the problem. Anyway here is the code to the script engine in your os let me know 

 

Code:

 

 

using System;
using System.Collections;

using System.Text;
namespace PearOs_AEE_Engine_V1._0.AEE.VRS.VRS_Engine
{

    class Compiler
    {
        #region "Varibles"
        public static System.Collections.Hashtable Objects = new System.Collections.Hashtable();
        public static System.Collections.Hashtable Methods = new System.Collections.Hashtable();
        public static System.Collections.Hashtable Scripts = new System.Collections.Hashtable();
        public static System.Collections.DictionaryEntry Entry;
        public static string Code = "";
        public static bool go = false;
        public static string CurrentSub;
        public static string LookSub = "Main";
        public static bool skip = false;
        public static bool InIf = false;
        public static bool RunOnElse = false;
        public static string Eq = "";
        public static bool runif = false;
        #endregion
        static string Out = "";
        public static void UpdateObjects()
        {
            Objects.Clear();
            //Add All The Needed Objects!
            Objects.Add("System.Time()", new VRSObject("System.Time()", "2:00 pm"));
            Objects.Add("System.Game.Running", new VRSObject("System.Game.Running", "True"));
            //End Adding All Needed Objects!
            
           //Add All The Required Methods!
           
            //End Adding The Methods
            LookSub = "Main";
        }
       #region "Engine"
        public static void Compile2(String Code)
        {
            VRSScript s5 = new VRSScript(Code);
            s5.strings.Clear();
            Code.Trim();
            string Label = "";
            bool Jmp = false;
            Jmp = true;
        Jump:
            foreach (string z in Code.Split('\n'))
            {
                string a = z.Trim();
                if (InIf == true)
                {
                    if (a.StartsWith("If"))
                    {
                        if (a == Eq)
                        {
                            if (RunOnElse == false)
                            {
                                go = true;
                            }
                            runif = true;
                        }
                    }
                    else
                    {
                        if (a == "Else")
                        {
                            if (runif == true)
                            {
                                if (RunOnElse == true)
                                {
                                    go = true;
                                }
                                else
                                {
                                    go = false;
                                    InIf = true;
                                    RunOnElse = false;
                                }
                            }
                        }
                        if (a == "End If")
                        {
                            if (runif == true)
                            {
                                go = true;
                                InIf = false;
                                RunOnElse = false;
                                Eq = "";
                                runif = false;
                            }
                        }
                    }
                }
                if (InIf == false)
                {
                    if (a == "Script Class ViperRuntime")
                    {
                        go = true;

                    }
                }
                if (go == true)
                {
                    if (a == "End Script Class")
                    {
                        go = false;
                        break; // TODO: might not be correct. Was : Exit For
                    }
                    if (go == true)
                    {
                        if (a.StartsWith("Public Sub"))
                        {
                            string n = null;
                            n = a.Substring(11);
                            CurrentSub = n;
                        }
                        //Ok so lets say I want to dim something in the main class well with this now you can!
                        if (a.StartsWith("Dim"))
                        {
                            string[] b = a.Split(' ');
                            string n = b[1];
                            string t = b[3];

                            //now we have the name and the type! See if its is a sentance or a actual object
                            //ok check to see if we are actualy dimming something or diming it and setting a value
                            if (b.Length >= 3)
                            {
                                try
                                {
                                    if (b[4] == "=")
                                    {
                                        if (b[5].StartsWith("\""))
                                        {
                                            //Ok so it is a sentance remove the comments and make the spaces!
                                            string w = b[5].Replace("\"", "");
                                            //ok so spaces are weird so lets check for &'s
                                            string b2 = w.Replace("&", " ");
                                           
                                            //so b2 is our current text all spaced out and fixed
                                            s5.strings.Add(n, new VRSString(n, b2));
                                        }
                                        else
                                        {
                                            //Ok so it is a object check all the objects and make sure that it contains it and then set the alue to the string
                                            string ob = b[5];
                                            if (((VRSObject)Objects[ob]).name == ob)
                                            {
                                                s5.strings.Add(n, new VRSString(n, ((VRSObject)Objects[ob]).data));
                                                //ok so I add the values and stuff lets check it
                                            }
                                        }
                                    }
                                    else
                                    {
                                        //Ok so we are just creating the object with a blank value
                                    }
                                }
                                catch (Exception ex)
                                {
                                    try
                                    {
                                        s5.strings.Add(n, new VRSString(n, ""));
                                    }
                                    catch (Exception ex2)
                                    {
                                    }
                                }
                            }
                            else
                            {
                                s5.strings.Add(n, new VRSString(n, ""));
                            }
                        }
                        //Check to see if its in a sub or in a
                        if (CurrentSub == LookSub)
                        {
                            //Ok its in the sub it was looking for 
                            //Check to see if A Jump Sub Call Was Called
                            if (a.StartsWith("Goto"))
                            {
                                InIf = false;
                                RunOnElse = false;
                                string n = null;
                                n = a.Substring(5);
                                LookSub = n;
                                goto Jump;
                            }
                            else
                            {
                                if (a == "End Sub")
                                {
                                    LookSub = null;
                                    return;
                                }
                            }
                            //END The Call!
                            //Check to see if a END call is called
                            if (a == "END")
                            {
                                LookSub = null;
                                return;
                            }
                            //End Check
                            //Now we look for a Wait sub!
                            if (a.StartsWith("Wait("))
                            {
                                string y = a.Substring(5).Replace(")", "");
                                int amout;
                                int.TryParse(y, out amout);
                                int I = 0;
                                
                            }
                            //End Check
                            //Ok Since We Now Have Methods Lets Check To See If We Called One!
                            try
                            {
                                if (a.StartsWith("System"))
                                {
                                    string[] b = a.Split('.');
                                    if (b[3] == "Kill()")
                                    {
                                        //Point pos = ((clsNPC)GameClass.NPCs(b[2])).Position;
                                        //GameClass.map.Passable(pos.X, pos.Y) = true;
                                        //GameClass.NPCs.Remove(b[2]);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                            }
                            //End The Check
                            //Check if we need to go into a if statement
                            if (InIf == false)
                            {
                                if (a.StartsWith("If"))
                                {
                                    string[] b = a.Split(' ');
                                    string firstob = b[1];
                                    if (b[2] == "=")
                                    {
                                        if (b[3].StartsWith("\""))
                                        {
                                            string f = b[3].Replace("\"", "");
                                            b[3] = f;
                                            f = b[3].Replace("&", " ");
                                            b[3] = f;
                                            if (((VRSString)s5.strings[firstob]).name == firstob)
                                            {
                                                if (((VRSString)s5.strings[firstob]).Data == b[3])
                                                {
                                                    InIf = true;
                                                    RunOnElse = false;
                                                    LookSub = CurrentSub;
                                                    Eq = a;
                                                    go = false;
                                                    
                                                    goto Jump;
                                                }
                                                else
                                                {
                                                    RunOnElse = true;
                                                    go = false;
                                                    LookSub = CurrentSub;
                                                    InIf = true;
                                                    Eq = a;
                                                    goto Jump;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            //End The Check
                            //Check to see if we are using a if statement 
                            //Check to see if we are going to dim anything!
                            if (a.StartsWith("Dim"))
                            {
                                string[] b = a.Split(' ');
                                string n = b[1];
                                string t = b[3];
                                //now we have the name and the type! See if its is a sentance or a actual object
                                //ok check to see if we are actualy dimming something or diming it and setting a value
                                if (b.Length >= 3)
                                {
                                    try
                                    {
                                        if (b[4] == "=")
                                        {
                                            if (b[5].StartsWith("\""))
                                            {
                                                //Ok so it is a sentance remove the comments and make the spaces!
                                                string w = b[5].Replace("\"", "");
                                                //ok so spaces are weird so lets check for &'s
                                                string b2 = w.Replace("&", " ");
                                                //so b2 is our current text all spaced out and fixed
                                                s5.strings.Add(n, new VRSString(n, b2));
                                            }
                                            else
                                            {
                                                //Ok so it is a object check all the objects and make sure that it contains it and then set the alue to the string
                                                string ob = b[5];
                                                if (((VRSObject)Objects[ob]).name == ob)
                                                {
                                                    s5.strings.Add(n, new VRSString(n, ((VRSObject)Objects[ob]).data));
                                                    //ok so I add the values and stuff lets check it
                                                }
                                            }
                                        }
                                        else
                                        {
                                            //Ok so we are just creating the object with a blank value
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        try
                                        {
                                            s5.strings.Add(n, new VRSString(n, ""));
                                        }
                                        catch (Exception ex2)
                                        {
                                        }
                                    }
                                }
                                else
                                {
                                    s5.strings.Add(n, new VRSString(n, ""));
                                }
                            }
                            //END The Check!
                            //Now We need to check for if your setting a strings value or adding it or whatever!
                            try
                            {
                                string[] b5 = a.Split(' ');
                                if (((VRSString)s5.strings[b5[0]]).name == b5[0])
                                {
                                    if (b5[1] == "=")
                                    {
                                        string sentance = "";
                                        sentance = b5[2];
                                        string sentance2 = sentance.Replace("\"", "");
                                        sentance = sentance2;
                                        sentance2 = sentance.Replace("&", " ");
                                        sentance = sentance2;
                                        ((VRSString)s5.strings[b5[0]]).Data = sentance;
                                    }
                                    if (b5[1] == "+=")
                                    {
                                        string sentance = ((VRSString)s5.strings[b5[0]]).Data;
                                        sentance += b5[2];
                                        string sentance2 = sentance.Replace("\"", "");
                                        sentance = sentance2;
                                        try
                                        {
                                            sentance2 = sentance.Replace("&", " ");
                                            sentance = sentance2;
                                        }
                                        catch (Exception ex)
                                        {
                                        }
                                        ((VRSString)s5.strings[b5[0]]).Data = sentance;
                                    }
                                }

                            }
                            catch (Exception ex)
                            {
                            }
                            //END The Check!
                            //Check if it needs to echo a message
                            if (a.StartsWith("Echo("))
                            {
                                string s = a.Substring(5);
                                string s2 = s.Replace(")", "");
                                if (((VRSScript)s5.strings[s2]).name == s2)
                                {
                                    Console.Write(((VRSString)s5.strings[s2]).Data);
                                }
                            }
                            //End 
                        }
                        else
                        {
                            //ok so lets say its not in the sub it wsa looking for, then see if it even entered a sub yet,
                            //if so then do these thing
                            if (string.IsNullOrEmpty(CurrentSub))
                            {
                                //Ok so it has not exactly entered a sub yet, so it needs to check for dims, thats the first thing, then well check a few other things
                            }
                        }
                        //Ok Now here is our other needed things
                        //END IT HERE
                    skip: ;
                    }
                }
            }
        }
        #endregion


    }
    class Var
    {
        public string Name;
        public int Index;

        public bool Int = false;
    }
}

I only seem to get a error when I try to use the engine. Thanks - Matt

Sep 28, 2011 at 12:00 AM

Firstly, if your wanting help, don't go removing the peices of code from your post that's causing issues, comment them out instead (you removed System.Threading.Thread.Sleep from your wait method), Also, the issue is not in this class, (it may very well be if your still using MS4), it's in VRSScript.

Sep 28, 2011 at 12:43 AM

Hmm ok will do blah38621. here is the VRSScript class I looked over it and I don't think thats the problem. I would switch to a newer version but they dont support VGA Screen anymore and I am still using Microsoft Visual C# 2010 Exspress Edition. 

 

Code:

 

using System;
using System.Collections;
using System.Collections.Generic;

public class VRSScript
{
    //Store his position
    public string name;
    public System.Collections.Hashtable strings = new System.Collections.Hashtable();
    public System.Collections.Hashtable integers = new System.Collections.Hashtable();
    public System.Collections.Hashtable Subs = new System.Collections.Hashtable();
    public System.Collections.DictionaryEntry Entry;

    public string Code;

    public VRSScript(string cde)
    {
        this.Code = cde;
    }

    
}

Sep 28, 2011 at 12:45 AM

the newest version very definately does support vga :P

Sep 28, 2011 at 1:00 AM
Edited Sep 28, 2011 at 1:03 AM

Hey blah38621, after doing some testing I found that without these four lines it compiles. Is there anyway I can get it to still compile with them?

Oh wow! Good Job! I think its been so long I dont even know what is supported and whats not. Lol 

If you can tell me how to install thew newest version on Microsoft Visual C# 2010 Express Edition  I will use it. I wonder if that will effect any of my code? And would this fix my problem?

Code:

 

 

        public static System.Collections.Hashtable Objects = new System.Collections.Hashtable();
        public static System.Collections.Hashtable Methods = new System.Collections.Hashtable();
        public static System.Collections.Hashtable Scripts = new System.Collections.Hashtable();
        public static System.Collections.DictionaryEntry Entry;
Sep 28, 2011 at 1:01 AM

yes, implement your own hashtable.

Sep 28, 2011 at 1:05 AM

Make my own hashtable? Never tried it. Can you maybe help with that? If that is you would not mind. Thanks - Matt

Sep 28, 2011 at 4:17 AM

I managed to track down the exact error. This line causes it, I wrote my own hashtable code. But If I add this line it gives me the compiler error posted above.

 

Line: 

 

 String Data = ((VRSString)s5.strings[Name]).Data;

 

 

Anyway to fix this? 

 

Compiler Error:

 

System.Exception: Plug needed. System.Void  System.Threading.Thread.BeginCriticalRegion()   at Cosmos.IL2CPU.ILScanner.ScanMethod(MethodBase aMethod, Boolean aIsPlug)   at Cosmos.IL2CPU.ILScanner.ScanQueue()   at Cosmos.IL2CPU.ILScanner.Execute(MethodBase aStartMethod)   at Cosmos.Compiler.Builder.Builder.RunEngine(Object aParam)

Sep 28, 2011 at 8:03 AM
That line does actually 4 things at once: first start by splitting it up into three pieces, so you can track down which one is causing the issue..

On Wed, Sep 28, 2011 at 5:17 AM, civilwarrock <notifications@codeplex.com> wrote:

From: civilwarrock

I managed to track down the exact error. This line causes it, I wrote my own hashtable code. But If I add this line it gives me the compiler error posted above.

Line:

 String Data = ((VRSString)s5.strings[Name]).Data;

Anyway to fix this?

Compiler Error:

System.Exception: Plug needed. System.Void System.Threading.Thread.BeginCriticalRegion() at Cosmos.IL2CPU.ILScanner.ScanMethod(MethodBase aMethod, Boolean aIsPlug) at Cosmos.IL2CPU.ILScanner.ScanQueue() at Cosmos.IL2CPU.ILScanner.Execute(MethodBase aStartMethod) at Cosmos.Compiler.Builder.Builder.RunEngine(Object aParam)

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Sep 28, 2011 at 8:03 AM
ok, 4 pieces.. :)

On Wed, Sep 28, 2011 at 9:03 AM, Matthijs ter Woord <matthijsterwoord@gmail.com> wrote:
That line does actually 4 things at once: first start by splitting it up into three pieces, so you can track down which one is causing the issue..


On Wed, Sep 28, 2011 at 5:17 AM, civilwarrock <notifications@codeplex.com> wrote:

From: civilwarrock

I managed to track down the exact error. This line causes it, I wrote my own hashtable code. But If I add this line it gives me the compiler error posted above.

Line:

 String Data = ((VRSString)s5.strings[Name]).Data;

Anyway to fix this?

Compiler Error:

System.Exception: Plug needed. System.Void System.Threading.Thread.BeginCriticalRegion() at Cosmos.IL2CPU.ILScanner.ScanMethod(MethodBase aMethod, Boolean aIsPlug) at Cosmos.IL2CPU.ILScanner.ScanQueue() at Cosmos.IL2CPU.ILScanner.Execute(MethodBase aStartMethod) at Cosmos.Compiler.Builder.Builder.RunEngine(Object aParam)

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com