Пример #1
0
        private ZType GetZTypeByTypeName(string typeName)
        {
            //if (typeName == "Func<bool>")
            //{
            //    arg = new ZMethodArg(typeName, ZTypeCache.GetByZType(typeof(Func<bool>)));
            //}
            //else if (argtypename == "Action")
            //{
            //    arg = new ZMethodArg(realArgName, ZTypeCache.GetByZType(typeof(Action)));
            //}
            //else
            //{

            var ztypes = ZTypeManager.GetByMarkName(typeName);

            if (ztypes.Length == 0)
            {
                ztypes = ZTypeManager.GetBySharpName(typeName);
            }
            if (ztypes.Length > 0)
            {
                ZType ztype = ztypes[0] as ZType;
                //arg = new ZMethodArg(typeName, ztype);
                return(ztype);
            }
            else
            {
            }
            return(null);
        }
Пример #2
0
        //public Type DimType { get; set; }

        //public SymbolLocalVar(string name)
        //{
        //    this.SymbolName = name;
        //}

        public SymbolLocalVar(string name, ZType type)
        {
            this.SymbolName = name;
            SymbolZType     = type;
            CanRead         = true;
            CanWrite        = true;
        }
Пример #3
0
 /// <summary>
 /// Date        Coder       Vers        Notes
 /// 2020-01-09  Clay        1.0         Initial
 ///
 /// There will be several overloads for the constructor.
 /// </summary>
 /// <param name="L"></param>
 /// <param name="N"></param>
 /// <param name="ZType"></param>
 /// <param name="Size"></param>
 public Horde(GeoEngine_Workspace.Location L, String N, ZType ZType, HordeSize Size)
 {
     this.ContactLocation  = L;
     this.ContactName      = N;
     this.ContactType      = ZType;
     this.ContactHordeSize = Size;
 }
Пример #4
0
        private void AnalyType()
        {
            if (_IsExist)
            {
                return;
            }
            ContextImportUse contextiu = this.FileContext.ImportUseContext;

            string[] names = contextiu.GetArgSegementer().Cut(ArgText);
            if (names.Length != 2)
            {
                throw new CCException();
            }
            ArgZTypeName = names[0];
            ArgName      = names[1];
            if (this.MethodContext.HasParameter(ArgName))
            {
                _IsExist = true;
                CodePosition argPos = new CodePosition(ParameterRaw.ParameterToken.Line, ParameterRaw.ParameterToken.Col + ArgZTypeName.Length);
                FileContext.Errorf(argPos, "参数'{0}'重复", ArgName);
            }
            else
            {
                ZType[] ztypes = contextiu.SearchZTypesByClassNameOrDimItem(ArgZTypeName);
                ArgZType = ztypes[0];
                //_argSymbol = new SymbolArg(ArgName, ArgZType);
                //this.ProcContext.AddParameter(_argSymbol);
                //_argSymbol = new ZCParamInfo(ArgName, ArgZType);
                //ProcContext.AddParameter(_argSymbol);
                _ZCParam            = MethodContext.AddParameterName(ArgName);
                _ZCParam.ZParamType = ArgZType;
            }
        }
Пример #5
0
 public static ZTypeCompareEnum Compare(ZType z1, ZType z2)
 {
     if (z1 is ZLEnumInfo || z2 is ZLEnumInfo)
     {
         return(ZTypeCompareEnum.NEQ);
     }
     if (z1.IsRuntimeType || z2.IsRuntimeType)
     {
         return(ZTypeCompareEnum.NEQ);
     }
     if (z1 is ZCClassInfo)
     {
         if (z2 is ZCClassInfo)
         {
             return(Compare((ZCClassInfo)z1, (ZCClassInfo)z2));
         }
         else
         {
             return(Compare((ZCClassInfo)z1, (ZLClassInfo)z2));
         }
     }
     else
     {
         if (z2 is ZCClassInfo)
         {
             return(Compare((ZLClassInfo)z1, (ZCClassInfo)z2));
         }
         else
         {
             return(Compare((ZLClassInfo)z1, (ZLClassInfo)z2));
         }
     }
 }
Пример #6
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Code,DescriptionRU,DescriptionKK,DescriptionEN,Color")] ZType zType)
        {
            if (id != zType.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(zType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ZTypeExists(zType.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(zType));
        }
Пример #7
0
        private void AnalyFields( )
        {
            var symbols = NestedClassContext.Symbols;

            FieldSymbols = new List <SymbolDefField>();
            if (ExpContext.ClassContext.IsStaticClass == false)
            {
                TypeBuilder    builder     = ExpContext.ClassContext.EmitContext.ClassBuilder;
                FieldBuilder   field       = ClassBuilder.DefineField(OutClassFieldName, builder, FieldAttributes.Public);
                ZType          ztype       = new ZClassType(builder, builder, false);
                SymbolDefField fieldSymbol = new SymbolDefField(OutClassFieldName, ztype, false);
                fieldSymbol.Field = field;
                FieldSymbols.Add(fieldSymbol);
                symbols.Add(fieldSymbol);
                this.NestedClassContext.NestedOutFieldSymbol = fieldSymbol;
            }

            foreach (SymbolBase symbol in BodyVars)
            {
                ZType          ztype       = symbol.SymbolZType;
                FieldBuilder   field       = ClassBuilder.DefineField(symbol.SymbolName, ztype.SharpType, FieldAttributes.Public);
                SymbolDefField fieldSymbol = new SymbolDefField(symbol.SymbolName, ztype, false);
                fieldSymbol.Field = field;
                FieldSymbols.Add(fieldSymbol);
                symbols.Add(fieldSymbol);
            }

            foreach (ExpVar expVar in FieldExpVars)
            {
                SymbolDefField symbol = symbols.Get(expVar.VarName) as SymbolDefField;
                expVar.SetAsLambdaFiled(symbol);
            }
        }
Пример #8
0
 public SymbolDefMember(string name, ZType memberType, bool isStatic)
 {
     this.SymbolName = name;
     SymbolZType     = memberType;
     HasDefaultValue = true;
     IsStatic        = isStatic;
 }
Пример #9
0
        protected void DownToExcel_B_Click(object sender, EventArgs e)
        {
            OfficeHelper office = new OfficeHelper();
            string       name   = ZType.ToLower().Equals("comment") ? "评论排行.xls" : "点击排行.xls";

            SafeC.DownStr(office.ExportExcel(GetDt(), "标题,点击数,评论数,录入者,录入时间"), DateTime.Now.ToString("yyyyMMdd") + "点击排行.xls", Encoding.Default);
        }
Пример #10
0
        private void AnalyCountMethod()
        {
            ZType        subjectZType  = SubjectExp.RetType;
            Type         mainType      = ZTypeUtil.GetTypeOrBuilder(subjectZType);               // subjectZType.SharpType;
            PropertyInfo countProperty = mainType.GetProperty(ZLangUtil.ZListCountPropertyName); //"Count");

            getCountMethod = countProperty.GetGetMethod();
        }
Пример #11
0
 public static MethodInfo GetCalcMethod(TokenKindSymbol opKind, ZType ltype, ZType rtype)
 {
     if (ltype is ZLType && rtype is ZLType)
     {
         return(GetCalcMethod(opKind, (ltype as ZLType).SharpType, (rtype as ZLType).SharpType));
     }
     return(null);
 }
Пример #12
0
        //ContextExp OutExpContext;

        public ExpLambdaBody(Exp exp, ZType fnRetType, List <SymbolBase> bodyVars, List <ExpVar> fieldExpVars, ContextExp outExpContext)
        {
            BodyExp      = exp;
            FnRetType    = fnRetType;
            BodyVars     = bodyVars;
            FieldExpVars = fieldExpVars;
            ExpContext   = outExpContext;
        }
Пример #13
0
 /// <summary>
 /// Date        Coder       Vers        Notes
 /// 2020-01-18  Clay        1.0         Initial
 ///
 ///
 /// This is the biggie constructor without the Serial Number.
 /// Why would I need to different constructors. The answer is
 /// to remember who gives out the serial numbers. The database. :)
 /// </summary>
 /// <param name="Lat"></param>
 /// <param name="Long"></param>
 /// <param name="Elevate"></param>
 /// <param name="Year"></param>
 /// <param name="Month"></param>
 /// <param name="Day"></param>
 /// <param name="ZType"></param>
 /// <param name="Name"></param>
 public Zombie(double Lat, double Long, double Elevate, int Year, int Month, int Day, ZType ZType, String Name)
 {
     ContactLocation = new GeoEngine_Workspace.Location(Lat, Long, Elevate);
     ContactLocation.SetDate(Year, Month, Day);
     ContactType        = ZType;
     ContactName        = Name;
     ZombieSerialNumber = 0;
 }
Пример #14
0
        private void AnalyCountMethod()
        {
            ZType        subjectZType  = SubjectExp.RetType;
            Type         mainType      = subjectZType.SharpType;
            PropertyInfo countProperty = mainType.GetProperty(CompileConstant.ZListCountPropertyName);//"Count");

            getCountMethod = countProperty.GetGetMethod();
        }
Пример #15
0
        public override Exp Analy( )
        {
            if (this.IsAnalyed)
            {
                return(this);
            }
            AnalyCorrect = true;
            if (LeftExp == null && RightExp != null)
            {
                ExpUnary unexp = new ExpUnary(this.ExpContext, OpToken, RightExp);
                var      exp   = unexp.Analy();
                return(exp);
            }
            else if (LeftExp == null && RightExp == null)
            {
                Errorf(this.OpToken.Position, "运算符'{0}'两边缺少表达式", OpToken.Text);
            }
            OpKind   = OpToken.Kind;
            LeftExp  = AnalySubExp(LeftExp);
            RightExp = AnalySubExp(RightExp);

            if (RightExp == null)
            {
                Errorf(OpToken.Position, "运算符'{0}'右边缺少运算元素", OpToken.Text);
            }
            else
            {
                this.AnalyCorrect = this.LeftExp.AnalyCorrect && RightExp.AnalyCorrect && this.AnalyCorrect;
                if (LeftExp.AnalyCorrect && RightExp.AnalyCorrect)
                {
                    ZType ltype = LeftExp.RetType;
                    ZType rtype = RightExp.RetType;
                    if (ZTypeUtil.IsVoid(ltype) || ZTypeUtil.IsVoid(rtype))
                    {
                        Errorf(OpToken.Position, "没有结果的表达式无法进行'{0}'运算", OpToken.ToCode());
                    }
                    else
                    {
                        OpMethod = ExpBinaryUtil.GetCalcMethod(OpKind, ltype, rtype);
                        if (OpMethod != null)
                        {
                            RetType = ZTypeManager.GetBySharpType(OpMethod.ReturnType) as ZType;
                        }
                        else
                        {
                            Errorf(OpToken.Position, "两种类型无法进行'{0}'运算", OpToken.ToCode());
                        }
                    }
                }
                else
                {
                    this.RetType = ZLangBasicTypes.ZOBJECT;
                }
            }
            //AnalyResultLocal();
            IsAnalyed = true;
            return(this);
        }
Пример #16
0
 private bool checkCanForeach(ZType ztype)
 {
     if (ztype is ZLType)
     {
         Type type = ((ZLType)ztype).SharpType;
         return(checkCanForeach(type));
     }
     return(false);
 }
Пример #17
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            ZType zType = await db.ZTypes.FindAsync(id);

            db.ZTypes.Remove(zType);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Пример #18
0
 public void AnalyType()
 {
     if (IsExists)
     {
         return;
     }
     PropertyZType = AnalyPropertyZType();
     ZPropertyCompiling.ZPropertyType = PropertyZType;//.SetMemberType(PropertyZType);
 }
Пример #19
0
        public SymbolArg(string name, ZType argType, int argIndex)
        {
            this.SymbolName = name;
            ArgZType        = argType;
            ArgIndex        = argIndex;
            SymbolZType     = ArgZType;

            CanRead  = true;
            CanWrite = true;
        }
Пример #20
0
 public ExpTypeTwo(ContextExp expContext, LexToken varToken1, LexToken varToken2, ZType varZtype1, ZType varZtype2, ZType varZtypeCreated)
     : base(expContext)
 {
     VarToken1       = varToken1;
     VarToken2       = varToken2;
     VarZtype1       = varZtype1;
     VarZtype2       = varZtype2;
     VarZtypeCreated = varZtypeCreated;
     this.RetType    = varZtypeCreated;
 }
Пример #21
0
        public async Task <IActionResult> Create([Bind("Id,Code,DescriptionRU,DescriptionKK,DescriptionEN,Color")] ZType zType)
        {
            if (ModelState.IsValid)
            {
                _context.Add(zType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(zType));
        }
Пример #22
0
 public bool AnalyNameType(NameTypeParser parser)
 {
     NameTypeParser.ParseResult result = parser.ParseVar(ArgToken);
     if (result != null)
     {
         ArgName  = result.VarName;
         ArgZType = result.ZType;
         return(true);
     }
     return(false);
 }
Пример #23
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,Code,Description,Color")] ZType zType)
        {
            if (ModelState.IsValid)
            {
                db.Entry(zType).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(zType));
        }
Пример #24
0
 private MethodInfo MakeCastMethod(ZType ztype)
 {
     if (ztype is ZLType)
     {
         return(caseMethod.MakeGenericMethod(new Type[] { ((ZLType)ztype).SharpType }));
     }
     else
     {
         return(caseMethod.MakeGenericMethod(new Type[] { ((ZCClassInfo)ztype).ClassBuilder }));
     }
 }
Пример #25
0
        public ZType Compile(ModuleBuilder moduleBuilder, string packageName)
        {
            AnalyName();
            EmitName(moduleBuilder, packageName);
            AnalyBody();
            EmitBody();
            var   EmitedType = Builder.CreateType();
            ZType ztype      = ZTypeManager.GetByMarkType(EmitedType) as ZType;

            return(ztype);
        }
Пример #26
0
        private ZType SearchZType(LexToken token)
        {
            string typeName = token.Text;
            var    ztypes   = this.ExpContext.FileContext.ImportUseContext.SearchImportType(typeName);
            ZType  ztype    = ztypes[0] as ZType;

            if (ztype == null)
            {
                Errorf(token.Position, "类型'{0}'不存在", token.Text);
            }
            return(ztype);
        }
Пример #27
0
        private void AnalyGeneric_1()
        {
            Token genericArgTypeToken = TypeTokens[0];
            ZType genericArgZType     = SearchZType(genericArgTypeToken);

            if (genericArgZType != null)
            {
                Type  newType  = mainZType.SharpType.MakeGenericType(genericArgZType.SharpType);
                ZType newZtype = ZTypeManager.RegNewGenericType(newType);
                RetType = newZtype;
            }
        }
Пример #28
0
 public static void EmitConv(ILGenerator il, ZType targetZType, ZType curZType)
 {
     if (targetZType is ZLType)
     {
         ZLType targetType = (ZLType)targetZType;
         if (curZType is ZLType)
         {
             ZLType curType = (ZLType)curZType;
             EmitConv(il, targetType.SharpType, curType.SharpType);
         }
     }
 }
Пример #29
0
        private ZType SearchZType(Token token)
        {
            string typeName = token.GetText();
            var    ztypes   = this.ExpContext.FileContext.SearchZDescType(typeName);
            ZType  ztype    = ztypes[0] as ZType;

            if (ztype == null)
            {
                ErrorE(token.Position, "类型'{0}'不存在", token.GetText());
            }
            return(ztype);
        }
Пример #30
0
 private bool CanUnary(ZType ztype)
 {
     if (ztype is ZLType)
     {
         Type stype = ((ZLType)ztype).SharpType;
         if (stype == typeof(int) || stype == typeof(float) || stype == typeof(double) || stype == typeof(decimal))
         {
             return(true);
         }
     }
     return(false);
 }