Sha256: 75ba50628e0e39038e32b21230e0f0392a96dc54983189cfc59d7c35b8d6d33e

Contents?: true

Size: 603 Bytes

Versions: 3

Compression:

Stored size: 603 Bytes

Contents

use :node;

var Node = module.require('../Node').Node;

fn UntilStatement(test, body)
  extends Node {
  
  this.type = 'UntilStatement';
  
  this.test = test;
  this.test.parent = this;
  
  this.body = body;
  this.body.parent = this;
}

UntilStatement.prototype.codegen = () -> {
  if !super.codegen() {
    return;
  }
  
  this.type = 'WhileStatement';
  
  this.test = {
    "type": "UnaryExpression",
    "operator": "!",
    "argument": this.test.codegen(),
    "prefix": true
  };
  
  this.body = this.body.blockWrap().codegen();
  
  return this;
};

exports.UntilStatement = UntilStatement;

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spider-src-0.1.7 lib/spider-src/support/spider/src/ast/statements/UntilStatement.spider
spider-src-0.1.6 lib/spider-src/support/spider/src/ast/statements/UntilStatement.spider
spider-src-0.1.5 lib/spider-src/support/spider/src/ast/statements/UntilStatement.spider