Example #1
0
        private void FindFieldSymbols()
        {
            foreach (FieldInfo f in this.mHostType.GetFields(BindingFlags.Instance |
                                                             BindingFlags.Static |
                                                             BindingFlags.Public |
                                                             BindingFlags.FlattenHierarchy))
            {
                object[] attrs = f.GetCustomAttributes(typeof(AffeBoundAttribute), true);

                if (attrs.Length == 0)
                {
                    continue;
                }

                if (f.FieldType == typeof(ScriptState))
                {
                    this.mState = f;
                    continue;
                }

                AffeBoundAttribute attr = (AffeBoundAttribute)attrs[0];

                string name = (attr.Name == null) ? f.Name : attr.Name;

                this.mTable.AddSymbol(new FieldSymbol(name, f));
            }
        }
Example #2
0
        private void FindMethodSymbols()
        {
            foreach (MethodInfo m in this.mHostType.GetMethods(BindingFlags.Instance |
                                                               BindingFlags.Static |
                                                               BindingFlags.Public |
                                                               BindingFlags.FlattenHierarchy))
            {
                object[] bound = m.GetCustomAttributes(typeof(AffeBoundAttribute), true);
                object[] trans = m.GetCustomAttributes(typeof(AffeTransformAttribute), true);

                if (trans.Length != 0)
                {
                    ParameterInfo[] ps = m.GetParameters();
                    if (ps.Length != 2 ||
                        ps[0].ParameterType != typeof(AffeCompilerState) ||
                        ps[1].ParameterType != typeof(Expression[]))
                    {
                        continue;
                    }

                    string name = m.Name;
                    if (bound.Length > 0)
                    {
                        AffeBoundAttribute battr = (AffeBoundAttribute)bound[0];
                        if (battr.Name != null)
                        {
                            name = battr.Name;
                        }
                    }

                    AffeTransformAttribute tattr = (AffeTransformAttribute)trans[0];

                    this.mTable.AddSymbol(new TransformSymbol(name, m,
                                                              tattr.ResultType));
                }
                else
                {
                    if (bound.Length == 0)
                    {
                        continue;
                    }

                    AffeBoundAttribute attr = (AffeBoundAttribute)bound[0];

                    string name = (attr.Name == null) ? m.Name : attr.Name;

                    this.mTable.AddSymbol(new MethodSymbol(name, m));
                }
            }
        }