Example #1
0
        //fetch the primary key for the dataset or set to invalid
        int RefreshObjDeclID(ObjDecl theObj)
        {
            String _SQL = ("SELECT ID from ObjectDecl where ClassID=='");

            _SQL += theObj.ClassID() + "' AND Function='" + theObj.Function() + "';";
            int     Return = 0;
            Boolean Exists = false;

            try {
                SQLiteCommand    command = new SQLiteCommand(_SQL, m_dbConnection);
                SQLiteDataReader reader  = command.ExecuteReader();
                while (reader.Read())
                {
                    //Todo fix non exist
                    Exists = true;
                    Return = reader.GetInt32(reader.GetOrdinal("ID"));
                }
                reader.Dispose();
                command.Dispose();
            } catch (Exception e) {
                HandleDBError(e);
            }
            theObj.updateID(Return);
            return(Return);
        }
Example #2
0
        //insert/update ObjectDeclaration
        public void UpdateObjDecl(ObjDecl theObj)
        {
            RefreshObjDeclID(theObj);

            DateTime Now = DateTime.Now;
            String   _SQL;

            if (theObj.ID() > 0)
            {
                _SQL = "Update ObjectDecl Set ClassID='" +
                       theObj.ClassID() +
                       "',Function='" + theObj.Function() +
                       "',Params='" + theObj.Params() +
                       "',Returns='" + theObj.Returns() +
                       "',ClassType=" + ((int)theObj.ClassType()).ToString() +
                       " ,State=1" +
                       " ,Descr='" + theObj.Description() +
                       " ',Time=" + (Now.ToBinary().ToString()) +
                       " ,Start=" + theObj.StartPos() +
                       " ,Length=" + theObj.Length() +
                       " where ID=" + (theObj.ID().ToString());
            }
            else
            {
                _SQL = "INSERT INTO ObjectDecl (ClassID, Function, Params, Returns, ClassType, State, Time,Descr,Start,Length) VALUES('" +
                       theObj.ClassID() +
                       "', '" + theObj.Function() + "', '" + theObj.Params() +
                       "', '" + theObj.Returns() + "', " + ((int)theObj.ClassType()).ToString() +
                       ",1" + "," + (Now.ToBinary().ToString()) + ",'" + theObj.Description() + "'," + theObj.StartPos() + "," + theObj.Length() + ");";
            }

            ExecuteSimpleQuery(_SQL);
            RefreshObjDeclID(theObj);   //get Ids after insert
        }
Example #3
0
 void PublishCmdToDB(String Scope, Parser2.CmdBase Cmd)
 {
     if (Scope != m_LastScope)
     {
         m_LastCmd = null;
     }
     if (Cmd.GetType().Equals(typeof(Parser2.CmdComment)))
     {
         Parser2.CmdComment Cmd2 = (Parser2.CmdComment)Cmd;
         m_LastCmd = Cmd2;
     }
     else if (Cmd.GetType().Equals(typeof(Parser2.CmdDecl)))
     {
         Parser2.CmdDecl Cmd2 = (Parser2.CmdDecl)Cmd;
         Obj             _obj = new Obj(Scope, Cmd2.m_Name, Cmd2.m_Type, Cmd2.Description(), Cmd2.StartPos(), Cmd2.Length());
         UpdateObjList(_obj);
     }
     else if (Cmd.GetType().Equals(typeof(Parser2.CmdInclude)))
     {
         Parser2.CmdInclude Cmd2 = (Parser2.CmdInclude)Cmd;
         Obj _obj = new Obj(Scope, Cmd2.m_Path,
                            /*m_ProjectDir +*/ getSeqDir(getSubProj()[0] /*??*/) + "\\" + Cmd2.m_Path, Cmd2.Description(), Cmd2.StartPos(), Cmd2.Length()); //Todo das ist falsch bei Subproject-Includes
         UpdateObjList(_obj);
     }
     else if (Cmd.GetType().Equals(typeof(Parser2.CmdUsing)))
     {
         Parser2.CmdUsing Cmd2 = (Parser2.CmdUsing)Cmd;
         Obj _obj = new Obj(Scope, Cmd2.m_Name,
                            /*m_ProjectDir +*/ getSourceDir() + "\\" + Cmd2.m_Path, Cmd2.Description(), Cmd2.StartPos(), Cmd2.Length());
         UpdateObjList(_obj);
         //Todo need to get the functions for this lvclass to put them into ObjDecl
         UpdateObjDecl(new ObjDecl(_obj.ClassID(), ObjDecl.TClassType.tCTClass, "Init", "", "", "", 0, 0));
     }
     else if (Cmd.GetType().Equals(typeof(Parser2.CmdFunctionDecl)))
     {
         Parser2.CmdFunctionDecl Cmd2 = (Parser2.CmdFunctionDecl)Cmd;
         ObjDecl _objDecl             = new ObjDecl(Scope,
                                                    /* m_IsClassDef*/ false ? ObjDecl.TClassType.tCTFunc : ObjDecl.TClassType.tCTSeq,
                                                    Cmd2.m_Name, Cmd2.m_Params.ToString(), Cmd2.m_Returns.ToString(),
                                                    (m_LastCmd != null ? m_LastCmd.AsText():Cmd2.Description()),
                                                    Cmd2.StartPos(), Cmd2.Length());
         UpdateObjDecl(_objDecl);
         m_LastCmd = null;
     }
     m_LastScope = Scope;
 }
Example #4
0
        void RebuildObjList()
        {
            // add the basic types to Intelisense
            ObjDecl _A;

            for (int i = 0; i < BASIC_TYPES.Count; i++)
            {
                _A = new ObjDecl(BASIC_TYPES[i], ObjDecl.TClassType.tCTType, "", "", "", "", 0, 0);
                UpdateObjDecl(_A);
            }
            DateTime _start = DateTime.Now;
            //Log.getInstance().Add("collecting files ", Log.EnuSeverity.Info, "");
            Tokenizer _tokenizer = new Tokenizer();
            LinkedList <Tokenizer.Token> _Tokens = new LinkedList <Tokenizer.Token>();
            List <String> Dirs = new List <String>(); //stack of directories relative to _path
            int           k    = 0;

            try {
                String[] _SubProj = getSubProj();
                for (int i = 0; i < _SubProj.Length; i++)
                {
                    Dirs.Add(Path.Combine(m_ProjectDir, getSeqDir(_SubProj[i])));
                }

                while (k < Dirs.Count)
                {
                    FileInfo[] _files = new DirectoryInfo(Dirs[k]).GetFiles();
                    for (int i = 0; i < _files.Length; i++)
                    {
                        if (_files[i].Extension.Equals(".seq", StringComparison.OrdinalIgnoreCase))
                        {
                            _Tokens.AddLast(_tokenizer.TokenizeFile(_files[i].FullName));
                        }
                    }
                    DirectoryInfo[] _Dirs = new DirectoryInfo(Dirs[k]).GetDirectories();
                    for (int i = 0; i < _Dirs.Length; i++)
                    {
                        // If the file is a directory (or is in some way invalid) we'll skip it
                        Dirs.Insert(k + 1, _Dirs[i].FullName);
                    }
                    k++;
                }
                //Log.getInstance().Add("Tokenized all" , Log.EnuSeverity.Info, "");
                Parser2 _parser2 = new Parser2(this, m_ProjectDir);
                _parser2.ParseTokens(_Tokens);
                LinkedList <Parser2.Context.Log> .Enumerator _l = _parser2.GetLogs().GetEnumerator();
                while (_l.MoveNext())
                {
                    Log.getInstance().Add(_l.Current.m_Text, Log.EnuSeverity.Warn, _l.Current.m_Cmd.AsText());
                }
                //update database with parserresult
                LinkedList <Parser2.CmdBase> .Enumerator _Cmds;
                List <String> .Enumerator _Scopes = _parser2.GetScopes().GetEnumerator();
                while (_Scopes.MoveNext())
                {
                    //Log.getInstance().Add("write DB " + _Scopes.Current, Log.EnuSeverity.Info, "");
                    // if(!m_IsClassDef) {
                    { //each SEQ includes itself
                        this.UpdateObjList(new Obj(_Scopes.Current, "", _Scopes.Current, "", 0, 0));
                    }
                    _Cmds = _parser2.GetCmds(_Scopes.Current).GetEnumerator();
                    while (_Cmds.MoveNext())
                    {
                        PublishCmdToDB(_Scopes.Current, _Cmds.Current);
                    }
                }
                Log.getInstance().Add("Parsing done ", Log.EnuSeverity.Info, "");
            } catch (Exception ex) {
                Log.getInstance().Add(ex.Message, Log.EnuSeverity.Error, "");
            }
            finally {
            }
        }