Exemplo n.º 1
0
        public override void VisitDeclarationClass(DeclarationClass n)
        {
            var cls = new TypeClass(n.Name);

            _currentClass = cls;
            n.Descriptor  = _scopeMgr.AddClass(cls.ClassName, cls);
            n.Type        = cls;
        }
Exemplo n.º 2
0
 public Prog(DeclarationClass s, DeclarationClass d, DeclarationClass c, DeclarationClass sec, DeclarationClass cpr, DeclarationClass sim)
 {
     Settings = s;
     Deal = d;
     Collateral = c;
     Securities = sec;
     CreditPaymentRules = cpr;
     Simulation = sim;
 }
Exemplo n.º 3
0
 public Prog(DeclarationClass s, DeclarationClass d, DeclarationClass c, DeclarationClass sec, DeclarationClass cpr, DeclarationClass sim)
 {
     Settings           = s;
     Deal               = d;
     Collateral         = c;
     Securities         = sec;
     CreditPaymentRules = cpr;
     Simulation         = sim;
 }
Exemplo n.º 4
0
        private void AddInternalClass(string name)
        {
            var decl = new DeclarationClass(name, new StatementList());

            TypeBuilderMap.Add(name, new TypeBuilderInfo(decl, Module));
            var entry      = TypeBuilderMap[name];
            var builderObj = entry.Builder.DefineDefaultConstructor(MethodAttributes.Public);

            entry.ConstructorBuilder = new ConstructorBuilderInfo(builderObj);
        }
Exemplo n.º 5
0
        private void HandleInternalType(string name, DeclarationClass n)
        {
            SetupInternalClass(n, name);

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

            _gen.Emit(OpCodes.Ret);
        }
Exemplo n.º 6
0
        private ConstructorBuilderInfo CreateInternalClassCtor(DeclarationClass n, string name)
        {
            _currentType        = name;
            _currentTypeBuilder = _typeManager.GetBuilderInfo(n.Name);

            var method = new DeclarationMethod(name, n.Statements)
            {
                Type       = new TypeFunction(true),
                Descriptor = new MethodDescriptor(n.Type, name, n.Descriptor)
            };

            _typeManager.AddCtor(name, method);
            return(_currentTypeBuilder.ConstructorBuilder);
        }
Exemplo n.º 7
0
        //this is a special case since it will be the entry point..
        private MethodBuilderInfo CreateEntryPointMethod(DeclarationClass n, string name)
        {
            _currentType        = name;
            _currentTypeBuilder = _typeManager.GetBuilderInfo(n.Name);

            var method = new DeclarationMethod(name, n.Statements)
            {
                Type       = new TypeFunction(true),
                Descriptor = new MethodDescriptor(n.Type, name, n.Descriptor)
            };

            _typeManager.AddMethod(name, method);

            return(_typeManager.GetMethodBuilderInfo(_currentType, n.Name));
        }
Exemplo n.º 8
0
        public override void VisitDeclarationClass(DeclarationClass n)
        {
            _itemIncrementer = 0;
            _currentClass    = new TypeClass(n.Name);
            var classScope = _mgr.PushScope(string.Format("class {0}", _currentClass.ClassName));

            _currentClass.Descriptor = (ClassDescriptor)_mgr.Find(n.Name, p => p is ClassDescriptor);

            if (n.Statements != null)
            {
                CheckSubTree(n.Statements);
            }

            n.Type = _currentClass;

            _currentClass.Descriptor.Scope = _currentClass.Scope = classScope;
            AddCtorIfNone(classScope, n.Name);
            _mgr.PopScope();
        }
Exemplo n.º 9
0
        private void SetupInternalClass(DeclarationClass n, string name)
        {
            _typeManager.AddClass(n);

            if (name.Equals(ENTRY_POINT, StringComparison.OrdinalIgnoreCase))
            {
                var methodInfo = CreateEntryPointMethod(n, name);
                _gen = methodInfo.Builder.GetILGenerator();

                foreach (var item in Enum.GetNames(typeof(InternalTrancheTypes)))
                {
                    var ident       = new Identifier(n.Location, item);
                    var instantiate = new InstantiateClass(item, new ExpressionList());
                    var assign      = new Assign(ident, instantiate)
                    {
                        InternalType = new TypeClass(item)
                    };

                    VisitAssign(assign);
                }

                _assemblyBuilder.SetEntryPoint(methodInfo.Builder);
            }
            else
            {
                var ctorInfo = CreateInternalClassCtor(n, name);
                _gen = ctorInfo.Builder.GetILGenerator();

                var baseCtor = typeof(object).GetConstructor(Type.EmptyTypes);
                _gen.Emit(OpCodes.Ldarg_0); //this.
                if (baseCtor != null)
                {
                    _gen.Emit(OpCodes.Call, baseCtor);
                }
            }
        }
Exemplo n.º 10
0
 public virtual void VisitDeclarationClass(DeclarationClass n)
 {
 }
Exemplo n.º 11
0
 public TypeBuilderInfo(DeclarationClass n, ModuleBuilder module)
 {
     Builder = module.DefineType(n.Name, TypeAttributes.Public);
     Init();
 }
Exemplo n.º 12
0
 public virtual void VisitDeclarationClass(DeclarationClass n)
 {
 }
Exemplo n.º 13
0
 public void AddClass(DeclarationClass n)
 {
     TypeBuilderMap.Add(n.Name, new TypeBuilderInfo(n, Module));
 }