Package ioke.lang

Examples of ioke.lang.Runtime



    public IkLanguage(LanguageMixin languageMixin, ExceptionFactory exceptionFactory) throws Exception, ControlFlow {
        super(languageMixin, exceptionFactory);

        ioke = new Runtime();
        ioke.init();
        ioke.ground.setCell("CucumberLanguage", this);
        ioke.evaluateString("use(\"cuke4duke/internal/ik/ik_dsl\")");
        clearHooksAndStepDefinitions();
View Full Code Here


        Readline.init(rl);
        return rl;
    }

    public static void init(final IokeObject rl) throws ControlFlow {
        Runtime runtime = rl.runtime;
        rl.setKind("Readline");
        rl.singleMimicsWithoutCheck(runtime.origin);
        runtime.ground.setCell("Readline", rl);
        rl.setCell("VERSION", runtime.newText("JLine wrapper"));

        final ConsoleHolder holder = new ConsoleHolder();
        holder.history = new History();
        holder.currentCompletor = null;

        IokeObject history = runtime.newFromOrigin();
        rl.setCell("HISTORY", history);

        rl.registerMethod(runtime.newNativeMethod("will print a prompt to standard out and then try to read a line with working readline functionality. takes two arguments, the first is the string to prompt, the second is a boolean that says whether we should add the read string to history or not", new NativeMethod("readline") {
                private final DefaultArgumentsDefinition ARGUMENTS = DefaultArgumentsDefinition
                    .builder()
                    .withRequiredPositional("prompt")
                    .withRequiredPositional("addToHistory?")
                    .getArguments();

                @Override
                public DefaultArgumentsDefinition getArguments() {
                    return ARGUMENTS;
                }

                @Override
                public Object activate(IokeObject method, IokeObject context, IokeObject message, Object on) throws ControlFlow {
                    List<Object> args = new ArrayList<Object>();
                    getArguments().getEvaluatedArguments(context, message, on, args, new HashMap<String, Object>());

                    Object line = method.runtime.nil;
                    try {
                        if(holder.readline == null) {
                            initReadline(method.runtime, holder);
                        }
                        holder.readline.getTerminal().disableEcho();
                        String v = holder.readline.readLine(Text.getText(args.get(0)));
                        holder.readline.getTerminal().enableEcho();
                        if(null != v) {
                            if(IokeObject.isTrue(args.get(1))) {
                                holder.readline.getHistory().addToHistory(v);
                            }

                            line = method.runtime.newText(v);
                        }
                    } catch(IOException e) {
                        final Runtime runtime = context.runtime;
                        final IokeObject condition = IokeObject.as(IokeObject.getCellChain(runtime.condition,
                                                                                           message,
                                                                                           context,
                                                                                           "Error",
                                                                                           "IO"), context).mimic(message, context);
                        condition.setCell("message", message);
                        condition.setCell("context", context);
                        condition.setCell("receiver", on);
                        condition.setCell("exceptionMessage", runtime.newText(e.getMessage()));
                        List<Object> ob = new ArrayList<Object>();
                        for(StackTraceElement ste : e.getStackTrace()) {
                            ob.add(runtime.newText(ste.toString()));
                        }

                        condition.setCell("exceptionStackTrace", runtime.newList(ob));

                        runtime.withReturningRestart("ignore", context, new RunnableWithControlFlow() {
                                public void run() throws ControlFlow {
                                    runtime.errorCondition(condition);
                                }});
                    }
                    return line;
                }
            }));

        history.registerMethod(runtime.newNativeMethod("will add a new line to the history", new NativeMethod("<<") {
                private final DefaultArgumentsDefinition ARGUMENTS = DefaultArgumentsDefinition
                    .builder()
                    .withRequiredPositional("line")
                    .getArguments();
View Full Code Here

*
* @author <a href="mailto:ola.bini@gmail.com">Ola Bini</a>
*/
public class Enumerable {
    public static void init(IokeObject enumerable) {
        Runtime runtime = enumerable.runtime;
        enumerable.setKind("Mixins Enumerable");
    }
View Full Code Here

*
* @author <a href="mailto:ola.bini@gmail.com">Ola Bini</a>
*/
public class Comparing {
    public static void init(IokeObject comparing) {
        Runtime runtime = comparing.runtime;
        comparing.setKind("Mixins Comparing");
    }
View Full Code Here

*
* @author <a href="mailto:ola.bini@gmail.com">Ola Bini</a>
*/
public class Sequenced {
    public static void init(IokeObject obj) {
        Runtime runtime = obj.runtime;
        obj.setKind("Mixins Sequenced");
    }
View Full Code Here

* @author <a href="mailto:ola.bini@gmail.com">Ola Bini</a>
*/
public class JavaInvocationHelper {
    public static boolean hasProxyMethod(IokeJavaIntegrated object, String name) {
        IokeObject pr = object.__get_IokeProxy();
        Runtime runtime = object.__get_IokeRuntime();

        Object cell = IokeObject.findCell(pr, name);
        if(cell != null && cell != runtime.nul && cell instanceof IokeObject) {
            return !(IokeObject.data(cell) instanceof NativeImplementedMethod);
        }
View Full Code Here

        return false;
    }

    public static void voidInvocation(IokeJavaIntegrated object, Object[] args, String name) {
        IokeObject pr = object.__get_IokeProxy();
        Runtime runtime = object.__get_IokeRuntime();
        Message newMessage = new Message(runtime, name);
        for(Object arg : args) {
            newMessage.getArguments(null).add(runtime.createMessage(Message.wrap(arg, runtime)));
        }

        try {
            IokeObject msg = runtime.createMessage(newMessage);
            Interpreter.send(msg, runtime.ground, pr);
        } catch(Throwable e) {
        }
    }
View Full Code Here

        }
    }

    public static byte byteInvocation(IokeJavaIntegrated object, Object[] args, String name) {
        IokeObject pr = object.__get_IokeProxy();
        Runtime runtime = object.__get_IokeRuntime();
        Message newMessage = new Message(runtime, name);
        for(Object arg : args) {
            newMessage.getArguments(null).add(runtime.createMessage(Message.wrap(arg, runtime)));
        }

        try {
            IokeObject msg = runtime.createMessage(newMessage);

            Object result = Interpreter.send(msg, runtime.ground, pr);
            if(result instanceof Byte) {
                return Byte.valueOf((Byte)result);
            } else if(result instanceof IokeObject && IokeObject.data(result) instanceof JavaWrapper && JavaWrapper.getObject(result) instanceof Byte) {
View Full Code Here

        return 0;
    }

    public static int intInvocation(IokeJavaIntegrated object, Object[] args, String name) {
        IokeObject pr = object.__get_IokeProxy();
        Runtime runtime = object.__get_IokeRuntime();
        Message newMessage = new Message(runtime, name);
        for(Object arg : args) {
            newMessage.getArguments(null).add(runtime.createMessage(Message.wrap(arg, runtime)));
        }

        try {
            IokeObject msg = runtime.createMessage(newMessage);
            Object result = Interpreter.send(msg, runtime.ground, pr);
            if(result instanceof Integer) {
                return Integer.valueOf((Integer)result);
            } else if(result instanceof IokeObject && IokeObject.data(result) instanceof JavaWrapper && JavaWrapper.getObject(result) instanceof Integer) {
                return Integer.valueOf((Integer)JavaWrapper.getObject(result));
View Full Code Here

        return 0;
    }

    public static short shortInvocation(IokeJavaIntegrated object, Object[] args, String name) {
        IokeObject pr = object.__get_IokeProxy();
        Runtime runtime = object.__get_IokeRuntime();
        Message newMessage = new Message(runtime, name);
        for(Object arg : args) {
            newMessage.getArguments(null).add(runtime.createMessage(Message.wrap(arg, runtime)));
        }

        try {
            IokeObject msg = runtime.createMessage(newMessage);
            Object result = Interpreter.send(msg, runtime.ground, pr);
            if(result instanceof Short) {
                return Short.valueOf((Short)result);
            } else if(result instanceof IokeObject && IokeObject.data(result) instanceof JavaWrapper && JavaWrapper.getObject(result) instanceof Short) {
                return Short.valueOf((Short)JavaWrapper.getObject(result));
View Full Code Here

TOP

Related Classes of ioke.lang.Runtime

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.