Пример #1
0
        public static CodeExpression ResultExpression(Mono.Build.Result r)
        {
            if (r == null)
            {
                throw new ArgumentNullException();
            }

            CodeObjectCreateExpression oce = new CodeObjectCreateExpression();

            if (r is MBString)
            {
                oce.CreateType = new CodeTypeReference(typeof(MBString));
                oce.Parameters.Add(new CodePrimitiveExpression(((MBString)r).Value));
            }
            else if (r is MBBool)
            {
                oce.CreateType = new CodeTypeReference(typeof(MBBool));
                oce.Parameters.Add(new CodePrimitiveExpression(((MBBool)r).Value));
            }
            else
            {
                throw ExHelp.InvalidOp("Don't know how to emit literal result {0}?", r);
            }

            return(oce);
        }
Пример #2
0
        public StructureParameterKind this[string name]
        {
            get {
            if (!sparams.ContainsKey (name))
            throw ExHelp.InvalidOp ("Trying to get type of undefined parameter `{0}'", name);

            return sparams[name];
            }
        }
Пример #3
0
        public UserType StructParamType(string name)
        {
            if (!sparams.ContainsKey (name))
            throw ExHelp.InvalidOp ("Trying to get type of undefined parameter `{0}'", name);

            if (sparams[name] != StructureParameterKind.Structure)
            throw ExHelp.InvalidOp ("Trying to get type of non-structure parameter `{0}'", name);

            return structtypes[name];
        }
Пример #4
0
        public void AddTypeArgument(UserType arg)
        {
            Type sys = t as Type;

            if (sys != null && !sys.IsGenericType)
            {
                throw ExHelp.InvalidOp("Cannot add type argument on known non-generic type {0}", sys);
            }

            if (typeargs == null)
            {
                typeargs = new List <UserType> ();
            }

            typeargs.Add(arg);
        }
Пример #5
0
        // Returns null and logs an error if the target with the given
        // name has already been defined.

        public TargetBuilder DefineTarget(string name, IWarningLogger log)
        {
            if (done_modifying)
            {
                throw ExHelp.InvalidOp("Cannot define target {0} because its " +
                                       "provider is now unmodifiable", name);
            }

            TargetBuilder tb = EnsureTarget(name);

            if (tb.Define(log))
            {
                return(null);
            }

            return(tb);
        }
Пример #6
0
        TargetBuilder EnsureTarget(string name)
        {
            TargetBuilder tb;

            if (targets.ContainsKey(name))
            {
                tb = targets[name];
            }
            else
            {
                if (done_modifying)
                {
                    throw ExHelp.InvalidOp("Cannot create new target {0} because its " +
                                           "provider is been marked as finished", name);
                }

                tb            = CreateTarget(name);
                targets[name] = tb;
            }

            return(tb);
        }