Skip to content

Todo #1

@nmeylan

Description

@nmeylan

Bases

  • antlr grammar
  • parser
  • VM architecture

Compiler

  • native functions list should be provided via a file
  • label hooks list should be provided via a file
  • bytecode generation
  • function argument count check
  • type checking
  • Compilation error with line number, column number and "highlighted" code snippet

VM

  • execute from bytecode
  • Runtime error with line number, column number and "highlighted" code snippet

basic Features

  • native function calling
  • local variable assignement to constant
  • local variable re assignement to constant
  • local variable assignement to expression
  • local variable load
  • "+" operator
  • "*" operator
  • "-" operator
  • "/" operator
  • "%" operator
  • "<<" operator
  • ">>" operator
  • "!" operator
  • "~" operator
  • "^" operator
  • "&" operator
  • "|" operator
  • "++" operator
  • "--" operator
  • " ? : " ternary operator
  • function definition
  • function calling
  • recursive function calling
  • for loop
  • while loop
  • if/else
  • conditional statement
  • logical and
  • logical or
  • greater than
  • less than
  • label/goto
  • array
  • switch

advanced features

  • load script (initialize static variable pool, initialize global function pool)
  • global function
  • instantiate script
  • instance variable (script/npc variable)
  • static variable (script/npc variable)
  • OnInit
  • OnInstanceInit
  • Track constant usage
  • Clear unused constant
  • command (menu/warp, etc...) evaluated as native function
  • Server/Account/char variables handling (not part of the VM, but VM should provide something)

Native function (rathena "commands") - implemented in the VM

  • clear;
  • end;
  • set <variable>,<expression>{,<char_id>};
  • set(<variable>,<expression>{,<char id>})
  • setd "<variable name>",<value>{,<char_id>};
  • getd("<variable name>")
  • getvariableofnpc(<variable_name>,"<npc name>")
  • getvariableofnpc(getd,"<npc name>") -> wont be implemented
  • getinstancevar(<variable>,<instance id>);
  • setinstancevar(<variable>,<value>,<instance id>);
  • set getvariableofnpc(getd,"<npc name>")
  • getvar <variable>,<char_id>;
  • goto <label>;
  • callfunc "<function>"{,<argument>,...<argument>};
  • callfunc("<function>"{,<argument>,...<argument>})
  • callsub <label>{,<argument>,...<argument>};
  • callsub(<label>{,<argument>,...<argument>})
  • getarg(<index>{,<default_value>})
  • getargcount()
  • return {<value>};
  • function <function name>;
  • <function name>{(<argument>,...<argument>)};
  • function <function name> {
  • is_function("<function name>")
  • if (<condition>) <statement>;
  • jump_zero (<condition>),<label>;
  • switch (expression);
  • while (<condition>) <statement>;
  • for (<variable initialization>; <condition>; <variable update>) <statement>;
  • do { <statement>; } while (<condition>);
  • freeloop({<toggle>})
  • setarray <array name>[<first value>],<value>{,<value>...<value>};
  • cleararray <array name>[<first value to alter>],<value>,<number of values to set>;
  • copyarray <destination array>[<first value>],<source array>[<first value>],<amount of data to copy>;
  • deletearray <array name>[<first value>]{,<how much to delete>};
  • inarray <array name>,<value>;
  • countinarray <array name>{[<start index>]},<array name>{[<start index>]};
  • getarraysize(<array name>)
  • getelementofarray(<array name>,<index>)

Standard library

  • pow(<number>,<power>)
  • sqrt(<number>)
  • min(<number or array>{,<number or array>,...})
  • minimum(<number or array>{,<number or array>,...})
  • max(<number or array>{,<number or array>,...})
  • maximum(<number or array>{,<number or array>,...})
  • round(<number>,<precision>);
  • ceil(<number>,<precision>);
  • floor(<number>,<precision>);
  • md5("<string>")
  • atoi("<string>")
  • axtoi("<string>")
  • strtol("<string>", base)
  • compare("<string>","<substring>")
  • strcmp("<string>","<string>")
  • getstrlen("<string>")
  • charisalpha("<string>",<position>)
  • charat(<string>,<index>)
  • setchar(<string>,<char>,<index>)
  • insertchar(<string>,<char>,<index>)
  • delchar(<string>,<index>)
  • strtoupper(<string>)
  • strtolower(<string>)
  • charisupper(<string>,<index>)
  • charislower(<string>,<index>)
  • substr(<string>,<start_index>,<end_index>)
  • explode(<dest_array>,<string>,<delimiter>)
  • implode(<string_array>{,<glue>})
  • sprintf(<format>[,param[,param[,...]]]) -> to be implemented by server
  • sscanf(<string>,<format>[,param[,param[,...]]])
  • strpos(<haystack>,<needle>{,<offset>})
  • replacestr(<input>, <search>, <replace>{, <usecase>{, <count>}})
  • countstr(<input>, <search>{, <usecase>})

Code optimization

  • replace variable by constant references whenever it is possible

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions