Package erjang

Examples of erjang.ESmall


          pop(dst, EBITSTRING_TYPE);
          return;
        }
        // {test,bs_get_integer2,{f,348},[{x,3},4,{integer,32},1,{field_flags,0},{x,4}]}
        case bs_get_integer2: {
          ESmall small;
          int int_bits;
          if (bits.kind == Kind.IMMEDIATE
              && bits.value != null
              && (small=bits.value.testSmall()) != null
              && (int_bits = (small.value * unit)) <= 32
View Full Code Here


      }

      private void push_scaled(Arg value, int factor) {
        if (value.kind == Kind.IMMEDIATE
            && value.value instanceof ESmall) {
          ESmall sm = (ESmall) value.value;
          mv.visitLdcInsn(new Integer(factor * sm.intValue()));
        } else {
          push(value, Type.INT_TYPE);
          push_int(factor);
          mv.visitInsn(IMUL);
        }
View Full Code Here

    @Override
    public CodeInt asCodeInt() {return this;}

    public EObject toSymbolic() {
      return new ESmall(value);
    }
View Full Code Here

   
    @Override
    public Int testInt() {return this;}

    @Override
    public EObject literalValue() {return new ESmall(value);}
View Full Code Here

    @Override
    public EObject literalValue() {return new ESmall(value);}

    public EObject toSymbolic() {
      return ETuple.make(INTEGER_ATOM, new ESmall(value));
    }
View Full Code Here

  @BIF
  public static EObject halt(EProc proc, EObject value) {
    int exitCode = 1;
    String message = null;
    if (value != null) {
      ESmall val = value.testSmall();
      if (val != null) {
        exitCode = val.value;
      }
     
      EString str = value.testString();
View Full Code Here

      return ERT.box(ERT.asyncThreadPoolSize());
    } else if (type == am_break_ignored) {
      return ERT.box(false);
    } else if (type == am_compat_rel) {
        // we return same value as R14
        return new ESmall(14);
    }
   
    ETuple2 tup;
    if (type == am_allocated_areas) {

      ECons res = ERT.NIL;

      List<MemoryPoolMXBean> bean2 = ManagementFactory
          .getMemoryPoolMXBeans();

      if (bean2 == null) {

        MemoryMXBean bean = ManagementFactory.getMemoryMXBean();
        if (bean != null) {

          MemoryUsage mu = bean.getHeapMemoryUsage();
          res = res.cons(ETuple.make(am_heap, ERT.box(mu.getCommitted()),
              ERT.box(mu.getUsed())));

          mu = bean.getNonHeapMemoryUsage();
          res = res.cons(ETuple.make(am_non_heap, ERT.box(mu
              .getCommitted()), ERT.box(mu.getUsed())));

        }
       
        return res;
      }
     
      for (MemoryPoolMXBean mb : bean2) {
       
        String name = mb.getName();
        MemoryUsage mu = mb.getUsage();
        if (mu == null) continue;
       
        String name2 = (mb.getType()==MemoryType.HEAP ? "heap:" : "non_heap:" ) + name;
       
        res = res.cons(ETuple.make(EAtom.intern(name2), ERT.box(mu
            .getCommitted()), ERT.box(mu.getUsed())));

       
      }
     
      return res;

    } else if (type == am_allocator) {
      return am_jvm;     
     
    } else if (type == am_heap_type) {
      return am_shared;
     
    } else if (type == am_smp_support) {
      return ERT.TRUE;
     
    } else if (type == am_thread_pool_size) {
      // TODO: hook up to thread pool
      return new ESmall(ERT.threadPoolSize());
     
    } else if (type == am_os_type) {
      String os = System.getProperty("os.name");
      if (os.startsWith("Windows")) {
        return ETuple.make(am_win32, new EString(os));
      } else {
        return ETuple.make(am_unix, new EString(os));
      }

    } else if (type == am_threads) {
      return ERT.TRUE;
     
    } else if (type == am_version) {
      String erts_version = ERT.runtime_info.erts_version;
      // remove prefix
      String prefix = "erts-";
      if (erts_version.startsWith(prefix)) {
        erts_version = erts_version.substring(prefix.length());
      }
      return EString.fromString(erts_version);
     
    } else if (type == am_otp_release) {
      return new EString(ERT.runtime_info.otp_version);
    } else if (type == am_logical_processors) {
      // TODO: be smarter somehow
      return ERT.box(Runtime.getRuntime().availableProcessors());
     
    } else if (type == am_global_heaps_size) {
      return ERT.box(Runtime.getRuntime().totalMemory());
     
    } else if (type == am_process_count) {
      return ERT.box(EProc.process_count());
     
    } else if (type == am_system_architecture) {
      return new EString(Main.SYSTEM_ARCHITECTURE);
     
    } else if (type == am_driver_version) {
      // TODO: be smarter somehow
      return new EString(Main.DRIVER_VERSION);
     
    } else if (type == am_wordsize) {
      return new ESmall(4);
      
    } else if (type == am_debug_compiled || type == am_lock_checking) {
       throw ERT.badarg(type);
      
    } else if (type == am_hipe_architecture) {
View Full Code Here

    int arity = a.length();
   
    EFun target = EModuleManager.resolve(new FunID(m,f,arity));
   
    if (target == null) {
      throw new ErlangUndefined(m, f, new ESmall(arity));
    }
   
    self.tail = target;
    a = a.reverse();
    switch (arity) {
View Full Code Here

  @BIF
  public static EObject function_exported(EObject a1, EObject a2, EObject a3) {
      EAtom mod = a1.testAtom();
      EAtom fun = a2.testAtom();
      ESmall ary = a3.testSmall();

      return ERT.box(EModuleManager.function_exported(mod,fun,ary.value));
  }
View Full Code Here

  @BIF
  public static EFun make_fun(EObject m, EObject f, EObject a)
  {
    EAtom mod = m.testAtom();
    EAtom fun = f.testAtom();
    ESmall arity = a.testSmall();
    if (mod==null||fun==null||arity==null) {
      throw ERT.badarg(m,f,a);
    }
   
    return EModuleManager.resolve(new FunID(mod, fun, arity.value));
View Full Code Here

TOP

Related Classes of erjang.ESmall

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.