Beispiel #1
0
        internal bool IsAConstructor(CFunction function)
        {
            if (function == null)
            {
                return(false);
            }
            CMember ctor = this.Constructor;

            if (null == ctor)
            {
                return(false);
            }
            switch (ctor.MemberType)
            {
            case "method":
                return(((CMethod)ctor).Function == function);

            case "override":
                CMemberOverload cmo = (CMemberOverload)ctor;
                foreach (CMember ctor_overload in cmo.Overloads)
                {
                    if (((CMethod)ctor_overload).Function == function)
                    {
                        return(true);
                    }
                }

                return(false);

            default:
                throw new InvalidOperationException(ctor.MemberType);
            }
        }
Beispiel #2
0
 public virtual void incAccessCount(CClass currentclass, CFunction currentfunction)
 {
     if (assignCount == 0)
     {
         accessedBeforeUsed = true;
     }
     accessCount++;
 }
Beispiel #3
0
        private CProgram()
            : base(null)
        {
            global = this;

            classes["String"]    = BuiltIns.String;
            classes["Int32"]     = BuiltIns.Int32;
            classes["Int64"]     = BuiltIns.Int32;
            classes["Character"] = BuiltIns.Character;
            classes["Boolean"]   = BuiltIns.Boolean;
            classes["Date"]      = BuiltIns.Date;
            classes["Double"]    = BuiltIns.Double;

            classes["__Object"]  = BuiltIns.Object;
            classes["__Variant"] = BuiltIns.Variant;

            // lowercase alias
            classes["byte"]      = BuiltIns.Byte;
            classes["string"]    = BuiltIns.String;
            classes["int32"]     = BuiltIns.Int32;
            classes["int64"]     = BuiltIns.Int32;
            classes["character"] = BuiltIns.Character;
            classes["boolean"]   = BuiltIns.Boolean;
            classes["date"]      = BuiltIns.Date;
            classes["double"]    = BuiltIns.Double;
            classes["object"]    = BuiltIns.Object;
            classes["variant"]   = BuiltIns.Variant;

            classes["DbNull"]  = BuiltIns.DbNull;
            classes["dbnull"]  = BuiltIns.DbNull;
            classes["Nothing"] = BuiltIns.Nothing;

            classes["__Void"] = BuiltIns.Void;

            foreach (KeyValuePair <string, CClass> e in classes)
            {
                e.Value.SetSemanticallyComplete();
                universalClasses[e.Key] = e.Value;
            }

            // Add valueOf method to Date object
            CFunction valueOf = new CFunction(new CToken("", 1, 0, "", TokenTypes.identifier, "valueof", "valueOf", true),
                                              "valueOf", "valueof", TokenTypes.visPublic, FunctionType.Function, new CArgumentList(),
                                              new CTypeRef(null, BuiltIns.Int32));

            valueOf.Attributes.Add(CToken.Identifer(valueOf.Token, "suppressusagewarning"), new CTypeRef(null, CToken.Identifer(valueOf.Token, "SuppressUsageWarningAttribute")));
            valueOf.Attributes.Add(CToken.Identifer(valueOf.Token, "executeonclient"), new CTypeRef(null, CToken.Identifer(valueOf.Token, "ExecuteOnClientAttribute")));
            valueOf.Class = BuiltIns.Date;
            BuiltIns.Date.SetMember("valueof", new CMethod(valueOf));
        }
 public CLambdaFunction(CToken token, CFunction containingFunction, CFile containingFile, String name, CTypeRef tref,
                        CArgumentList args)
     : base(token, name, name, TokenTypes.visInternal, FunctionType.Function, args, tref)
 {
     this.containingFunction = containingFunction;
     this.containingFile     = containingFile;
     if (this.containingFunction != null)
     {
         this.containingFunction.Lambdas.Add(this);
     }
     else
     {
         this.containingFile.Lambdas.Add(this);
     }
     CallCount++;
     Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute")));
 }
Beispiel #5
0
        public void add(CFunction func)
        {
            if (func.Class == null)
            {
                funcs[func.Name] = func;
                funcs[func.FunctionAlias.ToLower()] = func;
            }
            switch (func.FunctionType)
            {
            case CFunction.vbPropertySet:
            case CFunction.vbSub:
                break;

            case CFunction.vbPropertyGet:
            case CFunction.vbFunction:
            default:
                func.scope.add(func.Name, func);
                break;
            }
        }
        public CFunctionType(CToken token, CFunction function, bool declarationOnly)
            : base(token, function.TypeSignature)
        {
            target = function;
            this.declarationOnly = declarationOnly;

            CMethod method = new CMethod(function);

            DefaultMember = method;

            function.TypeChanged += new EventHandler(function_TypeChanged);
            foreach (CArgument arg in function.Arguments)
            {
                arg.TypeChanged += new EventHandler(function_TypeChanged);
            }

            this.IsSealed = true;

            // we don't actually want people accessing the default method directly
            // we also don't want it to get visited through the type.
            // so we don't do this: Members.Add(function.Name, method);
            Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute")));
        }
        internal CStatementBlock StartInitialize(CFunction containingFunction, CFile containingFile, CTypeRef tref, CArgumentList args)
        {
            if (lambdaFunction != null)
            {
                throw new InvalidOperationException("Lambdas can only be initalized once");
            }

            CClass @class = null;
            string extra  = "";

            if (containingFunction != null)
            {
                @class = containingFunction.Class;
                extra += containingFunction.RawName;
            }

            lambdaFunction =
                new CLambdaFunction(Token, containingFunction, containingFile, "Lambda_" + extra + "_" + lambdaId, tref, args);
            base.LoadType(lambdaType = new CFunctionType(Token, lambdaFunction, false));

            lambdaFunction.Class = @class;

            return(lambdaFunction.Statements);
        }
Beispiel #8
0
 public CProperty(CProperty property, bool isUnionMember)
     : base(property.Token, property.Name, "property", 3, isUnionMember)
 {
     Declared[ixGet] = m_get = property.m_get;
     Declared[ixSet] = m_set = property.m_set;
 }
Beispiel #9
0
 public virtual bool canAssign(CClass currentclass, CFunction currentfunction)
 {
     return(currentfunction == this);
 }
Beispiel #10
0
 public virtual void incAssignmentCount(CClass currentclass, CFunction currentfunction)
 {
     assignCount++;
 }
Beispiel #11
0
 public void incAccessCount(CClass currentclass, CFunction currentfunction)
 {
     accesses++;
 }
Beispiel #12
0
 public void incAssignmentCount(CClass currentclass, CFunction currentfunction)
 {
     throw new Exception("Const variable is readonly");
 }
Beispiel #13
0
 public bool canAssign(CClass currentclass, CFunction currentfunction)
 {
     return(false);
 }
Beispiel #14
0
 public CMethod(CFunction func)
     : base(func.Token, func.Name, "method", 1, false)
 {
     Declared[0] = func;
     function    = func;
 }
Beispiel #15
0
 public CMethod(CMethod method, bool isUnionMember)
     : base(method.Token, method.Name, "method", 1, isUnionMember)
 {
     Declared[0] = function = method.function;
 }
Beispiel #16
0
        public bool TryLookupFunction(string name, out CFunction function)
        {
            Dictionary <string, CFunction> functions = FunctionsTable;

            return(functions.TryGetValue(name, out function));
        }