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 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 ConvertPasVarDecl(PasVarDecl pasVar, CsClassTypeDecl csClass, bool isStatic) { var csField = new CsField(); csField.Name = pasVar.Name; csField.Visibility = CsVisibilityOf(pasVar.Visibility); csField.TypeRef = ConvertPasTypeRef(pasVar.TypeRef); csField.InitialValue = CsValueOf(pasVar.InitialValue); csField.IsStatic = isStatic; csClass.Decls.Add(csField); _associations.Assign(pasVar, csField); }
void ConvertPasPropertyDecl(CsClassTypeDecl csClass, PasProperty pasProperty, bool isStatic) { var csProperty = new CsProperty(); csProperty.Name = pasProperty.Name; csProperty.TypeRef = ConvertPasTypeRef(pasProperty.TypeRef); csProperty.IsStatic = isStatic; csProperty.Visibility = CsVisibilityOf(pasProperty.Visibility); csProperty.ReaderValue = CsValueOf(pasProperty.ReaderValue); csProperty.WriterValue = CsValueOf(pasProperty.WriterValue); csClass.Decls.Add(csProperty); _associations.Assign(pasProperty, csProperty); }
void ConvertPasProcedureDecl(PasProcedureDecl pasProcedure, CsClassTypeDecl csClass, bool isStatic) { /// TODO procurar com mesma lista de parametros var csMethod = csClass.Decls.Find(e => e.Name == pasProcedure.Name) as CsMethodDecl; if (csMethod != null) { var saved = convertingMethod; convertingMethod = csMethod; try { AddDecls(csMethod.Codes, pasProcedure.Decls); AddCodes(csMethod.Codes, pasProcedure.Codes); } finally { convertingMethod = saved; } } else { csMethod = new CsMethodDecl(); var saved = convertingMethod; convertingMethod = csMethod; try { csMethod.Name = pasProcedure.Name; csMethod.ReturnType = ConvertPasTypeRef(pasProcedure.ReturnType); csMethod.IsConstructor = pasProcedure.Approach == PasProcedureApproach.Constructor; csMethod.IsDestructor = pasProcedure.Approach == PasProcedureApproach.Destructor; csMethod.IsOverride = pasProcedure.IsOverride; csMethod.IsVirtual = pasProcedure.IsVirtual; csMethod.IsStatic = pasProcedure.IsStatic || isStatic; csMethod.IsAbstract = pasProcedure.IsAbstract; csMethod.Visibility = CsVisibilityOf(pasProcedure.Visibility); ConvertPasParams(pasProcedure.Params, csMethod.Params); if (pasProcedure.ReturnType != null) csMethod.Codes.Add(new CsLocalVarDecl { Name = "Result", TypeRef = csMethod.ReturnType }); AddDecls(csMethod.Codes, pasProcedure.Decls); AddCodes(csMethod.Codes, pasProcedure.Codes); csClass.Decls.Add(csMethod); _associations.Assign(pasProcedure, csMethod); } finally { convertingMethod = saved; } } }
void ConvertPasDecl(PasDecl pasDecl, CsClassTypeDecl csClass) { if (pasDecl is PasProcedureDecl) ConvertPasProcedureDecl(pasDecl as PasProcedureDecl, csClass, false); else if (pasDecl is PasProperty) ConvertPasPropertyDecl(csClass, pasDecl as PasProperty, false); else if (pasDecl is PasVarDecl) ConvertPasVarDecl(pasDecl as PasVarDecl, csClass, false); else throw new Exception(string.Format("Tipo desconhecido: {0}", pasDecl.GetType().Name)); }
void ConvertPasConstDecl(PasConstDecl pasConst, CsClassTypeDecl csClass, bool isStatic) { var csField = new CsField(); csField.Name = pasConst.Name; csField.Visibility = CsClassVisibility.Public; csField.TypeRef = ConvertPasTypeRef(pasConst.TypeRef); csField.IsConst = true; csField.IsStatic = isStatic; csField.InitialValue = CsValueOf(pasConst.Value); csClass.Decls.Add(csField); _associations.Assign(pasConst, csField); }
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); }