on master help sign in
Merge pull request #240 from JanBessai/master
e8d3f09Edwin Brady
java/executable_pom_template.xml+1
@@ -17,6 +17,7 @@
17 <artifactId>idris</artifactId>
17 <artifactId>idris</artifactId>
18 <version>$RTS-VERSION$</version>
18 <version>$RTS-VERSION$</version>
19 </dependency>
19 </dependency>
20+$DEPENDENCIES$
20 </dependencies>
21 </dependencies>
21
22
22
23
java/src/main/java/org/idris/rts/ForeignPrimitives.java+138−123
@@ -1,5 +1,6 @@
1package org.idris.rts;
1package org.idris.rts;
2
2
3+import java.lang.reflect.InvocationTargetException;
3import java.util.Arrays;
4import java.util.Arrays;
4import java.util.List;
5import java.util.List;
5import java.util.Map;
6import java.util.Map;
@@ -9,7 +10,6 @@ import java.util.HashSet;
9import java.io.Closeable;
10import java.io.Closeable;
10import java.io.File;
11import java.io.File;
11import java.io.IOException;
12import java.io.IOException;
12−import java.io.EOFException;
13import java.io.PrintStream;
13import java.io.PrintStream;
14import java.io.InputStream;
14import java.io.InputStream;
15import java.nio.ByteBuffer;
15import java.nio.ByteBuffer;
@@ -25,190 +25,205 @@ import java.util.concurrent.Semaphore;
25
25
26@SuppressWarnings("unchecked")
26@SuppressWarnings("unchecked")
27public class ForeignPrimitives {
27public class ForeignPrimitives {
28+
28 private static final Map<Thread, List<String>> args = new HashMap<>();
29 private static final Map<Thread, List<String>> args = new HashMap<>();
29 private static final Semaphore messageMutex = new Semaphore(1);
30 private static final Semaphore messageMutex = new Semaphore(1);
30 private static final Map<Thread, BlockingQueue<Object>> messages = new HashMap<>();
31 private static final Map<Thread, BlockingQueue<Object>> messages = new HashMap<>();
31 private static final Set<Object> feofFiles = new HashSet<>();
32 private static final Set<Object> feofFiles = new HashSet<>();
32
33
33− public static synchronized void idris_initArgs(Thread t, String [] args) {
34+ public static synchronized void idris_initArgs(Thread t, String[] args) {
34− ForeignPrimitives.args.put(t, Arrays.asList(args));
35+ ForeignPrimitives.args.put(t, Arrays.asList(args));
35 }
36 }
36
37
37 public static synchronized int idris_numArgs(Object thread) {
38 public static synchronized int idris_numArgs(Object thread) {
38− List<String> argsForThread = ForeignPrimitives.args.get((Thread)thread);
39+ List<String> argsForThread = ForeignPrimitives.args.get((Thread) thread);
39− return (argsForThread == null ? 0 : argsForThread.size());
40+ return (argsForThread == null ? 0 : argsForThread.size());
40 }
41 }
41
42
42 public static synchronized String idris_getArg(Object thread, int num) {
43 public static synchronized String idris_getArg(Object thread, int num) {
43− List<String> argsForThread = ForeignPrimitives.args.get((Thread)thread);
44+ List<String> argsForThread = ForeignPrimitives.args.get((Thread) thread);
44− return (argsForThread == null ? null : argsForThread.get(num));
45+ return (argsForThread == null ? null : argsForThread.get(num));
45 }
46 }
46
47
47 public static String getenv(String x) {
48 public static String getenv(String x) {
48− return System.getenv(x);
49+ return System.getenv(x);
49 }
50 }
50
51
51 public static void exit(int exitCode) {
52 public static void exit(int exitCode) {
52− System.exit(exitCode);
53+ System.exit(exitCode);
53 }
54 }
54
55
55 public static void usleep(int microsecs) {
56 public static void usleep(int microsecs) {
56− try {
57+ try {
57− Thread.sleep(microsecs / 1000, microsecs % 1000);
58+ Thread.sleep(microsecs / 1000, microsecs % 1000);
58− } catch (InterruptedException ex) {
59+ } catch (InterruptedException ex) {
59− }
60+ }
60 }
61 }
61
62
62 public static void idris_sendMessage(Object from, Object dest, Object message) throws InterruptedException {
63 public static void idris_sendMessage(Object from, Object dest, Object message) throws InterruptedException {
63− messageMutex.acquire();
64+ messageMutex.acquire();
64− BlockingQueue<Object> messagesForTarget = messages.get((Thread)dest);
65+ BlockingQueue<Object> messagesForTarget = messages.get((Thread) dest);
65− if (messagesForTarget == null) {
66+ if (messagesForTarget == null) {
66− messagesForTarget = new LinkedBlockingQueue<>();
67+ messagesForTarget = new LinkedBlockingQueue<>();
67− messages.put((Thread)dest, messagesForTarget);
68+ messages.put((Thread) dest, messagesForTarget);
68− }
69+ }
69− messagesForTarget.put(message);
70+ messagesForTarget.put(message);
70 messageMutex.release();
71 messageMutex.release();
71 }
72 }
72
73
73 public static int idris_checkMessage(Object dest) throws InterruptedException {
74 public static int idris_checkMessage(Object dest) throws InterruptedException {
74− messageMutex.acquire();
75+ messageMutex.acquire();
75− BlockingQueue<Object> messagesForTarget = messages.get((Thread)dest);
76+ BlockingQueue<Object> messagesForTarget = messages.get((Thread) dest);
76− messageMutex.release();
77+ messageMutex.release();
77− return (messagesForTarget == null ? 0 : messagesForTarget.size());
78+ return (messagesForTarget == null ? 0 : messagesForTarget.size());
78 }
79 }
79
80
80 public static Object idris_recvMessage(Object dest) throws InterruptedException {
81 public static Object idris_recvMessage(Object dest) throws InterruptedException {
81− messageMutex.acquire();
82+ messageMutex.acquire();
82− BlockingQueue<Object> messagesForTarget = messages.get((Thread)dest);
83+ BlockingQueue<Object> messagesForTarget = messages.get((Thread) dest);
83− if (messagesForTarget == null) {
84+ if (messagesForTarget == null) {
84− messagesForTarget = new LinkedBlockingQueue();
85+ messagesForTarget = new LinkedBlockingQueue();
85− messages.put((Thread)dest, messagesForTarget);
86+ messages.put((Thread) dest, messagesForTarget);
86− }
87+ }
87− messageMutex.release();
88+ messageMutex.release();
88− return messagesForTarget.take();
89+ return messagesForTarget.take();
89 }
90 }
90
91
91 public static void putStr(String str) {
92 public static void putStr(String str) {
92− System.out.print(str);
93+ System.out.print(str);
93 }
94 }
94
95
95 public static void putchar(char c) {
96 public static void putchar(char c) {
96− System.out.print(c);
97+ System.out.print(c);
97 }
98 }
98
99
99 public static int getchar() {
100 public static int getchar() {
100− try {
101+ try {
101− return (char)System.in.read();
102+ return (char) System.in.read();
102− } catch (IOException ex) {
103+ } catch (IOException ex) {
103− return -1;
104+ return -1;
104− }
105+ }
105 }
106 }
106
107
107 public static SeekableByteChannel fileOpen(String name, String privs) {
108 public static SeekableByteChannel fileOpen(String name, String privs) {
108− try {
109+ try {
109− OpenOption [] options;
110+ OpenOption[] options;
110− switch (privs) {
111+ switch (privs) {
111− case "r" :
112+ case "r":
112− options = new StandardOpenOption []
113+ options = new StandardOpenOption[]{StandardOpenOption.READ};
113− { StandardOpenOption.READ };
114− break;
114+ break;
115− case "r+" :
115+ case "r+":
116− options = new StandardOpenOption []
116+ options = new StandardOpenOption[]{StandardOpenOption.READ,
117− { StandardOpenOption.READ,
118− StandardOpenOption.WRITE };
117+ StandardOpenOption.WRITE};
119− break;
118+ break;
120− case "w" :
119+ case "w":
121− options = new StandardOpenOption []
120+ options = new StandardOpenOption[]{StandardOpenOption.WRITE,
122− { StandardOpenOption.WRITE,
123− StandardOpenOption.CREATE };
121+ StandardOpenOption.CREATE};
124− break;
122+ break;
125− case "w+" :
123+ case "w+":
126− options = new StandardOpenOption []
124+ options = new StandardOpenOption[]{StandardOpenOption.READ,
127− { StandardOpenOption.READ,
128− StandardOpenOption.WRITE,
125+ StandardOpenOption.WRITE,
129− StandardOpenOption.CREATE };
126+ StandardOpenOption.CREATE};
130− break;
127+ break;
131− case "a" :
128+ case "a":
132− options = new StandardOpenOption []
129+ options = new StandardOpenOption[]{StandardOpenOption.WRITE,
133− { StandardOpenOption.WRITE,
134− StandardOpenOption.CREATE,
130+ StandardOpenOption.CREATE,
135− StandardOpenOption.APPEND };
131+ StandardOpenOption.APPEND};
136− break;
132+ break;
137− case "a+" :
133+ case "a+":
138− options = new StandardOpenOption []
134+ options = new StandardOpenOption[]{StandardOpenOption.READ,
139− { StandardOpenOption.READ,
140− StandardOpenOption.WRITE,
135+ StandardOpenOption.WRITE,
141− StandardOpenOption.CREATE,
136+ StandardOpenOption.CREATE,
142− StandardOpenOption.APPEND };
137+ StandardOpenOption.APPEND};
143− break;
138+ break;
144− default :
139+ default:
145− options = new StandardOpenOption [] {};
140+ options = new StandardOpenOption[]{};
146− break;
141+ break;
147− }
142+ }
148− return Files.newByteChannel(new File(name).toPath(), options);
143+ return Files.newByteChannel(new File(name).toPath(), options);
149− } catch (IOException ex) {
144+ } catch (IOException ex) {
150− return null;
145+ return null;
151− }
146+ }
152 }
147 }
153
148
154 public static synchronized void fileClose(Object file) throws IOException {
149 public static synchronized void fileClose(Object file) throws IOException {
155− ((Closeable)file).close();
150+ ((Closeable) file).close();
156− feofFiles.remove(file);
151+ feofFiles.remove(file);
157 }
152 }
158
153
159 public static void fputStr(Object file, String string) throws IOException {
154 public static void fputStr(Object file, String string) throws IOException {
160− if (file instanceof PrintStream) {
155+ if (file instanceof PrintStream) {
161− ((PrintStream)file).print(string);
156+ ((PrintStream) file).print(string);
162− } else if (file instanceof SeekableByteChannel) {
157+ } else if (file instanceof SeekableByteChannel) {
163− ((SeekableByteChannel)file).write(ByteBuffer.wrap(string.getBytes()));
158+ ((SeekableByteChannel) file).write(ByteBuffer.wrap(string.getBytes()));
164− }
159+ }
165 }
160 }
166
161
167 public static synchronized String idris_readStr(Object file) throws IOException {
162 public static synchronized String idris_readStr(Object file) throws IOException {
168− ReadableByteChannel channel = file instanceof InputStream ?
163+ ReadableByteChannel channel = file instanceof InputStream
169− Channels.newChannel((InputStream)file) :
164+ ? Channels.newChannel((InputStream) file)
170− (ReadableByteChannel)file;
165+ : (ReadableByteChannel) file;
171− ByteBuffer buf = ByteBuffer.allocate(1);
166+ ByteBuffer buf = ByteBuffer.allocate(1);
172− StringBuilder resultBuilder = new StringBuilder("");
167+ StringBuilder resultBuilder = new StringBuilder("");
173− String delimiter = System.getProperty("line.separator");
168+ String delimiter = System.getProperty("line.separator");
174− int read = 0;
169+ int read = 0;
175− do {
170+ do {
176− buf.rewind();
171+ buf.rewind();
177− read = channel.read(buf);
172+ read = channel.read(buf);
178− if (read > 0) {
173+ if (read > 0) {
179− resultBuilder.append(new String(buf.array()));
174+ resultBuilder.append(new String(buf.array()));
180− if (resultBuilder.lastIndexOf(delimiter) > -1) {
175+ if (resultBuilder.lastIndexOf(delimiter) > -1) {
181− return resultBuilder.toString();
176+ return resultBuilder.toString();
182− }
177+ }
183− }
178+ }
184− if (read < 0) {
179+ if (read < 0) {
185− feofFiles.add(file);
180+ feofFiles.add(file);
186− }
181+ }
187− } while (read >= 0);
182+ } while (read >= 0);
188− return resultBuilder.toString();
183+ return resultBuilder.toString();
189 }
184 }
190
185
191 public static int fileEOF(Object file) {
186 public static int fileEOF(Object file) {
192− return (feofFiles.contains(file) ? 1 : 0);
187+ return (feofFiles.contains(file) ? 1 : 0);
193 }
188 }
194
189
195 public static int isNull(Object o) {
190 public static int isNull(Object o) {
196− return (o == null ? 1 : 0);
191+ return (o == null ? 1 : 0);
197 }
192 }
198
193
199 public final static Object idris_K(final Object result, final Object drop) {
194 public final static Object idris_K(final Object result, final Object drop) {
200− return result;
195+ return result;
201 }
196 }
202
197
203 public final static Object idris_flipK(final Object drop, final Object result) {
198 public final static Object idris_flipK(final Object drop, final Object result) {
204− return result;
199+ return result;
205− }
200+ }
206−
201+
207− public final static Object idris_assignStack(final Object [] context, final int start, final Object ... vars) {
202+ public final static Object idris_assignStack(final Object[] context, final int start, final Object... vars) {
208− int i = start;
203+ int i = start;
209− for (Object var : vars) {
204+ for (Object var : vars) {
210− context[i] = var;
205+ context[i] = var;
211− }
206+ }
212− return context;
207+ return context;
208+ }
209+
210+ public final static Object invokeOn(final Object obj, final String methodName, Object... args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
211+ Class cls = (obj instanceof Class ? (Class)obj : obj.getClass());
212+ Class argClasses[] = new Class[args.length];
213+ int i = 0;
214+ for (Object arg : args) {
215+ argClasses[i] = arg.getClass();
216+ }
217+ return cls.getMethod(methodName, argClasses).invoke(obj, args);
218+ }
219+
220+ public final static Object newObject(final Object cls, Object... args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
221+ Class clazz = (cls instanceof Class ? (Class)cls : cls.getClass());
222+ Class argClasses[] = new Class[args.length];
223+ int i = 0;
224+ for (Object arg : args) {
225+ argClasses[i] = arg.getClass();
226+ }
227+ return clazz.getConstructor(argClasses).newInstance(args);
213 }
228 }
214}
229}
samples/javaffi.idrnew file+12
@@ -0,0 +1,12 @@
1+module Main
2+
3+%include "com.google.common.math.IntMath"
4+%lib "com.google.guava:guava:14.0"
5+
6+binom : Int -> Int -> IO Int
7+binom n k = mkForeign (FFun "IntMath.binomial" [FInt, FInt] FInt) n k
8+
9+main : IO ()
10+main = do print "The number of possibilities in lotto is 49 choose 6:"
11+ res <- binom 49 6
12+ print res
src/IRTS/CodegenJava.hs+51−22
@@ -15,7 +15,7 @@ import qualified Control.Monad.Trans as T
15import Control.Monad.Trans.State
15import Control.Monad.Trans.State
16import Data.Char
16import Data.Char
17import Data.Maybe (fromJust)
17import Data.Maybe (fromJust)
18−import Data.List (isPrefixOf, intercalate)
18+import Data.List (isPrefixOf, isSuffixOf, intercalate)
19import qualified Data.Text as T
19import qualified Data.Text as T
20import qualified Data.Text.IO as TIO
20import qualified Data.Text.IO as TIO
21import Language.Java.Parser
21import Language.Java.Parser
@@ -35,9 +35,11 @@ type CodeGeneration = StateT (CodeGenerationEnv) (Either String)
35codegenJava :: [(Name, SExp)] -> -- initialization of globals
35codegenJava :: [(Name, SExp)] -> -- initialization of globals
36 [(Name, SDecl)] ->
36 [(Name, SDecl)] ->
37 FilePath -> -- output file name
37 FilePath -> -- output file name
38+ [String] -> -- headers
39+ [String] -> -- libs
38 OutputType ->
40 OutputType ->
39 IO ()
41 IO ()
40−codegenJava globalInit defs out exec = do
42+codegenJava globalInit defs out hdrs libs exec = do
41 withTempdir (takeBaseName out) $ \ tmpDir -> do
43 withTempdir (takeBaseName out) $ \ tmpDir -> do
42 let srcdir = tmpDir </> "src" </> "main" </> "java"
44 let srcdir = tmpDir </> "src" </> "main" </> "java"
43 createDirectoryIfMissing True srcdir
45 createDirectoryIfMissing True srcdir
@@ -46,7 +48,7 @@ codegenJava globalInit defs out exec = do
46 let outjava = srcdir </> clsName <.> "java"
48 let outjava = srcdir </> clsName <.> "java"
47 let jout = either error
49 let jout = either error
48 (flatIndent . prettyPrint)
50 (flatIndent . prettyPrint)
49− (evalStateT (mkCompilationUnit globalInit defs out) (mkCodeGenEnv globalInit))
51+ (evalStateT (mkCompilationUnit globalInit defs hdrs out) (mkCodeGenEnv globalInit))
50 writeFile outjava jout
52 writeFile outjava jout
51 if (exec == Raw)
53 if (exec == Raw)
52 then copyFile outjava (takeDirectory out </> clsName <.> "java")
54 then copyFile outjava (takeDirectory out </> clsName <.> "java")
@@ -57,12 +59,16 @@ codegenJava globalInit defs out exec = do
57 (T.pack clsName)
59 (T.pack clsName)
58 (T.replace (T.pack "$ARTIFACT-NAME$")
60 (T.replace (T.pack "$ARTIFACT-NAME$")
59 (T.pack $ takeBaseName out)
61 (T.pack $ takeBaseName out)
62+ (T.replace (T.pack "$DEPENDENCIES$")
63+ (mkPomDependencies libs)
60− execPomTemplate)
64+ execPomTemplate
65+ )
66+ )
61 TIO.writeFile (tmpDir </> "pom.xml") execPom
67 TIO.writeFile (tmpDir </> "pom.xml") execPom
62 mvnCmd <- getMvn
68 mvnCmd <- getMvn
63 let args = ["-f", (tmpDir </> "pom.xml")]
69 let args = ["-f", (tmpDir </> "pom.xml")]
64− (exit, _, err) <- readProcessWithExitCode mvnCmd (args ++ ["compile"]) ""
70+ (exit, mvout, err) <- readProcessWithExitCode mvnCmd (args ++ ["compile"]) ""
65− when (exit /= ExitSuccess) $ error ("FAILURE: " ++ mvnCmd ++ " compile\n" ++ err)
71+ when (exit /= ExitSuccess) $ error ("FAILURE: " ++ mvnCmd ++ " compile\n" ++ err ++ mvout)
66 if (exec == Object)
72 if (exec == Object)
67 then do
73 then do
68 classFiles <-
74 classFiles <-
@@ -72,8 +78,8 @@ codegenJava globalInit defs out exec = do
72 mapM_ (\ clsFile -> copyFile clsFile (takeDirectory out </> takeFileName clsFile))
78 mapM_ (\ clsFile -> copyFile clsFile (takeDirectory out </> takeFileName clsFile))
73 classFiles
79 classFiles
74 else do
80 else do
75− (exit, _, err) <- readProcessWithExitCode mvnCmd (args ++ ["package"]) ""
81+ (exit, mvout, err) <- readProcessWithExitCode mvnCmd (args ++ ["package"]) ""
76− when (exit /= ExitSuccess) (error ("FAILURE: " ++ mvnCmd ++ " package\n" ++ err))
82+ when (exit /= ExitSuccess) (error ("FAILURE: " ++ mvnCmd ++ " package\n" ++ err ++ mvout))
77 copyFile (tmpDir </> "target" </> (takeBaseName out) <.> "jar") out
83 copyFile (tmpDir </> "target" </> (takeBaseName out) <.> "jar") out
78 handle <- openBinaryFile out ReadMode
84 handle <- openBinaryFile out ReadMode
79 contents <- TIO.hGetContents handle
85 contents <- TIO.hGetContents handle
@@ -99,21 +105,40 @@ jarHeader =
99 ++ "exec \"$java\" $java_args -jar $MYSELF \"$@\""
105 ++ "exec \"$java\" $java_args -jar $MYSELF \"$@\""
100 ++ "exit 1\n"
106 ++ "exit 1\n"
101
107
108+mkPomDependencies :: [String] -> T.Text
109+mkPomDependencies deps =
110+ T.concat $ map (T.concat . map (T.append (T.pack " ")) . mkDependency . T.pack) deps
111+ where
112+ mkDependency s =
113+ case T.splitOn (T.pack ":") s of
114+ [g, a, v] ->
115+ [ T.pack $ "<dependency>\n"
116+ , T.append (T.pack " ") $ mkGroupId g
117+ , T.append (T.pack " ") $ mkArtifactId a
118+ , T.append (T.pack " ") $ mkVersion v
119+ , T.pack $ "</dependency>\n"
120+ ]
121+ _ -> []
122+ mkGroupId g = T.append (T.pack $ "<groupId>") (T.append g $ T.pack "</groupId>\n")
123+ mkArtifactId a = T.append (T.pack $ "<artifactId>") (T.append a $ T.pack "</artifactId>\n")
124+ mkVersion v = T.append (T.pack $ "<version>") (T.append v $ T.pack "</version>\n")
125+
102mkCodeGenEnv :: [(Name, SExp)] -> CodeGenerationEnv
126mkCodeGenEnv :: [(Name, SExp)] -> CodeGenerationEnv
103mkCodeGenEnv globalInit =
127mkCodeGenEnv globalInit =
104 CodeGenerationEnv $ zipWith (\ (name, _) pos -> (name, pos)) globalInit [0..]
128 CodeGenerationEnv $ zipWith (\ (name, _) pos -> (name, pos)) globalInit [0..]
105
129
106−mkCompilationUnit :: [(Name, SExp)] -> [(Name, SDecl)] -> FilePath -> CodeGeneration CompilationUnit
130+mkCompilationUnit :: [(Name, SExp)] -> [(Name, SDecl)] -> [String] -> FilePath -> CodeGeneration CompilationUnit
107−mkCompilationUnit globalInit defs out =
131+mkCompilationUnit globalInit defs hdrs out =
108− CompilationUnit Nothing [ ImportDecl False idrisRts True
132+ CompilationUnit Nothing ( [ ImportDecl False idrisRts True
109− , ImportDecl True idrisForeign True
133+ , ImportDecl True idrisForeign True
110− , ImportDecl False bigInteger False
134+ , ImportDecl False bigInteger False
111− , ImportDecl False stringBuffer False
135+ , ImportDecl False stringBuffer False
112− , ImportDecl False runtimeException False
136+ , ImportDecl False runtimeException False
113− , ImportDecl False scanner False
137+ , ImportDecl False scanner False
114− , ImportDecl False arrays False
138+ , ImportDecl False arrays False
115− ] <$>
139+ ] ++ otherHdrs
140+ )
116− mkTypeDecl globalInit defs out
141+ <$> mkTypeDecl globalInit defs out
117 where
142 where
118 idrisRts = J.Name $ map Ident ["org", "idris", "rts"]
143 idrisRts = J.Name $ map Ident ["org", "idris", "rts"]
119 idrisForeign = J.Name $ map Ident ["org", "idris", "rts", "ForeignPrimitives"]
144 idrisForeign = J.Name $ map Ident ["org", "idris", "rts", "ForeignPrimitives"]
@@ -122,6 +147,12 @@ mkCompilationUnit globalInit defs out =
122 runtimeException = J.Name $ map Ident ["java", "lang", "RuntimeException"]
147 runtimeException = J.Name $ map Ident ["java", "lang", "RuntimeException"]
123 scanner = J.Name $ map Ident ["java", "util", "Scanner"]
148 scanner = J.Name $ map Ident ["java", "util", "Scanner"]
124 arrays = J.Name $ map Ident ["java", "util", "Arrays"]
149 arrays = J.Name $ map Ident ["java", "util", "Arrays"]
150+ otherHdrs = map ( (\ name -> ImportDecl False name False)
151+ . J.Name
152+ . map (Ident . T.unpack)
153+ . T.splitOn (T.pack ".")
154+ . T.pack)
155+ $ filter (not . isSuffixOf ".h") hdrs
125
156
126flatIndent :: String -> String
157flatIndent :: String -> String
127flatIndent (' ' : ' ' : xs) = flatIndent xs
158flatIndent (' ' : ' ' : xs) = flatIndent xs
@@ -337,6 +368,7 @@ mkIdentifier (UN name) =
337 cleanReserved "volatile" = "_volatile"
368 cleanReserved "volatile" = "_volatile"
338 cleanReserved "transient" = "_transient"
369 cleanReserved "transient" = "_transient"
339 cleanReserved "native" = "_native"
370 cleanReserved "native" = "_native"
371+ cleanReserved "const" = "_const"
340
372
341 cleanReserved "import" = "_import"
373 cleanReserved "import" = "_import"
342 cleanReserved "package" = "_package"
374 cleanReserved "package" = "_package"
@@ -410,9 +442,6 @@ idrisClosureType = ClassType [(Ident "Closure", [])]
410idrisTailCallClosureType :: ClassType
442idrisTailCallClosureType :: ClassType
411idrisTailCallClosureType = ClassType [(Ident "TailCallClosure", [])]
443idrisTailCallClosureType = ClassType [(Ident "TailCallClosure", [])]
412
444
413−--idrisFunctionType :: ClassType
414−--idrisFunctionType = ClassType [(Ident "IdrisFunction", [])]
415−
416idrisObjectType :: ClassType
445idrisObjectType :: ClassType
417idrisObjectType = ClassType [(Ident "IdrisObject", [])]
446idrisObjectType = ClassType [(Ident "IdrisObject", [])]
418
447
src/IRTS/Compiler.hs+1−1
@@ -71,7 +71,7 @@ compile target f tm
71 (concatMap mkObj objs)
71 (concatMap mkObj objs)
72 (concatMap mkLib libs) NONE
72 (concatMap mkLib libs) NONE
73 ViaJava ->
73 ViaJava ->
74− codegenJava [] c f outty
74+ codegenJava [] c f hdrs libs outty
75 ViaJavaScript ->
75 ViaJavaScript ->
76 codegenJavaScript JavaScript c f outty
76 codegenJavaScript JavaScript c f outty
77 ViaNode ->
77 ViaNode ->
src/IRTS/LParser.hs+1−1
@@ -61,7 +61,7 @@ fovm tgt outty f
61 case checked of
61 case checked of
62 OK c -> case tgt of
62 OK c -> case tgt of
63 ViaC -> codegenC c "a.out" outty ["math.h"] "" "" TRACE
63 ViaC -> codegenC c "a.out" outty ["math.h"] "" "" TRACE
64− ViaJava -> codegenJava [] c "a.out" outty
64+ ViaJava -> codegenJava [] c "a.out" [] [] outty
65 Error e -> fail $ show e
65 Error e -> fail $ show e
66
66
67parseFOVM :: FilePath -> IO [(Name, LDecl)]
67parseFOVM :: FilePath -> IO [(Name, LDecl)]