Example #1
0
    public override void CopyValues(ScrObjLibraryEntry other)
    {
        base.CopyValues(other);
        CharEntry cd = (CharEntry)other;

        portraitSet      = cd.portraitSet;
        startClass       = cd.startClass;
        startClassLevels = cd.startClassLevels;

        hp  = cd.hp;
        dmg = cd.dmg;
        mnd = cd.mnd;
        skl = cd.skl;
        spd = cd.spd;
        def = cd.def;

        gHp  = cd.gHp;
        gDmg = cd.gDmg;
        gMnd = cd.gMnd;
        gSkl = cd.gSkl;
        gSpd = cd.gSpd;
        gDef = cd.gDef;

        supports = new List <SupportTuple>();
        for (int i = 0; i < cd.supports.Count; i++)
        {
            supports.Add(cd.supports[i]);
        }

        faction     = cd.faction;
        mustSurvive = cd.mustSurvive;
        deathQuote  = cd.deathQuote;
    }
Example #2
0
    public override void ResetValues()
    {
        base.ResetValues();

        portraitSet      = null;
        startClass       = null;
        startClassLevels = new int[ClassWheel.CLASS_COUNT];

        hp  = 0;
        dmg = 0;
        mnd = 0;
        skl = 0;
        spd = 0;
        def = 0;

        gHp  = 0;
        gDmg = 0;
        gMnd = 0;
        gSkl = 0;
        gSpd = 0;
        gDef = 0;

        supports = new List <SupportTuple>();

        faction     = Faction.NONE;
        mustSurvive = false;
        deathQuote  = null;
    }
        public List <ClassEntry> GetAllClasses()
        {
            command             = new SqlCommand();
            command.CommandText = "SELECT * FROM tbl_classes ORDER BY order_by ASC";

            command.Connection = connection;
            command.Connection.Open();

            reader = command.ExecuteReader();

            List <ClassEntry> allClasses = new List <ClassEntry>();

            while (reader.Read())
            {
                ClassEntry aClassEntry = new ClassEntry();

                aClassEntry.Id      = Convert.ToInt32(reader["id"]);
                aClassEntry.Name    = reader["name"].ToString();
                aClassEntry.OrderBy = Convert.ToInt32(reader["order_by"]);

                allClasses.Add(aClassEntry);
            }

            reader.Close();
            connection.Close();

            return(allClasses);
        }
		/// <summary>
		/// Returns a collection of <see cref="ClassEntry" /> containing
		/// information about all classes in this stream.
		/// </summary>
		/// <param name="document">A validated <see cref="XmlDocument"/> representing
		/// a mapping file.</param>
		public static ICollection GetClassEntries(XmlDocument document)
		{
			XmlNamespaceManager nsmgr = HbmBinder.BuildNamespaceManager(document.NameTable);

			// Since the document is validated, no error checking is done in this method.
			HashedSet classEntries = new HashedSet();

			XmlNode root = document.DocumentElement;

			string assembly = XmlHelper.GetAttributeValue(root, "assembly");
			string @namespace = XmlHelper.GetAttributeValue(root, "namespace");

			XmlNodeList classNodes = document.SelectNodes(
				"//" + HbmConstants.nsClass +
				"|//" + HbmConstants.nsSubclass +
				"|//" + HbmConstants.nsJoinedSubclass +
				"|//" + HbmConstants.nsUnionSubclass,
				nsmgr
				);

			foreach (XmlNode classNode in classNodes)
			{
				string name = XmlHelper.GetAttributeValue(classNode, "name");
				string extends = XmlHelper.GetAttributeValue(classNode, "extends");
				ClassEntry ce = new ClassEntry(extends, name, assembly, @namespace);
				classEntries.Add(ce);
			}

			return classEntries;
		}
Example #5
0
        /// <summary>
        /// Returns a collection of <see cref="ClassEntry" /> containing
        /// information about all classes in this stream.
        /// </summary>
        /// <param name="document">A validated <see cref="XmlDocument"/> representing
        /// a mapping file.</param>
        public static ICollection GetClassEntries(XmlDocument document)
        {
            // TODO this should be extracted into a utility method since there's similar
            // code in Configuration
            XmlNamespaceManager nsmgr = new XmlNamespaceManager(document.NameTable);
            nsmgr.AddNamespace(HbmConstants.nsPrefix, Configuration.MappingSchemaXMLNS);

            // Since the document is validated, no error checking is done in this method.
            HashedSet classEntries = new HashedSet();

            XmlNode root = document.DocumentElement;

            string assembly = XmlHelper.GetAttributeValue(root, "assembly");
            string @namespace = XmlHelper.GetAttributeValue(root, "namespace");

            XmlNodeList classNodes = document.SelectNodes(
                "//" + HbmConstants.nsClass +
                "|//" + HbmConstants.nsSubclass +
                "|//" + HbmConstants.nsJoinedSubclass +
                "|//" + HbmConstants.nsUnionSubclass,
                nsmgr
                );

            foreach (XmlNode classNode in classNodes)
            {
                string name = XmlHelper.GetAttributeValue(classNode, "name");
                string extends = XmlHelper.GetAttributeValue(classNode, "extends");
                ClassEntry ce = new ClassEntry(extends, name, assembly, @namespace);
                classEntries.Add(ce);
            }

            return classEntries;
        }
Example #6
0
    public List <CharacterSkill> GetSkillsFromLevel(int[] classLevels, ClassEntry startClass, int startLevel)
    {
        List <CharacterSkill> skills = new List <CharacterSkill>();

        bool edit = false;

        for (int i = 0; i < classLevels.Length; i++)
        {
            for (int level = 0; level < classLevels[i]; level++)
            {
                skills.Add(classes[i].skills[level]);
                //Debug.Log("Added skill:  " + classes[i].skills[level].entryName + " for class " + ((PlayerClassName)i));
                edit = true;
            }
        }

        if (!edit)
        {
            int levelups = 1 + (startLevel / 10);
            for (int i = 0; i < levelups; i++)
            {
                skills.Add(startClass.skills[i]);
            }
        }

        return(skills);
    }
Example #7
0
    private void OnRequestUseCard(Card drawnCard)
    {
        if (drawnCard.Player == _player && _isMe)
        {
            AnimateAndUseCard(drawnCard);
        }

        if (!_isMe && drawnCard.Player == _player)
        {
            ClassEntry cardEntry = _cardMap.GetEntryByKey(drawnCard.ID);
            TaskScheduler.Instance.Queue(new UnityTask(delegate
            {
                if (cardEntry != null)
                {
                    GameObject cardInstance = Instantiate(cardEntry.data.prefab, _gameCanvas.transform);
                    CardScript cardScript   = cardInstance.GetComponent <CardScript>();
                    cardScript.Ready(this, drawnCard);

                    _cardsOnHand.Add(cardInstance);

                    AnimateAndUseCard(drawnCard);
                }
            }));
        }
    }
Example #8
0
        private static void DoInit()
        {
            DoValidateTypes();

            List <ClassEntry> exports = new List <ClassEntry>();

            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                foreach (Type type in assembly.GetTypes())
                {
                    ExportClassAttribute attr = Attribute.GetCustomAttribute(type, typeof(ExportClassAttribute), false) as ExportClassAttribute;
                    if (attr != null)
                    {
                        exports.Add(new ClassEntry(type, attr));
                    }

                    RegisterAttribute attr2 = Attribute.GetCustomAttribute(type, typeof(RegisterAttribute), false) as RegisterAttribute;
                    if (attr2 != null)
                    {
                        string name = attr2.Name ?? type.Name;

                        if (type.IsValueType)
                        {
                            TypeEncoder.Register(type, name);
                        }
                        else
                        {
                            NSObject.Register(type, name);
                        }
                    }
                }
            }

            for (int i = 0; i < exports.Count; ++i)                                     // must process base types before derived types
            {
                for (int j = i + 1; j < exports.Count; ++j)                             // crappy O(N^2) sort, but it's difficult to use a more efficient sort because we cannot meaningfully compare two elements in isolation
                {                                                                       // should be OK though, because this is only for exported types, not registered types
                    if (ClassEntry.LeftDerivesFromRight(exports[i], exports[j]))
                    {
                        ClassEntry temp = exports[i];
                        exports[i] = exports[j];
                        exports[j] = temp;
                    }
                }
            }

            foreach (ClassEntry export in exports)
            {
                if (ms_typeNames.ContainsKey(export.Attr.DerivedName))
                {
                    throw new ArgumentException(string.Format("{0} exports {1} but that class name has already been exported.", export.Type, export.Attr.DerivedName));
                }

                ms_typeNames.Add(export.Attr.DerivedName, export.Type);
                ms_classNames.Add(export.Type, export.Attr.DerivedName);

                DoInitClass(export.Attr.DerivedName, export.Attr.BaseName, export.Type, export.Attr.Outlets);
            }
        }
Example #9
0
 public StatsContainer(SpawnData pos)
 {
     level        = pos.level;
     charData     = pos.charData;
     currentClass = pos.charData.startClass;
     classLevels  = pos.charData.startClassLevels;
     GenerateStartingStats();
 }
Example #10
0
        private void deleteButton_Click(object sender, EventArgs e)
        {
            ClassEntry aClassEntry = new ClassEntry();

            aClassEntry.Id = Convert.ToInt32(classIdTextBox.Text);
            string message = aClassEntryManager.DeleteClass(aClassEntry.Id);

            MessageBox.Show(message);

            LoadClassEntryListView();
        }
        public int UpdateClass(ClassEntry aClassEntry)
        {
            query = "UPDATE tbl_classes SET name = '" + aClassEntry.Name + "', order_by = '" + aClassEntry.OrderBy + "' WHERE id = '" + aClassEntry.Id + "'";

            connection.Open();
            command = new SqlCommand(query, connection);
            int rowAffected = command.ExecuteNonQuery();

            connection.Close();

            return(rowAffected);
        }
        public int SaveClass(ClassEntry aClassEntry)
        {
            string query = "INSERT INTO tbl_classes (name, order_by) VALUES ('" + aClassEntry.Name + "','" + aClassEntry.OrderBy + "')";

            connection.Open();
            command = new SqlCommand(query, connection);
            int rowAffected = command.ExecuteNonQuery();

            connection.Close();

            return(rowAffected);
        }
Example #13
0
    public void ChangeClass(ClassEntry newClass)
    {
        eHp         += newClass.hp - currentClass.hp;
        eDmg        += newClass.dmg - currentClass.dmg;
        eMnd        += newClass.mnd - currentClass.mnd;
        eSpd        += newClass.spd - currentClass.spd;
        eSkl        += newClass.skl - currentClass.skl;
        eDef        += newClass.def - currentClass.def;
        currentClass = newClass;

        CalculateStats();
    }
			public bool Equals(ClassEntry obj)
			{
				if (obj == null)
				{
					return false;
				}
				if (ReferenceEquals(this, obj))
				{
					return true;
				}
				return Equals(obj.entityName, entityName) && Equals(obj.fullExtends, fullExtends) && Equals(obj.fullClassName, fullClassName);
			}
Example #15
0
 public bool Equals(ClassEntry obj)
 {
     if (obj == null)
     {
         return(false);
     }
     if (ReferenceEquals(this, obj))
     {
         return(true);
     }
     return(Equals(obj.entityName, entityName) && Equals(obj.fullExtends, fullExtends) && Equals(obj.fullClassName, fullClassName));
 }
        public override List <string> ExecuteSemanticAction(Stack <SemanticRecord> semanticRecordTable, Stack <SymbolTable> symbolTable, IToken lastToken, MoonCodeResult moonCode)
        {
            ClassEntry    typeClass  = null;
            List <string> errors     = new List <string>();
            string        searchType = lastToken.getSemanticName();

            // Check if the type is of int or float
            if (lastToken.getToken() == Tokens.TokenList.IntRes)
            {
                typeClass = intClass;
            }
            else if (lastToken.getToken() == Tokens.TokenList.FloatRes)
            {
                typeClass = floatClass;
            }
            // Check if we are recursively using a type defined in the immediate parent
            else if (symbolTable.Any() && symbolTable.Peek().getParent() != null && symbolTable.Peek().getParent().getName() == searchType)
            {
                errors.Add(string.Format("{0}'s member variable or function parameter cannot refer to its own class at line {1}", searchType, lastToken.getLine()));
                typeClass = symbolTable.Peek().getParent() as ClassEntry;
            }
            else
            {
                // Find the type being referenced in the parent scopes
                foreach (SymbolTable table in symbolTable)
                {
                    // Look through this table's entry list for a type
                    typeClass = table.GetEntries().FirstOrDefault(x => x.getKind() == EntryKinds.classKind && x.getName() == searchType) as ClassEntry;

                    if (typeClass != null)
                    {
                        break;
                    }
                }
            }


            if (typeClass != null)
            {
                semanticRecordTable.Push(new SemanticRecord(typeClass));
            }
            else
            {
                errors.Add(string.Format("Type name: {0} does not exist at line {1}", searchType, lastToken.getLine()));
                semanticRecordTable.Push(new SemanticRecord(new ClassEntry(searchType, 0)));
            }

            return(errors);
        }
Example #17
0
    public override void CopyValues(ScrObjLibraryEntry other)
    {
        base.CopyValues(other);
        ClassEntry cc = (ClassEntry)other;

        className = cc.className;

        icon         = cc.icon;
        playerSprite = cc.playerSprite;
        allySprite   = cc.allySprite;
        enemySprite  = cc.enemySprite;
        bossSprite   = cc.bossSprite;

        classType = cc.classType;
        movespeed = cc.movespeed;

        hp  = cc.hp;
        dmg = cc.dmg;
        mnd = cc.mnd;
        skl = cc.skl;
        spd = cc.spd;
        def = cc.def;

        gHp  = cc.gHp;
        gDmg = cc.gDmg;
        gMnd = cc.gMnd;
        gSkl = cc.gSkl;
        gSpd = cc.gSpd;
        gDef = cc.gDef;

        lockTouch    = cc.lockTouch;
        weaponSkills = new List <WeaponType>();
        for (int i = 0; i < cc.weaponSkills.Count; i++)
        {
            weaponSkills.Add(cc.weaponSkills[i]);
        }
        skills = new List <CharacterSkill>();
        for (int i = 0; i < cc.skills.Count; i++)
        {
            skills.Add(cc.skills[i]);
        }
        bonusHp  = cc.bonusHp;
        bonusDmg = cc.bonusDmg;
        bonusMnd = cc.bonusMnd;
        bonusSkl = cc.bonusSkl;
        bonusSpd = cc.bonusSpd;
        bonusDef = cc.bonusDef;
    }
        public bool IsClassNameExist(ClassEntry aClassEntry)
        {
            query = "SELECT * FROM tbl_classes WHERE name = '" + aClassEntry.Name + "' AND id <> '" + aClassEntry.Id + "'";

            connection.Open();
            command = new SqlCommand(query, connection);

            reader = command.ExecuteReader();

            bool isExist = reader.HasRows;

            reader.Close();
            connection.Close();

            return(isExist);
        }
Example #19
0
        private void classEntryListView_DoubleClick(object sender, EventArgs e)
        {
            ListViewItem selectedItem = classEntryListView.SelectedItems[0];

            ClassEntry aClassEntry = (ClassEntry)selectedItem.Tag;

            deleteButton.Enabled = true;

            if (aClassEntry != null)
            {
                classNameTextBox.Text = aClassEntry.Name;
                orderByTextBox.Text   = aClassEntry.OrderBy.ToString();
                classIdTextBox.Text   = aClassEntry.Id.ToString();

                saveButton.Text = "Update";
            }
        }
Example #20
0
        public string UpdateClass(ClassEntry aClassEntry)
        {
            if (aClassGateway.IsClassNameExist(aClassEntry))
            {
                return("This Class Already Exists");
            }
            else
            {
                int rowAffected = aClassGateway.UpdateClass(aClassEntry);

                if (rowAffected > 0)
                {
                    return("Update Class Succesfully");
                }
                return("Update Failed");
            }
        }
Example #21
0
        public Holder()
        {
            var node1 = new ClassNode(typeof(Class01), new Class01());
            var node2 = new ClassNode(typeof(Class02), new Class02());
            var node3 = new ClassNode(typeof(Class03), new Class03());

            node1.Next = node2;
            node2.Next = node3;
            nodeRef    = node1;

            structEntriesRef    = new StructEntry[3];
            structEntriesRef[0] = new StructEntry(typeof(Class01), new Class01());
            structEntriesRef[1] = new StructEntry(typeof(Class02), new Class02());
            structEntriesRef[2] = new StructEntry(typeof(Class03), new Class03());

            classEntriesRef    = new ClassEntry[3];
            classEntriesRef[0] = new ClassEntry(typeof(Class01), new Class01());
            classEntriesRef[1] = new ClassEntry(typeof(Class02), new Class02());
            classEntriesRef[2] = new ClassEntry(typeof(Class03), new Class03());
        }
Example #22
0
        private void MergeInherited(ClassEntry base_cls, string class_name)
        {
            if (!this._obj.ContainsKey(class_name.ToLower()))
            {
                return;
            }

            CAutoComplete.ClassEntry cls = (ClassEntry)this._obj[class_name.ToLower()];

            if (cls.ClassInheritsFrom == cls.ClassName)
            {
                return;
            }

            if (cls.ClassInheritsFrom != "")
            {
                MergeInherited(cls, cls.ClassInheritsFrom);
            }

            foreach (ClassEntry.FuncEntry func in cls.func_list.Values)
            {
                if (base_cls.func_list.ContainsKey(func.func_name.ToLower()))
                {
                    //base_cls.func_list.Remove(base_cls.func_list[func.func_name.ToLower()]);
                    continue;
                }

                base_cls.func_list.Add(func.func_name.ToLower(), func);
            }

            foreach (ClassEntry.PropEntry prop in cls.prop_list.Values)
            {
                if (base_cls.prop_list.ContainsKey(prop.prop_name.ToLower()))
                {
                    //base_cls.prop_list.Remove(base_cls.prop_list[prop.prop_name.ToLower()]);
                    continue;
                }

                base_cls.prop_list.Add(prop.prop_name.ToLower(), prop);
            }
        }
Example #23
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            ClassEntry aClassEntry = new ClassEntry();

            aClassEntry.Name    = classNameTextBox.Text;
            aClassEntry.OrderBy = Convert.ToInt32(orderByTextBox.Text);

            if (saveButton.Text == "Save")
            {
                string message = aClassEntryManager.SaveClass(aClassEntry);
                MessageBox.Show(message);
            }
            else
            {
                aClassEntry.Id = Convert.ToInt32(classIdTextBox.Text);
                string message = aClassEntryManager.UpdateClass(aClassEntry);
                MessageBox.Show(message);
            }

            LoadClassEntryListView();
        }
Example #24
0
    private void OnCardAddedToHand(Card card, bool isDrawn)
    {
        if (!_isMe)
        {
            return;
        }
        if (card.Player != _player)
        {
            return;
        }

        ClassEntry cardEntry = _cardMap.GetEntryByKey(card.ID);

        if (cardEntry != null)
        {
            GameObject cardInstance = Instantiate(cardEntry.data.prefab, _gameCanvas.transform);
            CardScript cardScript   = cardInstance.GetComponent <CardScript>();
            cardScript.Ready(this, card);

            cardInstance.transform.position = _deckObject.transform.position;

            cardInstance.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f);
            float delay = 0.5f;

            LeanTween
            .scale(cardInstance, new Vector3(0.45f, 0.45f, 0.45f), delay)
            .setDelay(_addToHandDelay)
            .setOnComplete(() =>
            {
                _addToHandDelay -= delay;
            })
            .setOnStart(() =>
            {
                _cardsOnHand.Add(cardInstance);
                ReArrangeCardsOnHand(delay);
                cardScript.FlipCard(true);
            });
            _addToHandDelay += delay;
        }
    }
Example #25
0
        private static void MethodDecl(ClassEntry parentEntry)
        {
            if (analyzer.Token == Symbol.publict)
            {
                Match(Symbol.publict);
                var(type, _) = Type();

                var entry = symTable.Insert <MethodEntry>(analyzer.Lexeme, analyzer.Token, currentDepth);
                entry.ReturnType = type;
                parentEntry.MethodNames.Add(analyzer.Lexeme);

                Emit($"proc {entry.Lexeme}");

                Match(Symbol.idt);
                Match(Symbol.lparent);
                FormalList(entry);
                Match(Symbol.rparent);
                Match(Symbol.begint);
                VarDecl(entry);
                SeqOfStatements(entry);
                Match(Symbol.returnt);
                var retEntry = symTable.Lookup(analyzer.Lexeme);
                Expr(ref retEntry, entry);

                if (retEntry != null)
                {
                    Emit($"_AX = {GetBasePointerOffset(retEntry, entry)}");
                }

                Match(Symbol.semit);
                Match(Symbol.endt);

                Emit($"endp {entry.Lexeme}");
                Emit($""); // space
                currentOffset = 0;

                MethodDecl(parentEntry);
            }
            currentOffset = 0;
        }
        internal MethodHandleEntry ToConstantPool()
        {
            var referenceOwner       = new ClassEntry(new Utf8Entry(Owner.Name));
            var referenceNameAndType = new NameAndTypeEntry(new Utf8Entry(Name), new Utf8Entry(Descriptor.ToString()));
            var reference            = Type switch
            {
                ReferenceKindType.GetField => (ReferenceEntry) new FieldReferenceEntry(referenceOwner,
                                                                                       referenceNameAndType),
                ReferenceKindType.GetStatic => new FieldReferenceEntry(referenceOwner, referenceNameAndType),
                ReferenceKindType.PutField => new FieldReferenceEntry(referenceOwner, referenceNameAndType),
                ReferenceKindType.PutStatic => new FieldReferenceEntry(referenceOwner, referenceNameAndType),
                ReferenceKindType.InvokeVirtual => new MethodReferenceEntry(referenceOwner, referenceNameAndType),
                ReferenceKindType.NewInvokeSpecial => new MethodReferenceEntry(referenceOwner, referenceNameAndType),
                ReferenceKindType.InvokeStatic => new MethodReferenceEntry(referenceOwner, referenceNameAndType),
                ReferenceKindType.InvokeSpecial => new MethodReferenceEntry(referenceOwner, referenceNameAndType),
                ReferenceKindType.InvokeReference => new InterfaceMethodReferenceEntry(referenceOwner,
                                                                                       referenceNameAndType),
                _ => throw new ArgumentOutOfRangeException(nameof(Type))
            };

            return(new MethodHandleEntry(Type, reference));
        }
    }
        public override List <string> ExecuteSemanticAction(Stack <SemanticRecord> semanticRecordTable, Stack <SymbolTable> symbolTable, IToken lastToken, MoonCodeResult moonCode)
        {
            SymbolTable   currentTable = symbolTable.Peek();
            List <string> errors       = new List <string>();
            string        className    = lastToken.getSemanticName();

            // Check if the class' name already exists
            foreach (Entry entry in currentTable.GetEntries())
            {
                if (entry.getName() == className)
                {
                    errors.Add(string.Format("Identifier {0} at line {1} has already been declared", className, lastToken.getLine()));
                    break;
                }
            }

            // Create a class entry
            Entry classEntry = new ClassEntry(className, currentTable);

            symbolTable.Push(classEntry.getChild());

            return(errors);
        }
Example #28
0
    private void SetupValues(CharacterSaveData saveData, CharEntry cStacDatas, ClassEntry cClass)
    {
        charData     = cStacDatas;
        currentClass = cClass;

        if (saveData == null)
        {
            return;
        }

        classLevels = new int[ClassWheel.CLASS_COUNT];
        for (int i = 0; i < ClassWheel.CLASS_COUNT; i++)
        {
            if (i < saveData.classLevels.Length)
            {
                classLevels[i] = saveData.classLevels[i];
            }
        }
        level = saveData.level;
        if (level == -1)
        {
            return;
        }
        currentExp = saveData.currentExp;

        eHp  = saveData.eHp;
        eDmg = saveData.eDmg;
        eMnd = saveData.eMnd;
        eSpd = saveData.eSpd;
        eSkl = saveData.eSkl;
        eDef = saveData.eDef;

        //TODO calculate support boost.
        supportBoost = new Boost();

        CalculateStats();
    }
Example #29
0
        public void Automate()
        {
            var vm = new RegisterStudentViewModel(Navigation);

            UsernameEntry.Completed += (object sender, EventArgs e) =>
            {
                PasswordEntry.Focus();
            };
            PasswordEntry.Completed += (object sender, EventArgs e) =>
            {
                ConfirmPasswordEntry.Focus();
            };
            ConfirmPasswordEntry.Completed += (object sender, EventArgs e) =>
            {
                PhoneNumberEntry.Focus();
            };
            PhoneNumberEntry.Completed += (object sender, EventArgs e) =>
            {
                NameEntry.Focus();
            };
            NameEntry.Completed += (object sender, EventArgs e) =>
            {
                AgeEntry.Focus();
            };
            AgeEntry.Completed += (object sender, EventArgs e) =>
            {
                ClassEntry.Focus();
            };
            ClassEntry.Completed += (object sender, EventArgs e) =>
            {
                INameEntry.Focus();
            };
            INameEntry.Completed += (object sender, EventArgs e) =>
            {
                vm.RegisterStudent.Execute(null);
            };
        }
			private void ReadConfig (XmlTextReader xtr)
			{
				if (!CheckForMWFConfig (xtr))
					return;
				
				while (xtr.Read ()) {
					switch (xtr.NodeType) {
						case XmlNodeType.Element:
							ClassEntry class_entry = classes_hashtable [xtr.Name] as ClassEntry;
							
							if (class_entry == null) {
								class_entry = new ClassEntry ();
								class_entry.ClassName = xtr.Name;
								classes_hashtable [xtr.Name] = class_entry;
							}
							
							class_entry.ReadXml (xtr);
							break;
					}
				}
			}
			public void SetValue (string class_name, string value_name, object value)
			{
				ClassEntry class_entry = classes_hashtable [class_name] as ClassEntry;
				
				if (class_entry == null) {
					class_entry = new ClassEntry ();
					class_entry.ClassName = class_name;
					classes_hashtable [class_name] = class_entry;
				}
				
				class_entry.SetValue (value_name, value);
			}
Example #32
0
        public void LoadClassData(string filename)
        {
            g.LogDebug("CAUTOCOMPLETE::LoadClassData: Enter - " + filename);
            _obj = new Hashtable();

            StreamReader reader = new StreamReader(filename);
            string fulldata = reader.ReadToEnd();
            reader.Close();

            Regex classes = new Regex(@"\s*class\s*(\b[A-Z_][A-Z0-9_]*\b)\s*(\:\s*public\s*(\b[A-Z][A-Z0-9]*\b)\s*)?\s*\{\s*(.*?)\};", RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.Multiline);

            g.LogDebug("CAUTOCOMPLETE::LoadClassData: Loading classes");
            foreach(Match m in classes.Matches(fulldata)) {
                // Define the object and declare their functions
                if (this._obj.ContainsKey(m.Groups[1].Value.ToLower()))
                    continue;

                ClassEntry cls = new ClassEntry();
                cls.ClassName = m.Groups[1].Value;
                cls.ClassInheritsFrom = m.Groups[3].Value;

                // Run a regex on the list of functions
                Regex funcs = new Regex(@"(^\s*\/\*\!\s*(.*)\s*\*\/\n)?^\s*virtual\s*(void|bool|string|int|float|double)\s*(\b[A-Z_][A-Z0-9_]*)\s*\((.*)\)\s*\{\}\s*$", RegexOptions.IgnoreCase | RegexOptions.Multiline);

                foreach(Match func_m in funcs.Matches(m.Groups[4].Value)) {
                    // Insert function data into the arraylists
                    if (cls.func_list.ContainsKey(func_m.Groups[4].Value.ToLower()))
                        continue;

                    ClassEntry.FuncEntry func = new ClassEntry.FuncEntry();
                    func.func_descr = func_m.Groups[2].Value;
                    func.func_name = func_m.Groups[4].Value;
                    func.func_ret = func_m.Groups[3].Value;
                    func.func_params = func_m.Groups[5].Value;

                    cls.func_list.Add(func.func_name.ToLower(), func);
                }

                // ^\s*\/\*\!\s*\n\s*\*\/\n\s*(\b[A-Z_][A-Z0-9_]+\b)\s*(\b[A-Z_][A-Z0-9_]+\b)\s*\;\s*$

                // Pull the list of parameters next
                Regex param_list = new Regex(@"^\s*\/\*\!\s*(\n)?\s*\*\/(\n)?\s*(\b[A-Z_][A-Z0-9_]+\b)\s*(\b[A-Z_][A-Z0-9_]+\b)\s*\;\s*$", RegexOptions.IgnoreCase | RegexOptions.Multiline);

                foreach(Match param_m in param_list.Matches(m.Groups[4].Value)) {
                    // Insert parameter data into the arraylists
                    if (cls.prop_list.ContainsKey(param_m.Groups[4].Value.ToLower()))
                        continue;

                    ClassEntry.PropEntry prop = new ClassEntry.PropEntry();
                    prop.prop_name = param_m.Groups[4].Value;
                    prop.prop_type = param_m.Groups[3].Value;

                    cls.prop_list.Add(prop.prop_name.ToLower(), prop);
                }

                this._obj.Add(m.Groups[1].Value.ToLower(), cls);
            }

            // Merge the inherited functions and properties into the list:
            g.LogDebug("CAUTOCOMPLETE::LoadClassData: Merging inheritence tree");
            foreach(CAutoComplete.ClassEntry cls in this._obj.Values) {
                if (cls.ClassInheritsFrom != "")
                    MergeInherited(cls, cls.ClassInheritsFrom);
            }

            g.LogDebug("CAUTOCOMPLETE::LoadClassData: Done");
        }
Example #33
0
        public void LoadClassData(string filename)
        {
            g.LogDebug("CAUTOCOMPLETE::LoadClassData: Enter - " + filename);
            _obj = new Hashtable();

            StreamReader reader   = new StreamReader(filename);
            string       fulldata = reader.ReadToEnd();

            reader.Close();

            Regex classes = new Regex(@"\s*class\s*(\b[A-Z_][A-Z0-9_]*\b)\s*(\:\s*public\s*(\b[A-Z][A-Z0-9]*\b)\s*)?\s*\{\s*(.*?)\};", RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.Multiline);

            g.LogDebug("CAUTOCOMPLETE::LoadClassData: Loading classes");
            foreach (Match m in classes.Matches(fulldata))
            {
                // Define the object and declare their functions
                if (this._obj.ContainsKey(m.Groups[1].Value.ToLower()))
                {
                    continue;
                }

                ClassEntry cls = new ClassEntry();
                cls.ClassName         = m.Groups[1].Value;
                cls.ClassInheritsFrom = m.Groups[3].Value;

                // Run a regex on the list of functions
                Regex funcs = new Regex(@"(^\s*\/\*\!\s*(.*)\s*\*\/\n)?^\s*virtual\s*(void|bool|string|int|float|double)\s*(\b[A-Z_][A-Z0-9_]*)\s*\((.*)\)\s*\{\}\s*$", RegexOptions.IgnoreCase | RegexOptions.Multiline);

                foreach (Match func_m in funcs.Matches(m.Groups[4].Value))
                {
                    // Insert function data into the arraylists
                    if (cls.func_list.ContainsKey(func_m.Groups[4].Value.ToLower()))
                    {
                        continue;
                    }

                    ClassEntry.FuncEntry func = new ClassEntry.FuncEntry();
                    func.func_descr  = func_m.Groups[2].Value;
                    func.func_name   = func_m.Groups[4].Value;
                    func.func_ret    = func_m.Groups[3].Value;
                    func.func_params = func_m.Groups[5].Value;

                    cls.func_list.Add(func.func_name.ToLower(), func);
                }

                // ^\s*\/\*\!\s*\n\s*\*\/\n\s*(\b[A-Z_][A-Z0-9_]+\b)\s*(\b[A-Z_][A-Z0-9_]+\b)\s*\;\s*$

                // Pull the list of parameters next
                Regex param_list = new Regex(@"^\s*\/\*\!\s*(\n)?\s*\*\/(\n)?\s*(\b[A-Z_][A-Z0-9_]+\b)\s*(\b[A-Z_][A-Z0-9_]+\b)\s*\;\s*$", RegexOptions.IgnoreCase | RegexOptions.Multiline);

                foreach (Match param_m in param_list.Matches(m.Groups[4].Value))
                {
                    // Insert parameter data into the arraylists
                    if (cls.prop_list.ContainsKey(param_m.Groups[4].Value.ToLower()))
                    {
                        continue;
                    }

                    ClassEntry.PropEntry prop = new ClassEntry.PropEntry();
                    prop.prop_name = param_m.Groups[4].Value;
                    prop.prop_type = param_m.Groups[3].Value;

                    cls.prop_list.Add(prop.prop_name.ToLower(), prop);
                }

                this._obj.Add(m.Groups[1].Value.ToLower(), cls);
            }

            // Merge the inherited functions and properties into the list:
            g.LogDebug("CAUTOCOMPLETE::LoadClassData: Merging inheritence tree");
            foreach (CAutoComplete.ClassEntry cls in this._obj.Values)
            {
                if (cls.ClassInheritsFrom != "")
                {
                    MergeInherited(cls, cls.ClassInheritsFrom);
                }
            }

            g.LogDebug("CAUTOCOMPLETE::LoadClassData: Done");
        }
Example #34
0
        private void MergeInherited(ClassEntry base_cls, string class_name)
        {
            if (!this._obj.ContainsKey(class_name.ToLower()))
                return;

            CAutoComplete.ClassEntry cls = (ClassEntry)this._obj[class_name.ToLower()];

            if (cls.ClassInheritsFrom == cls.ClassName)
                return;

            if (cls.ClassInheritsFrom != "")
                MergeInherited(cls, cls.ClassInheritsFrom);

            foreach(ClassEntry.FuncEntry func in cls.func_list.Values) {
                if (base_cls.func_list.ContainsKey(func.func_name.ToLower()))
                    //base_cls.func_list.Remove(base_cls.func_list[func.func_name.ToLower()]);
                    continue;

                base_cls.func_list.Add(func.func_name.ToLower(), func);
            }

            foreach(ClassEntry.PropEntry prop in cls.prop_list.Values) {
                if (base_cls.prop_list.ContainsKey(prop.prop_name.ToLower()))
                    //base_cls.prop_list.Remove(base_cls.prop_list[prop.prop_name.ToLower()]);
                    continue;

                base_cls.prop_list.Add(prop.prop_name.ToLower(), prop);
            }
        }
		/// <summary>
		/// Gets an <see cref="IList"/> of <c>hbm.xml</c> resources in the correct order.
		/// </summary>
		/// <returns>
		/// An <see cref="IList"/> of <c>hbm.xml</c> resources in the correct order.
		/// </returns>
		public IList GetHbmFiles()
		{
			// tracks if any hbm.xml files make use of the "extends" attribute
			bool containsExtends = false;

			foreach( string fileName in _hbmResources ) 
			{
				Stream xmlInputStream = null;
				XmlReader xmlReader = null;

				try 
				{
					xmlInputStream = _assembly.GetManifestResourceStream( fileName );
					xmlReader = new XmlTextReader( xmlInputStream );

					while( xmlReader.Read() )
					{
						if( xmlReader.NodeType != XmlNodeType.Element )
						{
							continue;
						}

						if( xmlReader.Name=="class" )
						{
							xmlReader.MoveToAttribute("name");
							string className = StringHelper.GetClassname( xmlReader.Value );
							ClassEntry ce = new ClassEntry( null, className, fileName );
							_classes.Add(ce);
						}
						else if( xmlReader.Name=="joined-subclass" || xmlReader.Name=="subclass" )
						{
							xmlReader.MoveToAttribute("name");
							string className = StringHelper.GetClassname( xmlReader.Value );
							if( xmlReader.MoveToAttribute("extends") )
							{
								containsExtends = true;
								string baseClassName = StringHelper.GetClassname( xmlReader.Value );
								ClassEntry ce = new ClassEntry( baseClassName, className, fileName );
								_classes.Add(ce);
							}
						}
					}
				}
				finally 
				{
					if( xmlReader!=null ) 
					{
						xmlReader.Close();
					}
					if( xmlInputStream!=null )
					{
						xmlInputStream.Close();
					}
				}
			}

			// only bother to do the sorting if one of the hbm files uses 'extends' - 
			// the sorting does quite a bit of looping through collections so if we don't
			// need to spend the time doing that then don't bother.
			if( containsExtends )
			{
				return OrderedHbmFiles( _classes );
			}
			else
			{
				return _hbmResources;
			}
			
		}
        public override List <string> ExecuteSemanticAction(Stack <SemanticRecord> semanticRecordTable, Stack <SymbolTable> symbolTable, IToken lastToken, MoonCodeResult moonCode)
        {
            Stack <SemanticRecord> callChain = new Stack <SemanticRecord>();
            List <string>          errors    = new List <string>();

            if (!semanticRecordTable.Any())
            {
                errors.Add(string.Format("Grammar error at line {0}: could not verify factor for emtpy stack", lastToken.getLine()));
                return(errors);
            }

            SemanticRecord lastRecord = semanticRecordTable.Pop();

            // Accumulate semantic records until we reach the start of the factor
            while (lastRecord.recordType != RecordTypes.FactorStart)
            {
                callChain.Push(lastRecord);

                if (!semanticRecordTable.Any())
                {
                    errors.Add(string.Format("Grammar error at {0}. Could not find start for a factor", lastToken.getLine()));
                    break;
                }

                lastRecord = semanticRecordTable.Pop();
            }

            SemanticRecord currentLink    = callChain.Pop();
            Entry          linkedVariable = null;

            // The first element in the chain is a reference to a locally accessible variable or function
            // Go through symbol tables of increasing scope until we find the referenced identifier
            foreach (SymbolTable table in symbolTable)
            {
                linkedVariable = table.GetEntries().FirstOrDefault(x => (x is VarParamEntry || x is FunctionEntry) && x.getName() == currentLink.getValue());

                if (linkedVariable != null)
                {
                    break;
                }
            }

            // Verify the validity of this initial reference
            bool success = VerifyLink(currentLink, linkedVariable, lastToken, errors);

            // Go through the call chain and verify each link
            while (callChain.Any() && success)
            {
                currentLink = callChain.Pop();

                ClassEntry referredClass = ((VarParamEntry)linkedVariable).getVariable().getClass();

                if (referredClass.getChild() == null)
                {
                    errors.Add(string.Format("Identifier {0} cannot be reached at line {1}", currentLink.getValue(), lastToken.getLine()));
                    return(errors);
                }

                // Look in the referred class for the variable or function that is being referred to
                linkedVariable = referredClass.getChild().GetEntries().FirstOrDefault(x => (x is VarParamEntry || x is FunctionEntry) && x.getName() == currentLink.getValue());

                success = VerifyLink(currentLink, linkedVariable, lastToken, errors);
            }

            ClassEntry expressionType = new ClassEntry("undefined", 0);

            // Find the linked variable and create a new expression for it
            if (linkedVariable is VarParamEntry)
            {
                expressionType = ((VarParamEntry)linkedVariable).getVariable().getClass();
            }
            else if (linkedVariable is FunctionEntry)
            {
                expressionType = ((FunctionEntry)linkedVariable).GetReturnType();
            }

            if (linkedVariable == null)
            {
                errors.Add(string.Format("Grammar error: Could not link variable at line {0}", lastToken.getLine()));
            }
            else
            {
                semanticRecordTable.Push(new ExpressionRecord(expressionType, linkedVariable.getAddress()));
            }

            return(errors);
        }
        /// <summary>
        /// Returns an <see cref="IList"/> of <c>hbm.xml</c> files in the order that ensures
        /// base classes are loaded before their subclass/joined-subclass.
        /// </summary>
        /// <param name="unorderedClasses">An <see cref="IList"/> of <see cref="ClassEntry"/> objects.</param>
        /// <returns>
        /// An <see cref="IList"/> of <see cref="String"/> objects that contain the <c>hbm.xml</c> file names.
        /// </returns>
        private IList OrderedHbmFiles(IList unorderedClasses)
        {
            // Make sure joined-subclass mappings are loaded after base class
            ArrayList sortedList = new ArrayList();

            foreach (ClassEntry ce in unorderedClasses)
            {
                // this class extends nothing - so put it at the front of
                // the list because it is safe to process at any time.
                if (ce.BaseClassName == null)
                {
                    sortedList.Insert(0, ce);
                }
                else
                {
                    int insertIndex = -1;

                    // try to find this classes base class in the list already
                    for (int i = 0; i < sortedList.Count; i++)
                    {
                        ClassEntry sce = (ClassEntry)sortedList[i];

                        // base class was found - insert at the index
                        // immediately following it
                        if (sce.ClassName == ce.BaseClassName)
                        {
                            insertIndex = i + 1;
                            break;
                        }
                    }

                    // This Classes' baseClass was not found in the list so we still don't
                    // know where to insert it.  Check to see if any of the classes that
                    // have already been sorted derive from this class.
                    if (insertIndex == -1)
                    {
                        for (int j = 0; j < sortedList.Count; j++)
                        {
                            ClassEntry sce = (ClassEntry)sortedList[j];

                            // A class already in the sorted list derives from this class so
                            // insert this class before the class deriving from it.
                            if (sce.BaseClassName == ce.ClassName)
                            {
                                insertIndex = j;
                                break;
                            }
                        }
                    }

                    // could not find any classes that were subclasses of this one or
                    // that this class was a subclass of so it should be inserted at
                    // then end.
                    if (insertIndex == -1)
                    {
                        // Insert at end
                        insertIndex = sortedList.Count;
                    }


                    sortedList.Insert(insertIndex, ce);
                }
            }

            // now that we know the order the classes should be loaded - order the
            // hbm.xml files those classes are contained in.
            StringCollection loadedFiles = new StringCollection();

            foreach (ClassEntry ce in sortedList)
            {
                // Check if this file already loaded (this can happen if
                // we have mappings for multiple classes in one file).
                if (loadedFiles.Contains(ce.FileName) == false)
                {
                    loadedFiles.Add(ce.FileName);
                }
            }

            return(loadedFiles);
        }
        /// <summary>
        /// Gets an <see cref="IList"/> of <c>hbm.xml</c> resources in the correct order.
        /// </summary>
        /// <returns>
        /// An <see cref="IList"/> of <c>hbm.xml</c> resources in the correct order.
        /// </returns>
        public IList GetHbmFiles()
        {
            // tracks if any hbm.xml files make use of the "extends" attribute
            bool containsExtends = false;

            foreach (string fileName in _hbmResources)
            {
                Stream    xmlInputStream = null;
                XmlReader xmlReader      = null;

                try
                {
                    xmlInputStream = _assembly.GetManifestResourceStream(fileName);
                    xmlReader      = new XmlTextReader(xmlInputStream);

                    while (xmlReader.Read())
                    {
                        if (xmlReader.NodeType != XmlNodeType.Element)
                        {
                            continue;
                        }

                        if (xmlReader.Name == "class")
                        {
                            xmlReader.MoveToAttribute("name");
                            string     className = StringHelper.GetClassname(xmlReader.Value);
                            ClassEntry ce        = new ClassEntry(null, className, fileName);
                            _classes.Add(ce);
                        }
                        else if (xmlReader.Name == "joined-subclass" || xmlReader.Name == "subclass")
                        {
                            xmlReader.MoveToAttribute("name");
                            string className = StringHelper.GetClassname(xmlReader.Value);
                            if (xmlReader.MoveToAttribute("extends"))
                            {
                                containsExtends = true;
                                string     baseClassName = StringHelper.GetClassname(xmlReader.Value);
                                ClassEntry ce            = new ClassEntry(baseClassName, className, fileName);
                                _classes.Add(ce);
                            }
                        }
                    }
                }
                finally
                {
                    if (xmlReader != null)
                    {
                        xmlReader.Close();
                    }
                    if (xmlInputStream != null)
                    {
                        xmlInputStream.Close();
                    }
                }
            }

            // only bother to do the sorting if one of the hbm files uses 'extends' -
            // the sorting does quite a bit of looping through collections so if we don't
            // need to spend the time doing that then don't bother.
            if (containsExtends)
            {
                return(OrderedHbmFiles(_classes));
            }
            else
            {
                return(_hbmResources);
            }
        }