Commit 5193948e authored by rogerl%netscape.com's avatar rogerl%netscape.com
Browse files

Parameter/argument matching.

parent e8fe8119
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -401,9 +401,19 @@ namespace MetaData {
                if (pb) {
                    NamespaceList publicNamespaceList;
                    publicNamespaceList.push_back(publicNamespace);
                    uint32 pCount = 0;
                    while (pb) {
                        pCount++;
                        pb = pb->next;
                    }
                    pb = f->function.parameters;
                    compileFrame->positional = new Variable *[pCount];
                    compileFrame->positionalCount = pCount;
                    pCount = 0;
                    while (pb) {
                        // XXX define a static binding for each parameter
                        Variable *v = new Variable();
                        compileFrame->positional[pCount++] = v;
                        pb->mn = defineStaticMember(env, pb->name, &publicNamespaceList, Attribute::NoOverride, false, ReadWriteAccess, v, p->pos);
                        pb = pb->next;
                    }
@@ -3967,6 +3977,22 @@ deleteClassProperty:
        env->instantiateFrame(pluralFrame, this);
    }

    // Assume that instantiate has been called, the plural frame will contain
    // the cloned Variables assigned into this (singular) frame. Use the 
    // incoming values to initialize the positionals.
    void ParameterFrame::assignArguments(js2val *argBase, uint32 argCount)
    {
        ASSERT(pluralFrame->kind == ParameterKind);
        ParameterFrame *plural = checked_cast<ParameterFrame *>(pluralFrame);
        ASSERT((plural->positionalCount == 0) || (plural->positional != NULL));
        for (uint32 i = 0; ((i < argCount) && (i < plural->positionalCount)); i++) {
            ASSERT(plural->positional[i]->cloneContent);
            ASSERT(plural->positional[i]->cloneContent->kind == Member::Variable);
            (checked_cast<Variable *>(plural->positional[i]->cloneContent))->value = argBase[i];
        }
    }


    // gc-mark all contained JS2Objects and visit contained structures to do likewise
    void ParameterFrame::markChildren()
    {
+9 −3
Original line number Diff line number Diff line
@@ -271,6 +271,8 @@ public:
    StaticMember *cloneContent; // Used during cloning operation to prevent cloning of duplicates (i.e. once
                                // a clone exists for this member it's recorded here and used for any other
                                // bindings that refer to this member.)
                                // Also used thereafter by 'assignArguments' to initialize the singular
                                // variable instantations in a parameter frame.

    virtual StaticMember *clone()       { ASSERT(false); return NULL; }
};
@@ -751,17 +753,21 @@ public:
// Frames holding bindings for invoked functions
class ParameterFrame : public Frame {
public:
    ParameterFrame(js2val thisObject, bool prototype) : Frame(ParameterKind), thisObject(thisObject), prototype(prototype) { }    
    ParameterFrame(ParameterFrame *pluralFrame) : Frame(ParameterKind, pluralFrame), thisObject(JS2VAL_UNDEFINED), prototype(pluralFrame->prototype) { }
    ParameterFrame(js2val thisObject, bool prototype) : Frame(ParameterKind), thisObject(thisObject), prototype(prototype), positional(NULL), positionalCount(0) { }    
    ParameterFrame(ParameterFrame *pluralFrame) : Frame(ParameterKind, pluralFrame), thisObject(JS2VAL_UNDEFINED), prototype(pluralFrame->prototype), positional(NULL), positionalCount(0) { }

    Plurality plurality;
//    Plurality plurality;
    js2val thisObject;              // The value of this; none if this function doesn't define this;
                                    // inaccessible if this function defines this but the value is not 
                                    // available because this function hasn't been called yet.

    bool prototype;                 // true if this function is not an instance method but defines this anyway

    Variable **positional;          // list of positional parameters, in order
    uint32 positionalCount;

    virtual void instantiate(Environment *env);
    void assignArguments(js2val *argBase, uint32 argCount);
    virtual void markChildren();
};

+1 −22
Original line number Diff line number Diff line
@@ -127,28 +127,7 @@
                runtimeFrame->thisObject = a;
//                assignArguments(runtimeFrame, fWrap->compileFrame->signature);
                // XXX

                for (uint32 i = 0, a = 0; i < fWrap->compileFrame->parameterCount; i++) {
                    
                }

                for (StaticBindingIterator sbi = runtimeFrame->staticReadBindings.begin(), sbend = runtimeFrame->staticReadBindings.end(); (sbi != sbend); sbi++) {
                    StaticBinding *sb;
                    StaticBinding *m = sbi->second;
                    if (m->content->cloneContent == NULL) {
                        m->content->cloneContent = m->content->clone();
                    }
                    sb = new StaticBinding(m->qname, m->content->cloneContent);
                    sb->xplicit = m->xplicit;
                    const StaticBindingMap::value_type e(sbi->first, sb);
                    singularFrame->staticReadBindings.insert(e);
                }



                for (uint32 i = 0; i < argCount; i++) {
                    
                }
                runtimeFrame->assignArguments(base(argCount), argCount);
                if (!fWrap->code)
                    jsr(phase, fWrap->bCon);   // seems out of order, but we need to catch the current top frame 
                meta->env.addFrame(runtimeFrame);