Module: Rubex

Defined in:
lib/rubex/symbol_table/scope.rb,
lib/rubex/cli.rb,
lib/rubex/error.rb,
lib/rubex/helpers.rb,
lib/rubex/version.rb,
lib/rubex/ast/node.rb,
lib/rubex/compiler.rb,
lib/rubex/constants.rb,
lib/rubex/rake_task.rb,
lib/rubex/code_writer.rb,
lib/rubex/parser.racc.rb,
lib/rubex/ast/statement.rb,
lib/rubex/data_type/int.rb,
lib/rubex/ast/expression.rb,
lib/rubex/data_type/char.rb,
lib/rubex/data_type/f_32.rb,
lib/rubex/data_type/f_64.rb,
lib/rubex/data_type/void.rb,
lib/rubex/code_supervisor.rb,
lib/rubex/compiler_config.rb,
lib/rubex/data_type/c_ptr.rb,
lib/rubex/data_type/c_str.rb,
lib/rubex/data_type/int_8.rb,
lib/rubex/data_type/l_int.rb,
lib/rubex/data_type/u_int.rb,
lib/rubex/helpers/writers.rb,
lib/rubex/data_type/int_16.rb,
lib/rubex/data_type/int_32.rb,
lib/rubex/data_type/int_64.rb,
lib/rubex/data_type/u_char.rb,
lib/rubex/ast/statement/for.rb,
lib/rubex/data_type/c_array.rb,
lib/rubex/data_type/l_l_int.rb,
lib/rubex/data_type/u_int_8.rb,
lib/rubex/data_type/u_l_int.rb,
lib/rubex/ast/node/file_node.rb,
lib/rubex/ast/node/main_node.rb,
lib/rubex/data_type/type_def.rb,
lib/rubex/data_type/u_int_16.rb,
lib/rubex/data_type/u_int_32.rb,
lib/rubex/data_type/u_int_64.rb,
lib/rubex/symbol_table/entry.rb,
lib/rubex/symbol_table/scope.rb,
lib/rubex/ast/expression/name.rb,
lib/rubex/ast/expression/self.rb,
lib/rubex/ast/statement/alias.rb,
lib/rubex/ast/statement/break.rb,
lib/rubex/ast/statement/while.rb,
lib/rubex/data_type/u_l_l_int.rb,
lib/rubex/ast/expression/empty.rb,
lib/rubex/ast/expression/unary.rb,
lib/rubex/ast/statement/assign.rb,
lib/rubex/ast/statement/return.rb,
lib/rubex/data_type/c_function.rb,
lib/rubex/ast/expression/binary.rb,
lib/rubex/data_type/ruby_method.rb,
lib/rubex/data_type/ruby_object.rb,
lib/rubex/ast/expression/literal.rb,
lib/rubex/ast/expression/size_of.rb,
lib/rubex/ast/statement/if_block.rb,
lib/rubex/ast/statement/var_decl.rb,
lib/rubex/ast/expression/typecast.rb,
lib/rubex/ast/top_statement/klass.rb,
lib/rubex/data_type/int/c_boolean.rb,
lib/rubex/ast/statement/c_ptr_decl.rb,
lib/rubex/ast/statement/expression.rb,
lib/rubex/data_type/u_l_int/size_t.rb,
lib/rubex/ast/expression/unary_base.rb,
lib/rubex/ast/statement/begin_block.rb,
lib/rubex/ast/statement/c_base_type.rb,
lib/rubex/data_type_helpers/helpers.rb,
lib/rubex/helpers/node_type_methods.rb,
lib/rubex/ast/expression/block_given.rb,
lib/rubex/ast/expression/element_ref.rb,
lib/rubex/ast/expression/literal/int.rb,
lib/rubex/ast/expression/literal/nil.rb,
lib/rubex/ast/expression/method_call.rb,
lib/rubex/ast/expression/typecast_to.rb,
lib/rubex/ast/statement/c_array_decl.rb,
lib/rubex/ast/statement/forward_decl.rb,
lib/rubex/ast/statement/no_gil_block.rb,
lib/rubex/ast/expression/command_call.rb,
lib/rubex/ast/expression/instance_var.rb,
lib/rubex/ast/expression/literal/char.rb,
lib/rubex/ast/expression/literal/true.rb,
lib/rubex/ast/statement/argument_list.rb,
lib/rubex/ast/statement/if_block/else.rb,
lib/rubex/data_type/c_struct_or_union.rb,
lib/rubex/ast/expression/binary/colon2.rb,
lib/rubex/ast/expression/coerce_object.rb,
lib/rubex/ast/expression/literal/false.rb,
lib/rubex/ast/expression/ruby_constant.rb,
lib/rubex/ast/statement/if_block/elsif.rb,
lib/rubex/ast/top_statement/c_bindings.rb,
lib/rubex/ast/top_statement/method_def.rb,
lib/rubex/ast/expression/literal/c_null.rb,
lib/rubex/ast/expression/literal/double.rb,
lib/rubex/ast/expression/to_ruby_object.rb,
lib/rubex/ast/statement/c_function_decl.rb,
lib/rubex/ast/statement/if_block/helper.rb,
lib/rubex/data_type/ruby_object/boolean.rb,
lib/rubex/data_type_helpers/int_helpers.rb,
lib/rubex/ast/expression/actual_arg_list.rb,
lib/rubex/ast/expression/arg_declaration.rb,
lib/rubex/ast/statement/begin_block/else.rb,
lib/rubex/data_type/ruby_object/nil_type.rb,
lib/rubex/ast/expression/from_ruby_object.rb,
lib/rubex/ast/expression/literal/hash_lit.rb,
lib/rubex/ast/statement/begin_block/begin.rb,
lib/rubex/data_type/ruby_object/ruby_hash.rb,
lib/rubex/data_type_helpers/float_helpers.rb,
lib/rubex/data_type_helpers/u_int_helpers.rb,
lib/rubex/ast/expression/literal/array_lit.rb,
lib/rubex/ast/statement/begin_block/ensure.rb,
lib/rubex/ast/statement/begin_block/rescue.rb,
lib/rubex/data_type/ruby_object/ruby_array.rb,
lib/rubex/ast/expression/binary/binary_expo.rb,
lib/rubex/ast/expression/command_call/print.rb,
lib/rubex/ast/expression/command_call/raise.rb,
lib/rubex/ast/expression/command_call/yield.rb,
lib/rubex/ast/expression/literal/string_lit.rb,
lib/rubex/data_type/ruby_object/ruby_string.rb,
lib/rubex/data_type/ruby_object/ruby_symbol.rb,
lib/rubex/ast/expression/literal/ruby_symbol.rb,
lib/rubex/ast/expression/analysed_element_ref.rb,
lib/rubex/ast/expression/binary/empty_classes.rb,
lib/rubex/ast/expression/command_call/require.rb,
lib/rubex/ast/expression/unary_base/ampersand.rb,
lib/rubex/ast/expression/unary_base/unary_not.rb,
lib/rubex/ast/expression/unary_base/unary_sub.rb,
lib/rubex/ast/statement/c_struct_or_union_def.rb,
lib/rubex/data_type/ruby_object/ruby_constant.rb,
lib/rubex/ast/expression/binary/binary_boolean.rb,
lib/rubex/ast/top_statement/klass/attached_klass.rb,
lib/rubex/ast/expression/func_ptr_arg_declaration.rb,
lib/rubex/ast/expression/unary_base/unary_bit_not.rb,
lib/rubex/data_type/ruby_object/boolean/true_type.rb,
lib/rubex/ast/statement/c_ptr_decl/c_ptr_func_decl.rb,
lib/rubex/data_type/ruby_object/boolean/false_type.rb,
lib/rubex/ast/expression/method_call/c_function_call.rb,
lib/rubex/ast/expression/method_call/ruby_method_call.rb,
lib/rubex/ast/top_statement/method_def/c_function_def.rb,
lib/rubex/ast/top_statement/method_def/ruby_method_def.rb,
lib/rubex/data_type/ruby_object/ruby_constant/ruby_class.rb,
lib/rubex/ast/expression/binary/binary_boolean_special_op.rb,
lib/rubex/ast/expression/func_ptr_internal_arg_declaration.rb,
lib/rubex/ast/expression/analysed_element_ref/c_var_element_ref.rb,
lib/rubex/ast/expression/command_call/struct_or_union_member_call.rb,
lib/rubex/ast/expression/analysed_element_ref/ruby_object_element_ref.rb,
lib/rubex/ast/expression/ruby_object_element_ref/ruby_hash_element_ref.rb,
lib/rubex/ast/expression/ruby_object_element_ref/ruby_array_element_ref.rb,
lib/rubex/ast/expression/struct_or_union_member_call/element_ref_member_call.rb

Overview

Function argument is a function pointer.

Defined Under Namespace

Modules: AST, DataType, Helpers, SymbolTable Classes: ArrayLengthMismatchError, Cli, CodeSupervisor, CodeWriter, CompileCheckError, Compiler, CompilerConfig, FileNotFoundError, Lexer, LibraryNotFoundError, NoMethodError, Parser, RakeTask, SymbolNotFoundError, SyntaxError, TypeError, TypeMismatchError

Constant Summary collapse

VERSION =
"0.1.2".freeze
RUBEX_PREFIX =
"__rubex_"
GLOBAL_PREFIX =
"global_"
TEMP_PREFIX =
RUBEX_PREFIX + "temp_"
RUBY_FUNC_PREFIX =
RUBEX_PREFIX + "rb_f_"
C_FUNC_PREFIX =
RUBEX_PREFIX + "c_f_"
VAR_PREFIX =
RUBEX_PREFIX + "v_"
RUBY_CLASS_PREFIX =
RUBEX_PREFIX + "rb_cls_"
ATTACH_CLASS_PREFIX =
RUBEX_PREFIX + "attach_rb_cls"
ARG_PREFIX =
RUBEX_PREFIX + "arg_"
ARRAY_PREFIX =
RUBEX_PREFIX + "arr_"
POINTER_PREFIX =
RUBEX_PREFIX + "ptr_"
TYPE_PREFIX =
RUBEX_PREFIX + "t_"
ACTUAL_ARGS_SUFFIX =
"_actual_args"
COMMON_UTILS_CONST =
RUBEX_PREFIX + "_COMMON_UTILS_H"
COMMON_UTILS_FILE =
RUBEX_PREFIX + "_common_utils_"
TYPE_MAPPINGS =
{
  'char'                   => Rubex::DataType::Char,
  'bool'                   => Rubex::DataType::CBoolean,
  'unsigned char'          => Rubex::DataType::UChar,
  'i8'                     => Rubex::DataType::Int8,
  'i16'                    => Rubex::DataType::Int16,
  'i32'                    => Rubex::DataType::Int32,
  'i64'                    => Rubex::DataType::Int64,
  'u8'                     => Rubex::DataType::UInt8,
  'u16'                    => Rubex::DataType::UInt16,
  'u32'                    => Rubex::DataType::UInt32,
  'u64'                    => Rubex::DataType::UInt64,
  'int'                    => Rubex::DataType::Int,
  'unsigned int'           => Rubex::DataType::UInt,
  'long int'               => Rubex::DataType::LInt,
  'long'                   => Rubex::DataType::LInt,
  'unsigned long int'      => Rubex::DataType::ULInt,
  'long long int'          => Rubex::DataType::LLInt,
  'long long'              => Rubex::DataType::LLInt,
  'unsigned long long int' => Rubex::DataType::ULLInt,
  'f32'                    => Rubex::DataType::F32,
  'float'                  => Rubex::DataType::F32,
  'f64'                    => Rubex::DataType::F64,
  'double'                 => Rubex::DataType::F64,
  'object'                 => Rubex::DataType::RubyObject,
  'void'                   => Rubex::DataType::Void,
  'size_t'                 => Rubex::DataType::Size_t,
  'str'                    => Rubex::DataType::RubyString,
  'arr'                    => Rubex::DataType::RubyArray,
  'hsh'                    => Rubex::DataType::RubyHash
}
CUSTOM_TYPES =
{}
DEFAULT_CLASS_MAPPINGS =
{
  "Kernel"           => "rb_mKernel",
  "Comparable"       => "rb_mComparable",
  "Enumerable"       => "rb_mEnumerable",
  "Errno"            => "rb_mErrno",
  "FileTest"         => "rb_mFileTest",
  "GC"               => "rb_mGC",
  "Math"             => "rb_mMath",
  "Process"          => "rb_mProcess",
  "WaitReadable"     => "rb_mWaitReadable",
  "WaitWritable"     => "rb_mWaitWritable",
  "BasicObject"      => "rb_cBasicObject",
  "Object"           => "rb_cObject",
  "Array"            => "rb_cArray",
  "Bignum"           => "rb_cBignum",
  "Binding"          => "rb_cBinding",
  "Class"            => "rb_cClass",
  "Cont"             => "rb_cCont",
  "Dir"              => "rb_cDir",
  "Data"             => "rb_cData",
  "FalseClass"       => "rb_cFalseClass",
  "Encoding"         => "rb_cEncoding",
  "Enumerator"       => "rb_cEnumerator",
  "File"             => "rb_cFile",
  "Fixnum"           => "rb_cFixnum",
  "Float"            => "rb_cFloat",
  "Hash"             => "rb_cHash",
  "Integer"          => "rb_cInteger",
  "IO"               => "rb_cIO",
  "Match"            => "rb_cMatch",
  "Method"           => "rb_cMethod",
  "Module"           => "rb_cModule",
  "NameErrorMesg"    => "rb_cNameErrorMesg",
  "NilClass"         => "rb_cNilClass",
  "Numeric"          => "rb_cNumeric",
  "Proc"             => "rb_cProc",
  "Random"           => "rb_cRandom",
  "Range"            => "rb_cRange",
  "Rational"         => "rb_cRational",
  "Complex"          => "rb_cComplex",
  "Regexp"           => "rb_cRegexp",
  "Stat"             => "rb_cStat",
  "String"           => "rb_cString",
  "Struct"           => "rb_cStruct",
  "Symbol"           => "rb_cSymbol",
  "Thread"           => "rb_cThread",
  "Time"             => "rb_cTime",
  "TrueClass"        => "rb_cTrueClass",
  "UnboundMethod"    => "rb_cUnboundMethod",
  "Exception"        => "rb_eException",
  "StandardError"    => "rb_eStandardError",
  "SystemExit"       => "rb_eSystemExit",
  "Interrupt"        => "rb_eInterrupt",
  "Signal"           => "rb_eSignal",
  "Fatal"            => "rb_eFatal",
  "ArgumentError"    => "rb_eArgError",
  "EOFError"         => "rb_eEOFError",
  "IndexError"       => "rb_eIndexError",
  "StopIteration"    => "rb_eStopIteration",
  "KeyError"         => "rb_eKeyError",
  "RangeError"       => "rb_eRangeError",
  "IOError"          => "rb_eIOError",
  "RuntimeError"     => "rb_eRuntimeError",
  "SecurityError"    => "rb_eSecurityError",
  "SystemCallError"  => "rb_eSystemCallError",
  "ThreadError"      => "rb_eThreadError",
  "TypeError"        => "rb_eTypeError",
  "ZeroDivError"     => "rb_eZeroDivError",
  "NotImpError"      => "rb_eNotImpError",
  "NoMemError"       => "rb_eNoMemError",
  "NoMethodError"    => "rb_eNoMethodError",
  "FloatDomainError" => "rb_eFloatDomainError",
  "LocalJumpError"   => "rb_eLocalJumpError",
  "SysStackError"    => "rb_eSysStackError",
  "RegexpError"      => "rb_eRegexpError",
  "EncodingError"    => "rb_eEncodingError",
  "EncCompatError"   => "rb_eEncCompatError",
  "ScriptError"      => "rb_eScriptError",
  "NameError"        => "rb_eNameError",
  "SyntaxError"      => "rb_eSyntaxError",
  "LoadError"        => "rb_eLoadError",
  "MathDomainError"  => "rb_eMathDomainError",
  "STDIN"            => "rb_stdin",
  "STDOUT"           => "rb_stdout",
  "STDERR"           => "rb_stderr",
}
C_MACRO_INT2BOOL =
Rubex::RUBEX_PREFIX + "INT2BOOL"
C_FUNC_CHAR2RUBYSTR =
Rubex::RUBEX_PREFIX + "char2rubystr"
ALLOC_FUNC_NAME =
'allocate'
DEALLOC_FUNC_NAME =
'deallocate'
MEMCOUNT_FUNC_NAME =
'memcount'
GET_STRUCT_FUNC_NAME =
'get_struct'
LITERAL_MAPPINGS =

Maps regexes to the type of the variable for conversion from literal to the correct type of Ruby object.

{
  /'.\'/       => Rubex::DataType::Char,
  /-?\d+/      => Rubex::DataType::Int,
  /-?\d+\.\d+/ => Rubex::DataType::F64
}