Пример #1
0
    public Event(InputElement id, SymbolTable declSpace) : base(id, declSpace)
    {
        ClassType c = (ClassType)declSpace.Owner;

        add = c.AddMethod(new InputElement(mangle(id.str, "add_"), id.coord), null);
        add.AddFormal(new InputElement("value", id.coord), null);
        remove = c.AddMethod(new InputElement(mangle(id.str, "remove_"), id.coord), null);
        remove.AddFormal(new InputElement("value", id.coord), null);
    }
Пример #2
0
    public Method AddGet(InputElement id)
    {
        ClassType c = (ClassType)declSpace.Owner;

        get = c.AddMethod(new InputElement(mangle(id.str, "get_"), id.coord), null);
        return(get);
    }
Пример #3
0
    public Method AddSet(InputElement id)
    {
        ClassType c = (ClassType)declSpace.Owner;

        set = c.AddMethod(new InputElement(mangle(id.str, "set_"), id.coord), null);
        set.AddFormal(new InputElement("value", id.coord), null);
        return(set);
    }
Пример #4
0
        private IType ResolveClass(TypeDefinition definition)
        {
            if (_resolvedTypes.ContainsKey(definition))
            {
                return(_resolvedTypes[definition]);
            }
            Console.WriteLine("Loading " + definition.FullName + " (class)");
            ClassType type = new ClassType(definition.FullName);

            _resolvedTypes.Add(definition, type);

            if (definition.BaseType != null)
            {
                type.Parent = ResolveType(definition.BaseType);
            }

            foreach (FieldDefinition field in definition.Fields)
            {
                if (field.InitialValue.Length != 0)
                {
                    throw new NotSupportedException("Initial values not supported!");
                }

                if (field.HasConstant)
                {
                    type.AddField(field, new ConstantField(type, ResolveType(field.FieldType), field.Name,
                                                           field.Constant));
                }
                else if (field.IsStatic)
                {
                    type.AddField(field, new StaticField(type, ResolveType(field.FieldType), field.Name));
                }
                else
                {
                    type.AddField(field, new LocalField(type, ResolveType(field.FieldType), field.Name));
                }
            }

            foreach (MethodDefinition method in definition.Methods)
            {
                IType[] args = method.Parameters.Select(p => ResolveType(p.ParameterType).GetStackType()).ToArray();
                type.AddMethod(method, new StandardMethod(type, method.Name, method.IsStatic,
                                                          !method.IsStatic && !method.IsVirtual && !method.IsAbstract, method.IsVirtual,
                                                          method.HasThis && !method.ExplicitThis, ResolveType(method.ReturnType), args, method.Body));
            }

            type.Init();

            return(type);
        }
Пример #5
0
        private void Visit(MethodDeclNode node, ClassType classType)
        {
            var method = GetMethod(node);

            var methodInfo = new MethodInfo(
                method.Name,
                method.Ret,
                method.Static,
                classType,
                method.Args
                .Select(x => new MethodVarInfo(x.Name, x.Type, MethodVarType.Argument))
                .ToList());

            if (!classType.AddMethod(methodInfo))
            {
                Log(
                    string.Format("В типе {0} метод {1} уже существует",
                                  classType.Name,
                                  method.Name),
                    node);
            }
        }
Пример #6
0
        protected void BuildMethod(ClassType classType, System.Reflection.MethodInfo methodInfo)
        {
            var retType = storage.GetType(ConvertMSILNames(methodInfo.ReturnType));


            var args =
                methodInfo.GetParameters()
                .ToList()
                .Select(x => new { Type = storage.GetType(ConvertMSILNames(x.ParameterType)), Name = x.Name });

            if (!args.Any(x => x.Type == null))
            {
                var method = new plsql_msil.Types.MethodInfo(methodInfo.Name, retType, methodInfo.IsStatic, classType);

                foreach (var item in args)
                {
                    method.AddArg(item.Name, item.Type);
                }

                classType.AddMethod(method);
            }
        }
Пример #7
0
 Method GetMethod(ClassType t, string name, MethodBase info)
 {
     return(GetMethod(t.AddMethod(new InputElement(name), msg), info));
 }
Пример #8
0
 Method GetMethod(ClassType t, string name, MetaDataMethod x, string path)
 {
     return(GetMethod(t.AddMethod(new InputElement(name), msg), x, path));
 }