AVM2 中的 $cinit 和 $init 是什么?

发布于 2024-08-21 05:11:02 字数 503 浏览 14 评论 0原文

更新:发现一些关于的好信息AVM2。我没能花太多时间来研究它,但它确实涵盖了 $init 和 $cinit (以及 $iinit 和许多其他东西)。如果我在其他人提出问题之前很好地掌握了答案,我会发布对此问题的答复。


今天被拉进了一大堆链接跳转和谷歌搜索,但仍然不太了解 $cinit 和 $init 是什么。

我很关心,因为我今天了解到 $cinit 和 $init 是被解释的(如果我理解正确的话,由 FP 解释),而其他所有内容都是编译的。

我认为 $init 指的是给定类的构造函数,而 $cinit 指的是创建该类的对象的构造函数。 ...类似的事情...

任何人都可以让我直接了解这一点,或者至少为我指出一个有用的方向吗?

谢谢。

UPDATE: Found some nice info on AVM2. I haven't been able to spend much time with it, but it definitely covers $init and $cinit (as well as $iinit, and a lot of other things). I'll post a response to this question if I get a good handle on the answer before someone else puts something up.


Got pulled into a long thread of link-hopping and googling about this today, but still don't have much of a grasp on what $cinit and $init are.

I care because I learned today that $cinit and $init are interpreted (by the FP, if I understand correctly), while everything else is compiled.

I think that $init refers to the given class's constructor function, and $cinit refers to the constructor of the object that creates the class. ... something like that...

Can anyone set me straight on this, or at least point me in a helpful direction?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

笑忘罢 2024-08-28 05:11:02

这是一个老问题,但据我所知,我将在这里发布答案。

$cinit 是在需要使用该类之前调用​​的方法。它初始化所有静态成员并运行静态初始化程序中的任何代码。将其视为类自己的构造函数。例如,如果您在 AS3 中有以下类:

public class SomeClass extends Object {
   static private const SOME_STATIC_VAR = 4;
   ....
}

那么 $cinit 方法将在该类被使用甚至引用之前运行,并且它将初始化 SOME_STATIC_VAR< 的内存/code> 并将其值设置为 4。

$init 是类实例初始值设定项。它基本上是类构造函数。例如:

public function SomeClass() {
  super();
  return;
}

希望这对您来说已经足够详细了!

This is an old question, but as I know the answer I'll post here.

$cinit is the method that is called before any use of the class is required. It initializes all static members and runs any code that is in the static initializer. Think of it as the classes own constructor. For instance, if you had the following class in AS3:

public class SomeClass extends Object {
   static private const SOME_STATIC_VAR = 4;
   ....
}

Then the $cinit method would run before the class was ever used or even made reference to, and it would initialize the memory for SOME_STATIC_VAR and set its value to 4.

$init is the classes instance initializer. It's basically the classes constructor. For example:

public function SomeClass() {
  super();
  return;
}

Hope thats enough detail for you!

倚栏听风 2024-08-28 05:11:02

$cinit 是在第一次使用该类时构造所有静态变量。

$cinit is to construct all static variables while the class are used for the first time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文