on master help sign in
Merge pull request #594 from JanBessai/NullPtr

Null ptr

commit81632d757918690acd02893abb1cb82ee2192c5b authorEdwin Brady <edwin.brady@gmail.com> dateFri 8 Nov 2013, 04:28 (13 years ago) parent793cf0b2130030
7 files changed+11−28
src/IRTS/CodegenJava.hs+2 test/README+5−1 test/test033/expected+1−1 test/test033/run+2−3 test/test033/test033.c−10 test/test033/test033.h−6 test/test033/test033.idr+1−7
src/IRTS/CodegenJava.hs+2
@@ -486,6 +486,8 @@ mkExp pp (SOp LPar [arg]) =
486486 (Nothing <>@! arg) >>= ppExp pp
487487mkExp pp (SOp LNoOp args) =
488488 (Nothing <>@! (last args)) >>= ppExp pp
489+mkExp pp (SOp LNullPtr args) =
490+ ppExp pp $ Lit Null
489491mkExp pp (SOp op args) =
490492 (mkPrimitiveFunction op args) >>= ppExp pp
491493
test/README+5−1
@@ -27,8 +27,12 @@ Tests:
2727025: memory effects
2828026: simple file-I/O-based type provider
2929027: class constraints in using block
30−028:
30+028: hello world with comment and block comment syntax in idr file
3131029: match_refine and apply by type
32+030: %reflection for functions running on syntax
33+031: error reflection
34+032: control idris via stdin
35+033: null pointer creation and check
3236
3337regxxx: various regression tests
3438reg020: working strlen
test/test033/expected+1−1
@@ -1 +1 @@
1−0
1+True
test/test033/run+2−3
@@ -1,5 +1,4 @@
11#!/bin/bash
2−gcc -c test033.c
3−idris -o test033 test033.idr
2+idris $@ -o test033 test033.idr
43./test033
5−rm -f *.ibc *.o test033
4+rm -f *.ibc test033
test/test033/test033.cdeleted−10
@@ -1,10 +0,0 @@
1−#include "test033.h"
2−#include <stddef.h>
3−
4−int testNull(void* p) {
5− if(p == NULL) {
6− return 0;
7− }
8− return 1;
9−}
10−
test/test033/test033.hdeleted−6
@@ -1,6 +0,0 @@
1−#ifndef __TEST033_H__
2−#define __TEST033_H__
3−
4−int testNull(void*);
5−
6−#endif
test/test033/test033.idr+1−7
@@ -1,10 +1,4 @@
11module Main
22
3−%include C "test033.h"
4−%link C "test033.o"
5−
6−testNull : Ptr -> IO Int
7−testNull p = mkForeign (FFun "testNull" [FPtr] FInt) p
8−
93main : IO ()
10−main = testNull null >>= (putStrLn . show)
4+main = nullPtr null >>= (putStrLn . show)