public static bool FindMatchingFunctionType(TypeManager typeManager,  List<ClepsVariable> functionOverloads, List<IValue> parameters, out int matchPostition, out string errorMessage)
        {
            if(functionOverloads.Count > 1)
            {
                throw new NotImplementedException("Function overloads not yet supported");
            }

            var functionOverload = functionOverloads[0];
            var functionOverloadType = functionOverload.VariableType as FunctionClepsType;

            if (parameters.Count == functionOverloadType.ParameterTypes.Count &&
                functionOverloadType.ParameterTypes.Zip(parameters.Select(p => p.ExpressionType).ToList(), (targetType, callType) => typeManager.IsSameOrSubTypeOf(targetType, callType)).All(v => v))
            {
                matchPostition = 0;
                errorMessage = null;
                return true;
            }
            else
            {
                string parametersString = String.Join(",", parameters.Select(p => p.ExpressionType.GetClepsTypeString()).ToList());
                matchPostition = -1;
                errorMessage = String.Format("No function overload supports parameters of type: ({0})", parametersString);
                return false;
            }
        }
Example #2
0
        public CompileStatus CompileFiles()
        {
            ClassManager classManager = new ClassManager();
            CompileStatus status = new CompileStatus(Args.ExitOnFirstError);
            ICodeGenerator codeGenerator = new JavaScriptCodeGenerator();
            TypeManager typeManager = new TypeManager();
            EntryPointManager entryPointManager = new EntryPointManager(status, Args.EntryPointClass);

            try
            {
                codeGenerator.Initiate();

                {
                    ClepsClassNamesCollectorVisitor classSkeletonGenerator = new ClepsClassNamesCollectorVisitor(status, classManager, codeGenerator);
                    ParseFilesWithGenerator(classSkeletonGenerator, status);
                }
                {
                    ClepsMemberGeneratorVisitor memberGenerator = new ClepsMemberGeneratorVisitor(status, classManager, codeGenerator, entryPointManager);
                    ParseFilesWithGenerator(memberGenerator, status);
                }
                {
                    ClepsFunctionBodyGeneratorVisitor functionBodyGenerator = new ClepsFunctionBodyGeneratorVisitor(status, classManager, codeGenerator, typeManager);
                    ParseFilesWithGenerator(functionBodyGenerator, status);
                }

                string entryClassName = entryPointManager.GetChosenEntryPointOrNull();

                if (!String.IsNullOrWhiteSpace(entryClassName))
                {
                    codeGenerator.AddEntryPoint(entryClassName, EntryPointManager.EntryPointName);
                }

                codeGenerator.Output(Args.OutputDirectory, Args.OutputFileName, status);
            }
            catch (CompilerLogException)
            {
                //Supress compiler errors
            }
            finally
            {
                codeGenerator.Close();
            }

            return status;
        }
Example #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;
 }