예제 #1
0
        public MethodInterface(LibraryDeclaration library, MethodImplementationType implementation, string name, bool isPublic, MethodKind kind, VarType returnType, MethodParameter[] parameters, string alias = null)
        {
            this.Name           = name;
            this.Library        = library;
            this.Implementation = implementation;
            this.Kind           = kind;
            this.IsPublic       = isPublic;
            this.ReturnType     = returnType;
            this.Parameters     = parameters;
            this.PreCallback    = null;
            this.PostCallback   = null;

            this.Contract = this.Library.Name;

            if (alias != null)
            {
                this.Alias = alias;
            }
            else
            {
                this.Alias = $"{char.ToUpper(this.Name[0])}{this.Name.Substring(1)}";
                if (implementation == MethodImplementationType.ExtCall)
                {
                    this.Alias = this.Library.Name + '.' + this.Alias;
                }
            }
        }
예제 #2
0
        public MethodInterface AddMethod(string name, MethodImplementationType convention, VarType returnType, MethodParameter[] parameters, string alias = null)
        {
            if (!returnType.IsWeird && Compiler.Instance != null)
            {
                var vmType = MethodInterface.ConvertType(returnType);

                if (!ValidationUtils.IsValidMethod(name, vmType))
                {
                    throw new CompilerException("invalid method name: " + name);
                }
            }

            var method = new MethodInterface(this, convention, name, true, MethodKind.Method, returnType, parameters, alias);

            methods[name] = method;

            return(method);
        }
예제 #3
0
 public MethodInterface AddMethod(string name, MethodImplementationType convention, VarKind returnKind, MethodParameter[] parameters, string alias = null)
 {
     return(AddMethod(name, convention, VarType.Find(returnKind), parameters, alias));
 }