function compile_node($options)
 {
     $decl = $this->determine_name();
     if ($decl) {
         $name = $decl;
     } else {
         if (isset($this->name) && $this->name) {
             $name = $this->name;
         } else {
             $name = '_Class';
         }
     }
     $lname = yy('Literal', $name);
     $this->set_context($name);
     $this->walk_body($name, $options);
     $this->ensure_constructor($name);
     if ($this->parent) {
         array_unshift($this->body->expressions, yy('Extends', $lname, $this->parent));
     }
     if (!$this->ctor instanceof yy_Code) {
         array_unshift($this->body->expressions, $this->ctor);
     }
     $this->body->expressions[] = $lname;
     $this->add_bound_functions($options);
     $klass = yy('Parens', yy_Closure::wrap($this->body), TRUE);
     if ($this->variable) {
         $klass = yy('Assign', $this->variable, $klass);
     }
     return $klass->compile($options);
 }
Example #2
0
 function compile_closure($options)
 {
     if ($this->jumps()) {
         throw new SyntaxError('cannot use a pure statement in an expression.');
     }
     $options['sharedScope'] = TRUE;
     $closure = yy_Closure::wrap($this);
     return $closure->compile_node($options);
 }
Example #3
0
 function compile_node($options)
 {
     $decl = $this->determine_name();
     $name = $decl ? $decl : '_Class';
     if (isset($name->reserved) && $name->reserved) {
         $name = '_' . $name;
     }
     $lname = yy('Literal', $name);
     $this->hoist_directive_prologue();
     $this->set_context($name);
     $this->walk_body($name, $options);
     $this->ensure_constructor($name);
     $this->body->spaced = TRUE;
     if (!$this->ctor instanceof yy_Code) {
         array_unshift($this->body->expressions, $this->ctor);
     }
     $this->body->expressions[] = $lname;
     $this->body->expressions = array_merge($this->directives, $this->body->expressions);
     $this->add_bound_functions($options);
     $call = yy_Closure::wrap($this->body);
     if ($this->parent) {
         $this->super_class = yy('Literal', $options['scope']->free_variable('super', FALSE));
         array_unshift($this->body->expressions, yy('Extends', $lname, $this->super_class));
         $call->args[] = $this->parent;
         if (isset($call->variable->params)) {
             $params =& $call->variable->params;
         } else {
             $params =& $call->variable->base->params;
         }
         $params[] = yy('Param', $this->super_class);
     }
     $klass = yy('Parens', $call, TRUE);
     if ($this->variable) {
         $klass = yy('Assign', $this->variable, $klass);
     }
     return $klass->compile($options);
 }