Source

ocamlspot / tests / object.ml

class (* c0 => *) c0 (* <= c0 *) = object
  val a = 1
  method m = a
end 


class (* c => *) c (* <= c *) ((* p => *) p (* <= p *) : int) = 
  let (* x => *) x (* <= x *) = 1 in
  let p' = p (* ? p *) in
  object (* self => *)(self)(* <= self *)
    inherit (* a => *) c0 (* <= a *)

    val mutable (* y => *) y (* <= y *) = x
    val z = x (* ? x *)
    val p'' = p (* ? p *)
    method f () = x (* ? x *)
    method g () = y (* ? y *)
    method h () = self(* ? self *)#g ()
    method i () = a (* ? a *) (* We cannot follow into c0... *)
    method get_p = p (* ? p *)
    method get_p' = p'
    initializer
      y <- 42
  end


let _ = 
  let (* o => *) o (* <= o *) : c (* ? c *) = new c (* ? c *) 42 in
  o(*? o *)#f ()

let o = 
  let (* yy => *) yy (* <= yy *) = 2 in
object 
  val (* xx => *) xx (* <= xx *) = 1 
  method get_xx = xx (* ? xx *) 
  method get_yy = yy (* ? yy *)
end
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.