public override int VisitClassDeclarationStatements([NotNull] ClepsParser.ClassDeclarationStatementsContext context) { if (context.ClassName == null) { //Some antlr parsing exception has occurred. Just exit. return(-1); } CurrentNamespaceAndClass.Add(context.ClassName.GetText()); string className = String.Join(".", CurrentNamespaceAndClass); ClepsClass classDetails; if (!ClassManager.LoadedClassesAndMembers.TryGetValue(className, out classDetails)) { //if the class was not found in the loaded class stage, then this is probably due to an earlier parsing error, just stop processing this class return(-1); } var ret = VisitChildren(context); ClepsType classType = ClepsType.GetBasicType(className, new List <uint>() /* array dims */, 0 /* ptrIndirectionLevel */); LLVMTypeRef?structType = ClepsLLVMTypeConvertorInst.GetLLVMTypeOrNull(classType); Debug.Assert(structType != null); LLVMTypeRef[] memberTypes = GetLLVMTypesArrFromValidClepsTypesList(context, classDetails.MemberVariables.Values.ToList()); LLVM.StructSetBody(structType.Value, memberTypes, false); ValidateClass(context, classDetails); AddConstructor(structType.Value, className); CurrentNamespaceAndClass.RemoveAt(CurrentNamespaceAndClass.Count - 1); return(ret); }
public override bool VisitClassDeclarationStatements_Ex([NotNull] ClepsParser.ClassDeclarationStatementsContext context) { if (!ClassManager.IsClassBuilderAvailable(FullyQualifiedClassName)) { //if the class was not found in the loaded class stage, then this is probably due to an earlier parsing error, just stop processing this class return(false); } if (ClassManager.IsClassBodySet(FullyQualifiedClassName)) { //class body is already set //this branch is hit, if the user has an error in code where multiple classes have the same name //gracefully exit return(false); } Visit(context.classBodyStatements()); ClepsClassBuilder classBuilder = ClassManager.GetClassBuilder(FullyQualifiedClassName); ClepsClass classDetails = classBuilder.BuildClass(); ClassManager.SetClassDefinition(classDetails); CodeGenerator.SetClassBodyAndCreateConstructor(classDetails); return(true); }
public override int VisitClassDeclarationStatements([NotNull] ClepsParser.ClassDeclarationStatementsContext context) { if (context.ClassName == null) { //Some antlr parsing exception has occurred. Just exit. return(-1); } CurrentNamespaceAndClass.Add(context.ClassName.GetText()); string className = String.Join(".", CurrentNamespaceAndClass); //if this qualified name already exists, there is an error if (ClassManager.IsClassLoaded(className)) { string errorMessage = String.Format("Class {0} has multiple definitions", className); Status.AddError(new CompilerError(FileName, context.Start.Line, context.Start.Column, errorMessage)); //Don't process this class return(-1); } LLVMTypeRef structType = LLVM.StructCreateNamed(Context, className); ClassSkeletons[className] = structType; ClassManager.AddNewClass(className); CurrentNamespaceAndClass.RemoveAt(CurrentNamespaceAndClass.Count - 1); return(0); }
public sealed override object VisitClassDeclarationStatements([NotNull] ClepsParser.ClassDeclarationStatementsContext context) { if (context.ClassName == null) { //Some antlr parsing exception has occurred. Just exit. return(false); } CurrentClassHierarchy.Add(context.ClassName.GetText()); var ret = VisitClassDeclarationStatements_Ex(context); CurrentClassHierarchy.RemoveAt(CurrentClassHierarchy.Count - 1); return(ret); }
public override object VisitClassDeclarationStatements_Ex([NotNull] ClepsParser.ClassDeclarationStatementsContext context) { //if this qualified name already exists, there is an error if (ClassManager.IsClassBuilderAvailable(FullyQualifiedClassName)) { string errorMessage = String.Format("Class {0} has multiple definitions", FullyQualifiedClassName); Status.AddError(new CompilerError(FileName, context.Start.Line, context.Start.Column, errorMessage)); //Don't process this class return(false); } ClassManager.AddNewClassDeclaration(FullyQualifiedClassName); CodeGenerator.CreateClass(FullyQualifiedClassName); return(true); }
public override LLVMRegister VisitClassDeclarationStatements([NotNull] ClepsParser.ClassDeclarationStatementsContext context) { if (context.ClassName == null) { //Some antlr parsing exception has occurred. Just exit. return(null); } CurrentNamespaceAndClass.Add(context.ClassName.GetText()); string className = String.Join(".", CurrentNamespaceAndClass); ClepsClass classDetails; if (!ClassManager.LoadedClassesAndMembers.TryGetValue(className, out classDetails)) { //if the class was not found in the loaded class stage, then this is probably due to an earlier parsing error, just stop processing this class return(null); } var ret = VisitChildren(context); CurrentNamespaceAndClass.RemoveAt(CurrentNamespaceAndClass.Count - 1); return(ret); }
/// <summary> /// Exit a parse tree produced by <see cref="ClepsParser.classDeclarationStatements"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void ExitClassDeclarationStatements([NotNull] ClepsParser.ClassDeclarationStatementsContext context) { }
/// <summary> /// Visit a parse tree produced by <see cref="ClepsParser.classDeclarationStatements"/>. /// <para> /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/> /// on <paramref name="context"/>. /// </para> /// </summary> /// <param name="context">The parse tree.</param> /// <return>The visitor result.</return> public virtual Result VisitClassDeclarationStatements([NotNull] ClepsParser.ClassDeclarationStatementsContext context) { return(VisitChildren(context)); }
public virtual object VisitClassDeclarationStatements_Ex([NotNull] ClepsParser.ClassDeclarationStatementsContext context) { var ret = VisitChildren(context); return(ret); }
public virtual bool VisitClassDeclarationStatements_Ex([NotNull] ClepsParser.ClassDeclarationStatementsContext context) { VisitChildren(context); return(true); }