Closed Bug 496024 Opened 15 years ago Closed 15 years ago

Make use of iterators for dehydra's process callback

Categories

(Developer Infrastructure :: Source Code Analysis, defect)

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: taras.mozilla, Unassigned)

References

Details

Attachments

(1 file)

We've long had a top-secret process() callback(it never got documented) and convenience function called iter(). Unfortunately iter is written in a functional style and some have complained about it not using generators instead.

So I took this one step futher and made it so process() is passed a generator to variables in the current statement, this makes "grepping" a whole lot more convenient. Compare the example at http://www.kdedevelopers.org/node/3970
With:

function process(statement_items) {
  for each (var v in statement_items) {
    if (v.shortName == "strcpy")
      error("Evil")
  }
}

Would be nice if some JS expert confirmed that this is the right way(tm).
(In reply to comment #1)
> Created an attachment (id=381164) [details]
> patch to dehydra.js

Cc'ing better Pythonistas than a poser like me.

I like it -- "flat is better than nested" -- but that does not apply to the indentation :-P. Indent the inner for loops and their bodies appropriately.

Also, let goes with yield like a fish with a fighter-jet. Those vars are too old skool.

/be
I'm guessing we can close this out now that we have iterate_vars()?
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → WONTFIX
Product: Core → Firefox Build System
Product: Firefox Build System → Developer Infrastructure
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: