public CsNamespace ConvertPasUnit(PasUnit pasUnit) { var csNamespace = new CsNamespace(); _associations.Assign(pasUnit, csNamespace); _namespace = csNamespace; csNamespace.Name = pasUnit.Name; foreach (var pasUse in pasUnit.InterfaceUses) ConvertPasUse(pasUse, csNamespace); foreach (var pasUse in pasUnit.ImplementationUses) ConvertPasUse(pasUse, csNamespace); foreach (var pasDecl in pasUnit.InterfaceDecls) ConvertPasDecl(pasDecl, csNamespace); foreach (var pasDecl in pasUnit.ImplementationDecls) ConvertPasDecl(pasDecl, csNamespace); _namespace = null; _pendings.SolveAll(_associations); return csNamespace; }
void ConvertPasVarDecl(PasVarDecl pasVar, CsNamespace csNamespace) { ConvertPasVarDecl(pasVar, NamespaceClass(csNamespace), true); }
void ConvertPasUse(PasUse pasUse, CsNamespace csNamespace) { var csUsing = csNamespace.Usings.FirstOrDefault(u => u.Namespace == pasUse.UnitName); if (csUsing == null) csNamespace.Usings.Add(new CsUsing { Namespace = pasUse.UnitName }); }
void ConvertPasStringTypeDecl(PasStringTypeDecl pasString, CsNamespace csNamespace) { var csAlias = new CsAliasTypeDecl(); csAlias.Name = pasString.Name; csAlias.TargetTypeName = "String"; csNamespace.Decls.Add(csAlias); _associations.Assign(pasString, csAlias); }
void ConvertPasSetTypeDecl(PasSetTypeDecl pasSet, CsNamespace csNamespace) { var csSet = new CsClassTypeDecl(); csSet.Name = pasSet.Name; csSet.AncestorRef = new CsRef { Decl = new CsClassTypeDecl { Name = "Set<" + CsTypeNameOf(pasSet.ItemTypeRef) + ">" } }; csNamespace.Decls.Add(csSet); _associations.Assign(pasSet, csSet); }
void ConvertPasRecordTypeDecl(PasRecordTypeDecl pasRecord, CsNamespace csNamespace) { var csStruct = new CsStructTypeDecl(); csStruct.Name = pasRecord.Name; foreach (var pasVar in pasRecord.Vars) ConvertPasDecl(pasVar, csStruct); csNamespace.Decls.Add(csStruct); _associations.Assign(pasRecord, csStruct); }
void ConvertPasProcedureTypeDecl(PasProcedureTypeDecl pasProcedure, CsNamespace csNamespace) { var csDelegate = new CsDelegateDomain(); csDelegate.Name = pasProcedure.Name; ///TODO delegate csNamespace.Decls.Add(csDelegate); _associations.Assign(pasProcedure, csDelegate); }
void ConvertPasArrayTypeDecl(PasArrayTypeDecl pasArray, CsNamespace csNamespace) { /* var csArray = new CsClassDomain(); csArray.Name = pasArray.Name; csArray.AncestorName = CsDomainNameOf(pasArray); csNamespace.Decls.Add(csArray); */ }
void ConvertPasPointerTypeDecl(PasPointerTypeDecl pasPointer, CsNamespace csNamespace) { var csAlias = new CsAliasTypeDecl(); csAlias.Name = pasPointer.Name; csAlias.TargetTypeName = CsTypeNameOf(pasPointer.DataDomain); csNamespace.Decls.Add(csAlias); _associations.Assign(pasPointer, csAlias); }
void ConvertPasMetaclassTypeDecl(PasMetaclassTypeDecl pasMetaclass, CsNamespace csNamespace) { ///TODO throw new NotImplementedException(); }
void ConvertPasEnumTypeDecl(PasEnumTypeDecl pasEnum, CsNamespace csNamespace) { var csEnum = new CsEnumTypeDecl(); csEnum.Name = pasEnum.Name; foreach (var pasConst in pasEnum.Consts) { var csConst = new CsEnumConst { Name = pasConst.Name, EnumDomain = csEnum }; csEnum.Consts.Add(csConst); _associations.Assign(pasConst, csConst); } csNamespace.Decls.Add(csEnum); _associations.Assign(pasEnum, csEnum); }
void ConvertPasDecl(PasDecl pasDecl, CsNamespace csNamespace) { if (pasDecl is PasEnumTypeDecl) ConvertPasEnumTypeDecl(pasDecl as PasEnumTypeDecl, csNamespace); else if (pasDecl is PasArrayTypeDecl) ConvertPasArrayTypeDecl(pasDecl as PasArrayTypeDecl, csNamespace); else if (pasDecl is PasSetTypeDecl) ConvertPasSetTypeDecl(pasDecl as PasSetTypeDecl, csNamespace); else if (pasDecl is PasRecordTypeDecl) ConvertPasRecordTypeDecl(pasDecl as PasRecordTypeDecl, csNamespace); else if (pasDecl is PasPointerTypeDecl) ConvertPasPointerTypeDecl(pasDecl as PasPointerTypeDecl, csNamespace); else if (pasDecl is PasAliasTypeDecl) ConvertPasAliasTypeDecl(pasDecl as PasAliasTypeDecl, csNamespace); else if (pasDecl is PasStringTypeDecl) ConvertPasStringTypeDecl(pasDecl as PasStringTypeDecl, csNamespace); else if (pasDecl is PasProcedureTypeDecl) ConvertPasProcedureTypeDecl(pasDecl as PasProcedureTypeDecl, csNamespace); else if (pasDecl is PasClassTypeDecl) ConvertPasClassTypeDecl(pasDecl as PasClassTypeDecl, csNamespace); else if (pasDecl is PasMetaclassTypeDecl) ConvertPasMetaclassTypeDecl(pasDecl as PasMetaclassTypeDecl, csNamespace); else if (pasDecl is PasVarDecl) ConvertPasVarDecl(pasDecl as PasVarDecl, csNamespace); else if (pasDecl is PasConstDecl) ConvertPasConstDecl(pasDecl as PasConstDecl, csNamespace); else if (pasDecl is PasProcedureDecl) ConvertPasProcedureDecl(pasDecl as PasProcedureDecl, csNamespace); else throw new Exception(string.Format("Tipo desconhecido: {0}", pasDecl.GetType().Name)); }
void ConvertPasConstDecl(PasConstDecl pasConst, CsNamespace csNamespace) { ConvertPasConstDecl(pasConst, NamespaceClass(csNamespace), true); }
void ConvertPasClassTypeDecl(PasClassTypeDecl pasClass, CsNamespace csNamespace) { var csClass = new CsClassTypeDecl(); csClass.Name = pasClass.Name; if (pasClass.Ancestor != null) csClass.AncestorRef = ConvertPasTypeRef(pasClass.Ancestor); csClass.IsStatic = false; foreach (var intf in pasClass.Interfaces) csClass.Interfaces.Add(ConvertPasTypeRef(intf)); foreach (var decl in pasClass.Decls) ConvertPasDecl(decl, csClass); csNamespace.Decls.Add(csClass); _associations.Assign(pasClass, csClass); }
void ConvertPasProcedureDecl(PasProcedureDecl pasProcedure, CsNamespace csNamespace) { if (!string.IsNullOrEmpty(pasProcedure.InClassName)) { var csClass = csNamespace.Decls.Find(e => e.Name == pasProcedure.InClassName) as CsClassTypeDecl; if (csClass == null) throw new Exception(string.Format("Classe não encontrada: {0}", pasProcedure.InClassName)); ConvertPasProcedureDecl(pasProcedure, csClass, false); } else ConvertPasProcedureDecl(pasProcedure, NamespaceClass(csNamespace), true); }
CsClassTypeDecl NamespaceClass(CsNamespace csNamespace) { var found = csNamespace.Decls.Find(p => p.Name == csNamespace.Name) as CsClassTypeDecl; if (found == null) { found = new CsClassTypeDecl(); found.Name = csNamespace.Name; found.IsStatic = true; csNamespace.Decls.Add(found); } return found; }
void ConvertPasAliasTypeDecl(PasAliasTypeDecl pasAlias, CsNamespace csNamespace) { var csAlias = new CsAliasTypeDecl(); csAlias.Name = pasAlias.Name; csAlias.TargetTypeName = CsTypeNameOf(pasAlias.TargetType); csNamespace.Decls.Add(csAlias); _associations.Assign(pasAlias, csAlias); }