Package org.jatha.dynatype

Examples of org.jatha.dynatype.LispValue


    super(lisp, "STRING>=", 2);
  }

  public void Execute(SECDMachine machine)
  {
    LispValue arg2 = machine.S.pop();
    LispValue arg1 = machine.S.pop();

    machine.S.push(arg1.stringGreaterThanOrEqual(arg2));
    machine.C.pop();
  }
View Full Code Here


    super(lisp, "STRING-GREATERP", 2);
  }

  public void Execute(SECDMachine machine)
  {
    LispValue arg2 = machine.S.pop();
    LispValue arg1 = machine.S.pop();

    machine.S.push(arg1.stringGreaterP(arg2));
    machine.C.pop();
  }
View Full Code Here

    public Map parse(final LispValue arguments) {
        final Map ret = new HashMap();
        int state = 0; // 0 = regular, 1 = optional, 2 = rest, 3 = key
        final Set keyArgsLeft = new HashSet(keyArguments.keySet());
        final Set optArgsLeft = new HashSet(optionalArguments);
        LispValue vals = lisp.NIL;
           
        Iterator next = normalArguments.iterator();
        LispValue rests = null;
        boolean tempAllow = allowOtherKeys;

        if(!tempAllow) {
            for(final Iterator iter = arguments.iterator();iter.hasNext();) {
                if((((LispValue)iter.next()).eql(allowOtherKeysKey)) == lisp.T && iter.next() != lisp.NIL) {
                    tempAllow = true;
                    break;
                }
            }
        }
       
        for(final Iterator iter = arguments.iterator();iter.hasNext();) {
            final LispValue val = (LispValue)iter.next();
            if(tempAllow && (val.eql(allowOtherKeysKey) == lisp.T)) {
                iter.next();
                continue;
            }

            while(next != null && !next.hasNext()) {
                state++;
                switch(state) {
                case 1:
                    next = optionalArguments.iterator();
                    break;
                case 2:
                    if(restArgument != null) {
                        rests = lisp.NIL;
                    }
                    next = null;
                    break;
                default:
                    next = null;
                    break;
                }
            }
            switch(state) {
            case 0:
                final NormalArgument arg = (NormalArgument)next.next();
                ret.put(arg.getVar(),val);
                vals = lisp.makeCons(lisp.makeList(arg.getVar(),val),vals);
                break;
            case 1:
                final OptionalArgument oarg = (OptionalArgument)next.next();
                ret.put(oarg.getVar(),val);
                vals = lisp.makeCons(lisp.makeList(oarg.getVar(),val),vals);
                optArgsLeft.remove(oarg);
                if(oarg.getSupplied() != null) {
                    ret.put(oarg.getSupplied(),lisp.T);
                    vals = lisp.makeCons(lisp.makeList(oarg.getSupplied(),lisp.T),vals);
                }
                break;
            default:
                if(keyArguments.size() > 0 || tempAllow) {
                    final KeyArgument key = (KeyArgument)keyArguments.get(val);
                    if(null != key || tempAllow) {
                        keyArgsLeft.remove(val);
                        final LispValue theVal = (LispValue)iter.next();
                        if(null != rests) {
                            rests = rests.append(lisp.makeCons(val,lisp.makeCons(theVal,lisp.NIL)));
                        }
                        if(null != key) {
                            ret.put(key.getVar(),theVal);
                            vals = lisp.makeCons(lisp.makeList(key.getVar(),theVal),vals);
                            if(key.getSupplied() != null) {
                                ret.put(key.getSupplied(),lisp.T);
                                vals = lisp.makeCons(lisp.makeList(key.getSupplied(),lisp.T),vals);
                            }
                        }
                    } else {
                        throw new IllegalArgumentException("Bad key argument: " + val); //TODO: fix good exception here
                    }
                } else if(null != rests) {
                    rests = rests.append(lisp.makeCons(val,lisp.NIL));
                } else {
                    throw new IllegalArgumentException("Bad arguments"); //TODO: fix good exception here
                }



                break;
            }
        }
        if(state == 0 && !optionalArguments.isEmpty()) {
            next = optionalArguments.iterator();
        }
        for(;next != null && next.hasNext();) {
            final OptionalArgument arg = (OptionalArgument)next.next();
            if(arg.getInitForm() != null) {
                final LispValue val = lisp.eval(arg.getInitForm(),lisp.makeList(vals));
                ret.put(arg.getVar(),val);
                vals = lisp.makeCons(lisp.makeList(arg.getVar(),val),vals);
            } else {
                ret.put(arg.getVar(),lisp.NIL);
                vals = lisp.makeCons(lisp.makeList(arg.getVar(),lisp.NIL),vals);
            }
            if(arg.getSupplied() != null) {
                ret.put(arg.getSupplied(),lisp.NIL);
                vals = lisp.makeCons(lisp.makeList(arg.getSupplied(),lisp.NIL),vals);
            }
        }
        for(final Iterator iter = keyArgsLeft.iterator();iter.hasNext();) {
            final LispValue sym = (LispValue)iter.next();
            final KeyArgument arg = (KeyArgument)keyArguments.get(sym);
            if(arg.getInitForm() != null) {
                final LispValue val = lisp.eval(arg.getInitForm(),lisp.makeList(vals));
                ret.put(arg.getVar(),val);
                vals = lisp.makeCons(lisp.makeList(arg.getVar(),val),vals);
            } else {
                ret.put(arg.getVar(),lisp.NIL);
                vals = lisp.makeCons(lisp.makeList(arg.getVar(),lisp.NIL),vals);
            }
            if(arg.getSupplied() != null) {
                ret.put(arg.getSupplied(),lisp.NIL);
                vals = lisp.makeCons(lisp.makeList(arg.getSupplied(),lisp.NIL),vals);
            }
        }
        if(restArgument != null) {
            if(rests != null) {
                ret.put(restArgument.getVar(),rests);
                vals = lisp.makeCons(lisp.makeList(restArgument.getVar(),rests),vals);
            } else {
                ret.put(restArgument.getVar(),lisp.NIL);
                vals = lisp.makeCons(lisp.makeList(restArgument.getVar(),lisp.NIL),vals);
            }
        }

        for(final Iterator iter = auxArguments.iterator();iter.hasNext();) {
            final AuxArgument arg = (AuxArgument)iter.next();
            final LispValue val = lisp.eval(arg.getInitForm(),lisp.makeList(vals));
            ret.put(arg.getVar(),val);
            vals = lisp.makeCons(lisp.makeList(arg.getVar(),val),vals);
        }
        return ret;
    }
View Full Code Here

    super(lisp, "STRING<=", 2);
  }

  public void Execute(SECDMachine machine)
  {
    LispValue arg2 = machine.S.pop();
    LispValue arg1 = machine.S.pop();

    machine.S.push(arg1.stringLessThanOrEqual(arg2));
    machine.C.pop();
  }
View Full Code Here

  }

  public void Execute(SECDMachine machine)
  {
    long      numArgs;
    LispValue argList = f_lisp.NIL;

    machine.C.pop();               /* Pop the LIS command. */

    numArgs = ((LispInteger)machine.C.pop()).getLongValue();    /* Pop the number of args. */
    for (int i=0; i < numArgs; ++i)
View Full Code Here

  }


  public void Execute(SECDMachine machine)
  {
    LispValue val = machine.S.pop();

    machine.C.pop()// Pop the SP_BIND instruction
    LispValue sym = machine.C.pop();   // Pop the symbol name
    machine.special_bind(sym, val);
  }
View Full Code Here

  }


  public void Execute(SECDMachine machine)
  {
    LispValue indexes;

    indexes = machine.C.value().second();
    /*
    System.err.println("----DEBUG----");
    System.err.println(machine.E.value());
View Full Code Here

  }


  public void Execute(SECDMachine machine)
  {
    LispValue selector    = machine.S.pop();
    LispValue trueCodeBranch;
    LispValue falseCodeBranch;

    machine.C.pop();                    // Pop the SEL command.
    trueCodeBranch   = machine.C.pop();
    falseCodeBranch  = machine.C.pop();
View Full Code Here

  public void Execute(SECDMachine machine)
  {
    /* Make a closure and push it on the S Register. */
    machine.C.pop();   // pop the LDFC symbol.

    LispValue code = machine.C.pop().symbol_function();
    if (code instanceof LispFunction)
      code = ((LispFunction)code).getCode();

    machine.S.assign(f_lisp.makeCons(f_lisp.makeCons(code, machine.E.value()),
                                     machine.S.value()));
View Full Code Here


  public void Execute(SECDMachine machine)
  {
    machine.C.pop();                   // Pop the SP_BIND instruction
    LispValue sym = machine.C.pop();   // Pop the symbol name

    machine.special_unbind(sym);
  }
View Full Code Here

TOP

Related Classes of org.jatha.dynatype.LispValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.