private LabelInfo EnsureLabel(LabelTarget node) { LabelInfo result; if (!_labelInfo.TryGetValue(node, out result)) { _labelInfo.Add(node, result = new LabelInfo(_ilg, node, false)); } return result; }
internal void AddLabelInfo(LabelTarget target, LabelInfo info) { if (this.Labels == null) { this.Labels = new HybridReferenceDictionary<LabelTarget, LabelInfo>(); } this.Labels[target] = info; }
internal bool TryGetLabelInfo(LabelTarget target, out LabelInfo info) { if (this.Labels == null) { info = null; return false; } return this.Labels.TryGetValue(target, out info); }
private Completion CreateLabelCompletion(LabelInfo label) { string displayText = "$" + label.Name; string insertionText = "$" + label.Name; string description = label.Description; string iconAutomationText = string.Empty; ImageSource iconSource = Provider.GlyphService.GetGlyph(label.Glyph, StandardGlyphItem.GlyphItemPublic); return(new Completion(displayText, insertionText, description, iconSource, iconAutomationText)); }
/// <summary> /// Mark current IL position with a label /// </summary> internal void MarkLabel(object label) { EndBlock(); BasicBlock block = this.GetCurrentBlock(); //1.7.5 Backward branch constraints //It shall be possible, with a single forward-pass through the CIL instruction stream for any method, to infer the //exact state of the evaluation stack at every instruction (where by "state" we mean the number and type of each //item on the evaluation stack). // //In particular, if that single-pass analysis arrives at an instruction, call it location X, that immediately follows an //unconditional branch, and where X is not the target of an earlier branch instruction, then the state of the //evaluation stack at X, clearly, cannot be derived from existing information. In this case, the CLI demands that //the evaluation stack at X be empty. if (_labelInfos.TryGetValue(label, out LabelInfo labelInfo)) { Debug.Assert(labelInfo.bb == null, "duplicate use of a label"); int labelStack = labelInfo.stack; int curStack = _emitState.CurStack; // we have already seen a branch to this label so we know its stack. // Now we will require that fall-through must agree with that stack value. // For the purpose of this assert we assume that all codepaths are reachable. // This is a minor additional burden for languages to makes sure that stack is balanced // even at labels that follow unconditional branches. // What we get is an invariant that satisfies 1.7.5 in reachable code // even though we do not know yet what is reachable. Debug.Assert(curStack == labelStack, "forward branches and fall-through must agree on stack depth"); _labelInfos[label] = labelInfo.WithNewTarget(block); } else { // this is a label for which we have not seen a branch yet. // it could mean two things - // 1) it is a label of a backward branch or // 2) it is a label for an unreachable forward branch and codegen did not bother to emit the branch. // // We cannot know here which case we have, so we cannot verify or force stack to be 0 on a backward branch. // We will just assume that languages do not do backward branches on nonempty stack // and let PEVerify catch that. // // With the above "assumption" current stack state is correct by definition // so label will assume current value and all other branches to this label // will have to agree on that for consistency. int curStack = _emitState.CurStack; _labelInfos[label] = new LabelInfo(block, curStack, false); } _instructionCountAtLastLabel = _emitState.InstructionsEmitted; }
public NftrLabel(LabelInfo info) : base(info) { font = new NftrFont(info.Fontpath.FixPath()); extraGap = 2; // Constant present (at least in Ninokuni game). extraGap += 3; // Furigana font box height (Hard coded for Spanish trans). alignment = info.Alignment; Text = info.DefaultText; Text = Text.Replace("{!SP}", " "); }
public ActionResult Label(long id = 0L) { LabelInfo label = this._iMemberLabelService.GetLabel(id) ?? new LabelInfo(); LabelModel labelModel = new LabelModel() { Id = label.Id, LabelName = label.LabelName }; return(base.View(labelModel)); }
private LabelInfo DefineLabel(LabelTarget node) { if (node == null) { return(new LabelInfo(_ilg, null, false)); } LabelInfo result = EnsureLabel(node); result.Define(_labelBlock); return(result); }
private bool ForwardLabelsNoLeaving() { bool madeChanges = false; SmallDictionary <object, LabelInfo> .KeyCollection labels = _labelInfos.Keys; bool done; do { done = true; foreach (object label in labels) { LabelInfo labelInfo = _labelInfos[label]; BasicBlock targetBlock = labelInfo.bb; Debug.Assert(!IsSpecialEndHandlerBlock(targetBlock)); if (targetBlock.HasNoRegularInstructions) { BasicBlock targetsTarget = null; switch (targetBlock.BranchCode) { case ILOpCode.Br: targetsTarget = targetBlock.BranchBlock; break; case ILOpCode.Nop: targetsTarget = targetBlock.NextBlock; break; } if ((targetsTarget != null) && (targetsTarget != targetBlock)) { ExceptionHandlerScope currentHandler = targetBlock.EnclosingHandler; ExceptionHandlerScope newHandler = targetsTarget.EnclosingHandler; // forward the label if can be done without leaving current handler if (currentHandler == newHandler) { _labelInfos[label] = labelInfo.WithNewTarget(targetsTarget); madeChanges = true; // since we modified at least one label we want to try again. done = false; } } } } } while (!done); return(madeChanges); }
public void LabelInfoConstructorTest() { bool UseZoomLevel = false; // TODO: Initialize to an appropriate value double xMin = 0F; // TODO: Initialize to an appropriate value double yMin = 0F; // TODO: Initialize to an appropriate value double xMax = 0F; // TODO: Initialize to an appropriate value double yMax = 0F; // TODO: Initialize to an appropriate value LabelInfo target = new LabelInfo(UseZoomLevel, xMin, yMin, xMax, yMax); Assert.Inconclusive("TODO: Implement code to verify target"); }
internal void AddLabelInfo(LabelTarget target, LabelInfo info) { Debug.Assert(CanJumpInto); if (Labels == null) { Labels = new Dictionary <LabelTarget, LabelInfo>(); } Labels.Add(target, info); }
internal void StartPrintTT(LabelInfo labelInfo) { try { _web.SetLoading(false); this._web.LoadPageHtml("MUBAndTTLabel.html"); //this._web.RunScript("$('.status-text').css('color','#000').text('Please wait');"); //System.Threading.Thread.Sleep(1000); PrinterMonitor printerMonitor = PrinterMonitor.Instance; printerMonitor.OnPrintTTLabelSucceeded += OnPrintTTLabelsSucceeded; printerMonitor.OnMonitorException += OnPrintMUBAndTTLabelsException; BarcodePrinterUtil barcodeScannerUtils = BarcodePrinterUtil.Instance; Session session = Session.Instance; if (session.IsAuthenticated) { #region Print TTLabel // Check status of Barcode printer string ttLabelPrinterName = ConfigurationManager.AppSettings["TTLabelPrinterName"]; var ttLabelPrinterStatus = barcodeScannerUtils.GetDeviceStatus(ttLabelPrinterName); if (ttLabelPrinterStatus.Contains(EnumDeviceStatus.Connected)) { printerMonitor.PrintTTLabel(labelInfo); } else { // Printer disconnect, get list status of the causes disconnected string causeOfPrintFailure = ""; foreach (var item in ttLabelPrinterStatus) { causeOfPrintFailure = causeOfPrintFailure + CommonUtil.GetDeviceStatusText(item) + "; "; } RaisePrintTTLabelsFailedEvent(new PrintMUBAndTTLabelsEventArgs("TTLabel Printer have problem: " + causeOfPrintFailure)); return; } #endregion } } catch (Exception ex) { RaisePrintMUBAndTTLabelsExceptionEvent(new ExceptionArgs(new FailedInfo() { ErrorCode = (int)EnumErrorCodes.UnknownError, ErrorMessage = new ErrorInfo().GetErrorMessage(EnumErrorCodes.UnknownError) })); } }
public void DrawData(LabelInfo lx, LabelInfo ly, float x, float y, Point p) { float fx = lx.CalculateFactor(x); float fy = ly.CalculateFactor(y); int _x = (int)Math.Round(per_width * (1 - box_horizontal_factor * 2) * fx); int _y = (int)Math.Round(per_height * (1 - box_vertical_facotr * 2) * fy); SolidBrush sb = new SolidBrush(Color.FromArgb(alpha, data_brush)); g.FillEllipse(sb, p.X + _x, p.Y - _y, data_size, data_size); }
private LabelInfo InternalPushLabel(LabelStatement label, TargetType breakTarget) { var info = new LabelInfo() { Label = label, BreakTarget = breakTarget, ProtectedRegion = CurrProtectedRegion }; _labels.Add(info); return(info); }
/// <summary> /// 获取模板内的标签列表 /// </summary> /// <param name="templet">模板</param> /// <returns>已替换标签的模板</returns> private string ReplaceLable(string templet) { string Content = ""; int t1 = 0; int t2 = 0; List <string> lablist = new List <string>(); string tp = ""; tp = templet; while (t2 < tp.Length) { t1 = tp.IndexOf("{%"); if (t1 > -1) { tp = tp.Substring(t1, tp.Length - t1); t2 = tp.IndexOf("%}") + 2; if (t2 > 2) { lablist.Add(tp.Substring(0, t2)); tp = tp.Substring(t2, tp.Length - t2); } } else { t2 = tp.Length; } } ILabel ldal = new AccessDal.CodeMaker.Label(); IList <LabelInfo> lblist = new List <LabelInfo>(); //获取标签 foreach (string title in lablist) { LabelInfo info = ldal.LabelGetInfo(title); if (info != null) { if (info.Title != "") { lblist.Add(info); } } } Content = templet; foreach (LabelInfo info in lblist) { //替换标签 Content = Content.Replace(info.Title, info.Content); } return(Content); }
public void SetLabelData(List <List <float> > d, List <string> name) { label_data = d; for (int i = 0; i < name.Count; i++) { LabelInfo lf = new LabelInfo(); lf.Set(name[i], label_data[i]); label_info.Add(lf); } Console.WriteLine(""); }
public void PrintTTLabel(LabelInfo labelInfo) { // validation if (string.IsNullOrEmpty(labelInfo.Name)) { // username is null RaiseMonitorExceptionEvent(new ExceptionArgs(new FailedInfo() { ErrorCode = (int)EnumErrorCodes.UserNameNull, ErrorMessage = new ErrorInfo().GetErrorMessage(EnumErrorCodes.UserNameNull) })); return; } else if (string.IsNullOrEmpty(labelInfo.NRIC)) { // NRIC is null RaiseMonitorExceptionEvent(new ExceptionArgs(new FailedInfo() { ErrorCode = (int)EnumErrorCodes.NRICNull, ErrorMessage = new ErrorInfo().GetErrorMessage(EnumErrorCodes.NRICNull) })); return; } // print label BarcodePrinterUtil printerUtils = BarcodePrinterUtil.Instance; TTLabelInfo infoTTLabel = new TTLabelInfo { ID = labelInfo.NRIC, Name = labelInfo.Name, MarkingNumber = labelInfo.MarkingNo }; //MessageBox.Show("Call PrintTTLabel"); if (printerUtils.PrintTTLabel_Direction_0(infoTTLabel)) { // raise succeeded event RaisePrintTTLabelSucceededEvent(new PrintMUBAndTTLabelsEventArgs(labelInfo)); } else { // raise failed event RaiseMonitorExceptionEvent(new ExceptionArgs(new FailedInfo() { ErrorCode = (int)EnumErrorCodes.UnknownError, ErrorMessage = new ErrorInfo().GetErrorMessage(EnumErrorCodes.UnknownError) })); } }
protected void btnDeleteLabel_Click(object sender, System.EventArgs e) { AdminController aCont = new AdminController(); int LabelId = Convert.ToInt32(txtSelectedLabel.Value); LabelInfo Label = new LabelInfo(); Label.Id = LabelId; aCont.Delete_Label(Label); lblLabelMessage.Text = "Label Deleted."; FillLabelList(); clearLabel(); //fillDropDowns(""); }
public virtual Task SelectLabelAsync(LabelInfo label) { if (ActiveLabel == null || !label.Name.Equals(ActiveLabel.Info.Name)) { ActiveLabel = new Label() { Info = label }; // TODO: Put in command queue and run later. return(GmailImap.SelectLabelAsync(label.Name)); } return(Task.FromResult(0)); }
private LabelInfo GetLabelInfo(LabelTarget label) { if (_labelTemps == null) { _labelTemps = new Dictionary <LabelTarget, LabelInfo>(); } if (!_labelTemps.TryGetValue(label, out LabelInfo temp)) { _labelTemps[label] = temp = new LabelInfo(label); } return(temp); }
protected override Expression VisitGoto(GotoExpression node) { if (node.Target.Type == typeof(void)) { return(base.VisitGoto(node)); } LabelInfo info = GetLabelInfo(node.Target); return(Expression.Block( MakeAssign(info.Temp, Visit(node.Value)), Expression.MakeGoto(node.Kind, info.NewLabel, null, node.Type) )); }
/// <summary> /// 保存数据 /// </summary> private void SaveData() { LabelInfo info = new LabelInfo(); info.Title = tb_Title.Text.Trim(); info.Remark = tb_Remark.Text.Trim(); info.Content = rtb_Content.Text; if (ParentInfo == null && lb_ID.Text == "") { MessageBox.Show("请选择目录。"); return; } if (info.Title == "") { MessageBox.Show("请输入名称。"); return; } if (info.Content == "") { MessageBox.Show("请输入内容。"); return; } int rst = -1; if (lb_ID.Text == "") { info.ParentID = ParentInfo.ID; rst = dal.Label_Add(info); } else { info.ID = int.Parse(lb_ID.Text); rst = dal.Label_Edit(info); } QueryData(); if (rst == 1) { MessageBox.Show("保存成功。"); } else { MessageBox.Show("保存失败。"); } }
// // The rewriter assigns expressions into temporaries. If the expression is a label with a value the resulting tree would be illegal // since we cannot jump into RHS of an assignment. Hence we need to eliminate labels and gotos with value. We just need to rewrite // those that are used in MakeAssign but it is easier to rewrite all. // // var = label[L](value1) // ... // goto[L](value2) // // -> // // { tmp = value1; label[L]: var = tmp } // ... // { tmp = value2; goto[L] } // protected override Expression VisitLabel(LabelExpression node) { if (node.Target.Type == typeof(void)) { return(base.VisitLabel(node)); } LabelInfo info = GetLabelInfo(node.Target); return(Expression.Block( MakeAssign(info.Temp, Visit(node.DefaultValue)), Expression.Label(info.NewLabel), info.Temp )); }
protected override Expression VisitBlock(BlockExpression node) { var map = default(IDictionary<LabelTarget, LabelInfo>); foreach (var e in node.Expressions) { if (e.NodeType == ExpressionType.Label) { var l = (LabelExpression)e; if (l.Type != typeof(void)) { if (map == null) { map = new Dictionary<LabelTarget, LabelInfo>(); } var name = l.Target.Name; var newLabel = Expression.Label(typeof(void), name); var labelValue = Expression.Parameter(l.Type, name); var info = new LabelInfo { Target = newLabel, Value = labelValue, }; map.Add(l.Target, info); } } } if (map != null) { _labels.Push(map); } var res = (BlockExpression)base.VisitBlock(node); if (map != null) { _labels.Pop(); var newVariables = map.Values.Map(i => i.Value); res = res.Update(res.Variables.Concat(newVariables), res.Expressions); } return res; }
protected override Expression VisitBlock(BlockExpression node) { var map = default(IDictionary <LabelTarget, LabelInfo>); foreach (var e in node.Expressions) { if (e.NodeType == ExpressionType.Label) { var l = (LabelExpression)e; if (l.Type != typeof(void)) { if (map == null) { map = new Dictionary <LabelTarget, LabelInfo>(); } var name = l.Target.Name; var newLabel = Expression.Label(typeof(void), name); var labelValue = Expression.Parameter(l.Type, name); var info = new LabelInfo { Target = newLabel, Value = labelValue, }; map.Add(l.Target, info); } } } if (map != null) { _labels.Push(map); } var res = (BlockExpression)base.VisitBlock(node); if (map != null) { _labels.Pop(); var newVariables = map.Values.Map(i => i.Value); res = res.Update(res.Variables.Concat(newVariables), res.Expressions); } return(res); }
private bool TryGetLabelInfo(LabelTarget target, out LabelInfo info) { if (target.Type != typeof(void)) { foreach (var scope in _labels) { if (scope.TryGetValue(target, out info)) { return(true); } } } info = default(LabelInfo); return(false); }
public async Task <LabelInfo> UpdateAsync(LabelInfo labelInfo) { if (labelInfo == null) { throw new ArgumentNullException("labelInfo"); } var body = labelInfo.ToLabel(); var gmailService = await _gmailApiComponent.GetGmailService(_userId, _userName); var result = await await _gmailApiComponent.ExecuteBackoffAsync(() => gmailService.Users.Labels.Update(body, "me", labelInfo.Id).ExecuteAsync().ConfigureAwait(false)) .ConfigureAwait(false); return(result.ToLabelInfo()); }
private void SetLabelStackState(LabelInfo labelInfo) { if (labelInfo.StackState == null) { labelInfo.StackState = stack.TakeSnapshot(); return; } if (stack.Size == 0 && labelInfo.StackState.Length == 0) { return; } // TODO: merge stack states throw new NotImplementedException(); }
protected void btnGuardar_Click(object sender, EventArgs e) { try { if (!hdnCve_Software.Value.Equals("0")) { Model.Software sofware = new Model.Software(); sofware.Cve_Software = Convert.ToInt32(hdnCve_Software.Value); sofware.Descripcion = txtNombreLicenciaU.Text; sofware.Version = txtVersionU.Text; sofware.NumeroLicencias = Convert.ToInt32(txtCantidadU.Text); BLSoftware blSoftware = new BLSoftware(sofware); blSoftware.actualizaSoftware(); } else { InventarioHSC.Model.Software sofware = new Model.Software(); sofware.Cve_Software = 0; sofware.Descripcion = txtNombreLicenciaU.Text; sofware.Version = txtVersionU.Text; sofware.NumeroLicencias = Convert.ToInt32(txtCantidadU.Text); BLSoftware blSoftware = new BLSoftware(sofware); string respuesta = blSoftware.insertaSoftwareNuevo(); if (respuesta != "OK") { Warning.Visible = false; LabelWarning.Text = ""; LabelInfo.Text = respuesta; LabelInfo.Focus(); Info.Visible = true; btnBuscar_Click(sender, e); mpeDatosSoftware.Hide(); } } } catch (Exception ex) { Warning.Visible = true; LabelWarning.Text = "Ocurrio un Error en el Proceso: " + ex.Message; LabelWarning.Focus(); LabelInfo.Text = ""; Info.Visible = false; } }
public async Task <ActionResult> Edit(EditViewModel viewModel) { if (!ModelState.IsValid) { SetEditSelectLists(viewModel); return(View(viewModel)); } var labelsManager = GetLabelsManager(); LabelInfo label; try { label = await labelsManager.GetAsync(viewModel.Id); } catch (GoogleApiException ex) { if (ex.HttpStatusCode == System.Net.HttpStatusCode.NotFound) { return(HttpNotFound(string.Format("Label id {0} does not exist.", viewModel.Id))); } else { throw; } } if (!label.IsUserType) { return(HttpNotFound()); } var labelInfo = new LabelInfo { Id = viewModel.Id, Name = viewModel.Name, LabelType = viewModel.LabelType, LabelListVisibilityType = (LabelListVisibilityType)viewModel.LabelListVisibilityType, MessageListVisibilityType = (MessageListVisibilityType)viewModel.MessageListVisibilityType }; await labelsManager.UpdateAsync(labelInfo); await Task.Run(() => new TelemetryClient().TrackEvent("EditLabel")); return(RedirectToAction("Index")); }
private async void ButtonSearch_Click(object sender, EventArgs e) { if (ValidateChildren() && !HasError()) { SetLabelInfo("Searching...", Color.Green); _bigFileFinder = new BigFileFinder(Directory, new FilterOptions() { AllowedFileSizeMb = MaxFileSizeMb, NeedSearchFileExtensionNames = Extensions.Split(new[] { ",", Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries) }); _bigFileFinder.Matched += (o) => { FileInfo fileInfo; if (o.TryDequeue(out fileInfo)) { DataAccessHelper.Add(new DataAccess.BigFile() { Length = fileInfo.Length, CreationTime = fileInfo.CreationTime, FileName = fileInfo.Name, FilePath = fileInfo.FullName, LastWriteTime = fileInfo.LastWriteTime }); } }; _bigFileFinder.NewMessageArrived += (o) => { Library.Message message; if (o.TryDequeue(out message)) { DataAccessHelper.Add(new DataAccess.Message() { FolderPath = message.FolderPath, FilePath = message.FilePath, ExceptionMessage = message.Exception.Message, ExceptionLog = message.Exception.ToString(), MessageType = MessageType.Finder }); } }; await _bigFileFinder.Scan().ContinueWith(task => { if (task.Result) { LabelInfo.Invoke(_fillLabelInfo, "Done! Click 'Result' button to show."); } }); } else { ShowValidationEror(); } }
public void fill(LabelInfo liItem) { switch (iType) { case TYPE_STRING: { sText = liItem.GetType().GetProperty( sText ).GetValue(liItem, null).ToString(); break; } case TYPE_BARCODE: { sText = liItem.GetType().GetProperty( sText ).GetValue(liItem, null).ToString(); break; } } }
public void SetLabel(Control parent, Control child, string text) { int index = IndexOfLabel(parent, child); if (index >= 0) { LabelList[index].Text = text; } else { LabelInfo labelInfo = new LabelInfo(); labelInfo.Path = MakeLabelPath(parent, child); labelInfo.Text = text; Array.Resize <LabelInfo>(ref LabelList, (LabelList == null) ? 1 : LabelList.Length + 1); LabelList[LabelList.Length - 1] = labelInfo; } }
public override Label CreateLabel(string name) { int labelIndex = labels.Count; var sinkLabel = default(Label); if (sink != null) { sinkLabel = sink.CreateLabel(name); Contract.Assert(GetLabelIndex(sinkLabel) == labelIndex); } var labelInfo = new LabelInfo(name, sinkLabel); labels.Add(labelInfo); return(MakeLabel(labelIndex)); }
public void fill(LabelInfo liItem) { switch (iType) { case TYPE_STRING: { sText = liItem.GetType().GetProperty(sText).GetValue(liItem, null).ToString(); break; } case TYPE_BARCODE: { sText = liItem.GetType().GetProperty(sText).GetValue(liItem, null).ToString(); break; } } }
// Declare a label within the current method. public virtual Label DefineLabel() { if(labels == null) { labels = new LabelInfo [8]; } else if(numLabels >= labels.Length) { LabelInfo[] newLabels = new LabelInfo [numLabels * 2]; Array.Copy(labels, 0, newLabels, 0, numLabels); labels = newLabels; } return new Label(numLabels++); }
private static void dumpCode(Abc abc, MethodInfo m, string indent, StringBuilder sb) { MemoryStream ms = new MemoryStream(m.code); BinaryReader br = new BinaryReader(ms); //long totalSize = 0; //long[] opSizes = new long[256]; string[] stack = new string[m.max_stack]; LabelInfo labels = new LabelInfo(); long len = m.code.Length; while (br.BaseStream.Position < len) { long start = br.BaseStream.Position; string s = indent + start; while (s.Length < 12) s += ' '; int opcode = br.ReadByte(); if (opcode == (int)Op.label || labels.ContainsKey(br.BaseStream.Position - 1)) { sb.AppendLine(indent) .AppendLine(indent + labels.labelFor(br.BaseStream.Position - 1) + ": "); } s += opNames[opcode]; s += opNames[opcode].Length < 8 ? TAB + TAB : TAB; switch ((Op)opcode) { case Op.debugfile: case Op.pushstring: s += '"' + abc.strings[Abc.readU32(br)].ToString().Replace("\n", "\\n").Replace("\t", "\\t") + '"'; break; case Op.pushnamespace: s += abc.namespaces[Abc.readU32(br)]; break; case Op.pushint: int i = (int)abc.ints[Abc.readU32(br)]; s += i;// + "\t// 0x" + i.ToString(16); break; case Op.pushuint: uint u = (uint)abc.uints[Abc.readU32(br)]; s += u;// + "\t// 0x" + u.ToString(16); break; case Op.pushdouble: s += abc.doubles[Abc.readU32(br)]; break; case Op.getsuper: case Op.setsuper: case Op.getproperty: case Op.initproperty: case Op.setproperty: case Op.getlex: case Op.findpropstrict: case Op.findproperty: case Op.finddef: case Op.deleteproperty: case Op.istype: case Op.coerce: case Op.astype: case Op.getdescendants: s += abc.names[Abc.readU32(br)]; break; case Op.constructprop: case Op.callproperty: case Op.callproplex: case Op.callsuper: case Op.callsupervoid: case Op.callpropvoid: s += abc.names[Abc.readU32(br)]; s += " (" + Abc.readU32(br) + ")"; break; case Op.newfunction: { var method_id = Abc.readU32(br); s += abc.methods[method_id]; abc.methods[method_id].anon = true; break; } case Op.callstatic: s += abc.methods[Abc.readU32(br)]; s += " (" + Abc.readU32(br) + ")"; break; case Op.newclass: s += abc.instances[Abc.readU32(br)]; break; case Op.lookupswitch: var pos = br.BaseStream.Position - 1; var target = pos + readS24(br); var maxindex = Abc.readU32(br); s += "default:" + labels.labelFor(target); // target + "("+(target-pos)+")" s += " maxcase:" + maxindex; for (int j = 0; j <= maxindex; j++) { target = pos + readS24(br); s += " " + labels.labelFor(target); // target + "("+(target-pos)+")" } break; case Op.jump: case Op.iftrue: case Op.iffalse: case Op.ifeq: case Op.ifne: case Op.ifge: case Op.ifnge: case Op.ifgt: case Op.ifngt: case Op.ifle: case Op.ifnle: case Op.iflt: case Op.ifnlt: case Op.ifstricteq: case Op.ifstrictne: int offset = readS24(br); target = br.BaseStream.Position + offset; //s += target + " ("+offset+")" s += labels.labelFor(target); if (!labels.ContainsKey(br.BaseStream.Position)) s += "\n"; break; case Op.inclocal: case Op.declocal: case Op.inclocal_i: case Op.declocal_i: case Op.getlocal: case Op.kill: case Op.setlocal: case Op.debugline: case Op.getglobalslot: case Op.getslot: case Op.setglobalslot: case Op.setslot: case Op.pushshort: case Op.newcatch: s += Abc.readU32(br); break; case Op.debug: s += br.ReadByte(); s += " " + Abc.readU32(br); s += " " + br.ReadByte(); s += " " + Abc.readU32(br); break; case Op.newobject: s += "{" + Abc.readU32(br) + "}"; break; case Op.newarray: s += "[" + Abc.readU32(br) + "]"; break; case Op.call: case Op.construct: case Op.constructsuper: case Op.applytype: s += "(" + Abc.readU32(br) + ")"; break; case Op.pushbyte: case Op.getscopeobject: s += br.ReadSByte(); break; case Op.hasnext2: s += Abc.readU32(br) + " " + Abc.readU32(br); break; default: /*if (opNames[opcode] == ("0x"+opcode.toString(16).toUpperCase())) s += " UNKNOWN OPCODE"*/ break; } long size = br.BaseStream.Position - start; //totalSize += size; //opSizes[opcode] = opSizes[opcode] + size; sb.AppendLine(s); } }
/// <summary> /// Mark current IL position with a label /// </summary> internal void MarkLabel(object label) { EndBlock(); var block = this.GetCurrentBlock(); //1.7.5 Backward branch constraints //It shall be possible, with a single forward-pass through the CIL instruction stream for any method, to infer the //exact state of the evaluation stack at every instruction (where by "state" we mean the number and type of each //item on the evaluation stack). // //In particular, if that single-pass analysis arrives at an instruction, call it location X, that immediately follows an //unconditional branch, and where X is not the target of an earlier branch instruction, then the state of the //evaluation stack at X, clearly, cannot be derived from existing information. In this case, the CLI demands that //the evaluation stack at X be empty. LabelInfo labelInfo; if (_labelInfos.TryGetValue(label, out labelInfo)) { Debug.Assert(labelInfo.bb == null, "duplicate use of a label"); int labelStack = labelInfo.stack; var curStack = _emitState.CurStack; // we have already seen a branch to this label so we know its stack. // Now we will require that fall-through must agree with that stack value. // For the purpose of this assert we assume that all codepaths are reachable. // This is a minor additional burden for languages to makes sure that stack is balanced // even at labels that follow unconditional branches. // What we get is an invariant that satisfies 1.7.5 in reachable code // even though we do not know yet what is reachable. Debug.Assert(curStack == labelStack, "forward branches and fall-through must agree on stack depth"); _labelInfos[label] = labelInfo.WithNewTarget(block); } else { // this is a label for which we have not seen a branch yet. // it could mean two things - // 1) it is a label of a backward branch or // 2) it is a label for an unreachable forward branch and codegen did not bother to emit the branch. // // We cannot know here which case we have, so we cannot verify or force stack to be 0 on a backward branch. // We will just assume that languages do not do backward branches on nonempty stack // and let PEVerify catch that. // // With the above "assumption" current stack state is correct by definition // so label will assume current value and all other branches to this label // will have to agree on that for consistency. var curStack = _emitState.CurStack; _labelInfos[label] = new LabelInfo(block, curStack, false); } _instructionCountAtLastLabel = _emitState.InstructionsEmitted; }
internal void AddLabelInfo(LabelTarget target, LabelInfo info) { Debug.Assert(CanJumpInto); if (Labels == null) { Labels = new Dictionary<LabelTarget, LabelInfo>(); } Labels.Add(target, info); }
private bool TryGetLabelInfo(LabelTarget target, out LabelInfo info) { if (target.Type != typeof(void)) { foreach (var scope in _labels) { if (scope.TryGetValue(target, out info)) { return true; } } } info = default(LabelInfo); return false; }
private LabelInfo EnsureLabel(LabelTarget node) { LabelInfo info; if (!this._treeLabels.TryGetValue(node, out info)) { this._treeLabels[node] = info = new LabelInfo(node); } return info; }