On 2010-07-01, at 15:11, Henry Minsky wrote: > regarding http://jira.openlaszlo.org/jira/browse/LPP-9168 > > > Does the script compiler only evaluate "if ($debug)" at compile time for > top-level if statements?
It should evaluate them at any level at compile time, so long as the flag is defined as a compile-time constant. It will also evaluate conditional expressions (i.e., ?: operator). See: http://jira.openlaszlo.org/jira/browse/LPP-9030 > The method that NodeModel is emitting looks like this, so it's not a top > level 'if' statement: > > function $m109 () { > /* -*- file: -*- */ > try { > /* -*- file: lib.lzx#3 -*- */ > if ($debug) { > return $lzc$validateReferenceDependencies([parent, "width"], ["parent"]) > } else { > return [parent, "width"] > }} > > > Assuming that the compileTimeConstants are being set up correctly so that > $debug is bound for the > script compiler, should that first arm of the "if ($debug)" be getting > removed at compile time? Only in the script back end. Definitely _NOT_ by the tag compiler. See: http://jira.openlaszlo.org/jira/browse/LPP-9017 > As a matter of fact, that compileTimeConstants table is not being set up by > ImportCompiler, That's clearly wrong. > but even when > I fix that, the script compiler does not transform the "if ($debug)" at > compile time. Are you looking at the output of the tag compiler, or the output of the script compler? > Maybe I had better rewrite that code in NodeModel not emit a reference to > $lzc$validateReferenceDependencies > when compiling in non-debug mode, or else we need to put a stub function > into the non-debug runtime so that > the as3 compiler doesn't complain about not having it. No. Per above. The tag compiler _must_ defer compile-time conditionals to "link time", otherwise .lzo's will not be platform independent.
