Ejemplo n.º 1
0
        public override void VisitBond(Bond n)
        {
            _mgr.PushScope(string.Format("Bond{0}", _itemIncrementer++));

            if (n.Statements != null)
                n.Statements.Visit(this);

            _mgr.PopScope();

            if (n.Tail != null && !n.Tail.IsEmpty)
                n.Tail.Visit(this);
        }
        public override void VisitBond(Bond n)
        {
            var collatType = _moduleBuilder.GetType("Bond");
            var ctor = _typeManager.GetBuilderInfo("Bond").ConstructorBuilder.Builder;

            _gen.DeclareLocal(collatType);
            _gen.Emit(OpCodes.Newobj, ctor);
            _gen.Emit(OpCodes.Stloc, _internalListIndex);

            SetCurrentType("Bond");
            if (n.Statements != null)
                n.Statements.Visit(this);
            SetCurrentType("Securities");

            // add current item to the list member variable
            _gen.Emit(OpCodes.Ldarg_0);
            _gen.Emit(OpCodes.Ldfld, _typeManager.GetBuilderInfo(_currentType).FieldMap["Bonds"]);
            _gen.Emit(OpCodes.Ldloc, _internalListIndex);

            //get the generic add method and call it
            var listType = typeof(List<>).MakeGenericType(_moduleBuilder.GetType("Bond"));
            var method = TypeBuilder.GetMethod(listType, typeof(List<>).GetMethod("Add"));
            _gen.Emit(OpCodes.Callvirt, method);

            _internalListIndex++;

            if (n.Tail != null && !n.Tail.IsEmpty)
                n.Tail.Visit(this);
        }