Beispiel #1
0
        void CompileMetaPropertyDefinitions(AstMetaProperty ast, MetaProperty mp)
        {
            var defs = new MetaDefinition[ast.Definitions.Count];

            for (int i = 0; i < defs.Length; i++)
            {
                var fc = new FunctionCompiler(_compiler, mp);

                foreach (var req in ast.Definitions[i].Requirements)
                {
                    DataType dt = null;

                    if (req.Type != null)
                    {
                        dt = _resolver.GetType(mp.Parent, req.Type);
                    }

                    fc.AddReqStatement(new ReqProperty(req.Source, req.Name.Symbol, dt, req.Offset, req.Tag));
                }

                var       fixedInit = ast.Definitions[i].Value as AstFixedArrayInitializer;
                Statement s;

                if (fixedInit != null)
                {
                    s = fc.CompileFixedArrayDeclaration(mp.Source, mp.ReturnType, mp.Name, fixedInit);
                }
                else
                {
                    s = fc.CompileStatement(ast.Definitions[i].Value);

                    if (s is Expression)
                    {
                        s = fc.CompileImplicitCast(mp.Source, mp.ReturnType, s as Expression);
                    }
                }

                // Find implicit req statements
                if (s is Expression)
                {
                    var e = s as Expression;
                    new ReqStatementFinder(fc).VisitNullable(ref e);
                }
                else
                {
                    new ReqStatementFinder(fc).VisitNullable(ref s);
                }

                defs[i] = new MetaDefinition(s, ast.Definitions[i].Tags, fc.ReqStatements);
            }

            mp.SetDefinitions(defs);
        }