Search in sources :

Example 1 with Prototype

use of org.osate.aadl2.Prototype in project LuaViewSDK by alibaba.

the class DebugLib method getfuncname.

// Return the name info if found, or null if no useful information could be found.
static NameWhat getfuncname(DebugLib.CallFrame frame) {
    if (!frame.f.isclosure())
        return new NameWhat(frame.f.classnamestub(), "Java");
    Prototype p = frame.f.checkclosure().p;
    int pc = frame.pc;
    int i = p.code[pc];
    /* calling instruction */
    LuaString tm;
    switch(Lua.GET_OPCODE(i)) {
        case Lua.OP_CALL:
        case Lua.OP_TAILCALL:
            /* get function name */
            return getobjname(p, pc, Lua.GETARG_A(i));
        case Lua.OP_TFORCALL:
            /* for iterator */
            return new NameWhat("(for iterator)", "(for iterator");
        /* all other instructions can call only through metamethods */
        case Lua.OP_SELF:
        case Lua.OP_GETTABUP:
        case Lua.OP_GETTABLE:
            tm = LuaValue.INDEX;
            break;
        case Lua.OP_SETTABUP:
        case Lua.OP_SETTABLE:
            tm = LuaValue.NEWINDEX;
            break;
        case Lua.OP_EQ:
            tm = LuaValue.EQ;
            break;
        case Lua.OP_ADD:
            tm = LuaValue.ADD;
            break;
        case Lua.OP_SUB:
            tm = LuaValue.SUB;
            break;
        case Lua.OP_MUL:
            tm = LuaValue.MUL;
            break;
        case Lua.OP_DIV:
            tm = LuaValue.DIV;
            break;
        case Lua.OP_MOD:
            tm = LuaValue.MOD;
            break;
        case Lua.OP_POW:
            tm = LuaValue.POW;
            break;
        case Lua.OP_UNM:
            tm = LuaValue.UNM;
            break;
        case Lua.OP_LEN:
            tm = LuaValue.LEN;
            break;
        case Lua.OP_LT:
            tm = LuaValue.LT;
            break;
        case Lua.OP_LE:
            tm = LuaValue.LE;
            break;
        case Lua.OP_CONCAT:
            tm = LuaValue.CONCAT;
            break;
        default:
            return null;
    }
    return new NameWhat(tm.tojstring(), "metamethod");
}
Also used : Prototype(org.luaj.vm2.Prototype) LuaString(org.luaj.vm2.LuaString) LuaPrint(org.luaj.vm2.log.LuaPrint)

Example 2 with Prototype

use of org.osate.aadl2.Prototype in project LuaViewSDK by alibaba.

the class LexState method parlist.

/* }====================================================================== */
void parlist() {
    /* parlist -> [ param { `,' param } ] */
    FuncState fs = this.fs;
    Prototype f = fs.f;
    int nparams = 0;
    f.is_vararg = 0;
    if (this.t.token != ')') {
        /* is `parlist' not empty? */
        do {
            switch(this.t.token) {
                case TK_NAME:
                    {
                        /* param . NAME */
                        this.new_localvar(this.str_checkname());
                        ++nparams;
                        break;
                    }
                case TK_DOTS:
                    {
                        /* param . `...' */
                        this.next();
                        f.is_vararg = 1;
                        break;
                    }
                default:
                    this.syntaxerror("<name> or " + LUA_QL("...") + " expected");
            }
        } while ((f.is_vararg == 0) && this.testnext(','));
    }
    this.adjustlocalvars(nparams);
    f.numparams = fs.nactvar;
    fs.reserveregs(fs.nactvar);
/* reserve register for parameters */
}
Also used : Prototype(org.luaj.vm2.Prototype)

Example 3 with Prototype

use of org.osate.aadl2.Prototype in project LuaViewSDK by alibaba.

the class LexState method registerlocalvar.

int registerlocalvar(LuaString varname) {
    FuncState fs = this.fs;
    Prototype f = fs.f;
    if (f.locvars == null || fs.nlocvars + 1 > f.locvars.length)
        f.locvars = LuaC.realloc(f.locvars, fs.nlocvars * 2 + 1);
    f.locvars[fs.nlocvars] = new LocVars(varname, 0, 0);
    return fs.nlocvars++;
}
Also used : Prototype(org.luaj.vm2.Prototype) LocVars(org.luaj.vm2.LocVars)

Example 4 with Prototype

use of org.osate.aadl2.Prototype in project LuaViewSDK by alibaba.

the class FuncState method addk.

int addk(LuaValue v) {
    if (this.h == null) {
        this.h = new Hashtable();
    } else if (this.h.containsKey(v)) {
        return ((Integer) h.get(v)).intValue();
    }
    final int idx = this.nk;
    this.h.put(v, new Integer(idx));
    final Prototype f = this.f;
    if (f.k == null || nk + 1 >= f.k.length)
        f.k = realloc(f.k, nk * 2 + 1);
    f.k[this.nk++] = v;
    return idx;
}
Also used : LuaInteger(org.luaj.vm2.LuaInteger) Prototype(org.luaj.vm2.Prototype) Hashtable(java.util.Hashtable)

Example 5 with Prototype

use of org.osate.aadl2.Prototype in project LuaViewSDK by alibaba.

the class LuaC method luaY_parser.

/**
 * Parse the input
 */
private Prototype luaY_parser(InputStream z, String name, boolean standardSyntax) throws IOException {
    LexState lexstate = new LexState(this, z, standardSyntax);
    FuncState funcstate = new FuncState();
    // lexstate.buff = buff;
    lexstate.fs = funcstate;
    lexstate.setinput(this, z.read(), z, (LuaString) LuaValue.valueOf(name));
    /* main func. is always vararg */
    funcstate.f = new Prototype();
    funcstate.f.source = (LuaString) LuaValue.valueOf(name);
    lexstate.mainfunc(funcstate);
    LuaC._assert(funcstate.prev == null);
    /* all scopes should be correctly finished */
    LuaC._assert(lexstate.dyd == null || (lexstate.dyd.n_actvar == 0 && lexstate.dyd.n_gt == 0 && lexstate.dyd.n_label == 0));
    return funcstate.f;
}
Also used : Prototype(org.luaj.vm2.Prototype)

Aggregations

Prototype (org.osate.aadl2.Prototype)24 Prototype (org.luaj.vm2.Prototype)21 Classifier (org.osate.aadl2.Classifier)20 ComponentPrototype (org.osate.aadl2.ComponentPrototype)20 ComponentClassifier (org.osate.aadl2.ComponentClassifier)19 FeatureGroupPrototype (org.osate.aadl2.FeatureGroupPrototype)17 ComponentPrototypeBinding (org.osate.aadl2.ComponentPrototypeBinding)16 FeaturePrototype (org.osate.aadl2.FeaturePrototype)14 FeaturePrototypeBinding (org.osate.aadl2.FeaturePrototypeBinding)14 FeatureGroupPrototypeBinding (org.osate.aadl2.FeatureGroupPrototypeBinding)13 PrototypeBinding (org.osate.aadl2.PrototypeBinding)13 Subcomponent (org.osate.aadl2.Subcomponent)13 FeatureGroupType (org.osate.aadl2.FeatureGroupType)11 DataPrototype (org.osate.aadl2.DataPrototype)10 NamedElement (org.osate.aadl2.NamedElement)10 ComponentPrototypeActual (org.osate.aadl2.ComponentPrototypeActual)9 DataClassifier (org.osate.aadl2.DataClassifier)9 Feature (org.osate.aadl2.Feature)9 FeatureGroupPrototypeActual (org.osate.aadl2.FeatureGroupPrototypeActual)9 EClass (org.eclipse.emf.ecore.EClass)7