예제 #1
0
        // ClassType
        private void DoClassType()
        {
            LexToken firstClassToken = InputList.CurrentToken();
            Type     thisClassType   = null;

            try {
                thisClassType = Parser.ParseType(InputList, true, false, BindingFlags.Public);
            } catch (Exception ex) {
                InputList.ThrowException("The type of this class needs to be the same as a real C# class in the hosting program.");
            }
            if (ClassType != null && thisClassType != ClassType)
            {
                firstClassToken.ThrowException("The class type must be the same as the previous one '" + ClassType.Name + "'", InputList);
            }
            ClassType = thisClassType;

            if (ClassType.IsValueType)
            {
                firstClassToken.ThrowException("Cannot use a value type for the class.", InputList);
            }
            if (ClassType.IsAbstract && ClassType.IsSealed)
            {
                firstClassToken.ThrowException("Cannot use a static class here.", InputList);
            }
            if (ClassType.IsEnum)
            {
                firstClassToken.ThrowException("Cannot use a Enum type here.", InputList);
            }
            if (!ClassType.IsClass)
            {
                firstClassToken.ThrowException("Must use a class type here.", InputList);
            }
        }
예제 #2
0
        public void DeclareArg(Type type, LexToken name, LexList theList)
        {
            VarInfo found;

            if (VarAccess.TryGetValue(name.Str, out found))
            {
                name.ThrowException("Argument name '" + name.Str + "' is already used.", theList);
            }
            VarAccess.Add(name.Str, new VarInfo(type, true, ArgNames.Count, -1));
            ArgNames.Add(name.Str);
            ArgTypes.Add(type);
        }
예제 #3
0
        public LocalBuilder DeclareLocal(Type type, LexToken name, int nestingLevel, LexList theList)
        {
            if (!IL.Active)
            {
                return(null);
            }
            VarInfo found;

            if (VarAccess.TryGetValue(name.Str, out found))
            {
                name.ThrowException("Local name '" + name.Str + "' is already used.", theList);
            }
            LocalBuilder lb = IL.DeclareLocal_opCodes(type, name.Str);

            VarAccess.Add(name.Str, new VarInfo(type, false, LocalNames.Count, nestingLevel, lb));
            LocalNames.Add(name.Str);
            LocalTypes.Add(type);
            return(lb);
        }