示例#1
0
        public AbcScript DefineNamespaceScript(AbcNamespace ns, string name)
        {
            if (ns == null)
            {
                throw new ArgumentNullException("ns");
            }
            var script = _nsscripts[name] as AbcScript;

            if (script != null)
            {
                return(script);
            }
            ns = ImportConst(ns);

            var traitName = DefineName(QName.Global(name));

            script = new AbcScript
            {
                Initializer = DefineEmptyMethod()
            };
            _nsscripts[name] = script;

            script.Traits.AddConst(BuiltinTypes.Namespace, traitName, ns);

            return(script);
        }
示例#2
0
        public void ImportScript(AbcScript from)
        {
            var script = new AbcScript();

            Scripts.Add(script);
            script.Initializer = ImportMethod(from.Initializer);
            ImportTraits(from, script);
        }
示例#3
0
        public void DefineEmptyScript()
        {
            var script = new AbcScript {
                Initializer = DefineEmptyMethod()
            };

            Scripts.Add(script);
        }
示例#4
0
        public void DefineScript(IEnumerable <AbcInstance> instances, Predicate <AbcInstance> filter)
        {
            var script = new AbcScript();

            Scripts.Add(script);
            script.DefineClassTraits(instances, filter);
            DefineScriptInit(script);
        }
示例#5
0
 public void DefineScriptInit(AbcScript script)
 {
     script.Initializer = DefineMethod(
         Sig.@void(),
         code =>
     {
         code.PushThisScope();
         code.InitClassProperties(script);
         code.ReturnVoid();
     }
         );
 }
示例#6
0
        static int CompareScriptInstances(AbcScript s1, AbcScript s2)
        {
            var i1 = s1.SingleInstance;
            var i2 = s2.SingleInstance;

            if (i1 == null)
            {
                if (i2 != null)
                {
                    return(-1);
                }
                return(s1.Index - s2.Index);
            }

            if (i2 == null)
            {
                return(-1);
            }

            return(i1.Index - i2.Index);
        }
示例#7
0
 /// <summary>
 /// Determines whether the given <see cref="AbcScript"/> is defined in this ABC file.
 /// </summary>
 /// <param name="script">script to check</param>
 /// <returns></returns>
 public bool IsDefined(AbcScript script)
 {
     return(Scripts.IsDefined(script));
 }