summaryrefslogtreecommitdiff
path: root/chapter21/src/main/java
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2025-03-31 15:40:03 -0700
committerCliff Click <cliffc@acm.org>2025-03-31 15:40:03 -0700
commit950d57cc74a36655a770daea7c28cee03b60e707 (patch)
treef67221e7fd1e916b6d34485cf36b006d31466b5e /chapter21/src/main/java
parent6d50b541a7a5c6757ee507da24a995bc02354270 (diff)
downloadSimple-950d57cc74a36655a770daea7c28cee03b60e707.tar.gz
Simple-950d57cc74a36655a770daea7c28cee03b60e707.zip
Create intermediate dirs
Diffstat (limited to 'chapter21/src/main/java')
-rw-r--r--chapter21/src/main/java/com/seaofnodes/simple/codegen/ElfFile.java17
1 files changed, 7 insertions, 10 deletions
diff --git a/chapter21/src/main/java/com/seaofnodes/simple/codegen/ElfFile.java b/chapter21/src/main/java/com/seaofnodes/simple/codegen/ElfFile.java
index 654d6678..5db0bb75 100644
--- a/chapter21/src/main/java/com/seaofnodes/simple/codegen/ElfFile.java
+++ b/chapter21/src/main/java/com/seaofnodes/simple/codegen/ElfFile.java
@@ -3,15 +3,11 @@ package com.seaofnodes.simple.codegen;
import com.seaofnodes.simple.*;
import com.seaofnodes.simple.node.*;
import com.seaofnodes.simple.type.*;
-
-import java.util.Map;
-import java.util.HashMap;
+import java.io.*;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
-import java.io.IOException;
-import java.io.FileOutputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.BufferedOutputStream;
+import java.util.HashMap;
+import java.util.Map;
public class ElfFile {
@@ -222,9 +218,8 @@ public class ElfFile {
Node bb = _code._cfg.at(i);
if( bb instanceof FunNode f ) {
// skip until the function ends
- while( !(_code._cfg.at(i) instanceof ReturnNode) ) {
+ while( !(_code._cfg.at(i) instanceof ReturnNode) )
i++;
- }
Node r = _code._cfg.at(i);
int end = _code._encoding._opStart[r._nid] + _code._encoding._opLen[r._nid];
@@ -363,7 +358,9 @@ public class ElfFile {
}
assert out.position() == size;
- BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(fname));
+ File file = new File(fname);
+ file.getParentFile().mkdirs();
+ BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));
bos.write(out.array());
bos.close();
}