예제 #1
0
        private bool CanAddFunctionToClass(string memberName, ClepsType memberType, bool isStatic, out string cantAddReason)
        {
            //for a new member function, no variables, or static functions can have the same name
            //for a new static function, no variables, or member functions can have the same name
            if (
                (isStatic && (
                     MemberVariables.ContainsKey(memberName) ||
                     MemberMethods.ContainsKey(memberName) ||
                     StaticMemberVariables.ContainsKey(memberName))
                )
                ||
                (!isStatic && (
                     MemberVariables.ContainsKey(memberName) ||
                     StaticMemberVariables.ContainsKey(memberName) ||
                     StaticMemberMethods.ContainsKey(memberName))
                )
                )
            {
                cantAddReason = String.Format("Class {0} has multiple definitions of member {1}", FullyQualifiedName, memberName);
                return(false);
            }

            //the name is used by a function in the same class. Check if we can overload the function

            FunctionClepsType    methodMemberType = memberType as FunctionClepsType;
            List <ClepsVariable> methods;

            if (isStatic)
            {
                methods = StaticMemberMethods.ContainsKey(memberName) ? StaticMemberMethods[memberName] : new List <ClepsVariable>();
            }
            else
            {
                methods = MemberMethods.ContainsKey(memberName) ? MemberMethods[memberName] : new List <ClepsVariable>();
            }

            if (FunctionOverloadManager.MatchingFunctionTypeExists(methods.Select(m => m.VariableType as FunctionClepsType).ToList(), methodMemberType))
            {
                cantAddReason = String.Format("Class {0} already has a function {1}{2}.", FullyQualifiedName, memberName, methodMemberType.GetClepsTypeString());
                return(false);
            }
            else
            {
                cantAddReason = null;
                return(true);
            }
        }
예제 #2
0
        public CompileStatus CompileFiles()
        {
            ClassManager classManager = new ClassManager();
            CompileStatus status = new CompileStatus(Args.ExitOnFirstError);
            ICodeGenerator codeGenerator = new JavaScriptCodeGenerator();
            TypeManager typeManager = new TypeManager();
            FunctionOverloadManager functionOverloadManager = new FunctionOverloadManager();

            try
            {
                codeGenerator.Initiate();

                {
                    ClepsClassNamesCollectorVisitor classSkeletonGenerator = new ClepsClassNamesCollectorVisitor(status, classManager, codeGenerator);
                    ParseFilesWithGenerator(classSkeletonGenerator, status);
                }
                {
                    ClepsMemberGeneratorVisitor memberGenerator = new ClepsMemberGeneratorVisitor(status, classManager, codeGenerator);
                    ParseFilesWithGenerator(memberGenerator, status);
                }
                //{
                //    ClepsCodeAnalysisGeneratorParser codeAnalysisGenerator = new ClepsCodeAnalysisGeneratorParser(status, classManager, codeGenerator);
                //    ParseFilesWithGenerator(codeAnalysisGenerator, status);
                //}
                {
                    ClepsFunctionBodyGeneratorVisitor functionBodyGenerator = new ClepsFunctionBodyGeneratorVisitor(status, classManager, codeGenerator, typeManager, functionOverloadManager);
                    ParseFilesWithGenerator(functionBodyGenerator, status);
                }
                codeGenerator.Output(Args.OutputDirectory, Args.OutputFileName, status);
            }
            catch (CompilerErrorException)
            {
                //Supress compiler errors
            }
            finally
            {
                codeGenerator.Close();
            }

            return status;
        }
예제 #3
0
        public CompileStatus CompileFiles()
        {
            ClassManager            classManager            = new ClassManager();
            CompileStatus           status                  = new CompileStatus(Args.ExitOnFirstError);
            ICodeGenerator          codeGenerator           = new JavaScriptCodeGenerator();
            TypeManager             typeManager             = new TypeManager();
            FunctionOverloadManager functionOverloadManager = new FunctionOverloadManager();

            try
            {
                codeGenerator.Initiate();

                {
                    ClepsClassNamesCollectorVisitor classSkeletonGenerator = new ClepsClassNamesCollectorVisitor(status, classManager, codeGenerator);
                    ParseFilesWithGenerator(classSkeletonGenerator, status);
                }
                {
                    ClepsMemberGeneratorVisitor memberGenerator = new ClepsMemberGeneratorVisitor(status, classManager, codeGenerator);
                    ParseFilesWithGenerator(memberGenerator, status);
                }
                //{
                //    ClepsCodeAnalysisGeneratorParser codeAnalysisGenerator = new ClepsCodeAnalysisGeneratorParser(status, classManager, codeGenerator);
                //    ParseFilesWithGenerator(codeAnalysisGenerator, status);
                //}
                {
                    ClepsFunctionBodyGeneratorVisitor functionBodyGenerator = new ClepsFunctionBodyGeneratorVisitor(status, classManager, codeGenerator, typeManager, functionOverloadManager);
                    ParseFilesWithGenerator(functionBodyGenerator, status);
                }
                codeGenerator.Output(Args.OutputDirectory, Args.OutputFileName, status);
            }
            catch (CompilerErrorException)
            {
                //Supress compiler errors
            }
            finally
            {
                codeGenerator.Close();
            }

            return(status);
        }
 public ClepsFunctionBodyGeneratorVisitor(CompileStatus status, ClassManager classManager, ICodeGenerator codeGenerator, TypeManager typeManager, FunctionOverloadManager functionOverloadManager) : base(status, classManager, codeGenerator)
 {
     TypeManager = typeManager;
     FunctionOverloadManager = functionOverloadManager;
 }