Пример #1
0
        public override bool canConvertTo(CClass klass)
        {
            CFunctionType target = klass as CFunctionType;

            if (target == null)
            {
                return(base.canConvertTo(klass));
            }

            UpdateName();
            target.UpdateName();

            return(Name == target.Name);
        }
Пример #2
0
        public static bool PossibleMatch(CFunctionType from, CFunctionType to)
        {
            if (from.Target.Arguments.Count != to.Target.Arguments.Count)
                return false;

            for (int i = 0; i < from.Target.Arguments.Count; i++)
            {
                if (from.Target.Arguments[i].Direction.Value != to.Target.Arguments[i].Direction.Value)
                    return false;

                if (from.Target.Arguments[i].Type.Resolved && to.Target.Arguments[i].Type.Resolved
                    && from.Target.Arguments[i].Type.ActualType != to.Target.Arguments[i].Type.ActualType)
                    return false;
            }

            return true;
        }
        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;
        }
Пример #4
0
        public static bool PossibleMatch(CFunctionType from, CFunctionType to)
        {
            if (from.Target.Arguments.Count != to.Target.Arguments.Count)
            {
                return(false);
            }

            for (int i = 0; i < from.Target.Arguments.Count; i++)
            {
                if (from.Target.Arguments[i].Direction.Value != to.Target.Arguments[i].Direction.Value)
                {
                    return(false);
                }

                if (from.Target.Arguments[i].Type.Resolved && to.Target.Arguments[i].Type.Resolved &&
                    from.Target.Arguments[i].Type.ActualType != to.Target.Arguments[i].Type.ActualType)
                {
                    return(false);
                }
            }

            return(true);
        }
        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);
        }