Package bm.vm

Examples of bm.vm.Instance


    }

    private Instance sendRow( final Row row, final Instance table )
            throws VirtualMachineException
    {
        final Instance r = getVirtualMachine().newInstance( "Row" );
        r.setAttachment( "row", row );
        r.setAttachment( "table", table );
        return r;
    }
View Full Code Here


    }

    private Instance sendRow( final Row row, final Instance target )
            throws VirtualMachineException
    {
        final Instance r = getVirtualMachine().newInstance( "Row" );
        r.setAttachment( "row", row );
        r.setAttachment( "table", target );
        return r;
    }
View Full Code Here

    }

    private Instance sendRowSet( final RowSet rowSet, final Instance target )
            throws VirtualMachineException
    {
        final Instance r = getVirtualMachine().newInstance( "RowSet" );
        r.setAttachment( "rowset", rowSet );
        r.setAttachment( "table", target );
        return r;
    }
View Full Code Here

    }

    public static Instance toInstance( final VirtualMachine vm, final Object o )
            throws VirtualMachineException
    {
        Instance instance;
        if( o == null )
        {
            return null;
        }
        else if( o instanceof Instance )
        {
            return (Instance) o;
        }
        else if( o instanceof String )
        {
            instance = vm.newInstance( "String" );
        }
        else if( o instanceof Integer )
        {
            instance = vm.newInstance( "int" );
        }
        else if( o instanceof Long )
        {
            instance = vm.newInstance( "long" );
        }
        else if( o instanceof Short )
        {
            instance = vm.newInstance( "short" );
        }
        else if( o instanceof Byte )
        {
            instance = vm.newInstance( "byte" );
        }
        else if( o instanceof Boolean )
        {
            instance = vm.newInstance( "boolean" );
        }
        else
        {
            throw new VirtualMachineException(
                    0,
                    "Type not supported: " + o.getClass()
            );
        }
        instance.set( "value", o );
        return instance;
    }
View Full Code Here

    {
        Hashtable m = (Hashtable) map.getAttachment( "map" );
        int max = -1;
        for( Enumeration i = m.keys(); i.hasMoreElements(); )
        {
            final Instance key = (Instance) i.nextElement();
            final Integer value = toInteger( key, -1 );
            if( value.intValue() > max )
            {
                max = value.intValue();
            }
        }
        if( max > -1 )
        {
            final String[] retVal = new String[max + 1];
            for( Enumeration i = m.keys(); i.hasMoreElements(); )
            {
                final Instance key = (Instance) i.nextElement();
                final Integer value = toInteger( key, -1 );
                if( value.intValue() > -1 )
                {
                    retVal[ value.intValue() ] = m.get( key ).toString();
                }
View Full Code Here

        else
        {
            final Context context = getContext();
            operand1.setContext( context );
            operand2.setContext( context );
            Instance value1 = operand1.run();
            Instance value2 = operand2.run();

            final Object o1 = value1.get( "value" );
            final Object o2 = value2.get( "value" );
            if( ( o1 instanceof String) || ( o2 instanceof String) )
            {
                final Instance instance =
                        getVirtualMachine().newInstance( "String" );
                instance.set( "value", o1.toString() + o2.toString() );
                return instance;
            }
            else
            {
                return super.run();
View Full Code Here

    protected Instance doMath( final Object val1, final Object val2 )
            throws VirtualMachineException
    {
        if( val1 instanceof FixedPoint )
        {
            final Instance instance =
                    getVirtualMachine().newInstance( "double" );
            instance.set(
                    "value",
                    ((FixedPoint) val1).add( (FixedPoint) val2 )
            );
            return instance;
        }
        else if( val1 instanceof Long )
        {
            final Instance instance =
                    getVirtualMachine().newInstance( "long" );
            instance.set(
                    "value",
                    new Long(
                            ((Long) val1).longValue() +
                            ( (Long) val2 ).longValue()
                    )
            );
            return instance;
        }
        else if( val1 instanceof Integer )
        {
            final Instance instance =
                    getVirtualMachine().newInstance( "int" );
            instance.set(
                    "value",
                    new Integer(
                            ((Integer) val1).intValue() +
                            ( (Integer) val2 ).intValue()
                    )
            );
            return instance;
        }
        else if( val1 instanceof Short )
        {
            final Instance instance =
                    getVirtualMachine().newInstance( "short" );
            instance.set(
                    "value",
                    new Short( (short)
                            (((Short) val1).shortValue() +
                             ( (Short) val2 ).shortValue() )
                    )
            );
            return instance;
        }
        else
        {
            final Instance instance =
                    getVirtualMachine().newInstance( "byte" );
            instance.set(
                    "value",
                    new Byte( (byte)
                            (((Byte) val1).byteValue() +
                             ( (Byte) val2 ).byteValue() )
                    )
View Full Code Here

            throws VirtualMachineException
    {
        final Context context = getContext();
        condition.setContext( context );
        body.setContext( context );
        Instance retval;
        while( Conversor.toBoolean( condition.run() ) )
        {
            retval = body.run();
            if( body.isTerminated() )
            {
View Full Code Here

            {
                value = Conversor.toBoolean( operand2.run() ) ?
                        CoreConstants.TRUE :
                        CoreConstants.FALSE;
            }
            Instance instance = null;
            try
            {
                instance = getVirtualMachine().newInstance( "boolean" );
                instance.set( "value", value );
            }
            catch( ScriptingClassNotFoundException e )
            {
            }
            return instance;
View Full Code Here

        {
            operand1.setContext( getContext() );
            Boolean value = Conversor.toBoolean( operand1.run() ) ?
                                CoreConstants.FALSE :
                                CoreConstants.TRUE;
            Instance instance = null;
            try
            {
                instance = getVirtualMachine().newInstance( "boolean" );
                instance.set( "value", value );
            }
            catch( ScriptingClassNotFoundException e )
            {
            }
            return instance;
View Full Code Here

TOP

Related Classes of bm.vm.Instance

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.