FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Bugs
   Bug Fixes, Implemented Suggestions
(Moderator: fry)
   neophite: Register 4 contains wrong type
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: neophite: Register 4 contains wrong type  (Read 318 times)
pollux

WWW Email
neophite: Register 4 contains wrong type
« on: Mar 18th, 2003, 11:09pm »

ok, i'm getting, now and then, this message:
 
java.lang.VerifyError (class: [stuff], method: <init> signature: [morestuff] Register 4 contains wrong type. i guess it is a variable that gets the wrong type of data, but am not sure.
 
it is always Register 4.
 
can somebody explain to me what's wrong?
 
(let me know if [stuff] and [morestuff] are useful)
« Last Edit: Mar 20th, 2003, 8:08am by pollux »  

pollux | www.frwrd.net
pollux

WWW Email
Re: neophite: Register 4 contains wrong type
« Reply #1 on: Mar 18th, 2003, 11:15pm »

i include the code:
 
// flies around
// by pollux < www.00forward.com >
 
// ported from project <swarm>
// http://www.uncontrol.com/box_01.html
 
boolean init = false;
 
int w, h;
int NUM = 500;
int flyNum = 1;
Fly[] fly = new Fly[NUM];
 
void setup() {
  size(200, 200);
  w = width;
  h = height;
  background(255);
  noStroke();
  
  for(int i=0; i<NUM; i++) {
    newFly(i);
  }
  init = true;
}
 
void loop() {
  for (int i=0; i<flyNum; i++) {
    fly[i].flight();
    fly[i].display();
  }
  
}
 
void newFly(int num) {
  float sz = 3f;
  fly[num] = new Fly(random(w), random(h), sz);
}
 
// class Fly | flies that fly around, a fly that flies around
class Fly {
  float _x, _y;
  float fsize;
  int r, g, b;
  boolean initme = false;
  boolean play2 = true;
  
  float recursion = float(random(30)+30);
  
  float ba_percentage = 0.003;
  float be_percentage = 0.9;
  float a_x;
  float a_y;
  float b_x;
  float b_y;
  float c_x;
  float c_y;
  float d_x;
  float d_y;
  float e_x;
  float e_y;
  float f_x;
  float f_y;
  int x = 1;
  
  Fly(float x, float y, float s) {
    _x = x;
    _y = y;
    fsize = s;
    r = int(random(200, 255));
    g = int(random(200, 255));
    b = int(random(200, 255));
    // init vars
    a_x = float(160+random(80));
    a_y = float(160+random(80));
    c_x = float((a_x)+20);
    c_y = a_y;
    f_x = 0f;
    f_y = 0f;
  }
  
  void flight() {
  
    // frame 1 | init vars
 
    // frame 2
    if (play2) {
      a_x = float((random(200))+(width/2)-100);
      a_y = float((random(200))+(height/2)-100);
      b_x = this._x;
      b_y = this._y;
      c_x = f_x;
      c_y = f_y;
    }
    
    // frame 3
    d_x = (((a_x-b_x)*ba_percentage))+(b_x);
    d_y = (((a_y-b_y)*ba_percentage))+(b_y);
    e_x = b_x-(b_x-c_x)-(b_x-d_x);
    e_y = b_y-(b_y-c_y)-(b_y-d_y);
    f_x = e_x-((b_x-e_x)*be_percentage);
    f_y = e_y-((b_y-e_y)*be_percentage);
    x += 1;
    
    // decelerate to new point
    float x_plus = (b_x - this._x)*.25;
    this._x += x_plus;
    float y_plus = (b_y - this._y)*.25;
    this._y += y_plus;
    println("x="+_x+" y="+_y);
    
    // frame 4
    b_x = e_x;
    b_y = e_y;
    c_x = f_x;
    c_y = f_y;
    if (x>recursion) {
      play2 = true;
    } else {
      play2 = false;
    }
  }
  
  void display() {
    float ms = this.fsize/2;
    fill(r, g, b);
    rect(this._x-ms, this._y-ms, fsize, fsize);
  }
  
} // end Fly class
« Last Edit: Mar 18th, 2003, 11:15pm by pollux »  

pollux | www.frwrd.net
Martin

122417302122417302martingomez_listsmg1ph WWW Email
Re: neophite: Register 4 contains wrong type
« Reply #2 on: Mar 23rd, 2003, 11:14pm »

I'm not sure but I think it's a P5 thing. Tried to change a few things (such as adding the trailing 'f' at the end of float values) and compile it using the Java compiler. It compiles runs but doesn't show anything (except for a seemingly infinite loop of printlines).
« Last Edit: Mar 23rd, 2003, 11:15pm by Martin »  
benelek

35160983516098 WWW Email
Re: neophite: Register 4 contains wrong type
« Reply #3 on: Mar 24th, 2003, 8:53am »

i thought u weren't allowed to put p5-specific stuff in the constructor of a class... i remember having problems a few times with putting random() inside a constructor in different programs.
 
on Mar 18th, 2003, 11:15pm, pollux wrote:
// class Fly | flies that fly around, a fly that flies around
class Fly {
  float _x, _y;
  float fsize;
  int r, g, b;
  boolean initme = false;
  boolean play2 = true;
  float recursion = float(random(30)+30);
  float ba_percentage = 0.003;
  float be_percentage = 0.9;
  float a_x;
  float a_y;
  float b_x;
  float b_y;
  float c_x;
  float c_y;
  float d_x;
  float d_y;
  float e_x;
  float e_y;
  float f_x;
  float f_y;
  int x = 1;
  
  Fly(float x, float y, float s) {
    _x = x;
    _y = y;
    fsize = s;
    r = int(random(200, 255));
    g = int(random(200, 255));
    b = int(random(200, 255));
    // init vars
    a_x = float(160+random(80));
    a_y = float(160+random(80));
    c_x = float((a_x)+20);
    c_y = a_y;
    f_x = 0f;
    f_y = 0f;
  }

 
 
you should be able to get around it by doing something like...
 
Code:

Fly moo = new Fly(x,y,s,random(bla),random(bla),random(blablabla),random(etc));

 
and then just assigning the floats generated to varibles as needed in ur constructor. this goes for the pre-constructor declarations too (like the "float recursions" part). let me know if it works...
 
fry


WWW
Re: neophite: Register 4 contains wrong type
« Reply #4 on: Mar 24th, 2003, 3:52pm »

sounds like another bug in the kjc compiler. we're hoping to swap it out with a different compiler soon.
 
(moving this to the bugs section...)
 
pollux

WWW Email
Re: neophite: Register 4 contains wrong type
« Reply #5 on: Mar 24th, 2003, 9:27pm »

thanxs everybody, now i just have to figure everything else out!
 
glad i could help, glad you helped me.
 
btw, what does "Register 4 contains wrong type" means? should i assume that it means the constructor has found something that shouldn't be there?
 

pollux | www.frwrd.net
fry


WWW
Re: neophite: Register 4 contains wrong type
« Reply #6 on: Mar 25th, 2003, 2:25pm »

on Mar 24th, 2003, 9:27pm, pollux wrote:
btw, what does "Register 4 contains wrong type" means should i assume that it means the constructor has found something that shouldn't be there

it's an error in the java virtual machine, which acts a bit like a faux microprocessor. a register is a location (like a slot) for "fast" temporary memory used to store variables used inside loops, or those used only inside functions.
 
the same registers are used to store many different kinds of data--int, String, BImage, float, etc (or at least references to them). so the compiler's bug was something like a register was being used for a String, but then later it tried to use the register to store an int, before it was done using it for the String.  
 
thus "contains wrong type" because an unexpected flavor of data (i.e. a String instead of an int) was found.
 
Pages: 1 

« Previous topic | Next topic »