uint size; \
}; \
typedef struct Array ## name Array ## name; \
- inline Array ## name * allocArray ## name(uint size) { \
+ static inline Array ## name * allocArray ## name(uint size) { \
Array ## name * tmp = (Array ## name *)ourmalloc(sizeof(type)); \
tmp->size = size; \
tmp->array = (type *) ourcalloc(1, sizeof(type) * size); \
return tmp; \
} \
- inline Array ## name * allocArrayInit ## name(type * array, uint size) { \
+ static inline Array ## name * allocArrayInit ## name(type * array, uint size) { \
Array ## name * tmp = allocArray ## name(size); \
memcpy(tmp->array, array, size * sizeof(type)); \
return tmp; \
} \
- inline type getArray ## name(Array ## name * This, uint index) { \
+ static inline type getArray ## name(Array ## name * This, uint index) { \
return This->array[index]; \
} \
- inline void setArray ## name(Array ## name * This, uint index, type item) { \
+ static inline void setArray ## name(Array ## name * This, uint index, type item) { \
This->array[index]=item; \
} \
- inline uint getSizeArray ## name(Array ## name *This) { \
+ static inline uint getSizeArray ## name(Array ## name *This) { \
return This->size; \
} \
- inline void deleteArray ## name(Array ## name *This) { \
+ static inline void deleteArray ## name(Array ## name *This) { \
ourfree(This->array); \
ourfree(This); \
} \
- inline type * exposeCArray ## name(Array ## name * This) { \
+ static inline type * exposeCArray ## name(Array ## name * This) { \
return This->array; \
} \
- inline void deleteInlineArray ## name(Array ## name *This) { \
+ static inline void deleteInlineArray ## name(Array ## name *This) { \
ourfree(This->array); \
} \
- inline void allocInlineArray ## name(Array ## name * This, uint size) { \
+ static inline void allocInlineArray ## name(Array ## name * This, uint size) { \
This->size = size; \
This->array = (type *) ourcalloc(1, sizeof(type) * size); \
} \
- inline void allocInlineArrayInit ## name(Array ## name * This, type *array, uint size) { \
+ static inline void allocInlineArrayInit ## name(Array ## name * This, type *array, uint size) { \
allocInlineArray ##name(This, size); \
memcpy(This->array, array, size * sizeof(type)); \
}
#include "structs.h"
#include "mymemory.h"
-VectorImpl(Int, uint64_t, 4);
+VectorImpl(Table, Table *, 4);
+VectorImpl(Set, Set *, 4);
VectorImpl(Boolean, Boolean *, 4);
VectorImpl(Constraint, Constraint *, 4);
-VectorImpl(Set, Set *, 4);
+VectorImpl(Function, Function *, 4);
+VectorImpl(Predicate, Predicate *, 4);
VectorImpl(Element, Element *, 4);
+VectorImpl(Order, Order *, 4);
+VectorImpl(TableEntry, TableEntry *, 4);
VectorImpl(ASTNode, ASTNode *, 4);
-HashTableImpl(Void, void *, void *, Ptr_hash_function, Ptr_equals);
-HashSetImpl(Void, void *, Ptr_hash_function, Ptr_equals);
+VectorImpl(Int, uint64_t, 4);
ArrayDef(Element, Element *);
ArrayDef(Boolean, Boolean *);
ArrayDef(Set, Set *);
-VectorDef(Int, uint64_t, 4);
+
+VectorDef(Table, Table *, 4);
+VectorDef(Set, Set *, 4);
VectorDef(Boolean, Boolean *, 4);
VectorDef(Constraint, Constraint *, 4);
-VectorDef(Set, Set *, 4);
-VectorDef(Element, Element *, 4);
-VectorDef(TableEntry, TableEntry *, 4);
+VectorDef(Function, Function *, 4);
VectorDef(Predicate, Predicate *, 4);
-VectorDef(Table, Table *, 4);
+VectorDef(Element, Element *, 4);
VectorDef(Order, Order *, 4);
-VectorDef(Function, Function *, 4);
+VectorDef(TableEntry, TableEntry *, 4);
VectorDef(ASTNode, ASTNode *, 4);
+VectorDef(Int, uint64_t, 4);
+
inline unsigned int Ptr_hash_function(void * hash) {
return (unsigned int)((uint64_t)hash >> 4);
return key1 == key2;
}
-HashTableDef(Void, void *, void *, Ptr_hash_function, Ptr_equals);
-HashSetDef(Void, void *, Ptr_hash_function, Ptr_equals);
+
#endif
debug: CFLAGS += -DCONFIG_DEBUG
debug: all
+test: all
+ make -C Test
+
PHONY += docs
docs: $(C_SOURCES) $(HEADERS)
doxygen
--- /dev/null
+buildconstraints: buildconstraints.c ../csolver.h ../classlist.h \
+ ../mymemory.h ../config.h ../AST/ops.h ../Collections/structs.h \
+ ../Collections/vector.h ../Collections/hashtable.h ../common.h \
+ ../Collections/hashset.h ../Collections/array.h
--- /dev/null
+BASE := ..
+
+OBJECTS := $(patsubst %.c, %, $(wildcard *.c))
+
+include $(BASE)/common.mk
+
+DEPS := $(join $(addsuffix ., $(dir $(OBJECTS))), $(addsuffix .d, $(notdir $(OBJECTS))))
+
+CPPFLAGS += -I$(BASE) -I$(BASE)/AST -I$(BASE)/Collections
+
+all: $(OBJECTS)
+
+-include $(DEPS)
+
+%: %.c
+ $(CC) -MMD -MF $(@D)/.$(@F).d -o $@ $< $(CPPFLAGS) -L$(BASE)/bin/ -l_cons_comp
+
+clean::
+ rm -f $(OBJECTS) $(DEPS)
--- /dev/null
+#include "csolver.h"
+
+int main(int numargs, char ** argv) {
+ CSolver * solver=allocCSolver();
+ uint64_t set1[]={0, 1, 2};
+ Set * s=createSet(solver, 0, set1, 3);
+ Element * e1=getElementVar(solver, s);
+ Element * e2=getElementVar(solver, s);
+ Set * domain[]={s, s};
+ Predicate *equals=createPredicateOperator(solver, EQUALS, domain, 2);
+ Element * inputs[]={e1, e2};
+ Boolean * b=applyPredicate(solver, equals, inputs, 2);
+ addBoolean(solver, b);
+ deleteSolver(solver);
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+ <dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleIdentifier</key>
+ <string>com.apple.xcode.dsym.buildconstraints</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>dSYM</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+ </dict>
+</plist>
--- /dev/null
+#!/bin/bash
+
+export LD_LIBRARY_PATH=../bin
+# For Mac OSX
+export DYLD_LIBRARY_PATH=../bin
+
+$@
#include <stdio.h>
#include "config.h"
+/*
extern int model_out;
extern int model_err;
extern int switch_alloc;
#define model_print_err(fmt, ...) do { model_dprintf(model_err, fmt, ## __VA_ARGS__); } while (0)
+*/
+
+#define model_print printf
+
#define NEXTPOW2(x) (1<<(sizeof(uint)*8-__builtin_clz(x-1)))
#ifdef CONFIG_DEBUG
CSolver * allocCSolver();
+/** Delete solver instance. */
+
+void deleteSolver(CSolver * This);
+
/** This function creates a set containing the elements passed in the array. */
Set * createSet(CSolver *, VarType type, uint64_t * elements, uint num);
#include "config.h"
+/*
void * ourmalloc(size_t size);
void ourfree(void *ptr);
void * ourcalloc(size_t count, size_t size);
void * ourrealloc(void *ptr, size_t size);
+*/
+
+static inline void * ourmalloc(size_t size) { return malloc(size); }
+static inline void ourfree(void *ptr) { free(ptr); }
+static inline void * ourcalloc(size_t count, size_t size) { return calloc(count, size); }
+static inline void * ourrealloc(void *ptr, size_t size) { return realloc(ptr, size); }
#endif/* _MY_MEMORY_H */