Exemplo n.º 1
0
        /// <summary>
        /// Retorna o texto do registro do tipo 54 para uso do SIntegra.
        /// </summary>
        /// <returns>Uma string com os dados formatados para uso do SIntegra.</returns>
        public override string ToString()
        {
            // Formata os dados para o retorno do método
            string n01 = Tipo.ToString();
            string n02 = CNPJ.PadLeft(14, '0');
            string n03 = Modelo.PadLeft(2, '0');
            string n04 = Serie.ToString().PadRight(3);
            string n05 = Numero.ToString().PadLeft(6, '0');
            string n06 = CFOP.PadLeft(4, '0');
            string n07 = CST.PadRight(3);
            string n08 = NumeroItem.ToString().PadLeft(3, '0');

            string n09 = !string.IsNullOrEmpty(CodigoProduto) && CodigoProduto.Length > 14 ?
                         CodigoProduto.Substring(0, 14) : !string.IsNullOrEmpty(CodigoProduto) ?
                         CodigoProduto.PadRight(14) : "".PadRight(14);

            string n10 = Quantidade.ToString("0#######.##0").Remove(8, 1);
            string n11 = ValorProduto.ToString("0#########.#0").Remove(10, 1);
            string n12 = ValorDesconto.ToString("0#########.#0").Remove(10, 1);
            string n13 = BaseCalcICMS.ToString("0#########.#0").Remove(10, 1);
            string n14 = BaseCalcICMSST.ToString("0#########.#0").Remove(10, 1);
            string n15 = ValorIPI.ToString("0#########.#0").Remove(10, 1);
            string n16 = AliquotaICMS.ToString("0#.#0").Remove(2, 1);

            // Retorna os dados formatados
            return(n01 + n02 + n03 + n04 + n05 + n06 + n07 + n08 + n09 + n10 +
                   n11 + n12 + n13 + n14 + n15 + n16);
        }
Exemplo n.º 2
0
        private void PCC_Shown(object sender, EventArgs e)
        {
            //return;
            Thread.Sleep(1000);
            Initialization(this.panel1);
            Thread.Sleep(5000);
            return;

            Thread.Sleep(2000);
            Thread t2 = new Thread(loadDemo);

            t2.Start();
            while (true)
            {
                if (loading_done)
                {
                    //t.Abort();
                    t2.Abort();
                    Thread.Sleep(10000);
                    remote.setCustomView("V_PCC");
                    Thread.Sleep(2000);
                    //初始化 货位
                    CST.InitializStorage();
                    Thread.Sleep(2000);
                    //初始化托盘
                    CST.InitializStorageShowPallet();
                    break;
                }
                Thread.Sleep(1000);
            }
        }
Exemplo n.º 3
0
        public async Task <ActionResult> Post(CST cst)
        {
            _db.Add(cst);
            await _db.SaveChangesAsync();

            return(new CreatedAtRouteResult(nameof(GetByCST), new { cst.Codigo }, cst));
        }
Exemplo n.º 4
0
 private TypeCompilerEnvironment
     (CST.Global global,
      IImSeq<CST.SkolemDef> skolemDefs,
      CST.AssemblyDef assembly,
      CST.TypeDef type,
      IImSeq<CST.TypeRef> typeBoundArguments,
      CompilerEnvironment env,
      JST.NameSupply nameSupply,
      JST.Identifier rootId,
      JST.Identifier assemblyId,
      JST.Identifier typeId,
      IImSeq<JST.Identifier> typeBoundTypeParameterIds,
      TypeTrace typeTrace)
     : base(
         global,
         skolemDefs,
         assembly,
         type,
         typeBoundArguments)
 {
     this.env = env;
     NameSupply = nameSupply;
     this.rootId = rootId;
     this.assemblyId = assemblyId;
     this.typeId = typeId;
     TypeBoundTypeParameterIds = typeBoundTypeParameterIds;
     boundAssemblies = new Map<CST.AssemblyName, JST.Expression>();
     boundTypes = new Map<CST.TypeRef, ExpressionAndPhase>();
     this.typeTrace = typeTrace;
 }
Exemplo n.º 5
0
        public async Task <ActionResult> Put(CST cst)
        {
            _db.Entry(cst).State = EntityState.Modified;
            await _db.SaveChangesAsync();

            return(NoContent());
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Edit(string id, [Bind("Codigo,Descricao")] CST cST)
        {
            if (id != cST.Codigo)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cST);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CSTExists(cST.Codigo))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(cST));
        }
Exemplo n.º 7
0
        protected void MontarCstCabecera(string codigoIdentificacionAduanera7361, string calificadorListaCodigos1131)
        {
            var cst = new CST(null,
                              new CodigoIdentificacionAduanera(codigoIdentificacionAduanera7361, calificadorListaCodigos1131, null));

            Segmentos.Add(cst);
            Mensaje += cst.getSegmento();
        }
Exemplo n.º 8
0
        private void OnEnable()
        {
            bool Flagged = EditorPrefs.GetBool("ScriptTrackerFlagged", true);
            bool Check   = EditorPrefs.GetBool("ScriptTrackerCheck", true);

            checkScriptType = Check ? (Flagged ? CST.Flagged : CST.AllScripts) : CST.Disable;
            settings        = ScriptTracker.LoadScriptTrackerSettings();
        }
Exemplo n.º 9
0
 public void UpdateTime()
 {
     ustDateTime = nServerTime.GetCurrentServerTime();
     PST.UpdateZoneTime(ustDateTime);
     MST.UpdateZoneTime(ustDateTime);
     CST.UpdateZoneTime(ustDateTime);
     EST.UpdateZoneTime(ustDateTime);
     CurrVSServ.updateTime(ustDateTime);
 }
Exemplo n.º 10
0
        public async Task UpdateCst(CST cst)
        {
            var response = await httpService.Put(url, cst);

            if (!response.Success)
            {
                throw new ApplicationException(await response.GetBody());
            }
        }
Exemplo n.º 11
0
        public async Task <IActionResult> Create([Bind("Codigo,Descricao")] CST cST)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cST);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cST));
        }
Exemplo n.º 12
0
        protected void MontarCstPartidas(string numeroPartida, string codigoIdentificacionAduanera7361,
                                         string naturalezaTransaccion, string regimenEstadistico)
        {
            var cst = new CST(numeroPartida,
                              new CodigoIdentificacionAduanera(codigoIdentificacionAduanera7361, _calificadorListaCodigosMercancia, null),
                              null,
                              new CodigoIdentificacionAduanera(naturalezaTransaccion, _calificadorListaCodigosNaturalezaTransaccion, null),
                              new CodigoIdentificacionAduanera(regimenEstadistico, _calificadorListaCodigosRegimenEstadistico, null),
                              null);

            Segmentos.Add(cst);
            Mensaje += cst.getSegmento();
        }
Exemplo n.º 13
0
        private void OnGUI()
        {
            EditorGUI.BeginChangeCheck();
            checkScriptType = (CST)EditorGUILayout.EnumPopup("Prompt Scripts", checkScriptType);
            if (EditorGUI.EndChangeCheck())
            {
                switch ((int)checkScriptType)
                {
                case 0:
                    EditorPrefs.SetBool("ScriptTrackerFlagged", false);
                    EditorPrefs.SetBool("ScriptTrackerCheck", true);
                    break;

                case 1:
                    EditorPrefs.SetBool("ScriptTrackerFlagged", true);
                    EditorPrefs.SetBool("ScriptTrackerCheck", true);
                    break;

                case 2:
                    EditorPrefs.SetBool("ScriptTrackerFlagged", false);
                    EditorPrefs.SetBool("ScriptTrackerCheck", false);
                    break;
                }
            }

            if (checkScriptType == CST.Flagged)
            {
                ScriptTrackerSettings dummy;
                EditorGUI.BeginChangeCheck();
                dummy = (ScriptTrackerSettings)EditorGUILayout.ObjectField("Settings", settings, typeof(ScriptTrackerSettings), false);
                if (EditorGUI.EndChangeCheck())
                {
                    if (dummy != null)
                    {
                        settings = dummy;
                        PlayerPrefs.SetString(ScriptTracker.PREFS_SETTINGSGUID, AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(settings)));
                    }
                }
            }

            if (GUILayout.Button("Allow Current Project Scripts and DLLs"))
            {
                string[] paths = AssetDatabase.FindAssets("t:Script");
                foreach (var p in paths)
                {
                    EditorPrefs.SetBool(p, true);
                }
                Debug.Log("All Scripts in projects added to whitelist");
            }
        }
Exemplo n.º 14
0
 // Collecting mode entry point
 public TypeDefinitionCompiler(AssemblyCompiler parent, CST.TypeDef typeDef)
 {
     Env = parent.Env;
     Parent = parent;
     TyconEnv = parent.AssmEnv.AddType(typeDef);
     TypeTrace = null;
     // Inline type definition and method definitions into overall assembly
     NameSupply = parent.NameSupply;
     // Already bound by parent
     RootId = parent.RootId;
     AssemblyId = parent.AssemblyId;
     // Will be bound locally
     TypeDefinitionId = NameSupply.GenSym();
 }
Exemplo n.º 15
0
 public ActionResult OptionLookup(CST.ISIS.Data.OptionType optType, string optTypeCD, string term)
 {
     if (optType == OptionType.Characteristic)
     {
         return JsonCharValues(optTypeCD, term);
     }
     else if (optType == OptionType.Component)
     {
         return JsonCompValues(optTypeCD, term);
     }
     else
     {
         return Json(null, JsonRequestBehavior.AllowGet);
     }
 }
Exemplo n.º 16
0
        public async Task <IActionResult> Create([Bind("Id_produto,Nome,Valor_unitario,Unidade_medida,Descricao,Estoque_minimo,Estoque_maximo,Estoque_atual,Peso_bruto, Peso_liquido,Fornecedor_Cnpj, Fornecedor, CST_Codigo, CST, CFOP_Codigo, CFOP, NCM_Codigo, NCM")] Produto produto)
        {
            if (ModelState.IsValid)
            {
                Fornecedor fornecedor = new Fornecedor();
                fornecedor.Cnpj = produto.Fornecedor_Cnpj;

                CST cst = new CST();
                cst.Codigo = produto.CST_Codigo;

                CFOP cfop = new CFOP();
                cfop.Codigo = produto.CFOP_Codigo;

                NCM ncm = new NCM();
                ncm.Codigo = produto.NCM_Codigo;

                string lastestFornecedorId = fornecedor.Cnpj;
                produto.Fornecedor_Cnpj = lastestFornecedorId;

                string lastestCSTId = cst.Codigo;
                produto.CST_Codigo = lastestCSTId;

                long lastestCFOPId = cfop.Codigo;
                produto.CFOP_Codigo = lastestCFOPId;

                long lastestNCMId = ncm.Codigo;
                produto.NCM_Codigo = lastestNCMId;

                DateTime localDate = DateTime.Now;

                Historico historico = new Historico();
                historico.Data_inicio        = localDate;
                historico.Produto            = produto;
                historico.Produto_Id_produto = produto.Id_produto;
                historico.Valor = produto.Valor_unitario;

                _context.Add(produto);
                _context.Historico.Add(historico);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Fornecedor_Cnpj"] = new SelectList(_context.Fornecedor, "Cnpj", "NomeEmpresa", produto.Fornecedor_Cnpj);
            ViewData["CFOP_Codigo"]     = new SelectList(_context.CFOP, "Codigo", "FullName");
            ViewData["NCM_Codigo"]      = new SelectList(_context.NCM, "Codigo", "FullName");
            ViewData["CST_Codigo"]      = new SelectList(_context.CST, "Codigo", "FullName");
            return(View(produto));
        }
Exemplo n.º 17
0
 public CST getCST_ID(int id)
 {
     try
     {
         SQL = string.Format("SELECT id, nome FROM fiscal_cst WHERE id = {0} ", id);
         ds  = con.ConsultaSQL(SQL);
         CST obj = null;
         foreach (DataRow dr in ds.Tables[0].Rows)
         {
             obj      = new CST();
             obj.Id   = int.Parse(dr["id"].ToString());
             obj.nome = dr["nome"].ToString();
         }
         return(obj);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemplo n.º 18
0
        public List <CST> selectCST()
        {
            try
            {
                SQL = "SELECT id, nome FROM fiscal_cst ORDER BY id";
                ds  = con.ConsultaSQL(SQL);
                List <CST> ls = new List <CST>();

                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    CST c = new CST();
                    c.Id   = int.Parse(dr["id"].ToString());
                    c.nome = dr["nome"].ToString();
                    ls.Add(c);
                }
                return(ls);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemplo n.º 19
0
        public JsonResult CST(CST rec)
        {
            CSTservices services = new CSTservices();

            services.CST(rec);
            var sub_list = db.Subjects.ToList();

            ViewBag.sb = sub_list;
            var sec_list = db.Sections.ToList();

            ViewBag.sc = sec_list;
            var sat_list = db.Staffs.ToList();

            ViewBag.st = sat_list;
            var cal_list = db.Classes.ToList();

            ViewBag.cl = cal_list;



            return(Json(new { msg = "save" }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 20
0
        // ----------------------------------------------------------------------
        // Methods
        // ----------------------------------------------------------------------

        public JST.Expression MethodCallExpression(CST.MethodRef methodRef, JST.NameSupply localNameSupply, bool isFactory, IImSeq<JST.Expression> arguments)
        {
            return env.JSTHelpers.DefaultMethodCallExpression(this, localNameSupply, methodRef, isFactory, arguments);
        }
Exemplo n.º 21
0
 public JST.Expression ResolveType(CST.TypeRef typeRef)
 {
     return ResolveType(typeRef, TypePhase.Constructed);
 }
Exemplo n.º 22
0
        // ----------------------------------------------------------------------
        // Types
        // ----------------------------------------------------------------------

        public JST.Expression ResolveType(CST.TypeRef typeRef, TypePhase typePhase)
        {
            var groundTypeRef = SubstituteType(typeRef);
            var existing = default(ExpressionAndPhase);
            if (boundTypes.TryGetValue(groundTypeRef, out existing) && typePhase <= existing.Phase)
                return existing.Expression;
            else
                return env.JSTHelpers.DefaultResolveType(this, groundTypeRef, typePhase);
        }
Exemplo n.º 23
0
        // ----------------------------------------------------------------------
        // Assemblies
        // ----------------------------------------------------------------------

        public JST.Expression ResolveAssembly(CST.AssemblyName assemblyName)
        {
            var res = default(JST.Expression);
            if (boundAssemblies.TryGetValue(assemblyName, out res))
                return res;
            else
                return env.JSTHelpers.DefaultResolveAssembly(this, assemblyName);
        }
Exemplo n.º 24
0
        public void BindUsage(ISeq<JST.Statement> statements, CST.Usage usage, TypePhase typePhase)
        {
            foreach (var kv in usage.Assemblies)
            {
                if (kv.Value > 1)
                {
                    if (!boundAssemblies.ContainsKey(kv.Key))
                    {
                        var e = env.JSTHelpers.DefaultResolveAssembly(this, kv.Key);
                        if (e != null)
                        {
                            if (env.DebugMode)
                                statements.Add(new JST.CommentStatement(kv.Key.ToString()));
                            var id = NameSupply.GenSym();
                            statements.Add(JST.Statement.Var(id, e));
                            boundAssemblies.Add(kv.Key, id.ToE());
                        }
                    }
                    // else: use outer binding
                }
                // else: inline expression as need it
            }

            foreach (var kv in usage.Types)
            {
                if (kv.Value > 1)
                {
                    var existing = default(ExpressionAndPhase);
                    var b = boundTypes.TryGetValue(kv.Key, out existing);
                    if (!b || typePhase > existing.Phase)
                    {
                        var e = env.JSTHelpers.DefaultResolveType(this, kv.Key, typePhase);
                        if (e != null)
                        {
                            if (env.DebugMode)
                                statements.Add(new JST.CommentStatement(kv.Key.ToString()));
                            var id = NameSupply.GenSym();
                            statements.Add(JST.Statement.Var(id, e));
                            var updated = new ExpressionAndPhase(id.ToE(), typePhase);
                            if (b)
                                boundTypes[kv.Key] = updated;
                            else
                                boundTypes.Add(kv.Key, updated);
                        }
                    }
                    // else: use outer binding
                }
                // else: inline expression as need it
            }
        }
Exemplo n.º 25
0
        private JST.Expression MethodInfoFromMethod(Seq<JST.Statement> body, TypeCompilerEnvironment innerTypeCompEnv, CST.MethodDef methodDef)
        {
            if (methodDef.TypeArity > 0)
                // TODO: polymorphic methods
                return null;

            if (methodDef.Invalid != null || !methodDef.IsUsed ||
                Env.InlinedMethods.IsInlinable(innerTypeCompEnv.Assembly, innerTypeCompEnv.Type, methodDef))
                // This is possible if method is a getter/setter/adder/removed for a used property
                // or event but the method itself is unused or inlined.
                return null;

            if (methodDef.IsOverriding)
                // MethodInfo will have been supplied by supertype
                return null;

            var slot = Env.GlobalMapping.ResolveMethodDefToSlot(innerTypeCompEnv.Assembly, innerTypeCompEnv.Type, methodDef);
            var attrs = CustomAttributesExpression
                (body,
                 innerTypeCompEnv,
                 CST.MessageContextBuilders.Member
                     (Env.Global, innerTypeCompEnv.Assembly, innerTypeCompEnv.Type, methodDef),
                 methodDef.CustomAttributes);
            var paramTypes = new JST.ArrayLiteral
                (methodDef.ValueParameters.Skip(methodDef.IsStatic ? 0 : 1).Select
                     (p => innerTypeCompEnv.ResolveType(p.Type, TypePhase.Constructed)).ToSeq());
            if (methodDef.IsConstructor)
                return JST.Expression.DotCall
                    (RootId.ToE(),
                     Constants.RootReflectionConstructorInfo,
                     new JST.StringLiteral(slot),
                     TypeId.ToE(),
                     new JST.BooleanLiteral(!methodDef.IsStatic),
                     attrs,
                     paramTypes);
            else
                return JST.Expression.DotCall
                    (RootId.ToE(),
                     Constants.RootReflectionMethodInfo,
                     new JST.StringLiteral(slot),
                     TypeId.ToE(),
                     new JST.BooleanLiteral(methodDef.IsStatic),
                     new JST.BooleanLiteral(!methodDef.IsStatic),
                     new JST.StringLiteral(methodDef.Name),
                     attrs,
                     new JST.BooleanLiteral(methodDef.IsVirtualOrAbstract),
                     paramTypes,
                     new JST.BooleanLiteral(true),
                     methodDef.Result == null
                         ? (JST.Expression)new JST.NullExpression()
                         : innerTypeCompEnv.ResolveType(methodDef.Result.Type, TypePhase.Constructed));
        }
Exemplo n.º 26
0
 public WorksheetEditViewModel(string prodTypeCD, CST.Prdn.Data.Worksheet worksheet)
     : this(prodTypeCD, worksheet.IfNotNull(w => w.ID))
 {
     ProdCD = worksheet.IfNotNull(w => w.ProdCD);
     ProdSetid = worksheet.IfNotNull(w => w.ProdSetid);
 }
Exemplo n.º 27
0
        private JST.Expression FieldInfoFromField(Seq<JST.Statement> body, TypeCompilerEnvironment innerTypeCompEnv, CST.FieldDef fieldDef)
        {
            if (Env.AttributeHelper.FieldHasAttribute
                (innerTypeCompEnv.Assembly,
                 innerTypeCompEnv.Type,
                 fieldDef,
                 Env.Global.CompilerGeneratedAttributeRef,
                 false,
                 false))
                // Ignore compiler-generate fields
                return null;

            var slot = Env.GlobalMapping.ResolveFieldDefToSlot
                (innerTypeCompEnv.Assembly, innerTypeCompEnv.Type, fieldDef);
            return JST.Expression.DotCall
                (RootId.ToE(),
                 Constants.RootReflectionFieldInfo,
                 new JST.StringLiteral(slot),
                 TypeId.ToE(),
                 new JST.BooleanLiteral(fieldDef.IsStatic),
                 new JST.BooleanLiteral(!fieldDef.IsStatic),
                 new JST.StringLiteral(fieldDef.Name),
                 CustomAttributesExpression
                     (body,
                      innerTypeCompEnv,
                      CST.MessageContextBuilders.Member
                          (Env.Global, innerTypeCompEnv.Assembly, innerTypeCompEnv.Type, fieldDef),
                      fieldDef.CustomAttributes),
                 innerTypeCompEnv.ResolveType(fieldDef.FieldType, TypePhase.Constructed),
                 new JST.NullExpression());
        }
Exemplo n.º 28
0
 public virtual object NewRunActionParm(CST.Prdn.Data.ProductionRun newRun)
 {
     return new { prdnOrdNo = newRun.PrdnOrderNo, runID = newRun.ID };
 }
Exemplo n.º 29
0
 public OutOfDateAssemblyMessage(CST.AssemblyName assemblyName, string assemblyFileName, string javaScriptFileName)
     : base(null, Severity.Error, "2002")
 {
     AssemblyName = assemblyName;
     AssemblyFileName = assemblyFileName;
     JavaScriptFileName = javaScriptFileName;
 }
Exemplo n.º 30
0
 public AssemblyNotCompiledMessage(CST.AssemblyName assemblyName, string javaScriptFileName)
     : base(null, Severity.Error, "2003")
 {
     AssemblyName = assemblyName;
     JavaScriptFileName = javaScriptFileName;
 }
Exemplo n.º 31
0
 public SkippingJavaScriptComplilation(CST.AssemblyName assemblyName, string reason)
     : base(null, Severity.Warning, "2009")
 {
     AssemblyName = assemblyName;
     Reason = reason;
 }
Exemplo n.º 32
0
        // ----------------------------------------------------------------------
        // Object helper methods in type structure
        // ----------------------------------------------------------------------

        private void AccumInstanceFields(CST.TypeEnvironment thisTypeEnv, ISeq<CST.FieldRef> fields)
        {
            if (thisTypeEnv.Type.Extends != null)
                AccumInstanceFields(thisTypeEnv.Type.Extends.Enter(thisTypeEnv), fields);

            foreach (var fieldDef in
                thisTypeEnv.Type.Members.OfType<CST.FieldDef>().Where
                    (f => f.Invalid == null && f.IsUsed && !f.IsStatic))
                fields.Add(new CST.FieldRef(thisTypeEnv.TypeRef, fieldDef.FieldSignature));
        }
Exemplo n.º 33
0
        public PrdnCalMonth(int theYear, int theMonth, PrdnEntities thePrdnDB,
            DateTime maxDate, CST.Prdn.Data.ProductionOrder maxPrdnOrder, DateTime lastRunDate)
        {
            year = theYear;
            month = theMonth;
            prdnDB = thePrdnDB;
            firstDayOfMonth = new DateTime(year, month, 1);
            firstDayOfCalendar = StartOfWeek(firstDayOfMonth, firstDayOfWeek).Date;

            int nextMonth = firstDayOfMonth.AddMonths(1).Month;
            int daysInMonth = DateTime.DaysInMonth(year, month);

            lastDayOfMonth = new DateTime(year, month, daysInMonth).Date;
            lastDayOfCalendar = StartOfWeek(lastDayOfMonth.AddDays(7), firstDayOfWeek).AddDays(-1).Date;

            monthName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(month);

            maxCalDate = maxDate;

            if (maxPrdnOrder != null)
            { maxProductionOrder = maxPrdnOrder; }
            else
            { maxProductionOrder = new CST.Prdn.Data.ProductionOrder() { ShipDay = DateTime.MinValue, OrderNo = "0" }; }

            lastPrdnOrdRunDt = lastRunDate;
        }
Exemplo n.º 34
0
        public static TypeCompilerEnvironment EnterType
            (CompilerEnvironment env,
             JST.NameSupply nameSupply,
             JST.Identifier rootId,
             JST.Identifier assemblyId,
             JST.Identifier typeId,
             CST.TypeEnvironment typeEnv,
             TypeTrace typeTrace)
        {
            var typeBoundTypeParameterIds = new Seq<JST.Identifier>();
            for (var i = 0; i < typeEnv.Type.Arity; i++)
                typeBoundTypeParameterIds.Add(nameSupply.GenSym());

            var res = new TypeCompilerEnvironment
                (typeEnv.Global,
                 typeEnv.SkolemDefs,
                 typeEnv.Assembly,
                 typeEnv.Type,
                 typeEnv.TypeBoundArguments,
                 env,
                 nameSupply,
                 rootId,
                 assemblyId,
                 typeId,
                 typeBoundTypeParameterIds,
                 typeTrace);

            res.BindSpecial();

            return res;
        }
Exemplo n.º 35
0
 private JST.Expression PropertyInfoFromProperty(Seq<JST.Statement> body, TypeCompilerEnvironment innerTypeCompEnv, Map<CST.MethodSignature, JST.Identifier> sharedMethodInfos, CST.PropertyDef propDef)
 {
     var slot = Env.GlobalMapping.ResolvePropertyDefToSlot(innerTypeCompEnv.Assembly, innerTypeCompEnv.Type, propDef);
     var slotExp = new JST.StringLiteral(Constants.ObjectPropertySlot(slot));
     return JST.Expression.DotCall
         (RootId.ToE(),
          Constants.RootReflectionPropertyInfo,
          slotExp,
          TypeId.ToE(),
          new JST.BooleanLiteral(propDef.IsStatic),
          new JST.BooleanLiteral(!propDef.IsStatic),
          new JST.StringLiteral(propDef.Name),
          CustomAttributesExpression
              (body, innerTypeCompEnv,
               CST.MessageContextBuilders.Member(Env.Global, innerTypeCompEnv.Assembly, innerTypeCompEnv.Type, propDef),
               propDef.CustomAttributes),
          innerTypeCompEnv.ResolveType(propDef.FieldType, TypePhase.Constructed),
          propDef.Get == null || !sharedMethodInfos.ContainsKey(propDef.Get) ? (JST.Expression)new JST.NullExpression() : sharedMethodInfos[propDef.Get].ToE(),
          propDef.Set == null || !sharedMethodInfos.ContainsKey(propDef.Set) ? (JST.Expression)new JST.NullExpression() : sharedMethodInfos[propDef.Set].ToE());
 }
Exemplo n.º 36
0
 // GET: StudentServices
 public void CST(CST rec)
 {
     db.CSTs.Add(rec);
     db.SaveChanges();
 }
Exemplo n.º 37
0
 private void BindBaseTypes(CST.TypeEnvironment thisTypeEnv, JST.Expression thisType)
 {
     if (thisTypeEnv.Type.Extends != null)
     {
         var baseTypeEnv = thisTypeEnv.Type.Extends.Enter(thisTypeEnv);
         var baseType = JST.Expression.Dot(thisType, Constants.TypeBaseType);
         if (!boundTypes.ContainsKey(baseTypeEnv.TypeRef))
             boundTypes.Add(baseTypeEnv.TypeRef, new ExpressionAndPhase(baseType, TypePhase.Slots));
         if (baseTypeEnv.Type.Arity > 0)
         {
             if (!boundTypes.ContainsKey(baseTypeEnv.TypeConstructorRef))
                 boundTypes.Add(baseTypeEnv.TypeConstructorRef, new ExpressionAndPhase(JST.Expression.Dot(baseType, Constants.TypeApplicand), TypePhase.Slots));
         }
         BindBaseTypes(baseTypeEnv, baseType);
     }
 }
Exemplo n.º 38
0
 private JST.Expression EventInfoFromEvent(Seq<JST.Statement> body, TypeCompilerEnvironment innerTypeCompEnv, Map<CST.MethodSignature, JST.Identifier> sharedMethodInfos, CST.EventDef eventDef)
 {
     var slot = Env.GlobalMapping.ResolveEventDefToSlot(innerTypeCompEnv.Assembly, innerTypeCompEnv.Type, eventDef);
     var slotExp = new JST.StringLiteral(Constants.ObjectEventSlot(slot));
     return JST.Expression.DotCall
         (RootId.ToE(),
          Constants.RootReflectionEventInfo,
          slotExp,
          TypeId.ToE(),
          new JST.BooleanLiteral(eventDef.IsStatic),
          new JST.BooleanLiteral(!eventDef.IsStatic),
          new JST.StringLiteral(eventDef.Name),
          CustomAttributesExpression
              (body, innerTypeCompEnv,
               CST.MessageContextBuilders.Member(Env.Global, innerTypeCompEnv.Assembly, innerTypeCompEnv.Type, eventDef),
               eventDef.CustomAttributes),
          innerTypeCompEnv.ResolveType(eventDef.HandlerType, TypePhase.Constructed),
          eventDef.Add == null || !sharedMethodInfos.ContainsKey(eventDef.Add)
              ? (JST.Expression)new JST.NullExpression()
              : sharedMethodInfos[eventDef.Add].ToE(),
          eventDef.Remove == null || !sharedMethodInfos.ContainsKey(eventDef.Remove)
              ? (JST.Expression)new JST.NullExpression()
              : sharedMethodInfos[eventDef.Remove].ToE());
 }
Exemplo n.º 39
0
        // ----------------------------------------------------------------------
        // Reflection   
        // ----------------------------------------------------------------------

        // The object representing custom attribute
        private JST.Expression CustomAttributeExpression(Seq<JST.Statement> body, TypeCompilerEnvironment innerTypeCompEnv, MessageContext ctxt, CST.CustomAttribute attr)
        {
            if (Env.AttributeHelper.IsSpecialAttribute(attr))
                return null;

            var attrTypeEnv = attr.Type.Enter(innerTypeCompEnv);

            if (attrTypeEnv.Type.Invalid != null || !attrTypeEnv.Type.IsUsed)
            {
                Env.Log
                    (new UnimplementableFeatureMessage
                         (ctxt,
                          "custom attribute",
                          String.Format("Type '{0}' is not marked as [Used] or is invalid", attr.Type)));
                return null;
            }

            var ctorDef =
                attrTypeEnv.Type.Members.OfType<CST.MethodDef>().Where
                    (m =>
                     m.Invalid == null && m.IsUsed && m.IsConstructor && !m.IsStatic &&
                     m.Arity == attr.PositionalProperties.Count + 1).FirstOrDefault();

            if (ctorDef == null)
            {
                Env.Log
                    (new UnimplementableFeatureMessage
                         (ctxt,
                          "custom attribute",
                          String.Format
                              ("Type '{0}' does not have a constructor for {1} positional parameters",
                               attr.Type,
                               attr.PositionalProperties.Count)));
                return null;
            }
            var ctorRef = new CST.MethodRef(attr.Type, ctorDef.MethodSignature, null);

            var args = new Seq<JST.Expression>();
            for (var i = 0; i < attr.PositionalProperties.Count; i++)
            {
                var t = attrTypeEnv.SubstituteType(ctorDef.ValueParameters[i + 1].Type);
                var o = attr.PositionalProperties[i];
                var e = Env.JSTHelpers.InitializerExpression(innerTypeCompEnv, ctxt, o, t);
                args.Add(e);
            }

            var id = innerTypeCompEnv.NameSupply.GenSym();
            body.Add(JST.Statement.Var(id));
            Env.JSTHelpers.ConstructorExpression(innerTypeCompEnv, innerTypeCompEnv.NameSupply, body, id.ToE(), ctorRef, args);

            foreach (var kv in attr.NamedProperties)
            {
                var stmnt = default(JST.Statement);
                foreach (var memberDef in
                    attrTypeEnv.Type.Members.Where
                        (m => !m.IsStatic && m.Name.Equals(kv.Key, StringComparison.Ordinal)))
                {
                    switch (memberDef.Flavor)
                    {
                        case CST.MemberDefFlavor.Field:
                            {
                                var fieldDef = (CST.FieldDef)memberDef;
                                if (fieldDef.Invalid == null && fieldDef.IsUsed)
                                {
                                    var t = attrTypeEnv.SubstituteType(fieldDef.FieldType);
                                    var o = kv.Value;
                                    var e = Env.JSTHelpers.InitializerExpression(innerTypeCompEnv, ctxt, o, t);
                                    var slot = Env.GlobalMapping.ResolveFieldDefToSlot
                                        (attrTypeEnv.Assembly, attrTypeEnv.Type, fieldDef);
                                    stmnt = JST.Statement.DotAssignment
                                        (id.ToE(), new JST.Identifier(Constants.ObjectInstanceFieldSlot(slot)), e);
                                }
                                break;
                            }
                        case CST.MemberDefFlavor.Property:
                            {
                                var propDef = (CST.PropertyDef)memberDef;
                                if (propDef.Invalid == null)
                                {
                                    var t = attrTypeEnv.SubstituteType(propDef.FieldType);
                                    var o = kv.Value;
                                    var e = Env.JSTHelpers.InitializerExpression(innerTypeCompEnv, ctxt, o, t);
                                    if (propDef.Set != null)
                                    {
                                        var setMethodDef = attrTypeEnv.Type.ResolveMethod(propDef.Set);
                                        if (setMethodDef != null && setMethodDef.Invalid == null && setMethodDef.IsUsed &&
                                            setMethodDef.Arity == 2 && !Env.InlinedMethods.IsInlinable(innerTypeCompEnv.Assembly, innerTypeCompEnv.Type, setMethodDef))
                                        {
                                            var setMethodRef = new CST.MethodRef
                                                (attr.Type, setMethodDef.MethodSignature, null);
                                            stmnt = new JST.ExpressionStatement
                                                (innerTypeCompEnv.MethodCallExpression
                                                     (setMethodRef,
                                                      innerTypeCompEnv.NameSupply,
                                                      false,
                                                      new Seq<JST.Expression>(id.ToE(), e)));
                                        }
                                    }
                                }
                                break;
                            }
                        case CST.MemberDefFlavor.Method:
                        case CST.MemberDefFlavor.Event:
                            break;
                        default:
                            throw new ArgumentOutOfRangeException();
                    }
                }
                if (stmnt == null)
                {
                    Env.Log
                        (new UnimplementableFeatureMessage
                             (ctxt,
                              "custom attribute",
                              String.Format
                                  ("Type '{0}' does not have a field or set-able property for named parameter '{1}'",
                                   kv.Key)));
                }
                else
                    body.Add(stmnt);
            }

            return id.ToE();
        }