コード例 #1
0
        public ColorClickUserControl()
        {
            InitializeComponent();

            this.currentPass = new PassData(1.5f, 8, 10, 6,
                                            string.Empty, string.Empty);
        }
コード例 #2
0
    private static ExpressionData CompileExpression_SimpleBinary(
        ref PassData passData,
        ref FunctionData funcData,
        ESIR_SimpleBinaryExpression expr
        )
    {
        var lhsExpr = CompileExpression(ref passData, ref funcData, expr.ExprLeft);
        var rhsExpr = CompileExpression(ref passData, ref funcData, expr.ExprRight);

        StripFirstConst(ref lhsExpr);
        StripFirstConst(ref rhsExpr);

        return((lhsExpr.Type->TypeTag, rhsExpr.Type->TypeTag) switch {
            (ES_TypeTag.Bool, ES_TypeTag.Bool) => CompileExpression_BinaryBoolBool(ref passData, expr, ref lhsExpr, ref rhsExpr),

            (ES_TypeTag.Int, ES_TypeTag.Int) => CompileExpression_BinaryIntInt(ref passData, expr, ref lhsExpr, ref rhsExpr),

            (ES_TypeTag.Float, ES_TypeTag.Float) => CompileExpression_BinaryFloatFloat(ref passData, expr, ref lhsExpr, ref rhsExpr),
            (ES_TypeTag.Float, ES_TypeTag.Int) => CompileExpression_BinaryFloatInt(ref passData, expr, ref lhsExpr, ref rhsExpr),

            (ES_TypeTag.Reference, ES_TypeTag.Reference) => CompileExpression_BinaryRefRef(ref passData, expr, ref lhsExpr, ref rhsExpr),

            (ES_TypeTag.Array, ES_TypeTag.Array) => CompileExpression_BinaryArrayArray(ref passData, expr, ref lhsExpr, ref rhsExpr),

            _ => throw new CompilationException("Binary expression not supported."),
        });
コード例 #3
0
        private void btnInVe_Click(object sender, EventArgs e)
        {
            PassData pass = new PassData(frmVeXe.GetData);

            pass(this.txtBienSo, this.txtLoaiVe, this.txtGiaVe);
            frmVeXe.ShowDialog();
        }
コード例 #4
0
 private void UserControl_Loaded(object sender, RoutedEventArgs e)
 {
     this.currentPass    = DataMgr.Instance.FistPass;
     this.generatedCount = 0;
     this.passCount      = 0;
     this.StartPass();
 }
コード例 #5
0
        //recebe as informaçoes do usuario selecionado e passa todas as suas informçoes para o formulario de cadastro para atualizaçao ou deletar
        private void usersDataG_DoubleClick(object sender, EventArgs e)
        {
            if (usersDataG.CurrentRow.Index != -1)
            {
                var frm = new RegisterForm();
                frm.Location      = this.Location;
                frm.StartPosition = FormStartPosition.Manual;
                frm.FormClosing  += delegate { this.Search(); this.Show(); };
                PassData     del = new PassData(frm.PassedData);
                byte[]       img = (byte[])usersDataG.CurrentRow.Cells[13].Value;
                MemoryStream ms  = new MemoryStream(img);
                frm.pictureBox1.Image = Image.FromStream(ms);

                del(usersDataG.CurrentRow.Cells[1].Value.ToString(),
                    usersDataG.CurrentRow.Cells[2].Value.ToString(),
                    usersDataG.CurrentRow.Cells[3].Value.ToString(),
                    usersDataG.CurrentRow.Cells[4].Value.ToString(),
                    usersDataG.CurrentRow.Cells[5].Value.ToString(),
                    usersDataG.CurrentRow.Cells[6].Value.ToString(),
                    usersDataG.CurrentRow.Cells[7].Value.ToString(),
                    usersDataG.CurrentRow.Cells[8].Value.ToString(),
                    usersDataG.CurrentRow.Cells[9].Value.ToString(),
                    usersDataG.CurrentRow.Cells[10].Value.ToString(),
                    usersDataG.CurrentRow.Cells[11].Value.ToString(),
                    usersDataG.CurrentRow.Cells[12].Value.ToString(),
                    usersDataG.CurrentRow.Cells[14].Value.ToString(),
                    usersDataG.CurrentRow.Cells[15].Value.ToString(),
                    Convert.ToInt32(usersDataG.CurrentRow.Cells[0].Value)
                    );
                frm.Show();
                this.Hide();
            }
        }
コード例 #6
0
    private static void CompileStruct(ref PassData passData, ESIR_Struct structDef)
    {
        using var memberTypes = new StructPooledList <SyntaxNode> (CL_ClearMode.Auto);

        var mangledStructName = MangleTypeName(structDef.Type);

        // Create the struct's members.
        foreach (var member in structDef.Members.Elements)
        {
            switch (member.Kind)
            {
            case ESIR_NodeKind.Field when member is ESIR_Field fieldDef: {
                var roslynType   = GetRoslynType(fieldDef.Type.Pointer);
                var variableName = fieldDef.Name.GetPooledString(ES_Encodings.Identifier);

                var variablesList = SingletonSeparatedList(VariableDeclarator(Identifier(variableName)));
                memberTypes.Add(
                    FieldDeclaration(
                        VariableDeclaration(
                            roslynType
                            ).WithVariables(variablesList)
                        ).WithModifiers(TokenList(
                                            Token(SyntaxKind.PublicKeyword)
                                            )).WithAttributeLists(SingletonList(SingletonAttributeList(
                                                                                    Attribute_FieldOffset(fieldDef.Offset)
                                                                                    )))
                    );

                break;
            }

            case ESIR_NodeKind.StaticField:
                // Ignore.
                break;

            default:
                throw new NotImplementedException("Member type not implemented.");
            }
        }

        // Generate the struct declaration.
        passData.Types.Add(
            StructDeclaration(
                mangledStructName
                ).WithMembers(
                ListSpan(memberTypes.Span)
                ).WithModifiers(TokenList(
                                    Token(SyntaxKind.PublicKeyword),
                                    Token(SyntaxKind.UnsafeKeyword)
                                    )).WithAttributeLists(SingletonList(
                                                              SingletonAttributeList(
                                                                  Attribute_StructLayout(
                                                                      nameof(LayoutKind.Explicit),
                                                                      null,
                                                                      LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(structDef.Type->RuntimeSize))
                                                                      )
                                                                  )
                                                              ))
            );
    }
コード例 #7
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            pd = e.Parameter as PassData;
            this.DataContext = pd.Selected;
            this.InitializeComponent();
            search            = pd.tds;
            tasks.ItemsSource = pd.tds;
            taskpriority.Items.Clear();
            taskstatus.Items.Clear();
            taskrelated.Items.Clear();
            taskpriority.Items.Add("High");
            taskpriority.Items.Add("Medium");
            taskpriority.Items.Add("Low");
            taskstatus.Items.Add("Open");
            taskstatus.Items.Add("Close");
            taskrelated.Items.Add("Other");
            taskrelated.Items.Add("Login");
            taskrelated.Items.Add("sample");
            var temp = await LoadTeamMembers();

            MenuFlyoutItemSettings(temp);
            IntializeFrameData();
            secondstimer.Tick    += Secondstimer_Tick;
            secondstimer.Interval = new TimeSpan(0, 0, 1);
        }
コード例 #8
0
ファイル: DangNhap.cs プロジェクト: AnhKiet1911/WinForm
        /// <summary>
        /// Login
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string PassWordMD5 = txtMatKhau.Text;

            PassWordMD5 = md5(PassWordMD5);



            if (txtTaiKhoan.Text == "" && txtMatKhau.Text == "")
            {
                this.lblThongBao.Visible   = true;
                this.lblThongBao.Text      = "Chưa Nhập Tài Khoản Và Mật Khẩu";
                this.lblTBPass.Visible     = true;
                this.lblTBTaiKhoan.Visible = true;
            }
            else
            {
                if (this.txtTaiKhoan.Text != "" && this.txtMatKhau.Text == "")
                {
                    this.lblThongBao.Visible   = true;
                    this.lblThongBao.Text      = "Chưa Nhập Mật Khẩu";
                    this.lblTBPass.Visible     = true;
                    this.lblTBTaiKhoan.Visible = false;
                }

                else if (this.txtTaiKhoan.Text != "" && this.txtMatKhau.Text != "")
                {
                    Class.XuLyThuVien KiemTra = new Class.XuLyThuVien();

                    if (KiemTra.DangNhap(txtTaiKhoan.Text, PassWordMD5) == 1)
                    {
                        this.lblTBPass.Visible     = false;
                        this.lblTBTaiKhoan.Visible = false;
                        Main     FrmMain = new Main();
                        PassData Share   = new PassData(FrmMain.GetData_Form1);
                        Share(this.txtTaiKhoan);
                        this.Hide();
                        FrmMain.ShowDialog();
                        this.lblThongBao.Visible = false;
                        this.Show();
                    }
                    else
                    {
                        this.lblThongBao.Visible   = true;
                        this.lblThongBao.Text      = "Sai Tài Khoản Hoặc Mật Khẩu";
                        this.lblTBPass.Visible     = false;
                        this.lblTBTaiKhoan.Visible = false;
                    }
                }

                else
                {
                    this.lblThongBao.Visible   = true;
                    this.lblThongBao.Text      = "Chưa Nhập Tài Khoản";
                    this.lblTBPass.Visible     = false;
                    this.lblTBTaiKhoan.Visible = true;
                }
            }
        }
コード例 #9
0
 public TaskList()
 {
     this.InitializeComponent();
     data = new PassData();
     select.Items.Add("All");
     select.Items.Add("Assigned by me");
     select.Items.Add("Assigned to");
 }
コード例 #10
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            pd = e.Parameter as PassData;
            string pic = "Assets/" + pd.emp.id + ".jpg";

            dp.ProfilePicture = new BitmapImage(new Uri(this.BaseUri, pic));
            Empname.Text      = pd.emp.name;
            myframe.Navigate(typeof(TaskList), pd);
        }
コード例 #11
0
        private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            //enable progress bar
            lblStatus.InvokeEx(x => x.Visible   = true);
            progressBar.InvokeEx(x => x.Visible = true);

            PassData passData = (PassData)e.Argument;

            ImportExcel(passData.savedPath);
        }
コード例 #12
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            pd   = e.Parameter as PassData;
            temp = await LoadTeamMembers();

            MenuFlyoutItemSettings(temp);
            tds = await Task.Run(() => tdl.Get("All", pd.emp));

            LoadSpecificTask();
        }
コード例 #13
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     pd = e.Parameter as PassData;
     if (!(pd.emp.designation == "manager"))
     {
         add_team.Visibility = Visibility.Collapsed;
         add1.Visibility     = Visibility.Collapsed;
     }
     LoadTeams();
     LoadMembersItems();
 }
コード例 #14
0
    private static ExpressionData CompileExpression(
        ref PassData passData,
        ref FunctionData funcData,
        ESIR_Expression expr
        )
    {
        if (expr is ESIR_SimpleBinaryExpression simpleBinaryExpr)
        {
            return(CompileExpression_SimpleBinary(ref passData, ref funcData, simpleBinaryExpr));
        }
        else if (expr is ESIR_UnaryExpression unaryExpr)
        {
            return(CompileExpression_Unary(ref passData, ref funcData, unaryExpr));
        }

        switch (expr.Kind)
        {
        case ESIR_NodeKind.ErrorExpression:
            throw new CompilationException(ES_BackendErrors.FrontendError);

        case ESIR_NodeKind.AssignExpression when expr is ESIR_AssignExpression assignExpr: {
            var assigneeExpr = CompileExpression(ref passData, ref funcData, assignExpr.Assignee);
            var valueExpr    = CompileExpression(ref passData, ref funcData, assignExpr.Value);

            Debug.Assert(assigneeExpr.Type == valueExpr.Type);

            var value = AssignmentExpression(
                SyntaxKind.SimpleAssignmentExpression,
                assigneeExpr.Value !,
                valueExpr.Value !
                );

            return(new ExpressionData {
                    Type = assigneeExpr.Type, Value = value,
                });
        }

            #region Literals

        case ESIR_NodeKind.LiteralTrue:
        case ESIR_NodeKind.LiteralFalse:
            return(new ExpressionData {
                Type = passData.Env.TypeBool, Value = BoolLiteral(expr.Kind == ESIR_NodeKind.LiteralTrue),
            });

        case ESIR_NodeKind.LiteralInt when expr is ESIR_LiteralExpression litIntExpr: {
            bool             unsigned;
            ExpressionSyntax value;

            if (litIntExpr.Value !.TryGetInt(out var longVal))
            {
                value    = NumericLiteral(longVal);
                unsigned = false;
            }
コード例 #15
0
 void Awake()
 {
     if (passData == null)
     {
         DontDestroyOnLoad(transform.gameObject);
         passData = this;
     }
     else if (passData != this)
     {
         Destroy(gameObject);
     }
 }
コード例 #16
0
    // Use this for initialization

    void Start()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(instance.gameObject);
        }
        instance = this;
        GameObject.DontDestroyOnLoad(gameObject);
    }
コード例 #17
0
        static void Main(string[] args)
        {
            PassData orgdata   = new PassData();
            IDATA    injection = orgdata.Addidata();


            DataInjection Injection = new DataInjection();

            Injection.addData(injection);


            Console.Read();
        }
コード例 #18
0
 private void MessageWindowCallback(bool ok)
 {
     if (ok)
     {
         this.currentPass    = DataMgr.Instance.NextPass;
         this.generatedCount = 0;
         this.passCount      = 0;
         this.StartPass();
     }
     else
     {
         this.generatedCount = 0;
         this.passCount      = 0;
         this.StartPass();
     }
 }
コード例 #19
0
ファイル: Function.cs プロジェクト: Doom2fan/EchelonScript
    private static void FinishExpression(ref PassData passData, ref ExpressionData exprData)
    {
        var irWriter = passData.IRWriter;

        using var exprList = exprData.Expressions;

        foreach (var expr in exprList.Expressions)
        {
            irWriter.AddStatement(ExpressionStatement(expr));
        }
        irWriter.AddStatement(ExpressionStatement(exprData.Value));

        exprList.ReturnRegisters(irWriter);
        irWriter.ReturnRegister(exprData.ValueRegister);

        exprData.Expressions = new ExpressionList(null, null);
    }
コード例 #20
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            pd   = e.Parameter as PassData;
            emp1 = await edl.LoadEmployees();

            foreach (var item in emp1)
            {
                Employee ed = new Employee();
                ed.id = item.id; ed.name = item.name; ed.designation = item.designation; ed.role = item.role; ed.username = item.username;
                string pic = "Assets/" + ed.id + ".jpg";
                ed.Img = new BitmapImage(new Uri(this.BaseUri, pic));
                emp2.Add(ed);
            }
            if (!(pd.emp.designation == "manager"))
            {
                Addmember.Visibility = Visibility.Collapsed;
            }
        }
コード例 #21
0
    private static StatementData CheckStatement_Block(
        ref PassData passData, TypeData retType,
        ES_AstBlockStatement blockStmt
        )
    {
        var symbols  = passData.Symbols;
        var irWriter = passData.IRWriter;

        symbols.Push();
        irWriter.PushScope();

        var alwaysReturns       = false;
        var reportedUnreachable = false;

        var subStmt = blockStmt.Statement;

        while (subStmt is not null)
        {
            Debug.Assert(subStmt is not null);

            if (alwaysReturns && !reportedUnreachable)
            {
                passData.WarnList.Add(new (
                                          passData.Source, subStmt.NodeBounds, ES_FrontendWarnings.UnreachableCode
                                          ));

                reportedUnreachable = true;
            }

            var subStmtData = CheckStatement(ref passData, retType, subStmt);

            alwaysReturns |= subStmtData.AlwaysReturns;

            subStmt = subStmt.Endpoint;
        }

        using var blockStmts = irWriter.PopScope();
        irWriter.AddStatements(blockStmts.Span);

        symbols.Pop();
        return(new StatementData {
            AlwaysReturns = alwaysReturns
        });
    }
コード例 #22
0
    private static ExpressionData CompileExpression_Unary(
        ref PassData passData,
        ref FunctionData funcData,
        ESIR_UnaryExpression expr
        )
    {
        var innerExpr = CompileExpression(ref passData, ref funcData, expr.ExprInner);

        StripFirstConst(ref innerExpr);

        return(innerExpr.Type->TypeTag switch {
            ES_TypeTag.Bool => CompileExpression_UnaryBool(ref passData, expr, ref innerExpr),
            ES_TypeTag.Int => CompileExpression_UnaryInt(ref passData, expr, ref innerExpr),
            ES_TypeTag.Float => CompileExpression_UnaryFloat(ref passData, expr, ref innerExpr),

            ES_TypeTag.Reference => CompileExpression_UnaryRef(ref passData, expr, ref innerExpr),

            _ => throw new CompilationException("Binary expression not supported."),
        });
コード例 #23
0
        private void SendData()
        {
            PassData pass = new PassData(active.ApplyData);

            for (int i = 0; i < allNameBoxes.Count; i++)
            {
                KeyValuePair <string, int> data = new KeyValuePair <string, int>(allNameBoxes[i].Text, (int)allValueBoxes[i].Value);
                allData.Add(data);
            }

            if (cache.All(allData.Contains) && cache.Count == allData.Count)
            {
                return;
            }

            active.SaveCache(allData);

            pass(allData);
        }
コード例 #24
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     data  = e.Parameter as PassData;
     emp   = data.emp;
     click = data.click1;
     tds   = data.tds;
     tprior.Items.Clear();
     tstatus.Items.Clear();
     trelate.Items.Clear();
     tprior.Items.Add("None");
     tprior.Items.Add("Low");
     tprior.Items.Add("Medium");
     tprior.Items.Add("High");
     trelate.Items.Add("sample");
     trelate.Items.Add("Login");
     trelate.Items.Add("Other");
     tstatus.Items.Add("Open");
     tstatus.Items.Add("Close");
     initiaze();
 }
コード例 #25
0
    private static ExpressionData CompileExpression_MemberAccess(
        ref PassData passData,
        ref FunctionData funcData,
        ESIR_MemberAccessExpression expr
        )
    {
        var parentExpr = CompileExpression(ref passData, ref funcData, expr.ExprParent);

        StripFirstConst(ref parentExpr);

        Debug.Assert(parentExpr.Type is not null);

        return(parentExpr.Type->TypeTag switch {
            ES_TypeTag.UNKNOWN => throw new CompilationException(ES_BackendErrors.FrontendError),

            ES_TypeTag.Struct => CompileExpression_MemberAccess_Struct(ref passData, ref funcData, expr, parentExpr),
            ES_TypeTag.Array => CompileExpression_MemberAccess_Array(ref passData, ref funcData, expr, parentExpr),
            ES_TypeTag.Reference => throw new CompilationException("Reference types must be dereferenced manually before access."),

            _ => throw new NotImplementedException("Type not implemented."),
        });
コード例 #26
0
        public override void PrepareVisibleObjects(ICamera camera, PassData batchHelper)
        {
            batchHelper.visibleObjects.FastClear();

            Frustum frus = camera.Frustum;

            Vector3 camPos = camera.Position;
            // do a BFS pass here

            queue.Enqueue(octRootNode);

            while (queue.Count > 0)
            {
                OctreeSceneNode node = queue.Dequeue();

                Vector3 dir;
                Vector3 center2;
                
                if (frus.IntersectsSphere(ref node.BoundingSphere.Center, node.BoundingSphere.Radius))
                {
                    for (int i = 0; i < 2; i++)
                        for (int j = 0; j < 2; j++)
                            for (int k = 0; k < 2; k++)
                            {
                                if (node[i, j, k] != null)
                                {
                                    queue.Enqueue(node[i, j, k]);
                                }
                            }
                    FastList<SceneObject> objs = node.AttchedObjects;
                    for (int i = 0; i < objs.Count; i++)
                    {
                        SceneObject obj = objs.Elements[i];
                        dir = obj.BoundingSphere.Center;
                        dir.Normalize();

                        Vector3.Multiply(ref dir, obj.BoundingSphere.Radius, out dir);
                        Vector3.Subtract(ref obj.BoundingSphere.Center, ref dir, out center2);

                        Vector3.Subtract(ref center2, ref camPos, out dir);

                        if (Vector3.Dot(ref dir, ref center2) <= 0)
                        {
                            int level = GetLevel(ref obj.BoundingSphere, ref camPos);

                            if (obj.HasSubObjects)
                            {
                                obj.PrepareVisibleObjects(camera, level);
                            }
                            AddVisibleObject(obj, level, batchHelper);
                        }
                    }
                }

            }

            for (int i = 0; i < farObjects.Count; i++)
            {
                int level = GetLevel(ref farObjects[i].BoundingSphere, ref camPos);

                AddVisibleObject(farObjects[i], level, batchHelper);
            }
        }
コード例 #27
0
 // Start is called before the first frame update
 void Awake()
 {
     currentLevel = levels[levelID];
     Instance     = this;
     DontDestroyOnLoad(gameObject);
 }
コード例 #28
0
        public override void PrepareVisibleObjects(ICamera camera, PassData batchHelper)
        {
            batchHelper.visibleObjects.FastClear();

            Frustum frus = camera.Frustum;

            Vector3 camPos = camera.Position;

            // do a BFS pass here

            queue.Enqueue(octRootNode);

            while (queue.Count > 0)
            {
                OctreeSceneNode node = queue.Dequeue();

                Vector3 dir;
                Vector3 center2;

                if (frus.IntersectsSphere(ref node.BoundingSphere.Center, node.BoundingSphere.Radius))
                {
                    for (int i = 0; i < 2; i++)
                    {
                        for (int j = 0; j < 2; j++)
                        {
                            for (int k = 0; k < 2; k++)
                            {
                                if (node[i, j, k] != null)
                                {
                                    queue.Enqueue(node[i, j, k]);
                                }
                            }
                        }
                    }
                    FastList <SceneObject> objs = node.AttchedObjects;
                    for (int i = 0; i < objs.Count; i++)
                    {
                        SceneObject obj = objs.Elements[i];
                        dir = obj.BoundingSphere.Center;
                        dir.Normalize();

                        Vector3.Multiply(ref dir, obj.BoundingSphere.Radius, out dir);
                        Vector3.Subtract(ref obj.BoundingSphere.Center, ref dir, out center2);

                        Vector3.Subtract(ref center2, ref camPos, out dir);

                        if (Vector3.Dot(ref dir, ref center2) <= 0)
                        {
                            int level = GetLevel(ref obj.BoundingSphere, ref camPos);

                            if (obj.HasSubObjects)
                            {
                                obj.PrepareVisibleObjects(camera, level);
                            }
                            AddVisibleObject(obj, level, batchHelper);
                        }
                    }
                }
            }

            for (int i = 0; i < farObjects.Count; i++)
            {
                int level = GetLevel(ref farObjects[i].BoundingSphere, ref camPos);

                AddVisibleObject(farObjects[i], level, batchHelper);
            }
        }
コード例 #29
0
    private static ES_IntTypeData *DetermineIntLiteralType(
        ref PassData passData,
        ES_AstIntegerLiteralExpression intLitExpr, ES_TypeInfo *expectedType, bool negated
        )
    {
        ES_IntTypeData *expectedIntType = null;

        bool?unsigned   = null;
        var  isSigned   = intLitExpr.Signed;
        var  chosenSize = intLitExpr.Size;

        if (expectedType != null && expectedType->TypeTag == ES_TypeTag.Int)
        {
            expectedIntType = (ES_IntTypeData *)expectedType;

            if (isSigned == null)
            {
                isSigned = !expectedIntType->Unsigned;
            }
        }

        ES_IntSize size;
        ES_IntSize minSize;

        var tooBig = false;

        var value = intLitExpr.Value;

        if (isSigned == false || intLitExpr.HexBin)
        {
            if (value <= byte.MaxValue)
            {
                minSize = ES_IntSize.Int8;
            }
            else if (value <= ushort.MaxValue)
            {
                minSize = ES_IntSize.Int16;
            }
            else if (value <= uint.MaxValue)
            {
                minSize = ES_IntSize.Int32;
            }
            else
            {
                minSize = ES_IntSize.Int64;
            }
        }
        else if (!negated)
        {
            if (value <= (ulong)sbyte.MaxValue)
            {
                minSize = ES_IntSize.Int8;
            }
            else if (value <= (ulong)short.MaxValue)
            {
                minSize = ES_IntSize.Int16;
            }
            else if (value <= int.MaxValue)
            {
                minSize = ES_IntSize.Int32;
            }
            else if (value <= long.MaxValue)
            {
                minSize = ES_IntSize.Int64;
            }
            else
            {
                minSize  = ES_IntSize.Int64;
                unsigned = true;

                if (isSigned == true)
                {
                    tooBig = true;
                }
            }
        }
        else
        {
            unsigned = false;

            if (value <= ((ulong)sbyte.MaxValue) + 1)
            {
                minSize = ES_IntSize.Int8;
            }
            else if (value <= ((ulong)short.MaxValue) + 1)
            {
                minSize = ES_IntSize.Int16;
            }
            else if (value <= ((ulong)int.MaxValue) + 1)
            {
                minSize = ES_IntSize.Int32;
            }
            else if (value <= ((ulong)long.MaxValue) + 1)
            {
                minSize = ES_IntSize.Int64;
            }
            else
            {
                minSize  = ES_IntSize.Int64;
                unsigned = true;

                if (isSigned == true)
                {
                    tooBig = true;
                }
            }
        }

        tooBig |= (
            (chosenSize is not null && chosenSize.Value < minSize) ||
            (unsigned == true && isSigned == true)
            );

        if (tooBig)
        {
            var errSize = minSize;
            if (chosenSize is not null)
            {
                errSize = chosenSize.Value;
            }
            passData.ErrorList.Add(ES_FrontendErrors.GenIntLitTooBig(isSigned !.Value, errSize, intLitExpr.Token));

            if (unsigned is null && isSigned == false)
            {
                unsigned = true;
            }
        }
        else
        {
            if (chosenSize is not null)
            {
                minSize = chosenSize.Value;
            }

            if (unsigned is null && isSigned is not null)
            {
                unsigned = !isSigned.Value;
            }
        }

        size = minSize;
        if (expectedIntType is not null)
        {
            var isCompat = false;

            var expectsUnsign = expectedIntType->Unsigned;
            var expectedSize  = expectedIntType->IntSize;

            if (intLitExpr.HexBin && (isSigned is null || isSigned == !expectsUnsign) && minSize <= expectedSize)
            {
                isCompat = true;
            }
            else if (unsigned == expectsUnsign && minSize <= expectedSize)
            {
                isCompat = true;
            }

            if (isCompat)
            {
                size     = expectedSize;
                unsigned = expectsUnsign;
            }
        }
コード例 #30
0
        /// <summary>
        /// Login
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                SqlConnection Con = KetNoiCSDL.KetNoiSQL();

                Con.Open();

                string PassWordMD5 = txtMatKhau.Text;
                PassWordMD5 = md5(PassWordMD5);


                string     SelectDangNhap = string.Format("exec DangNhap @UseName, @MatKhau"); //Gọi Proc
                SqlCommand Com            = new SqlCommand(SelectDangNhap, Con);
                Com.Parameters.Add(new SqlParameter("@UseName", txtTaiKhoan.Text));
                Com.Parameters.Add(new SqlParameter("@MatKhau", PassWordMD5));
                int check = Convert.ToInt32(Com.ExecuteScalar());

                Con.Close();


                if (txtTaiKhoan.Text == "" && txtMatKhau.Text == "")
                {
                    this.lblThongBao.Visible   = true;
                    this.lblThongBao.Text      = "Chưa Nhập Tài Khoản Và Mật Khẩu";
                    this.lblTBPass.Visible     = true;
                    this.lblTBTaiKhoan.Visible = true;
                }
                else
                {
                    if (this.txtTaiKhoan.Text != "" && this.txtMatKhau.Text == "")
                    {
                        this.lblThongBao.Visible   = true;
                        this.lblThongBao.Text      = "Chưa Nhập Mật Khẩu";
                        this.lblTBPass.Visible     = true;
                        this.lblTBTaiKhoan.Visible = false;
                    }

                    else if (this.txtTaiKhoan.Text != "" && this.txtMatKhau.Text != "")
                    {
                        if (check == 1)
                        {
                            this.lblTBPass.Visible     = false;
                            this.lblTBTaiKhoan.Visible = false;
                            Main     FrmMain = new Main();
                            PassData Share   = new PassData(FrmMain.GetData_Form1);
                            Share(this.txtTaiKhoan);
                            this.Hide();
                            FrmMain.ShowDialog();
                            this.lblThongBao.Visible = false;
                            this.Show();
                        }
                        else
                        {
                            this.lblThongBao.Visible   = true;
                            this.lblThongBao.Text      = "Sai Tài Khoản Hoặc Mật Khẩu";
                            this.lblTBPass.Visible     = false;
                            this.lblTBTaiKhoan.Visible = false;
                        }
                    }

                    else
                    {
                        this.lblThongBao.Visible   = true;
                        this.lblThongBao.Text      = "Chưa Nhập Tài Khoản";
                        this.lblTBPass.Visible     = false;
                        this.lblTBTaiKhoan.Visible = true;
                    }
                }
            }
            catch (Exception EX)
            {
                MetroFramework.MetroMessageBox.Show(this, EX.Message);
            }
        }
コード例 #31
0
    private static ExpressionData CompileExpression_Cast(
        ref PassData passData,
        ref FunctionData funcData,
        ESIR_CastExpression expr
        )
    {
        var origExpr = CompileExpression(ref passData, ref funcData, expr.Expression);
        var destType = StripFirstConst(expr.DestType.Pointer);

        StripFirstConst(ref origExpr);

        var origVal = origExpr.Value !;

        Debug.Assert(origVal is not null);

        ES_TypeInfo *    retType;
        ExpressionSyntax retValue;

        if (IsTypeEquivalent(origExpr.Type, destType))
        {
            retType = destType;

            var origTypeRoslyn = GetRoslynType(origExpr.Type);
            var destTypeRoslyn = GetRoslynType(destType);
            if (!origTypeRoslyn.IsEquivalentTo(destTypeRoslyn))
            {
                retValue = CastExpression(destTypeRoslyn, origVal);
            }
            else
            {
                retValue = origVal;
            }
        }
        else
        {
            switch (origExpr.Type->TypeTag)
            {
            case ES_TypeTag.Int: {
                var intSrc = (ES_IntTypeData *)origExpr.Type;

                if (destType->TypeTag == ES_TypeTag.Int)
                {
                    var intDest = (ES_IntTypeData *)destType;

                    if (intDest->IntSize == intSrc->IntSize && intDest->Unsigned == intSrc->Unsigned)
                    {
                        origExpr.Writable = false;
                        return(origExpr);
                    }

                    var roslynDestType = GetIntType(intDest->IntSize, intDest->Unsigned);
                    retValue = CastExpression(roslynDestType, origVal);
                }
                else if (destType->TypeTag == ES_TypeTag.Float)
                {
                    var floatDest = (ES_FloatTypeData *)destType;

                    var roslynDestType = GetFloatType(floatDest->FloatSize);
                    retValue = CastExpression(roslynDestType, origVal);
                }
                else
                {
                    throw new CompilationException(ES_BackendErrors.FrontendError);
                }

                retType = destType;

                break;
            }

            case ES_TypeTag.Float: {
                var floatSrc = (ES_FloatTypeData *)origExpr.Type;

                if (destType->TypeTag == ES_TypeTag.Float)
                {
                    var floatDest = (ES_FloatTypeData *)destType;

                    if (floatSrc->FloatSize == floatDest->FloatSize)
                    {
                        origExpr.Writable = false;
                        return(origExpr);
                    }

                    var roslynDestType = GetFloatType(floatDest->FloatSize);
                    retValue = CastExpression(roslynDestType, origVal);
                }
                else if (destType->TypeTag == ES_TypeTag.Int)
                {
                    var intDest = (ES_IntTypeData *)destType;

                    var roslynDestType = GetIntType(intDest->IntSize, intDest->Unsigned);
                    retValue = CastExpression(roslynDestType, origVal);
                }
                else
                {
                    throw new CompilationException(ES_BackendErrors.FrontendError);
                }

                retType = destType;

                break;
            }

            default:
                throw new NotImplementedException("Cast not implemented.");
            }
        }

        return(new ExpressionData {
            Type = retType, Value = retValue,
        });
    }
コード例 #32
0
ファイル: Form1.cs プロジェクト: thuyenvinh/qlvx
 private void btnInVe_Click(object sender, EventArgs e)
 {
     PassData pass = new PassData(frmVeXe.GetData);
     pass(this.txtBienSo, this.txtLoaiVe, this.txtGiaVe);
     frmVeXe.ShowDialog();
 }
コード例 #33
0
ファイル: Pass.cs プロジェクト: ssjjsj/softRender
 public Pass(PassData data)
 {
     this.data = data;
 }