compileAST method

Uint8List compileAST(
  1. ASTNode node, {
  2. bool endOfExec = false,
})

Implementation

Uint8List compileAST(ASTNode node, {bool endOfExec = false}) {
  final lowered = _compilation.loweredExpression(node);
  if (lowered != null) {
    return compileAST(lowered, endOfExec: endOfExec);
  }
  final bytesBuilder = BytesBuilder();
  if (config.computeConstantExpression) {
    final constant = _constantFolder.fold(node, _optimization);
    if (constant != null) {
      bytesBuilder.add(_compileResolvedConstant(constant.value));
    } else {
      bytesBuilder.add(node.accept(this));
    }
  } else {
    bytesBuilder.add(node.accept(this));
  }
  if (endOfExec) {
    bytesBuilder.addByte(OpCode.endOfExec);
  }
  return bytesBuilder.toBytes();
}