private void GenerateStructure(IClassContainer classContainer, LinkedList <TreeUIItem> parent) { foreach (var ilClass in classContainer.Classes.OrderBy(x => x.Name)) { var item = new TreeUIItem() { Header = ilClass.ShortName, Parent = ilClass, ItemType = ItemType.Class }; // find a place for this class if (!ilClass.Name.Contains('.')) { parent.AddLast(item); } else { GetTreeUIItemForNamespace(ilClass.ParentAssembly, ilClass.Name, parent).Items.AddLast(item); } // add methods, properties and fields foreach (var unitKey in _unitNameToCollectionMap.Keys) { var collection = _unitNameToCollectionMap[unitKey](ilClass); if (!collection.Any()) { continue; } var itemType = _unitKeyToItemTypeMap[unitKey]; // grouping item var unitItem = new TreeUIItem() { Header = unitKey, ItemType = itemType }; item.Items.AddLast(unitItem); // all methods/properties/fields foreach (var ilUnit in collection) { unitItem.Items.AddLast(new TreeUIItem() { Header = ilUnit.Name, Parent = ilUnit, ItemType = itemType }); } } // add nested classes if (ilClass.Classes.Any()) { var nestedClassesItem = new TreeUIItem() { Header = "Nested classes", ItemType = ItemType.Class }; item.Items.AddLast(nestedClassesItem); GenerateStructure(ilClass, nestedClassesItem.Items); // recursive call for nested classes } } }
public ClassInstancePointer(IClassContainer host, ClassPointer definition, UInt32 instanceId) { if (host == null) { throw new DesignerException("ClassInstancePointer missing host. Instance id [{0}].", instanceId); } _hostingClass = host; _definingClass = definition; _definingClassId = definition.ClassId; _memberId = instanceId; }
public MemoryManager(VirtualMachine Machine, uint codeAddr, uint stackAddr, uint staticAddr, uint heapAddr) { classcontainer = Machine; memory = Machine.memory; this.codeAddr = codeAddr; this.stackAddr = stackAddr; this.localAddr = staticAddr; this.heapAddr = heapAddr; this.allocAddr = 0; this.maxStaticVars = (int)((heapAddr - staticAddr) / 4); this.stackPointer = stackAddr; }
private void GenerateStructure(IClassContainer classContainer, LinkedList<TreeUIItem> parent) { foreach (var ilClass in classContainer.Classes.OrderBy(x => x.Name)) { var item = new TreeUIItem() { Header = ilClass.ShortName, Parent = ilClass, ItemType = ItemType.Class }; // find a place for this class if (!ilClass.Name.Contains('.')) { parent.AddLast(item); } else { GetTreeUIItemForNamespace(ilClass.ParentAssembly, ilClass.Name, parent).Items.AddLast(item); } // add methods, properties and fields foreach (var unitKey in _unitNameToCollectionMap.Keys) { var collection = _unitNameToCollectionMap[unitKey](ilClass); if (!collection.Any()) { continue; } var itemType = _unitKeyToItemTypeMap[unitKey]; // grouping item var unitItem = new TreeUIItem() { Header = unitKey, ItemType = itemType }; item.Items.AddLast(unitItem); // all methods/properties/fields foreach (var ilUnit in collection) { unitItem.Items.AddLast(new TreeUIItem() { Header = ilUnit.Name, Parent = ilUnit, ItemType = itemType }); } } // add nested classes if (ilClass.Classes.Any()) { var nestedClassesItem = new TreeUIItem() { Header = "Nested classes", ItemType = ItemType.Class }; item.Items.AddLast(nestedClassesItem); GenerateStructure(ilClass, nestedClassesItem.Items); // recursive call for nested classes } } }
private void ParseClass(IClassContainer container) { Move(); if (mToken.TagValue != Tag.Identifier) { Error("Identifier expected!"); } var xId = (Word)mToken; var xClass = new ClassDefinition(mResult); xClass.Container = container; xClass.Name = xId.Value; container.Classes.Add(xClass); Move(); Match('{'); while (!IsMatch('}')) { ParseClassMember(xClass); } Move(); // } char was found }
private void ParseClasses(Assembly assembly, IClassContainer classContainer, string ilCode, int offset = 0) { bool newLine = false; bool comment = false; var length = ilCode.Length; var fms = new ILFMS(); ILClass currentClass = null; for (int i = 0; i < length; i++) { fms.GoToNextState(ilCode[i]); if (fms.CurrentState.IsFinal) { var ilUnit = new ILUnit() { ParentAssembly = assembly, ParentClass = currentClass }; if (fms.CurrentState.StateId == ILFMS.StateIdentifier.Class) { int newLineIndex = ilCode.IndexOf(Environment.NewLine, i); var name = ExtractClassName(ilCode, i, newLineIndex); currentClass = new ILClass() { StartIndex = offset + i - 5, NameStartIndex = offset + name.Item1, Name = name.Item2, ParentAssembly = assembly, ParentClass = currentClass }; // append class to the parent if (currentClass.ParentClass != null) { currentClass.ParentClass.Classes.AddLast(currentClass); } else { classContainer.Classes.AddLast(currentClass); } } else if (fms.CurrentState.StateId == ILFMS.StateIdentifier.Method) { SetPropertyMethodName(ilUnit, ilCode, i, offset, MethodNameEndToken); currentClass.Methods.AddLast(ilUnit); } else if (fms.CurrentState.StateId == ILFMS.StateIdentifier.Property) { SetPropertyMethodName(ilUnit, ilCode, i, offset, PropertyNameEndToken); currentClass.Properties.AddLast(ilUnit); } else if (fms.CurrentState.StateId == ILFMS.StateIdentifier.Field) { SetFieldName(ilUnit, ilCode, i, offset); currentClass.Fields.AddLast(ilUnit); } else if (fms.CurrentState.StateId == ILFMS.StateIdentifier.Event) { SetEventName(ilUnit, ilCode, i, offset); currentClass.Events.AddLast(ilUnit); } fms.Restart(); } else if (i + 1 < length && ilCode[i] == '/' && ilCode[i + 1] == '/') //to skip comments next to custom attributes { comment = true; } else if (comment && ilCode[i] == '\n') { comment = false; } else if (!comment && currentClass != null) { // look for class end if (ilCode[i] == '\n') { newLine = true; } else if (ilCode[i] == '{') { currentClass.BracketsCounter++; newLine = false; } else if (ilCode[i] == '}') { if (--currentClass.BracketsCounter == 0 && newLine) //closing bracket should be in another line then the opening one { currentClass.EndIndex = offset + i + 1; currentClass = currentClass.ParentClass; } } } } }
public ClassInstancePointer(IClassContainer host) { _hostingClass = host; }
public void OnPostSerialize(ObjectIDmap objMap, XmlNode objectNode, bool saved, object serializer) { if (saved) { XmlUtil.SetNameAttribute(objectNode, _name); XmlUtil.SetAttribute(objectNode, XmlTags.XMLATT_instanceId, _memberId); XmlUtil.SetAttribute(objectNode, XmlTags.XMLATT_ClassID, ClassId); ClassInstancePointer ip = _hostingClass as ClassInstancePointer; if (ip != null) { XmlNode nd = XmlUtil.CreateSingleNewElement(objectNode, XmlTags.XML_ClassInstance); ip.OnPostSerialize(objMap, nd, saved, serializer); } else { ClassPointer root = _hostingClass as ClassPointer; if (root != null) { if (root.ClassId != objMap.ClassId) { XmlUtil.SetAttribute(objectNode, XmlTags.XMLATT_hostClassId, root.ClassId); } } } //save custom property values if (_properties != null) { XmlObjectWriter writer = (XmlObjectWriter)serializer; PropertyDescriptorCollection pdc = new PropertyDescriptorCollection(_properties.ToArray()); writer.WriteProperties(objectNode, pdc, this, XmlTags.XML_PROPERTY); } } else { _name = XmlUtil.GetNameAttribute(objectNode); if (_memberId == 0) { _memberId = XmlUtil.GetAttributeUInt(objectNode, XmlTags.XMLATT_instanceId); } XmlNode nd = objectNode.SelectSingleNode(XmlTags.XML_ClassInstance); if (nd == null) { //load _hostingClass if (_hostingClass == null) { ClassPointer root; UInt32 hostClassId = XmlUtil.GetAttributeUInt(objectNode, XmlTags.XMLATT_hostClassId); if (hostClassId == 0) { root = ClassPointer.CreateClassPointer(objMap); } else { if (hostClassId == objMap.ClassId) { root = ClassPointer.CreateClassPointer(objMap); } else { root = ClassPointer.CreateClassPointer(hostClassId, objMap.Project); } } if (root == null) { throw new DesignerException("Invalid class id: {0}", hostClassId); } _hostingClass = root; if (_definingClassId == 0) //ClassId may be loaded by property deserialize { IClassRef r = root.ObjectList.GetClassRefById(MemberId); if (r != null) { _definingClassId = r.ClassId; } } } //load _definingClass if (_definingClass == null) { if (_definingClassId == 0) { _definingClassId = XmlUtil.GetAttributeUInt(objectNode, XmlTags.XMLATT_ClassID); } if (_definingClassId == 0) { ClassPointer root = (ClassPointer)_hostingClass; IClassRef r = root.ObjectList.GetClassRefById(MemberId); if (r != null) { _definingClassId = r.ClassId; } } _definingClass = ClassPointer.CreateClassPointer(_definingClassId, objMap.Project); } } else { _definingClassId = XmlUtil.GetAttributeUInt(objectNode, XmlTags.XMLATT_ClassID); ClassInstancePointer ip = new ClassInstancePointer(); ip.OnPostSerialize(objMap, nd, saved, serializer); _hostingClass = ip; if (this.ClassId == 0) //ClassId may be loaded by property deserialize { if (_hostingClass.Definition.ObjectList.Count == 0) { _hostingClass.Definition.ObjectList.LoadObjects(); if (_hostingClass.Definition.ObjectList.Reader.HasErrors) { MathNode.Log(_hostingClass.Definition.ObjectList.Reader.Errors); _hostingClass.Definition.ObjectList.Reader.ResetErrors(); } } IClassRef r = _hostingClass.Definition.ObjectList.GetClassRefById(_memberId); _definingClassId = r.ClassId; } if (_definingClass == null) { _definingClass = ClassPointer.CreateClassPointer(_definingClassId, objMap.Project); } } if (MemberId == 0 && _definingClassId == 0) { //backward compatebility _definingClassId = XmlUtil.GetAttributeUInt(objectNode, XmlTags.XMLATT_ClassID); MemberId = XmlUtil.GetAttributeUInt(objectNode, XmlTags.XMLATT_ComponentID); _definingClass = objMap.Project.GetTypedData <ClassPointer>(_definingClassId); _hostingClass = objMap.GetTypedData <ClassPointer>(); } if (_definingClass != null) //not being deleted { //load custom property definitions XmlObjectReader reader = _definingClass.ObjectList.Reader; if (reader == null) { reader = (XmlObjectReader)serializer; } LoadProperties(reader); //load custom property values LoadCustomPropertyValues(reader, objectNode); } if (MemberId == 0) { MemberId = XmlUtil.GetAttributeUInt(objectNode, XmlTags.XMLATT_ComponentID); } } }