예제 #1
0
        private Function CompileFunctionDeclaration(Type type, FunctionSyntax functionSyntax)
        {
            Type returnType = null;

            if (functionSyntax.typeSyntax != null)
            {
                returnType = typeResolver.ResolveType(functionSyntax.typeSyntax);
            }

            var arguments = new List <FunctionArg>();

            foreach (var arg in functionSyntax.argumentSyntaxes)
            {
                arguments.Add(new FunctionArg(arg.nameToken.value,
                                              typeResolver.ResolveType(arg.typeSyntax)));
            }

            // TODO determine if the function is static analyzing the variable usage
            // TODO do the same for pure
            var isStatic = true;

            return(new Function(type,
                                isStatic,
                                functionSyntax.nameToken.value,
                                arguments,
                                returnType));
        }
예제 #2
0
 public FunctionBodyCompiler(Function function, FunctionSyntax functionSyntax, TypeResolver typeResolver, List <CompilerException> errors)
 {
     this.function       = function;
     this.functionSyntax = functionSyntax;
     this.typeResolver   = typeResolver;
     this.errors         = errors;
     localVariables      = new List <DeclarationStatement>();
 }