repo_name
stringlengths
5
122
path
stringlengths
3
232
text
stringlengths
6
1.05M
RabbitBio/RabbitBM
src/barcodePositionMap.h
<reponame>RabbitBio/RabbitBM #ifndef BARCODEPOSITIONMAP_H #define BARCODEPOSITIONMAP_H #include <string> #include <cstring> #include "fastqreader.h" #include "read.h" #include "util.h" #include "options.h" #include "chipMaskHDF5.h" #include "bloomFilter.h" #include <unordered_map> //#include "robin_hood.h" #include <iomanip> #include <set> #include <boost/archive/binary_iarchive.hpp> #include <boost/archive/binary_oarchive.hpp> #include <boost/serialization/string.hpp> #include <boost/serialization/unordered_map.hpp> using namespace std; class BarcodePositionMap { public: //BarcodePositionMap(vector<string>& InFile, string MaskFile, int BarcodeStart, int BarcodeLen, int Segment, int TurnFovDegree, bool IsSeq500, int RC, string readidSep = "/"); //BarcodePositionMap(string InFile, string MaskFile, int BarcodeStart, int BarcodeLen, int Segment, int TurnFovDegree, bool IsSeq500, int RC); //BarcodePositionMap(string InFile, int BarcodeStart, int BarcodeLen); BarcodePositionMap(Options *opt); ~BarcodePositionMap(); private: void rangeRefresh(Position1 &position); public: long getBarcodeTypes(); void dumpbpmap(string &mapOutFile); void loadbpmap(); unordered_map<uint64, Position1> *getBpmap() { return &bpmap; }; int *GetHashHead() const; node *GetHashMap() const; int GetHashNum() const; int GetDims1() const; BloomFilter *GetBloomFilter() const; Position1* getPosition() {return position_index;} int* getHead(){return bpmap_head;} int* getNext(){return bpmap_nxt;} uint64* getKey() {return bpmap_key;} int* getValue(){return bpmap_value;} int* getLen(){return bpmap_len;} BloomFilter* getBloomFilter(){return bloomFilter;} bpmap_key_value* getPositionAll(){return position_all;} public: unordered_map<uint64, Position1> bpmap; //***********list-hash add by ylf************// int *hashHead; node *hashMap; int hashNum; int dims1; //******************************************// //***********bloom filter add by ylf************// BloomFilter *bloomFilter; // uint64 *bloomFilter; //******************************************// int *bpmap_head; int *bpmap_nxt; int *bpmap_value; uint64 *bpmap_key; bpmap_key_value* position_all; int *bpmap_len; Position1* position_index; Options *mOptions; set<uint64> dupBarcode; long overlapBarcodes; long dupBarcodes; string maskFile; int barcodeStart; int barcodeLen; int segment; uint32 minX = OUTSIDE_DNB_POS_COL; uint32 minY = OUTSIDE_DNB_POS_ROW; uint32 maxX = 0; uint32 maxY = 0; vector<std::string> inMasks; int slidePitch = 500; }; #endif // ! BARCODEPOSITIONMAP_H
RabbitBio/RabbitBM
src/chipMaskHDF5.h
<reponame>RabbitBio/RabbitBM #ifndef CHIPMASKHDF5_H #define CHIPMASKHDF5_H #include <iostream> #include <hdf5.h> #include <unordered_map> #include "common.h" #include <libdeflate.h> //#include "robin_hood.h" #include "util.h" #include "bloomFilter.h" #define RANK 3 #define CDIM0 1537 #define CDIM1 1537 #define DATASETNAME "bpMatrix_" #define ATTRIBUTEDIM 6 //rowShift, colShift, barcodeLength, slide pitch #define ATTRIBUTEDIM1 2 #define ATTRIBUTENAME "dnbInfo" #define ATTRIBUTENAME1 "chipInfo" using namespace std; //using namespace robin_hood; class ChipMaskHDF5 { public: ChipMaskHDF5(std::string FileName); ~ChipMaskHDF5(); void creatFile(); herr_t writeDataSet(std::string chipID, slideRange &sliderange, unordered_map<uint64, Position1> &bpMap, uint32_t BarcodeLen, uint8_t segment, uint32_t slidePitch, uint compressionLevel = 6, int index = 1); void openFile(); // void readDataSet(unordered_map<uint64, Position1> &bpMap, int index = 1); // void // readDataSet(int &headNum, int *&hashHead, node *&hashMap, int &dims1, BloomFilter *&bloomFilter, int index = 1); void readDataSet(int &headNum, int *&hashHead, node *&hashMap, int &dims1, uint64 *&bloomFilter, int index = 1); void readDataSetHashListOneArrayWithBloomFilter(uint32 &mapSize, int *&bpmap_head, int *&bpmap_nxt, bpmap_key_value *&position_all, BloomFilter *&bloomFilter, int index = 1); public: std::string fileName; hid_t fileID; uint64 ***bpMatrix; }; #endif
RabbitBio/RabbitBM
common/system.h
<reponame>RabbitBio/RabbitBM #ifndef SYSTEM_H #define SYSTEM_H #include <cstdlib> #include <exception> #include <system_error> #include <string> namespace utils { namespace system { namespace except { void throw_syserr(const std::string& what) { int errcode = errno; errno = 0; switch (errcode) { case ENOMEM: throw std::bad_alloc(); default: throw std::system_error(errcode, std::generic_category(), what); } } inline int check_ret(int ret, const std::string& what) { if (ret < 0) throw_syserr(what); return ret; } template<typename T> inline T* check_ptr(T* ret, const std::string& what) { if (ret == nullptr) throw_syserr(what); return ret; } }}} #endif // SYSTEM_H
RabbitBio/RabbitBM
libdeflatePugz.h
/* * libdeflate.h - public header for libdeflate */ #ifndef LIBDEFLATE_H #define LIBDEFLATE_H #define LIBDEFLATE_VERSION_MAJOR 0 #define LIBDEFLATE_VERSION_MINOR 8 #define LIBDEFLATE_VERSION_STRING "0.8" #include <cstddef> #include <cstdint> /* ========================================================================== */ /* Decompression */ /* ========================================================================== */ /* * Result of a call to libdeflate_deflate_decompress(), * libdeflate_zlib_decompress(), or libdeflate_gzip_decompress(). */ enum libdeflate_result { /* Decompression was successful. */ LIBDEFLATE_SUCCESS = 0, /* Decompressed failed because the compressed data was invalid, corrupt, * or otherwise unsupported. */ LIBDEFLATE_BAD_DATA = 1, /* A nullptr 'actual_out_nbytes_ret' was provided, but the data would have * decompressed to fewer than 'out_nbytes_avail' bytes. */ LIBDEFLATE_SHORT_OUTPUT = 2, /* The data would have decompressed to more than 'out_nbytes_avail' * bytes. */ LIBDEFLATE_INSUFFICIENT_SPACE = 3, }; #endif /* LIBDEFLATE_H */
RabbitBio/RabbitBM
src/FastqStream.h
<gh_stars>0 /* This file is a part of DSRC software distributed under GNU GPL 2 licence. The homepage of the DSRC project is http://sun.aei.polsl.pl/dsrc Authors: <NAME> and <NAME> Version: 2.00 */ /* This file is modified by SDU HPC lab for RabbitQC project. Last modified: JULY2019 */ #ifndef H_FASTQSTREAM #define H_FASTQSTREAM #include <unistd.h> #include <cstring> #include "Globals.h" #include "Fastq.h" #include "Buffer.h" #include "zlib/zlib.h" #include "util.h" #include "readerwriterqueue.h" #include "atomicops.h" #if defined (_WIN32) # define _CRT_SECURE_NO_WARNINGS # pragma warning(disable : 4996) // D_SCL_SECURE # pragma warning(disable : 4244) // conversion uint64 to uint32 //# pragma warning(disable : 4267) # define FOPEN fopen # define FSEEK _fseeki64 # define FTELL _ftelli64 # define FCLOSE fclose #elif __APPLE__ // Apple by default suport 64 bit file operations (Darwin 10.5+) # define FOPEN fopen # define FSEEK fseek # define FTELL ftell # define FCLOSE fclose #else # if !defined(_LARGEFILE_SOURCE) # define _LARGEFILE_SOURCE # if !defined(_LARGEFILE64_SOURCE) # define _LARGEFILE64_SOURCE # endif # endif # if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS != 64) # undef _FILE_OFFSET_BITS # endif # if !defined(_FILE_OFFSET_BITS) # define _FILE_OFFSET_BITS 64 # endif # define FOPEN fopen64 # define FSEEK fseeko64 # define FTELL ftello64 # define FCLOSE fclose #endif static const uint32 SwapBufferSize = 1 << 22; static const uint32 tmpSwapBufferSize = 1 << 20; namespace dsrc { namespace fq { class FastqFileReader { private: public: FastqFileReader(const std::string &fileName_) : swapBuffer(SwapBufferSize), bufferSize(0), eof(false), usesCrlf(false), isZipped(false) { if (ends_with(fileName_, ".gz")) { mZipFile = gzopen(fileName_.c_str(), "r"); isZipped = true; gzrewind(mZipFile); } else { mFile = FOPEN(fileName_.c_str(), "rb"); if (mFile == NULL) { throw DsrcException(("Can not open file to read: " + fileName_).c_str()); //--------------need to change----------// } } } ~FastqFileReader() { if (mFile != NULL || mZipFile != NULL) Close(); delete mFile; //delete mZipFile; } bool Eof() const { return eof; } bool ReadNextChunk(FastqDataChunk *chunk_); bool ReadNextPairedChunk(FastqDataChunk *chunk_); void Close() { if (mFile != NULL) FCLOSE(mFile); if (mZipFile != NULL && isZipped) { gzclose(mZipFile); mZipFile = NULL; } mFile = NULL; } int64 Read(byte *memory_, uint64 size_) { if (isZipped) { int64 n = gzread(mZipFile, memory_, size_); if (n == -1) cerr << "Error to read gzip file" << endl; return n; } else { int64 n = fread(memory_, 1, size_, mFile); return n; } } int64 Read(byte *buf, uint64 len, moodycamel::ReaderWriterQueue<std::pair<char *, int>> *Q, atomic_int *done, pair<char *, int> &L, int num) { pair<char *, int> now; int64 ret; int64 got = 0; if (L.second > 0) { if (L.second >= len) { memcpy(buf, L.first, len); char *tmp = new char[L.second - len]; memcpy(tmp, L.first + len, L.second - len); memcpy(L.first, tmp, L.second - len); delete[]tmp; L.second = L.second - len; ret = len; buf += ret; len -= ret; got += ret; return got; } else { memcpy(buf, L.first, L.second); ret = L.second; L.second = 0; buf += ret; len -= ret; got += ret; } } bool overWhile = false; while (len > 0) { while (Q->try_dequeue(now) == 0) { if (Q->size_approx() == 0 && *done == 1) { ret = 0; overWhile = true; break; } usleep(100); } if (overWhile) { ret = 0; break; } // printf("get some data %d\n", now.second); if (now.second <= len) { memcpy(buf, now.first, now.second); delete[] now.first; ret = now.second; } else { int move_last = now.second - len; memcpy(buf, now.first, len); memcpy(L.first, now.first + len, move_last); L.second = move_last; delete[] now.first; ret = len; } buf += ret; len -= ret; got += ret; } return got; // // int64 resSum = 0; // int64 numFor = 0; // //TODO lastInfo.size > size_ // if (lastInfo.second > size_) { // printf("lastInfo.second>size_\n"); // exit(0); // } // if (lastInfo.second != 0) { // memcpy(memory_, lastInfo.first, lastInfo.second); // resSum += lastInfo.second; // memory_ += lastInfo.second; // } // int cntt = 0; // // while (resSum < size_) { // //// if (numFor > 5000) { //// printf("num for > 5000 ,break\n"); //// break; //// } // // // std::pair<char *, int> now; // if (q->try_dequeue(now)) { // // cntt = 0; //// cout << "get one small chunk, size is " << now.second << "queue size " << q->size_approx() //// << endl; // if (resSum + now.second <= size_) { //// printf("read all small chunk to memory_...\n"); // memcpy(memory_, now.first, now.second); // resSum += now.second; // memory_ += now.second; //// printf("read after res sum is %lld\n\n", resSum); // delete[] now.first; // } else { //// printf("read part of small chunk to memory_...\n"); // int canCpoy = size_ - resSum; // memcpy(memory_, now.first, canCpoy); // resSum += canCpoy; // memory_ += canCpoy; // lastInfo.second = now.second - canCpoy; // memcpy(lastInfo.first, now.first + canCpoy, lastInfo.second); //// printf("read after res sum is %lld\n\n", resSum); // // delete[] now.first; // break; // } // } else if (q->size_approx() == 0) { // if (done == 1)break; // numFor++; //// printf("prudocer wait pugz %d\n", cntt++); //// cout << "prudocer " << num << " wait pugz " << cntt++ << " q->size_approx() " //// << q->size_approx() << endl; // usleep(100); // } // } //// printf("ok of one read, now res sum is %lld, need to read is %lld, leave %d to read next time\n", //// resSum, size_, lastInfo.second); //// printf("===============================\n"); // return resSum; } private: core::Buffer swapBuffer; uint64 bufferSize; bool eof; bool usesCrlf; bool isZipped; FILE *mFile; gzFile mZipFile; uint64 lastOneReadPos; uint64 lastTwoReadPos; uint64 GetNextRecordPos(uchar *data_, uint64 pos_, const uint64 size_); uint64 GetPreviousRecordPos(uchar *data_, uint64 pos_, const uint64 size_); void SkipToEol(uchar *data_, uint64 &pos_, const uint64 size_) { //cout << "SkipToEol " << pos_ << " " << size_ << endl; ASSERT(pos_ < size_); while (data_[pos_] != '\n' && data_[pos_] != '\r' && pos_ < size_) ++pos_; if (data_[pos_] == '\r' && pos_ < size_) { if (data_[pos_ + 1] == '\n') { usesCrlf = true; ++pos_; } } } //跳转到行首 void SkipToSol(uchar *data_, uint64 &pos_, const uint64 size_) { //std::cout<<"SkipToSol:"<<data_[pos_]<<std::endl; ASSERT(pos_ < size_); if (data_[pos_] == '\n') { --pos_; } if (data_[pos_] == '\r') { usesCrlf = true; pos_--; } //找到换行符 while (data_[pos_] != '\n' && data_[pos_] != '\r') { //std::cout<<"pos_;"<<pos_<<std::endl; --pos_; } if (data_[pos_] == '\n') { --pos_; } if (data_[pos_] == '\r') { usesCrlf = true; pos_--; } } }; } // namespace fq } // namespace dsrc #endif // H_FASTQSTREAM
manparvesh/regx.h
src/regx.h
<filename>src/regx.h<gh_stars>0 /********************************************************* * Created by manparvesh on 7/6/18. *********************************************************/ #ifndef REGX_H_REGX_H #define REGX_H_REGX_H #include <stdbool.h> /** * Search for a regex pattern in the text * */ bool search(char *pattern, char *text); /** * Search for all matches for a regex pattern in the text * */ char **search_all(char *pattern, char *text); #endif //REGX_H_REGX_H
manparvesh/regx.h
src/regx.c
/********************************************************* * Created by manparvesh on 7/6/18. *********************************************************/ #include <stdlib.h> #include <string.h> #include "regx.h" /********************************************************* * Private methods declarations *********************************************************/ bool match(char *pattern, char *text); bool match_at_beginning(char *pattern, char *text); bool match_star(int c, char *pattern, char *text); char *string_concat(const char *s1, const char *s2); /********************************************************* * Public methods implementations *********************************************************/ /** * Search for a regex pattern in the text * */ char **search_all(char *pattern, char *text) { return NULL; } /** * Search for all matches for a regex pattern in the text * */ bool search(char *pattern, char *text) { if (pattern[0] == '^') { return match(pattern + 1, text); } return match(string_concat(".*", pattern), text); } /********************************************************* * Private methods implementations *********************************************************/ bool match(char *pattern, char *text) { if (pattern[0] == '^') return match_at_beginning(pattern + 1, text); do { // must look even if string is empty if (match_at_beginning(pattern, text)) return true; } while (*text++ != '\0'); return false; } bool match_at_beginning(char *pattern, char *text) { if (pattern[0] == '\0') { return true; } if (pattern[1] == '*') { return match_star(pattern[0], pattern + 2, text); } if (pattern[0] == '$' && pattern[1] == '\0') { return *text == '\0'; } if (*text != '\0' && (pattern[0] == '.' || pattern[0] == *text)) return match_at_beginning(pattern + 1, text + 1); return false; } bool match_star(int c, char *pattern, char *text) { do { // a `*` matches zero or more instances if (match_at_beginning(pattern, text)) return true; } while (*text != '\0' && (*text++ == c || c == '.')); return false; } char *string_concat(const char *s1, const char *s2) { char *result = malloc(strlen(s1) + strlen(s2) + 1);//+1 for the null-terminator //in real code you would check for errors in malloc here strcpy(result, s1); strcat(result, s2); return result; }
manparvesh/regx.h
tests/test.c
/********************************************************* * Created by manparvesh on 7/6/18. *********************************************************/ #include <assert.h> #include "regx.h" int main(){ char *pattern = ".*"; char *text = "abcdfseirjhewo34434jj"; assert(search(pattern, text)); pattern = "1."; text = "as34434jj"; assert(!search(pattern, text)); pattern = "^3."; text = "34434jj"; assert(search(pattern, text)); pattern = "^a3."; text = "as34434jj"; assert(!search(pattern, text)); pattern = "jj$"; text = "as34434jj"; assert(search(pattern, text)); pattern = ".*j$"; text = "as34434jj"; assert(search(pattern, text)); pattern = ".*j"; text = "as34434jj"; assert(search(pattern, text)); pattern = "^a.*j$"; text = "as34434jj"; assert(search(pattern, text)); pattern = ".*j$"; text = "as34434jj"; assert(search(pattern, text)); pattern = "3.*j$"; text = "as34434jj"; assert(search(pattern, text)); pattern = ".*4"; text = "as34434jj"; assert(search(pattern, text)); }
DiplexSoftfork/Skyrcoin
src/chainparamsseeds.h
#ifndef BITCOIN_CHAINPARAMSSEEDS_H #define BITCOIN_CHAINPARAMSSEEDS_H /** * List of fixed seed nodes for the bitcoin network * AUTOGENERATED by contrib/seeds/generate-seeds.py * * Each line contains a 16-byte IPv6 address and a port. * IPv4 as well as onion addresses are wrapped inside an IPv6 address accordingly. */ static SeedSpec6 pnSeed6_main[] = { {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x2d,0x09,0x49,0xcf}, PORT_MAINNET}, {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xcf,0xb4,0xe2,0x66}, PORT_MAINNET}, {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xb9,0xc3,0x18,0xdf}, PORT_MAINNET}, {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x50,0x59,0xea,0xc5}, PORT_MAINNET}, {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x4d,0x29,0xbe,0xb5}, PORT_MAINNET}, {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xa4,0x44,0x6f,0x32}, PORT_MAINNET}, {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x4b,0x77,0x9c,0x90}, PORT_MAINNET} }; static SeedSpec6 pnSeed6_test[] = { // {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x2d,0x23,0xfb,0x45}, PORT_TESTNET}, // {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x33,0x59,0x2e,0xe6}, PORT_TESTNET}, // {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x68,0x80,0xe0,0xbc}, PORT_TESTNET}, // {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xb9,0x51,0xa6,0x3c}, PORT_TESTNET}, // {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xc2,0x87,0x54,0x6f}, PORT_TESTNET}, // {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xc2,0x87,0x59,0x3f}, PORT_TESTNET}, // {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xd4,0x18,0x66,0x01}, PORT_TESTNET}, // {{0x2a,0x02,0x7b,0x40,0xc2,0x87,0x59,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01}, PORT_TESTNET}, // {{0x26,0x02,0xff,0xc5,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xe0,0xa7}, PORT_TESTNET}, // {{0x26,0x02,0xff,0xc5,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x3c,0xef}, PORT_TESTNET}, // {{0xfd,0x87,0xd8,0x7e,0xeb,0x43,0xb9,0x78,0x28,0x21,0xcb,0x89,0x95,0x66,0xda,0xb0}, PORT_TESTNET}, // {{0xfd,0x87,0xd8,0x7e,0xeb,0x43,0x90,0xcc,0x09,0x4e,0x04,0x89,0x76,0x42,0x3c,0x0c}, PORT_TESTNET}, // {{0xfd,0x87,0xd8,0x7e,0xeb,0x43,0xa3,0xe1,0xaf,0xa8,0xbd,0xfc,0x7a,0xe0,0xa0,0x63}, PORT_TESTNET}, // {{0xfd,0x87,0xd8,0x7e,0xeb,0x43,0xc1,0x35,0x0f,0x23,0x8e,0x15,0x10,0xda,0xa3,0x60}, PORT_TESTNET}, // {{0xfd,0x87,0xd8,0x7e,0xeb,0x43,0x24,0xd3,0xb1,0x53,0xf2,0x6a,0x4f,0x75,0xf2,0xb8}, PORT_TESTNET}, // {{0xfd,0x87,0xd8,0x7e,0xeb,0x43,0x09,0xde,0xde,0x93,0x3d,0xbc,0x33,0x08,0xfb,0x2a}, PORT_TESTNET}, // {{0xfd,0x87,0xd8,0x7e,0xeb,0x43,0x2b,0x2b,0xbe,0x13,0xc0,0x7c,0x61,0x6e,0x6b,0xf6}, PORT_TESTNET} }; #endif // BITCOIN_CHAINPARAMSSEEDS_H
calcmogul/sysid
sysid-application/src/main/native/include/sysid/generation/HardwareType.h
<reponame>calcmogul/sysid // Copyright (c) FIRST and other WPILib contributors. // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. #pragma once #include <array> #include <string_view> namespace sysid { /** * Stores information of a specific hardware device that sysid supports so that * it can be easily identified, used, and displayed. */ struct HardwareType { /** * The name of the hardware device to facillitate comparisons */ std::string_view name; /** * The display name of the hardware device to facilitate GUI display */ const char* displayName; /** * Creates a HardwareType object from a device name. * * @param deviceName The name of the hardware device. */ constexpr explicit HardwareType(std::string_view deviceName) : name{deviceName}, displayName{name.data()} {} /** * Equality operator between HardwareTypes * * @param rhs Another HardwareType * @returns True if they are equal */ constexpr bool operator==(const HardwareType& rhs) const { return name == rhs.name; } /** * Inequality operator between HardwareTypes * * @param rhs Another HardwareType * @returns True if they are not equal */ constexpr bool operator!=(const HardwareType& rhs) const { return !operator==(rhs); } }; namespace motorcontroller { constexpr HardwareType kPWM{"PWM"}; constexpr HardwareType kTalonSRX{"TalonSRX"}; constexpr HardwareType kVictorSPX{"VictorSPX"}; constexpr HardwareType kTalonFX{"TalonFX"}; constexpr HardwareType kSPARKMAXBrushless{"SPARK MAX (Brushless)"}; constexpr HardwareType kSPARKMAXBrushed{"SPARK MAX (Brushed)"}; constexpr HardwareType kVenom{"Venom"}; constexpr std::array<HardwareType, 7> kMotorControllers = { kPWM, kTalonSRX, kVictorSPX, kTalonFX, kSPARKMAXBrushless, kSPARKMAXBrushed, kVenom}; /** * Returns an existing motor controller HardwareType from a string_view. Throws * if the passed name doesn't exist. * * @param name The name of the motor controller. * @return The motor controller HardwareType associated with the inputted name. */ HardwareType FromMotorControllerName(std::string_view name); } // namespace motorcontroller namespace encoder { constexpr HardwareType kRoboRIO{"roboRIO quadrature"}; constexpr HardwareType kCANCoder{"CANCoder"}; constexpr HardwareType kBuiltInSetting{"Built-in"}; constexpr HardwareType kCTRETachometer{"Tachometer"}; constexpr HardwareType kSMaxEncoderPort{"Encoder Port"}; constexpr HardwareType kSMaxDataPort{"Data Port"}; constexpr std::array<HardwareType, 6> kEncoders = { kRoboRIO, kCANCoder, kBuiltInSetting, kCTRETachometer, kSMaxEncoderPort, kSMaxDataPort}; /** * Returns an existing encoder HardwareType from a string_view. Throws if the * passed name doesn't exist. * * @param name The name of the encoder. * @return The encoder HardwareType associated with the inputted name. */ HardwareType FromEncoderName(std::string_view name); } // namespace encoder namespace gyro { constexpr HardwareType kAnalogGyro{"Analog Gyro"}; constexpr HardwareType kADXRS450{"ADXRS450"}; constexpr HardwareType kNavX{"NavX"}; constexpr HardwareType kPigeon{"Pigeon"}; constexpr HardwareType kRomiGyro{"Romi"}; constexpr HardwareType kNoGyroOption{"None"}; constexpr std::array<HardwareType, 6> kGyros = { kAnalogGyro, kADXRS450, kNavX, kPigeon, kRomiGyro, kNoGyroOption}; /** * Returns an existing gyro HardwareType from a string_view. Throws if the * passed name doesn't exist. * * @param name The name of the gyro. * @return The gyro HardwareType associated with the inputted name. */ HardwareType FromGyroName(std::string_view name); } // namespace gyro } // namespace sysid
calcmogul/sysid
sysid-application/src/main/native/include/sysid/analysis/AngularDriveSim.h
<gh_stars>10-100 // Copyright (c) FIRST and other WPILib contributors. // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. #pragma once #include <Eigen/Core> #include <units/time.h> #include <units/voltage.h> namespace sysid { /** * Simulates an angular drivetrain. This is primarily intended for unit testing * purposes. */ class AngularDriveSim { public: /** * @param Ks Static friction gain in linear units. * @param Kv Velocity gain in linear units. * @param Ka Acceleration gain in linear units. * @param trackwidth Trackwidth of the drivetrain. * @param initialPosition Initial angle in radians. * @param initialVelocity Initial angular velocity in radians per second. */ AngularDriveSim(double Ks, double Kv, double Ka, double trackwidth, double initialPosition = 0.0, double initialVelocity = 0.0); /** * Simulates affine state-space system dx/dt = Ax + Bu + c sgn(x) forward dt * seconds. * * @param voltage Voltage to apply over the timestep. * @param dt Sammple period. */ void Update(units::volt_t voltage, units::second_t dt); /** * Returns the position. * * @return The current position */ double GetPosition() const; /** * Returns the velocity. * * @return The current velocity */ double GetVelocity() const; /** * Returns the acceleration for the current state and given input. * * @param voltage The voltage that is being applied to the mechanism / input * @return The acceleration given the state and input */ double GetAcceleration(units::volt_t voltage) const; /** * Resets model position and velocity. * * @param position The position the mechanism should be reset to * @param velocity The velocity the mechanism should be reset to */ void Reset(double position = 0.0, double velocity = 0.0); private: Eigen::Matrix<double, 2, 2> m_A; Eigen::Matrix<double, 2, 1> m_B; Eigen::Vector<double, 2> m_c; Eigen::Vector<double, 2> m_x; double m_trackwidth; }; } // namespace sysid
G33kDude/tinycomputer
src/assembler/macros.h
#pragma once #include <string> #include <vector> #include <map> #include <cstring> // strlen #include "lines.h" #define MACRO_START "!@" #define MACRO_END "!" #define MACRO_REF "@" namespace macros { struct macro { std::string name; std::vector<lines::line> repl; }; using macros = std::map<std::string,macro>; lines::lines process_macros(lines::lines &lines); lines::lines find_macros( lines::lines &lines, std::map<std::string,macro> &macros); lines::lines replace_macros( lines::lines &input_lines, macros &input_macros); void split_macro( std::string &macrogtext, std::string &macroname, std::string &macrorepl); }
G33kDude/tinycomputer
src/assembler/assemble.h
#pragma once #include <algorithm> #include <array> #include <vector> #include "lines.h" #include "labels.h" #define ASM_BIT_PTR 1 << 2 #define ASM_TYPE_LITRL 1 << 0 #define ASM_TYPE_RWRAM 1 << 1 #define ASM_TYPE_RORAM 1 << 2 #define ASM_TYPE_LABEL 1 << 3 namespace assemble { using instruction = std::array<unsigned short, 4>; using instructions = std::vector<instruction>; instructions assemble( lines::lines &input_lines, labels::labels &input_labels); instruction parse(lines::line &input_line, labels::labels &input_labels, int i); }
G33kDude/tinycomputer
src/assembler/labels.h
#pragma once #include <map> #include "lines.h" namespace labels { using labels = std::map<std::string, int>; lines::lines find_labels(lines::lines &input_lines, labels &found_labels); }
G33kDude/tinycomputer
src/assembler/lines.h
<gh_stars>1-10 #pragma once #include <iostream> #include <vector> #include <string> #define COMMENT_CHAR "#" #define WHITESPACE " \t" namespace lines { struct line { int number; std::string text; }; void trim_line(line &input); using lines = std::vector<line>; lines lines_from_cin(); lines clean_lines(lines &lines); std::vector<std::string> split_line(line input); }
joshbainbridge/morphogenetic-sim
include/RenderThread.h
<filename>include/RenderThread.h #ifndef _RENDERTHREAD_H_ #define _RENDERTHREAD_H_ #include <boost/thread.hpp> #include <boost/shared_ptr.hpp> #include <Scene.h> #include <Settings.h> #include <Image.h> #include <TaskStack.h> #include <Task.h> #include <IntegratorInterface.h> #include <RandomGenerator.h> class RenderThread { public: RenderThread( boost::shared_ptr<Scene> _scene_ptr, boost::shared_ptr<Settings> _settings_ptr, boost::shared_ptr<Image> _image_ptr, boost::shared_ptr<TaskStack> _task_stack_ptr, boost::shared_ptr<IntegratorInterface> _integrator ); void start(); void join(); void process(); private: boost::thread m_thread; boost::shared_ptr<Scene> m_scene_ptr; boost::shared_ptr<Settings> m_settings_ptr; boost::shared_ptr<Image> m_image_ptr; boost::shared_ptr<RandomGenerator> m_random_generator; boost::shared_ptr<TaskStack> m_task_stack_ptr; boost::shared_ptr<IntegratorInterface> m_integrator; Task m_task; }; #endif
joshbainbridge/morphogenetic-sim
include/IntegratorInterface.h
#ifndef _INTEGRATORINTERFACE_H_ #define _INTEGRATORINTERFACE_H_ #include <boost/shared_ptr.hpp> #include <Scene.h> #include <RandomGenerator.h> #include <Common.h> class IntegratorInterface { public: IntegratorInterface() : m_current_depth(0), m_limit_depth(0), m_absorption(0.f) {;} virtual ~IntegratorInterface() {} virtual Colour3f run(const boost::shared_ptr<Scene> _scene, boost::shared_ptr<RandomGenerator> _random_generator, const Ray3f _sample, const Colour3f _contribution) = 0; inline int currentDepth() const {return m_current_depth;} inline int limitDepth() const {return m_limit_depth;} inline float absorption() const {return m_absorption;} inline void currentDepth(const int _current_depth){m_current_depth = _current_depth;} inline void limitDepth(const int _limit_depth){m_limit_depth = _limit_depth;} inline void absorption(const float _absorption){m_absorption = _absorption;} protected: int m_current_depth; int m_limit_depth; float m_absorption; }; #endif
joshbainbridge/morphogenetic-sim
include/Aabb.h
<gh_stars>1-10 #ifndef _AABB_H_ #define _AABB_H_ #include <Common.h> class Aabb { public: Aabb() : m_min(Vector3f(0.f, 0.f, 0.f)), m_max(Vector3f(0.f, 0.f, 0.f)) {;} Aabb(const Vector3f _min, const Vector3f _max) : m_min(_min), m_max(_max) {;} inline Vector3f min() const {return m_min;} inline Vector3f max() const {return m_max;} void updateAabb(const Aabb _input_AABB); void updateAabb(const Vector3f _input_vector); bool intersect(const Ray3f _ray) const; private: Vector3f m_min; Vector3f m_max; }; #endif
joshbainbridge/morphogenetic-sim
include/Settings.h
#ifndef _SETTINGS_H_ #define _SETTINGS_H_ struct Settings { Settings() : resolution_x(0) , resolution_y(0) , bucket_size(0) , frame_number(0) , samples(0) , depth(0) , absorption(0.f) {;} int resolution_x; int resolution_y; int bucket_size; int frame_number; int samples; int depth; float absorption; }; #endif
joshbainbridge/morphogenetic-sim
include/TaskStack.h
<gh_stars>1-10 #ifndef _TASKSTACK_H_ #define _TASKSTACK_H_ #include <vector> #include <boost/thread.hpp> #include <Task.h> class TaskStack { public: TaskStack() : m_count(0) , m_total(0) , m_percentage(1.f) {;} void addTask(const Task _task); int takeTask(Task *_task); private: std::vector<Task> m_tasks; int m_count; int m_total; float m_percentage; boost::mutex m_mutex; }; #endif
joshbainbridge/morphogenetic-sim
include/HierarchicalAggregate.h
#ifndef _HIERARCHICALAGGREGATE_H_ #define _HIERARCHICALAGGREGATE_H_ // Currently just looping over all primitives in list #endif
joshbainbridge/morphogenetic-sim
include/Common.h
<reponame>joshbainbridge/morphogenetic-sim<filename>include/Common.h #ifndef _COMMON_H_ #define _COMMON_H_ #include <cfloat> #include <cmath> #include <Eigen/Core> #include <Eigen/Geometry> //Common defines constants and linear algebraic types used through out the project //Algebraic types are based on the Eigen library that is optimised for expression templating, cache coherency and SSE vectorizaion #ifdef M_PI #undef M_PI #endif #define M_PI 3.14159265358979323846f #define M_INV_PI 0.31830988618379067154f #define M_PI_180 0.01745329251994329577f #define M_180_PI 57.2957795130823208768f #define M_EPSILON FLT_EPSILON #define M_INFINITY FLT_MAX template < typename t_origin, typename t_direction > struct Ray { t_origin origin; t_direction dir; }; template < typename type > bool compare(const type _a, const type _b) { return std::fabs(static_cast<float>(_a) - static_cast<float>(_b)) < M_EPSILON; } typedef Eigen::Matrix< float, 2, 1 > Vector2f; typedef Eigen::Matrix< float, 3, 1 > Vector3f; typedef Eigen::Matrix< float, 4, 1 > Vector4f; typedef Eigen::Matrix< float, 4, 4 > TransMatrix; typedef Ray< Vector2f, Vector2f > Ray2f; typedef Ray< Vector3f, Vector3f > Ray3f; typedef Ray< Vector4f, Vector4f > Ray4f; typedef Eigen::Array< float, 3, 1 > Colour3f; #endif
joshbainbridge/morphogenetic-sim
include/Scene.h
<reponame>joshbainbridge/morphogenetic-sim #ifndef _SCENE_H_ #define _SCENE_H_ #include <vector> #include <boost/shared_ptr.hpp> #include <CameraInterface.h> #include <LightInterface.h> #include <Primitive.h> #include <ShapeInterface.h> #include <Transmission.h> class Scene { public: inline void setCamera(boost::shared_ptr< CameraInterface > _camera) {m_camera = _camera;} inline void addLight(boost::shared_ptr< LightInterface > _light) {m_lights.push_back(_light);} inline void addShape(boost::shared_ptr< ShapeInterface > _shape) {m_shapes.push_back(_shape);} inline void addPrimitive(boost::shared_ptr< Primitive > _primitive) {m_primitives.push_back(_primitive);} inline boost::shared_ptr< CameraInterface > getCamera() const {return m_camera;} inline boost::shared_ptr< LightInterface > getLight(int _index) const {return m_lights[_index];} inline boost::shared_ptr< ShapeInterface > getShape(int _index) const {return m_shapes[_index];} inline boost::shared_ptr< Primitive > getPrimitive(int _index) const {return m_primitives[_index];} inline int countLight() const {return m_lights.size();} inline int countShape() const {return m_shapes.size();} inline int countPrimitive() const {return m_primitives.size();} bool intersectPrimitives(const Ray3f _ray, Transmission *_output) const; private: boost::shared_ptr< CameraInterface > m_camera; std::vector< boost::shared_ptr< LightInterface > > m_lights; std::vector< boost::shared_ptr< ShapeInterface > > m_shapes; std::vector< boost::shared_ptr< Primitive > > m_primitives; }; #endif
joshbainbridge/morphogenetic-sim
include/Transmission.h
<gh_stars>1-10 #ifndef _TRANSMISSION_H_ #define _TRANSMISSION_H_ #include <boost/shared_ptr.hpp> #include <Common.h> #include <Material.h> struct Transmission { Transmission() : distance(M_INFINITY) {;} Vector3f position; Vector3f normal; float distance; boost::shared_ptr<Material> material; }; #endif
joshbainbridge/morphogenetic-sim
include/QuadLight.h
<gh_stars>1-10 #ifndef _QUADLIGHT_H_ #define _QUADLIGHT_H_ #include <LightInterface.h> #include <RandomGenerator.h> class QuadLight : public LightInterface { public: QuadLight() : LightInterface() {;} inline void illumination(const Colour3f &_illum){m_illum = _illum;} Colour3f illumination(const Vector3f &light_direction) const; Vector3f sampleLight(RandomGenerator &_random_generator) const; }; #endif
joshbainbridge/morphogenetic-sim
include/RandomGenerator.h
#ifndef _RANDOMGENERATOR_H_ #define _RANDOMGENERATOR_H_ #include <boost/random.hpp> class RandomGenerator { public: float getValue(); private: boost::mt19937 m_generator; boost::uniform_real<float> m_uniform_dist; }; #endif
joshbainbridge/morphogenetic-sim
include/Image.h
#ifndef _IMAGE_H_ #define _IMAGE_H_ #include <vector> #include <boost/thread.hpp> #include <Pixel.h> #include <Transmission.h> #include <Task.h> #include <Common.h> class Image { public: Image() : m_resolution_x(0), m_resolution_y(0) {;} void resolution(const int _resolution_x, const int _resolution_y); void addSample(const int _pixel_x, const int _pixel_y, const Colour3f _sample); void addBucket(const Task &_task, const std::vector< std::vector< std::vector< Colour3f > > > &_bucket); std::vector< std::vector< Colour3f > > getImage(); void clearImage(); private: std::vector< std::vector<Pixel> > m_pixels; int m_resolution_x; int m_resolution_y; boost::mutex m_mutex; float gamma(const float _value, const float _gamma) const; float clamp(const float _value, const float _min, const float _max) const; }; #endif
joshbainbridge/morphogenetic-sim
include/LightInterface.h
<filename>include/LightInterface.h #ifndef _LIGHTINTERFACE_H_ #define _LIGHTINTERFACE_H_ #include <Common.h> #include <RandomGenerator.h> class LightInterface { public: LightInterface() : m_illum(Vector3f(1.f, 1.f, 1.f)) , m_origin(Vector3f(0.f, 0.f, 0.f)) , m_dir(Vector3f(0.f, 0.f, 1.f)) , m_up(Vector3f(0.f, 1.f, 0.f)) , m_right(Vector3f(1.f, 0.f, 0.f)) , m_width(1.f) , m_height(1.f) , m_sine_exponent(1.f) {;} virtual ~LightInterface() {} virtual Vector3f sampleLight(RandomGenerator &_random_generator) const =0; virtual Colour3f illumination(const Vector3f &light_direction) const =0; inline Vector3f origin() const {return m_origin;} inline Vector3f direction() const {return m_dir;} inline Vector3f up() const {return m_up;} inline Vector3f right() const {return m_right;} inline float width() const {return m_width;} inline float height() const {return m_height;} inline float exponent() const {return m_sine_exponent;} inline void origin(const Vector3f &_origin){m_origin = _origin;} inline void width(const float &_width){m_width = _width;} inline void height(const float &_height){m_height = _height;} inline void exponent(const float &_sine_exponent){m_sine_exponent = _sine_exponent;} void direction(const Vector3f &_dir); protected: Colour3f m_illum; Vector3f m_origin; Vector3f m_dir; Vector3f m_up; Vector3f m_right; float m_width; float m_height; float m_sine_exponent; }; #endif
joshbainbridge/morphogenetic-sim
include/TissueShape.h
<gh_stars>1-10 #ifndef _TISSUESHAPE_H_ #define _TISSUESHAPE_H_ #include <vector> #include <boost/shared_ptr.hpp> #include <boost/random.hpp> #include <Common.h> #include <CellShape.h> #include <ShapeInterface.h> #include <RandomGenerator.h> class TissueShape : public ShapeInterface { public: TissueShape(); inline float springFactor() const {return m_spring_factor;} inline float planarFactor() const {return m_planar_factor;} inline float bulgeFactor() const {return m_bulge_factor;} inline float linkRestLength() const {return m_link_rest_length;} inline float repulsionFactor() const {return m_repulsion_factor;} inline float repulsionRadius() const {return m_repulsion_radius;} inline float timeStep() const {return m_time_step;} inline void springFactor(const float _spring_factor){m_spring_factor = _spring_factor;} inline void planarFactor(const float _planar_factor){m_planar_factor = _planar_factor;} inline void bulgeFactor(const float _bulge_factor){m_bulge_factor = _bulge_factor;} inline void linkRestLength(const float _link_rest_length){m_link_rest_length = _link_rest_length;} inline void repulsionFactor(const float _repulsion_factor){m_repulsion_factor = _repulsion_factor;} inline void repulsionRadius(const float _repulsion_radius){m_repulsion_radius = _repulsion_radius;} inline void timeStep(const float _time_step){m_time_step = _time_step;} bool intersect(const Ray3f _ray, Transmission *_output) const; Vector3f position() const; Vector3f AABBmin() const; Vector3f AABBmax() const; void construction(); void simulate(); int exportData(float *_input) const; private: std::vector< boost::shared_ptr<CellShape> > m_cells; int m_count; int m_feed; float m_spring_factor; float m_planar_factor; float m_bulge_factor; float m_link_rest_length; float m_repulsion_factor; float m_repulsion_radius; float m_time_step; RandomGenerator m_feeder; boost::mt19937 m_generator; int modulus(const int _a, const int _b) const; void collisionOffset(boost::shared_ptr<CellShape> _current_cell); void splitCell(boost::shared_ptr<CellShape> _current_cell); }; #endif
joshbainbridge/morphogenetic-sim
include/Engine.h
#ifndef _ENGINE_H_ #define _ENGINE_H_ #include <vector> #include <string> #include <boost/shared_ptr.hpp> #include <Scene.h> #include <Settings.h> #include <Image.h> #include <TaskStack.h> #include <RenderThread.h> #include <IntegratorInterface.h> class Engine { public: Engine(); void run(boost::shared_ptr<Scene> _scene, boost::shared_ptr<Settings> _settings); private: boost::shared_ptr<Scene> m_scene; boost::shared_ptr<Settings> m_settings; boost::shared_ptr<Image> m_image; boost::shared_ptr<TaskStack> m_task_stack; std::vector< boost::shared_ptr<RenderThread> > m_render_threads; int m_nthreads; void construct(boost::shared_ptr<Scene> _scene, boost::shared_ptr<Settings> _settings); void createThreads(); void createTasks(); void startThreads(); void saveImage(); void clean(); }; #endif
joshbainbridge/morphogenetic-sim
include/Task.h
<gh_stars>1-10 #ifndef _TASK_H_ #define _TASK_H_ struct Task { Task() : pixel_x(0) , pixel_y(0) , width(0) , height(0) , samples(0) {;} int pixel_x; int pixel_y; int width; int height; int samples; }; #endif
joshbainbridge/morphogenetic-sim
include/PlanarLightAbstract.h
<reponame>joshbainbridge/morphogenetic-sim<filename>include/PlanarLightAbstract.h #ifndef _PLANARLIGHTABSTRACT_H_ #define _PLANARLIGHTABSTRACT_H_ //Currently Implementing both planar lights directly #endif
joshbainbridge/morphogenetic-sim
include/LambertBsdf.h
#ifndef _LAMBERTBSDF_H_ #define _LAMBERTBSDF_H_ #include <Common.h> #include <RandomGenerator.h> #include <BsdfInterface.h> class LambertBsdf : public BsdfInterface { public: Vector3f sample(const Vector3f &_incident, const Vector3f &_normal, RandomGenerator &_random_generator) const; float evaluate(const Vector3f &_incident, const Vector3f &_reflection, const Vector3f &_normal) const; float pdf(const Vector3f &_incident, const Vector3f &_reflection, const Vector3f &_normal) const; private: Vector3f rejectionSample(const Vector3f &_normal, RandomGenerator &_random_generator) const; }; #endif
joshbainbridge/morphogenetic-sim
include/Material.h
<reponame>joshbainbridge/morphogenetic-sim<gh_stars>1-10 #ifndef _MATERIAL_H_ #define _MATERIAL_H_ #include <boost/shared_ptr.hpp> #include <Common.h> #include <BsdfInterface.h> #include <RandomGenerator.h> class Material { public: Material(boost::shared_ptr< BsdfInterface > _bsdf); inline Colour3f colour() const {return m_colour;} inline boost::shared_ptr< BsdfInterface > bsdf() const {return m_bsdf;} inline void colour(const Colour3f &_colour){m_colour = _colour;} inline void bsdf(const boost::shared_ptr< BsdfInterface > &_bsdf){m_bsdf = _bsdf;} Ray3f sample(const Vector3f &_incident, const Vector3f &_position, const Vector3f &_normal, RandomGenerator &_random_generator) const; Colour3f evaluate(const Vector3f &_incident, const Vector3f &_reflection, const Vector3f &_position, const Vector3f &_normal) const; private: Colour3f m_colour; boost::shared_ptr< BsdfInterface > m_bsdf; }; #endif
joshbainbridge/morphogenetic-sim
include/CellShape.h
#ifndef _CELLSHAPE_H_ #define _CELLSHAPE_H_ #include <vector> #include <boost/shared_ptr.hpp> #include <Common.h> #include <SphereShape.h> #include <RandomGenerator.h> class CellShape : public SphereShape { public: CellShape(int _identifier) : SphereShape() , m_nutrition(0.f) , m_identifier(_identifier) , m_target_pos(Vector3f(0.f, 0.f, 0.f)) , m_normal(Vector3f(0.f, 0.f, 0.f)) {;} inline float nutrition() const {return m_nutrition;} inline int identifier() const {return m_identifier;} inline Vector3f targetPosition() const {return m_target_pos;} inline Vector3f normal() const {return m_normal;} inline int linkListSize() const {return m_links.size();} inline boost::shared_ptr<CellShape> getLink(const int _index) const {return m_links[_index];} inline void targetPosition(const Vector3f &_target_pos){m_target_pos = _target_pos;} inline void normal(const Vector3f &_normal){m_normal = _normal;} inline void nutrition(const float &_nutrition){m_nutrition = _nutrition;} inline void identifier(const unsigned int &_identifier){m_identifier = _identifier;} inline void setLink(const int _index, boost::shared_ptr<CellShape> _cell){m_links[_index] = _cell;} void addLink(const boost::shared_ptr<CellShape> &_link); void insertLink(const int _index, const boost::shared_ptr<CellShape> &_link); void eraseLink(const int _index); int findLink(const int _identifier) const; void addNutrition(RandomGenerator &_random_sampler); void calculateNormal(); void findTarget(const float _spring_factor, const float _planar_factor, const float _bulge_factor, const float _link_rest_length); void update(const float _time_step); private: std::vector< boost::shared_ptr<CellShape> > m_links; float m_nutrition; int m_identifier; Vector3f m_target_pos; Vector3f m_normal; Vector3f springTarget(const float _link_rest_length) const; Vector3f planarTarget() const; Vector3f bulgeTarget(const float _link_rest_length) const; }; #endif
joshbainbridge/morphogenetic-sim
include/SphereShape.h
<filename>include/SphereShape.h #ifndef _SPHERESHAPE_H_ #define _SPHERESHAPE_H_ #include <ShapeInterface.h> #include <Common.h> #include <Transmission.h> class SphereShape : public ShapeInterface { public: SphereShape() : m_pos(Vector3f(0.f, 0.f, 0.f)), m_rad(1.f) {;} inline Vector3f position() const {return m_pos;} inline float radius() const {return m_rad;} inline void position(const Vector3f &_pos){m_pos = _pos;} inline void radius(const float _rad){m_rad = _rad;} bool intersect(const Ray3f _ray, Transmission *_output) const; Vector3f AABBmin() const { return Vector3f(m_pos.x() - m_rad, m_pos.y() - m_rad, m_pos.z() - m_rad); } Vector3f AABBmax() const { return Vector3f(m_pos.x() + m_rad, m_pos.y() + m_rad, m_pos.z() + m_rad); } protected: Vector3f m_pos; float m_rad; }; #endif
joshbainbridge/morphogenetic-sim
include/CameraInterface.h
#ifndef _CAMERAINTERFACE_H_ #define _CAMERAINTERFACE_H_ #include <Common.h> #include <RandomGenerator.h> class CameraInterface { public: virtual ~CameraInterface() {} inline Vector3f direction() const {return m_dir;} inline Vector3f origin() const {return m_origin;} inline Vector3f up() const {return m_up;} inline Vector3f right() const {return m_right;} inline float distance() const {return m_dist;} inline float ratio() const {return m_ratio;} inline void origin(const Vector3f &_origin){m_origin = _origin;} inline void distance(const float &_dist){m_dist = _dist;} inline void ratio(const float &_ratio){m_ratio = _ratio;} void direction(const Vector3f &_dir); virtual void makeSample(const float xpos, const float ypos, Vector3f *ray_origin, Vector3f *ray_direction, RandomGenerator &_random_generator) const =0; protected: //Protected variables Vector3f m_origin; Vector3f m_dir; Vector3f m_up; Vector3f m_right; float m_dist; float m_ratio; }; #endif
joshbainbridge/morphogenetic-sim
include/GeometricCamera.h
<reponame>joshbainbridge/morphogenetic-sim #ifndef _GEOMETRICCAMERA_H_ #define _GEOMETRICCAMERA_H_ #include <Common.h> #include <CameraInterface.h> #include <RandomGenerator.h> class GeometricCamera : public CameraInterface { public: GeometricCamera(); inline float aperture() const {return m_aperture;} inline float focalDistance() const {return m_focal_dist;} inline void aperture(const float &_aperture){m_aperture = _aperture;} inline void focalDistance(const float &_focal_dist){m_focal_dist = _focal_dist;} void makeSample(const float xpos, const float ypos, Vector3f *ray_origin, Vector3f *ray_direction, RandomGenerator &_random_generator) const; private: float m_aperture; float m_focal_dist; Vector2f rejection_sample_circle(RandomGenerator &_random_generator) const; }; #endif
joshbainbridge/morphogenetic-sim
include/ShapeInterface.h
#ifndef _SHAPEINTERFACE_H_ #define _SHAPEINTERFACE_H_ #include <Common.h> #include <Transmission.h> class ShapeInterface { public: virtual ~ShapeInterface() {} virtual bool intersect(const Ray3f _ray, Transmission *_output) const =0; virtual Vector3f position() const =0; virtual Vector3f AABBmin() const =0; virtual Vector3f AABBmax() const =0; }; #endif
joshbainbridge/morphogenetic-sim
include/Primitive.h
#ifndef _PRIMITIVE_H_ #define _PRIMITIVE_H_ #include <vector> #include <boost/shared_ptr.hpp> #include <Common.h> #include <Material.h> #include <ShapeInterface.h> #include <Transmission.h> #include <Aabb.h> class Primitive { public: Primitive(boost::shared_ptr<ShapeInterface> _shape, boost::shared_ptr<Material> _material); inline TransMatrix transform() const {return m_transform;} inline Aabb aabb() const {return m_aabb;} inline void transform(const TransMatrix &_transform){m_transform = _transform;} bool intersect(const Ray3f _ray, Transmission *_output) const; void addPrimitive(boost::shared_ptr<Primitive> _primitive); boost::shared_ptr<Primitive> getPrimitive(const int _index) const; void clearPrimitives(); void updateAabb(); private: boost::shared_ptr<ShapeInterface> m_shape; boost::shared_ptr<Material> m_material; std::vector< boost::shared_ptr<Primitive> > m_primitives; int m_primitive_count; TransMatrix m_transform; Aabb m_aabb; }; #endif
joshbainbridge/morphogenetic-sim
include/BsdfInterface.h
<gh_stars>1-10 #ifndef _BSDFINTERFACE_H_ #define _BSDFINTERFACE_H_ #include <Common.h> #include <RandomGenerator.h> class BsdfInterface { public: virtual ~BsdfInterface() {} virtual Vector3f sample(const Vector3f &_incident, const Vector3f &_normal, RandomGenerator &_random_generator) const =0; virtual float evaluate(const Vector3f &_incident, const Vector3f &_reflection, const Vector3f &_normal) const =0; virtual float pdf(const Vector3f &_incident, const Vector3f &_reflection, const Vector3f &_normal) const =0; }; #endif
joshbainbridge/morphogenetic-sim
include/PathtraceIntegrator.h
#ifndef _PATHTRACEINTEGRATOR_H_ #define _PATHTRACEINTEGRATOR_H_ #include <boost/shared_ptr.hpp> #include <IntegratorInterface.h> #include <Scene.h> #include <RandomGenerator.h> #include <Common.h> class PathtraceIntegrator : public IntegratorInterface { public: PathtraceIntegrator() : IntegratorInterface() {} Colour3f run(const boost::shared_ptr<Scene> _scene, boost::shared_ptr<RandomGenerator> _random_generator, const Ray3f _sample, const Colour3f _contribution); }; #endif
joshbainbridge/morphogenetic-sim
include/Pixel.h
#ifndef _PIXEL_H_ #define _PIXEL_H_ #include <vector> #include <Common.h> #include <Transmission.h> class Pixel { public: Colour3f pixelColour() const; void addSample(const Colour3f _sample); Colour3f getSample(const int _index) const; private: std::vector< Colour3f > m_samples; }; #endif
Ramjonchhen/hacktoberfest2021-1
C/LinkedList/Circular Singly Linked List Operations.c
#include <stdio.h> #include <stdlib.h> #include <stdio.h> #include <stdlib.h> struct node { int data; struct node* next; }; struct node* head = NULL ; struct node* tail = NULL ; int count = 0; void display() { struct node* display = head; if( head == NULL ) { printf("\nThe Linked List is empty.\n"); return; } printf("\nThe contents of the linked list is: "); do { printf("%d ",display->data); display = display ->next; }while( display!= head); printf("\n"); } struct node* getNode(int x){ struct node* newnode = (struct node*)malloc(sizeof(struct node)); newnode->data = x; newnode->next = NULL; return newnode; } void insertInHead() { int x; printf("\n Enter the data to insert: "); scanf("%d",&x); struct node* newnode = getNode(x); if ( head == NULL ) { head = tail = newnode; head->next = head; } else { newnode->next = head; head = newnode; tail->next = head; } } void insertInTail() { int x; printf("\n Enter the data to insert: "); scanf("%d",&x); struct node* newnode = getNode(x); if ( head == NULL ) { head = tail = newnode; head->next = head; } else { tail->next = newnode; newnode->next = head; tail = newnode;; } } void insertInN(){ int x, pos; printf("\n Enter the data to insert: "); scanf("%d",&x); printf("\n Enter the position to insert: "); scanf("%d",&pos); if( pos<1 || pos>count+1) { printf("\n Invalid Position"); return; } struct node* newnode = getNode(x); if ( pos==1) { if ( head == NULL ) { head = tail = newnode; head->next = head; } else { newnode->next = head; head = newnode; tail->next = head; } } else { int i; struct node* nminus1 = head; for(i=1; i<pos-1; i++) { nminus1 = nminus1->next; } if ( nminus1 == tail ) { tail->next = newnode; newnode->next = head; tail = newnode; } else { newnode->next = nminus1->next; nminus1->next = newnode; } } count++; } void deleteAtHead() { struct node* temp = head; if ( head == NULL ) { return; } else if ( head == tail ) { free(head); head = tail = NULL; }else { head = head->next; tail->next = head; free(temp); } count--; } void deleteAtTail() { struct node* secondLast = head; if ( head == NULL ) { return; } else if ( head == tail ) { free(head); head = tail = NULL; }else { while(secondLast->next != tail) { secondLast= secondLast->next; } free(tail); tail = secondLast; tail->next = head; } count--; } void deleteAtN() { if ( head == NULL ) { return; } int pos; printf("\n Enter the position for linked list to delete: "); scanf("%d",&pos); if( pos<1 || pos>count) { printf("\n Cannot Delete Invalid Position."); return; } struct node* temp = head; if ( pos == 1 ) { if ( head == tail ) { free(head); head = tail = NULL; }else { head = head->next; tail->next = head; free(temp); } } else { int i; for( i=1; i<pos-1; i++ ) { temp = temp ->next; } if ( temp->next == tail ) { free(temp->next); tail=temp; tail->next = head; } else { struct node* n = temp ->next; struct node* nplus1 = temp->next->next; temp->next = nplus1; free(n); } } count--; } void search() { if (head == NULL) { return; } int x; printf("\n Enter the element to search in the linked list: "); scanf("%d",&x); int found = 0 , pos = 1; struct node* travel = head; do{ if(travel->data == x) { found = 1; goto found; } travel = travel->next; pos++; }while(travel!=head); found:if( found == 1) { printf("\n Element found at position %d",pos); }else { printf("\n Element not found"); } } int main() { int choice; while(1) { printf("\n Operations For Singly Circular Linked List: "); printf("\n Enter 1 for Insertion in Nth Position. "); printf("\n Enter 2 for Deletion in Nth Position. "); printf("\n Enter 3 for Insertion in Head Position. "); printf("\n Enter 4 for Insertion in Tail Position. "); printf("\n Enter 5 for Deletion at Head Position. "); printf("\n Enter 6 for Deletion at Tail Position. "); printf("\n Enter 7 for Displaying the Linked List. "); printf("\n Enter 8 for searching in the Linked List. "); printf("\n Enter 9 for counting no of element the Linked List. "); printf("\n Enter 10 for Exit. "); printf("\n Enter your choice: "); scanf("%d",&choice); switch(choice) { case 1: insertInN(); display(); break; case 2: deleteAtN(); display(); break; case 3: insertInHead(); display(); count++; break; case 4: insertInTail(); display(); count++; break; case 5: deleteAtHead(); display(); break; case 6: deleteAtTail(); display(); break; case 7: display(); break; case 8: search(); display(); break; case 9: printf("\n No of elements in the linked list: %d",count); display(); break; case 10: return 0; } } return 0; }
jodyhagins/WJHEventTap
WJHEventTap/NSDictionary+WJHEventTap.h
<gh_stars>0 // // NSDictionary+WJHEventTap.h // WJHEventTap // // Copyright (c) 2015 <NAME>. All rights reserved. // #import <Foundation/Foundation.h> @interface NSDictionary (WJHEventTap) /** Creates a dictionary object containing the specified CGEventTapInformation structure. @param tapInfo the value for the new object @return A new dictionary object that contains the @a tapInfo information. Each field of the structure is contained in the dictionary, with the same name as in the actual structure. Each value is wrapped in an NSNumber object, as appropriate for the field value type. */ + (NSDictionary*)wjh_dictionaryWithCGEventTapInformation:(CGEventTapInformation)tapInfo; /** The CGEventTapInformation structure representation of the value. Any field not found in the dictionary will be set to zero. */ @property (readonly) CGEventTapInformation wjh_CGEventTapInformationValue; @end
jodyhagins/WJHEventTap
WJHEventTap/WJHEventTapDelegate.h
<reponame>jodyhagins/WJHEventTap<gh_stars>0 // // WJHEventTapDelegate.h // WJHEventTap // // Created by <NAME> on 9/17/15. // Copyright (c) 2015 <NAME>. All rights reserved. // #import <Foundation/Foundation.h> @class WJHEventTap; #pragma mark - WJHEventTapDelegate Protocol /** Protocol to be implemented by any WJHEventTap delegate */ @protocol WJHEventTapDelegate<NSObject> @optional /** Called when any event is received by the tap, this method will be called before any other delegate method for any given event. @param eventTap the tap for which the event is being processed @param event a pointer to the intercepted event, guaranteed to not be NULL. The dereferenced object is the incoming event, owned by the caller, and does not need to be released. @param type the type of event that was intercepted @param proxy the tap proxy @return YES if processing for this event is complete. In that case, *event will be returned to the system event processor and no other delegate methods are called for this event. NO if event-specific delegate methods should be called. @note The following rules apply for all event processing delegate methods. If the eventTap is active, one of the following values should be returned: - The same event that was passed in. The system event processor will continue using the event, releasing it when complete. - A newly-constructed event. The system event processor will use the returned event for further event handling. When done, the system event processor will release both the original incoming event and the new event returned to it. - NULL to have the system event processor delete (and stop further processing of) the event. The system will still be responsible for releasing the incoming event. */ - (BOOL)eventTap:(WJHEventTap*)eventTap receivedEvent:(CGEventRef*)event type:(CGEventType)type proxy:(CGEventTapProxy)proxy; /** Called when a kCGEventNull is received by the tap. @param eventTap the tap for which the event is being processed @param event the intercepted event @param proxy the tap proxy @return the event as it is to be interpreted by the system event processor. */ - (CGEventRef)eventTap:(WJHEventTap*)eventTap nullEvent:(CGEventRef)event proxy:(CGEventTapProxy)proxy; /** Called when a kCGEventLeftMouseDown is received by the tap. @param eventTap the tap for which the event is being processed @param event the intercepted event @param proxy the tap proxy @return the event as it is to be interpreted by the system event processor. */ - (CGEventRef)eventTap:(WJHEventTap*)eventTap leftMouseDownEvent:(CGEventRef)event proxy:(CGEventTapProxy)proxy; /** Called when a kCGEventLeftMouseDragged is received by the tap. @param eventTap the tap for which the event is being processed @param event the intercepted event @param proxy the tap proxy @return the event as it is to be interpreted by the system event processor. */ - (CGEventRef)eventTap:(WJHEventTap*)eventTap leftMouseDraggedEvent:(CGEventRef)event proxy:(CGEventTapProxy)proxy; /** Called when a kCGEventLeftMouseUp is received by the tap. @param eventTap the tap for which the event is being processed @param event the intercepted event @param proxy the tap proxy @return the event as it is to be interpreted by the system event processor. */ - (CGEventRef)eventTap:(WJHEventTap*)eventTap leftMouseUpEvent:(CGEventRef)event proxy:(CGEventTapProxy)proxy; /** Called when a kCGEventRightMouseDown is received by the tap. @param eventTap the tap for which the event is being processed @param event the intercepted event @param proxy the tap proxy @return the event as it is to be interpreted by the system event processor. */ - (CGEventRef)eventTap:(WJHEventTap*)eventTap rightMouseDownEvent:(CGEventRef)event proxy:(CGEventTapProxy)proxy; /** Called when a kCGEventRightMouseDragged is received by the tap. @param eventTap the tap for which the event is being processed @param event the intercepted event @param proxy the tap proxy @return the event as it is to be interpreted by the system event processor. */ - (CGEventRef)eventTap:(WJHEventTap*)eventTap rightMouseDraggedEvent:(CGEventRef)event proxy:(CGEventTapProxy)proxy; /** Called when a kCGEventRightMouseUp is received by the tap. @param eventTap the tap for which the event is being processed @param event the intercepted event @param proxy the tap proxy @return the event as it is to be interpreted by the system event processor. */ - (CGEventRef)eventTap:(WJHEventTap*)eventTap rightMouseUpEvent:(CGEventRef)event proxy:(CGEventTapProxy)proxy; /** Called when a kCGEventOtherMouseDown is received by the tap. @param eventTap the tap for which the event is being processed @param event the intercepted event @param proxy the tap proxy @return the event as it is to be interpreted by the system event processor. */ - (CGEventRef)eventTap:(WJHEventTap*)eventTap otherMouseDownEvent:(CGEventRef)event proxy:(CGEventTapProxy)proxy; /** Called when a kCGEventOtherMouseDragged is received by the tap. @param eventTap the tap for which the event is being processed @param event the intercepted event @param proxy the tap proxy @return the event as it is to be interpreted by the system event processor. */ - (CGEventRef)eventTap:(WJHEventTap*)eventTap otherMouseDraggedEvent:(CGEventRef)event proxy:(CGEventTapProxy)proxy; /** Called when a kCGEventOtherMouseUp is received by the tap. @param eventTap the tap for which the event is being processed @param event the intercepted event @param proxy the tap proxy @return the event as it is to be interpreted by the system event processor. */ - (CGEventRef)eventTap:(WJHEventTap*)eventTap otherMouseUpEvent:(CGEventRef)event proxy:(CGEventTapProxy)proxy; /** Called when a kCGEventMouseMoved is received by the tap. @param eventTap the tap for which the event is being processed @param event the intercepted event @param proxy the tap proxy @return the event as it is to be interpreted by the system event processor. */ - (CGEventRef)eventTap:(WJHEventTap*)eventTap mouseMovedEvent:(CGEventRef)event proxy:(CGEventTapProxy)proxy; /** Called when a kCGEventKeyDown is received by the tap. @param eventTap the tap for which the event is being processed @param event the intercepted event @param proxy the tap proxy @return the event as it is to be interpreted by the system event processor. */ - (CGEventRef)eventTap:(WJHEventTap*)eventTap keyDownEvent:(CGEventRef)event proxy:(CGEventTapProxy)proxy; /** Called when a kCGEventKeyUp is received by the tap. @param eventTap the tap for which the event is being processed @param event the intercepted event @param proxy the tap proxy @return the event as it is to be interpreted by the system event processor. */ - (CGEventRef)eventTap:(WJHEventTap*)eventTap keyUpEvent:(CGEventRef)event proxy:(CGEventTapProxy)proxy; /** Called when a kCGEventFlagsChanged is received by the tap. @param eventTap the tap for which the event is being processed @param event the intercepted event @param proxy the tap proxy @return the event as it is to be interpreted by the system event processor. */ - (CGEventRef)eventTap:(WJHEventTap*)eventTap modifierFlagsChangedEvent:(CGEventRef)event proxy:(CGEventTapProxy)proxy; /** Called when a kCGEventScrollWheel is received by the tap. @param eventTap the tap for which the event is being processed @param event the intercepted event @param proxy the tap proxy @return the event as it is to be interpreted by the system event processor. */ - (CGEventRef)eventTap:(WJHEventTap*)eventTap scrollWheelEvent:(CGEventRef)event proxy:(CGEventTapProxy)proxy; /** Called when a kCGEventTabletPointer is received by the tap. @param eventTap the tap for which the event is being processed @param event the intercepted event @param proxy the tap proxy @return the event as it is to be interpreted by the system event processor. */ - (CGEventRef)eventTap:(WJHEventTap*)eventTap tabletPointerEvent:(CGEventRef)event proxy:(CGEventTapProxy)proxy; /** Called when a kCGEventTabletProximity is received by the tap. @param eventTap the tap for which the event is being processed @param event the intercepted event @param proxy the tap proxy @return the event as it is to be interpreted by the system event processor. */ - (CGEventRef)eventTap:(WJHEventTap*)eventTap tabletProximityEvent:(CGEventRef)event proxy:(CGEventTapProxy)proxy; /** Called when a kCGEventTapDisabledByTimeout is received by the tap. @param eventTap the tap for which the event is being processed @param event the intercepted event @param proxy the tap proxy @return the event as it is to be interpreted by the system event processor. */ - (CGEventRef)eventTap:(WJHEventTap*)eventTap eventTapDisabledByTimeoutEvent:(CGEventRef)event proxy:(CGEventTapProxy)proxy; /** Called when a kCGEventTapDisabledByUserInput is received by the tap. @param eventTap the tap for which the event is being processed @param event the intercepted event @param proxy the tap proxy @return the event as it is to be interpreted by the system event processor. */ - (CGEventRef)eventTap:(WJHEventTap*)eventTap eventTapDisabledByUserInputEvent:(CGEventRef)event proxy:(CGEventTapProxy)proxy; /** Called when an unknown event type is received by the tap. @param eventTap the tap for which the event is being processed @param event the intercepted event @param type the type of the unknown event @param proxy the tap proxy @return the event as it is to be interpreted by the system event processor. */ - (CGEventRef)eventTap:(WJHEventTap*)eventTap unknownEvent:(CGEventRef)event type:(CGEventType)type proxy:(CGEventTapProxy)proxy; @end #pragma mark - WJHEventTapDelegate Class /** Block for handling any event from an event tap. @param eventTap the tap for which the event is being processed @param event a pointer to the intercepted event, guaranteed to not be NULL. The dereferenced object is the incoming event, owned by the caller, and does not need to be released. @param type the type of event that was intercepted @param proxy the tap proxy @return YES if processing for this event is complete. In that case, *event will be returned to the system event processor. NO if event-specific delegate methods should be called. */ typedef BOOL (^WJHEventTapReceivedEventBlock)(WJHEventTap *eventTap, CGEventRef *event, CGEventType type, CGEventTapProxy proxy); /** Block for handling known events from an event tap. @param eventTap the tap for which the event is being processed @param event the intercepted event @param proxy the tap proxy @return the event as it is to be interpreted by the system event processor. */ typedef CGEventRef (^WJHEventTapEventBlock)(WJHEventTap *eventTap, CGEventRef event, CGEventTapProxy proxy); /** Block for handling an unknown event from an event tap. @param eventTap the tap for which the event is being processed @param event the intercepted event @param type the type of the unknown event @param proxy the tap proxy @return the event as it is to be interpreted by the system event processor. */ typedef CGEventRef (^WJHEventTapUnknownEventBlock)(WJHEventTap *eventTap, CGEventRef event, CGEventType type, CGEventTapProxy proxy); /** A concrete class that implements all delegate methods of the @a WJHEventTapDelegate protocol by forwarding the call to the similarly named block property. If the event handler block is nil, the resulting behavior is the same as if the delegate method had not been overridden. Otherwise, the delegate method forwards the call to the block, and returns the return value of the block. */ @interface WJHEventTapDelegate : NSObject<WJHEventTapDelegate> @property (strong) WJHEventTapReceivedEventBlock receivedEvent; @property (strong) WJHEventTapEventBlock nullEvent; @property (strong) WJHEventTapEventBlock leftMouseDownEvent; @property (strong) WJHEventTapEventBlock leftMouseDraggedEvent; @property (strong) WJHEventTapEventBlock leftMouseUpEvent; @property (strong) WJHEventTapEventBlock rightMouseDownEvent; @property (strong) WJHEventTapEventBlock rightMouseDraggedEvent; @property (strong) WJHEventTapEventBlock rightMouseUpEvent; @property (strong) WJHEventTapEventBlock otherMouseDownEvent; @property (strong) WJHEventTapEventBlock otherMouseDraggedEvent; @property (strong) WJHEventTapEventBlock otherMouseUpEvent; @property (strong) WJHEventTapEventBlock mouseMovedEvent; @property (strong) WJHEventTapEventBlock keyDownEvent; @property (strong) WJHEventTapEventBlock keyUpEvent; @property (strong) WJHEventTapEventBlock modifierFlagsChangedEvent; @property (strong) WJHEventTapEventBlock scrollWheelEvent; @property (strong) WJHEventTapEventBlock tabletPointerEvent; @property (strong) WJHEventTapEventBlock tabletProximityEvent; @property (strong) WJHEventTapEventBlock eventTapDisabledByTimeoutEvent; @property (strong) WJHEventTapEventBlock eventTapDisabledByUserInputEvent; @property (strong) WJHEventTapUnknownEventBlock unknownEvent; @end
jodyhagins/WJHEventTap
WJHEventTap/NSValue+WJHEventTap.h
<gh_stars>0 // // NSValue+WJHEventTap.h // WJHEventTap // // Copyright (c) 2015 <NAME>. All rights reserved. // #import <Foundation/Foundation.h> @interface NSValue (WJHEventTap) /** Creates a value object containing the specified CGEventTapInformation structure. @param tapInfo the value for the new object @return A new value object that contains the @a tapInfo information. */ + (NSValue*)wjh_valueWithCGEventTapInformation:(CGEventTapInformation)tapInfo; /** The CGEventTapInformation structure representation of the value. */ @property (readonly) CGEventTapInformation wjh_CGEventTapInformationValue; @end
jodyhagins/WJHEventTap
WJHEventTap/WJHEventTap.h
// // WJHEventTap.h // WJHEventTap // // Copyright (c) 2015 <NAME>. All rights reserved. // #import <Foundation/Foundation.h> #import <WJHEventTap/WJHEventTapDelegate.h> #import <WJHEventTap/NSDictionary+WJHEventTap.h> #import <WJHEventTap/NSValue+WJHEventTap.h> extern double WJHEventTapVersionNumber(); extern unsigned char const * WJHEventTapVersionString(); enum { /// The location value that will be returned as the "tapPoint" field of CGEventTapInformation and the "location" property of WJHEventTap if the represented event tap is targetd at a specific process instead of one of the general tap locations. kWJHProcessEventTap = 3, }; #pragma mark - WJHEventTap /** Allow a little easier management of event taps than the CGEventTap API. */ @interface WJHEventTap : NSObject /** Get the total number of all system event taps. This number includes all taps, including, but not limited to WJHEventTap style taps. */ + (uint32_t)systemTapCount; /** Get all system taps. @return an array of NSValue-boxed CGEventTapInformation structures, each representing a system tap. */ + (NSArray*)systemTaps; /** Get an array of objects by applying the transform to each system tap. @param transform a block that transforms a CGEventTapInformation structure into an ObjectiveC object. If @a transform is nil, the structures will be converted into NSValue-boxed objects. The pointer passed into @a transform is guaranteed to be non-NULL. @return an array of objects representing each currently installed system tap. Each object is the result of applying @a transform on each system tap. @note Return nil from the transform block if you want the resulting array to exclude that item. @code NSArray *eventTapIDs = [WJHEventTap systemTapsWithTransform:^id(const CGEventTapInformation *tapInfo) { return @(tapInfo->eventTapID); }]; @endCode */ + (NSArray *)systemTapsWithTransform:(id(^)(CGEventTapInformation const *tapInfo))transform; /** The runLoop to which the tap is attached. */ @property (nonatomic, strong, readonly) NSRunLoop *runLoop; /** The actual event mask used to create the event tap. When an event tap is created, it takes the requested mask, and strips off the bits that can't be supported (e.g., requesting keyboard events without accessibility authorization). Thus, this value may be different from the actual requested event bitmask. */ @property (nonatomic, assign, readonly) CGEventMask eventMask; /** The event mask as requested in the initializer. */ @property (nonatomic, assign, readonly) CGEventMask requestedEventMask; /** Whether the tap was inserted before other taps, or after other taps. */ @property (nonatomic, assign, readonly) BOOL beforeOthers; /** Whether the tap was created in passive or active mode. */ @property (nonatomic, assign, readonly) BOOL passive; /** The enabled/disabled state of the tap. */ @property (atomic, assign, getter=isEnabled) BOOL enabled; /** The unique event tap ID */ @property (nonatomic, assign, readonly) uint32_t eventTapID; /** The location of the event tap. If the receiver was initialized with a tap location, the returned value will be the same value as passed to the initializer. If the receiver was initialized by targeting a specific process, the returned value will be equal to kWJHProcessEventTap. */ @property (nonatomic, assign, readonly) CGEventTapLocation location; /** The serial number of the process targeted by this event tap. If the event tap is targeted at a specific process, the returned value will be the same value as poassed into the initializer. If the event tap is not targeted at a specific process, this structure will contain all zero-bytes. */ @property (nonatomic, assign, readonly) ProcessSerialNumber processSerialNumber; /** The tap delegate, which will be notified for any action on the tap. @note The delegate is held strongly by the tap. The delegate can be changed, and set to nil. */ @property (atomic, strong) id<WJHEventTapDelegate> delegate; /** Initialize an event tap @param location specifies at what point in event processing the tap is to be inserted. If @a location is equal to kWJHProcessEventTap, then the tap will be installed at the currently running process. @param eventMask a bitmask that specifies which events are to be intercepted @param beforeOthers YES means that the tap will be inserted before any existing taps at the same location. NO means that the tap will be inserted after any existing taps at the same location. @param passive YES for a passive (listen only) tap, NO for an active tap that can change the event being processed. @param runLoop the run loop to which this tap will be attached. The tap will be added to the run loop for all common run loop modes. @param delegate the delegate to be notified of tap events. @note The event tap is created in a disabled state, and must be manually enabled. @see CGEventTapCreate in Apple's API */ - (instancetype)initWithLocation:(CGEventTapLocation)location eventMask:(CGEventMask)eventMask beforeOthers:(BOOL)beforeOthers passive:(BOOL)passive runLoop:(NSRunLoop *)runLoop delegate:(id<WJHEventTapDelegate>)delegate; /** Initialize an event tap @param process a pointer to serial number for the process to be tapped, or NULL for the current process. @param eventMask a bitmask that specifies which events are to be intercepted @param beforeOthers YES means that the tap will be inserted before any existing taps at the same location. NO means that the tap will be inserted after any existing taps at the same location. @param passive YES for a passive (listen only) tap, NO for an active tap that can change the event being processed. @param runLoop the run loop to which this tap will be attached. The tap will be added to the run loop for all common run loop modes. @param delegate the delegate to be notified of tap events. @note The event tap is created in a disabled state, and must be manually enabled. @see CGEventTapCreate in Apple's API */ - (instancetype)initWithProcess:(ProcessSerialNumber*)process eventMask:(CGEventMask)eventMask beforeOthers:(BOOL)beforeOthers passive:(BOOL)passive runLoop:(NSRunLoop *)runLoop delegate:(id<WJHEventTapDelegate>)delegate; @end
gkwityn/Advent-of-Code-2021
day_3/part1/day3_pt1.c
<filename>day_3/part1/day3_pt1.c #include <stdlib.h> #include <stdio.h> #include <string.h> #define BIT_LENGTH 13 void build_gamma_epsilon(char *gamma, char *epsilon, int *ones, int *zeros){ for(int i = 0; i <= BIT_LENGTH; i++){ if(i == BIT_LENGTH){ gamma[i] = '\0'; epsilon[i] = '\0'; } else if (ones[i] > zeros[i]){ gamma[i] = '1'; epsilon[i] = '0'; } else if (zeros[i] > ones[i]){ gamma[i] = '0'; epsilon[i] = '1'; } } return; } //------------------------------------------------------------------------------- int base10_to_binary(char *array){ int n = 0; int c = 0; for(int i = BIT_LENGTH-2; i >= 0; i--){ if(array[i] == '1'){ n += (1 << c); } c++; } return n; } //------------------------------------------------------------------------------- void print_binary_char_array(char *array){ for(int i = 0; i < BIT_LENGTH-1; i++){ printf("%c", array[i]); } printf("\n"); return; } //------------------------------------------------------------------------------- void print_binary_int_array(int *array){ for(int i = 0; i < BIT_LENGTH-1; i++){ printf("%d ", array[i]); } printf("\n"); return; } //------------------------------------------------------------------------------- int main(int argc, char const *argv[]) { char buff[BIT_LENGTH]; char gamma[BIT_LENGTH]; char epsilon[BIT_LENGTH]; int ones[BIT_LENGTH-1]; int zeros[BIT_LENGTH-1]; for(int i = 0; i < BIT_LENGTH-1; i++){ ones[i] = 0; zeros[i] = 0; gamma[i] = '0'; epsilon[i] = '0'; } gamma[BIT_LENGTH] = '\0'; epsilon[BIT_LENGTH] = '\0'; FILE *fp; fp = fopen("input.txt", "r"); while(fscanf(fp, "%s", buff) != EOF){ for(int i = 0; i < BIT_LENGTH; i++){ if(buff[i] == '1'){ ones[i] = ones[i]+1; }else if(buff[i] == '0'){ zeros[i] = zeros[i]+1; } } } //print sum of occurances of 1 or 0 in //each index of corosponding arrays. printf("ones: "); print_binary_int_array(ones); printf("zeros: "); print_binary_int_array(zeros); build_gamma_epsilon(gamma, epsilon, ones, zeros); printf("gamma base2: "); print_binary_char_array(gamma); printf("epsilon: base2: "); print_binary_char_array(epsilon); int gamma_int = base10_to_binary(gamma); int epsilon_int = base10_to_binary(epsilon); printf("gamma base10: %d\n", gamma_int); printf("epsilon base10: %d\n", epsilon_int); printf("gamma * epsilon = %d\n", gamma_int*epsilon_int); return 0; }
gkwityn/Advent-of-Code-2021
day_1/part1/day1_pt1.c
<reponame>gkwityn/Advent-of-Code-2021<filename>day_1/part1/day1_pt1.c #include <stdlib.h> #include <stdio.h> #define N_INPUT 2000 int main(int argc, char const *argv[]) { int depth_readings[N_INPUT]; int data; int count = 0; FILE *fp; fp = fopen("sonar_sweep.txt", "r"); if(fp == NULL){ return EXIT_FAILURE; } int i = 0; while( fscanf(fp, "%d", &data) != EOF ){ depth_readings[i++] = data; } int prev = depth_readings[0]; for(int i = 1; i < N_INPUT; i++){ if(depth_readings[i] > prev){ count++; } prev = depth_readings[i]; } printf("Number of depth increases: %d\n", count); return EXIT_SUCCESS; }
gkwityn/Advent-of-Code-2021
day_2/part2/day2_pt2.c
/* forward X increases the horizontal position by X units. down X increases the depth by X units. up X decreases the depth by X units. down X increases your aim by X units. up X decreases your aim by X units. forward X does two things: It increases your horizontal position by X units. It increases your depth by your aim multiplied by X. */ #include <stdio.h> #include <string.h> #include <stdlib.h> struct submarine{ int horizontal; int depth; int aim; }; int main(int argc, char const *argv[]){ struct submarine my_sub; my_sub.horizontal = 0; my_sub.depth = 0; my_sub.aim = 0; char buff[8]; int x_unites; FILE *fp; fp = fopen("input.txt", "r"); if(fp == NULL){ printf("Error: unable to open file.\n"); return EXIT_FAILURE; } while(fscanf(fp, "%s %d", buff, &x_unites) != EOF){ if(strcmp(buff, "forward") == 0){ my_sub.depth += (my_sub.aim * x_unites); my_sub.horizontal += x_unites; } else if(strcmp(buff, "up") == 0){ my_sub.aim -= x_unites; } else if(strcmp(buff, "down") == 0){ my_sub.aim += x_unites; } } printf("Horizontal * Depth = %d\n", my_sub.horizontal * my_sub.depth); fclose(fp); return 0; }
gkwityn/Advent-of-Code-2021
day_1/part2/day1_pt2.c
#include <stdio.h> #include <stdlib.h> #define N_INPUT 2000 void cmp_arrays(int* prev, int* current, int* count){ int prev_sum = 0; int curr_sum = 0; for(int i = 0; i < 3; i++){ prev_sum += prev[i]; curr_sum += current[i]; } if(prev_sum < curr_sum ){ *count = *count + 1; } printf("P3_sum: %d, C3_sum: %d, Count: %d\n", prev_sum, curr_sum, *count); return; } void update_prev(int *prev, int *x){ for(int i = 0; i < 3; i++){ prev[i] = x[i]; } return; } int main(int argc, char const *argv[]) { int depth_readings[N_INPUT]; int data_in; int count = 0; int a[3]; int b[3]; int c[3]; int d[3]; FILE *fp; fp = fopen("sonar_sweep.txt", "r"); int i = 0; while(fscanf(fp, "%d", &data_in) != EOF){ depth_readings[i++] = data_in; } int prev[3]; prev[0] = depth_readings[0]; prev[1] = depth_readings[1]; prev[2] = depth_readings[2]; for(int i = 1; i < N_INPUT-1; i++){ char char_array; switch(i%4){ case 0:{ //printf("A "); char_array = 'a'; a[0] = depth_readings[i-1]; a[1] = depth_readings[i]; a[2] = depth_readings[i+1]; cmp_arrays(prev, a, &count); update_prev(prev, a); break; } case 1:{ //printf("B "); char_array = 'b'; b[0] = depth_readings[i-1]; b[1] = depth_readings[i]; b[2] = depth_readings[i+1]; cmp_arrays(prev, b, &count); update_prev(prev, b); break; } case 2:{ //printf("C "); char_array = 'c'; c[0] = depth_readings[i-1]; c[1] = depth_readings[i]; c[2] = depth_readings[i+1]; cmp_arrays(prev, c, &count); update_prev(prev, c); break; } case 3:{ //printf("D "); char_array = 'd'; d[0] = depth_readings[i-1]; d[1] = depth_readings[i]; d[2] = depth_readings[i+1]; cmp_arrays(prev, d, &count); update_prev(prev, d); break; } } } printf("Count: %d\n", count); return EXIT_SUCCESS; }
gkwityn/Advent-of-Code-2021
day_2/part1/day2_pt1.c
#include <stdio.h> #include <string.h> int main(int argc, char const *argv[]) { int horizontal = 0; int depth = 0; char buff[8]; int x_unites; // forward X increases the horizontal position by X units. // down X increases the depth by X units. // up X decreases the depth by X units. FILE *fp; fp = fopen("input.txt", "r"); while(fscanf(fp, "%s %d", buff, &x_unites) != EOF){ //printf("%s %d\n", buff, x_unites); //printf("Hoz: %d, Depth: %d\n", horizontal, depth); if(strcmp(buff, "forward") == 0){ horizontal += x_unites; //printf("horiz: %d\n", horizontal); } else if(strcmp(buff, "up") == 0){ depth -= x_unites; //printf("Up: %d\n", depth); } else if(strcmp(buff, "down") == 0){ depth += x_unites; //printf("Down: %d\n", depth); } } printf("Horiz * Depth = %d\n", horizontal*depth); fclose(fp); return 0; }
gkwityn/Advent-of-Code-2021
day_3/part2/day3_pt2.c
#include <stdlib.h> #include <stdio.h> #include <string.h> #define BIT_LENGTH 13 #define N_INPUT 1000 //------------------------------------------------------------------------------- void build_gamma_epsilon(char *gamma, char *epsilon, int *ones, int *zeros){ for(int i = 0; i < BIT_LENGTH-1; i++){ if (ones[i] > zeros[i]){ gamma[i] = '1'; epsilon[i] = '0'; } else{ gamma[i] = '0'; epsilon[i] = '1'; } } return; } //------------------------------------------------------------------------------- int base10_to_binary(char *array){ int n = 0; int c = 0; for(int i = BIT_LENGTH-2; i >= 0; i--){ if(array[i] == '1'){ n += (1 << c); } c++; } return n; } //------------------------------------------------------------------------------- void print_binary_char_array(char *array){ for(int i = 0; i < BIT_LENGTH-1; i++){ printf("%c", array[i]); } printf("\n"); return; } //------------------------------------------------------------------------------- void print_binary_int_array(int *array){ for(int i = 0; i < BIT_LENGTH-1; i++){ printf("%d ", array[i]); } printf("\n"); return; } //------------------------------------------------------------------------------- int main(int argc, char const *argv[]) { char buff[BIT_LENGTH]; char gamma[BIT_LENGTH]; char epsilon[BIT_LENGTH]; int ones[BIT_LENGTH]; int zeros[BIT_LENGTH]; char *o2_gen_array[N_INPUT]; char *co2_scrub_array[N_INPUT]; char input[N_INPUT][BIT_LENGTH]; int k = 0; for(int i = 0; i < BIT_LENGTH-1; i++){ ones[i] = 0; zeros[i] = 0; } FILE *fp; fp = fopen("input.txt", "r"); if(fp == NULL){ printf("Error: Unable to open file.\n"); return EXIT_FAILURE; } while(fscanf(fp, "%s", buff) != EOF){ strcpy(input[k++], buff); for(int i = 0; i < BIT_LENGTH-1; i++){ if(buff[i] == '1'){ ones[i] = ones[i]+1; }else if(buff[i] == '0'){ zeros[i] = zeros[i]+1; } } } int c = 0; char **temp1; char **temp2; while(c < BIT_LENGTH-1){ if(ones[c] >= zeros[c]){ o2_gen_array[c] = malloc(sizeof(char *)) for(int i = 0; i < N_INPUT; i++){ if(input[i][c] == '1'){ } ) } o2_gen_array } c++; } // build_gamma_epsilon(gamma, epsilon, ones, zeros); // printf("gamma base2: "); // print_binary_char_array(gamma); // printf("epsilon: base2: "); // print_binary_char_array(epsilon); // int gamma_int = base10_to_binary(gamma); // int epsilon_int = base10_to_binary(epsilon); // printf("gamma base10: %d\n", gamma_int); // printf("epsilon base10: %d\n", epsilon_int); // printf("gamma * epsilon = %d\n", gamma_int*epsilon_int); return EXIT_SUCCESS; }
akalend/sophiaDb
src/config.c
<filename>src/config.c #include "main.h" #include "ini.h" #include "mc.h" extern void parse(const char* fname, conf_t *server_ctx); int parser(void* pctx, const char* section, const char* name, const char* value) { conf_t* ctx = (conf_t*) pctx; static datatype_t *p = NULL; datatype_t *tmp = NULL; int tmp_int = 0; int max_num=0; if (strcmp(section, "daemon") == 0) { // printf("[%s] %s=%s;\n", section, name, value); if(strcmp("daemon", name)==0) { sscanf(value,"%d",&tmp_int); ctx->is_demonize = tmp_int; } if(strcmp("trace" , name)==0) { sscanf(value,"%d",&tmp_int); ctx->trace = tmp_int; } if(strcmp("level", name)==0) { //sscanf(value,"%d",&tmp_int); ctx->level = 0; if (strcmp("error",value) ) ctx->level = 1; if (strcmp("warning",value) ) ctx->level = 2; if (strcmp("notice",value) ) ctx->level = 3; } if(strcmp("logfile", name)==0) { ctx->logfile = strdup(value); } if(strcmp("pidfile", name)==0) { ctx->pidfile = strdup(value); } if(strcmp("listen", name)==0) { ctx->listen = strdup(value); } if(strcmp("username", name)==0) { if (strcmp("any", value)) ctx->username = strdup(value); } if(strcmp("datadir", name)==0) { ctx->datadir = strdup(value); } } else if (strcmp(section, "data") == 0){ if (strcmp("number", name) == 0) { if(ctx->list_datatypes) { tmp = p; p = malloc(sizeof(datatype_t)); if (!p) { (void)fprintf(stderr, "mpool Error : %s\n", strerror(errno)); } // printf("alloc %x\n", (unsigned) p); assert(p); p->next = NULL; p->comment = NULL; tmp->next = p;//(datatype_t*) } else { p = (datatype_t*) calloc(1, sizeof(datatype_t)); // printf("alloc %x\n", (unsigned) p); if (!p) { (void)fprintf(stderr, "mpool Error:%s %s\n", __LINE__, strerror(errno)); } ctx->list_datatypes = p; assert(ctx->list_datatypes); } sscanf(value,"%d",&tmp_int); p->number = tmp_int; ctx->list_size++; if (tmp_int > ctx->max_num) ctx->max_num = tmp_int; } assert(p); if(strcmp("comment", name)==0) { p->comment = strdup(value); if (!p->comment) { (void)fprintf(stderr, "mpool Error:%d : %s\n", __LINE__, strerror(errno)); } } if(strcmp("datadir", name)==0) { p->datadir = strdup(value); if (!p->datadir) { (void)fprintf(stderr, "mpool Error:%d %s\n", __LINE__, strerror(errno)); } } if(strcmp("type", name)==0) { if (strcmp("int",value)==0) { p->type = SPHDB_INT; } if (strcmp("long",value)==0) { p->type = SPHDB_LONG; } if (strcmp("string",value)==0) { p->type = SPHDB_STRING; } } } return 0; } void parse(const char* fname, conf_t *server_ctx) { bzero(server_ctx, sizeof(conf_t)); ini_parse(fname, parser, (void*)server_ctx); }
akalend/sophiaDb
src/mc.c
#include "mc.h" #ifndef __sophiadb_mc__ #define __sophiadb_mc__ #endif #ifdef __sophiadb_mc__ #include <sophia.h> #include <sys/stat.h> #include <sys/time.h> #include <ev.h> #define BUFSIZE 512 //TODO nax... extern FILE *flog; extern int max_clients; extern fd_ctx *clients; extern int is_finish; extern int is_trace; extern struct timeval t_start; // start timeinterval extern struct timeval t_end; // finish timeinterval extern struct { /* some stat data */ unsigned connections; // active connections (memcache clients) unsigned cnn_count; // count connectionss unsigned cmd_per; // count of commands into period unsigned cmd_count; // count of commands float rps; // last count of commands per second float rps_peak; // peak of commands per second unsigned get; // count of get commands unsigned set; // count of set/append/prepend/incr/decr commands unsigned del; // count of delete commands unsigned inc; // count of increment/decrement commands unsigned miss; // count of miss keys (key not found) time_t uptime; // uptime server unsigned err; // count of errors } stats; void periodic_watcher(EV_P_ ev_timer *t, int revents); static ev_io* memcached_client_new(int sock); static void memcached_client(EV_P_ ev_io *io, int revents); static void memcached_client_free(db_t *ctx); static int setup_socket(int sock); int num_digits(unsigned x) { return (x < 10 ? 1 : (x < 100 ? 2 : (x < 1000 ? 3 : (x < 10000 ? 4 : (x < 100000 ? 5 : (x < 1000000 ? 6 : (x < 10000000 ? 7 : (x < 100000000 ? 8 : (x < 1000000000 ? 9 : 10))))))))); } void close_io(EV_P_ ev_io *io) { ev_io_stop(EV_A_ io); close(io->fd); } void close_all(EV_P) { int i; for (i=0; i < max_clients; i++) { if (clients[i].flags ) { close_io(EV_A_ clients[i].io); } if(clients[i].mc) { if(clients[i].mc->value) free(clients[i].mc->value); clients[i].mc->value = NULL; free(clients[i].mc); clients[i].mc = NULL; } } } void cllear_mc_all() { int i; for (i=0; i < max_clients; i++) { if (clients[i].mc) { if (clients[i].mc->value) { free(clients[i].mc->value); clients[i].mc->value = NULL; } free(clients[i].mc); clients[i].mc = NULL; } //if(FD_ACTIVE) close_io(EV_A_ clients[i].io); } } void periodic_watcher(EV_P_ ev_timer *t, int revents) { gettimeofday(&t_end, NULL); long mtime, seconds, useconds; seconds = t_end.tv_sec - t_start.tv_sec; useconds = t_end.tv_usec - t_start.tv_usec; mtime = ((seconds) * 1000 + useconds/1000.0) + 0.5; stats.rps = stats.cmd_per * 1000 /mtime ; if(stats.rps_peak < stats.rps) stats.rps_peak = stats.rps; stats.cmd_per = 0; gettimeofday(&t_start, NULL); } /* Set misc socket parameters: non-blocking mode, linger, enable keep alive. */ static int setup_socket(int sock) { int keep_alive = 1; struct linger l = {0, 0}; if (set_nonblock(sock, 1) == -1) return -1; if (setsockopt(sock, SOL_SOCKET, SO_LINGER, &l, sizeof(l)) == -1) return -1; if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, &keep_alive, sizeof(keep_alive)) == -1) return -1; return 0; } static void memcached_client_free(db_t *ctx) { stats.connections--; if(is_trace) printf("connection fd=%d free [%d]\n", ctx->io.fd, stats.connections); if (!ctx) return; // if (ctx->value) free(ctx->value); // free(ctx); // clients[ctx->io.fd].mc = NULL; } /*process data for set*/ static int memcached_process_set( db_t *mctx, sophiadb_t* ctx) { printf("save[len=%d] %s:%s\n",strlen(mctx->value), mctx->key, mctx->value); int rc = sp_set(ctx->db, &mctx->key, strlen(mctx->key), mctx->value, sizeof(mctx->value)); if (rc == -1) { printf("sp_set: %s\n", sp_error(ctx->db)); return 1; } memset(mctx->value, BUFSIZE, '\0'); memset(mctx->key, BUFSIZE, '\0'); stats.set ++; return 0; } static void memcached_cb_set(EV_P_ ev_io *io, int revents) { db_t *mctx = (db_t*)io; if(is_trace) printf("\n-------- data len=%d -----------\n'%s'\n", mctx->value_size - mctx->value_len, mctx->value); while (mctx->value_len < mctx->value_size) { size_t bytes = read(io->fd, mctx->value + mctx->value_len, mctx->value_size - mctx->value_len); if (bytes > 0) { if (bytes > BUFSIZE) { fprintf(flog, "%s reciive bytes %d more than BUFSIZE\n", __FUNCTION__, (int)bytes); goto error; } mctx->value_len += bytes; } else if(bytes == -1){ if (errno == EAGAIN) return; if (errno == EINTR) continue; goto disconnect; } } set_client_timeout(io, RECV_TIMEOUT); mctx->value[mctx->value_size-2] = 0; sophiadb_t* ctx = ev_userdata(EV_A); int ret = memcached_process_set(mctx, ctx); switch (ret) { case 1 : goto error; break; case 2 : goto notstored; break; } if(mctx->key) { free(mctx->key); mctx->key = NULL; } mctx->cmd_len = 0; ev_io_stop(EV_A_ io); ev_set_cb(io, memcached_client); ev_io_set(io, io->fd, EV_WRITE); obuffer_init(&mctx->response, "STORED\r\n", sizeof("STORED\r\n") - 1); ev_io_start(EV_A_ io); return; error: mctx->cmd_len = 0; ev_io_stop(EV_A_ io); ev_set_cb(io, memcached_client); ev_io_set(io, io->fd, EV_WRITE); obuffer_init(&mctx->response, "ERROR\r\n", sizeof("ERROR\r\n") - 1); ev_io_start(EV_A_ io); return; notstored: mctx->cmd_len = 0; ev_io_stop(EV_A_ io); ev_set_cb(io, memcached_client); ev_io_set(io, io->fd, EV_WRITE); obuffer_init(&mctx->response, "NOT_STORED\r\n", sizeof("NOT_STORED\r\n") - 1); ev_io_start(EV_A_ io); return; disconnect: close_io(EV_A_ io); return; } /* memcache GET handler */ int memcache_get(EV_P_ db_t *mctx) { int len=0; char *key = mctx->cmd + 4; char *p = key; while(1) { if (*p == ' ' || *p == '\r' || *p == '\n' ) break; p++; len++; } *(key+len-1) = '\0'; sophiadb_t* ctx = ev_userdata(EV_A); memset(mctx->value, BUFSIZE, '\0'); printf("key: %s\n", key); char* pdata = NULL; size_t valuesize; int rc = sp_get(ctx->db, key, len-1, &pdata, &valuesize); if (rc == -1) { printf("sp_get: %s\n", sp_error(ctx->db)); goto error; } printf("key[%d]: '%s', len=%d value='%s'\n", len,key, valuesize, pdata); free(pdata); len = snprintf(mctx->value, BUFSIZE, "VALUE %s 0 %d\r\n%s\r\nEND\r\n", key, valuesize, pdata); if (pdata) free(pdata); obuffer_init(&mctx->response, mctx->value, len); stats.get ++; return 0; error: return 1; end: stats.miss ++; return 2; } /* memcache DELETE handler */ int memcache_del(EV_P_ db_t *mctx) { int len; char *key = mctx->cmd + 7; char *p=key; while(1) { if (*p == ' ' || *p == '\r' || *p == '\n' ) break; p++; len++; } *(key+len-1) = '\0'; sophiadb_t* ctx = ev_userdata(EV_A); memset(mctx->value, BUFSIZE, '\0'); // ctx->ecode = 0; // bool res = tchdbout2(ctx->hdb, key); // if (res) { // len=9; // strcpy(mctx->value, "DELETED\r\n" ); // } else { // ctx->ecode = tchdbecode(ctx->hdb); // if (ctx->ecode == TCENOREC) { // len=11; // stats.miss ++; // strcpy(mctx->value, "NOT_FOUND\r\n" ); // } else { // fprintf(flog, "res=false delete tcdb error[%d]: %s\n",ctx->ecode, tchdberrmsg(ctx->ecode)); // goto error; // } // } mctx->value[len] = '\0'; obuffer_init(&mctx->response, mctx->value, len); stats.del ++; return 0; error: return 1; } /* memcache SET handler */ int memcache_set(EV_P_ db_t *mctx, int readed, int end) { /* Set command */ unsigned bytes; char *p; p = mctx->cmd + 4; *(mctx->key) = '\0'; if (sscanf(p, "%s %u %u %u", &mctx->key, &mctx->flag, &mctx->exptime, &bytes) != 4) { fprintf(flog, "%s[%d] sscanf error\n", __FUNCTION__,__LINE__); return 1; } int len = mctx->cmd_len - end; /* Don't send messages longer than 1 megabyte */ if (!bytes || bytes > 1 << 20) { fprintf(flog, "%s invalid message length: %d\n", __FUNCTION__, bytes); return 1; } mctx->cmd_len = 0; mctx->data_size = bytes; mctx->value_size = bytes+2; // TODO ???? mctx->value_len = len; if (readed > end) { if(is_trace) printf("\n-------- data -----------\n'%s'\nlen=%d", mctx->cmd+end, readed-end-3); memcpy(mctx->value,mctx->cmd+end, readed-end); mctx->value[readed-end] = '\0'; sophiadb_t* ctx = ev_userdata(EV_A); if(memcached_process_set(mctx, ctx)) { return 1; } obuffer_init(&mctx->response, "STORED\r\n", sizeof("STORED\r\n") - 1); return 0; } if (len) { memcpy(mctx->value, mctx->cmd + end, len); /* Maybe we've read all value? */ if (len == mctx->value_size) { mctx->value[bytes] = 0; fprintf( flog, " ATTENTION!! %s we are read all data\n", __FUNCTION__); //mctx->value = NULL; obuffer_init(&mctx->response, "STORED\r\n", sizeof("STORED\r\n") - 1); stats.err ++; *(mctx->key) = '\0'; return 0; } *(mctx->key) = '\0'; return 1; } set_client_timeout((ev_io *)mctx, RECV_TIMEOUT); ev_set_cb((ev_io *)mctx, memcached_cb_set); return 2; } static void memcached_stats(EV_P_ db_t *mctx) { int len; char *statsbuf = malloc(BUFSIZE); time_t t; time(&t); len = snprintf(statsbuf, BUFSIZE, "STAT pid %ld\r\n" "STAT uptime %d\r\n" "STAT curent connections %u\r\n" "STAT total connections %u\r\n" "STAT rps %4.2f\r\n" "STAT peak rps %4.2f\r\n" "STAT request %u\r\n" "STAT get %u\r\n" "STAT set %u\r\n" "STAT inc %u\r\n" "STAT del %u\r\n" "STAT miss %u\r\n" "STAT error %u\r\n" "END\r\n", (long)getpid(), (int)(t-stats.uptime) , stats.connections, stats.cnn_count, stats.rps, stats.rps_peak, stats.cmd_count, stats.get, stats.set, stats.inc, stats.del, stats.miss, stats.err ); memcpy(mctx->value, statsbuf, len); free(statsbuf); obuffer_init(&mctx->response, mctx->value, len); } /* Handle line-based memcached-like protocol */ static void memcached_client(EV_P_ ev_io *io, int revents) { db_t *mctx = ( db_t*)io; if (revents & EV_READ) { int end = 0; int i = mctx->cmd_len ? mctx->cmd_len - 1 : 0; /* Read command till '\r\n' (actually -- till '\n') */ size_t bytes =0; while (mctx->cmd_len < MAX_COMMAND_LEN && !end) { bytes = read(io->fd, mctx->cmd + mctx->cmd_len, MAX_COMMAND_LEN - mctx->cmd_len); if (bytes > 0) { if (bytes > BUFSIZE) { fprintf( flog, "%s readed=%d more as BUFSIZE\n", __FUNCTION__, (int)bytes); goto send_error; } mctx->cmd_len += bytes; while (i < mctx->cmd_len - 1) { if (mctx->cmd[i] == '\r' && mctx->cmd[i+1] == '\n') { end = i + 2; mctx->cmd[i] = 0; break; } i++; } } else if (bytes == -1) { if (errno == EAGAIN) break; if (errno == EINTR) continue; goto disconnect; } else goto disconnect; } /* If there is no EOL but string is too long, disconnect client */ if (mctx->cmd_len >= MAX_COMMAND_LEN && !end) goto disconnect; /* If we haven't read whole command, set timeout */ if (!end) { set_client_timeout(io, RECV_TIMEOUT); return; } stats.cmd_count++; stats.cmd_per++; /* handle set command */ if (strncmp(mctx->cmd, "set ", 4) == 0) { switch (memcache_set(EV_A_ mctx, bytes, end)) { case 0: goto send_reply; case 1: goto send_error; case 2: return; } /* Handle "Get" command */ } else if (strncmp(mctx->cmd, "get ", 4) == 0) { switch (memcache_get(EV_A_ mctx)) { case 0: goto send_reply; case 1: goto send_error; case 2: goto send_end; } /* Handle "Dalete" command */ } else if (strncmp(mctx->cmd, "delete ", 7) == 0) { if (memcache_del(EV_A_ mctx)) goto send_error; else goto send_reply; } else if (strncmp(mctx->cmd, "flush_all", 9) == 0) { sophiadb_t* ctx = ev_userdata(EV_A); if(true) { //tchdbvanish(ctx->hdb) obuffer_init(&mctx->response, "OK\r\n", sizeof("OK\r\n") - 1); stats.inc = stats.rps_peak = stats.rps = stats.cmd_count = stats.get = stats.set = stats.del = stats.miss = stats.err = 0; goto send_reply; } else goto send_error; /* Close connection */ } if (strncmp(mctx->cmd, "quit", 4) == 0) { if (is_finish) goto exit; goto disconnect; /* Terminate server */ } if (strncmp(mctx->cmd, "term", 4) == 0) { goto exit; /* Statistics */ } else if (strncmp(mctx->cmd, "stats", 5) == 0) { memcached_stats(EV_A_ mctx); goto send_reply; } else { /* Invalid command */ fprintf(flog, "invalid command: \"%s\"\n", mctx->cmd); goto send_error; } } else if (revents & EV_WRITE) { switch (obuffer_send(&mctx->response, io->fd)) { case 0: mctx->cmd_len = 0; memset(mctx->cmd, 0, MAX_COMMAND_LEN); reset_client_timeout(io); ev_io_stop(EV_A_ io); if (is_finish) goto exit; ev_io_set(io, io->fd, EV_READ); ev_io_start(EV_A_ io); break; case -1: goto disconnect; } } return; send_error: stats.err ++; obuffer_init(&mctx->response, "ERROR\r\n", sizeof("ERROR\r\n") - 1); goto send_reply; send_end: obuffer_init(&mctx->response, "END\r\n", sizeof("END\r\n") - 1); send_reply: set_client_timeout(io, RECV_TIMEOUT); mctx->cmd_len = 0; ev_io_stop(EV_A_ io); ev_io_set(io, io->fd, EV_WRITE); ev_io_start(EV_A_ io); return; disconnect: close_io(EV_A_ io); memcached_client_free(mctx); return; exit: close_all(EV_A ); ev_unloop(EV_A_ EVUNLOOP_ALL); } /* Create connections context */ static ev_io* memcached_client_new(int sock) { if(is_trace) printf("%s: new connection [%d]", __FUNCTION__, sock); if (setup_socket(sock) != -1) { db_t *mctx = calloc(1, sizeof(db_t)); if (!mctx) { fprintf(flog, "%s: allocate error size=%d\n", __FUNCTION__, (int)sizeof(db_t)); return NULL; } if (!mctx->value) { mctx->value = malloc(BUFSIZE); if (!mctx->value) { fprintf(flog, "%s: allocate error size=%d\n", __FUNCTION__, BUFSIZE); return NULL; } } if (!mctx->key) { mctx->key = malloc(BUFSIZE); if (!mctx->key) { fprintf(flog, "%s: allocate error size=%d\n", __FUNCTION__, BUFSIZE); return NULL; } } ev_io_init(&mctx->io, memcached_client, sock, EV_READ); clients[sock].io = &mctx->io; clients[sock].cleanup = (cleanup_proc)memcached_client_free; clients[sock].mc = mctx; stats.connections++; stats.cnn_count++; if(is_trace) printf(" Ok\n"); return &mctx->io; } else { if(is_trace) printf(" Fail\n"); return NULL; } } /* Serve connectionss */ void memcached_on_connect(EV_P_ ev_io *io, int revents) { while (1) { int client = accept(io->fd, NULL, NULL); if (client >= 0) { ev_io *mctx = memcached_client_new(client); if (mctx) { ev_io_start(EV_A_ mctx); } else { fprintf(flog, "failed to create connections context %s", strerror(errno)); close(client); } } else { if (errno == EAGAIN) return; if (errno == EMFILE || errno == ENFILE) { fprintf(flog, "out of file descriptors, dropping all clients. %s", strerror(errno)); close_all(EV_A); } else if (errno != EINTR) { fprintf(flog, "accept_connections error: %s", strerror(errno)); } } } } #endif
akalend/sophiaDb
src/main.h
#ifndef __mymc_main__ #define __mymc_main__ #endif #ifdef __mymc_main__ #include <unistd.h> #include <fcntl.h> #include <ev.h> #include <sys/socket.h> #include <netinet/in.h> #include <sys/un.h> #include <stdlib.h> #include <errno.h> #include <stdint.h> #include <ctype.h> #include <signal.h> #include <sys/resource.h> #include <syslog.h> #include <sys/types.h> #include <pwd.h> #include <getopt.h> #include <assert.h> #include <string.h> #include <tchdb.h> #include <tcutil.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <strings.h> #include <time.h> //#include "mqueue.h" #include "io_buffer.h" #define LIKE_CACHESIZE 16777216; #define MAX_COMMAND_LEN 128 #define LK_STORAGE_FILENAME "storage.tch" #define LK_STORAGE_FILENAME_LEN sizeof(LK_STORAGE_FILENAME) #define LK_KEYSIZE sizeof(lk_key) #define LK_LIKESIZE sizeof(unsigned) // typedef struct { // unsigned data; // unsigned crc; // } lk_data; void perror_fatal(const char *what); #endif
akalend/sophiaDb
src/io_buffer.h
<filename>src/io_buffer.h #pragma once #include <stdint.h> typedef unsigned bsize_t; typedef int bssize_t; #define IBUFFER_EOF 1 #define IBUFFER_STATIC 2 /** Input buffer */ struct ibuffer { union { char *c_data; /**< buffer data as character array */ uint8_t *u_data; /**< buffer data as array of bytes */ void *data; /**< opaque */ }; bsize_t length; /**< length of data (in bytes) */ bsize_t capacity; /**< size of data in bytes */ int flags; /**< set when EOF received from last read operation. */ }; struct obuffer { union { const char *c_data; const uint8_t *u_data; const void *data; }; bsize_t pos; bsize_t length; }; /* Initialize buffer of specified capacity. */ void ibuffer_init(struct ibuffer *b, bsize_t initsize, void *s_buf); /** Resize input buffer so it can contain as lease size bytes. */ void ibuffer_reserve(struct ibuffer *b, bsize_t size); /* Remove first pos bytes from buffer */ void ibuffer_discard(struct ibuffer *b, bsize_t pos); /* Read buffer until it's full capacity or EAGAIN/EOF */ bssize_t ibuffer_read(struct ibuffer *b, int fd); /* Free dynamically allocated buffer */ void ibuffer_free(struct ibuffer *b); /* Reset buffer size */ void ibuffer_reset(struct ibuffer *b, bsize_t initsize, void *s_buf); void obuffer_init(struct obuffer *b, const void *data, bsize_t size); int obuffer_send(struct obuffer *b, int fd);
akalend/sophiaDb
src/mc.h
#ifndef __sophiadb_mch__ #define __sophiadb_mch__ #endif #ifdef __sophiadb_mch__ #include "main.h" #include <sys/socket.h> #define set_client_timeout(io,t_o) clients[(io)->fd].timeout = ev_now(EV_A) + t_o #define reset_client_timeout(io) clients[(io)->fd].timeout = 0 #define TIMEOUT_CHECK_INTERVAL 10 #define TIME_CHECK_INTERVAL 5 #define RECV_TIMEOUT 5 #define LPOLL_TIMEOUT 25 /* interval of time after which client will get 304 not modified response */ #define SPHDB_STRLEN 256 enum { SPHDB_UNDEF, SPHDB_INT, SPHDB_LONG, SPHDB_STRING }; typedef void (*cleanup_proc)(ev_io *data); typedef struct { void* env; void* db; char* datadir; int type; int datalen; } sophiadb_t; typedef struct { void * next; int number; char* comment; // the data type information int type; char* datadir; } datatype_t; typedef struct { char* logfile; int level; // error output level char* listen; char* pidfile; char * username; short is_demonize; short trace; char* datadir; int list_size; int max_num; datatype_t* list_datatypes; sophiadb_t* db; } conf_t; typedef struct { union { struct sockaddr name; struct sockaddr_in in_name; struct sockaddr_un un_name; }; int pf_family; socklen_t namelen; char *a_addr; } addr_t; typedef struct { ev_io io; /**< io descriptor */ char cmd[MAX_COMMAND_LEN]; /**< buffer for line-buffered input */ int cmd_len; /**< bytes in line buffer */ struct obuffer response; /**< response data */ char *value; /**< key value from last set command */ int value_len; /**< number of bytes in value buffer */ int value_size; /**< capacity of value buffer */ int data_size; /**< value size into cmd */ unsigned flag; /**< request flag read */ unsigned exptime; /**< request expire read */ char* key; /**< request key read */ int mode; } db_t; typedef struct { ev_tstamp timeout; /**< time, when this socked should be closed. */ int flags; /**< flags mask */ cleanup_proc cleanup; /**< cleanup handler */ struct timeval time; union { ev_io *io; /**< private data */ db_t *mc; /**< publisher */ }; } fd_ctx; void cllear_mc_all(); void close_io(EV_P_ ev_io *io); void close_all(EV_P); /* Serve */ void memcached_on_connect(EV_P_ ev_io *io, int revents); void periodic_watcher(EV_P_ ev_timer *t, int revents); /* declared server.c */ int set_nonblock(int sock,int value); #endif
akalend/sophiaDb
src/io_buffer.c
<reponame>akalend/sophiaDb #include "io_buffer.h" #include <unistd.h> #include <fcntl.h> #include <stdlib.h> #include <string.h> #include <errno.h> #define DISCARD_THRESHOLD 1024 /** Initialize input buffer structure. * @param $b input buffer. * @param $pool pool for memory allocation. * @param $initsize initial capacity. */ void ibuffer_init(struct ibuffer *b, bsize_t initsize, void *s_buf) { if (s_buf) { b->data = s_buf; b->flags |= IBUFFER_STATIC; } else { b->data = malloc(initsize); b->flags = 0; } b->length = 0; b->capacity = initsize; } /** Reset input buffer structure. * @param $b input buffer. * @param $pool pool for memory allocation. * @param $initsize initial capacity. */ void ibuffer_reset(struct ibuffer *b, bsize_t initsize, void *s_buf) { if (!(b->flags & IBUFFER_STATIC) && b->data) free(b->data); ibuffer_init(b, initsize, s_buf); } /** Free dynamically allocated buffer. * @param $b input buffer. */ void ibuffer_free(struct ibuffer *b) { if (!(b->flags & IBUFFER_STATIC) && b->data) free (b->data); } /** Resize input buffer so it can contain as lease size bytes. * @param $b input buffer. * @param $size new capacity. */ void ibuffer_reserve(struct ibuffer *b, bsize_t size) { while (b->capacity < size) b->capacity = (b->capacity + 1) * 2; if (b->flags & IBUFFER_STATIC) { void *new_data = malloc(b->capacity); if (b->length) memcpy(new_data, b->data, b->length); b->data = new_data; b->flags &= ~IBUFFER_STATIC; } else { b->data = realloc(b->data, b->capacity); } } /** Append data to buffer contents (internal). */ static void ibuffer_append(struct ibuffer *b, const void *data, bsize_t size) { if (b->length + size <= b->capacity) { ibuffer_reserve(b, b->length + size); } memcpy(b->u_data + b->length, data, size); b->length += size; } /** Discard data from input queue. * @param $b input buffer. * @param $size bytes to discard. */ void ibuffer_discard(struct ibuffer *b, bsize_t size) { /* Disard all data */ if (size == 0 || size >= b->length) { b->length = 0; } else { memmove(b->u_data, b->u_data + size, b->length - size); b->length -= size; } } /** Read from file descriptor until buffer fully filled (capacity reached). * @param $b input buffer. * @param $fd file descriptor to read from. * @return end-of-file flag in b->flags and <ul> * <li>-1 and errno from last read operation on error. * <li>number of bytes read from $fd. * </ul> */ bssize_t ibuffer_read(struct ibuffer *b, int fd) { bssize_t bytes = 0; ssize_t nbytes; if (b->length == b->capacity) ibuffer_reserve(b, (b->capacity + 1) * 2); while (b->length + bytes < b->capacity) { bsize_t s = b->capacity - b->length - bytes; nbytes = read(fd, b->u_data + b->length + bytes, s); if (nbytes > 0) { bytes += nbytes; } else if (nbytes < 0) { if (errno == EAGAIN) break; if (errno == EINTR) continue; return -1; } else { b->flags |= IBUFFER_EOF; break; // EOF } } b->length += bytes; return bytes; } /** Read from file descriptor up to N bytes. * @param $b input buffer. * @param $size maximum count of bytes to read. * @param $fd file descriptor to read from. * @return end-of-file flag in b->eof and <ul> * <li>-1 and errno from last read operation on error. * <li>number of bytes read from $fd. * </ul> */ bssize_t ibuffer_readn(struct ibuffer *b, int fd, bsize_t size) { if (b->length + size < b->capacity) ibuffer_reserve(b, b->length + size); return ibuffer_read(b,fd); } /** Send shared data. * @param $b buffer. * @param $data data to send (MUST be available while buffer object exists). * @param $size data length in bytes. */ void obuffer_init(struct obuffer *b, const void *data, bsize_t size) { b->data = data; b->pos = 0; b->length = size; } /** Send data to socket. * @param $b buffer. * @param $fd file descriptor to send to. * @return -1 on error, bytes letf to send when success, so 0 meand all data had been sent. */ int obuffer_send(struct obuffer *b, int fd) { while (b->pos < b->length) { ssize_t bytes = write(fd, b->u_data + b->pos, b->length - b->pos); if (bytes > 0) { b->pos += bytes; } else { if (errno == EAGAIN) break; if (errno == EINTR) continue; return -1; } } return b->length - b->pos; }
akalend/sophiaDb
src/main.c
<gh_stars>1-10 /* выпилить лог, заменить на суслог */ #include "main.h" #include "mc.h" #include "ini.h" #include <sophia.h> #include <sys/time.h> #include <libgen.h> #include <netdb.h> #ifdef PREFIX #define CONFIGFILE PREFIX"/conf/config.ini" #else #define CONFIGFILE "config.ini" #endif #define MYMC_VERSION "1.0" extern void parse(const char* fname, conf_t *server_ctx); static inline int cmp32(char *a, size_t asz, char *b, size_t bsz, void *arg) { register uint32_t av = *(uint32_t*)a; register uint32_t bv = *(uint32_t*)b; if (av == bv) return 0; return (av > bv) ? 1 : -1; } static inline int cmp64(char *a, size_t asz, char *b, size_t bsz, void *arg) { register uint64_t av = *(uint64_t*)a; register uint64_t bv = *(uint64_t*)b; if (av == bv) return 0; return (av > bv) ? 1 : -1; } static inline int cmp0(char *a, size_t asz, char *b, size_t bsz, void *arg) { return 0; } static const char *listen_addr; conf_t server_ctx; const char *confilename = NULL; FILE *flog = NULL; int max_clients = 0; fd_ctx *clients = NULL; int is_finish = 0; int is_trace = 0; struct timeval t_start; // start timeinterval struct timeval t_end; // finish timeinterval struct { /* some stat data */ unsigned connections; // active connections (memcache clients) unsigned cnn_count; // count connectionss unsigned cmd_per; // count of commands into period unsigned cmd_count; // count of commands float rps; // last count of commands per second float rps_peak; // peak of commands per second unsigned get; // count of get commands unsigned set; // count of set/append/prepend/incr/decr commands unsigned del; // count of delete commands unsigned inc; // count of increment/decrement commands unsigned miss; // count of miss keys (key not found) time_t uptime; // uptime server unsigned err; // count of errors } stats = {0,0,0,0,0,0,0,0,0,0,0,0,0}; static void usage(const char *binary,int exitcode) { const char *name = strrchr(binary, '/'); name = name ? name+1 : binary; printf("Usage: %s [options]\n" "default port: %s\n" "Options are:\n" " -n, --max-clients=limit maximum number of open files (like ulimit -n)\n" " -V, --version show version\n" " -h, --help this help message\n" " -c configfile config filename or config.ini in the current dir" " -t trace commands\n", name, listen_addr); exit(exitcode); }; void perror_fatal(const char *what) { perror(what); exit(EXIT_FAILURE); } sophiadb_t* db_init(void * conf) { conf_t * pconf = (conf_t *)conf; printf("size of datatype = %d\n",pconf->max_num); sophiadb_t* db = (sophiadb_t*) calloc(pconf->max_num, sizeof(sophiadb_t)); if (!db) { printf("error alloc size=%lu\n", sizeof(sophiadb_t)); exit(1); } assert(db); datatype_t * p = (datatype_t *)pconf->list_datatypes; spcmpf fcmp ; while(p) { fcmp = cmp0; if (p->number <= 0) { printf("error config parametr: number=%d \n", p->number ); free(db); return NULL; } db[p->number-1].type = p->type; db[p->number-1].datadir = p->datadir; switch (p->type) { case SPHDB_INT : db[p->number-1].datalen = sizeof(int32_t); fcmp = cmp32; break; case SPHDB_LONG : db[p->number-1].datalen = sizeof(int64_t); fcmp = cmp64; break; case SPHDB_STRING : db[p->number-1].datalen = SPHDB_STRLEN; break; default: printf("error: undefined config datatype\n"); free(db); exit(1); } printf("fcmp: fcmp=%x\n", fcmp); db[p->number-1].env = sp_env(); if (db[p->number-1].env == NULL) { /* memory allocation error */ printf("env error\n"); free(db); exit(1); } int rc = sp_ctl(db[p->number-1].env, SPDIR, SPO_CREAT|SPO_RDWR, p->datadir); if (rc == -1) { /* memory allocation error */ printf("error: %s\n", sp_error(db[p->number-1].env)); sp_destroy(db[p->number-1].env); free(db); exit(1); } if (fcmp != cmp0) { printf("%s type=%d %x\n", p->datadir, p->type , fcmp); rc = sp_ctl(db[p->number-1].env, SPCMP, fcmp, NULL); if (rc == -1) { /* memory allocation error */ printf("error: %s\n", sp_error(db[p->number-1].env)); sp_destroy(db[p->number-1].env); free(db); exit(1); } } db[p->number-1].db = sp_open(db[p->number-1].env); if (db[p->number-1].db == NULL) { printf("sp_open: %s\n", sp_error(db[p->number-1].env)); sp_destroy(db[p->number-1].env); exit(1); } p = p->next; } printf("db is open %s\n", pconf->datadir ); return db; } void destroy(sophiadb_t* ctx) { assert(ctx); sp_destroy(ctx->db); sp_destroy(ctx->env); free(ctx); } void free_config() { if (server_ctx.logfile) free(server_ctx.logfile); server_ctx.logfile = NULL; if (server_ctx.datadir) free(server_ctx.datadir); server_ctx.datadir = NULL; if (server_ctx.username) free(server_ctx.username); server_ctx.username = NULL; if (server_ctx.pidfile) free(server_ctx.pidfile); server_ctx.pidfile = NULL; if (server_ctx.listen) free(server_ctx.listen); server_ctx.listen = NULL; datatype_t *p = (datatype_t*) server_ctx.list_datatypes, *old; while(p) { // printf("number:%d\ntype:%d\nlink:%d\n",p->number, p->type,p->link); if (p->comment) { // printf("comment: '%s'\n", p->comment); free(p->comment); } // printf("\n"); old = p; p = p->next; free(old); } server_ctx.list_datatypes = NULL; } void ignore_sigpipe() { struct sigaction sa; sa.sa_handler = SIG_IGN; sa.sa_flags = 0; if (sigemptyset(&sa.sa_mask) == -1 || sigaction(SIGPIPE, &sa, 0) == -1) { perror("failed to ignore SIGPIPE; sigaction"); exit(EXIT_FAILURE); } } static void set_rlimit() { struct rlimit r; if (max_clients) { r.rlim_cur = r.rlim_max = max_clients; if (setrlimit(RLIMIT_NOFILE, &r) == -1) { perror_fatal("setrlimit"); } } else { if (getrlimit(RLIMIT_NOFILE, &r) == -1) { perror_fatal("getrlimit"); } max_clients = r.rlim_cur; } } static int init_addr( addr_t *addr, const char *astring) { addr->a_addr = strdup(astring); /* Make correct sockaddr */ if (strncmp(astring,"file:",5) == 0) { /* local namespace */ struct sockaddr_un *name = &addr->un_name; addr->pf_family = PF_LOCAL; name->sun_family = AF_LOCAL; strncpy (name->sun_path, astring+5, sizeof(name->sun_path)); name->sun_path[sizeof(name->sun_path)-1] = '\0'; addr->namelen = SUN_LEN(name); } else { /* inet namespace */ struct sockaddr_in *name = &addr->in_name; char *colon = strchr(addr->a_addr, ':'); addr->pf_family = PF_INET; if (colon || isdigit(*addr->a_addr)) { if (colon && colon != addr->a_addr) { struct hostent *hostinfo; *colon = 0; hostinfo = gethostbyname (addr->a_addr); if (hostinfo == NULL) { free (addr->a_addr); addr->a_addr=NULL; return 1; } *colon = ':'; name->sin_addr = *(struct in_addr*)hostinfo->h_addr; } else { name->sin_addr.s_addr = htonl(INADDR_ANY); } name->sin_family = AF_INET; name->sin_port = htons(atoi(colon ? colon+1 : addr->a_addr)); addr->namelen = sizeof(struct sockaddr_in); } else { free (addr->a_addr); addr->a_addr=NULL; return 1; } } return 0; } int set_nonblock(int sock,int value) { long fl = fcntl(sock, F_GETFL); if (fl == -1) return fl; if (value) fl |= O_NONBLOCK; else fl &= ~O_NONBLOCK; return fcntl (sock, F_SETFL, fl); } /** * signal SIGHUP callback */ static void sighup_cb (struct ev_loop *loop, struct ev_signal *w, int revents) { stats.cmd_count = 0; stats.get = 0; stats.set = 0; stats.del = 0; stats.miss = 0; stats.err = 0; time(&stats.uptime); is_finish = 1; if (!max_clients) ev_unloop (loop, EVUNLOOP_ALL); if (!stats.connections) ev_unloop (loop, EVUNLOOP_ONE); is_finish = 0; sophiadb_t* ctx = ev_userdata(EV_A); free_config(); if (confilename) parse(confilename, &server_ctx); else parse("config.ini", &server_ctx); // ctx->types = malloc((server_ctx.max_num+1) * sizeof(int)); // ctx->types[0] = server_ctx.max_num; datatype_t * p = (datatype_t *)server_ctx.list_datatypes; // printf("max banks=%d\n", ctx->conf->max_num); while(p) { // ctx->types[p->number] = p->datalen; printf("%s:%d %d:%d [%s] \n", __FUNCTION__,__LINE__, p->number,p->type, p->comment); p = p->next; } ev_loop(loop,0); } /** * signal SIGINT callback */ static void sigint_cb (struct ev_loop *loop, struct ev_signal *w, int revents) { // printf("recv signal SIGINT cnn=%d\n", stats.connections); is_finish = 1; if (!stats.connections) { // printf("cnn = 0\n"); ev_unloop (loop, EVUNLOOP_ALL); return; } } static void listen_sock(int mc_sock, addr_t *mc_addr) { { // set sock option int flag = 1; setsockopt(mc_sock, SOL_SOCKET, SO_REUSEADDR, &flag, sizeof(flag)); long fl = fcntl(mc_sock, F_GETFL); if (fl == -1) perror_fatal("can't get fcntl sock option"); set_nonblock(mc_sock,1); } if ( bind(mc_sock, &mc_addr->name, mc_addr->namelen) < 0) perror_fatal("bind"); if (listen(mc_sock, 10) < 0) perror_fatal("publisher listen"); } static void daemonize(int do_daemonize, const char *pidfile, const char *run_as) { int fd; /* Daemonize part 1 */ if (do_daemonize) { switch (fork()) { case -1: perror("fork"); exit(1); case 0: break; default: exit(EXIT_SUCCESS); } if (setsid() == -1) perror_fatal("setsid"); } /* Change effective uid/gid if requested */ if (run_as) { struct passwd *pw = getpwnam(run_as); if (!pw) { fprintf(stderr, "No such user: \"%s\"\n", run_as); exit(EXIT_FAILURE); } if (setgid(pw->pw_gid) < 0 || setuid(pw->pw_uid) < 0) { fprintf(stderr, "Can't switch to user \"%s\": %s\n", run_as, strerror(errno)); exit(EXIT_FAILURE); } } /* Save PID file if requested */ if (pidfile) { FILE *fpid = fopen(pidfile, "w"); if (!fpid) perror_fatal("Can't create pid file"); fprintf(fpid, "%ld", (long)getpid()); fclose(fpid); } /* Daemonize part 2 */ if (do_daemonize) { if(chdir("/") != 0) perror_fatal("chdir"); if ((fd = open("/dev/null", O_RDWR, 0)) != -1) { if(dup2(fd, STDIN_FILENO) < 0) perror_fatal("dup2 stdin"); if(dup2(fd, STDOUT_FILENO) < 0) perror_fatal("dup2 stdout"); if(dup2(fd, STDERR_FILENO) < 0) perror_fatal("dup2 stderr"); if (fd > STDERR_FILENO && close(fd) < 0) perror_fatal("close"); } else { perror_fatal("open(\"/dev/null\")"); } } } int main(int argc, char **argv){ int mc_sock; addr_t mc_addr; ev_io mc_io; sophiadb_t * db; int c; while (1) { int option_index = 0; static struct option long_options[] = { {"help", no_argument, 0, 'h'}, {"version", no_argument, 0, 'V'}, {"max-clients", required_argument, 0, 'l'}, {0, 0, 0, 0} }; c = getopt_long(argc, argv, "n:Vc:t", long_options, &option_index); if (c == -1) break; switch (c) { case 'c': confilename = optarg; break; case 'n': max_clients = atoi(optarg); break; case 'V': printf("Version %s\n", MYMC_VERSION); exit(0); case 't': is_trace = 1; break; default: usage(argv[0], c == 'h' ? EXIT_SUCCESS : EXIT_FAILURE); } } if (confilename) parse(confilename, &server_ctx); else parse( CONFIGFILE, &server_ctx); //assert(server_ctx.logfile); //assert(server_ctx.listen); if (!server_ctx.listen) { perror("undefined listen port"); exit(1); } flog = server_ctx.logfile ? fopen(server_ctx.logfile, "a+") : fopen("error.log", "a+"); if (flog) { time_t lt; lt = time(NULL); fprintf(flog, "server started at %s\n",ctime(&lt)); } else { perror("can not create log file"); exit(1); } daemonize(server_ctx.is_demonize, server_ctx.pidfile, server_ctx.username); set_rlimit(); ignore_sigpipe(); init_addr(&mc_addr, server_ctx.listen); mc_sock = socket(mc_addr.pf_family, SOCK_STREAM, 0); if (mc_sock < 0) { perror("can't create socket"); exit(1); } listen_sock(mc_sock, &mc_addr); //TODO if (is_trace) printf("pid=%ld\n\n", (long)getpid()); clients = calloc(max_clients, sizeof(fd_ctx)); if (!clients) { perror_fatal("Cannot allocate array for client descriptors!"); } int i=0; while(i < max_clients) { if(clients[i].mc) printf("init err %i\n", i); i++; } db = db_init(&server_ctx); assert(db); struct ev_loop *loop = ev_default_loop(0); assert(loop); ev_set_userdata(loop,(void*)db); ev_io_init( &mc_io, memcached_on_connect, mc_sock, EV_READ); ev_io_start(loop, &mc_io); struct ev_timer timeout_watcher; ev_init(&timeout_watcher, periodic_watcher); timeout_watcher.repeat = TIME_CHECK_INTERVAL; ev_timer_again(loop, &timeout_watcher); struct ev_signal signal_watcher,signal_watcher2; // ev_signal_init (&signal_watcher, sigint_cb, SIGINT); // ev_signal_start (loop, &signal_watcher); ev_signal_init (&signal_watcher, sigint_cb, SIGTERM); ev_signal_start (loop, &signal_watcher); ev_signal_init (&signal_watcher2, sighup_cb, SIGHUP); ev_signal_start (loop, &signal_watcher2); //start server time(&stats.uptime); gettimeofday(&t_start, NULL); // event loop ev_loop(loop, 0); cllear_mc_all(); close(mc_sock); if (clients) free(clients); //ev_loop_destroy(loop); destroy(db); if (mc_addr.a_addr) free(mc_addr.a_addr); if (server_ctx.pidfile) { if( unlink(server_ctx.pidfile)) printf("cannot delete pid file %s %s\n",server_ctx.pidfile, strerror(errno)); } free_config(); if (flog) { time_t lt; lt = time(NULL); fprintf(flog, "server finis Ok at %s\n",ctime(&lt)); fclose(flog); } return 0; }
marce-ldv/swiftCache
CacheManager/CacheManager.h
// // CacheManager.h // CacheManager // // Created by <NAME> on 22/04/2020. // Copyright © 2020 <NAME>. All rights reserved. // #import <Foundation/Foundation.h> //! Project version number for CacheManager. FOUNDATION_EXPORT double CacheManagerVersionNumber; //! Project version string for CacheManager. FOUNDATION_EXPORT const unsigned char CacheManagerVersionString[]; // In this header, you should import all the public headers of your framework using statements like #import <CacheManager/PublicHeader.h>
zedshaw/earing
tests/repl_tests.c
#include <cut/2.6/cut.h> void __CUT__repl_test( void ) { ASSERT( 1, "Any non-zero value must always pass an ASSERT." ); }
zedshaw/earing
src/module.c
#include "module.h" #include <assert.h> #include <stdio.h> #include <stdint.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include "directives.h" #include "grammar.h" #include <string.h> #include "error.h" #include <gc/gc.h> #include <gc/cord.h> Module *Module_create(const char *name, size_t max_code_size) { Module *state = GC_MALLOC( sizeof(Module)); assert(state && "Memory alloc failure for Module."); state->curline = 1; state->module_name = strdup(name); state->max_code_size = max_code_size; return state; } Module *Module_resolve_module(Module *state, Token *ident) { if(CORD_cmp(ident->data, "self")) { return state; } else { return (Module *)tst_search(state->imports, ident->start, ident->len); } } Token *Module_resolve_function_data(Function *func, Token *ident) { Token *expr = tst_search(func->data, ident->start, ident->len); if(expr) { *ident = *expr; // copy it over reusing the ident return ident; } else { return NULL; } } Token *Module_outside_function_data(Module *state, Token *func_ref, Token *ident) { Token *expr = NULL; Function *func = Function_find(state, func_ref->start, func_ref->len); if(func) expr = Module_resolve_function_data(func, ident); if(!expr) { die(state, "function %.*s doesn't have data named %.*s", func_ref->len, func_ref->start, ident->len, ident->start); } return expr; } Token *Module_resolve_data(Module *state, Token *ident) { if(!state->current) { Token *expr = tst_search(state->data, ident->start, ident->len); if(expr) { return expr; } else { die(state, "failed to find %.*s module constant.", ident->len, ident->start); return NULL; } } Token *expr = Module_resolve_function_data(state->current, ident); if(expr) { return expr; } else { expr = Function_resolve_param(state, state->current, ident); if(expr) { return expr; } else { // try to find it in the module expr = tst_search(state->data, ident->start, ident->len); if(expr) { *ident = *expr; return ident; } else { die(state, "failed to resolve %.*s, not a parameter or constant\n", ident->len, ident->start); return NULL; } } } } Token *Module_resolve_function(Module *state, Token *module, Token *ident) { void *result = NULL; Module *mod = Module_resolve_module(state, module); if(mod) { Function *func = Function_find(mod, ident->start, ident->len); if(func) { result = func->code; } } else { result = Library_search(state, module, ident); } if(result != NULL) { // it's a function defined in this module ident->value = (unsigned long)result; } else { // it's not found so not a possible ident die(state, "did not find function %.*s in a library or module named %.*s.", ident->len, ident->start, module->len, module->start); } return ident; } void Module_call_directive(Module *state, Token *ident, Parameters *params) { Directive *to_call = (Directive *)tst_search(state->directives, ident->start, ident->len); if(to_call) { to_call->call(state, params); } else { die(state, "referenced directive %.*s which doesn't exist.", ident->len, ident->start); } } int Module_register_directive(Module *state, const char *name, int length, Module_directive_cb call, Module_directive_cb destroy) { Directive *d = GC_MALLOC(sizeof(Directive)); assert(d && "Memory allocation failed for Directive."); if(tst_search(state->directives, name, length)) { die(state, "Directive %.*s already exists in the directive list.", length, name); return 0; } else { d->name = name; d->len = length; d->call = call; d->destroy = destroy; state->directives = tst_insert(state->directives, name, length, d); return 1; } } void Module_create_constant(Module *state, Token *ident, Token *expr) { if(tst_search(state->data, ident->start, ident->len)) { die(state, "you already defined a constant named %.*s in this module.", ident->len, ident->start); } else { state->data = tst_insert(state->data, ident->start, ident->len, expr); assert(state->data && "Unable to insert an element into the module data store."); if(expr->id == TK_STR) { // need to disconnect this from its actual source for reference later. expr->value = (unsigned long)strndup(expr->start, expr->len); } } } void Module_create_function_constant(Module *state, Token *ident, Token *expr) { if(tst_search(state->current->data, ident->start, ident->len)) { die(state, "you already defined a function constant named %.*s", ident->len, ident->start); } else { state->current->data = tst_insert(state->current->data, ident->start, ident->len, expr); assert(state->current->data && "Unable to insert an element into the module data store."); if(expr->id == TK_STR) { // need to disconnect this from its actual source for reference later. expr->value = (unsigned long)strndup(expr->start, expr->len); } } } void Module_dump_directives(Module *state, FILE *out) { void dump(void *p, void *ignored) { Directive *d = p; fprintf(out, "directive: %.*s\n", d->len, d->name); } tst_traverse(state->directives, dump, NULL); }
zedshaw/earing
src/allocator_ops.h
int inst_size_of(Module *state, Token *type, array_t *args); int inst_alloc(Module *state, Token *type, array_t *args); int inst_realloc(Module *state, Token *type, array_t *args); int inst_free(Module *state, Token *type, array_t *args); int inst_collect(Module *state, Token *type, array_t *args);
zedshaw/earing
src/error.c
#include "error.h" #include <stdarg.h> #include <gc/cord.h> static void print_location(Module *state) { if(state) { printf("%s:%d: ", state->module_name, state->curline); if(state->current) { CORD_printf("in function %r, ", state->current->name); } } } void error(Module *state, const char *format, ...) { va_list ap; va_start(ap, format); print_location(state); CORD_vprintf(format, ap); printf("\n"); } void die(Module *state, const char *format, ...) { va_list ap; va_start(ap, format); if(state) { print_location(state); } CORD_vprintf(format, ap); printf("\n"); exit(1); }
zedshaw/earing
src/token.h
<gh_stars>1-10 #ifndef token_h #define token_h #include "array.h" #include <gc/cord.h> struct Module; struct Token; /** * This is attached to operation tokens and is called later to do the actual byte code * generation. */ typedef int (*f_inst_call)(struct Module *state, struct Token *type, array_t *params); /** * A Token holds almost all of the data, since an assembler is so simple * we can actually put the values inside the token. */ typedef struct Token { // all tokens have this int id; CORD data; // different tokens have these set mutually exclusive f_inst_call call; // lightning apparently does lots of casting, so we just need the biggest numeric for storage unsigned long value; } Token; Token *Token_create(int id, CORD data, f_inst_call call); #define TK(I,C) (Token_create(I, CORD_from_char_star(te-ts,ts), C)) #define KW(T) Parse(pParser, TK_##T, TK(TK_##T,0), state); #define SYM(T) Parse(pParser, TK_##T, TK(TK_##T,0), state); #define IDENT() Parse(pParser, TK_IDENT, TK(TK_IDENT,0), state); #define OP(T) Parse(pParser, TK_OP, TK(TK_OP,inst_##T), state); #define TYPE(T) tk = TK(TK_TYPE,0); tk->value = OpType_##T; Parse(pParser, TK_TYPE, tk, state); #define LABEL() Parse(pParser, TK_LABEL, TK(TK_LABEL,0), state); #define NO_LEAF(name) if(state->current_is_leaf)\ die(state, "You cannot do " # name " in a function declared %%leaf."); #define REG(T) tk = TK(TK_REG,0); tk->value = JIT_##T; Parse(pParser, TK_REG, tk, state); #endif
zedshaw/earing
src/allocator_ops.c
<reponame>zedshaw/earing /* these are included directly into src/ops.c */ #include "allocator.h" int inst_size_of(Module *state, Token *type, array_t *params) { if(type) { if(array_length(params) != 1) die(state, "sizeof requires 1 parameter for a type."); } else { if(array_length(params) != 2) die(state, "sizeof requires 2 parameters for data."); } return 1; } int inst_alloc(Module *state, Token *type, array_t *params) { if(array_length(params) != 2) die(state, "alloc requires 2 parameters."); if(type) die(state, "Operation alloc does not take a type."); int size = array_of(Token, params, 1)->value; jit_movi_i(array_of(Token, params, 0)->value, size); jit_prepare_i(1); jit_pusharg_p(array_of(Token, params, 0)->value); jit_finish(Allocator_malloc); jit_retval(array_of(Token, params, 0)->value); return 1; } int inst_realloc(Module *state, Token *type, array_t *params) { if(array_length(params) != 2) die(state, "realloc requires 2 parameters."); if(type) die(state, "Operation realloc does not take a type."); jit_movi_i(JIT_R0, array_of(Token, params, 1)->value); jit_prepare_i(2); jit_pusharg_i(JIT_R0); jit_pusharg_p(array_of(Token, params, 0)->value); jit_finish(Allocator_realloc); jit_retval(array_of(Token, params, 0)->value); return 1; } int inst_free(Module *state, Token *type, array_t *params) { if(array_length(params) != 1) die(state, "free requires 1 parameters."); if(type) die(state, "Operation free does not take a type."); jit_prepare_i(1); jit_pusharg_p(array_of(Token, params, 0)->value); jit_calli(Allocator_free); return 1; } int inst_collect(Module *state, Token *type, array_t *params) { if(array_length(params) != 0) die(state, "collect requires 0 parameters."); if(type) die(state, "Operation collect does not take a type."); jit_calli(Allocator_collect); return 1; }
zedshaw/earing
src/function.c
#include "module.h" #include "directives.h" #include "grammar.h" #include "error.h" #include "array.h" #include "hash.h" #include <gc/gc.h> #include <gc/cord.h> #include <assert.h> Function *Function_find(Module *state, CORD name) { hnode_t *hn = hash_lookup(state->functions, name); return hn ? hnode_get(hn) : NULL; } void FunctionParam_create(Function *func, Token *ident, Token *type) { FunctionParam *p = GC_MALLOC(sizeof(FunctionParam)); assert(p && "Failed to allocate FunctionParam."); p->name = ident->data; p->type = type->value; array_add(func->params, p); } /* Returns a -1 when it doesn't find that parameter. */ int FunctionParam_index(Function *func, Token *ident) { FunctionParam *param = NULL; size_t i = 0; for(i = 0; i < array_length(func->params); i++) { param = (CORD)array_at(func->params, i); if(CORD_cmp(param->name, ident->data) == 0) { return i; } } return -1; } Token *Function_resolve_param(Module *state, Function *func, Token *ident) { if(!func) return ident; // skip any processing if not in a function unsigned long value = (unsigned long)FunctionParam_index(func, ident); if(value != -1) { // it's a function parameter ident->value = value; } else { return NULL; } return ident; }
zedshaw/earing
src/array.c
<reponame>zedshaw/earing #include "array.h" #include <gc/gc.h> #include <assert.h> array_t *array_create(size_t size) { array_t *ary = GC_MALLOC(sizeof(array_t) + size * sizeof(void *)); ary->size = size; ary->end = 0; return ary; } size_t array_add(array_t *ary, void *el) { assert(ary != NULL && "array_t can't be NULL."); assert(!array_isfull(ary) && "array_t is full."); assert(el != NULL && "can't put a NULL value in."); ary->data[ary->end] = el; ary->end++; return array_length(ary); } void *array_pop(array_t *ary) { assert(ary != NULL && "array_t can't be NULL."); if(ary->end == 0) { return NULL; } else { ary->end--; return ary->data[ary->end]; } } array_t *array_extend(array_t *ary, size_t by) { assert(ary != NULL && "array_t can't be NULL"); assert(by != 0 && "can't extend by 0."); ary->size += by; ary = GC_REALLOC(ary, sizeof(array_t) + ary->size * sizeof(void *)); return ary; } array_t *array_clamp(array_t *ary) { assert(ary != NULL && "array_t can't be NULL"); assert(!array_isempty(ary) && "can't clamp an empty array."); ary->size = ary->end; ary = GC_REALLOC(ary, sizeof(array_t) + ary->size * sizeof(void *)); return ary; }
zedshaw/earing
src/ops.c
#include "module.h" #include "allocator_ops.c" int inst_addr(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "addr requires 3 parameters."); if(!type) die(state, "addr requires type of: ['i', 'ui', 'l', 'ul', 'p', 'f', 'd']."); switch(type->value) { case OpType_i: jit_addr_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_addr_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_addr_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_addr_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_p: jit_addr_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_f: jit_addr_f (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_d: jit_addr_d (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation addr, only ['i', 'ui', 'l', 'ul', 'p', 'f', 'd'] allowed."); } return 1; } int inst_addi(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "addi requires 3 parameters."); if(!type) die(state, "addi requires type of: ['i', 'ui', 'l', 'ul', 'p']."); switch(type->value) { case OpType_i: jit_addi_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_addi_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_addi_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_addi_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_p: jit_addi_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation addi, only ['i', 'ui', 'l', 'ul', 'p'] allowed."); } return 1; } int inst_addxr(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "addxr requires 3 parameters."); if(!type) die(state, "addxr requires type of: ['i', 'ui']."); switch(type->value) { case OpType_i: jit_addxr_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_addxr_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation addxr, only ['i', 'ui'] allowed."); } return 1; } int inst_addxi(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "addxi requires 3 parameters."); if(!type) die(state, "addxi requires type of: ['i', 'ui']."); switch(type->value) { case OpType_i: jit_addxi_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_addxi_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation addxi, only ['i', 'ui'] allowed."); } return 1; } int inst_addcr(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "addcr requires 3 parameters."); if(!type) die(state, "addcr requires type of: ['i', 'ui']."); switch(type->value) { case OpType_i: jit_addcr_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_addcr_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation addcr, only ['i', 'ui'] allowed."); } return 1; } int inst_addci(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "addci requires 3 parameters."); if(!type) die(state, "addci requires type of: ['i', 'ui']."); switch(type->value) { case OpType_i: jit_addci_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_addci_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation addci, only ['i', 'ui'] allowed."); } return 1; } int inst_subr(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "subr requires 3 parameters."); if(!type) die(state, "subr requires type of: ['i', 'ui', 'l', 'ul', 'p', 'f', 'd']."); switch(type->value) { case OpType_i: jit_subr_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_subr_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_subr_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_subr_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_p: jit_subr_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_f: jit_subr_f (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_d: jit_subr_d (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation subr, only ['i', 'ui', 'l', 'ul', 'p', 'f', 'd'] allowed."); } return 1; } int inst_subi(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "subi requires 3 parameters."); if(!type) die(state, "subi requires type of: ['i', 'ui', 'l', 'ul', 'p']."); switch(type->value) { case OpType_i: jit_subi_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_subi_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_subi_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_subi_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_p: jit_subi_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation subi, only ['i', 'ui', 'l', 'ul', 'p'] allowed."); } return 1; } int inst_subxr(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "subxr requires 3 parameters."); if(!type) die(state, "subxr requires type of: ['i', 'ui']."); switch(type->value) { case OpType_i: jit_subxr_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_subxr_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation subxr, only ['i', 'ui'] allowed."); } return 1; } int inst_subxi(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "subxi requires 3 parameters."); if(!type) die(state, "subxi requires type of: ['i', 'ui']."); switch(type->value) { case OpType_i: jit_subxi_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_subxi_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation subxi, only ['i', 'ui'] allowed."); } return 1; } int inst_subcr(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "subcr requires 3 parameters."); if(!type) die(state, "subcr requires type of: ['i', 'ui']."); switch(type->value) { case OpType_i: jit_subcr_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_subcr_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation subcr, only ['i', 'ui'] allowed."); } return 1; } int inst_subci(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "subci requires 3 parameters."); if(!type) die(state, "subci requires type of: ['i', 'ui']."); switch(type->value) { case OpType_i: jit_subci_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_subci_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation subci, only ['i', 'ui'] allowed."); } return 1; } int inst_rsbr(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "rsbr requires 3 parameters."); if(!type) die(state, "rsbr requires type of: ['i', 'ui', 'l', 'ul', 'p', 'f', 'd']."); switch(type->value) { case OpType_i: jit_rsbr_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_rsbr_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_rsbr_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_rsbr_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_p: jit_rsbr_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_f: jit_rsbr_f (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_d: jit_rsbr_d (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation rsbr, only ['i', 'ui', 'l', 'ul', 'p', 'f', 'd'] allowed."); } return 1; } int inst_rsbi(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "rsbi requires 3 parameters."); if(!type) die(state, "rsbi requires type of: ['i', 'ui', 'l', 'ul', 'p']."); switch(type->value) { case OpType_i: jit_rsbi_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_rsbi_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_rsbi_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_rsbi_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_p: jit_rsbi_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation rsbi, only ['i', 'ui', 'l', 'ul', 'p'] allowed."); } return 1; } int inst_mulr(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "mulr requires 3 parameters."); if(!type) die(state, "mulr requires type of: ['i', 'ui', 'l', 'ul', 'f', 'd']."); switch(type->value) { case OpType_i: jit_mulr_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_mulr_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_mulr_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_mulr_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_f: jit_mulr_f (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_d: jit_mulr_d (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation mulr, only ['i', 'ui', 'l', 'ul', 'f', 'd'] allowed."); } return 1; } int inst_muli(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "muli requires 3 parameters."); if(!type) die(state, "muli requires type of: ['i', 'ui', 'l', 'ul']."); switch(type->value) { case OpType_i: jit_muli_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_muli_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_muli_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_muli_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation muli, only ['i', 'ui', 'l', 'ul'] allowed."); } return 1; } int inst_hmulr(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "hmulr requires 3 parameters."); if(!type) die(state, "hmulr requires type of: ['i', 'ui']."); switch(type->value) { case OpType_i: jit_hmulr_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_hmulr_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation hmulr, only ['i', 'ui'] allowed."); } return 1; } int inst_hmuli(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "hmuli requires 3 parameters."); if(!type) die(state, "hmuli requires type of: ['i', 'ui', 'l', 'ul']."); switch(type->value) { case OpType_i: jit_hmuli_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_hmuli_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_hmuli_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_hmuli_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation hmuli, only ['i', 'ui', 'l', 'ul'] allowed."); } return 1; } int inst_divr(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "divr requires 3 parameters."); if(!type) die(state, "divr requires type of: ['i', 'ui', 'l', 'ul', 'f', 'd']."); switch(type->value) { case OpType_i: jit_divr_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_divr_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_divr_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_divr_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_f: jit_divr_f (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_d: jit_divr_d (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation divr, only ['i', 'ui', 'l', 'ul', 'f', 'd'] allowed."); } return 1; } int inst_divi(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "divi requires 3 parameters."); if(!type) die(state, "divi requires type of: ['i', 'ui', 'l', 'ul']."); switch(type->value) { case OpType_i: jit_divi_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_divi_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_divi_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_divi_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation divi, only ['i', 'ui', 'l', 'ul'] allowed."); } return 1; } int inst_modr(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "modr requires 3 parameters."); if(!type) die(state, "modr requires type of: ['i', 'ui', 'l', 'ul']."); switch(type->value) { case OpType_i: jit_modr_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_modr_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_modr_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_modr_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation modr, only ['i', 'ui', 'l', 'ul'] allowed."); } return 1; } int inst_modi(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "modi requires 3 parameters."); if(!type) die(state, "modi requires type of: ['i', 'ui', 'l', 'ul']."); switch(type->value) { case OpType_i: jit_modi_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_modi_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_modi_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_modi_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation modi, only ['i', 'ui', 'l', 'ul'] allowed."); } return 1; } int inst_andr(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "andr requires 3 parameters."); if(!type) die(state, "andr requires type of: ['i', 'ui', 'l', 'ul']."); switch(type->value) { case OpType_i: jit_andr_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_andr_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_andr_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_andr_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation andr, only ['i', 'ui', 'l', 'ul'] allowed."); } return 1; } int inst_andi(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "andi requires 3 parameters."); if(!type) die(state, "andi requires type of: ['i', 'ui', 'l', 'ul']."); switch(type->value) { case OpType_i: jit_andi_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_andi_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_andi_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_andi_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation andi, only ['i', 'ui', 'l', 'ul'] allowed."); } return 1; } int inst_orr(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "orr requires 3 parameters."); if(!type) die(state, "orr requires type of: ['i', 'ui', 'l', 'ul']."); switch(type->value) { case OpType_i: jit_orr_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_orr_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_orr_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_orr_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation orr, only ['i', 'ui', 'l', 'ul'] allowed."); } return 1; } int inst_ori(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "ori requires 3 parameters."); if(!type) die(state, "ori requires type of: ['i', 'ui', 'l', 'ul']."); switch(type->value) { case OpType_i: jit_ori_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_ori_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_ori_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_ori_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation ori, only ['i', 'ui', 'l', 'ul'] allowed."); } return 1; } int inst_xorr(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "xorr requires 3 parameters."); if(!type) die(state, "xorr requires type of: ['i', 'ui', 'l', 'ul']."); switch(type->value) { case OpType_i: jit_xorr_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_xorr_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_xorr_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_xorr_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation xorr, only ['i', 'ui', 'l', 'ul'] allowed."); } return 1; } int inst_xori(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "xori requires 3 parameters."); if(!type) die(state, "xori requires type of: ['i', 'ui', 'l', 'ul']."); switch(type->value) { case OpType_i: jit_xori_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_xori_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_xori_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_xori_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation xori, only ['i', 'ui', 'l', 'ul'] allowed."); } return 1; } int inst_lshr(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "lshr requires 3 parameters."); if(!type) die(state, "lshr requires type of: ['i', 'ui', 'l', 'ul']."); switch(type->value) { case OpType_i: jit_lshr_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_lshr_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_lshr_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_lshr_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation lshr, only ['i', 'ui', 'l', 'ul'] allowed."); } return 1; } int inst_lshi(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "lshi requires 3 parameters."); if(!type) die(state, "lshi requires type of: ['i', 'ui', 'l', 'ul']."); switch(type->value) { case OpType_i: jit_lshi_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_lshi_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_lshi_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_lshi_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation lshi, only ['i', 'ui', 'l', 'ul'] allowed."); } return 1; } int inst_rshr(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "rshr requires 3 parameters."); if(!type) die(state, "rshr requires type of: ['i', 'ui', 'l', 'ul']."); switch(type->value) { case OpType_i: jit_rshr_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_rshr_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_rshr_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_rshr_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation rshr, only ['i', 'ui', 'l', 'ul'] allowed."); } return 1; } int inst_rshi(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "rshi requires 3 parameters."); if(!type) die(state, "rshi requires type of: ['i', 'ui', 'l', 'ul']."); switch(type->value) { case OpType_i: jit_rshi_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_rshi_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_rshi_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_rshi_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation rshi, only ['i', 'ui', 'l', 'ul'] allowed."); } return 1; } int inst_negr(Module *state, Token *type, array_t *params) { if(array_length(params) != 2) die(state, "negr requires 2 parameters."); if(!type) die(state, "negr requires type of: ['i', 'l']."); switch(type->value) { case OpType_i: jit_negr_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_l: jit_negr_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; default: die(state, "Invalid type given for operation negr, only ['i', 'l'] allowed."); } return 1; } int inst_notr(Module *state, Token *type, array_t *params) { if(array_length(params) != 2) die(state, "notr requires 2 parameters."); if(!type) die(state, "notr requires type of: ['i', 'ui', 'l', 'ul']."); switch(type->value) { case OpType_i: jit_notr_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_ui: jit_notr_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_l: jit_notr_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_ul: jit_notr_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; default: die(state, "Invalid type given for operation notr, only ['i', 'ui', 'l', 'ul'] allowed."); } return 1; } int inst_ltr(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "ltr requires 3 parameters."); if(!type) die(state, "ltr requires type of: ['i', 'ui', 'l', 'ul', 'p', 'f', 'd']."); switch(type->value) { case OpType_i: jit_ltr_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_ltr_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_ltr_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_ltr_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_p: jit_ltr_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_f: jit_ltr_f (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_d: jit_ltr_d (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation ltr, only ['i', 'ui', 'l', 'ul', 'p', 'f', 'd'] allowed."); } return 1; } int inst_lti(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "lti requires 3 parameters."); if(!type) die(state, "lti requires type of: ['i', 'ui', 'l', 'ul', 'p']."); switch(type->value) { case OpType_i: jit_lti_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_lti_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_lti_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_lti_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_p: jit_lti_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation lti, only ['i', 'ui', 'l', 'ul', 'p'] allowed."); } return 1; } int inst_ler(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "ler requires 3 parameters."); if(!type) die(state, "ler requires type of: ['i', 'ui', 'l', 'ul', 'p', 'f', 'd']."); switch(type->value) { case OpType_i: jit_ler_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_ler_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_ler_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_ler_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_p: jit_ler_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_f: jit_ler_f (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_d: jit_ler_d (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation ler, only ['i', 'ui', 'l', 'ul', 'p', 'f', 'd'] allowed."); } return 1; } int inst_lei(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "lei requires 3 parameters."); if(!type) die(state, "lei requires type of: ['i', 'ui', 'l', 'ul', 'p']."); switch(type->value) { case OpType_i: jit_lei_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_lei_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_lei_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_lei_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_p: jit_lei_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation lei, only ['i', 'ui', 'l', 'ul', 'p'] allowed."); } return 1; } int inst_gtr(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "gtr requires 3 parameters."); if(!type) die(state, "gtr requires type of: ['i', 'ui', 'l', 'ul', 'p', 'f', 'd']."); switch(type->value) { case OpType_i: jit_gtr_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_gtr_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_gtr_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_gtr_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_p: jit_gtr_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_f: jit_gtr_f (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_d: jit_gtr_d (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation gtr, only ['i', 'ui', 'l', 'ul', 'p', 'f', 'd'] allowed."); } return 1; } int inst_gti(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "gti requires 3 parameters."); if(!type) die(state, "gti requires type of: ['i', 'ui', 'l', 'ul', 'p']."); switch(type->value) { case OpType_i: jit_gti_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_gti_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_gti_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_gti_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_p: jit_gti_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation gti, only ['i', 'ui', 'l', 'ul', 'p'] allowed."); } return 1; } int inst_ger(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "ger requires 3 parameters."); if(!type) die(state, "ger requires type of: ['i', 'ui', 'l', 'ul', 'p', 'f', 'd']."); switch(type->value) { case OpType_i: jit_ger_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_ger_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_ger_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_ger_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_p: jit_ger_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_f: jit_ger_f (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_d: jit_ger_d (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation ger, only ['i', 'ui', 'l', 'ul', 'p', 'f', 'd'] allowed."); } return 1; } int inst_gei(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "gei requires 3 parameters."); if(!type) die(state, "gei requires type of: ['i', 'ui', 'l', 'ul', 'p']."); switch(type->value) { case OpType_i: jit_gei_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_gei_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_gei_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_gei_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_p: jit_gei_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation gei, only ['i', 'ui', 'l', 'ul', 'p'] allowed."); } return 1; } int inst_eqr(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "eqr requires 3 parameters."); if(!type) die(state, "eqr requires type of: ['i', 'ui', 'l', 'ul', 'p', 'f', 'd']."); switch(type->value) { case OpType_i: jit_eqr_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_eqr_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_eqr_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_eqr_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_p: jit_eqr_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_f: jit_eqr_f (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_d: jit_eqr_d (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation eqr, only ['i', 'ui', 'l', 'ul', 'p', 'f', 'd'] allowed."); } return 1; } int inst_eqi(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "eqi requires 3 parameters."); if(!type) die(state, "eqi requires type of: ['i', 'ui', 'l', 'ul', 'p']."); switch(type->value) { case OpType_i: jit_eqi_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_eqi_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_eqi_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_eqi_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_p: jit_eqi_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation eqi, only ['i', 'ui', 'l', 'ul', 'p'] allowed."); } return 1; } int inst_ner(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "ner requires 3 parameters."); if(!type) die(state, "ner requires type of: ['i', 'ui', 'l', 'ul', 'p', 'f', 'd']."); switch(type->value) { case OpType_i: jit_ner_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_ner_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_ner_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_ner_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_p: jit_ner_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_f: jit_ner_f (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_d: jit_ner_d (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation ner, only ['i', 'ui', 'l', 'ul', 'p', 'f', 'd'] allowed."); } return 1; } int inst_nei(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "nei requires 3 parameters."); if(!type) die(state, "nei requires type of: ['i', 'ui', 'l', 'ul', 'p']."); switch(type->value) { case OpType_i: jit_nei_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_nei_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_nei_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_nei_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_p: jit_nei_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation nei, only ['i', 'ui', 'l', 'ul', 'p'] allowed."); } return 1; } int inst_unltr(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "unltr requires 3 parameters."); if(!type) die(state, "unltr requires type of: ['f', 'd']."); switch(type->value) { case OpType_f: jit_unltr_f (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_d: jit_unltr_d (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation unltr, only ['f', 'd'] allowed."); } return 1; } int inst_unler(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "unler requires 3 parameters."); if(!type) die(state, "unler requires type of: ['f', 'd']."); switch(type->value) { case OpType_f: jit_unler_f (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_d: jit_unler_d (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation unler, only ['f', 'd'] allowed."); } return 1; } int inst_ungtr(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "ungtr requires 3 parameters."); if(!type) die(state, "ungtr requires type of: ['f', 'd']."); switch(type->value) { case OpType_f: jit_ungtr_f (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_d: jit_ungtr_d (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation ungtr, only ['f', 'd'] allowed."); } return 1; } int inst_unger(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "unger requires 3 parameters."); if(!type) die(state, "unger requires type of: ['f', 'd']."); switch(type->value) { case OpType_f: jit_unger_f (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_d: jit_unger_d (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation unger, only ['f', 'd'] allowed."); } return 1; } int inst_uneqr(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "uneqr requires 3 parameters."); if(!type) die(state, "uneqr requires type of: ['f', 'd']."); switch(type->value) { case OpType_f: jit_uneqr_f (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_d: jit_uneqr_d (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation uneqr, only ['f', 'd'] allowed."); } return 1; } int inst_ltgtr(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "ltgtr requires 3 parameters."); if(!type) die(state, "ltgtr requires type of: ['f', 'd']."); switch(type->value) { case OpType_f: jit_ltgtr_f (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_d: jit_ltgtr_d (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation ltgtr, only ['f', 'd'] allowed."); } return 1; } int inst_ordr(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "ordr requires 3 parameters."); if(!type) die(state, "ordr requires type of: ['f', 'd']."); switch(type->value) { case OpType_f: jit_ordr_f (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_d: jit_ordr_d (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation ordr, only ['f', 'd'] allowed."); } return 1; } int inst_unordr(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "unordr requires 3 parameters."); if(!type) die(state, "unordr requires type of: ['f', 'd']."); switch(type->value) { case OpType_f: jit_unordr_f (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_d: jit_unordr_d (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation unordr, only ['f', 'd'] allowed."); } return 1; } int inst_movr(Module *state, Token *type, array_t *params) { if(array_length(params) != 2) die(state, "movr requires 2 parameters."); if(!type) die(state, "movr requires type of: ['i', 'ui', 'l', 'ul', 'p', 'f', 'd']."); switch(type->value) { case OpType_i: jit_movr_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_ui: jit_movr_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_l: jit_movr_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_ul: jit_movr_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_p: jit_movr_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_f: jit_movr_f (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_d: jit_movr_d (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; default: die(state, "Invalid type given for operation movr, only ['i', 'ui', 'l', 'ul', 'p', 'f', 'd'] allowed."); } return 1; } int inst_movi(Module *state, Token *type, array_t *params) { if(array_length(params) != 2) die(state, "movi requires 2 parameters."); if(!type) die(state, "movi requires type of: ['i', 'ui', 'l', 'ul', 'p', 'f', 'd']."); switch(type->value) { case OpType_i: jit_movi_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_ui: jit_movi_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_l: jit_movi_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_ul: jit_movi_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_p: jit_movi_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_f: jit_movi_f (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_d: jit_movi_d (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; default: die(state, "Invalid type given for operation movi, only ['i', 'ui', 'l', 'ul', 'p', 'f', 'd'] allowed."); } return 1; } int inst_hton(Module *state, Token *type, array_t *params) { if(array_length(params) != 2) die(state, "hton requires 2 parameters."); if(!type) die(state, "hton requires type of: ['us', 'ui']."); switch(type->value) { case OpType_us: jit_hton_us (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_ui: jit_hton_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; default: die(state, "Invalid type given for operation hton, only ['us', 'ui'] allowed."); } return 1; } int inst_ntoh(Module *state, Token *type, array_t *params) { if(array_length(params) != 2) die(state, "ntoh requires 2 parameters."); if(!type) die(state, "ntoh requires type of: ['us', 'ui']."); switch(type->value) { case OpType_us: jit_ntoh_us (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_ui: jit_ntoh_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; default: die(state, "Invalid type given for operation ntoh, only ['us', 'ui'] allowed."); } return 1; } int inst_ldr(Module *state, Token *type, array_t *params) { if(array_length(params) != 2) die(state, "ldr requires 2 parameters."); if(!type) die(state, "ldr requires type of: ['c', 'uc', 's', 'us', 'i', 'ui', 'l', 'ul', 'p', 'f', 'd']."); switch(type->value) { case OpType_c: jit_ldr_c (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_uc: jit_ldr_uc (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_s: jit_ldr_s (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_us: jit_ldr_us (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_i: jit_ldr_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_ui: jit_ldr_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_l: jit_ldr_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_ul: jit_ldr_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_p: jit_ldr_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_f: jit_ldr_f (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_d: jit_ldr_d (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; default: die(state, "Invalid type given for operation ldr, only ['c', 'uc', 's', 'us', 'i', 'ui', 'l', 'ul', 'p', 'f', 'd'] allowed."); } return 1; } int inst_ldi(Module *state, Token *type, array_t *params) { if(array_length(params) != 2) die(state, "ldi requires 2 parameters."); if(!type) die(state, "ldi requires type of: ['c', 'uc', 's', 'us', 'i', 'ui', 'l', 'ul', 'p', 'f', 'd']."); switch(type->value) { case OpType_c: jit_ldi_c (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_uc: jit_ldi_uc (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_s: jit_ldi_s (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_us: jit_ldi_us (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_i: jit_ldi_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_ui: jit_ldi_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_l: jit_ldi_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_ul: jit_ldi_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_p: jit_ldi_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_f: jit_ldi_f (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_d: jit_ldi_d (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; default: die(state, "Invalid type given for operation ldi, only ['c', 'uc', 's', 'us', 'i', 'ui', 'l', 'ul', 'p', 'f', 'd'] allowed."); } return 1; } int inst_ldxr(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "ldxr requires 3 parameters."); if(!type) die(state, "ldxr requires type of: ['c', 'uc', 's', 'us', 'i', 'ui', 'l', 'ul', 'p', 'f', 'd']."); switch(type->value) { case OpType_c: jit_ldxr_c (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_uc: jit_ldxr_uc (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_s: jit_ldxr_s (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_us: jit_ldxr_us (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_i: jit_ldxr_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_ldxr_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_ldxr_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_ldxr_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_p: jit_ldxr_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_f: jit_ldxr_f (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_d: jit_ldxr_d (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation ldxr, only ['c', 'uc', 's', 'us', 'i', 'ui', 'l', 'ul', 'p', 'f', 'd'] allowed."); } return 1; } int inst_ldxi(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "ldxi requires 3 parameters."); if(!type) die(state, "ldxi requires type of: ['c', 'uc', 's', 'us', 'i', 'ui', 'l', 'ul', 'p', 'f', 'd']."); switch(type->value) { case OpType_c: jit_ldxi_c (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_uc: jit_ldxi_uc (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_s: jit_ldxi_s (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_us: jit_ldxi_us (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_i: jit_ldxi_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_ldxi_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_ldxi_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_ldxi_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_p: jit_ldxi_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_f: jit_ldxi_f (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_d: jit_ldxi_d (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation ldxi, only ['c', 'uc', 's', 'us', 'i', 'ui', 'l', 'ul', 'p', 'f', 'd'] allowed."); } return 1; } int inst_str(Module *state, Token *type, array_t *params) { if(array_length(params) != 2) die(state, "str requires 2 parameters."); if(!type) die(state, "str requires type of: ['c', 'uc', 's', 'us', 'i', 'ui', 'l', 'ul', 'p', 'f', 'd']."); switch(type->value) { case OpType_c: jit_str_c (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_uc: jit_str_uc (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_s: jit_str_s (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_us: jit_str_us (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_i: jit_str_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_ui: jit_str_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_l: jit_str_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_ul: jit_str_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_p: jit_str_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_f: jit_str_f (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_d: jit_str_d (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; default: die(state, "Invalid type given for operation str, only ['c', 'uc', 's', 'us', 'i', 'ui', 'l', 'ul', 'p', 'f', 'd'] allowed."); } return 1; } int inst_sti(Module *state, Token *type, array_t *params) { if(array_length(params) != 2) die(state, "sti requires 2 parameters."); if(!type) die(state, "sti requires type of: ['c', 'uc', 's', 'us', 'i', 'ui', 'l', 'ul', 'p', 'f', 'd']."); switch(type->value) { case OpType_c: jit_sti_c (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_uc: jit_sti_uc (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_s: jit_sti_s (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_us: jit_sti_us (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_i: jit_sti_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_ui: jit_sti_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_l: jit_sti_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_ul: jit_sti_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_p: jit_sti_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_f: jit_sti_f (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_d: jit_sti_d (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; default: die(state, "Invalid type given for operation sti, only ['c', 'uc', 's', 'us', 'i', 'ui', 'l', 'ul', 'p', 'f', 'd'] allowed."); } return 1; } int inst_stxr(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "stxr requires 3 parameters."); if(!type) die(state, "stxr requires type of: ['c', 'uc', 's', 'us', 'i', 'ui', 'l', 'ul', 'p', 'f', 'd']."); switch(type->value) { case OpType_c: jit_stxr_c (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_uc: jit_stxr_uc (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_s: jit_stxr_s (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_us: jit_stxr_us (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_i: jit_stxr_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_stxr_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_stxr_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_stxr_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_p: jit_stxr_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_f: jit_stxr_f (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_d: jit_stxr_d (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation stxr, only ['c', 'uc', 's', 'us', 'i', 'ui', 'l', 'ul', 'p', 'f', 'd'] allowed."); } return 1; } int inst_stxi(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "stxi requires 3 parameters."); if(!type) die(state, "stxi requires type of: ['c', 'uc', 's', 'us', 'i', 'ui', 'l', 'ul', 'p', 'f', 'd']."); switch(type->value) { case OpType_c: jit_stxi_c (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_uc: jit_stxi_uc (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_s: jit_stxi_s (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_us: jit_stxi_us (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_i: jit_stxi_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_stxi_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_stxi_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_stxi_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_p: jit_stxi_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_f: jit_stxi_f (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_d: jit_stxi_d (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation stxi, only ['c', 'uc', 's', 'us', 'i', 'ui', 'l', 'ul', 'p', 'f', 'd'] allowed."); } return 1; } int inst_prepare(Module *state, Token *type, array_t *params) { if(array_length(params) != 1) die(state, "prepare requires 1 parameters."); if(!type) die(state, "prepare requires type of: ['i', 'f', 'd']."); switch(type->value) { case OpType_i: jit_prepare_i (array_of(Token, params, 0)->value); break; case OpType_f: jit_prepare_f (array_of(Token, params, 0)->value); break; case OpType_d: jit_prepare_d (array_of(Token, params, 0)->value); break; default: die(state, "Invalid type given for operation prepare, only ['i', 'f', 'd'] allowed."); } return 1; } int inst_pusharg(Module *state, Token *type, array_t *params) { if(array_length(params) != 1) die(state, "pusharg requires 1 parameters."); if(!type) die(state, "pusharg requires type of: ['c', 'uc', 's', 'us', 'i', 'ui', 'l', 'ul', 'p', 'f', 'd']."); switch(type->value) { case OpType_c: jit_pusharg_c (array_of(Token, params, 0)->value); break; case OpType_uc: jit_pusharg_uc (array_of(Token, params, 0)->value); break; case OpType_s: jit_pusharg_s (array_of(Token, params, 0)->value); break; case OpType_us: jit_pusharg_us (array_of(Token, params, 0)->value); break; case OpType_i: jit_pusharg_i (array_of(Token, params, 0)->value); break; case OpType_ui: jit_pusharg_ui (array_of(Token, params, 0)->value); break; case OpType_l: jit_pusharg_l (array_of(Token, params, 0)->value); break; case OpType_ul: jit_pusharg_ul (array_of(Token, params, 0)->value); break; case OpType_p: jit_pusharg_p (array_of(Token, params, 0)->value); break; case OpType_f: jit_pusharg_f (array_of(Token, params, 0)->value); break; case OpType_d: jit_pusharg_d (array_of(Token, params, 0)->value); break; default: die(state, "Invalid type given for operation pusharg, only ['c', 'uc', 's', 'us', 'i', 'ui', 'l', 'ul', 'p', 'f', 'd'] allowed."); } return 1; } int inst_getarg(Module *state, Token *type, array_t *params) { if(array_length(params) != 2) die(state, "getarg requires 2 parameters."); if(!type) die(state, "getarg requires type of: ['c', 'uc', 's', 'us', 'i', 'ui', 'l', 'ul', 'p', 'f', 'd']."); switch(type->value) { case OpType_c: jit_getarg_c (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_uc: jit_getarg_uc (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_s: jit_getarg_s (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_us: jit_getarg_us (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_i: jit_getarg_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_ui: jit_getarg_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_l: jit_getarg_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_ul: jit_getarg_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_p: jit_getarg_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_f: jit_getarg_f (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; case OpType_d: jit_getarg_d (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value); break; default: die(state, "Invalid type given for operation getarg, only ['c', 'uc', 's', 'us', 'i', 'ui', 'l', 'ul', 'p', 'f', 'd'] allowed."); } return 1; } int inst_blti(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "blti requires 3 parameters."); if(!type) die(state, "blti requires type of: ['i', 'ui', 'l', 'ul', 'p']."); switch(type->value) { case OpType_i: jit_blti_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_blti_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_blti_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_blti_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_p: jit_blti_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation blti, only ['i', 'ui', 'l', 'ul', 'p'] allowed."); } return 1; } int inst_blei(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "blei requires 3 parameters."); if(!type) die(state, "blei requires type of: ['i', 'ui', 'l', 'ul', 'p']."); switch(type->value) { case OpType_i: jit_blei_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_blei_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_blei_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_blei_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_p: jit_blei_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation blei, only ['i', 'ui', 'l', 'ul', 'p'] allowed."); } return 1; } int inst_bgti(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "bgti requires 3 parameters."); if(!type) die(state, "bgti requires type of: ['i', 'ui', 'l', 'ul', 'p']."); switch(type->value) { case OpType_i: jit_bgti_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_bgti_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_bgti_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_bgti_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_p: jit_bgti_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation bgti, only ['i', 'ui', 'l', 'ul', 'p'] allowed."); } return 1; } int inst_bgei(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "bgei requires 3 parameters."); if(!type) die(state, "bgei requires type of: ['i', 'ui', 'l', 'ul', 'p']."); switch(type->value) { case OpType_i: jit_bgei_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_bgei_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_bgei_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_bgei_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_p: jit_bgei_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation bgei, only ['i', 'ui', 'l', 'ul', 'p'] allowed."); } return 1; } int inst_beqi(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "beqi requires 3 parameters."); if(!type) die(state, "beqi requires type of: ['i', 'ui', 'l', 'ul', 'p']."); switch(type->value) { case OpType_i: jit_beqi_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_beqi_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_beqi_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_beqi_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_p: jit_beqi_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation beqi, only ['i', 'ui', 'l', 'ul', 'p'] allowed."); } return 1; } int inst_bnei(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "bnei requires 3 parameters."); if(!type) die(state, "bnei requires type of: ['i', 'ui', 'l', 'ul', 'p']."); switch(type->value) { case OpType_i: jit_bnei_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_bnei_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_bnei_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_bnei_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_p: jit_bnei_p (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation bnei, only ['i', 'ui', 'l', 'ul', 'p'] allowed."); } return 1; } int inst_bmsr(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "bmsr requires 3 parameters."); if(!type) die(state, "bmsr requires type of: ['i', 'ui', 'l', 'ul']."); switch(type->value) { case OpType_i: jit_bmsr_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_bmsr_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_bmsr_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_bmsr_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation bmsr, only ['i', 'ui', 'l', 'ul'] allowed."); } return 1; } int inst_bmsi(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "bmsi requires 3 parameters."); if(!type) die(state, "bmsi requires type of: ['i', 'ui', 'l', 'ul']."); switch(type->value) { case OpType_i: jit_bmsi_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_bmsi_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_bmsi_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_bmsi_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation bmsi, only ['i', 'ui', 'l', 'ul'] allowed."); } return 1; } int inst_bmcr(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "bmcr requires 3 parameters."); if(!type) die(state, "bmcr requires type of: ['i', 'ui', 'l', 'ul']."); switch(type->value) { case OpType_i: jit_bmcr_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_bmcr_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_bmcr_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_bmcr_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation bmcr, only ['i', 'ui', 'l', 'ul'] allowed."); } return 1; } int inst_bmci(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "bmci requires 3 parameters."); if(!type) die(state, "bmci requires type of: ['i', 'ui', 'l', 'ul']."); switch(type->value) { case OpType_i: jit_bmci_i (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ui: jit_bmci_ui (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_l: jit_bmci_l (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; case OpType_ul: jit_bmci_ul (array_of(Token, params, 0)->value, array_of(Token, params, 1)->value, array_of(Token, params, 2)->value); break; default: die(state, "Invalid type given for operation bmci, only ['i', 'ui', 'l', 'ul'] allowed."); } return 1; } int inst_calli(Module *state, Token *type, array_t *params) { if(array_length(params) != 1) die(state, "calli requires 1 parameters."); if(type) die(state, "Operation calli does not take a type."); jit_calli (array_of(Token, params, 0)->value); return 1; } int inst_callr(Module *state, Token *type, array_t *params) { if(array_length(params) != 1) die(state, "callr requires 1 parameters."); if(type) die(state, "Operation callr does not take a type."); jit_callr (array_of(Token, params, 0)->value); return 1; } int inst_finish(Module *state, Token *type, array_t *params) { if(array_length(params) != 1) die(state, "finish requires 1 parameters."); if(type) die(state, "Operation finish does not take a type."); jit_finish (array_of(Token, params, 0)->value); return 1; } int inst_finishr(Module *state, Token *type, array_t *params) { if(array_length(params) != 1) die(state, "finishr requires 1 parameters."); if(type) die(state, "Operation finishr does not take a type."); jit_finishr (array_of(Token, params, 0)->value); return 1; } int inst_jmpi(Module *state, Token *type, array_t *params) { if(array_length(params) != 1) die(state, "jmpi requires 1 parameters."); if(type) die(state, "Operation jmpi does not take a type."); jit_jmpi (array_of(Token, params, 0)->value); return 1; } int inst_jmpr(Module *state, Token *type, array_t *params) { if(array_length(params) != 1) die(state, "jmpr requires 1 parameters."); if(type) die(state, "Operation jmpr does not take a type."); jit_jmpr (array_of(Token, params, 0)->value); return 1; } int inst_ret(Module *state, Token *type, array_t *params) { if(array_length(params) != 0) die(state, "ret requires 0 parameters."); if(type) die(state, "Operation ret does not take a type."); jit_ret (); return 1; } int inst_retval(Module *state, Token *type, array_t *params) { if(array_length(params) != 1) die(state, "retval requires 1 parameters."); if(!type) die(state, "retval requires type of: ['c', 'uc', 's', 'us', 'i', 'ui', 'l', 'ul', 'p', 'f', 'd']."); switch(type->value) { case OpType_c: jit_retval_c (array_of(Token, params, 0)->value); break; case OpType_uc: jit_retval_uc (array_of(Token, params, 0)->value); break; case OpType_s: jit_retval_s (array_of(Token, params, 0)->value); break; case OpType_us: jit_retval_us (array_of(Token, params, 0)->value); break; case OpType_i: jit_retval_i (array_of(Token, params, 0)->value); break; case OpType_ui: jit_retval_ui (array_of(Token, params, 0)->value); break; case OpType_l: jit_retval_l (array_of(Token, params, 0)->value); break; case OpType_ul: jit_retval_ul (array_of(Token, params, 0)->value); break; case OpType_p: jit_retval_p (array_of(Token, params, 0)->value); break; case OpType_f: jit_retval_f (array_of(Token, params, 0)->value); break; case OpType_d: jit_retval_d (array_of(Token, params, 0)->value); break; default: die(state, "Invalid type given for operation retval, only ['c', 'uc', 's', 'us', 'i', 'ui', 'l', 'ul', 'p', 'f', 'd'] allowed."); } return 1; }
zedshaw/earing
src/types.c
#include "types.h" #include <assert.h> const char *OpType_strings[] = { "int", "uint", "long", "ulong", "ptr", "float", "double", "void", "char", "uchar", "short", "ushort" }; const char *OpType_to_str(OpType type) { assert(type >= 0 && type < 12 && "Invalid OpType_code"); return OpType_strings[type]; }
zedshaw/earing
tests/token_tests.c
#include <cut/2.6/cut.h> #include "token.h" #include "ops.h" #include "grammar.h" #include <gc.h> #include <string.h> #include <gc/cord.h> void __CUT__Token_createBringup(void) { GC_INIT(); } void __CUT__Token_create( void ) { CORD data = CORD_from_char_star("100"); Token *tk = Token_create(TK_INT, data, NULL); ASSERT(tk->id == TK_INT, "wrong id."); ASSERT(tk->value == 100, "wrong value."); tk = Token_create(TK_CHR, CORD_from_char_star("'A'"), NULL); ASSERT(tk->id == TK_CHR, "wrong id."); ASSERT(tk->value == 'A', "wrong value."); tk = Token_create(TK_FLOAT, CORD_from_char_star("1.1"), NULL); ASSERT(tk->id == TK_FLOAT, "wrong id."); ASSERT(tk->value <= 2.0f && tk->value >= 0.0f, "wrong value"); tk = Token_create(TK_HEX, CORD_from_char_star("0xAE"), NULL); ASSERT(tk->id == TK_HEX, "wrong id."); ASSERT(tk->value == 0xAE, "wrong value"); tk = Token_create(TK_REG, CORD_from_char_star("R0"), NULL); ASSERT(tk->id = TK_REG, "wrong id."); ASSERT(tk->value == 0, "wrong value."); }
zedshaw/earing
src/repl.c
<gh_stars>1-10 #include <stdio.h> #include "repl.h" #include <string.h> #include <stdlib.h> #include <gc/gc.h> void repl_init(complete_function func) { // does nothing until I can figure out how to portably use readline } char *repl_prompt() { char *line = GC_MALLOC(1024 * sizeof(char)); printf(">>> "); char *result = fgets(line, 1023, stdin); if(result) { result[strlen(result)-1] = '\0'; } return result; }
zedshaw/earing
src/token.c
<reponame>zedshaw/earing<filename>src/token.c<gh_stars>1-10 #include "token.h" #include <stdlib.h> #include "grammar.h" #include <assert.h> #include <string.h> #include <gc/gc.h> Token *Token_create(int id, CORD data, f_inst_call call) { Token *tk = GC_MALLOC(sizeof(Token)); tk->id = id; tk->data = data; tk->call = call; switch(id) { case TK_CHR: tk->value = (int)CORD_fetch(tk->data, 1); break; case TK_STR: tk->value = (unsigned long)CORD_to_char_star(tk->data); break; case TK_INT: tk->value = atoi(CORD_to_const_char_star(tk->data)); break; case TK_FLOAT: tk->value = atof(CORD_to_const_char_star(tk->data)); break; case TK_HEX: tk->value = (int)strtol(CORD_to_const_char_star(tk->data), NULL, 16); break; default: tk->value = 0; } return tk; }
zedshaw/earing
tests/struct_tests.c
<filename>tests/struct_tests.c #include <cut/2.6/cut.h> #include "struct.h" #include <gc.h> #include <stdio.h> void __CUT__StructAlign_create( void ) { StructAlign sa = StructAlign_create(); ASSERT(!StructAlign_indeterminate(sa), "Indeterminate structure alignment."); ASSERT(!StructAlign_multiple_cases(sa), "Mulitple possible cases for structure alignment."); }
zedshaw/earing
src/lexer.c
<filename>src/lexer.c #line 1 "src/lexer.rl" /** <NAME> -- A weird assembler. Copyright 2008. */ #include "module.h" #include "grammar.h" #include "tokenize.h" #include "grammar.c" #include "ops.h" #include "error.h" #include "allocator.h" #line 187 "src/lexer.rl" #line 19 "src/lexer.c" static const int lexer_start = 12; static const int lexer_error = 0; static const int lexer_en_c_comment = 10; static const int lexer_en_main = 12; #line 190 "src/lexer.rl" int Module_compile(Module *state, CORD source) { int cs, act; const char *ts = 0, *te = 0; void *pParser = ParseAlloc(Allocator_malloc); Token *tk = NULL; const char *p = CORD_to_const_char_star(source); #line 38 "src/lexer.c" { cs = lexer_start; ts = 0; te = 0; act = 0; } #line 200 "src/lexer.rl" const char *pe = p+CORD_len(source); const char *eof = pe; #line 52 "src/lexer.c" { if ( p == pe ) goto _test_eof; switch ( cs ) { tr2: #line 172 "src/lexer.rl" {te = p+1;{ STR() }} goto st12; tr5: #line 14 "src/lexer.rl" {state->curline++; SYM(EOL)} #line 178 "src/lexer.rl" {te = p+1;} goto st12; tr8: #line 168 "src/lexer.rl" {te = p+1;{ CHR() }} goto st12; tr12: #line 182 "src/lexer.rl" {{p = ((te))-1;}{ INT() }} goto st12; tr14: #line 179 "src/lexer.rl" {te = p+1;{ {goto st10;} }} goto st12; tr20: #line 175 "src/lexer.rl" {te = p+1;} goto st12; tr21: #line 14 "src/lexer.rl" {state->curline++; SYM(EOL)} #line 175 "src/lexer.rl" {te = p+1;} goto st12; tr22: #line 31 "src/lexer.rl" {te = p+1;{ SYM(PERCENT) }} goto st12; tr23: #line 26 "src/lexer.rl" {te = p+1;{ SYM(LPAREN) }} goto st12; tr24: #line 27 "src/lexer.rl" {te = p+1;{ SYM(RPAREN) }} goto st12; tr25: #line 28 "src/lexer.rl" {te = p+1;{ SYM(COMMA) }} goto st12; tr27: #line 25 "src/lexer.rl" {te = p+1;{ SYM(DOT) }} goto st12; tr30: #line 29 "src/lexer.rl" {te = p+1;{ SYM(COLON) }} goto st12; tr31: #line 32 "src/lexer.rl" {te = p+1;{ SYM(EOL) }} goto st12; tr32: #line 30 "src/lexer.rl" {te = p+1;{ SYM(EQ) }} goto st12; tr38: #line 33 "src/lexer.rl" {te = p+1;{ SYM(LBRACK) }} goto st12; tr39: #line 34 "src/lexer.rl" {te = p+1;{ SYM(RBRACK) }} goto st12; tr60: #line 182 "src/lexer.rl" {te = p;p--;{ INT() }} goto st12; tr62: #line 183 "src/lexer.rl" {te = p;p--;{ FLOAT() }} goto st12; tr64: #line 184 "src/lexer.rl" {te = p;p--;{ HEX() }} goto st12; tr65: #line 1 "src/lexer.rl" { switch( act ) { case 11: {{p = ((te))-1;} KW(FUNCTION) } break; case 12: {{p = ((te))-1;} KW(END) } break; case 13: {{p = ((te))-1;}REG(NOREG) } break; case 14: {{p = ((te))-1;}REG(R0) } break; case 15: {{p = ((te))-1;}REG(R1) } break; case 16: {{p = ((te))-1;}REG(R2) } break; case 17: {{p = ((te))-1;}REG(V0) } break; case 18: {{p = ((te))-1;}REG(V1) } break; case 19: {{p = ((te))-1;}REG(V2) } break; case 20: {{p = ((te))-1;}REG(FP) } break; case 21: {{p = ((te))-1;} REG(RET) } break; case 22: {{p = ((te))-1;} TYPE(i) } break; case 23: {{p = ((te))-1;} TYPE(ui) } break; case 24: {{p = ((te))-1;} TYPE(l) } break; case 25: {{p = ((te))-1;} TYPE(ul) } break; case 26: {{p = ((te))-1;} TYPE(p) } break; case 27: {{p = ((te))-1;} TYPE(f) } break; case 28: {{p = ((te))-1;} TYPE(d) } break; case 29: {{p = ((te))-1;} TYPE(v) } break; case 30: {{p = ((te))-1;} TYPE(c) } break; case 31: {{p = ((te))-1;} TYPE(uc) } break; case 32: {{p = ((te))-1;} TYPE(s) } break; case 33: {{p = ((te))-1;} TYPE(us) } break; case 34: {{p = ((te))-1;}OP(addr) } break; case 35: {{p = ((te))-1;}OP(addi) } break; case 36: {{p = ((te))-1;}OP(addxr) } break; case 37: {{p = ((te))-1;}OP(addxi) } break; case 38: {{p = ((te))-1;}OP(addcr) } break; case 39: {{p = ((te))-1;}OP(addci) } break; case 40: {{p = ((te))-1;}OP(subr) } break; case 41: {{p = ((te))-1;}OP(subi) } break; case 42: {{p = ((te))-1;}OP(subxr) } break; case 43: {{p = ((te))-1;}OP(subxi) } break; case 44: {{p = ((te))-1;}OP(subcr) } break; case 45: {{p = ((te))-1;}OP(subci) } break; case 46: {{p = ((te))-1;}OP(rsbr) } break; case 47: {{p = ((te))-1;}OP(rsbi) } break; case 48: {{p = ((te))-1;}OP(mulr) } break; case 49: {{p = ((te))-1;}OP(muli) } break; case 50: {{p = ((te))-1;}OP(hmulr) } break; case 51: {{p = ((te))-1;}OP(hmuli) } break; case 52: {{p = ((te))-1;}OP(divr) } break; case 53: {{p = ((te))-1;}OP(divi) } break; case 54: {{p = ((te))-1;}OP(modr) } break; case 55: {{p = ((te))-1;}OP(modi) } break; case 56: {{p = ((te))-1;}OP(andr) } break; case 57: {{p = ((te))-1;}OP(andi) } break; case 58: {{p = ((te))-1;}OP(orr) } break; case 59: {{p = ((te))-1;}OP(ori) } break; case 60: {{p = ((te))-1;}OP(xorr) } break; case 61: {{p = ((te))-1;}OP(xori) } break; case 62: {{p = ((te))-1;}OP(lshr) } break; case 63: {{p = ((te))-1;}OP(lshi) } break; case 64: {{p = ((te))-1;}OP(rshr) } break; case 65: {{p = ((te))-1;}OP(rshi) } break; case 66: {{p = ((te))-1;}OP(negr) } break; case 67: {{p = ((te))-1;}OP(notr) } break; case 68: {{p = ((te))-1;}OP(ltr) } break; case 69: {{p = ((te))-1;}OP(lti) } break; case 70: {{p = ((te))-1;}OP(ler) } break; case 71: {{p = ((te))-1;}OP(lei) } break; case 72: {{p = ((te))-1;}OP(gtr) } break; case 73: {{p = ((te))-1;}OP(gti) } break; case 74: {{p = ((te))-1;}OP(ger) } break; case 75: {{p = ((te))-1;}OP(gei) } break; case 76: {{p = ((te))-1;}OP(eqr) } break; case 77: {{p = ((te))-1;}OP(eqi) } break; case 78: {{p = ((te))-1;}OP(ner) } break; case 79: {{p = ((te))-1;}OP(nei) } break; case 80: {{p = ((te))-1;}OP(unltr) } break; case 81: {{p = ((te))-1;}OP(unler) } break; case 82: {{p = ((te))-1;}OP(ungtr) } break; case 83: {{p = ((te))-1;}OP(unger) } break; case 84: {{p = ((te))-1;}OP(uneqr) } break; case 85: {{p = ((te))-1;}OP(ltgtr) } break; case 86: {{p = ((te))-1;}OP(ordr) } break; case 87: {{p = ((te))-1;}OP(unordr) } break; case 88: {{p = ((te))-1;}OP(movr) } break; case 89: {{p = ((te))-1;}OP(movi) } break; case 90: {{p = ((te))-1;}OP(hton) } break; case 91: {{p = ((te))-1;}OP(ntoh) } break; case 92: {{p = ((te))-1;}OP(ldr) } break; case 93: {{p = ((te))-1;}OP(ldi) } break; case 94: {{p = ((te))-1;}OP(ldxr) } break; case 95: {{p = ((te))-1;}OP(ldxi) } break; case 96: {{p = ((te))-1;}OP(str) } break; case 97: {{p = ((te))-1;}OP(sti) } break; case 98: {{p = ((te))-1;}OP(stxr) } break; case 99: {{p = ((te))-1;}OP(stxi) } break; case 100: {{p = ((te))-1;}OP(prepare) } break; case 101: {{p = ((te))-1;}OP(pusharg) } break; case 102: {{p = ((te))-1;}OP(getarg) } break; case 103: {{p = ((te))-1;}OP(retval) } break; case 104: {{p = ((te))-1;}OP(blti) } break; case 105: {{p = ((te))-1;}OP(blei) } break; case 106: {{p = ((te))-1;}OP(bgti) } break; case 107: {{p = ((te))-1;}OP(bgei) } break; case 108: {{p = ((te))-1;}OP(beqi) } break; case 109: {{p = ((te))-1;}OP(bnei) } break; case 110: {{p = ((te))-1;}OP(bmsi) } break; case 111: {{p = ((te))-1;}OP(bmci) } break; case 112: {{p = ((te))-1;}OP(jmpi) } break; case 113: {{p = ((te))-1;}OP(jmpr) } break; case 115: {{p = ((te))-1;} OP(size_of) } break; case 116: {{p = ((te))-1;} OP(alloc) } break; case 117: {{p = ((te))-1;} OP(realloc) } break; case 118: {{p = ((te))-1;} OP(free) } break; case 119: {{p = ((te))-1;} OP(collect) } break; case 120: {{p = ((te))-1;} OP(calli); NO_LEAF(calli); } break; case 121: {{p = ((te))-1;}OP(callr); NO_LEAF(callr); } break; case 123: {{p = ((te))-1;}OP(finishr); NO_LEAF(finishr); } break; case 124: {{p = ((te))-1;} IDENT() } break; } } goto st12; tr66: #line 164 "src/lexer.rl" {te = p+1;{ LABEL() }} goto st12; tr67: #line 163 "src/lexer.rl" {te = p;p--;{ IDENT() }} goto st12; tr124: #line 60 "src/lexer.rl" {te = p;p--;{ TYPE(c) }} goto st12; tr139: #line 58 "src/lexer.rl" {te = p;p--;{ TYPE(d) }} goto st12; tr154: #line 57 "src/lexer.rl" {te = p;p--;{ TYPE(f) }} goto st12; tr163: #line 159 "src/lexer.rl" {te = p;p--;{OP(finish); NO_LEAF(finish); }} goto st12; tr194: #line 52 "src/lexer.rl" {te = p;p--;{ TYPE(i) }} goto st12; tr201: #line 54 "src/lexer.rl" {te = p;p--;{ TYPE(l) }} goto st12; tr251: #line 56 "src/lexer.rl" {te = p;p--;{ TYPE(p) }} goto st12; tr274: #line 146 "src/lexer.rl" {te = p;p--;{OP(ret) }} goto st12; tr284: #line 62 "src/lexer.rl" {te = p;p--;{ TYPE(s) }} goto st12; tr315: #line 61 "src/lexer.rl" {te = p;p--;{ TYPE(uc) }} goto st12; tr319: #line 53 "src/lexer.rl" {te = p;p--;{ TYPE(ui) }} goto st12; tr322: #line 55 "src/lexer.rl" {te = p;p--;{ TYPE(ul) }} goto st12; tr343: #line 63 "src/lexer.rl" {te = p;p--;{ TYPE(us) }} goto st12; tr348: #line 59 "src/lexer.rl" {te = p;p--;{ TYPE(v) }} goto st12; st12: #line 1 "src/lexer.rl" {ts = 0;} if ( ++p == pe ) goto _test_eof12; case 12: #line 1 "src/lexer.rl" {ts = p;} #line 556 "src/lexer.c" switch( (*p) ) { case 10: goto tr21; case 34: goto st1; case 35: goto st3; case 37: goto tr22; case 39: goto st4; case 40: goto tr23; case 41: goto tr24; case 44: goto tr25; case 45: goto st6; case 46: goto tr27; case 47: goto st8; case 48: goto tr29; case 58: goto tr30; case 59: goto tr31; case 61: goto tr32; case 70: goto st18; case 78: goto st19; case 82: goto st23; case 86: goto st25; case 91: goto tr38; case 92: goto st0; case 93: goto tr39; case 94: goto st0; case 96: goto st0; case 97: goto st26; case 98: goto st40; case 99: goto st54; case 100: goto st65; case 101: goto st72; case 102: goto st75; case 103: goto st92; case 104: goto st98; case 105: goto st104; case 106: goto st106; case 108: goto st109; case 109: goto st120; case 110: goto st126; case 111: goto st133; case 112: goto st136; case 114: goto st148; case 115: goto st160; case 117: goto st174; case 118: goto st199; case 120: goto st202; } if ( (*p) < 60 ) { if ( (*p) > 43 ) { if ( 49 <= (*p) && (*p) <= 57 ) goto tr10; } else if ( (*p) >= 33 ) goto st0; } else if ( (*p) > 64 ) { if ( (*p) > 122 ) { if ( 123 <= (*p) && (*p) <= 126 ) goto st0; } else if ( (*p) >= 65 ) goto tr33; } else goto st0; goto tr20; st0: cs = 0; goto _out; tr1: #line 14 "src/lexer.rl" {state->curline++; SYM(EOL)} goto st1; st1: if ( ++p == pe ) goto _test_eof1; case 1: #line 629 "src/lexer.c" switch( (*p) ) { case 10: goto tr1; case 34: goto tr2; case 92: goto st2; } goto st1; st2: if ( ++p == pe ) goto _test_eof2; case 2: if ( (*p) == 10 ) goto tr1; goto st1; st3: if ( ++p == pe ) goto _test_eof3; case 3: if ( (*p) == 10 ) goto tr5; goto st3; tr7: #line 14 "src/lexer.rl" {state->curline++; SYM(EOL)} goto st4; st4: if ( ++p == pe ) goto _test_eof4; case 4: #line 658 "src/lexer.c" switch( (*p) ) { case 10: goto tr7; case 39: goto tr8; case 92: goto st5; } goto st4; st5: if ( ++p == pe ) goto _test_eof5; case 5: if ( (*p) == 10 ) goto tr7; goto st4; st6: if ( ++p == pe ) goto _test_eof6; case 6: if ( 48 <= (*p) && (*p) <= 57 ) goto tr10; goto st0; tr10: #line 1 "src/lexer.rl" {te = p+1;} goto st13; st13: if ( ++p == pe ) goto _test_eof13; case 13: #line 687 "src/lexer.c" if ( (*p) == 46 ) goto st7; if ( 48 <= (*p) && (*p) <= 57 ) goto tr10; goto tr60; st7: if ( ++p == pe ) goto _test_eof7; case 7: if ( 48 <= (*p) && (*p) <= 57 ) goto st14; goto tr12; st14: if ( ++p == pe ) goto _test_eof14; case 14: if ( 48 <= (*p) && (*p) <= 57 ) goto st14; goto tr62; st8: if ( ++p == pe ) goto _test_eof8; case 8: if ( (*p) == 42 ) goto tr14; goto st0; tr29: #line 1 "src/lexer.rl" {te = p+1;} goto st15; st15: if ( ++p == pe ) goto _test_eof15; case 15: #line 722 "src/lexer.c" switch( (*p) ) { case 46: goto st7; case 120: goto st9; } if ( 48 <= (*p) && (*p) <= 57 ) goto tr10; goto tr60; st9: if ( ++p == pe ) goto _test_eof9; case 9: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st16; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st16; } else goto st16; goto tr12; st16: if ( ++p == pe ) goto _test_eof16; case 16: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st16; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st16; } else goto st16; goto tr64; tr33: #line 1 "src/lexer.rl" {te = p+1;} #line 163 "src/lexer.rl" {act = 124;} goto st17; tr68: #line 1 "src/lexer.rl" {te = p+1;} #line 48 "src/lexer.rl" {act = 20;} goto st17; tr72: #line 1 "src/lexer.rl" {te = p+1;} #line 41 "src/lexer.rl" {act = 13;} goto st17; tr73: #line 1 "src/lexer.rl" {te = p+1;} #line 42 "src/lexer.rl" {act = 14;} goto st17; tr74: #line 1 "src/lexer.rl" {te = p+1;} #line 43 "src/lexer.rl" {act = 15;} goto st17; tr75: #line 1 "src/lexer.rl" {te = p+1;} #line 44 "src/lexer.rl" {act = 16;} goto st17; tr77: #line 1 "src/lexer.rl" {te = p+1;} #line 49 "src/lexer.rl" {act = 21;} goto st17; tr78: #line 1 "src/lexer.rl" {te = p+1;} #line 45 "src/lexer.rl" {act = 17;} goto st17; tr79: #line 1 "src/lexer.rl" {te = p+1;} #line 46 "src/lexer.rl" {act = 18;} goto st17; tr80: #line 1 "src/lexer.rl" {te = p+1;} #line 47 "src/lexer.rl" {act = 19;} goto st17; tr86: #line 1 "src/lexer.rl" {te = p+1;} #line 67 "src/lexer.rl" {act = 35;} goto st17; tr87: #line 1 "src/lexer.rl" {te = p+1;} #line 66 "src/lexer.rl" {act = 34;} goto st17; tr92: #line 1 "src/lexer.rl" {te = p+1;} #line 71 "src/lexer.rl" {act = 39;} goto st17; tr94: #line 1 "src/lexer.rl" {te = p+1;} #line 70 "src/lexer.rl" {act = 38;} goto st17; tr95: #line 1 "src/lexer.rl" {te = p+1;} #line 69 "src/lexer.rl" {act = 37;} goto st17; tr96: #line 1 "src/lexer.rl" {te = p+1;} #line 68 "src/lexer.rl" {act = 36;} goto st17; tr99: #line 1 "src/lexer.rl" {te = p+1;} #line 150 "src/lexer.rl" {act = 116;} goto st17; tr101: #line 1 "src/lexer.rl" {te = p+1;} #line 89 "src/lexer.rl" {act = 57;} goto st17; tr102: #line 1 "src/lexer.rl" {te = p+1;} #line 88 "src/lexer.rl" {act = 56;} goto st17; tr109: #line 1 "src/lexer.rl" {te = p+1;} #line 140 "src/lexer.rl" {act = 108;} goto st17; tr112: #line 1 "src/lexer.rl" {te = p+1;} #line 139 "src/lexer.rl" {act = 107;} goto st17; tr113: #line 1 "src/lexer.rl" {te = p+1;} #line 138 "src/lexer.rl" {act = 106;} goto st17; tr116: #line 1 "src/lexer.rl" {te = p+1;} #line 137 "src/lexer.rl" {act = 105;} goto st17; tr117: #line 1 "src/lexer.rl" {te = p+1;} #line 136 "src/lexer.rl" {act = 104;} goto st17; tr120: #line 1 "src/lexer.rl" {te = p+1;} #line 143 "src/lexer.rl" {act = 111;} goto st17; tr121: #line 1 "src/lexer.rl" {te = p+1;} #line 142 "src/lexer.rl" {act = 110;} goto st17; tr123: #line 1 "src/lexer.rl" {te = p+1;} #line 141 "src/lexer.rl" {act = 109;} goto st17; tr130: #line 1 "src/lexer.rl" {te = p+1;} #line 157 "src/lexer.rl" {act = 120;} goto st17; tr131: #line 1 "src/lexer.rl" {te = p+1;} #line 158 "src/lexer.rl" {act = 121;} goto st17; tr133: #line 1 "src/lexer.rl" {te = p+1;} #line 60 "src/lexer.rl" {act = 30;} goto st17; tr138: #line 1 "src/lexer.rl" {te = p+1;} #line 153 "src/lexer.rl" {act = 119;} goto st17; tr143: #line 1 "src/lexer.rl" {te = p+1;} #line 85 "src/lexer.rl" {act = 53;} goto st17; tr144: #line 1 "src/lexer.rl" {te = p+1;} #line 84 "src/lexer.rl" {act = 52;} goto st17; tr148: #line 1 "src/lexer.rl" {te = p+1;} #line 58 "src/lexer.rl" {act = 28;} goto st17; tr151: #line 1 "src/lexer.rl" {te = p+1;} #line 38 "src/lexer.rl" {act = 12;} goto st17; tr152: #line 1 "src/lexer.rl" {te = p+1;} #line 109 "src/lexer.rl" {act = 77;} goto st17; tr153: #line 1 "src/lexer.rl" {te = p+1;} #line 108 "src/lexer.rl" {act = 76;} goto st17; tr164: #line 1 "src/lexer.rl" {te = p+1;} #line 160 "src/lexer.rl" {act = 123;} goto st17; tr167: #line 1 "src/lexer.rl" {te = p+1;} #line 57 "src/lexer.rl" {act = 27;} goto st17; tr169: #line 1 "src/lexer.rl" {te = p+1;} #line 152 "src/lexer.rl" {act = 118;} goto st17; tr175: #line 1 "src/lexer.rl" {te = p+1;} #line 37 "src/lexer.rl" {act = 11;} goto st17; tr178: #line 1 "src/lexer.rl" {te = p+1;} #line 107 "src/lexer.rl" {act = 75;} goto st17; tr179: #line 1 "src/lexer.rl" {te = p+1;} #line 106 "src/lexer.rl" {act = 74;} goto st17; tr183: #line 1 "src/lexer.rl" {te = p+1;} #line 134 "src/lexer.rl" {act = 102;} goto st17; tr184: #line 1 "src/lexer.rl" {te = p+1;} #line 105 "src/lexer.rl" {act = 73;} goto st17; tr185: #line 1 "src/lexer.rl" {te = p+1;} #line 104 "src/lexer.rl" {act = 72;} goto st17; tr190: #line 1 "src/lexer.rl" {te = p+1;} #line 83 "src/lexer.rl" {act = 51;} goto st17; tr191: #line 1 "src/lexer.rl" {te = p+1;} #line 82 "src/lexer.rl" {act = 50;} goto st17; tr193: #line 1 "src/lexer.rl" {te = p+1;} #line 122 "src/lexer.rl" {act = 90;} goto st17; tr196: #line 1 "src/lexer.rl" {te = p+1;} #line 52 "src/lexer.rl" {act = 22;} goto st17; tr199: #line 1 "src/lexer.rl" {te = p+1;} #line 144 "src/lexer.rl" {act = 112;} goto st17; tr200: #line 1 "src/lexer.rl" {te = p+1;} #line 145 "src/lexer.rl" {act = 113;} goto st17; tr207: #line 1 "src/lexer.rl" {te = p+1;} #line 125 "src/lexer.rl" {act = 93;} goto st17; tr208: #line 1 "src/lexer.rl" {te = p+1;} #line 124 "src/lexer.rl" {act = 92;} goto st17; tr210: #line 1 "src/lexer.rl" {te = p+1;} #line 127 "src/lexer.rl" {act = 95;} goto st17; tr211: #line 1 "src/lexer.rl" {te = p+1;} #line 126 "src/lexer.rl" {act = 94;} goto st17; tr212: #line 1 "src/lexer.rl" {te = p+1;} #line 103 "src/lexer.rl" {act = 71;} goto st17; tr213: #line 1 "src/lexer.rl" {te = p+1;} #line 102 "src/lexer.rl" {act = 70;} goto st17; tr215: #line 1 "src/lexer.rl" {te = p+1;} #line 54 "src/lexer.rl" {act = 24;} goto st17; tr217: #line 1 "src/lexer.rl" {te = p+1;} #line 95 "src/lexer.rl" {act = 63;} goto st17; tr218: #line 1 "src/lexer.rl" {te = p+1;} #line 94 "src/lexer.rl" {act = 62;} goto st17; tr220: #line 1 "src/lexer.rl" {te = p+1;} #line 101 "src/lexer.rl" {act = 69;} goto st17; tr221: #line 1 "src/lexer.rl" {te = p+1;} #line 100 "src/lexer.rl" {act = 68;} goto st17; tr223: #line 1 "src/lexer.rl" {te = p+1;} #line 117 "src/lexer.rl" {act = 85;} goto st17; tr228: #line 1 "src/lexer.rl" {te = p+1;} #line 87 "src/lexer.rl" {act = 55;} goto st17; tr229: #line 1 "src/lexer.rl" {te = p+1;} #line 86 "src/lexer.rl" {act = 54;} goto st17; tr230: #line 1 "src/lexer.rl" {te = p+1;} #line 121 "src/lexer.rl" {act = 89;} goto st17; tr231: #line 1 "src/lexer.rl" {te = p+1;} #line 120 "src/lexer.rl" {act = 88;} goto st17; tr233: #line 1 "src/lexer.rl" {te = p+1;} #line 81 "src/lexer.rl" {act = 49;} goto st17; tr234: #line 1 "src/lexer.rl" {te = p+1;} #line 80 "src/lexer.rl" {act = 48;} goto st17; tr239: #line 1 "src/lexer.rl" {te = p+1;} #line 111 "src/lexer.rl" {act = 79;} goto st17; tr240: #line 1 "src/lexer.rl" {te = p+1;} #line 110 "src/lexer.rl" {act = 78;} goto st17; tr241: #line 1 "src/lexer.rl" {te = p+1;} #line 98 "src/lexer.rl" {act = 66;} goto st17; tr243: #line 1 "src/lexer.rl" {te = p+1;} #line 99 "src/lexer.rl" {act = 67;} goto st17; tr245: #line 1 "src/lexer.rl" {te = p+1;} #line 123 "src/lexer.rl" {act = 91;} goto st17; tr248: #line 1 "src/lexer.rl" {te = p+1;} #line 91 "src/lexer.rl" {act = 59;} goto st17; tr249: #line 1 "src/lexer.rl" {te = p+1;} #line 90 "src/lexer.rl" {act = 58;} goto st17; tr250: #line 1 "src/lexer.rl" {te = p+1;} #line 118 "src/lexer.rl" {act = 86;} goto st17; tr259: #line 1 "src/lexer.rl" {te = p+1;} #line 132 "src/lexer.rl" {act = 100;} goto st17; tr260: #line 1 "src/lexer.rl" {te = p+1;} #line 56 "src/lexer.rl" {act = 26;} goto st17; tr265: #line 1 "src/lexer.rl" {te = p+1;} #line 133 "src/lexer.rl" {act = 101;} goto st17; tr273: #line 1 "src/lexer.rl" {te = p+1;} #line 151 "src/lexer.rl" {act = 117;} goto st17; tr277: #line 1 "src/lexer.rl" {te = p+1;} #line 135 "src/lexer.rl" {act = 103;} goto st17; tr280: #line 1 "src/lexer.rl" {te = p+1;} #line 79 "src/lexer.rl" {act = 47;} goto st17; tr281: #line 1 "src/lexer.rl" {te = p+1;} #line 78 "src/lexer.rl" {act = 46;} goto st17; tr282: #line 1 "src/lexer.rl" {te = p+1;} #line 97 "src/lexer.rl" {act = 65;} goto st17; tr283: #line 1 "src/lexer.rl" {te = p+1;} #line 96 "src/lexer.rl" {act = 64;} goto st17; tr291: #line 1 "src/lexer.rl" {te = p+1;} #line 62 "src/lexer.rl" {act = 32;} goto st17; tr295: #line 1 "src/lexer.rl" {te = p+1;} #line 149 "src/lexer.rl" {act = 115;} goto st17; tr296: #line 1 "src/lexer.rl" {te = p+1;} #line 129 "src/lexer.rl" {act = 97;} goto st17; tr297: #line 1 "src/lexer.rl" {te = p+1;} #line 128 "src/lexer.rl" {act = 96;} goto st17; tr299: #line 1 "src/lexer.rl" {te = p+1;} #line 131 "src/lexer.rl" {act = 99;} goto st17; tr300: #line 1 "src/lexer.rl" {te = p+1;} #line 130 "src/lexer.rl" {act = 98;} goto st17; tr303: #line 1 "src/lexer.rl" {te = p+1;} #line 73 "src/lexer.rl" {act = 41;} goto st17; tr304: #line 1 "src/lexer.rl" {te = p+1;} #line 72 "src/lexer.rl" {act = 40;} goto st17; tr306: #line 1 "src/lexer.rl" {te = p+1;} #line 77 "src/lexer.rl" {act = 45;} goto st17; tr307: #line 1 "src/lexer.rl" {te = p+1;} #line 76 "src/lexer.rl" {act = 44;} goto st17; tr308: #line 1 "src/lexer.rl" {te = p+1;} #line 75 "src/lexer.rl" {act = 43;} goto st17; tr309: #line 1 "src/lexer.rl" {te = p+1;} #line 74 "src/lexer.rl" {act = 42;} goto st17; tr318: #line 1 "src/lexer.rl" {te = p+1;} #line 61 "src/lexer.rl" {act = 31;} goto st17; tr321: #line 1 "src/lexer.rl" {te = p+1;} #line 53 "src/lexer.rl" {act = 23;} goto st17; tr325: #line 1 "src/lexer.rl" {te = p+1;} #line 55 "src/lexer.rl" {act = 25;} goto st17; tr331: #line 1 "src/lexer.rl" {te = p+1;} #line 116 "src/lexer.rl" {act = 84;} goto st17; tr334: #line 1 "src/lexer.rl" {te = p+1;} #line 115 "src/lexer.rl" {act = 83;} goto st17; tr335: #line 1 "src/lexer.rl" {te = p+1;} #line 114 "src/lexer.rl" {act = 82;} goto st17; tr338: #line 1 "src/lexer.rl" {te = p+1;} #line 113 "src/lexer.rl" {act = 81;} goto st17; tr339: #line 1 "src/lexer.rl" {te = p+1;} #line 112 "src/lexer.rl" {act = 80;} goto st17; tr342: #line 1 "src/lexer.rl" {te = p+1;} #line 119 "src/lexer.rl" {act = 87;} goto st17; tr347: #line 1 "src/lexer.rl" {te = p+1;} #line 63 "src/lexer.rl" {act = 33;} goto st17; tr351: #line 1 "src/lexer.rl" {te = p+1;} #line 59 "src/lexer.rl" {act = 29;} goto st17; tr354: #line 1 "src/lexer.rl" {te = p+1;} #line 93 "src/lexer.rl" {act = 61;} goto st17; tr355: #line 1 "src/lexer.rl" {te = p+1;} #line 92 "src/lexer.rl" {act = 60;} goto st17; st17: if ( ++p == pe ) goto _test_eof17; case 17: #line 1432 "src/lexer.c" switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr65; st18: if ( ++p == pe ) goto _test_eof18; case 18: switch( (*p) ) { case 58: goto tr66; case 80: goto tr68; case 95: goto tr33; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st19: if ( ++p == pe ) goto _test_eof19; case 19: switch( (*p) ) { case 58: goto tr66; case 79: goto st20; case 95: goto tr33; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st20: if ( ++p == pe ) goto _test_eof20; case 20: switch( (*p) ) { case 58: goto tr66; case 82: goto st21; case 95: goto tr33; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st21: if ( ++p == pe ) goto _test_eof21; case 21: switch( (*p) ) { case 58: goto tr66; case 69: goto st22; case 95: goto tr33; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st22: if ( ++p == pe ) goto _test_eof22; case 22: switch( (*p) ) { case 58: goto tr66; case 71: goto tr72; case 95: goto tr33; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st23: if ( ++p == pe ) goto _test_eof23; case 23: switch( (*p) ) { case 48: goto tr73; case 49: goto tr74; case 50: goto tr75; case 58: goto tr66; case 69: goto st24; case 95: goto tr33; } if ( (*p) < 65 ) { if ( 51 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st24: if ( ++p == pe ) goto _test_eof24; case 24: switch( (*p) ) { case 58: goto tr66; case 84: goto tr77; case 95: goto tr33; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st25: if ( ++p == pe ) goto _test_eof25; case 25: switch( (*p) ) { case 48: goto tr78; case 49: goto tr79; case 50: goto tr80; case 58: goto tr66; case 95: goto tr33; } if ( (*p) < 65 ) { if ( 51 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st26: if ( ++p == pe ) goto _test_eof26; case 26: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 100: goto st27; case 108: goto st35; case 110: goto st38; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st27: if ( ++p == pe ) goto _test_eof27; case 27: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 100: goto st28; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st28: if ( ++p == pe ) goto _test_eof28; case 28: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 99: goto st29; case 105: goto tr86; case 114: goto tr87; case 120: goto st34; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st29: if ( ++p == pe ) goto _test_eof29; case 29: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto st30; case 114: goto st32; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st30: if ( ++p == pe ) goto _test_eof30; case 30: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 101: goto st31; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st31: if ( ++p == pe ) goto _test_eof31; case 31: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 116: goto tr92; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st32: if ( ++p == pe ) goto _test_eof32; case 32: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 101: goto st33; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st33: if ( ++p == pe ) goto _test_eof33; case 33: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 116: goto tr94; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st34: if ( ++p == pe ) goto _test_eof34; case 34: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto tr95; case 114: goto tr96; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st35: if ( ++p == pe ) goto _test_eof35; case 35: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 108: goto st36; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st36: if ( ++p == pe ) goto _test_eof36; case 36: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 111: goto st37; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st37: if ( ++p == pe ) goto _test_eof37; case 37: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 99: goto tr99; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st38: if ( ++p == pe ) goto _test_eof38; case 38: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 100: goto st39; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st39: if ( ++p == pe ) goto _test_eof39; case 39: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto tr101; case 114: goto tr102; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st40: if ( ++p == pe ) goto _test_eof40; case 40: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 101: goto st41; case 103: goto st43; case 108: goto st46; case 109: goto st49; case 110: goto st52; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st41: if ( ++p == pe ) goto _test_eof41; case 41: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 113: goto st42; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st42: if ( ++p == pe ) goto _test_eof42; case 42: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto tr109; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st43: if ( ++p == pe ) goto _test_eof43; case 43: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 101: goto st44; case 116: goto st45; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st44: if ( ++p == pe ) goto _test_eof44; case 44: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto tr112; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st45: if ( ++p == pe ) goto _test_eof45; case 45: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto tr113; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st46: if ( ++p == pe ) goto _test_eof46; case 46: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 101: goto st47; case 116: goto st48; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st47: if ( ++p == pe ) goto _test_eof47; case 47: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto tr116; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st48: if ( ++p == pe ) goto _test_eof48; case 48: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto tr117; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st49: if ( ++p == pe ) goto _test_eof49; case 49: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 99: goto st50; case 115: goto st51; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st50: if ( ++p == pe ) goto _test_eof50; case 50: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto tr120; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st51: if ( ++p == pe ) goto _test_eof51; case 51: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto tr121; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st52: if ( ++p == pe ) goto _test_eof52; case 52: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 101: goto st53; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st53: if ( ++p == pe ) goto _test_eof53; case 53: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto tr123; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st54: if ( ++p == pe ) goto _test_eof54; case 54: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 97: goto st55; case 104: goto st58; case 111: goto st60; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 98 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr124; st55: if ( ++p == pe ) goto _test_eof55; case 55: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 108: goto st56; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st56: if ( ++p == pe ) goto _test_eof56; case 56: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 108: goto st57; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st57: if ( ++p == pe ) goto _test_eof57; case 57: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto tr130; case 114: goto tr131; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st58: if ( ++p == pe ) goto _test_eof58; case 58: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 97: goto st59; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 98 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st59: if ( ++p == pe ) goto _test_eof59; case 59: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 114: goto tr133; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st60: if ( ++p == pe ) goto _test_eof60; case 60: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 108: goto st61; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st61: if ( ++p == pe ) goto _test_eof61; case 61: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 108: goto st62; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st62: if ( ++p == pe ) goto _test_eof62; case 62: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 101: goto st63; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st63: if ( ++p == pe ) goto _test_eof63; case 63: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 99: goto st64; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st64: if ( ++p == pe ) goto _test_eof64; case 64: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 116: goto tr138; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st65: if ( ++p == pe ) goto _test_eof65; case 65: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto st66; case 111: goto st68; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr139; st66: if ( ++p == pe ) goto _test_eof66; case 66: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 118: goto st67; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st67: if ( ++p == pe ) goto _test_eof67; case 67: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto tr143; case 114: goto tr144; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st68: if ( ++p == pe ) goto _test_eof68; case 68: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 117: goto st69; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st69: if ( ++p == pe ) goto _test_eof69; case 69: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 98: goto st70; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st70: if ( ++p == pe ) goto _test_eof70; case 70: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 108: goto st71; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st71: if ( ++p == pe ) goto _test_eof71; case 71: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 101: goto tr148; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st72: if ( ++p == pe ) goto _test_eof72; case 72: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 110: goto st73; case 113: goto st74; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st73: if ( ++p == pe ) goto _test_eof73; case 73: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 100: goto tr151; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st74: if ( ++p == pe ) goto _test_eof74; case 74: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto tr152; case 114: goto tr153; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st75: if ( ++p == pe ) goto _test_eof75; case 75: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto st76; case 108: goto st81; case 114: goto st84; case 117: goto st86; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr154; st76: if ( ++p == pe ) goto _test_eof76; case 76: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 110: goto st77; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st77: if ( ++p == pe ) goto _test_eof77; case 77: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto st78; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st78: if ( ++p == pe ) goto _test_eof78; case 78: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 115: goto st79; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st79: if ( ++p == pe ) goto _test_eof79; case 79: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 104: goto st80; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st80: if ( ++p == pe ) goto _test_eof80; case 80: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 114: goto tr164; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr163; st81: if ( ++p == pe ) goto _test_eof81; case 81: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 111: goto st82; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st82: if ( ++p == pe ) goto _test_eof82; case 82: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 97: goto st83; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 98 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st83: if ( ++p == pe ) goto _test_eof83; case 83: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 116: goto tr167; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st84: if ( ++p == pe ) goto _test_eof84; case 84: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 101: goto st85; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st85: if ( ++p == pe ) goto _test_eof85; case 85: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 101: goto tr169; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st86: if ( ++p == pe ) goto _test_eof86; case 86: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 110: goto st87; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st87: if ( ++p == pe ) goto _test_eof87; case 87: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 99: goto st88; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st88: if ( ++p == pe ) goto _test_eof88; case 88: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 116: goto st89; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st89: if ( ++p == pe ) goto _test_eof89; case 89: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto st90; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st90: if ( ++p == pe ) goto _test_eof90; case 90: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 111: goto st91; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st91: if ( ++p == pe ) goto _test_eof91; case 91: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 110: goto tr175; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st92: if ( ++p == pe ) goto _test_eof92; case 92: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 101: goto st93; case 116: goto st97; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st93: if ( ++p == pe ) goto _test_eof93; case 93: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto tr178; case 114: goto tr179; case 116: goto st94; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st94: if ( ++p == pe ) goto _test_eof94; case 94: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 97: goto st95; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 98 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st95: if ( ++p == pe ) goto _test_eof95; case 95: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 114: goto st96; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st96: if ( ++p == pe ) goto _test_eof96; case 96: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 103: goto tr183; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st97: if ( ++p == pe ) goto _test_eof97; case 97: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto tr184; case 114: goto tr185; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st98: if ( ++p == pe ) goto _test_eof98; case 98: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 109: goto st99; case 116: goto st102; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st99: if ( ++p == pe ) goto _test_eof99; case 99: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 117: goto st100; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st100: if ( ++p == pe ) goto _test_eof100; case 100: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 108: goto st101; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st101: if ( ++p == pe ) goto _test_eof101; case 101: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto tr190; case 114: goto tr191; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st102: if ( ++p == pe ) goto _test_eof102; case 102: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 111: goto st103; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st103: if ( ++p == pe ) goto _test_eof103; case 103: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 110: goto tr193; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st104: if ( ++p == pe ) goto _test_eof104; case 104: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 110: goto st105; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr194; st105: if ( ++p == pe ) goto _test_eof105; case 105: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 116: goto tr196; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st106: if ( ++p == pe ) goto _test_eof106; case 106: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 109: goto st107; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st107: if ( ++p == pe ) goto _test_eof107; case 107: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 112: goto st108; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st108: if ( ++p == pe ) goto _test_eof108; case 108: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto tr199; case 114: goto tr200; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st109: if ( ++p == pe ) goto _test_eof109; case 109: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 100: goto st110; case 101: goto st112; case 111: goto st113; case 115: goto st115; case 116: goto st117; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr201; st110: if ( ++p == pe ) goto _test_eof110; case 110: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto tr207; case 114: goto tr208; case 120: goto st111; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st111: if ( ++p == pe ) goto _test_eof111; case 111: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto tr210; case 114: goto tr211; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st112: if ( ++p == pe ) goto _test_eof112; case 112: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto tr212; case 114: goto tr213; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st113: if ( ++p == pe ) goto _test_eof113; case 113: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 110: goto st114; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st114: if ( ++p == pe ) goto _test_eof114; case 114: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 103: goto tr215; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st115: if ( ++p == pe ) goto _test_eof115; case 115: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 104: goto st116; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st116: if ( ++p == pe ) goto _test_eof116; case 116: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto tr217; case 114: goto tr218; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st117: if ( ++p == pe ) goto _test_eof117; case 117: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 103: goto st118; case 105: goto tr220; case 114: goto tr221; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st118: if ( ++p == pe ) goto _test_eof118; case 118: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 116: goto st119; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st119: if ( ++p == pe ) goto _test_eof119; case 119: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 114: goto tr223; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st120: if ( ++p == pe ) goto _test_eof120; case 120: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 111: goto st121; case 117: goto st124; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st121: if ( ++p == pe ) goto _test_eof121; case 121: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 100: goto st122; case 118: goto st123; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st122: if ( ++p == pe ) goto _test_eof122; case 122: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto tr228; case 114: goto tr229; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st123: if ( ++p == pe ) goto _test_eof123; case 123: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto tr230; case 114: goto tr231; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st124: if ( ++p == pe ) goto _test_eof124; case 124: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 108: goto st125; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st125: if ( ++p == pe ) goto _test_eof125; case 125: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto tr233; case 114: goto tr234; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st126: if ( ++p == pe ) goto _test_eof126; case 126: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 101: goto st127; case 111: goto st129; case 116: goto st131; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st127: if ( ++p == pe ) goto _test_eof127; case 127: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 103: goto st128; case 105: goto tr239; case 114: goto tr240; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st128: if ( ++p == pe ) goto _test_eof128; case 128: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 114: goto tr241; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st129: if ( ++p == pe ) goto _test_eof129; case 129: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 116: goto st130; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st130: if ( ++p == pe ) goto _test_eof130; case 130: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 114: goto tr243; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st131: if ( ++p == pe ) goto _test_eof131; case 131: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 111: goto st132; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st132: if ( ++p == pe ) goto _test_eof132; case 132: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 104: goto tr245; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st133: if ( ++p == pe ) goto _test_eof133; case 133: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 114: goto st134; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st134: if ( ++p == pe ) goto _test_eof134; case 134: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 100: goto st135; case 105: goto tr248; case 114: goto tr249; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st135: if ( ++p == pe ) goto _test_eof135; case 135: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 114: goto tr250; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st136: if ( ++p == pe ) goto _test_eof136; case 136: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 114: goto st137; case 116: goto st142; case 117: goto st143; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr251; st137: if ( ++p == pe ) goto _test_eof137; case 137: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 101: goto st138; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st138: if ( ++p == pe ) goto _test_eof138; case 138: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 112: goto st139; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st139: if ( ++p == pe ) goto _test_eof139; case 139: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 97: goto st140; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 98 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st140: if ( ++p == pe ) goto _test_eof140; case 140: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 114: goto st141; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st141: if ( ++p == pe ) goto _test_eof141; case 141: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 101: goto tr259; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st142: if ( ++p == pe ) goto _test_eof142; case 142: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 114: goto tr260; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st143: if ( ++p == pe ) goto _test_eof143; case 143: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 115: goto st144; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st144: if ( ++p == pe ) goto _test_eof144; case 144: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 104: goto st145; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st145: if ( ++p == pe ) goto _test_eof145; case 145: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 97: goto st146; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 98 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st146: if ( ++p == pe ) goto _test_eof146; case 146: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 114: goto st147; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st147: if ( ++p == pe ) goto _test_eof147; case 147: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 103: goto tr265; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st148: if ( ++p == pe ) goto _test_eof148; case 148: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 101: goto st149; case 115: goto st157; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st149: if ( ++p == pe ) goto _test_eof149; case 149: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 97: goto st150; case 116: goto st154; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 98 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st150: if ( ++p == pe ) goto _test_eof150; case 150: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 108: goto st151; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st151: if ( ++p == pe ) goto _test_eof151; case 151: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 108: goto st152; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st152: if ( ++p == pe ) goto _test_eof152; case 152: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 111: goto st153; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st153: if ( ++p == pe ) goto _test_eof153; case 153: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 99: goto tr273; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st154: if ( ++p == pe ) goto _test_eof154; case 154: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 118: goto st155; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr274; st155: if ( ++p == pe ) goto _test_eof155; case 155: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 97: goto st156; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 98 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st156: if ( ++p == pe ) goto _test_eof156; case 156: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 108: goto tr277; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st157: if ( ++p == pe ) goto _test_eof157; case 157: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 98: goto st158; case 104: goto st159; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st158: if ( ++p == pe ) goto _test_eof158; case 158: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto tr280; case 114: goto tr281; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st159: if ( ++p == pe ) goto _test_eof159; case 159: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto tr282; case 114: goto tr283; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st160: if ( ++p == pe ) goto _test_eof160; case 160: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 104: goto st161; case 105: goto st164; case 116: goto st168; case 117: goto st170; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr284; st161: if ( ++p == pe ) goto _test_eof161; case 161: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 111: goto st162; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st162: if ( ++p == pe ) goto _test_eof162; case 162: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 114: goto st163; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st163: if ( ++p == pe ) goto _test_eof163; case 163: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 116: goto tr291; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st164: if ( ++p == pe ) goto _test_eof164; case 164: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 122: goto st165; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 121 ) goto tr33; } else goto tr33; goto tr67; st165: if ( ++p == pe ) goto _test_eof165; case 165: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 101: goto st166; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st166: if ( ++p == pe ) goto _test_eof166; case 166: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 111: goto st167; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st167: if ( ++p == pe ) goto _test_eof167; case 167: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 102: goto tr295; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st168: if ( ++p == pe ) goto _test_eof168; case 168: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto tr296; case 114: goto tr297; case 120: goto st169; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st169: if ( ++p == pe ) goto _test_eof169; case 169: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto tr299; case 114: goto tr300; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st170: if ( ++p == pe ) goto _test_eof170; case 170: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 98: goto st171; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st171: if ( ++p == pe ) goto _test_eof171; case 171: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 99: goto st172; case 105: goto tr303; case 114: goto tr304; case 120: goto st173; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st172: if ( ++p == pe ) goto _test_eof172; case 172: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto tr306; case 114: goto tr307; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st173: if ( ++p == pe ) goto _test_eof173; case 173: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto tr308; case 114: goto tr309; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st174: if ( ++p == pe ) goto _test_eof174; case 174: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 99: goto st175; case 105: goto st178; case 108: goto st180; case 110: goto st183; case 115: goto st195; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st175: if ( ++p == pe ) goto _test_eof175; case 175: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 104: goto st176; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr315; st176: if ( ++p == pe ) goto _test_eof176; case 176: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 97: goto st177; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 98 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st177: if ( ++p == pe ) goto _test_eof177; case 177: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 114: goto tr318; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st178: if ( ++p == pe ) goto _test_eof178; case 178: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 110: goto st179; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr319; st179: if ( ++p == pe ) goto _test_eof179; case 179: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 116: goto tr321; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st180: if ( ++p == pe ) goto _test_eof180; case 180: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 111: goto st181; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr322; st181: if ( ++p == pe ) goto _test_eof181; case 181: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 110: goto st182; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st182: if ( ++p == pe ) goto _test_eof182; case 182: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 103: goto tr325; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st183: if ( ++p == pe ) goto _test_eof183; case 183: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 101: goto st184; case 103: goto st186; case 108: goto st189; case 111: goto st192; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st184: if ( ++p == pe ) goto _test_eof184; case 184: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 113: goto st185; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st185: if ( ++p == pe ) goto _test_eof185; case 185: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 114: goto tr331; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st186: if ( ++p == pe ) goto _test_eof186; case 186: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 101: goto st187; case 116: goto st188; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st187: if ( ++p == pe ) goto _test_eof187; case 187: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 114: goto tr334; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st188: if ( ++p == pe ) goto _test_eof188; case 188: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 114: goto tr335; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st189: if ( ++p == pe ) goto _test_eof189; case 189: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 101: goto st190; case 116: goto st191; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st190: if ( ++p == pe ) goto _test_eof190; case 190: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 114: goto tr338; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st191: if ( ++p == pe ) goto _test_eof191; case 191: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 114: goto tr339; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st192: if ( ++p == pe ) goto _test_eof192; case 192: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 114: goto st193; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st193: if ( ++p == pe ) goto _test_eof193; case 193: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 100: goto st194; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st194: if ( ++p == pe ) goto _test_eof194; case 194: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 114: goto tr342; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st195: if ( ++p == pe ) goto _test_eof195; case 195: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 104: goto st196; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr343; st196: if ( ++p == pe ) goto _test_eof196; case 196: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 111: goto st197; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st197: if ( ++p == pe ) goto _test_eof197; case 197: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 114: goto st198; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st198: if ( ++p == pe ) goto _test_eof198; case 198: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 116: goto tr347; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st199: if ( ++p == pe ) goto _test_eof199; case 199: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 111: goto st200; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr348; st200: if ( ++p == pe ) goto _test_eof200; case 200: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto st201; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st201: if ( ++p == pe ) goto _test_eof201; case 201: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 100: goto tr351; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st202: if ( ++p == pe ) goto _test_eof202; case 202: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 111: goto st203; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st203: if ( ++p == pe ) goto _test_eof203; case 203: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 114: goto st204; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; st204: if ( ++p == pe ) goto _test_eof204; case 204: switch( (*p) ) { case 58: goto tr66; case 95: goto tr33; case 105: goto tr354; case 114: goto tr355; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr33; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr33; } else goto tr33; goto tr67; tr17: #line 14 "src/lexer.rl" {state->curline++; SYM(EOL)} goto st10; st10: #line 1 "src/lexer.rl" {ts = 0;} if ( ++p == pe ) goto _test_eof10; case 10: #line 4909 "src/lexer.c" switch( (*p) ) { case 10: goto tr17; case 42: goto st11; } goto st10; st11: if ( ++p == pe ) goto _test_eof11; case 11: switch( (*p) ) { case 10: goto tr17; case 42: goto st11; case 47: goto tr19; } goto st10; tr19: #line 17 "src/lexer.rl" {{goto st12;}} goto st205; st205: if ( ++p == pe ) goto _test_eof205; case 205: #line 4933 "src/lexer.c" goto st0; } _test_eof12: cs = 12; goto _test_eof; _test_eof1: cs = 1; goto _test_eof; _test_eof2: cs = 2; goto _test_eof; _test_eof3: cs = 3; goto _test_eof; _test_eof4: cs = 4; goto _test_eof; _test_eof5: cs = 5; goto _test_eof; _test_eof6: cs = 6; goto _test_eof; _test_eof13: cs = 13; goto _test_eof; _test_eof7: cs = 7; goto _test_eof; _test_eof14: cs = 14; goto _test_eof; _test_eof8: cs = 8; goto _test_eof; _test_eof15: cs = 15; goto _test_eof; _test_eof9: cs = 9; goto _test_eof; _test_eof16: cs = 16; goto _test_eof; _test_eof17: cs = 17; goto _test_eof; _test_eof18: cs = 18; goto _test_eof; _test_eof19: cs = 19; goto _test_eof; _test_eof20: cs = 20; goto _test_eof; _test_eof21: cs = 21; goto _test_eof; _test_eof22: cs = 22; goto _test_eof; _test_eof23: cs = 23; goto _test_eof; _test_eof24: cs = 24; goto _test_eof; _test_eof25: cs = 25; goto _test_eof; _test_eof26: cs = 26; goto _test_eof; _test_eof27: cs = 27; goto _test_eof; _test_eof28: cs = 28; goto _test_eof; _test_eof29: cs = 29; goto _test_eof; _test_eof30: cs = 30; goto _test_eof; _test_eof31: cs = 31; goto _test_eof; _test_eof32: cs = 32; goto _test_eof; _test_eof33: cs = 33; goto _test_eof; _test_eof34: cs = 34; goto _test_eof; _test_eof35: cs = 35; goto _test_eof; _test_eof36: cs = 36; goto _test_eof; _test_eof37: cs = 37; goto _test_eof; _test_eof38: cs = 38; goto _test_eof; _test_eof39: cs = 39; goto _test_eof; _test_eof40: cs = 40; goto _test_eof; _test_eof41: cs = 41; goto _test_eof; _test_eof42: cs = 42; goto _test_eof; _test_eof43: cs = 43; goto _test_eof; _test_eof44: cs = 44; goto _test_eof; _test_eof45: cs = 45; goto _test_eof; _test_eof46: cs = 46; goto _test_eof; _test_eof47: cs = 47; goto _test_eof; _test_eof48: cs = 48; goto _test_eof; _test_eof49: cs = 49; goto _test_eof; _test_eof50: cs = 50; goto _test_eof; _test_eof51: cs = 51; goto _test_eof; _test_eof52: cs = 52; goto _test_eof; _test_eof53: cs = 53; goto _test_eof; _test_eof54: cs = 54; goto _test_eof; _test_eof55: cs = 55; goto _test_eof; _test_eof56: cs = 56; goto _test_eof; _test_eof57: cs = 57; goto _test_eof; _test_eof58: cs = 58; goto _test_eof; _test_eof59: cs = 59; goto _test_eof; _test_eof60: cs = 60; goto _test_eof; _test_eof61: cs = 61; goto _test_eof; _test_eof62: cs = 62; goto _test_eof; _test_eof63: cs = 63; goto _test_eof; _test_eof64: cs = 64; goto _test_eof; _test_eof65: cs = 65; goto _test_eof; _test_eof66: cs = 66; goto _test_eof; _test_eof67: cs = 67; goto _test_eof; _test_eof68: cs = 68; goto _test_eof; _test_eof69: cs = 69; goto _test_eof; _test_eof70: cs = 70; goto _test_eof; _test_eof71: cs = 71; goto _test_eof; _test_eof72: cs = 72; goto _test_eof; _test_eof73: cs = 73; goto _test_eof; _test_eof74: cs = 74; goto _test_eof; _test_eof75: cs = 75; goto _test_eof; _test_eof76: cs = 76; goto _test_eof; _test_eof77: cs = 77; goto _test_eof; _test_eof78: cs = 78; goto _test_eof; _test_eof79: cs = 79; goto _test_eof; _test_eof80: cs = 80; goto _test_eof; _test_eof81: cs = 81; goto _test_eof; _test_eof82: cs = 82; goto _test_eof; _test_eof83: cs = 83; goto _test_eof; _test_eof84: cs = 84; goto _test_eof; _test_eof85: cs = 85; goto _test_eof; _test_eof86: cs = 86; goto _test_eof; _test_eof87: cs = 87; goto _test_eof; _test_eof88: cs = 88; goto _test_eof; _test_eof89: cs = 89; goto _test_eof; _test_eof90: cs = 90; goto _test_eof; _test_eof91: cs = 91; goto _test_eof; _test_eof92: cs = 92; goto _test_eof; _test_eof93: cs = 93; goto _test_eof; _test_eof94: cs = 94; goto _test_eof; _test_eof95: cs = 95; goto _test_eof; _test_eof96: cs = 96; goto _test_eof; _test_eof97: cs = 97; goto _test_eof; _test_eof98: cs = 98; goto _test_eof; _test_eof99: cs = 99; goto _test_eof; _test_eof100: cs = 100; goto _test_eof; _test_eof101: cs = 101; goto _test_eof; _test_eof102: cs = 102; goto _test_eof; _test_eof103: cs = 103; goto _test_eof; _test_eof104: cs = 104; goto _test_eof; _test_eof105: cs = 105; goto _test_eof; _test_eof106: cs = 106; goto _test_eof; _test_eof107: cs = 107; goto _test_eof; _test_eof108: cs = 108; goto _test_eof; _test_eof109: cs = 109; goto _test_eof; _test_eof110: cs = 110; goto _test_eof; _test_eof111: cs = 111; goto _test_eof; _test_eof112: cs = 112; goto _test_eof; _test_eof113: cs = 113; goto _test_eof; _test_eof114: cs = 114; goto _test_eof; _test_eof115: cs = 115; goto _test_eof; _test_eof116: cs = 116; goto _test_eof; _test_eof117: cs = 117; goto _test_eof; _test_eof118: cs = 118; goto _test_eof; _test_eof119: cs = 119; goto _test_eof; _test_eof120: cs = 120; goto _test_eof; _test_eof121: cs = 121; goto _test_eof; _test_eof122: cs = 122; goto _test_eof; _test_eof123: cs = 123; goto _test_eof; _test_eof124: cs = 124; goto _test_eof; _test_eof125: cs = 125; goto _test_eof; _test_eof126: cs = 126; goto _test_eof; _test_eof127: cs = 127; goto _test_eof; _test_eof128: cs = 128; goto _test_eof; _test_eof129: cs = 129; goto _test_eof; _test_eof130: cs = 130; goto _test_eof; _test_eof131: cs = 131; goto _test_eof; _test_eof132: cs = 132; goto _test_eof; _test_eof133: cs = 133; goto _test_eof; _test_eof134: cs = 134; goto _test_eof; _test_eof135: cs = 135; goto _test_eof; _test_eof136: cs = 136; goto _test_eof; _test_eof137: cs = 137; goto _test_eof; _test_eof138: cs = 138; goto _test_eof; _test_eof139: cs = 139; goto _test_eof; _test_eof140: cs = 140; goto _test_eof; _test_eof141: cs = 141; goto _test_eof; _test_eof142: cs = 142; goto _test_eof; _test_eof143: cs = 143; goto _test_eof; _test_eof144: cs = 144; goto _test_eof; _test_eof145: cs = 145; goto _test_eof; _test_eof146: cs = 146; goto _test_eof; _test_eof147: cs = 147; goto _test_eof; _test_eof148: cs = 148; goto _test_eof; _test_eof149: cs = 149; goto _test_eof; _test_eof150: cs = 150; goto _test_eof; _test_eof151: cs = 151; goto _test_eof; _test_eof152: cs = 152; goto _test_eof; _test_eof153: cs = 153; goto _test_eof; _test_eof154: cs = 154; goto _test_eof; _test_eof155: cs = 155; goto _test_eof; _test_eof156: cs = 156; goto _test_eof; _test_eof157: cs = 157; goto _test_eof; _test_eof158: cs = 158; goto _test_eof; _test_eof159: cs = 159; goto _test_eof; _test_eof160: cs = 160; goto _test_eof; _test_eof161: cs = 161; goto _test_eof; _test_eof162: cs = 162; goto _test_eof; _test_eof163: cs = 163; goto _test_eof; _test_eof164: cs = 164; goto _test_eof; _test_eof165: cs = 165; goto _test_eof; _test_eof166: cs = 166; goto _test_eof; _test_eof167: cs = 167; goto _test_eof; _test_eof168: cs = 168; goto _test_eof; _test_eof169: cs = 169; goto _test_eof; _test_eof170: cs = 170; goto _test_eof; _test_eof171: cs = 171; goto _test_eof; _test_eof172: cs = 172; goto _test_eof; _test_eof173: cs = 173; goto _test_eof; _test_eof174: cs = 174; goto _test_eof; _test_eof175: cs = 175; goto _test_eof; _test_eof176: cs = 176; goto _test_eof; _test_eof177: cs = 177; goto _test_eof; _test_eof178: cs = 178; goto _test_eof; _test_eof179: cs = 179; goto _test_eof; _test_eof180: cs = 180; goto _test_eof; _test_eof181: cs = 181; goto _test_eof; _test_eof182: cs = 182; goto _test_eof; _test_eof183: cs = 183; goto _test_eof; _test_eof184: cs = 184; goto _test_eof; _test_eof185: cs = 185; goto _test_eof; _test_eof186: cs = 186; goto _test_eof; _test_eof187: cs = 187; goto _test_eof; _test_eof188: cs = 188; goto _test_eof; _test_eof189: cs = 189; goto _test_eof; _test_eof190: cs = 190; goto _test_eof; _test_eof191: cs = 191; goto _test_eof; _test_eof192: cs = 192; goto _test_eof; _test_eof193: cs = 193; goto _test_eof; _test_eof194: cs = 194; goto _test_eof; _test_eof195: cs = 195; goto _test_eof; _test_eof196: cs = 196; goto _test_eof; _test_eof197: cs = 197; goto _test_eof; _test_eof198: cs = 198; goto _test_eof; _test_eof199: cs = 199; goto _test_eof; _test_eof200: cs = 200; goto _test_eof; _test_eof201: cs = 201; goto _test_eof; _test_eof202: cs = 202; goto _test_eof; _test_eof203: cs = 203; goto _test_eof; _test_eof204: cs = 204; goto _test_eof; _test_eof10: cs = 10; goto _test_eof; _test_eof11: cs = 11; goto _test_eof; _test_eof205: cs = 205; goto _test_eof; _test_eof: {} if ( p == eof ) { switch ( cs ) { case 13: goto tr60; case 7: goto tr12; case 14: goto tr62; case 15: goto tr60; case 9: goto tr12; case 16: goto tr64; case 17: goto tr65; case 18: goto tr67; case 19: goto tr67; case 20: goto tr67; case 21: goto tr67; case 22: goto tr67; case 23: goto tr67; case 24: goto tr67; case 25: goto tr67; case 26: goto tr67; case 27: goto tr67; case 28: goto tr67; case 29: goto tr67; case 30: goto tr67; case 31: goto tr67; case 32: goto tr67; case 33: goto tr67; case 34: goto tr67; case 35: goto tr67; case 36: goto tr67; case 37: goto tr67; case 38: goto tr67; case 39: goto tr67; case 40: goto tr67; case 41: goto tr67; case 42: goto tr67; case 43: goto tr67; case 44: goto tr67; case 45: goto tr67; case 46: goto tr67; case 47: goto tr67; case 48: goto tr67; case 49: goto tr67; case 50: goto tr67; case 51: goto tr67; case 52: goto tr67; case 53: goto tr67; case 54: goto tr124; case 55: goto tr67; case 56: goto tr67; case 57: goto tr67; case 58: goto tr67; case 59: goto tr67; case 60: goto tr67; case 61: goto tr67; case 62: goto tr67; case 63: goto tr67; case 64: goto tr67; case 65: goto tr139; case 66: goto tr67; case 67: goto tr67; case 68: goto tr67; case 69: goto tr67; case 70: goto tr67; case 71: goto tr67; case 72: goto tr67; case 73: goto tr67; case 74: goto tr67; case 75: goto tr154; case 76: goto tr67; case 77: goto tr67; case 78: goto tr67; case 79: goto tr67; case 80: goto tr163; case 81: goto tr67; case 82: goto tr67; case 83: goto tr67; case 84: goto tr67; case 85: goto tr67; case 86: goto tr67; case 87: goto tr67; case 88: goto tr67; case 89: goto tr67; case 90: goto tr67; case 91: goto tr67; case 92: goto tr67; case 93: goto tr67; case 94: goto tr67; case 95: goto tr67; case 96: goto tr67; case 97: goto tr67; case 98: goto tr67; case 99: goto tr67; case 100: goto tr67; case 101: goto tr67; case 102: goto tr67; case 103: goto tr67; case 104: goto tr194; case 105: goto tr67; case 106: goto tr67; case 107: goto tr67; case 108: goto tr67; case 109: goto tr201; case 110: goto tr67; case 111: goto tr67; case 112: goto tr67; case 113: goto tr67; case 114: goto tr67; case 115: goto tr67; case 116: goto tr67; case 117: goto tr67; case 118: goto tr67; case 119: goto tr67; case 120: goto tr67; case 121: goto tr67; case 122: goto tr67; case 123: goto tr67; case 124: goto tr67; case 125: goto tr67; case 126: goto tr67; case 127: goto tr67; case 128: goto tr67; case 129: goto tr67; case 130: goto tr67; case 131: goto tr67; case 132: goto tr67; case 133: goto tr67; case 134: goto tr67; case 135: goto tr67; case 136: goto tr251; case 137: goto tr67; case 138: goto tr67; case 139: goto tr67; case 140: goto tr67; case 141: goto tr67; case 142: goto tr67; case 143: goto tr67; case 144: goto tr67; case 145: goto tr67; case 146: goto tr67; case 147: goto tr67; case 148: goto tr67; case 149: goto tr67; case 150: goto tr67; case 151: goto tr67; case 152: goto tr67; case 153: goto tr67; case 154: goto tr274; case 155: goto tr67; case 156: goto tr67; case 157: goto tr67; case 158: goto tr67; case 159: goto tr67; case 160: goto tr284; case 161: goto tr67; case 162: goto tr67; case 163: goto tr67; case 164: goto tr67; case 165: goto tr67; case 166: goto tr67; case 167: goto tr67; case 168: goto tr67; case 169: goto tr67; case 170: goto tr67; case 171: goto tr67; case 172: goto tr67; case 173: goto tr67; case 174: goto tr67; case 175: goto tr315; case 176: goto tr67; case 177: goto tr67; case 178: goto tr319; case 179: goto tr67; case 180: goto tr322; case 181: goto tr67; case 182: goto tr67; case 183: goto tr67; case 184: goto tr67; case 185: goto tr67; case 186: goto tr67; case 187: goto tr67; case 188: goto tr67; case 189: goto tr67; case 190: goto tr67; case 191: goto tr67; case 192: goto tr67; case 193: goto tr67; case 194: goto tr67; case 195: goto tr343; case 196: goto tr67; case 197: goto tr67; case 198: goto tr67; case 199: goto tr348; case 200: goto tr67; case 201: goto tr67; case 202: goto tr67; case 203: goto tr67; case 204: goto tr67; } } _out: {} } #line 205 "src/lexer.rl" if(cs == lexer_error) { state->errors++; error(state, "invalid character '%c'\n", p[0]); } else { Parse(pParser, 0, NULL, state); } ParseFree(pParser, Allocator_free); return state->errors > 0 ? 0 : 1; }
zedshaw/earing
tests/array_tests.c
<reponame>zedshaw/earing #include <cut/2.6/cut.h> #include "array.h" #include <gc.h> #define ARRAY_BASE_SIZE 10 void __CUT__array_Bringup(void) { GC_INIT(); } void __CUT__array_create( void ) { array_t *ary = array_create(ARRAY_BASE_SIZE); ASSERT(ary != NULL, "Must create an array." ); ASSERT(ary->size == ARRAY_BASE_SIZE, "Wrong size."); ASSERT(ary->end == 0, "End isn't at the beginning."); ASSERT(ary->data != NULL, "Data should be pointing somewhere."); } void __CUT__array_status(void) { array_t *ary = array_create(ARRAY_BASE_SIZE); ASSERT(array_max(ary) == ARRAY_BASE_SIZE, "Wrong length."); ASSERT(!array_isfull(ary), "Should not be full."); ASSERT(array_isempty(ary), "Should be empty."); ASSERT(array_length(ary) == 0, "End should be right at 0."); } void __CUT__array_operations(void) { array_t *ary = array_create(ARRAY_BASE_SIZE); int i = 0; size_t end = 0; end = array_add(ary, &i); ASSERT(end == 1, "array end should be 1."); ASSERT(!array_isempty(ary), "Array shouldn't be empty."); ASSERT(!array_isfull(ary), "Array shouldn't be full."); ASSERT(array_at(ary, 0) == &i, "Not the right value."); ASSERT(array_last(ary) == &i, "Not the right last."); void *ptr = array_pop(ary); ASSERT(array_isempty(ary), "Array should be empty."); ASSERT(ptr == &i, "Wrong value."); end = array_push(ary, &i); ASSERT(end == 1, "should be 1."); ary = array_create(1); end = array_push(ary, &i); ASSERT(array_isfull(ary), "Should be full."); ASSERT(!array_isempty(ary), "Should be empty."); ASSERT(array_at(ary, 0) == &i, "wrong value."); ptr = array_pop(ary); ASSERT(ptr == &i, "wrong value."); ASSERT(array_isempty(ary), "Should be empty."); ASSERT(array_pop(ary) == NULL, "pop should return NULL."); array_at(ary, 0) = (void *)4; ASSERT(array_at(ary, 0) == (void *)4, "Should be 4."); array_set(ary, 0, &i); ASSERT(array_at(ary, 0) == &i, "wrong value after set."); } void __CUT__array_extend(void) { array_t *ary = array_create(1); int i = 0; array_add(ary, &i); ASSERT(array_isfull(ary), "Should be full."); ary = array_extend(ary, 1); ASSERT(!array_isfull(ary), "Should not be full."); array_add(ary, &i+1); ASSERT(array_isfull(ary), "Should be full."); ASSERT(array_pop(ary) == &i+1, "first pop wrong."); ASSERT(array_pop(ary) == &i, "second pop wrong."); ASSERT(!array_isfull(ary), "should not be full."); ASSERT(array_isempty(ary), "should be empty."); array_add(ary, &i); array_add(ary, &i+1); ary = array_extend(ary, 100); ASSERT(array_max(ary) == 102, "wrong length"); ASSERT(array_length(ary) == 2, "wrong end."); ary = array_clamp(ary); ASSERT(array_max(ary) == 2, "wrong length after clamp."); }
zedshaw/earing
src/struct.h
<reponame>zedshaw/earing #ifndef struct_h #define struct_h typedef struct StructAlign { int is_packed; int is_two; int is_four; int is_eight; int is_largest; int size; int extent; } StructAlign; StructAlign StructAlign_create(void); int StructAlign_indeterminate(StructAlign sa); int StructAlign_multiple_cases(StructAlign sa); #define StructAlign_is_packed(A) ((A).is_packed) #define StructAlign_is_largest(A) ((A).is_largest) #define StructAlign_is_two(A) ((A).is_two) #define StructAlign_is_four(A) ((A).is_four) #define StructAlign_is_eight(A) ((A).is_eight) #endif
zedshaw/earing
src/gen.c
#include "module.h" #include "label.h" #include "function.h" #include "grammar.h" #include "error.h" #include "hash.h" #include <gc/gc.h> #include <assert.h> // because of the way GNU lightning is designed we have to keep ALL of the // code generation tasks in the same file. Since the function management is // here we also have to include the code ops.c here. #include "ops.c" void Function_synthesize_param(FunctionParam *p) { switch(p->type) { case OpType_i: p->index = jit_arg_i(); break; case OpType_ui: p->index = jit_arg_ui(); break; case OpType_l: p->index = jit_arg_l(); break; case OpType_ul: p->index = jit_arg_ul(); break; case OpType_p: p->index = jit_arg_p(); break; case OpType_f: p->index = jit_arg_f(); break; case OpType_d: p->index = jit_arg_d(); break; case OpType_c: p->index = jit_arg_c(); break; case OpType_uc: p->index = jit_arg_uc(); break; case OpType_s: p->index = jit_arg_s(); break; case OpType_us: p->index = jit_arg_us(); break; default: assert(!"Invalid type given for function parameter."); } } Function *Function_create(struct Module *state, OpType type, CORD name, array_t *params) { size_t i = 0; if(Function_find(state, name)) { die(state, "%r is already defined, what you think this is Ruby?.", name); } Function *func = GC_MALLOC(sizeof(Function)); assert(func && "Failed to allocate the function."); func->code = GC_MALLOC(state->max_code_size * sizeof(jit_insn)); func->code_len = state->max_code_size; func->name = name; func->type = type; func->params = params; func->fp = jit_set_ip(func->code); if(state->current_is_leaf) { jit_leaf(func->nparams); } else { jit_prolog(func->nparams); } if(func->params) { for(i = 0; i < array_length(func->params); i++) { Function_synthesize_param(array_at(func->params, i)); } } // now we just record ourselves in the state for further processing hash_alloc_insert(state->functions, func->name, func); state->current = func; return func; } Function *Function_finalize(Module *state, Function *func, Token *end) { jit_ret(); func->code_len = jit_get_ip().ptr - (char *)func->code; jit_flush_code(func->code, jit_get_ip().ptr); state->current = NULL; state->current_is_leaf = 0; return func; } void Label_patch_back_refs(Label *label) { int i = 0; jit_insn *ref = NULL; for(i = 0; i < array_length(label->back_refs); i++) { ref = array_at(label->back_refs, i); assert(ref && "back_ref was NULL and shouldn't be."); jit_patch(ref); array_set(label->back_refs, i, NULL); } } Label *Label_create_and_add(Function *func, Token *tk, int realized) { assert(tk && "Must give a tk."); assert(func && "Must have an active function."); Label *result = GC_MALLOC(sizeof(Label)); result->name = tk->data; result->ref = jit_get_label(); result->realized = realized; hash_alloc_insert(func->labels, result->name, result); return result; } void Label_statement(Function *func, Token *tk) { Label *label = Label_find(func, tk); if(!label) { // forward label statement, create realized label = Label_create_and_add(func, tk, 1); } else { // backward label statement assert(!label->realized && "You've already used this label."); // patch the back references label->realized = 1; Label_patch_back_refs(label); label->ref = jit_get_label(); } } static int Call_param_is(array_t *params, int i, int tk) { assert(array_length(params) <= i && "array bounds error."); Token *param = array_at(params, i); return param->id == tk; } void Label_add_back_ref(Label *label, jit_insn *ref) { array_add(label->back_refs, ref); } void Call_operation(Module *state, Function *func, Token *op, Token *type, array_t *params) { // TODO: adapt this to handle any parameter as a label Label *label = NULL; Token *label_tk = NULL; if(Call_param_is(params, 0, TK_LABEL)) { label = Label_find(func, array_at(params, 0)); assert(label && "Label should be found."); if(!label->realized) { // adjust the value of this parameter to the jit_forward for the call label_tk = array_at(params, 0); label_tk->value = (unsigned long)jit_forward(); } // otherwise value was set by Label_expression } // TODO: expand this assert(jit_get_ip().ptr - (char *)func->code < func->code_len && "You exceeded the space specified for function code blocks."); op->call(state, type, params); if(Call_param_is(params, 0, TK_LABEL) && !label->realized) { // we have to update backrefs here, and not in the label code // since the label is created outside the opcode run Label_add_back_ref(label, jit_get_label()); } }
zedshaw/earing
src/struct.c
<reponame>zedshaw/earing<filename>src/struct.c /* * This program attempts to determine struct layout rules for the compiler * in use. It is only approximate, of course. It looks for: * packed (no gaps) * aligned on 4 bytes * aligned on 8 bytes * aligned on sizeof(largest member) * Suggestions for further improvements are welcome; send to * <EMAIL> * * The IBM AIX compiler xlC will produce multiple packings. Try * xlC -qalign=twobyte structlayout.c * xlC -qalign=packed structlayout.c * xlC -qalign=power structlayout.c */ #include "struct.h" StructAlign StructAlign_create(void) { StructAlign sa = { .is_packed = 1, .is_two = 1, .is_four = 1, .is_eight = 1, .is_largest = 1, .size = 0, .extent = 0 }; struct { char a; int b; } char_int; struct { char a; short b; } char_short; struct { char a; long b; } char_long; struct { char a; float b; } char_float; struct { char a; double b; } char_double; struct { char a; int b; char c; } char_int_char; struct { char a; short b; char c; } char_short_char; struct { char a; long double b; } char_long_double; sa.size = sizeof(char) + sizeof(int); sa.extent = sizeof(char_int); if (sa.size != sa.extent) sa.is_packed = 0; if ( (sa.extent % sizeof(int)) != 0) sa.is_largest = 0; if ( (sa.extent % 2) != 0) sa.is_two = 0; if ( (sa.extent % 4) != 0) sa.is_four = 0; if (sizeof(int) == 8 && (sa.extent % 8) != 0) sa.is_eight = 0; sa.size = sizeof(char) + sizeof(short); sa.extent = sizeof(char_short); if (sa.size != sa.extent) sa.is_packed = 0; if ( (sa.extent % sizeof(short)) != 0) sa.is_largest = 0; if ( (sa.extent % 2) != 0) sa.is_two = 0; if (sizeof(short) == 4 && (sa.extent % 4) != 0) sa.is_four = 0; if (sizeof(short) == 8 && (sa.extent % 8) != 0) sa.is_eight = 0; sa.size = sizeof(char) + sizeof(long); sa.extent = sizeof(char_long); if (sa.size != sa.extent) sa.is_packed = 0; if ( (sa.extent % sizeof(long)) != 0) sa.is_largest = 0; if ( (sa.extent % 2) != 0) sa.is_two = 0; if ( (sa.extent % 4) != 0) sa.is_four = 0; if (sizeof(long) == 8 && (sa.extent % 8) != 0) sa.is_eight = 0; sa.size = sizeof(char) + sizeof(float); sa.extent = sizeof(char_float); if (sa.size != sa.extent) sa.is_packed = 0; if ( (sa.extent % sizeof(float)) != 0) sa.is_largest = 0; if ( (sa.extent % 2) != 0) sa.is_two = 0; if ( (sa.extent % 4) != 0) sa.is_four = 0; if (sizeof(float) == 8 && (sa.extent % 8) != 0) sa.is_eight = 0; sa.size = sizeof(char) + sizeof(double); sa.extent = sizeof(char_double); if (sa.size != sa.extent) sa.is_packed = 0; if ( (sa.extent % sizeof(double)) != 0) sa.is_largest = 0; if ( (sa.extent % 2) != 0) sa.is_two = 0; if ( (sa.extent % 4) != 0) sa.is_four = 0; if (sizeof(double) == 8 && (sa.extent % 8) != 0) sa.is_eight = 0; sa.size = sizeof(char) + sizeof(long double); sa.extent = sizeof(char_long_double); if (sa.size != sa.extent) sa.is_packed = 0; if ( (sa.extent % sizeof(long double)) != 0) sa.is_largest = 0; if ( (sa.extent % 2) != 0) sa.is_two = 0; if ( (sa.extent % 4) != 0) sa.is_four = 0; if (sizeof(long double) >= 8 && (sa.extent % 8) != 0) sa.is_eight = 0; /* char int char helps separate largest from 4/8 aligned */ sa.size = sizeof(char) + sizeof(int) + sizeof(char); sa.extent = sizeof(char_int_char); if (sa.size != sa.extent) sa.is_packed = 0; if ( (sa.extent % sizeof(int)) != 0) sa.is_largest = 0; if ( (sa.extent % 2) != 0) sa.is_two = 0; if ( (sa.extent % 4) != 0) sa.is_four = 0; if (sizeof(int) == 8 && (sa.extent % 8) != 0) sa.is_eight = 0; /* char short char helps separate largest from 4/8 aligned */ sa.size = sizeof(char) + sizeof(short) + sizeof(char); sa.extent = sizeof(char_short_char); if (sa.size != sa.extent) sa.is_packed = 0; if ( (sa.extent % sizeof(short)) != 0) sa.is_largest = 0; if ( (sa.extent % 2) != 0) sa.is_two = 0; if (sizeof(short) == 4 && (sa.extent % 4) != 0) sa.is_four = 0; if (sizeof(short) == 8 && (sa.extent % 8) != 0) sa.is_eight = 0; /* If aligned mod 8, it will be aligned mod 4 */ if (sa.is_eight) { sa.is_four = 0; sa.is_two = 0; } if (sa.is_four) sa.is_two = 0; /* largest superceeds eight */ if (sa.is_largest) sa.is_eight = 0; return sa; } int StructAlign_indeterminate(StructAlign sa) { if (sa.is_packed + sa.is_largest + sa.is_two + sa.is_four + sa.is_eight == 0) { return 1; } else { return 0; } } int StructAlign_multiple_cases(StructAlign sa) { if (sa.is_packed + sa.is_largest + sa.is_two + sa.is_four + sa.is_eight != 1) { return 1; } else { return 0; } }
zedshaw/earing
tests/hash_tests.c
#include "hash.h" #include <stdio.h> #include <ctype.h> #include <stdarg.h> #include <cut/2.6/cut.h> #include <stdlib.h> #include <string.h> typedef char input_t[256]; static int tokenize(char *string, ...) { char **tokptr; va_list arglist; int tokcount = 0; va_start(arglist, string); tokptr = va_arg(arglist, char **); while (tokptr) { while (*string && isspace((unsigned char) *string)) string++; if (!*string) break; *tokptr = string; while (*string && !isspace((unsigned char) *string)) string++; tokptr = va_arg(arglist, char **); tokcount++; if (!*string) break; *string++ = 0; } va_end(arglist); return tokcount; } static char *dupstring(char *str) { int sz = strlen(str) + 1; char *new = malloc(sz); if (new) memcpy(new, str, sz); return new; } static hnode_t *new_node(void *c) { static hnode_t few[5]; static int count; if (count < 5) return few + count++; return NULL; } static void del_node(hnode_t *n, void *c) { } void __CUT__hash_big_test(void) { input_t in; hash_t *h = hash_create(HASHCOUNT_T_MAX, 0, 0); hnode_t *hn; hscan_t hs; char *tok1, *tok2, *val; const char *key; int prompt = 0; fclose(stdin); stdin = fopen("tests/test_data.txt", "r"); ASSERT(stdin != NULL, "Couldn't open hash test data: tests/test_data.txt."); ASSERT(h != NULL, "hash_create failed"); for (;;) { if (prompt) putchar('>'); fflush(stdout); if (!fgets(in, sizeof(input_t), stdin)) break; switch(in[0]) { case 'b': printf("%d\n", hash_val_t_bit); break; case 'a': if (tokenize(in+1, &tok1, &tok2, (char **) 0) != 2) { puts("what?"); break; } key = dupstring(tok1); val = dupstring(tok2); ASSERT(key && val, "out of memory"); ASSERT(hash_alloc_insert(h, key, val), "hash_alloc_insert failed"); break; case 'd': if (tokenize(in+1, &tok1, (char **) 0) != 1) { puts("what?"); break; } hn = hash_lookup(h, tok1); ASSERT(hn != NULL, "hash_lookup failed"); val = hnode_get(hn); key = hnode_getkey(hn); hash_scan_delfree(h, hn); free((void *) key); free(val); break; case 'l': if (tokenize(in+1, &tok1, (char **) 0) != 1) { puts("what?"); break; } hn = hash_lookup(h, tok1); ASSERT(hn != NULL, "hash_lookup failed"); val = hnode_get(hn); puts(val); break; case 'n': printf("%lu\n", (unsigned long) hash_size(h)); break; case 'c': printf("%lu\n", (unsigned long) hash_count(h)); break; case 't': hash_scan_begin(&hs, h); while ((hn = hash_scan_next(&hs))) printf("%s\t%s\n", (char*) hnode_getkey(hn), (char*) hnode_get(hn)); break; case 'q': exit(0); break; case '\0': break; case 'p': prompt = 1; break; case 's': hash_set_allocator(h, new_node, del_node, NULL); break; default: putchar('?'); putchar('\n'); break; } } }
zedshaw/earing
src/array.h
#ifndef array_h #define array_h #include <stdlib.h> typedef struct array_t { size_t size; size_t end; void *data[]; } array_t; array_t *array_create(); void *array_pop(array_t *ary); size_t array_add(array_t *ary, void *el); array_t *array_extend(array_t *ary, size_t by); array_t *array_clamp(array_t *ary); #define array_length(A) ((A)->end) #define array_max(A) ((A)->size) #define array_isfull(A) ((A)->end == (A)->size) #define array_isempty(A) ((A)->end == 0) #define array_at(A,I) ((A)->data[(I)]) #define array_push(A, I) array_add((A), (I)) #define array_last(A) array_at((A), (A)->end-1) #define array_set(A,I,V) array_at(A,I) = (V) #define array_of(T, A, I) ((T *)array_at(A, I)) #endif
zedshaw/earing
src/repl.h
<gh_stars>1-10 #ifndef repl_h #define repl_h typedef char **(*complete_function)(const char *string, int start, int end); void repl_init(complete_function func); char *repl_prompt(); #endif
zedshaw/earing
tests/allocator_tests.c
<gh_stars>1-10 #include <cut/2.6/cut.h> #include "allocator.h" #include <gc.h> void __CUT_allocator_Bringup(void) { GC_INIT(); } void __CUT__Allocator_expression( void ) { Token alloc = {.value = 100L}; Token *res = Allocator_expression(NULL, &alloc); ASSERT(res != NULL, "Failed to run allocator expression."); ASSERT(res->value, "Value wasn't set."); } void __CUT__Allocator_malloc(void) { void *data = Allocator_malloc(100); ASSERT(data != NULL, "Failed to allocate."); } void __CUT__Allocator_realloc(void) { void *data = Allocator_malloc(100); ASSERT(data != NULL, "Failed to allocate."); data = Allocator_realloc(data, 1000); ASSERT(data != NULL, "Failed to reallocate."); } void __CUT__Allocator_free(void) { void *data = Allocator_malloc(100); Allocator_free(data); } void __CUT__Allocator_collect(void) { Allocator_collect(); }
zedshaw/earing
src/tst.h
#ifndef tst_h #define tst_h #include <stdlib.h> typedef struct tst_t { char splitchar; struct tst_t *low; struct tst_t *equal; struct tst_t *high; void *value; } tst_t; typedef struct tst_collect_t { size_t length; void **values; } tst_collect_t; typedef void (*tst_traverse_cb)(void *value, void *data); void *tst_search(tst_t *root, const char *s, int len); tst_t *tst_insert(tst_t *p, const char *s, int len, void *value); void tst_traverse(tst_t *p, tst_traverse_cb cb, void *data); tst_collect_t tst_collect(tst_t *root, const char *s, int len); #endif
zedshaw/earing
src/dis.c
#include <udis86.h> #include "module.h" #include "sglib.h" void dis_code_bytes(Function *func, ud_t *ud_obj) { ud_set_input_buffer(ud_obj, func->code, func->code_len); printf("function %s(", func->name); int count; SGLIB_SORTED_LIST_MAP_ON_ELEMENTS(FunctionParam, func->params, i, next, { printf("%.*s : %s", i->len, i->name, OpType_to_str(i->type)); if(count++ < func->nparams-1) printf(", "); }); printf(") : %s\n", OpType_to_str(func->type)); while(ud_disassemble(ud_obj)) { printf("\t%s\n", ud_insn_asm(ud_obj)); } printf("end\n\n"); } void dis_functions(Module *state) { ud_t ud_obj; ud_init(&ud_obj); ud_set_mode(&ud_obj, 64); ud_set_syntax(&ud_obj, UD_SYN_INTEL); ud_set_vendor(&ud_obj, UD_VENDOR_AMD); tst_traverse(state->functions, (tst_traverse_cb)dis_code_bytes, &ud_obj); }
zedshaw/earing
tests/dict_tests.c
#include "dict.h" #include <stdio.h> #include <ctype.h> #include <stdarg.h> #include <cut/2.6/cut.h> #include <stdlib.h> #include <string.h> typedef char input_t[256]; static int tokenize(char *string, ...) { char **tokptr; va_list arglist; int tokcount = 0; va_start(arglist, string); tokptr = va_arg(arglist, char **); while (tokptr) { while (*string && isspace((unsigned char) *string)) string++; if (!*string) break; *tokptr = string; while (*string && !isspace((unsigned char) *string)) string++; tokptr = va_arg(arglist, char **); tokcount++; if (!*string) break; *string++ = 0; } va_end(arglist); return tokcount; } static int comparef(const void *key1, const void *key2) { return strcmp(key1, key2); } static char *dupstring(char *str) { int sz = strlen(str) + 1; char *new = malloc(sz); if (new) memcpy(new, str, sz); return new; } static dnode_t *new_node(void *c) { static dnode_t few[5]; static int count; if (count < 5) return few + count++; return NULL; } static void del_node(dnode_t *n, void *c) { } static int prompt = 0; static void construct(dict_t *d) { input_t in; int done = 0; dict_load_t dl; dnode_t *dn; char *tok1, *tok2, *val; const char *key; char *help = "p turn prompt on\n" "q finish construction\n" "a <key> <val> add new entry\n"; if (!dict_isempty(d)) puts("warning: dictionary not empty!"); dict_load_begin(&dl, d); while (!done) { if (prompt) putchar('>'); fflush(stdout); if (!fgets(in, sizeof(input_t), stdin)) break; switch (in[0]) { case '?': puts(help); break; case 'p': prompt = 1; break; case 'q': done = 1; break; case 'a': if (tokenize(in+1, &tok1, &tok2, (char **) 0) != 2) { puts("what?"); break; } key = dupstring(tok1); val = dupstring(tok2); dn = dnode_create(val); ASSERT(key && val && dn, "out of memory"); dict_load_next(&dl, dn, key); break; default: putchar('?'); putchar('\n'); break; } } dict_load_end(&dl); } void __CUT__dict_big_test(void) { input_t in; dict_t darray[10]; dict_t *d = &darray[0]; dnode_t *dn; int i; char *tok1, *tok2, *val; const char *key; fclose(stdin); stdin = fopen("tests/test_data.txt", "r"); ASSERT(stdin != NULL, "failed to open dict test data: tests/test_data.txt"); for (i = 0; i < sizeof darray / sizeof *darray; i++) dict_init(&darray[i], DICTCOUNT_T_MAX, comparef); for (;;) { if (prompt) putchar('>'); fflush(stdout); if (!fgets(in, sizeof(input_t), stdin)) break; switch(in[0]) { case 'a': if (tokenize(in+1, &tok1, &tok2, (char **) 0) != 2) { puts("what?"); break; } key = dupstring(tok1); val = dupstring(tok2); ASSERT(key && val, "out of memory"); ASSERT(dict_alloc_insert(d, key, val), "dict_alloc_insert failed"); break; case 'd': if (tokenize(in+1, &tok1, (char **) 0) != 1) { puts("what?"); break; } dn = dict_lookup(d, tok1); ASSERT(dn != NULL, "dict_lookup failed"); val = dnode_get(dn); key = dnode_getkey(dn); dict_delete_free(d, dn); free(val); free((void *) key); break; case 'f': dict_free(d); break; case 'l': case '(': case ')': if (tokenize(in+1, &tok1, (char **) 0) != 1) { puts("what?"); break; } dn = 0; switch (in[0]) { case 'l': dn = dict_lookup(d, tok1); break; case '(': dn = dict_lower_bound(d, tok1); break; case ')': dn = dict_upper_bound(d, tok1); break; } ASSERT(!dn, "lookup failed"); val = dnode_get(dn); puts(val); break; case 'm': construct(d); break; case 'k': dict_allow_dupes(d); break; case 'c': printf("%lu\n", (unsigned long) dict_count(d)); break; case 't': for (dn = dict_first(d); dn; dn = dict_next(d, dn)) { printf("%s\t%s\n", (char *) dnode_getkey(dn), (char *) dnode_get(dn)); } break; case 'q': break; case '\0': break; case 'p': prompt = 1; break; case 's': dict_set_allocator(d, new_node, del_node, NULL); break; case '#': if (tokenize(in+1, &tok1, (char **) 0) != 1) { puts("what?"); break; } else { int dictnum = atoi(tok1); if (dictnum < 0 || dictnum > 9) { puts("invalid number"); break; } d = &darray[dictnum]; } break; case 'j': if (tokenize(in+1, &tok1, &tok2, (char **) 0) != 2) { puts("what?"); break; } else { int dict1 = atoi(tok1), dict2 = atoi(tok2); if (dict1 < 0 || dict1 > 9 || dict2 < 0 || dict2 > 9) { puts("invalid number"); break; } dict_merge(&darray[dict1], &darray[dict2]); } break; default: putchar('?'); putchar('\n'); break; } } }
zedshaw/earing
src/ops.h
#ifndef ops_h #define ops_h #include "module.h" #include "array.h" #include "allocator_ops.h" int inst_addr(Module *state, Token *type, array_t *params); int inst_addi(Module *state, Token *type, array_t *params); int inst_addxr(Module *state, Token *type, array_t *params); int inst_addxi(Module *state, Token *type, array_t *params); int inst_addcr(Module *state, Token *type, array_t *params); int inst_addci(Module *state, Token *type, array_t *params); int inst_subr(Module *state, Token *type, array_t *params); int inst_subi(Module *state, Token *type, array_t *params); int inst_subxr(Module *state, Token *type, array_t *params); int inst_subxi(Module *state, Token *type, array_t *params); int inst_subcr(Module *state, Token *type, array_t *params); int inst_subci(Module *state, Token *type, array_t *params); int inst_rsbr(Module *state, Token *type, array_t *params); int inst_rsbi(Module *state, Token *type, array_t *params); int inst_mulr(Module *state, Token *type, array_t *params); int inst_muli(Module *state, Token *type, array_t *params); int inst_hmulr(Module *state, Token *type, array_t *params); int inst_hmuli(Module *state, Token *type, array_t *params); int inst_divr(Module *state, Token *type, array_t *params); int inst_divi(Module *state, Token *type, array_t *params); int inst_modr(Module *state, Token *type, array_t *params); int inst_modi(Module *state, Token *type, array_t *params); int inst_andr(Module *state, Token *type, array_t *params); int inst_andi(Module *state, Token *type, array_t *params); int inst_orr(Module *state, Token *type, array_t *params); int inst_ori(Module *state, Token *type, array_t *params); int inst_xorr(Module *state, Token *type, array_t *params); int inst_xori(Module *state, Token *type, array_t *params); int inst_lshr(Module *state, Token *type, array_t *params); int inst_lshi(Module *state, Token *type, array_t *params); int inst_rshr(Module *state, Token *type, array_t *params); int inst_rshi(Module *state, Token *type, array_t *params); int inst_negr(Module *state, Token *type, array_t *params); int inst_notr(Module *state, Token *type, array_t *params); int inst_ltr(Module *state, Token *type, array_t *params); int inst_lti(Module *state, Token *type, array_t *params); int inst_ler(Module *state, Token *type, array_t *params); int inst_lei(Module *state, Token *type, array_t *params); int inst_gtr(Module *state, Token *type, array_t *params); int inst_gti(Module *state, Token *type, array_t *params); int inst_ger(Module *state, Token *type, array_t *params); int inst_gei(Module *state, Token *type, array_t *params); int inst_eqr(Module *state, Token *type, array_t *params); int inst_eqi(Module *state, Token *type, array_t *params); int inst_ner(Module *state, Token *type, array_t *params); int inst_nei(Module *state, Token *type, array_t *params); int inst_unltr(Module *state, Token *type, array_t *params); int inst_unler(Module *state, Token *type, array_t *params); int inst_ungtr(Module *state, Token *type, array_t *params); int inst_unger(Module *state, Token *type, array_t *params); int inst_uneqr(Module *state, Token *type, array_t *params); int inst_ltgtr(Module *state, Token *type, array_t *params); int inst_ordr(Module *state, Token *type, array_t *params); int inst_unordr(Module *state, Token *type, array_t *params); int inst_movr(Module *state, Token *type, array_t *params); int inst_movi(Module *state, Token *type, array_t *params); int inst_hton(Module *state, Token *type, array_t *params); int inst_ntoh(Module *state, Token *type, array_t *params); int inst_ldr(Module *state, Token *type, array_t *params); int inst_ldi(Module *state, Token *type, array_t *params); int inst_ldxr(Module *state, Token *type, array_t *params); int inst_ldxi(Module *state, Token *type, array_t *params); int inst_str(Module *state, Token *type, array_t *params); int inst_sti(Module *state, Token *type, array_t *params); int inst_stxr(Module *state, Token *type, array_t *params); int inst_stxi(Module *state, Token *type, array_t *params); int inst_prepare(Module *state, Token *type, array_t *params); int inst_pusharg(Module *state, Token *type, array_t *params); int inst_getarg(Module *state, Token *type, array_t *params); int inst_blti(Module *state, Token *type, array_t *params); int inst_blei(Module *state, Token *type, array_t *params); int inst_bgti(Module *state, Token *type, array_t *params); int inst_bgei(Module *state, Token *type, array_t *params); int inst_beqi(Module *state, Token *type, array_t *params); int inst_bnei(Module *state, Token *type, array_t *params); int inst_bmsr(Module *state, Token *type, array_t *params); int inst_bmsi(Module *state, Token *type, array_t *params); int inst_bmcr(Module *state, Token *type, array_t *params); int inst_bmci(Module *state, Token *type, array_t *params); int inst_calli(Module *state, Token *type, array_t *params); int inst_callr(Module *state, Token *type, array_t *params); int inst_finish(Module *state, Token *type, array_t *params); int inst_finishr(Module *state, Token *type, array_t *params); int inst_jmpi(Module *state, Token *type, array_t *params); int inst_jmpr(Module *state, Token *type, array_t *params); int inst_ret(Module *state, Token *type, array_t *params); int inst_retval(Module *state, Token *type, array_t *params); #endif
zedshaw/earing
src/earing.c
<reponame>zedshaw/earing<gh_stars>1-10 #include <stdio.h> #include <stdlib.h> #include <assert.h> #include <sys/mman.h> #include <sys/types.h> #include <sys/wait.h> #include <sys/stat.h> #include <unistd.h> #include <fcntl.h> #include <sys/time.h> #include "directives.h" #include "module.h" #include "util.h" #include "repl.h" #include <string.h> #include "dis.h" #include <unistd.h> #include "error.h" #include <gc/gc.h> #include <gc/cord.h> Module *current_module = NULL; void query_functions(Function *func, void *ignored) { printf("%.*s: %zu bytes of code, %d params defined\n", func->len, func->name, func->code_len, func->nparams); } void run_repl(Module *state, const char *in_file) { printf("EaRing. Copyright 2008 <NAME>.\n"); printf("Done compiling %s. Enter ? to get the function list.\n", in_file); char *cmd = NULL; current_module = state; repl_init(NULL); while((cmd = repl_prompt())) { if(cmd[0] == '?') { tst_traverse(state->functions, (tst_traverse_cb)query_functions, NULL); } else { run_function(state, cmd); } } } int main(int argc, char *argv[]) { CORD input = NULL; const char *in_file_name = NULL; FILE *in_file = NULL; Module *state = NULL; int opt; int disassemble = 0; const char *func = "main"; int interactive = 0; int listing = 0; while((opt = getopt(argc, argv, "lhdf:i")) != -1) { switch(opt) { case 'd': disassemble = 1; break; case 'f': func = optarg; break; case 'i': interactive = 1; break; case 'l': listing = 1; break; case 'h': /// fall through! default: die(NULL, "USAGE: earing [-d | -i] [-f function] <file.asm>\n"); return 1; } } if(optind >= argc) { die(NULL, "You have to give a file. Use -h to see the usage."); return 1; } GC_INIT(); in_file_name = argv[optind]; in_file = fopen(in_file_name, "r"); if(!in_file) { die(NULL, "Failed to open the input file %s", in_file_name); } input = CORD_from_file(in_file); state = Module_create(in_file_name, 1024); Module_register_default_directives(state); if(!Module_compile(state, CORD_to_const_char_star(input), CORD_len(input))) { die(state, "Parsing failed with %d errors.\n", state->errors); return 1; } else { if(listing) { tst_traverse(state->functions, (tst_traverse_cb)query_functions, NULL); } else if(disassemble) { dis_functions(state); } else if(interactive) { // go into interactive mode with the repl run_repl(state, in_file_name); } else { // run the given function or the "main" default run_function(state, func); } } return 0; }
zedshaw/earing
src/util.h
#ifndef util_h #define util_h char *mmap_file(const char *fname, size_t *length); void run_function(Module *state, const char *named); #endif
zedshaw/earing
src/label.h
#ifndef label_h #define label_h #include "function.h" #include <gc/cord.h> typedef struct Label { jit_insn *ref; CORD name; int realized; array_t *back_refs; } Label; Label *Label_find_or_create(Function *func, Token *ident); Token *Label_expression(Function *func, Token *tk); void Label_statement(Function *func, Token *tk); Label *Label_find(Function *func, Token *tk); Label *Label_create_and_add(Function *func, Token *tk, int realized); #endif
zedshaw/earing
src/grammar.c
/* Driver template for the LEMON parser generator. ** The author disclaims copyright to this source code. */ /* First off, code is include which follows the "include" declaration ** in the input file. */ #include <stdio.h> #line 3 "grammar.y" #include <assert.h> #include <stdio.h> #include <gc/gc.h> #include "allocator.h" #line 16 "grammar.c" /* Next is all token values, in a form suitable for use by makeheaders. ** This section will be null unless lemon is run with the -m switch. */ /* ** These constants (all generated automatically by the parser generator) ** specify the various kinds of tokens (terminals) that the parser ** understands. ** ** Each symbol here is a terminal symbol in the grammar. */ /* Make sure the INTERFACE macro is defined. */ #ifndef INTERFACE # define INTERFACE 1 #endif /* The next thing included is series of defines which control ** various aspects of the generated parser. ** YYCODETYPE is the data type used for storing terminal ** and nonterminal numbers. "unsigned char" is ** used if there are fewer than 250 terminals ** and nonterminals. "int" is used otherwise. ** YYNOCODE is a number of type YYCODETYPE which corresponds ** to no legal terminal or nonterminal number. This ** number is used to fill in empty slots of the hash ** table. ** YYFALLBACK If defined, this indicates that one or more tokens ** have fall-back values which should be used if the ** original value of the token will not parse. ** YYACTIONTYPE is the data type used for storing terminal ** and nonterminal numbers. "unsigned char" is ** used if there are fewer than 250 rules and ** states combined. "int" is used otherwise. ** ParseTOKENTYPE is the data type used for minor tokens given ** directly to the parser from the tokenizer. ** YYMINORTYPE is the data type used for all minor tokens. ** This is typically a union of many types, one of ** which is ParseTOKENTYPE. The entry in the union ** for base tokens is called "yy0". ** YYSTACKDEPTH is the maximum depth of the parser's stack. If ** zero the stack is dynamically sized using realloc() ** ParseARG_SDECL A static variable declaration for the %extra_argument ** ParseARG_PDECL A parameter declaration for the %extra_argument ** ParseARG_STORE Code to store %extra_argument into yypParser ** ParseARG_FETCH Code to extract %extra_argument from yypParser ** YYNSTATE the combined number of states. ** YYNRULE the number of rules in the grammar ** YYERRORSYMBOL is the code number of the error symbol. If not ** defined, then do no error processing. */ #define YYCODETYPE unsigned char #define YYNOCODE 41 #define YYACTIONTYPE unsigned char #define ParseTOKENTYPE Token* typedef union { ParseTOKENTYPE yy0; Function * yy13; Label * yy27; FunctionParam * yy62; Parameters * yy67; Token * yy68; int yy81; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 #endif #define ParseARG_SDECL Module *state ; #define ParseARG_PDECL , Module *state #define ParseARG_FETCH Module *state = yypParser->state #define ParseARG_STORE yypParser->state = state #define YYNSTATE 75 #define YYNRULE 42 #define YYERRORSYMBOL 23 #define YYERRSYMDT yy81 #define YY_NO_ACTION (YYNSTATE+YYNRULE+2) #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1) #define YY_ERROR_ACTION (YYNSTATE+YYNRULE) /* The yyzerominor constant is used to initialize instances of ** YYMINORTYPE objects to zero. */ static const YYMINORTYPE yyzerominor; /* Next are that tables used to determine what action to take based on the ** current state and lookahead token. These tables are used to implement ** functions that take a state number and lookahead value and return an ** action integer. ** ** Suppose the action integer is N. Then the action is determined as ** follows ** ** 0 <= N < YYNSTATE Shift N. That is, push the lookahead ** token onto the stack and goto state N. ** ** YYNSTATE <= N < YYNSTATE+YYNRULE Reduce by rule N-YYNSTATE. ** ** N == YYNSTATE+YYNRULE A syntax error has occurred. ** ** N == YYNSTATE+YYNRULE+1 The parser accepts its input. ** ** N == YYNSTATE+YYNRULE+2 No such action. Denotes unused ** slots in the yy_action[] table. ** ** The action table is constructed as a single large table named yy_action[]. ** Given state S and lookahead X, the action is computed as ** ** yy_action[ yy_shift_ofst[S] + X ] ** ** If the index value yy_shift_ofst[S]+X is out of range or if the value ** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S] ** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table ** and that yy_default[S] should be used instead. ** ** The formula above is for computing the action when the lookahead is ** a terminal symbol. If the lookahead is a non-terminal (as occurs after ** a reduce action) then the yy_reduce_ofst[] array is used in place of ** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of ** YY_SHIFT_USE_DFLT. ** ** The following are the tables generated in this section: ** ** yy_action[] A single table containing all actions. ** yy_lookahead[] A table containing the lookahead for each entry in ** yy_action. Used to detect hash collisions. ** yy_shift_ofst[] For each state, the offset into yy_action for ** shifting terminals. ** yy_reduce_ofst[] For each state, the offset into yy_action for ** shifting non-terminals after a reduce. ** yy_default[] Default action for each state. */ static const YYACTIONTYPE yy_action[] = { /* 0 */ 17, 52, 70, 6, 51, 5, 31, 16, 42, 41, /* 10 */ 74, 71, 69, 68, 60, 14, 20, 3, 47, 21, /* 20 */ 20, 118, 1, 54, 18, 19, 30, 59, 18, 19, /* 30 */ 30, 9, 75, 47, 21, 9, 27, 11, 33, 35, /* 40 */ 53, 20, 4, 27, 53, 48, 28, 27, 43, 18, /* 50 */ 19, 27, 11, 52, 15, 23, 51, 23, 29, 23, /* 60 */ 23, 44, 26, 72, 36, 73, 56, 32, 37, 2, /* 70 */ 66, 4, 25, 39, 40, 57, 45, 61, 24, 22, /* 80 */ 55, 64, 65, 67, 12, 62, 13, 63, 50, 8, /* 90 */ 58, 7, 46, 38, 10, 34, 119, 119, 119, 119, /* 100 */ 119, 49, }; static const YYCODETYPE yy_lookahead[] = { /* 0 */ 2, 34, 5, 6, 37, 38, 39, 28, 10, 11, /* 10 */ 12, 13, 14, 15, 16, 17, 26, 23, 1, 2, /* 20 */ 26, 31, 32, 33, 34, 35, 2, 33, 34, 35, /* 30 */ 2, 7, 0, 1, 2, 7, 19, 20, 5, 6, /* 40 */ 16, 26, 4, 19, 16, 21, 8, 19, 33, 34, /* 50 */ 35, 19, 20, 34, 25, 30, 37, 30, 39, 30, /* 60 */ 30, 36, 2, 36, 2, 36, 36, 2, 22, 27, /* 70 */ 9, 4, 12, 22, 24, 9, 24, 2, 8, 8, /* 80 */ 1, 1, 18, 2, 2, 1, 9, 18, 1, 3, /* 90 */ 1, 3, 24, 2, 4, 22, 40, 40, 40, 40, /* 100 */ 40, 9, }; #define YY_SHIFT_USE_DFLT (-4) #define YY_SHIFT_MAX 39 static const signed char yy_shift_ofst[] = { /* 0 */ 17, 32, 28, 17, -2, 24, -2, -2, -2, 38, /* 10 */ 91, 65, 67, 67, 60, -3, 33, 71, 80, 84, /* 20 */ 79, 86, 81, 70, 75, 69, 64, 82, 77, 87, /* 30 */ 88, 89, 90, 73, 92, 62, 46, 61, 51, 66, }; #define YY_REDUCE_USE_DFLT (-34) #define YY_REDUCE_MAX 13 static const signed char yy_reduce_ofst[] = { /* 0 */ -10, -6, -33, 15, 29, 19, 27, 30, 25, 68, /* 10 */ -21, 42, 50, 52, }; static const YYACTIONTYPE yy_default[] = { /* 0 */ 117, 117, 115, 117, 87, 115, 117, 117, 117, 84, /* 10 */ 108, 117, 84, 84, 117, 117, 117, 96, 117, 117, /* 20 */ 117, 117, 117, 97, 117, 117, 117, 117, 117, 117, /* 30 */ 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, /* 40 */ 103, 91, 90, 116, 82, 88, 89, 81, 104, 105, /* 50 */ 110, 111, 112, 113, 76, 80, 114, 106, 109, 77, /* 60 */ 99, 98, 79, 100, 78, 101, 107, 102, 95, 94, /* 70 */ 83, 93, 85, 86, 92, }; #define YY_SZ_ACTTAB (int)(sizeof(yy_action)/sizeof(yy_action[0])) /* The next table maps tokens into fallback tokens. If a construct ** like the following: ** ** %fallback ID X Y Z. ** ** appears in the grammer, then ID becomes a fallback token for X, Y, ** and Z. Whenever one of the tokens X, Y, or Z is input to the parser ** but it does not parse, the type of the token is changed to ID and ** the parse is retried before an error is thrown. */ #ifdef YYFALLBACK static const YYCODETYPE yyFallback[] = { }; #endif /* YYFALLBACK */ /* The following structure represents a single element of the ** parser's stack. Information stored includes: ** ** + The state number for the parser at this level of the stack. ** ** + The value of the token stored at this level of the stack. ** (In other words, the "major" token.) ** ** + The semantic value stored at this level of the stack. This is ** the information used by the action routines in the grammar. ** It is sometimes called the "minor" token. */ struct yyStackEntry { int stateno; /* The state-number */ int major; /* The major token value. This is the code ** number for the token at this stack level */ YYMINORTYPE minor; /* The user-supplied minor token value. This ** is the value of the token */ }; typedef struct yyStackEntry yyStackEntry; /* The state of the parser is completely contained in an instance of ** the following structure */ struct yyParser { int yyidx; /* Index of top element in stack */ int yyerrcnt; /* Shifts left before out of the error */ ParseARG_SDECL /* A place to hold %extra_argument */ #if YYSTACKDEPTH<=0 int yystksz; /* Current side of the stack */ yyStackEntry *yystack; /* The parser's stack */ #else yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */ #endif }; typedef struct yyParser yyParser; #ifndef NDEBUG #include <stdio.h> static FILE *yyTraceFILE = 0; static char *yyTracePrompt = 0; #endif /* NDEBUG */ #ifndef NDEBUG /* ** Turn parser tracing on by giving a stream to which to write the trace ** and a prompt to preface each trace message. Tracing is turned off ** by making either argument NULL ** ** Inputs: ** <ul> ** <li> A FILE* to which trace output should be written. ** If NULL, then tracing is turned off. ** <li> A prefix string written at the beginning of every ** line of trace output. If NULL, then tracing is ** turned off. ** </ul> ** ** Outputs: ** None. */ void ParseTrace(FILE *TraceFILE, char *zTracePrompt){ yyTraceFILE = TraceFILE; yyTracePrompt = zTracePrompt; if( yyTraceFILE==0 ) yyTracePrompt = 0; else if( yyTracePrompt==0 ) yyTraceFILE = 0; } #endif /* NDEBUG */ /* For tracing shifts, the names of all terminals and nonterminals ** are required. The following table supplies these names */ static const char *const yyTokenName[] = { "$", "EOL", "IDENT", "EQ", "LPAREN", "RPAREN", "COMMA", "OP", "DOT", "TYPE", "HEX", "FLOAT", "INT", "STR", "CHR", "REG", "LABEL", "LBRACK", "RBRACK", "PERCENT", "FUNCTION", "END", "COLON", "error", "parameters", "args", "function", "function_decl", "function_params", "label", "function_reference", "module", "statements", "statement", "directive", "constant", "expr", "operation", "block", "element", }; /* For tracing reduce actions, the names of all rules are required. */ static const char *const yyRuleName[] = { /* 0 */ "module ::= statements", /* 1 */ "statements ::= statement", /* 2 */ "statements ::= statements statement", /* 3 */ "statement ::= directive EOL", /* 4 */ "statement ::= constant EOL", /* 5 */ "statement ::= function EOL", /* 6 */ "statement ::= EOL", /* 7 */ "constant ::= IDENT EQ expr", /* 8 */ "parameters ::= LPAREN args RPAREN", /* 9 */ "parameters ::=", /* 10 */ "args ::= args COMMA expr", /* 11 */ "args ::= expr", /* 12 */ "args ::=", /* 13 */ "operation ::= OP DOT TYPE parameters", /* 14 */ "operation ::= OP parameters", /* 15 */ "expr ::= HEX", /* 16 */ "expr ::= FLOAT", /* 17 */ "expr ::= INT", /* 18 */ "expr ::= STR", /* 19 */ "expr ::= CHR", /* 20 */ "expr ::= REG", /* 21 */ "expr ::= IDENT", /* 22 */ "expr ::= function_reference", /* 23 */ "expr ::= function_reference DOT IDENT", /* 24 */ "expr ::= LABEL", /* 25 */ "expr ::= LBRACK INT RBRACK", /* 26 */ "expr ::= LBRACK IDENT RBRACK", /* 27 */ "function_reference ::= IDENT DOT IDENT", /* 28 */ "directive ::= PERCENT IDENT parameters", /* 29 */ "function ::= FUNCTION function_decl block END", /* 30 */ "function_decl ::= IDENT LPAREN function_params RPAREN COLON TYPE", /* 31 */ "function_params ::= IDENT COLON TYPE", /* 32 */ "function_params ::= function_params COMMA IDENT COLON TYPE", /* 33 */ "function_params ::=", /* 34 */ "block ::= element EOL", /* 35 */ "block ::= block element EOL", /* 36 */ "element ::= operation", /* 37 */ "element ::= directive", /* 38 */ "element ::= LABEL", /* 39 */ "element ::= IDENT EQ expr", /* 40 */ "element ::=", /* 41 */ "statements ::= statements error statement", }; #if YYSTACKDEPTH<=0 /* ** Try to increase the size of the parser stack. */ static void yyGrowStack(yyParser *p){ int newSize; yyStackEntry *pNew; newSize = p->yystksz*2 + 100; pNew = realloc(p->yystack, newSize*sizeof(pNew[0])); if( pNew ){ p->yystack = pNew; p->yystksz = newSize; #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sStack grows to %d entries!\n", yyTracePrompt, p->yystksz); } #endif } } #endif /* ** This function allocates a new parser. ** The only argument is a pointer to a function which works like ** malloc. ** ** Inputs: ** A pointer to the function used to allocate memory. ** ** Outputs: ** A pointer to a parser. This pointer is used in subsequent calls ** to Parse and ParseFree. */ void *ParseAlloc(void *(*mallocProc)(size_t)){ yyParser *pParser; pParser = (yyParser*)(*mallocProc)( (size_t)sizeof(yyParser) ); if( pParser ){ pParser->yyidx = -1; #if YYSTACKDEPTH<=0 yyGrowStack(pParser); #endif } return pParser; } /* The following function deletes the value associated with a ** symbol. The symbol can be either a terminal or nonterminal. ** "yymajor" is the symbol code, and "yypminor" is a pointer to ** the value. */ static void yy_destructor(YYCODETYPE yymajor, YYMINORTYPE *yypminor){ switch( yymajor ){ /* Here is inserted the actions which take place when a ** terminal or non-terminal is destroyed. This can happen ** when the symbol is popped from the stack during a ** reduce or during error processing or when a parser is ** being destroyed before it is finished parsing. ** ** Note: during a reduce, the only symbols destroyed are those ** which appear on the RHS of the rule, but which are not used ** inside the C code. */ case 1: /* EOL */ case 2: /* IDENT */ case 3: /* EQ */ case 4: /* LPAREN */ case 5: /* RPAREN */ case 6: /* COMMA */ case 7: /* OP */ case 8: /* DOT */ case 9: /* TYPE */ case 10: /* HEX */ case 11: /* FLOAT */ case 12: /* INT */ case 13: /* STR */ case 14: /* CHR */ case 15: /* REG */ case 16: /* LABEL */ case 17: /* LBRACK */ case 18: /* RBRACK */ case 19: /* PERCENT */ case 20: /* FUNCTION */ case 21: /* END */ case 22: /* COLON */ { #line 9 "grammar.y" GC_FREE((yypminor->yy0)); #line 433 "grammar.c" } break; default: break; /* If no destructor action specified: do nothing */ } } /* ** Pop the parser's stack once. ** ** If there is a destructor routine associated with the token which ** is popped from the stack, then call it. ** ** Return the major token number for the symbol popped. */ static int yy_pop_parser_stack(yyParser *pParser){ YYCODETYPE yymajor; yyStackEntry *yytos = &pParser->yystack[pParser->yyidx]; if( pParser->yyidx<0 ) return 0; #ifndef NDEBUG if( yyTraceFILE && pParser->yyidx>=0 ){ fprintf(yyTraceFILE,"%sPopping %s\n", yyTracePrompt, yyTokenName[yytos->major]); } #endif yymajor = yytos->major; yy_destructor( yymajor, &yytos->minor); pParser->yyidx--; return yymajor; } /* ** Deallocate and destroy a parser. Destructors are all called for ** all stack elements before shutting the parser down. ** ** Inputs: ** <ul> ** <li> A pointer to the parser. This should be a pointer ** obtained from ParseAlloc. ** <li> A pointer to a function used to reclaim memory obtained ** from malloc. ** </ul> */ void ParseFree( void *p, /* The parser to be deleted */ void (*freeProc)(void*) /* Function used to reclaim memory */ ){ yyParser *pParser = (yyParser*)p; if( pParser==0 ) return; while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser); #if YYSTACKDEPTH<=0 GC_FREE(pParser->yystack); #endif (*freeProc)((void*)pParser); } /* ** Find the appropriate action for a parser given the terminal ** look-ahead token iLookAhead. ** ** If the look-ahead token is YYNOCODE, then check to see if the action is ** independent of the look-ahead. If it is, return the action, otherwise ** return YY_NO_ACTION. */ static int yy_find_shift_action( yyParser *pParser, /* The parser */ YYCODETYPE iLookAhead /* The look-ahead token */ ){ int i; int stateno = pParser->yystack[pParser->yyidx].stateno; if( stateno>YY_SHIFT_MAX || (i = yy_shift_ofst[stateno])==YY_SHIFT_USE_DFLT ){ return yy_default[stateno]; } assert( iLookAhead!=YYNOCODE ); i += iLookAhead; if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){ if( iLookAhead>0 ){ #ifdef YYFALLBACK int iFallback; /* Fallback token */ if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0]) && (iFallback = yyFallback[iLookAhead])!=0 ){ #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n", yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]); } #endif return yy_find_shift_action(pParser, iFallback); } #endif #ifdef YYWILDCARD { int j = i - iLookAhead + YYWILDCARD; if( j>=0 && j<YY_SZ_ACTTAB && yy_lookahead[j]==YYWILDCARD ){ #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]); } #endif /* NDEBUG */ return yy_action[j]; } } #endif /* YYWILDCARD */ } return yy_default[stateno]; }else{ return yy_action[i]; } } /* ** Find the appropriate action for a parser given the non-terminal ** look-ahead token iLookAhead. ** ** If the look-ahead token is YYNOCODE, then check to see if the action is ** independent of the look-ahead. If it is, return the action, otherwise ** return YY_NO_ACTION. */ static int yy_find_reduce_action( int stateno, /* Current state number */ YYCODETYPE iLookAhead /* The look-ahead token */ ){ int i; #ifdef YYERRORSYMBOL if( stateno>YY_REDUCE_MAX ){ return yy_default[stateno]; } #else assert( stateno<=YY_REDUCE_MAX ); #endif i = yy_reduce_ofst[stateno]; assert( i!=YY_REDUCE_USE_DFLT ); assert( iLookAhead!=YYNOCODE ); i += iLookAhead; #ifdef YYERRORSYMBOL if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){ return yy_default[stateno]; } #else assert( i>=0 && i<YY_SZ_ACTTAB ); assert( yy_lookahead[i]==iLookAhead ); #endif return yy_action[i]; } /* ** The following routine is called if the stack overflows. */ static void yyStackOverflow(yyParser *yypParser, YYMINORTYPE *yypMinor){ ParseARG_FETCH; yypParser->yyidx--; #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt); } #endif while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); /* Here code is inserted which will execute if the parser ** stack every overflows */ #line 36 "grammar.y" printf("Stack overflowed, you suck after line: %u.\n", state->curline); #line 600 "grammar.c" ParseARG_STORE; /* Suppress warning about unused %extra_argument var */ } /* ** Perform a shift action. */ static void yy_shift( yyParser *yypParser, /* The parser to be shifted */ int yyNewState, /* The new state to shift in */ int yyMajor, /* The major token to shift in */ YYMINORTYPE *yypMinor /* Pointer ot the minor token to shift in */ ){ yyStackEntry *yytos; yypParser->yyidx++; #if YYSTACKDEPTH>0 if( yypParser->yyidx>=YYSTACKDEPTH ){ yyStackOverflow(yypParser, yypMinor); return; } #else if( yypParser->yyidx>=yypParser->yystksz ){ yyGrowStack(yypParser); if( yypParser->yyidx>=yypParser->yystksz ){ yyStackOverflow(yypParser, yypMinor); return; } } #endif yytos = &yypParser->yystack[yypParser->yyidx]; yytos->stateno = yyNewState; yytos->major = yyMajor; yytos->minor = *yypMinor; #ifndef NDEBUG if( yyTraceFILE && yypParser->yyidx>0 ){ int i; fprintf(yyTraceFILE,"%sShift %d\n",yyTracePrompt,yyNewState); fprintf(yyTraceFILE,"%sStack:",yyTracePrompt); for(i=1; i<=yypParser->yyidx; i++) fprintf(yyTraceFILE," %s",yyTokenName[yypParser->yystack[i].major]); fprintf(yyTraceFILE,"\n"); } #endif } /* The following table contains information about every rule that ** is used during the reduce. */ static const struct { YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ unsigned char nrhs; /* Number of right-hand side symbols in the rule */ } yyRuleInfo[] = { { 31, 1 }, { 32, 1 }, { 32, 2 }, { 33, 2 }, { 33, 2 }, { 33, 2 }, { 33, 1 }, { 35, 3 }, { 24, 3 }, { 24, 0 }, { 25, 3 }, { 25, 1 }, { 25, 0 }, { 37, 4 }, { 37, 2 }, { 36, 1 }, { 36, 1 }, { 36, 1 }, { 36, 1 }, { 36, 1 }, { 36, 1 }, { 36, 1 }, { 36, 1 }, { 36, 3 }, { 36, 1 }, { 36, 3 }, { 36, 3 }, { 30, 3 }, { 34, 3 }, { 26, 4 }, { 27, 6 }, { 28, 3 }, { 28, 5 }, { 28, 0 }, { 38, 2 }, { 38, 3 }, { 39, 1 }, { 39, 1 }, { 39, 1 }, { 39, 3 }, { 39, 0 }, { 32, 3 }, }; static void yy_accept(yyParser*); /* Forward Declaration */ /* ** Perform a reduce action and the shift that must immediately ** follow the reduce. */ static void yy_reduce( yyParser *yypParser, /* The parser */ int yyruleno /* Number of the rule by which to reduce */ ){ int yygoto; /* The next state */ int yyact; /* The next action */ YYMINORTYPE yygotominor; /* The LHS of the rule reduced */ yyStackEntry *yymsp; /* The top of the parser's stack */ int yysize; /* Amount to pop the stack */ ParseARG_FETCH; yymsp = &yypParser->yystack[yypParser->yyidx]; #ifndef NDEBUG if( yyTraceFILE && yyruleno>=0 && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt, yyRuleName[yyruleno]); } #endif /* NDEBUG */ /* Silence complaints from purify about yygotominor being uninitialized ** in some cases when it is copied into the stack after the following ** switch. yygotominor is uninitialized when a rule reduces that does ** not set the value of its left-hand side nonterminal. Leaving the ** value of the nonterminal uninitialized is utterly harmless as long ** as the value is never used. So really the only thing this code ** accomplishes is to quieten purify. ** ** 2007-01-16: The wireshark project (www.wireshark.org) reports that ** without this code, their parser segfaults. I'm not sure what there ** parser is doing to make this happen. This is the second bug report ** from wireshark this week. Clearly they are stressing Lemon in ways ** that it has not been previously stressed... (SQLite ticket #2172) */ /*memset(&yygotominor, 0, sizeof(yygotominor));*/ yygotominor = yyzerominor; switch( yyruleno ){ /* Beginning here are the reduction cases. A typical example ** follows: ** case 0: ** #line <lineno> <grammarfile> ** { ... } // User supplied code ** #line <lineno> <thisfile> ** break; */ case 0: /* module ::= statements */ case 1: /* statements ::= statement */ case 2: /* statements ::= statements statement */ case 36: /* element ::= operation */ case 37: /* element ::= directive */ case 40: /* element ::= */ case 41: /* statements ::= statements error statement */ #line 58 "grammar.y" { } #line 758 "grammar.c" break; case 3: /* statement ::= directive EOL */ case 4: /* statement ::= constant EOL */ case 5: /* statement ::= function EOL */ case 6: /* statement ::= EOL */ case 34: /* block ::= element EOL */ case 35: /* block ::= block element EOL */ #line 63 "grammar.y" { yy_destructor(1,&yymsp[0].minor); } #line 770 "grammar.c" break; case 7: /* constant ::= IDENT EQ expr */ #line 68 "grammar.y" { Module_create_constant(state, yymsp[-2].minor.yy0, yymsp[0].minor.yy0); yy_destructor(3,&yymsp[-1].minor); } #line 778 "grammar.c" break; case 8: /* parameters ::= LPAREN args RPAREN */ #line 72 "grammar.y" { yygotominor.yy67 = yymsp[-1].minor.yy67; yy_destructor(4,&yymsp[-2].minor); yy_destructor(5,&yymsp[0].minor); } #line 785 "grammar.c" break; case 9: /* parameters ::= */ case 12: /* args ::= */ #line 73 "grammar.y" { yygotominor.yy67 = GC_MALLOC(sizeof(Parameters)); } #line 791 "grammar.c" break; case 10: /* args ::= args COMMA expr */ #line 75 "grammar.y" { yymsp[-2].minor.yy67->args[yymsp[-2].minor.yy67->i++] = yymsp[0].minor.yy0; yygotominor.yy67=yymsp[-2].minor.yy67; yy_destructor(6,&yymsp[-1].minor); } #line 797 "grammar.c" break; case 11: /* args ::= expr */ #line 76 "grammar.y" { yygotominor.yy67 = GC_MALLOC(sizeof(Parameters)); yygotominor.yy67->args[yygotominor.yy67->i++] = yymsp[0].minor.yy0;} #line 802 "grammar.c" break; case 13: /* operation ::= OP DOT TYPE parameters */ #line 80 "grammar.y" { Call_operation(state, state->current, yymsp[-3].minor.yy0, yymsp[-1].minor.yy0, yymsp[0].minor.yy67); yy_destructor(8,&yymsp[-2].minor); } #line 808 "grammar.c" break; case 14: /* operation ::= OP parameters */ #line 82 "grammar.y" { Call_operation(state, state->current, yymsp[-1].minor.yy0, NULL, yymsp[0].minor.yy67); } #line 813 "grammar.c" break; case 15: /* expr ::= HEX */ case 16: /* expr ::= FLOAT */ case 17: /* expr ::= INT */ case 18: /* expr ::= STR */ case 19: /* expr ::= CHR */ case 20: /* expr ::= REG */ #line 84 "grammar.y" { yygotominor.yy0 = yymsp[0].minor.yy0; } #line 823 "grammar.c" break; case 21: /* expr ::= IDENT */ #line 90 "grammar.y" { yygotominor.yy0 = Module_resolve_data(state, yymsp[0].minor.yy0); } #line 828 "grammar.c" break; case 22: /* expr ::= function_reference */ #line 91 "grammar.y" { yygotominor.yy0 = yymsp[0].minor.yy68; } #line 833 "grammar.c" break; case 23: /* expr ::= function_reference DOT IDENT */ #line 92 "grammar.y" { yygotominor.yy0 = Module_outside_function_data(state, yymsp[-2].minor.yy68, yymsp[0].minor.yy0); yy_destructor(8,&yymsp[-1].minor); } #line 839 "grammar.c" break; case 24: /* expr ::= LABEL */ #line 93 "grammar.y" { yygotominor.yy0 = Label_expression(state->current, yymsp[0].minor.yy0); } #line 844 "grammar.c" break; case 25: /* expr ::= LBRACK INT RBRACK */ #line 94 "grammar.y" { yygotominor.yy0 = Allocator_expression(state, yymsp[-1].minor.yy0); yy_destructor(17,&yymsp[-2].minor); yy_destructor(18,&yymsp[0].minor); } #line 851 "grammar.c" break; case 26: /* expr ::= LBRACK IDENT RBRACK */ #line 96 "grammar.y" { yygotominor.yy0 = Allocator_expression(state, Module_resolve_data(state, yymsp[-1].minor.yy0)); yy_destructor(17,&yymsp[-2].minor); yy_destructor(18,&yymsp[0].minor); } #line 858 "grammar.c" break; case 27: /* function_reference ::= IDENT DOT IDENT */ #line 99 "grammar.y" { yygotominor.yy68 = Module_resolve_function(state, yymsp[-2].minor.yy0, yymsp[0].minor.yy0); yy_destructor(8,&yymsp[-1].minor); } #line 864 "grammar.c" break; case 28: /* directive ::= PERCENT IDENT parameters */ #line 102 "grammar.y" { Module_call_directive(state, yymsp[-1].minor.yy0, yymsp[0].minor.yy67); yy_destructor(19,&yymsp[-2].minor); } #line 870 "grammar.c" break; case 29: /* function ::= FUNCTION function_decl block END */ #line 105 "grammar.y" { yygotominor.yy13 = Function_finalize(state, yymsp[-2].minor.yy13, yymsp[0].minor.yy0); yy_destructor(20,&yymsp[-3].minor); } #line 876 "grammar.c" break; case 30: /* function_decl ::= IDENT LPAREN function_params RPAREN COLON TYPE */ #line 108 "grammar.y" { yygotominor.yy13 = Function_create(state, yymsp[0].minor.yy0->value, yymsp[-5].minor.yy0->start, yymsp[-5].minor.yy0->len, yymsp[-3].minor.yy62); yy_destructor(4,&yymsp[-4].minor); yy_destructor(5,&yymsp[-2].minor); yy_destructor(22,&yymsp[-1].minor); } #line 884 "grammar.c" break; case 31: /* function_params ::= IDENT COLON TYPE */ #line 111 "grammar.y" { yygotominor.yy62 = FunctionParam_create(NULL, yymsp[-2].minor.yy0, yymsp[0].minor.yy0); yy_destructor(22,&yymsp[-1].minor); } #line 890 "grammar.c" break; case 32: /* function_params ::= function_params COMMA IDENT COLON TYPE */ #line 113 "grammar.y" { yygotominor.yy62 = FunctionParam_create(yymsp[-4].minor.yy62, yymsp[-2].minor.yy0, yymsp[0].minor.yy0); yy_destructor(6,&yymsp[-3].minor); yy_destructor(22,&yymsp[-1].minor); } #line 897 "grammar.c" break; case 33: /* function_params ::= */ #line 114 "grammar.y" { yygotominor.yy62 = NULL; } #line 902 "grammar.c" break; case 38: /* element ::= LABEL */ #line 121 "grammar.y" { Label_statement(state->current, yymsp[0].minor.yy0); } #line 907 "grammar.c" break; case 39: /* element ::= IDENT EQ expr */ #line 122 "grammar.y" { Module_create_function_constant(state, yymsp[-2].minor.yy0, yymsp[0].minor.yy0); yy_destructor(3,&yymsp[-1].minor); } #line 915 "grammar.c" break; }; yygoto = yyRuleInfo[yyruleno].lhs; yysize = yyRuleInfo[yyruleno].nrhs; yypParser->yyidx -= yysize; yyact = yy_find_reduce_action(yymsp[-yysize].stateno,yygoto); if( yyact < YYNSTATE ){ #ifdef NDEBUG /* If we are not debugging and the reduce action popped at least ** one element off the stack, then we can push the new element back ** onto the stack here, and skip the stack overflow test in yy_shift(). ** That gives a significant speed improvement. */ if( yysize ){ yypParser->yyidx++; yymsp -= yysize-1; yymsp->stateno = yyact; yymsp->major = yygoto; yymsp->minor = yygotominor; }else #endif { yy_shift(yypParser,yyact,yygoto,&yygotominor); } }else{ assert( yyact == YYNSTATE + YYNRULE + 1 ); yy_accept(yypParser); } } /* ** The following code executes when the parse fails */ static void yy_parse_failed( yyParser *yypParser /* The parser */ ){ ParseARG_FETCH; #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt); } #endif while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); /* Here code is inserted which will be executed whenever the ** parser fails */ ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ } /* ** The following code executes when a syntax error first occurs. */ static void yy_syntax_error( yyParser *yypParser, /* The parser */ int yymajor, /* The major type of the error token */ YYMINORTYPE yyminor /* The minor type of the error token */ ){ ParseARG_FETCH; #define TOKEN (yyminor.yy0) #line 14 "grammar.y" state->errors++; if(state->current) { printf("%s: In function '%.*s':\n", state->module_name, state->current->len, state->current->name); state->current = NULL; } printf("%s:%d: error at %s token in [", state->module_name, state->curline, yyTokenName[yymajor]); int i; for(i=1; i<=yypParser->yyidx; i++) printf(" %s",yyTokenName[yypParser->yystack[i].major]); printf(" | %s ] unexpected '%.*s'\n", yyTokenName[yymajor], yymajor != 0 ? TOKEN->len : 7, yymajor != 0 ? TOKEN->start : "$ (EOF)"); #line 996 "grammar.c" ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ } /* ** The following is executed when the parser accepts */ static void yy_accept( yyParser *yypParser /* The parser */ ){ ParseARG_FETCH; #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); } #endif while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); /* Here code is inserted which will be executed whenever the ** parser accepts */ #line 11 "grammar.y" #line 1019 "grammar.c" ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ } /* The main parser program. ** The first argument is a pointer to a structure obtained from ** "ParseAlloc" which describes the current state of the parser. ** The second argument is the major token number. The third is ** the minor token. The fourth optional argument is whatever the ** user wants (and specified in the grammar) and is available for ** use by the action routines. ** ** Inputs: ** <ul> ** <li> A pointer to the parser (an opaque structure.) ** <li> The major token number. ** <li> The minor token number. ** <li> An option argument of a grammar-specified type. ** </ul> ** ** Outputs: ** None. */ void Parse( void *yyp, /* The parser */ int yymajor, /* The major token code number */ ParseTOKENTYPE yyminor /* The value for the token */ ParseARG_PDECL /* Optional %extra_argument parameter */ ){ YYMINORTYPE yyminorunion; int yyact; /* The parser action. */ int yyendofinput; /* True if we are at the end of input */ #ifdef YYERRORSYMBOL int yyerrorhit = 0; /* True if yymajor has invoked an error */ #endif yyParser *yypParser; /* The parser */ /* (re)initialize the parser, if necessary */ yypParser = (yyParser*)yyp; if( yypParser->yyidx<0 ){ #if YYSTACKDEPTH<=0 if( yypParser->yystksz <=0 ){ /*memset(&yyminorunion, 0, sizeof(yyminorunion));*/ yyminorunion = yyzerominor; yyStackOverflow(yypParser, &yyminorunion); return; } #endif yypParser->yyidx = 0; yypParser->yyerrcnt = -1; yypParser->yystack[0].stateno = 0; yypParser->yystack[0].major = 0; } yyminorunion.yy0 = yyminor; yyendofinput = (yymajor==0); ParseARG_STORE; #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sInput %s\n",yyTracePrompt,yyTokenName[yymajor]); } #endif do{ yyact = yy_find_shift_action(yypParser,yymajor); if( yyact<YYNSTATE ){ assert( !yyendofinput ); /* Impossible to shift the $ token */ yy_shift(yypParser,yyact,yymajor,&yyminorunion); yypParser->yyerrcnt--; yymajor = YYNOCODE; }else if( yyact < YYNSTATE + YYNRULE ){ yy_reduce(yypParser,yyact-YYNSTATE); }else{ assert( yyact == YY_ERROR_ACTION ); #ifdef YYERRORSYMBOL int yymx; #endif #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt); } #endif #ifdef YYERRORSYMBOL /* A syntax error has occurred. ** The response to an error depends upon whether or not the ** grammar defines an error token "ERROR". ** ** This is what we do if the grammar does define ERROR: ** ** * Call the %syntax_error function. ** ** * Begin popping the stack until we enter a state where ** it is legal to shift the error symbol, then shift ** the error symbol. ** ** * Set the error count to three. ** ** * Begin accepting and shifting new tokens. No new error ** processing will occur until three tokens have been ** shifted successfully. ** */ if( yypParser->yyerrcnt<0 ){ yy_syntax_error(yypParser,yymajor,yyminorunion); } yymx = yypParser->yystack[yypParser->yyidx].major; if( yymx==YYERRORSYMBOL || yyerrorhit ){ #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sDiscard input token %s\n", yyTracePrompt,yyTokenName[yymajor]); } #endif yy_destructor(yymajor,&yyminorunion); yymajor = YYNOCODE; }else{ while( yypParser->yyidx >= 0 && yymx != YYERRORSYMBOL && (yyact = yy_find_reduce_action( yypParser->yystack[yypParser->yyidx].stateno, YYERRORSYMBOL)) >= YYNSTATE ){ yy_pop_parser_stack(yypParser); } if( yypParser->yyidx < 0 || yymajor==0 ){ yy_destructor(yymajor,&yyminorunion); yy_parse_failed(yypParser); yymajor = YYNOCODE; }else if( yymx!=YYERRORSYMBOL ){ YYMINORTYPE u2; u2.YYERRSYMDT = 0; yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2); } } yypParser->yyerrcnt = 3; yyerrorhit = 1; #else /* YYERRORSYMBOL is not defined */ /* This is what we do if the grammar does not define ERROR: ** ** * Report an error message, and throw away the input token. ** ** * If the input token is $, then fail the parse. ** ** As before, subsequent error messages are suppressed until ** three input tokens have been successfully shifted. */ if( yypParser->yyerrcnt<=0 ){ yy_syntax_error(yypParser,yymajor,yyminorunion); } yypParser->yyerrcnt = 3; yy_destructor(yymajor,&yyminorunion); if( yyendofinput ){ yy_parse_failed(yypParser); } yymajor = YYNOCODE; #endif } }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 ); return; }
zedshaw/earing
src/directives.h
#ifndef directives_h #define directives_h #include "module.h" typedef struct Directive { int len; CORD name; Module_directive_cb call; Module_directive_cb destroy; } Directive; void Module_register_default_directives(Module *state); void *Library_search(Module *state, Token *module, Token *name); #endif
zedshaw/earing
src/allocator.h
#ifndef allocator_h #define allocator_h #include "token.h" #include "module.h" Token *Allocator_expression(Module *state, Token *tk); void *Allocator_malloc(int size); void *Allocator_realloc(void *mem, int new_size); void Allocator_free(void *mem); void Allocator_collect(); #endif
zedshaw/earing
src/function.h
#ifndef function_h #define function_h #include <lightning.h> #include <gc/cord.h> #include "types.h" #include "array.h" #include "hash.h" #include "token.h" struct Module; typedef struct FunctionParam { int index; CORD name; OpType type; } FunctionParam; typedef struct Function { jit_insn *code; size_t code_len; jit_code fp; OpType type; CORD name; array_t *params; hash_t *data; hash_t *labels; } Function; Function *Function_create(struct Module *state, OpType type, CORD name, array_t *params); Function *Function_find(struct Module *state, CORD name); Function *Function_finalize(struct Module *state, Function *func, Token *end); Token *Function_resolve_param(struct Module *state, Function *func, Token *ident); void FunctionParam_create(Function *func, Token *ident, Token *type); int FunctionParam_index(Function *func, Token *ident); #endif
zedshaw/earing
tests/util_tests.c
#include <cut/2.6/cut.h> void __CUT__util_test( void ) { ASSERT( 1, "Any non-zero value must always pass an ASSERT." ); }
zedshaw/earing
tests/types_tests.c
<filename>tests/types_tests.c #include "types.h" #include <cut/2.6/cut.h> void __CUT__OpType_to_str_test(void) { const char *name = OpType_to_str(OpType_i); ASSERT(name != NULL, "Bad OpType."); ASSERT(name == "int", "Wrong one for int."); name = Opttype_to_str(OpType_c); ASSERT(name != NULL, "Bad OpType."); ASSERT(name == "char", "Wrong one for char."); }
zedshaw/earing
src/tst.c
#include <stdlib.h> #include "tst.h" #include <stdio.h> #include <assert.h> #include <gc/gc.h> static void tst_collect_build(void *value, tst_collect_t *results) { if(results->length < 100) { results->values[results->length++] = value; } } tst_collect_t tst_collect(tst_t *root, const char *s, int len) { tst_collect_t results = {.length = 0, .values = NULL}; tst_t *p = root; int i = 0; results.values = GC_MALLOC(100 * sizeof(void *)); // first we get to where we match the prefix while(i < len && p) { if (s[i] < p->splitchar) { p = p->low; } else if (s[i] == p->splitchar) { i++; p = p->equal; } else { p = p->high; } } if(p) { // we found node matching this prefix, so traverse and collect tst_traverse(p, (tst_traverse_cb)tst_collect_build, &results); } return results; } void *tst_search(tst_t *root, const char *s, int len) { tst_t *p = root; int i = 0; while(i < len && p) { if (s[i] < p->splitchar) { p = p->low; } else if (s[i] == p->splitchar) { i++; if(i < len) p = p->equal; } else { p = p->high; } } if(p) { return p->value; } else { return NULL; } } tst_t *tst_insert(tst_t *p, const char *s, int len, void *value) { if (p == NULL) { p = (tst_t *) GC_MALLOC(sizeof(tst_t)); p->splitchar = *s; } if (*s < p->splitchar) { p->low = tst_insert(p->low, s, len, value); } else if (*s == p->splitchar) { if (len > 1) { // not done yet, keep going but one less p->equal = tst_insert(p->equal, s+1, len - 1, value); } else { p->value = value; } } else { p->high = tst_insert(p->high, s, len, value); } return p; } void tst_traverse(tst_t *p, tst_traverse_cb cb, void *data) { if (!p) return; if(p->low) tst_traverse(p->low, cb, data); if (p->equal) { tst_traverse(p->equal, cb, data); } if(p->high) tst_traverse(p->high, cb, data); if(p->value) cb(p->value, data); }
zedshaw/earing
tests/module_tests.c
#include <cut/2.6/cut.h> /* A pointless module -- tests nothing useful, will never fail. * This nonetheless shows the basic form of tests. */ void __CUT__module1( void ) { ASSERT( 1, "Any non-zero value must always pass an ASSERT." ); } /* A more complex test, consisting of a bringup, a takedown, * and the test body. */ static int module_broughtup = 0; void __CUT_BRINGUP__moduleBringup( void ) { module_broughtup = 1; } void __CUT__module2( void ) { /* ASSERT explanations are usually phrased as mandatory statements. */ ASSERT( 1 == module_broughtup, "We must be initialized by now." ); } void __CUT_TAKEDOWN__moduleBringup( void ) { /* ASSERTs in takedowns are a very bad idea; takedowns have to be able to * run at any time, including when a test has thrown an exception. */ module_broughtup = 0; } void __CUT__module3( void ) { ASSERT( 0 == module_broughtup, "We must be uninitialized by now." ); }