src/compiler/HIR.cpp
author David Anderson <dvander@alliedmods.net>
Sun Jan 06 13:52:21 2013 -0800 (2013-01-06)
changeset 256 3c184218462d
parent 247 7721042bdb67
child 263 ba85a47ee414
permissions -rw-r--r--
Initial implementation of module imports.
[email protected]
     1
/* vim: set ts=4 sw=4 tw=99 et:
[email protected]
     2
 *
[email protected]
     3
 * Copyright (C) 2012 David Anderson
[email protected]
     4
 *
[email protected]
     5
 * This file is part of JITCraft.
[email protected]
     6
 *
[email protected]
     7
 * JITCraft is free software: you can redistribute it and/or modify it under
[email protected]
     8
 * the terms of the GNU General Public License as published by the Free
[email protected]
     9
 * Software Foundation, either version 3 of the License, or (at your option)
[email protected]
    10
 * any later version.
[email protected]
    11
 * 
[email protected]
    12
 * Foobar is distributed in the hope that it will be useful, but WITHOUT ANY
[email protected]
    13
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
[email protected]
    14
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
[email protected]
    15
 *
[email protected]
    16
 * You should have received a copy of the GNU General Public License along with
[email protected]
    17
 * JITCraft. If not, see http://www.gnu.org/licenses/.
[email protected]
    18
 */
[email protected]
    19
#include "AST.h"
[email protected]
    20
#include "HIR.h"
[email protected]
    21
#include "BytecodeEmitter.h"
[email protected]
    22
#include "../Strings.h"
[email protected]
    23
#include "../Heap-inl.h"
[email protected]
    24
#include "../Handles-inl.h"
[email protected]
    25
[email protected]
    26
using namespace ke;
[email protected]
    27
[email protected]
    28
class HIRTranslator : public HIRVisitor
[email protected]
    29
{
[email protected]
    30
  public:
[email protected]
    31
    HIRTranslator(Zone *zone, BytecodeEmitter &emitter)
[email protected]
    32
      : zone_(zone),
[email protected]
    33
        emitter_(emitter)
[email protected]
    34
    {
[email protected]
    35
    }
[email protected]
    36
[email protected]
    37
    void translate(HIR *hir) {
[email protected]
    38
        hir->accept(this);
[email protected]
    39
    }
[email protected]
    40
[email protected]
    41
    void visitBoolean(HBoolean *hir);
[email protected]
    42
    void visitFloat(HFloat *hir);
[email protected]
    43
    void visitInteger(HInteger *hir);
[email protected]
    44
    void visitArray(HArray *hir);
[email protected]
    45
    void visitCall(HCall *call);
[email protected]
    46
    void visitStore(HStore *store);
[email protected]
    47
    void visitUnary(HUnary *unary);
[email protected]
    48
    void visitBinary(HBinary *binary);
[email protected]
    49
    void visitLocal(HLocal *local);
[email protected]
    50
    void visitGlobal(HGlobal *global);
[email protected]
    51
    void visitConvert(HConvert *convert);
[email protected]
    52
    void visitIndex(HIndex *index);
[email protected]
    53
    void visitField(HField *field);
[email protected]
    54
    void visitPostIncDec(HPostIncDec *hir);
[email protected]
    55
    void visitToRef(HToRef *hir);
[email protected]
    56
    void visitNewDependentArray(HNewDependentArray *hir);
[email protected]
    57
    void visitImport(HImport *import);
[email protected]
    58
[email protected]
    59
  private:
[email protected]
    60
    Zone *zone_;
[email protected]
    61
    BytecodeEmitter &emitter_;
[email protected]
    62
};
[email protected]
    63
[email protected]
    64
#define __ emitter_.
[email protected]
    65
[email protected]
    66
void
[email protected]
    67
HIRTranslator::visitBoolean(HBoolean *hir)
[email protected]
    68
{
[email protected]
    69
    if (hir->value())
[email protected]
    70
        __ true_();
[email protected]
    71
    else
[email protected]
    72
        __ false_();
[email protected]
    73
}
[email protected]
    74
[email protected]
    75
void
[email protected]
    76
HIRTranslator::visitFloat(HFloat *hir)
[email protected]
    77
{
[email protected]
    78
    __ float_(hir->value());
[email protected]
    79
}
[email protected]
    80
[email protected]
    81
void
[email protected]
    82
HIRTranslator::visitInteger(HInteger *hir)
[email protected]
    83
{
[email protected]
    84
    __ int_(hir->value());
[email protected]
    85
}
[email protected]
    86
[email protected]
    87
void
[email protected]
    88
HIRTranslator::visitArray(HArray *hir)
[email protected]
    89
{
[email protected]
    90
    __ object(hir->array());
[email protected]
    91
[email protected]
    92
    if (hir->duplicate())
[email protected]
    93
        __ duparray(); 
[email protected]
    94
}
[email protected]
    95
[email protected]
    96
void
[email protected]
    97
HIRTranslator::visitCall(HCall *call)
[email protected]
    98
{
[email protected]
    99
    Local<FunctionType> fun(zone_, FunctionType::cast(call->callee()->type()));
[email protected]
   100
    
[email protected]
   101
    assert(call->args()->length() == fun->parameters()->length());
[email protected]
   102
[email protected]
   103
    __ note_position(call->node()->pos());
[email protected]
   104
[email protected]
   105
    unsigned argc = call->args()->length();
[email protected]
   106
    for (size_t i = call->args()->length() - 1; i < call->args()->length(); i--) {
[email protected]
   107
        HIR *hir = call->args()->at(i);
[email protected]
   108
        hir->accept(this);
[email protected]
   109
    }
[email protected]
   110
[email protected]
   111
    call->callee()->accept(this);
[email protected]
   112
    __ call(fun, argc);
[email protected]
   113
}
[email protected]
   114
[email protected]
   115
void
[email protected]
   116
HGlobal::bind(HIRVisitor *visitor, BytecodeEmitter &emitter_)
[email protected]
   117
{
[email protected]
   118
}
[email protected]
   119
[email protected]
   120
void
[email protected]
   121
HGlobal::hold(BytecodeEmitter &emitter_)
[email protected]
   122
{
[email protected]
   123
}
[email protected]
   124
[email protected]
   125
void
[email protected]
   126
HGlobal::swapAndPick(BytecodeEmitter &emitter_)
[email protected]
   127
{
[email protected]
   128
    __ dup();
[email protected]
   129
}
[email protected]
   130
[email protected]
   131
void
[email protected]
   132
HGlobal::store(BytecodeEmitter &emitter_)
[email protected]
   133
{
[email protected]
   134
    __ setglobal(sym_);
[email protected]
   135
}
[email protected]
   136
[email protected]
   137
void
[email protected]
   138
HGlobal::load(BytecodeEmitter &emitter_)
[email protected]
   139
{
[email protected]
   140
    __ getglobal(sym_);
[email protected]
   141
}
[email protected]
   142
[email protected]
   143
bool
[email protected]
   144
HGlobal::ref(BytecodeEmitter &emitter_)
[email protected]
   145
{
[email protected]
   146
    return false;
[email protected]
   147
}
[email protected]
   148
[email protected]
   149
static inline Type *
[email protected]
   150
MaybeDereference(Type *type)
[email protected]
   151
{
[email protected]
   152
    if (type->isReference())
[email protected]
   153
        return ReferenceType::cast(type)->contained();
[email protected]
   154
    return type;
[email protected]
   155
}
[email protected]
   156
[email protected]
   157
HLocal::HLocal(AstNode *node, VariableSymbol *sym)
[email protected]
   158
  : HLValue(node, MaybeDereference(sym->type())),
[email protected]
   159
    sym_(sym)
[email protected]
   160
{
[email protected]
   161
}
[email protected]
   162
[email protected]
   163
void
[email protected]
   164
HLocal::bind(HIRVisitor *visitor, BytecodeEmitter &emitter_)
[email protected]
   165
{
[email protected]
   166
    if (sym_->type()->isReference()) {
[email protected]
   167
        if (sym_->storage() == VariableSymbol::Local)
[email protected]
   168
            __ getlocal(sym_);
[email protected]
   169
        else if (sym_->storage() == VariableSymbol::Arg)
[email protected]
   170
            __ getarg(sym_);
[email protected]
   171
        else
[email protected]
   172
            assert(false);
[email protected]
   173
    }
[email protected]
   174
}
[email protected]
   175
[email protected]
   176
void
[email protected]
   177
HLocal::hold(BytecodeEmitter &emitter_)
[email protected]
   178
{
[email protected]
   179
    if (sym_->type()->isReference())
[email protected]
   180
        __ dup();
[email protected]
   181
}
[email protected]
   182
[email protected]
   183
void
[email protected]
   184
HLocal::swapAndPick(BytecodeEmitter &emitter_)
[email protected]
   185
{
[email protected]
   186
    if (sym_->type()->isReference()) {
[email protected]
   187
        __ swap();
[email protected]
   188
        __ pick2();
[email protected]
   189
    } else {
[email protected]
   190
        __ dup();
[email protected]
   191
    }
[email protected]
   192
}
[email protected]
   193
[email protected]
   194
void
[email protected]
   195
HLocal::store(BytecodeEmitter &emitter_)
[email protected]
   196
{
[email protected]
   197
    if (sym_->type()->isReference()) {
[email protected]
   198
        __ setref(ReferenceType::cast(sym_->type())->contained());
[email protected]
   199
    } else {
[email protected]
   200
        if (sym_->storage() == VariableSymbol::Local)
[email protected]
   201
            __ setlocal(sym_);
[email protected]
   202
        else if (sym_->storage() == VariableSymbol::Arg)
[email protected]
   203
            __ setarg(sym_);
[email protected]
   204
        else
[email protected]
   205
            assert(false);
[email protected]
   206
    }
[email protected]
   207
}
[email protected]
   208
[email protected]
   209
void
[email protected]
   210
HLocal::load(BytecodeEmitter &emitter_)
[email protected]
   211
{
[email protected]
   212
    if (sym_->type()->isReference())
[email protected]
   213
        __ getref(ReferenceType::cast(sym_->type())->contained());
[email protected]
   214
    else if (sym_->storage() == VariableSymbol::Local)
[email protected]
   215
        __ getlocal(sym_);
[email protected]
   216
    else if (sym_->storage() == VariableSymbol::Arg)
[email protected]
   217
        __ getarg(sym_);
[email protected]
   218
    else
[email protected]
   219
        assert(false);
[email protected]
   220
}
[email protected]
   221
[email protected]
   222
bool
[email protected]
   223
HLocal::ref(BytecodeEmitter &emitter_)
[email protected]
   224
{
[email protected]
   225
    if (sym_->storage() == VariableSymbol::Heap) {
[email protected]
   226
        // Closing over a reference should never pass SemA.
[email protected]
   227
        assert(!sym_->type()->isReference());
[email protected]
   228
[email protected]
   229
        // We don't support direct references to heap-allocated locals. This
[email protected]
   230
        // should probably be banned in SemA? But for now, just assert. :TODO:
[email protected]
   231
        assert(false);
[email protected]
   232
        return false;
[email protected]
   233
    }
[email protected]
   234
        
[email protected]
   235
    if (sym_->type()->isReference()) {
[email protected]
   236
        if (sym_->storage() == VariableSymbol::Local)
[email protected]
   237
            __ getlocal(sym_);
[email protected]
   238
        else if (sym_->storage() == VariableSymbol::Arg)
[email protected]
   239
            __ getarg(sym_);
[email protected]
   240
        else
[email protected]
   241
            assert(false);
[email protected]
   242
    } else {
[email protected]
   243
        __ newref(sym_);
[email protected]
   244
    }
[email protected]
   245
[email protected]
   246
    return true;
[email protected]
   247
}
[email protected]
   248
[email protected]
   249
void
[email protected]
   250
HIndex::bind(HIRVisitor *visitor, BytecodeEmitter &emitter_)
[email protected]
   251
{
[email protected]
   252
    __ note_position(node()->pos());
[email protected]
   253
    left_->accept(visitor);
[email protected]
   254
    right_->accept(visitor);
[email protected]
   255
}
[email protected]
   256
[email protected]
   257
void
[email protected]
   258
HIndex::hold(BytecodeEmitter &emitter_)
[email protected]
   259
{
[email protected]
   260
    __ dup2();
[email protected]
   261
}
[email protected]
   262
[email protected]
   263
void
[email protected]
   264
HIndex::swapAndPick(BytecodeEmitter &emitter_)
[email protected]
   265
{
[email protected]
   266
    // BASE INDEX VALUE
[email protected]
   267
    __ roll3();         // INDEX VALUE BASE
[email protected]
   268
    __ roll3();         // VALUE BASE INDEX
[email protected]
   269
    __ pick3();         // VALUE BASE INDEX VALUE
[email protected]
   270
}
[email protected]
   271
[email protected]
   272
void
[email protected]
   273
HIndex::store(BytecodeEmitter &emitter_)
[email protected]
   274
{
[email protected]
   275
    __ setelem(type());
[email protected]
   276
}
[email protected]
   277
[email protected]
   278
void
[email protected]
   279
HIndex::load(BytecodeEmitter &emitter_)
[email protected]
   280
{
[email protected]
   281
    __ getelem(type());
[email protected]
   282
}
[email protected]
   283
[email protected]
   284
bool
[email protected]
   285
HIndex::ref(BytecodeEmitter &emitter_)
[email protected]
   286
{
[email protected]
   287
    return false;
[email protected]
   288
}
[email protected]
   289
[email protected]
   290
void
[email protected]
   291
HField::bind(HIRVisitor *visitor, BytecodeEmitter &emitter_)
[email protected]
   292
{
[email protected]
   293
    __ note_position(node()->pos());
[email protected]
   294
    base_->accept(visitor);
[email protected]
   295
}
[email protected]
   296
[email protected]
   297
void
[email protected]
   298
HField::hold(BytecodeEmitter &emitter_)
[email protected]
   299
{
[email protected]
   300
    __ dup();
[email protected]
   301
}
[email protected]
   302
[email protected]
   303
void
[email protected]
   304
HField::swapAndPick(BytecodeEmitter &emitter_)
[email protected]
   305
{
[email protected]
   306
    // BASE VALUE
[email protected]
   307
    __ swap();      // VALUE BASE
[email protected]
   308
    __ pick2();     // VALUE BASE VALUE
[email protected]
   309
}
dvander[email protected]
   310
[email protected]
   311
void
[email protected]
   312
HField::store(BytecodeEmitter &emitter_)
[email protected]
   313
{
[email protected]
   314
    __ setfield(index_, type());
[email protected]
   315
}
[email protected]
   316
[email protected]
   317
void
[email protected]
   318
HField::load(BytecodeEmitter &emitter_)
[email protected]
   319
{
[email protected]
   320
    __ getfield(index_, type());
[email protected]
   321
}
[email protected]
   322
[email protected]
   323
bool
[email protected]
   324
HField::ref(BytecodeEmitter &emitter_)
[email protected]
   325
{
[email protected]
   326
    return false;
[email protected]
   327
}
[email protected]
   328
[email protected]
   329
void
[email protected]
   330
HIRTranslator::visitLocal(HLocal *local)
[email protected]
   331
{
[email protected]
   332
    local->bind(this, emitter_);
[email protected]
   333
    local->load(emitter_);
[email protected]
   334
}
[email protected]
   335
[email protected]
   336
void
[email protected]
   337
HIRTranslator::visitIndex(HIndex *index)
[email protected]
   338
{
[email protected]
   339
    index->bind(this, emitter_);
[email protected]
   340
    index->load(emitter_);
[email protected]
   341
}
[email protected]
   342
[email protected]
   343
void
[email protected]
   344
HIRTranslator::visitField(HField *field)
[email protected]
   345
{
[email protected]
   346
    field->bind(this, emitter_);
[email protected]
   347
    field->load(emitter_);
[email protected]
   348
}
[email protected]
   349
[email protected]
   350
void
[email protected]
   351
HIRTranslator::visitGlobal(HGlobal *global)
[email protected]
   352
{
[email protected]
   353
    global->bind(this, emitter_);
[email protected]
   354
    global->load(emitter_);
[email protected]
   355
}
[email protected]
   356
[email protected]
   357
static inline Opcode
[email protected]
   358
TokenToOpcode(TokenKind kind)
[email protected]
   359
{
[email protected]
   360
    switch (kind) {
[email protected]
   361
      case TOK_PLUS:
[email protected]
   362
      case TOK_ASSIGN_ADD:
[email protected]
   363
      case TOK_INCREMENT:
[email protected]
   364
        return OP_ADD;
[email protected]
   365
      case TOK_MINUS:
[email protected]
   366
      case TOK_ASSIGN_SUB:
[email protected]
   367
      case TOK_DECREMENT:
[email protected]
   368
        return OP_SUB;
[email protected]
   369
      case TOK_STAR:
[email protected]
   370
      case TOK_ASSIGN_MUL:
[email protected]
   371
        return OP_MUL;
[email protected]
   372
      case TOK_SLASH:
[email protected]
   373
      case TOK_ASSIGN_DIV:
[email protected]
   374
        return OP_DIV;
[email protected]
   375
      case TOK_PERCENT:
[email protected]
   376
      case TOK_ASSIGN_MOD:
[email protected]
   377
        return OP_MOD;
[email protected]
   378
      case TOK_SHR:
[email protected]
   379
      case TOK_ASSIGN_SHR:
[email protected]
   380
        return OP_SHR;
[email protected]
   381
      case TOK_USHR:
[email protected]
   382
      case TOK_ASSIGN_USHR:
[email protected]
   383
        return OP_USHR;
[email protected]
   384
      case TOK_SHL:
[email protected]
   385
      case TOK_ASSIGN_SHL:
[email protected]
   386
        return OP_SHL;
[email protected]
   387
      case TOK_BITAND:
[email protected]
   388
      case TOK_ASSIGN_BITAND:
[email protected]
   389
        return OP_BITAND;
[email protected]
   390
      case TOK_BITOR:
[email protected]
   391
      case TOK_ASSIGN_BITOR:
[email protected]
   392
        return OP_BITOR;
[email protected]
   393
      case TOK_GT:
[email protected]
   394
          return OP_GT;
[email protected]
   395
      case TOK_GE:
[email protected]
   396
          return OP_GE;
[email protected]
   397
      case TOK_LT:
[email protected]
   398
          return OP_LT;
[email protected]
   399
      case TOK_LE:
[email protected]
   400
          return OP_LE;
[email protected]
   401
      case TOK_EQUALS:
[email protected]
   402
          return OP_EQ;
[email protected]
   403
      case TOK_NOTEQUALS:
[email protected]
   404
          return OP_NE;
[email protected]
   405
      default:
[email protected]
   406
        assert(kind == TOK_BITXOR);
[email protected]
   407
        return OP_BITXOR;
[email protected]
   408
    }
[email protected]
   409
}
[email protected]
   410
[email protected]
   411
void
[email protected]
   412
HIRTranslator::visitStore(HStore *store)
[email protected]
   413
{
[email protected]
   414
    store->lval()->bind(this, emitter_);
[email protected]
   415
[email protected]
   416
    if (store->kind() == TOK_ASSIGN) {
[email protected]
   417
        // Fixed-length arrays and structs have copy semantics.
[email protected]
   418
        Local<Type> type(zone_, store->lval()->type());
[email protected]
   419
        if (type->isArray() && ArrayType::cast(type)->isFixedLength()) {
[email protected]
   420
            store->lval()->load(emitter_);
[email protected]
   421
            store->rval()->accept(this);
[email protected]
   422
            __ copyarray();
[email protected]
   423
        } else if (type->isStruct()) {
[email protected]
   424
            store->lval()->load(emitter_);
[email protected]
   425
            store->rval()->accept(this);
[email protected]
   426
            __ copystruct();
[email protected]
   427
        } else {
[email protected]
   428
            store->rval()->accept(this);
[email protected]
   429
            store->lval()->store(emitter_);
[email protected]
   430
        }
[email protected]
   431
    } else {
[email protected]
   432
        // Advanced case: dup the ref, load, op, store.
[email protected]
   433
        store->lval()->hold(emitter_);
[email protected]
   434
        store->lval()->load(emitter_);
[email protected]
   435
        store->rval()->accept(this);
[email protected]
   436
        __ binary(TokenToOpcode(store->kind()));
[email protected]
   437
        store->lval()->store(emitter_);
[email protected]
   438
    }
[email protected]
   439
}
[email protected]
   440
[email protected]
   441
void
[email protected]
   442
HIRTranslator::visitPostIncDec(HPostIncDec *hir)
[email protected]
   443
{
[email protected]
   444
    hir->lval()->bind(this, emitter_);
[email protected]
   445
    hir->lval()->hold(emitter_);
[email protected]
   446
    hir->lval()->load(emitter_);
[email protected]
   447
    hir->lval()->swapAndPick(emitter_);
[email protected]
   448
    hir->rval()->accept(this);
[email protected]
   449
    __ binary(TokenToOpcode(hir->kind()));
[email protected]
   450
    hir->lval()->store(emitter_);
[email protected]
   451
    __ pop();
[email protected]
   452
}
[email protected]
   453
[email protected]
   454
void
[email protected]
   455
HIRTranslator::visitBinary(HBinary *binary)
[email protected]
   456
{
[email protected]
   457
    binary->left()->accept(this);
[email protected]
   458
    binary->right()->accept(this);
[email protected]
   459
[email protected]
   460
    // We define three sets of math operators:
[email protected]
   461
    //
[email protected]
   462
    //  (1) ADD, SUB, MUL, DIV, MOD, which take two equal types and produce
[email protected]
   463
    //      the same type.
[email protected]
   464
    //  (2) LT, LE, GE, GT, EQ, NE, which take two equal types and produce
[email protected]
   465
    //      a boolean.
[email protected]
   466
    //  (3) SHL, SR, USHR, BITAND, BITOR, BITXOR, BITNOT, which take two
[email protected]
   467
    //      equal integer types and return that integer type.
[email protected]
   468
    //
[email protected]
   469
    Opcode op = TokenToOpcode(binary->token());
[email protected]
   470
[email protected]
   471
    if (op == OP_DIV)
[email protected]
   472
        __ note_position(binary->node()->pos());
[email protected]
   473
[email protected]
   474
    if (op >= OP_ADD && op <= OP_NE) {
[email protected]
   475
        if (binary->type()->isFloat())
[email protected]
   476
            op = Opcode(int(op) + int(OP_ADD_F - OP_ADD));
[email protected]
   477
    } else {
[email protected]
   478
        assert(binary->type()->isInt32());
[email protected]
   479
    }
[email protected]
   480
[email protected]
   481
    __ binary(op);
[email protected]
   482
}
[email protected]
   483
[email protected]
   484
void
[email protected]
   485
HIRTranslator::visitUnary(HUnary *unary)
[email protected]
   486
{
[email protected]
   487
    unary->in()->accept(this);
[email protected]
   488
[email protected]
   489
    switch (unary->token()) {
[email protected]
   490
      case TOK_TILDE:
[email protected]
   491
        __ bitnot();
[email protected]
   492
        break;
[email protected]
   493
[email protected]
   494
      case TOK_MINUS:
[email protected]
   495
        if (unary->type()->isFloat())
[email protected]
   496
            __ neg_f();
[email protected]
   497
        else
[email protected]
   498
            __ neg();
[email protected]
   499
        break;
[email protected]
   500
[email protected]
   501
      default:
[email protected]
   502
        assert(unary->token() == TOK_LABEL);
[email protected]
   503
        __ bitcast(unary->type());
[email protected]
   504
        break;
[email protected]
   505
    }
[email protected]
   506
}
[email protected]
   507
[email protected]
   508
void
[email protected]
   509
HIRTranslator::visitConvert(HConvert *convert)
[email protected]
   510
{
[email protected]
   511
    convert->in()->accept(this);
[email protected]
   512
    __ unary(convert->opcode());
[email protected]
   513
}
[email protected]
   514
[email protected]
   515
void
[email protected]
   516
HIRTranslator::visitToRef(HToRef *hir)
[email protected]
   517
{
[email protected]
   518
    HIR *in = hir->in();
[email protected]
   519
[email protected]
   520
    // See if we can bind a direct reference.
[email protected]
   521
    if (in->isLValue() && in->toLValue()->ref(emitter_))
[email protected]
   522
        return;
[email protected]
   523
[email protected]
   524
    // No, we can't. So instead we create an on-stack reference.
[email protected]
   525
    in->accept(this);
[email protected]
   526
    __ slotref_lifo();
[email protected]
   527
}
[email protected]
   528
[email protected]
   529
void
[email protected]
   530
HIRTranslator::visitNewDependentArray(HNewDependentArray *hir)
[email protected]
   531
{
[email protected]
   532
    hir->base()->accept(this);
[email protected]
   533
    hir->index()->accept(this);
[email protected]
   534
[email protected]
   535
    Local<ArrayType> type(zone_, ArrayType::cast(hir->type()));
[email protected]
   536
[email protected]
   537
    // The dependent map is used for the opcode, but is not attached.
[email protected]
   538
    Local<ArrayMap> map(zone_, ArrayMap::NewDependent(zone_, type));
[email protected]
   539
    if (!map)
[email protected]
   540
        return;
[email protected]
   541
[email protected]
   542
    __ deparray(map);
[email protected]
   543
}
[email protected]
   544
[email protected]
   545
void
[email protected]
   546
HIRTranslator::visitImport(HImport *import)
[email protected]
   547
{
[email protected]
   548
    __ import(import->index());
[email protected]
   549
}
[email protected]
   550
[email protected]
   551
void
[email protected]
   552
ke::EmitHIR(Zone *zone, BytecodeEmitter &emitter, HIR *hir)
[email protected]
   553
{
[email protected]
   554
    HIRTranslator translator(zone, emitter);
[email protected]
   555
    translator.translate(hir);
[email protected]
   556
}