Security:Strawman Model: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
<code>
Types:
function Iterator() {
<pre>
    var i = arguments.length;
Principal = (System, Origin, Null)   // disjoint type union
System    = {system}                  // system principal singleton
Origin    = {origin1, ... originN}    // set of N origin principals
Null      = {null}                    // null principal singleton
</pre>


    if (i < 0 && 2 < i)
Definitions:
        throw TypeError("Iterator requires 0 to 2 arguments");
Let P be the set of all principals.


    function generic_next() { return this(); };
Let <= be a binary relation by which P is partially ordered.


    var arg0 = arguments[0];
For all p in P, p <= system.
    if (arg0 && typeof arg0 == "object") {
        if (i == 2 && typeof arg0 == "function") {
            var callable = arg0;
            var sentinel = arguments[1];
            var last;


            function funiter() {
For all Origin principals p and q in P, !(p <= q) && !(q <= p).
                last = callable();
                if (last == sentinel)
                    throw "StopIteration";
                return last;
            }
            funiter.next = generic_next;
            funiter.done = function () { return last == sentinel; };
            return funiter;
        }


        var keys = [];
For all p in P, unknown <= p.
        for (i in arg0)
            keys.push(i);


        i = 0;
For all principals p and q, there exists in P the greatest lower bound (p ^ q),
        function objiter() {
the meet of p and q, defined by <=. (P, <=) is a meet semi-lattice.
            if (i == keys.length)
                throw "StopIteration";
            return keys[i++];
        }
        objiter.next = generic_next;
        objiter.done = function () { return i == keys.length; };
        return objiter;
    }


    var end, start = 0, step = 1;
For all p in P, (p ^ system) == p.
    i = 0;
    switch (arguments.length) {
      case 3:
        step = Number(arguments[2]);
      case 2:
        start = Number(arg0), i = 1;
      case 1:
        end = Number(arguments[i]);
        break;
    }


    i = start;
For all p in P, (p ^ null) == null.
    function iter() {
        if (i == end)
            throw "StopIteration";
        var j = i;
        i += step;
        return j;
    }
    iter.next = generic_next;
    iter.done = function () { return i == end; };
    return iter;
}
</code>

Revision as of 22:45, 1 August 2006

Types:

Principal = (System, Origin, Null)    // disjoint type union
System    = {system}                  // system principal singleton
Origin    = {origin1, ... originN}    // set of N origin principals
Null      = {null}                    // null principal singleton

Definitions: Let P be the set of all principals.

Let <= be a binary relation by which P is partially ordered.

For all p in P, p <= system.

For all Origin principals p and q in P, !(p <= q) && !(q <= p).

For all p in P, unknown <= p.

For all principals p and q, there exists in P the greatest lower bound (p ^ q), the meet of p and q, defined by <=. (P, <=) is a meet semi-lattice.

For all p in P, (p ^ system) == p.

For all p in P, (p ^ null) == null.