Mercurial Hosting > luan
comparison src/luan/modules/JavaLuan.java @ 1353:8d95711f6615
replace java() with require "java"
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 20 Mar 2019 17:03:29 -0600 |
parents | e0cf0d108a77 |
children | e1a13e707bf3 |
comparison
equal
deleted
inserted
replaced
1352:1604d7f36f3a | 1353:8d95711f6615 |
---|---|
30 public static void java(Luan luan) throws LuanException { | 30 public static void java(Luan luan) throws LuanException { |
31 Luan.checkSecurity(luan,"java"); | 31 Luan.checkSecurity(luan,"java"); |
32 luan.peek().javaOk = true; | 32 luan.peek().javaOk = true; |
33 } | 33 } |
34 | 34 |
35 public static LuanFunction javaFn(Luan luan) { | |
36 LuanFunction fn = (LuanFunction)luan.registry().get("JavaLuan.java"); | |
37 if( fn == null ) { | |
38 try { | |
39 fn = new LuanJavaFunction(luan,JavaLuan.class.getMethod("java",Luan.class),null); | |
40 } catch(NoSuchMethodException e) { | |
41 throw new RuntimeException(e); | |
42 } | |
43 luan.registry().put("JavaLuan.java",fn); | |
44 } | |
45 return fn; | |
46 } | |
47 | |
48 private static void checkJava(Luan luan) throws LuanException { | 35 private static void checkJava(Luan luan) throws LuanException { |
49 if( !luan.peek().javaOk ) | 36 if( !luan.peek().javaOk ) |
50 throw new LuanException("Java isn't allowed"); | 37 throw new LuanException("Java isn't allowed"); |
51 } | 38 } |
52 | 39 |