C# 中的代码好奇心
我正在查看 YUI 压缩机,并在 ECMA 中发现了这段代码。 NET 项目(如果您有兴趣,可以查看继续文件)。
protected internal override int FindPrototypeId (string s)
{
int id;
#region Generated PrototypeId Switch
L0: {
id = 0;
string X = null;
if (s.Length == 11) { X = "constructor"; id = Id_constructor; }
if (X != null && X != s && !X.Equals (s))
id = 0;
}
EL0:
#endregion
return id;
}
我不知道 L0: 和 EL0: 在这里做什么,以前从未见过。 这个术语对于谷歌来说似乎也太初级了。
有人知道这是什么一回事吗?
I was looking at the YUI Compressor and came across this piece of code in the ECMA.NET project (Continuation file if you are interested).
protected internal override int FindPrototypeId (string s)
{
int id;
#region Generated PrototypeId Switch
L0: {
id = 0;
string X = null;
if (s.Length == 11) { X = "constructor"; id = Id_constructor; }
if (X != null && X != s && !X.Equals (s))
id = 0;
}
EL0:
#endregion
return id;
}
I have no idea what L0: and EL0: are doing here and have never seen this before. The term seems too rudimentary for google as well.
Anyone know anything about this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
它们看起来像用作转到目标的标签。 请参阅 http://msdn.microsoft.com/en-us/library/13940fs2 .aspx 了解更多信息。
They look like lables for use as goto targets. See http://msdn.microsoft.com/en-us/library/13940fs2.aspx for more information.
它们对我来说就像标签。 这个例子中没有使用标签(因为它是生成代码?),但可以用来跳转到另一个地方。 您可以使用
goto L0;
跳转到第一个标签。 例如,以下代码仅写入“Hello, World”,因为它跳过了中间的Write()
:They look like labels to me. The label is not used in this example (because it is generated code?), but can be used to jump another place. You could use
goto L0;
to jump the the first label. As an example, the following code writes just "Hello, World" because it skips the middleWrite()
:这些是标签,如 GOTO 中的标签。
Those are labels, as in GOTO.
它们显然是标签,但我不认为它们被用作跳转目标。 我想它们被设计为可以被某种代码生成工具识别。 代码生成工具“拥有”L0 和 EL0 之间的代码,这可能只是意味着“L0 结束”。
They're obviously labels, but I don't think that they're used as goto targets. I imagine that they're designed to be recognized by a code generation tool of some kind. The code generation tool "owns" the code between L0 and EL0, which probably just means "end L0."
L0 和 EL0 看起来像 goto 语句的标签
L0 and EL0 look like labels for the goto statement