repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
boriel/zxbasic
prepro/definestable.py
DefinesTable.set
def set(self, id_, lineno, value='', fname=None, args=None): """ Like the above, but issues no warning on duplicate macro definitions. """ if fname is None: if CURRENT_FILE: fname = CURRENT_FILE[-1] else: # If no files opened yet, use owns pro...
python
def set(self, id_, lineno, value='', fname=None, args=None): """ Like the above, but issues no warning on duplicate macro definitions. """ if fname is None: if CURRENT_FILE: fname = CURRENT_FILE[-1] else: # If no files opened yet, use owns pro...
[ "def", "set", "(", "self", ",", "id_", ",", "lineno", ",", "value", "=", "''", ",", "fname", "=", "None", ",", "args", "=", "None", ")", ":", "if", "fname", "is", "None", ":", "if", "CURRENT_FILE", ":", "fname", "=", "CURRENT_FILE", "[", "-", "1"...
Like the above, but issues no warning on duplicate macro definitions.
[ "Like", "the", "above", "but", "issues", "no", "warning", "on", "duplicate", "macro", "definitions", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/prepro/definestable.py#L47-L56
boriel/zxbasic
arch/zx48k/backend/__common.py
_int_ops
def _int_ops(op1, op2, swap=True): """ Receives a list with two strings (operands). If none of them contains integers, returns None. Otherwise, returns a t-uple with (op[0], op[1]), where op[1] is the integer one (the list is swapped) unless swap is False (e.g. sub and div used this because they...
python
def _int_ops(op1, op2, swap=True): """ Receives a list with two strings (operands). If none of them contains integers, returns None. Otherwise, returns a t-uple with (op[0], op[1]), where op[1] is the integer one (the list is swapped) unless swap is False (e.g. sub and div used this because they...
[ "def", "_int_ops", "(", "op1", ",", "op2", ",", "swap", "=", "True", ")", ":", "if", "is_int", "(", "op1", ")", ":", "if", "swap", ":", "return", "op2", ",", "int", "(", "op1", ")", "else", ":", "return", "int", "(", "op1", ")", ",", "op2", "...
Receives a list with two strings (operands). If none of them contains integers, returns None. Otherwise, returns a t-uple with (op[0], op[1]), where op[1] is the integer one (the list is swapped) unless swap is False (e.g. sub and div used this because they're not commutative). The integer oper...
[ "Receives", "a", "list", "with", "two", "strings", "(", "operands", ")", ".", "If", "none", "of", "them", "contains", "integers", "returns", "None", ".", "Otherwise", "returns", "a", "t", "-", "uple", "with", "(", "op", "[", "0", "]", "op", "[", "1",...
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__common.py#L124-L143
boriel/zxbasic
arch/zx48k/backend/__common.py
_f_ops
def _f_ops(op1, op2, swap=True): """ Receives a list with two strings (operands). If none of them contains integers, returns None. Otherwise, returns a t-uple with (op[0], op[1]), where op[1] is the integer one (the list is swapped) unless swap is False (e.g. sub and div used this because they'r...
python
def _f_ops(op1, op2, swap=True): """ Receives a list with two strings (operands). If none of them contains integers, returns None. Otherwise, returns a t-uple with (op[0], op[1]), where op[1] is the integer one (the list is swapped) unless swap is False (e.g. sub and div used this because they'r...
[ "def", "_f_ops", "(", "op1", ",", "op2", ",", "swap", "=", "True", ")", ":", "if", "is_float", "(", "op1", ")", ":", "if", "swap", ":", "return", "op2", ",", "float", "(", "op1", ")", "else", ":", "return", "float", "(", "op1", ")", ",", "op2",...
Receives a list with two strings (operands). If none of them contains integers, returns None. Otherwise, returns a t-uple with (op[0], op[1]), where op[1] is the integer one (the list is swapped) unless swap is False (e.g. sub and div used this because they're not commutative). The integer oper...
[ "Receives", "a", "list", "with", "two", "strings", "(", "operands", ")", ".", "If", "none", "of", "them", "contains", "integers", "returns", "None", ".", "Otherwise", "returns", "a", "t", "-", "uple", "with", "(", "op", "[", "0", "]", "op", "[", "1",...
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__common.py#L146-L165
boriel/zxbasic
symbols/call.py
SymbolCALL.make_node
def make_node(cls, id_, params, lineno): """ This will return an AST node for a function/procedure call. """ assert isinstance(params, SymbolARGLIST) entry = gl.SYMBOL_TABLE.access_func(id_, lineno) if entry is None: # A syntax / semantic error return None i...
python
def make_node(cls, id_, params, lineno): """ This will return an AST node for a function/procedure call. """ assert isinstance(params, SymbolARGLIST) entry = gl.SYMBOL_TABLE.access_func(id_, lineno) if entry is None: # A syntax / semantic error return None i...
[ "def", "make_node", "(", "cls", ",", "id_", ",", "params", ",", "lineno", ")", ":", "assert", "isinstance", "(", "params", ",", "SymbolARGLIST", ")", "entry", "=", "gl", ".", "SYMBOL_TABLE", ".", "access_func", "(", "id_", ",", "lineno", ")", "if", "en...
This will return an AST node for a function/procedure call.
[ "This", "will", "return", "an", "AST", "node", "for", "a", "function", "/", "procedure", "call", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/symbols/call.py#L75-L99
boriel/zxbasic
symbols/paramlist.py
SymbolPARAMLIST.make_node
def make_node(clss, node, *params): ''' This will return a node with a param_list (declared in a function declaration) Parameters: -node: A SymbolPARAMLIST instance or None -params: SymbolPARAMDECL insances ''' if node is None: node = clss() ...
python
def make_node(clss, node, *params): ''' This will return a node with a param_list (declared in a function declaration) Parameters: -node: A SymbolPARAMLIST instance or None -params: SymbolPARAMDECL insances ''' if node is None: node = clss() ...
[ "def", "make_node", "(", "clss", ",", "node", ",", "*", "params", ")", ":", "if", "node", "is", "None", ":", "node", "=", "clss", "(", ")", "if", "node", ".", "token", "!=", "'PARAMLIST'", ":", "return", "clss", ".", "make_node", "(", "None", ",", ...
This will return a node with a param_list (declared in a function declaration) Parameters: -node: A SymbolPARAMLIST instance or None -params: SymbolPARAMDECL insances
[ "This", "will", "return", "a", "node", "with", "a", "param_list", "(", "declared", "in", "a", "function", "declaration", ")", "Parameters", ":", "-", "node", ":", "A", "SymbolPARAMLIST", "instance", "or", "None", "-", "params", ":", "SymbolPARAMDECL", "insan...
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/symbols/paramlist.py#L32-L49
boriel/zxbasic
symbols/paramlist.py
SymbolPARAMLIST.appendChild
def appendChild(self, param): ''' Overrides base class. ''' Symbol.appendChild(self, param) if param.offset is None: param.offset = self.size self.size += param.size
python
def appendChild(self, param): ''' Overrides base class. ''' Symbol.appendChild(self, param) if param.offset is None: param.offset = self.size self.size += param.size
[ "def", "appendChild", "(", "self", ",", "param", ")", ":", "Symbol", ".", "appendChild", "(", "self", ",", "param", ")", "if", "param", ".", "offset", "is", "None", ":", "param", ".", "offset", "=", "self", ".", "size", "self", ".", "size", "+=", "...
Overrides base class.
[ "Overrides", "base", "class", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/symbols/paramlist.py#L51-L57
boriel/zxbasic
symbols/binary.py
SymbolBINARY.make_node
def make_node(cls, operator, left, right, lineno, func=None, type_=None): """ Creates a binary node for a binary operation, e.g. A + 6 => '+' (A, 6) in prefix notation. Parameters: -operator: the binary operation token. e.g. 'PLUS' for A + 6 -le...
python
def make_node(cls, operator, left, right, lineno, func=None, type_=None): """ Creates a binary node for a binary operation, e.g. A + 6 => '+' (A, 6) in prefix notation. Parameters: -operator: the binary operation token. e.g. 'PLUS' for A + 6 -le...
[ "def", "make_node", "(", "cls", ",", "operator", ",", "left", ",", "right", ",", "lineno", ",", "func", "=", "None", ",", "type_", "=", "None", ")", ":", "if", "left", "is", "None", "or", "right", "is", "None", ":", "return", "None", "a", ",", "b...
Creates a binary node for a binary operation, e.g. A + 6 => '+' (A, 6) in prefix notation. Parameters: -operator: the binary operation token. e.g. 'PLUS' for A + 6 -left: left operand -right: right operand -func: is a lambda function used when con...
[ "Creates", "a", "binary", "node", "for", "a", "binary", "operation", "e", ".", "g", ".", "A", "+", "6", "=", ">", "+", "(", "A", "6", ")", "in", "prefix", "notation", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/symbols/binary.py#L68-L135
boriel/zxbasic
symbols/type_.py
SymbolTYPE.is_dynamic
def is_dynamic(self): """ True if this type uses dynamic (Heap) memory. e.g. strings or dynamic arrays """ if self is not self.final: return self.final.is_dynamic return any([x.is_dynamic for x in self.children])
python
def is_dynamic(self): """ True if this type uses dynamic (Heap) memory. e.g. strings or dynamic arrays """ if self is not self.final: return self.final.is_dynamic return any([x.is_dynamic for x in self.children])
[ "def", "is_dynamic", "(", "self", ")", ":", "if", "self", "is", "not", "self", ".", "final", ":", "return", "self", ".", "final", ".", "is_dynamic", "return", "any", "(", "[", "x", ".", "is_dynamic", "for", "x", "in", "self", ".", "children", "]", ...
True if this type uses dynamic (Heap) memory. e.g. strings or dynamic arrays
[ "True", "if", "this", "type", "uses", "dynamic", "(", "Heap", ")", "memory", ".", "e", ".", "g", ".", "strings", "or", "dynamic", "arrays" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/symbols/type_.py#L65-L72
boriel/zxbasic
symbols/type_.py
Type.to_signed
def to_signed(cls, t): """ Return signed type or equivalent """ assert isinstance(t, SymbolTYPE) t = t.final assert t.is_basic if cls.is_unsigned(t): return {cls.ubyte: cls.byte_, cls.uinteger: cls.integer, cls.ulong: cl...
python
def to_signed(cls, t): """ Return signed type or equivalent """ assert isinstance(t, SymbolTYPE) t = t.final assert t.is_basic if cls.is_unsigned(t): return {cls.ubyte: cls.byte_, cls.uinteger: cls.integer, cls.ulong: cl...
[ "def", "to_signed", "(", "cls", ",", "t", ")", ":", "assert", "isinstance", "(", "t", ",", "SymbolTYPE", ")", "t", "=", "t", ".", "final", "assert", "t", ".", "is_basic", "if", "cls", ".", "is_unsigned", "(", "t", ")", ":", "return", "{", "cls", ...
Return signed type or equivalent
[ "Return", "signed", "type", "or", "equivalent" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/symbols/type_.py#L325-L337
boriel/zxbasic
api/symboltable.py
SymbolTable.get_entry
def get_entry(self, id_, scope=None): """ Returns the ID entry stored in self.table, starting by the first one. Returns None if not found. If scope is not None, only the given scope is searched. """ if id_[-1] in DEPRECATED_SUFFIXES: id_ = id_[:-1] # Remove it ...
python
def get_entry(self, id_, scope=None): """ Returns the ID entry stored in self.table, starting by the first one. Returns None if not found. If scope is not None, only the given scope is searched. """ if id_[-1] in DEPRECATED_SUFFIXES: id_ = id_[:-1] # Remove it ...
[ "def", "get_entry", "(", "self", ",", "id_", ",", "scope", "=", "None", ")", ":", "if", "id_", "[", "-", "1", "]", "in", "DEPRECATED_SUFFIXES", ":", "id_", "=", "id_", "[", ":", "-", "1", "]", "# Remove it", "if", "scope", "is", "not", "None", ":...
Returns the ID entry stored in self.table, starting by the first one. Returns None if not found. If scope is not None, only the given scope is searched.
[ "Returns", "the", "ID", "entry", "stored", "in", "self", ".", "table", "starting", "by", "the", "first", "one", ".", "Returns", "None", "if", "not", "found", ".", "If", "scope", "is", "not", "None", "only", "the", "given", "scope", "is", "searched", "....
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/symboltable.py#L147-L163
boriel/zxbasic
api/symboltable.py
SymbolTable.declare
def declare(self, id_, lineno, entry): """ Check there is no 'id' already declared in the current scope, and creates and returns it. Otherwise, returns None, and the caller function raises the syntax/semantic error. Parameter entry is the SymbolVAR, SymbolVARARRAY, etc. insta...
python
def declare(self, id_, lineno, entry): """ Check there is no 'id' already declared in the current scope, and creates and returns it. Otherwise, returns None, and the caller function raises the syntax/semantic error. Parameter entry is the SymbolVAR, SymbolVARARRAY, etc. insta...
[ "def", "declare", "(", "self", ",", "id_", ",", "lineno", ",", "entry", ")", ":", "id2", "=", "id_", "type_", "=", "entry", ".", "type_", "if", "id2", "[", "-", "1", "]", "in", "DEPRECATED_SUFFIXES", ":", "id2", "=", "id2", "[", ":", "-", "1", ...
Check there is no 'id' already declared in the current scope, and creates and returns it. Otherwise, returns None, and the caller function raises the syntax/semantic error. Parameter entry is the SymbolVAR, SymbolVARARRAY, etc. instance The entry 'declared' field is leave...
[ "Check", "there", "is", "no", "id", "already", "declared", "in", "the", "current", "scope", "and", "creates", "and", "returns", "it", ".", "Otherwise", "returns", "None", "and", "the", "caller", "function", "raises", "the", "syntax", "/", "semantic", "error"...
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/symboltable.py#L165-L202
boriel/zxbasic
api/symboltable.py
SymbolTable.check_is_declared
def check_is_declared(self, id_, lineno, classname='identifier', scope=None, show_error=True): """ Checks if the given id is already defined in any scope or raises a Syntax Error. Note: classname is not the class attribute, but the name of the class...
python
def check_is_declared(self, id_, lineno, classname='identifier', scope=None, show_error=True): """ Checks if the given id is already defined in any scope or raises a Syntax Error. Note: classname is not the class attribute, but the name of the class...
[ "def", "check_is_declared", "(", "self", ",", "id_", ",", "lineno", ",", "classname", "=", "'identifier'", ",", "scope", "=", "None", ",", "show_error", "=", "True", ")", ":", "result", "=", "self", ".", "get_entry", "(", "id_", ",", "scope", ")", "if"...
Checks if the given id is already defined in any scope or raises a Syntax Error. Note: classname is not the class attribute, but the name of the class as it would appear on compiler messages.
[ "Checks", "if", "the", "given", "id", "is", "already", "defined", "in", "any", "scope", "or", "raises", "a", "Syntax", "Error", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/symboltable.py#L207-L223
boriel/zxbasic
api/symboltable.py
SymbolTable.check_is_undeclared
def check_is_undeclared(self, id_, lineno, classname='identifier', scope=None, show_error=False): """ The reverse of the above. Check the given identifier is not already declared. Returns True if OK, False otherwise. """ result = self.get_entry(id_, s...
python
def check_is_undeclared(self, id_, lineno, classname='identifier', scope=None, show_error=False): """ The reverse of the above. Check the given identifier is not already declared. Returns True if OK, False otherwise. """ result = self.get_entry(id_, s...
[ "def", "check_is_undeclared", "(", "self", ",", "id_", ",", "lineno", ",", "classname", "=", "'identifier'", ",", "scope", "=", "None", ",", "show_error", "=", "False", ")", ":", "result", "=", "self", ".", "get_entry", "(", "id_", ",", "scope", ")", "...
The reverse of the above. Check the given identifier is not already declared. Returns True if OK, False otherwise.
[ "The", "reverse", "of", "the", "above", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/symboltable.py#L225-L244
boriel/zxbasic
api/symboltable.py
SymbolTable.check_class
def check_class(self, id_, class_, lineno, scope=None, show_error=True): """ Check the id is either undefined or defined with the given class. - If the identifier (e.g. variable) does not exists means it's undeclared, and returns True (OK). - If the identifier exists, but its cl...
python
def check_class(self, id_, class_, lineno, scope=None, show_error=True): """ Check the id is either undefined or defined with the given class. - If the identifier (e.g. variable) does not exists means it's undeclared, and returns True (OK). - If the identifier exists, but its cl...
[ "def", "check_class", "(", "self", ",", "id_", ",", "class_", ",", "lineno", ",", "scope", "=", "None", ",", "show_error", "=", "True", ")", ":", "assert", "CLASS", ".", "is_valid", "(", "class_", ")", "entry", "=", "self", ".", "get_entry", "(", "id...
Check the id is either undefined or defined with the given class. - If the identifier (e.g. variable) does not exists means it's undeclared, and returns True (OK). - If the identifier exists, but its class_ attribute is unknown yet (None), returns also True. This means the ...
[ "Check", "the", "id", "is", "either", "undefined", "or", "defined", "with", "the", "given", "class", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/symboltable.py#L246-L277
boriel/zxbasic
api/symboltable.py
SymbolTable.enter_scope
def enter_scope(self, funcname): """ Starts a new variable scope. Notice the *IMPORTANT* marked lines. This is how a new scope is added, by pushing a new dict at the end (and popped out later). """ old_mangle = self.mangle self.mangle = '%s%s%s' % (self.mangle, global_.M...
python
def enter_scope(self, funcname): """ Starts a new variable scope. Notice the *IMPORTANT* marked lines. This is how a new scope is added, by pushing a new dict at the end (and popped out later). """ old_mangle = self.mangle self.mangle = '%s%s%s' % (self.mangle, global_.M...
[ "def", "enter_scope", "(", "self", ",", "funcname", ")", ":", "old_mangle", "=", "self", ".", "mangle", "self", ".", "mangle", "=", "'%s%s%s'", "%", "(", "self", ".", "mangle", ",", "global_", ".", "MANGLE_CHR", ",", "funcname", ")", "self", ".", "tabl...
Starts a new variable scope. Notice the *IMPORTANT* marked lines. This is how a new scope is added, by pushing a new dict at the end (and popped out later).
[ "Starts", "a", "new", "variable", "scope", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/symboltable.py#L282-L292
boriel/zxbasic
api/symboltable.py
SymbolTable.leave_scope
def leave_scope(self): """ Ends a function body and pops current scope out of the symbol table. """ def entry_size(entry): """ For local variables and params, returns the real variable or local array size in bytes """ if entry.scope == SCOPE.global...
python
def leave_scope(self): """ Ends a function body and pops current scope out of the symbol table. """ def entry_size(entry): """ For local variables and params, returns the real variable or local array size in bytes """ if entry.scope == SCOPE.global...
[ "def", "leave_scope", "(", "self", ")", ":", "def", "entry_size", "(", "entry", ")", ":", "\"\"\" For local variables and params, returns the real variable or\n local array size in bytes\n \"\"\"", "if", "entry", ".", "scope", "==", "SCOPE", ".", "global...
Ends a function body and pops current scope out of the symbol table.
[ "Ends", "a", "function", "body", "and", "pops", "current", "scope", "out", "of", "the", "symbol", "table", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/symboltable.py#L294-L345
boriel/zxbasic
api/symboltable.py
SymbolTable.move_to_global_scope
def move_to_global_scope(self, id_): """ If the given id is in the current scope, and there is more than 1 scope, move the current id to the global scope and make it global. Labels need this. """ # In the current scope and more than 1 scope? if id_ in self.table[self.curr...
python
def move_to_global_scope(self, id_): """ If the given id is in the current scope, and there is more than 1 scope, move the current id to the global scope and make it global. Labels need this. """ # In the current scope and more than 1 scope? if id_ in self.table[self.curr...
[ "def", "move_to_global_scope", "(", "self", ",", "id_", ")", ":", "# In the current scope and more than 1 scope?", "if", "id_", "in", "self", ".", "table", "[", "self", ".", "current_scope", "]", ".", "keys", "(", "filter_by_opt", "=", "False", ")", "and", "le...
If the given id is in the current scope, and there is more than 1 scope, move the current id to the global scope and make it global. Labels need this.
[ "If", "the", "given", "id", "is", "in", "the", "current", "scope", "and", "there", "is", "more", "than", "1", "scope", "move", "the", "current", "id", "to", "the", "global", "scope", "and", "make", "it", "global", ".", "Labels", "need", "this", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/symboltable.py#L347-L362
boriel/zxbasic
api/symboltable.py
SymbolTable.make_static
def make_static(self, id_): """ The given ID in the current scope is changed to 'global', but the variable remains in the current scope, if it's a 'global private' variable: A variable private to a function scope, but whose contents are not in the stack, not in the global variable area. ...
python
def make_static(self, id_): """ The given ID in the current scope is changed to 'global', but the variable remains in the current scope, if it's a 'global private' variable: A variable private to a function scope, but whose contents are not in the stack, not in the global variable area. ...
[ "def", "make_static", "(", "self", ",", "id_", ")", ":", "entry", "=", "self", ".", "table", "[", "self", ".", "current_scope", "]", "[", "id_", "]", "entry", ".", "scope", "=", "SCOPE", ".", "global_", "self", ".", "table", "[", "self", ".", "glob...
The given ID in the current scope is changed to 'global', but the variable remains in the current scope, if it's a 'global private' variable: A variable private to a function scope, but whose contents are not in the stack, not in the global variable area. These are called 'static variabl...
[ "The", "given", "ID", "in", "the", "current", "scope", "is", "changed", "to", "global", "but", "the", "variable", "remains", "in", "the", "current", "scope", "if", "it", "s", "a", "global", "private", "variable", ":", "A", "variable", "private", "to", "a...
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/symboltable.py#L364-L376
boriel/zxbasic
api/symboltable.py
SymbolTable.access_id
def access_id(self, id_, lineno, scope=None, default_type=None, default_class=CLASS.unknown): """ Access a symbol by its identifier and checks if it exists. If not, it's supposed to be an implicit declared variable. default_class is the class to use in case of an undeclared-implicit-accessed id...
python
def access_id(self, id_, lineno, scope=None, default_type=None, default_class=CLASS.unknown): """ Access a symbol by its identifier and checks if it exists. If not, it's supposed to be an implicit declared variable. default_class is the class to use in case of an undeclared-implicit-accessed id...
[ "def", "access_id", "(", "self", ",", "id_", ",", "lineno", ",", "scope", "=", "None", ",", "default_type", "=", "None", ",", "default_class", "=", "CLASS", ".", "unknown", ")", ":", "if", "isinstance", "(", "default_type", ",", "symbols", ".", "BASICTYP...
Access a symbol by its identifier and checks if it exists. If not, it's supposed to be an implicit declared variable. default_class is the class to use in case of an undeclared-implicit-accessed id
[ "Access", "a", "symbol", "by", "its", "identifier", "and", "checks", "if", "it", "exists", ".", "If", "not", "it", "s", "supposed", "to", "be", "an", "implicit", "declared", "variable", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/symboltable.py#L390-L420
boriel/zxbasic
api/symboltable.py
SymbolTable.access_var
def access_var(self, id_, lineno, scope=None, default_type=None): """ Since ZX BASIC allows access to undeclared variables, we must allow them, and *implicitly* declare them if they are not declared already. This function just checks if the id_ exists and returns its entry so. Ot...
python
def access_var(self, id_, lineno, scope=None, default_type=None): """ Since ZX BASIC allows access to undeclared variables, we must allow them, and *implicitly* declare them if they are not declared already. This function just checks if the id_ exists and returns its entry so. Ot...
[ "def", "access_var", "(", "self", ",", "id_", ",", "lineno", ",", "scope", "=", "None", ",", "default_type", "=", "None", ")", ":", "result", "=", "self", ".", "access_id", "(", "id_", ",", "lineno", ",", "scope", ",", "default_type", ")", "if", "res...
Since ZX BASIC allows access to undeclared variables, we must allow them, and *implicitly* declare them if they are not declared already. This function just checks if the id_ exists and returns its entry so. Otherwise, creates an implicit declared variable entry and returns it. If the -...
[ "Since", "ZX", "BASIC", "allows", "access", "to", "undeclared", "variables", "we", "must", "allow", "them", "and", "*", "implicitly", "*", "declare", "them", "if", "they", "are", "not", "declared", "already", ".", "This", "function", "just", "checks", "if", ...
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/symboltable.py#L422-L444
boriel/zxbasic
api/symboltable.py
SymbolTable.access_array
def access_array(self, id_, lineno, scope=None, default_type=None): """ Called whenever an accessed variable is expected to be an array. ZX BASIC requires arrays to be declared before usage, so they're checked. Also checks for class array. """ if not self.check_i...
python
def access_array(self, id_, lineno, scope=None, default_type=None): """ Called whenever an accessed variable is expected to be an array. ZX BASIC requires arrays to be declared before usage, so they're checked. Also checks for class array. """ if not self.check_i...
[ "def", "access_array", "(", "self", ",", "id_", ",", "lineno", ",", "scope", "=", "None", ",", "default_type", "=", "None", ")", ":", "if", "not", "self", ".", "check_is_declared", "(", "id_", ",", "lineno", ",", "'array'", ",", "scope", ")", ":", "r...
Called whenever an accessed variable is expected to be an array. ZX BASIC requires arrays to be declared before usage, so they're checked. Also checks for class array.
[ "Called", "whenever", "an", "accessed", "variable", "is", "expected", "to", "be", "an", "array", ".", "ZX", "BASIC", "requires", "arrays", "to", "be", "declared", "before", "usage", "so", "they", "re", "checked", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/symboltable.py#L446-L460
boriel/zxbasic
api/symboltable.py
SymbolTable.access_func
def access_func(self, id_, lineno, scope=None, default_type=None): """ Since ZX BASIC allows access to undeclared functions, we must allow and *implicitly* declare them if they are not declared already. This function just checks if the id_ exists and returns its entry if so. Othe...
python
def access_func(self, id_, lineno, scope=None, default_type=None): """ Since ZX BASIC allows access to undeclared functions, we must allow and *implicitly* declare them if they are not declared already. This function just checks if the id_ exists and returns its entry if so. Othe...
[ "def", "access_func", "(", "self", ",", "id_", ",", "lineno", ",", "scope", "=", "None", ",", "default_type", "=", "None", ")", ":", "assert", "default_type", "is", "None", "or", "isinstance", "(", "default_type", ",", "symbols", ".", "TYPEREF", ")", "re...
Since ZX BASIC allows access to undeclared functions, we must allow and *implicitly* declare them if they are not declared already. This function just checks if the id_ exists and returns its entry if so. Otherwise, creates an implicit declared variable entry and returns it.
[ "Since", "ZX", "BASIC", "allows", "access", "to", "undeclared", "functions", "we", "must", "allow", "and", "*", "implicitly", "*", "declare", "them", "if", "they", "are", "not", "declared", "already", ".", "This", "function", "just", "checks", "if", "the", ...
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/symboltable.py#L462-L484
boriel/zxbasic
api/symboltable.py
SymbolTable.access_call
def access_call(self, id_, lineno, scope=None, type_=None): """ Creates a func/array/string call. Checks if id is callable or not. An identifier is "callable" if it can be followed by a list of para- meters. This does not mean the id_ is a function, but that it allows the same sy...
python
def access_call(self, id_, lineno, scope=None, type_=None): """ Creates a func/array/string call. Checks if id is callable or not. An identifier is "callable" if it can be followed by a list of para- meters. This does not mean the id_ is a function, but that it allows the same sy...
[ "def", "access_call", "(", "self", ",", "id_", ",", "lineno", ",", "scope", "=", "None", ",", "type_", "=", "None", ")", ":", "entry", "=", "self", ".", "access_id", "(", "id_", ",", "lineno", ",", "scope", ",", "default_type", "=", "type_", ")", "...
Creates a func/array/string call. Checks if id is callable or not. An identifier is "callable" if it can be followed by a list of para- meters. This does not mean the id_ is a function, but that it allows the same syntax a function does: For example: - MyFunction(a, "...
[ "Creates", "a", "func", "/", "array", "/", "string", "call", ".", "Checks", "if", "id", "is", "callable", "or", "not", ".", "An", "identifier", "is", "callable", "if", "it", "can", "be", "followed", "by", "a", "list", "of", "para", "-", "meters", "."...
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/symboltable.py#L486-L517
boriel/zxbasic
api/symboltable.py
SymbolTable.declare_variable
def declare_variable(self, id_, lineno, type_, default_value=None): """ Like the above, but checks that entry.declared is False. Otherwise raises an error. Parameter default_value specifies an initialized variable, if set. """ assert isinstance(type_, symbols.TYPEREF) if...
python
def declare_variable(self, id_, lineno, type_, default_value=None): """ Like the above, but checks that entry.declared is False. Otherwise raises an error. Parameter default_value specifies an initialized variable, if set. """ assert isinstance(type_, symbols.TYPEREF) if...
[ "def", "declare_variable", "(", "self", ",", "id_", ",", "lineno", ",", "type_", ",", "default_value", "=", "None", ")", ":", "assert", "isinstance", "(", "type_", ",", "symbols", ".", "TYPEREF", ")", "if", "not", "self", ".", "check_is_undeclared", "(", ...
Like the above, but checks that entry.declared is False. Otherwise raises an error. Parameter default_value specifies an initialized variable, if set.
[ "Like", "the", "above", "but", "checks", "that", "entry", ".", "declared", "is", "False", ".", "Otherwise", "raises", "an", "error", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/symboltable.py#L534-L594
boriel/zxbasic
api/symboltable.py
SymbolTable.declare_type
def declare_type(self, type_): """ Declares a type. Checks its name is not already used in the current scope, and that it's not a basic type. Returns the given type_ Symbol, or None on error. """ assert isinstance(type_, symbols.TYPE) # Checks it's not a basic ty...
python
def declare_type(self, type_): """ Declares a type. Checks its name is not already used in the current scope, and that it's not a basic type. Returns the given type_ Symbol, or None on error. """ assert isinstance(type_, symbols.TYPE) # Checks it's not a basic ty...
[ "def", "declare_type", "(", "self", ",", "type_", ")", ":", "assert", "isinstance", "(", "type_", ",", "symbols", ".", "TYPE", ")", "# Checks it's not a basic type", "if", "not", "type_", ".", "is_basic", "and", "type_", ".", "name", ".", "lower", "(", ")"...
Declares a type. Checks its name is not already used in the current scope, and that it's not a basic type. Returns the given type_ Symbol, or None on error.
[ "Declares", "a", "type", ".", "Checks", "its", "name", "is", "not", "already", "used", "in", "the", "current", "scope", "and", "that", "it", "s", "not", "a", "basic", "type", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/symboltable.py#L596-L614
boriel/zxbasic
api/symboltable.py
SymbolTable.declare_const
def declare_const(self, id_, lineno, type_, default_value): """ Similar to the above. But declares a Constant. """ if not self.check_is_undeclared(id_, lineno, scope=self.current_scope, show_error=False): entry = self.get_entry(id_) if entry.scope == SCOPE.parameter: ...
python
def declare_const(self, id_, lineno, type_, default_value): """ Similar to the above. But declares a Constant. """ if not self.check_is_undeclared(id_, lineno, scope=self.current_scope, show_error=False): entry = self.get_entry(id_) if entry.scope == SCOPE.parameter: ...
[ "def", "declare_const", "(", "self", ",", "id_", ",", "lineno", ",", "type_", ",", "default_value", ")", ":", "if", "not", "self", ".", "check_is_undeclared", "(", "id_", ",", "lineno", ",", "scope", "=", "self", ".", "current_scope", ",", "show_error", ...
Similar to the above. But declares a Constant.
[ "Similar", "to", "the", "above", ".", "But", "declares", "a", "Constant", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/symboltable.py#L616-L635
boriel/zxbasic
api/symboltable.py
SymbolTable.declare_label
def declare_label(self, id_, lineno): """ Declares a label (line numbers are also labels). Unlike variables, labels are always global. """ # TODO: consider to make labels private id1 = id_ id_ = str(id_) if not self.check_is_undeclared(id_, lineno, 'label'): ...
python
def declare_label(self, id_, lineno): """ Declares a label (line numbers are also labels). Unlike variables, labels are always global. """ # TODO: consider to make labels private id1 = id_ id_ = str(id_) if not self.check_is_undeclared(id_, lineno, 'label'): ...
[ "def", "declare_label", "(", "self", ",", "id_", ",", "lineno", ")", ":", "# TODO: consider to make labels private", "id1", "=", "id_", "id_", "=", "str", "(", "id_", ")", "if", "not", "self", ".", "check_is_undeclared", "(", "id_", ",", "lineno", ",", "'l...
Declares a label (line numbers are also labels). Unlike variables, labels are always global.
[ "Declares", "a", "label", "(", "line", "numbers", "are", "also", "labels", ")", ".", "Unlike", "variables", "labels", "are", "always", "global", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/symboltable.py#L637-L686
boriel/zxbasic
api/symboltable.py
SymbolTable.declare_param
def declare_param(self, id_, lineno, type_=None): """ Declares a parameter Check if entry.declared is False. Otherwise raises an error. """ if not self.check_is_undeclared(id_, lineno, classname='parameter', scope=self.current_scope, show_error=Tru...
python
def declare_param(self, id_, lineno, type_=None): """ Declares a parameter Check if entry.declared is False. Otherwise raises an error. """ if not self.check_is_undeclared(id_, lineno, classname='parameter', scope=self.current_scope, show_error=Tru...
[ "def", "declare_param", "(", "self", ",", "id_", ",", "lineno", ",", "type_", "=", "None", ")", ":", "if", "not", "self", ".", "check_is_undeclared", "(", "id_", ",", "lineno", ",", "classname", "=", "'parameter'", ",", "scope", "=", "self", ".", "curr...
Declares a parameter Check if entry.declared is False. Otherwise raises an error.
[ "Declares", "a", "parameter", "Check", "if", "entry", ".", "declared", "is", "False", ".", "Otherwise", "raises", "an", "error", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/symboltable.py#L688-L702
boriel/zxbasic
api/symboltable.py
SymbolTable.declare_array
def declare_array(self, id_, lineno, type_, bounds, default_value=None): """ Declares an array in the symbol table (VARARRAY). Error if already exists. """ assert isinstance(type_, symbols.TYPEREF) assert isinstance(bounds, symbols.BOUNDLIST) if not self.check_class(id_,...
python
def declare_array(self, id_, lineno, type_, bounds, default_value=None): """ Declares an array in the symbol table (VARARRAY). Error if already exists. """ assert isinstance(type_, symbols.TYPEREF) assert isinstance(bounds, symbols.BOUNDLIST) if not self.check_class(id_,...
[ "def", "declare_array", "(", "self", ",", "id_", ",", "lineno", ",", "type_", ",", "bounds", ",", "default_value", "=", "None", ")", ":", "assert", "isinstance", "(", "type_", ",", "symbols", ".", "TYPEREF", ")", "assert", "isinstance", "(", "bounds", ",...
Declares an array in the symbol table (VARARRAY). Error if already exists.
[ "Declares", "an", "array", "in", "the", "symbol", "table", "(", "VARARRAY", ")", ".", "Error", "if", "already", "exists", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/symboltable.py#L704-L760
boriel/zxbasic
api/symboltable.py
SymbolTable.declare_func
def declare_func(self, id_, lineno, type_=None): """ Declares a function in the current scope. Checks whether the id exist or not (error if exists). And creates the entry at the symbol table. """ if not self.check_class(id_, 'function', lineno): entry = self.get_entry...
python
def declare_func(self, id_, lineno, type_=None): """ Declares a function in the current scope. Checks whether the id exist or not (error if exists). And creates the entry at the symbol table. """ if not self.check_class(id_, 'function', lineno): entry = self.get_entry...
[ "def", "declare_func", "(", "self", ",", "id_", ",", "lineno", ",", "type_", "=", "None", ")", ":", "if", "not", "self", ".", "check_class", "(", "id_", ",", "'function'", ",", "lineno", ")", ":", "entry", "=", "self", ".", "get_entry", "(", "id_", ...
Declares a function in the current scope. Checks whether the id exist or not (error if exists). And creates the entry at the symbol table.
[ "Declares", "a", "function", "in", "the", "current", "scope", ".", "Checks", "whether", "the", "id", "exist", "or", "not", "(", "error", "if", "exists", ")", ".", "And", "creates", "the", "entry", "at", "the", "symbol", "table", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/symboltable.py#L762-L804
boriel/zxbasic
api/symboltable.py
SymbolTable.check_labels
def check_labels(self): """ Checks if all the labels has been declared """ for entry in self.labels: self.check_is_declared(entry.name, entry.lineno, CLASS.label)
python
def check_labels(self): """ Checks if all the labels has been declared """ for entry in self.labels: self.check_is_declared(entry.name, entry.lineno, CLASS.label)
[ "def", "check_labels", "(", "self", ")", ":", "for", "entry", "in", "self", ".", "labels", ":", "self", ".", "check_is_declared", "(", "entry", ".", "name", ",", "entry", ".", "lineno", ",", "CLASS", ".", "label", ")" ]
Checks if all the labels has been declared
[ "Checks", "if", "all", "the", "labels", "has", "been", "declared" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/symboltable.py#L806-L810
boriel/zxbasic
api/symboltable.py
SymbolTable.check_classes
def check_classes(self, scope=-1): """ Check if pending identifiers are defined or not. If not, returns a syntax error. If no scope is given, the current one is checked. """ for entry in self[scope].values(): if entry.class_ is None: syntax_error(entry...
python
def check_classes(self, scope=-1): """ Check if pending identifiers are defined or not. If not, returns a syntax error. If no scope is given, the current one is checked. """ for entry in self[scope].values(): if entry.class_ is None: syntax_error(entry...
[ "def", "check_classes", "(", "self", ",", "scope", "=", "-", "1", ")", ":", "for", "entry", "in", "self", "[", "scope", "]", ".", "values", "(", ")", ":", "if", "entry", ".", "class_", "is", "None", ":", "syntax_error", "(", "entry", ".", "lineno",...
Check if pending identifiers are defined or not. If not, returns a syntax error. If no scope is given, the current one is checked.
[ "Check", "if", "pending", "identifiers", "are", "defined", "or", "not", ".", "If", "not", "returns", "a", "syntax", "error", ".", "If", "no", "scope", "is", "given", "the", "current", "one", "is", "checked", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/symboltable.py#L812-L819
boriel/zxbasic
api/symboltable.py
SymbolTable.vars_
def vars_(self): """ Returns symbol instances corresponding to variables of the current scope. """ return [x for x in self[self.current_scope].values() if x.class_ == CLASS.var]
python
def vars_(self): """ Returns symbol instances corresponding to variables of the current scope. """ return [x for x in self[self.current_scope].values() if x.class_ == CLASS.var]
[ "def", "vars_", "(", "self", ")", ":", "return", "[", "x", "for", "x", "in", "self", "[", "self", ".", "current_scope", "]", ".", "values", "(", ")", "if", "x", ".", "class_", "==", "CLASS", ".", "var", "]" ]
Returns symbol instances corresponding to variables of the current scope.
[ "Returns", "symbol", "instances", "corresponding", "to", "variables", "of", "the", "current", "scope", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/symboltable.py#L825-L829
boriel/zxbasic
api/symboltable.py
SymbolTable.labels
def labels(self): """ Returns symbol instances corresponding to labels in the current scope. """ return [x for x in self[self.current_scope].values() if x.class_ == CLASS.label]
python
def labels(self): """ Returns symbol instances corresponding to labels in the current scope. """ return [x for x in self[self.current_scope].values() if x.class_ == CLASS.label]
[ "def", "labels", "(", "self", ")", ":", "return", "[", "x", "for", "x", "in", "self", "[", "self", ".", "current_scope", "]", ".", "values", "(", ")", "if", "x", ".", "class_", "==", "CLASS", ".", "label", "]" ]
Returns symbol instances corresponding to labels in the current scope.
[ "Returns", "symbol", "instances", "corresponding", "to", "labels", "in", "the", "current", "scope", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/symboltable.py#L832-L836
boriel/zxbasic
api/symboltable.py
SymbolTable.types
def types(self): """ Returns symbol instances corresponding to type declarations within the current scope. """ return [x for x in self[self.current_scope].values() if isinstance(x, symbols.TYPE)]
python
def types(self): """ Returns symbol instances corresponding to type declarations within the current scope. """ return [x for x in self[self.current_scope].values() if isinstance(x, symbols.TYPE)]
[ "def", "types", "(", "self", ")", ":", "return", "[", "x", "for", "x", "in", "self", "[", "self", ".", "current_scope", "]", ".", "values", "(", ")", "if", "isinstance", "(", "x", ",", "symbols", ".", "TYPE", ")", "]" ]
Returns symbol instances corresponding to type declarations within the current scope.
[ "Returns", "symbol", "instances", "corresponding", "to", "type", "declarations", "within", "the", "current", "scope", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/symboltable.py#L839-L843
boriel/zxbasic
api/symboltable.py
SymbolTable.arrays
def arrays(self): """ Returns symbol instances corresponding to arrays of the current scope. """ return [x for x in self[self.current_scope].values() if x.class_ == CLASS.array]
python
def arrays(self): """ Returns symbol instances corresponding to arrays of the current scope. """ return [x for x in self[self.current_scope].values() if x.class_ == CLASS.array]
[ "def", "arrays", "(", "self", ")", ":", "return", "[", "x", "for", "x", "in", "self", "[", "self", ".", "current_scope", "]", ".", "values", "(", ")", "if", "x", ".", "class_", "==", "CLASS", ".", "array", "]" ]
Returns symbol instances corresponding to arrays of the current scope.
[ "Returns", "symbol", "instances", "corresponding", "to", "arrays", "of", "the", "current", "scope", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/symboltable.py#L846-L850
boriel/zxbasic
api/symboltable.py
SymbolTable.functions
def functions(self): """ Returns symbol instances corresponding to functions of the current scope. """ return [x for x in self[self.current_scope].values() if x.class_ in (CLASS.function, CLASS.sub)]
python
def functions(self): """ Returns symbol instances corresponding to functions of the current scope. """ return [x for x in self[self.current_scope].values() if x.class_ in (CLASS.function, CLASS.sub)]
[ "def", "functions", "(", "self", ")", ":", "return", "[", "x", "for", "x", "in", "self", "[", "self", ".", "current_scope", "]", ".", "values", "(", ")", "if", "x", ".", "class_", "in", "(", "CLASS", ".", "function", ",", "CLASS", ".", "sub", ")"...
Returns symbol instances corresponding to functions of the current scope.
[ "Returns", "symbol", "instances", "corresponding", "to", "functions", "of", "the", "current", "scope", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/symboltable.py#L853-L858
boriel/zxbasic
api/symboltable.py
SymbolTable.aliases
def aliases(self): """ Returns symbol instances corresponding to aliased vars. """ return [x for x in self[self.current_scope].values() if x.is_aliased]
python
def aliases(self): """ Returns symbol instances corresponding to aliased vars. """ return [x for x in self[self.current_scope].values() if x.is_aliased]
[ "def", "aliases", "(", "self", ")", ":", "return", "[", "x", "for", "x", "in", "self", "[", "self", ".", "current_scope", "]", ".", "values", "(", ")", "if", "x", ".", "is_aliased", "]" ]
Returns symbol instances corresponding to aliased vars.
[ "Returns", "symbol", "instances", "corresponding", "to", "aliased", "vars", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/symboltable.py#L861-L864
boriel/zxbasic
api/check.py
check_type
def check_type(lineno, type_list, arg): """ Check arg's type is one in type_list, otherwise, raises an error. """ if not isinstance(type_list, list): type_list = [type_list] if arg.type_ in type_list: return True if len(type_list) == 1: syntax_error(lineno, "Wrong expre...
python
def check_type(lineno, type_list, arg): """ Check arg's type is one in type_list, otherwise, raises an error. """ if not isinstance(type_list, list): type_list = [type_list] if arg.type_ in type_list: return True if len(type_list) == 1: syntax_error(lineno, "Wrong expre...
[ "def", "check_type", "(", "lineno", ",", "type_list", ",", "arg", ")", ":", "if", "not", "isinstance", "(", "type_list", ",", "list", ")", ":", "type_list", "=", "[", "type_list", "]", "if", "arg", ".", "type_", "in", "type_list", ":", "return", "True"...
Check arg's type is one in type_list, otherwise, raises an error.
[ "Check", "arg", "s", "type", "is", "one", "in", "type_list", "otherwise", "raises", "an", "error", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/check.py#L44-L61
boriel/zxbasic
api/check.py
check_is_declared_explicit
def check_is_declared_explicit(lineno, id_, classname='variable'): """ Check if the current ID is already declared. If not, triggers a "undeclared identifier" error, if the --explicit command line flag is enabled (or #pragma option strict is in use). If not in strict mode, passes it silently. "...
python
def check_is_declared_explicit(lineno, id_, classname='variable'): """ Check if the current ID is already declared. If not, triggers a "undeclared identifier" error, if the --explicit command line flag is enabled (or #pragma option strict is in use). If not in strict mode, passes it silently. "...
[ "def", "check_is_declared_explicit", "(", "lineno", ",", "id_", ",", "classname", "=", "'variable'", ")", ":", "if", "not", "config", ".", "OPTIONS", ".", "explicit", ".", "value", ":", "return", "True", "entry", "=", "global_", ".", "SYMBOL_TABLE", ".", "...
Check if the current ID is already declared. If not, triggers a "undeclared identifier" error, if the --explicit command line flag is enabled (or #pragma option strict is in use). If not in strict mode, passes it silently.
[ "Check", "if", "the", "current", "ID", "is", "already", "declared", ".", "If", "not", "triggers", "a", "undeclared", "identifier", "error", "if", "the", "--", "explicit", "command", "line", "flag", "is", "enabled", "(", "or", "#pragma", "option", "strict", ...
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/check.py#L64-L76
boriel/zxbasic
api/check.py
check_call_arguments
def check_call_arguments(lineno, id_, args): """ Check arguments against function signature. Checks every argument in a function call against a function. Returns True on success. """ if not global_.SYMBOL_TABLE.check_is_declared(id_, lineno, 'function'): return False if not glo...
python
def check_call_arguments(lineno, id_, args): """ Check arguments against function signature. Checks every argument in a function call against a function. Returns True on success. """ if not global_.SYMBOL_TABLE.check_is_declared(id_, lineno, 'function'): return False if not glo...
[ "def", "check_call_arguments", "(", "lineno", ",", "id_", ",", "args", ")", ":", "if", "not", "global_", ".", "SYMBOL_TABLE", ".", "check_is_declared", "(", "id_", ",", "lineno", ",", "'function'", ")", ":", "return", "False", "if", "not", "global_", ".", ...
Check arguments against function signature. Checks every argument in a function call against a function. Returns True on success.
[ "Check", "arguments", "against", "function", "signature", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/check.py#L87-L129
boriel/zxbasic
api/check.py
check_pending_calls
def check_pending_calls(): """ Calls the above function for each pending call of the current scope level """ result = True # Check for functions defined after calls (parametres, etc) for id_, params, lineno in global_.FUNCTION_CALLS: result = result and check_call_arguments(lineno, id_,...
python
def check_pending_calls(): """ Calls the above function for each pending call of the current scope level """ result = True # Check for functions defined after calls (parametres, etc) for id_, params, lineno in global_.FUNCTION_CALLS: result = result and check_call_arguments(lineno, id_,...
[ "def", "check_pending_calls", "(", ")", ":", "result", "=", "True", "# Check for functions defined after calls (parametres, etc)", "for", "id_", ",", "params", ",", "lineno", "in", "global_", ".", "FUNCTION_CALLS", ":", "result", "=", "result", "and", "check_call_argu...
Calls the above function for each pending call of the current scope level
[ "Calls", "the", "above", "function", "for", "each", "pending", "call", "of", "the", "current", "scope", "level" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/check.py#L132-L142
boriel/zxbasic
api/check.py
check_pending_labels
def check_pending_labels(ast): """ Iteratively traverses the node looking for ID with no class set, marks them as labels, and check they've been declared. This way we avoid stack overflow for high line-numbered listings. """ result = True visited = set() pending = [ast] while pending: ...
python
def check_pending_labels(ast): """ Iteratively traverses the node looking for ID with no class set, marks them as labels, and check they've been declared. This way we avoid stack overflow for high line-numbered listings. """ result = True visited = set() pending = [ast] while pending: ...
[ "def", "check_pending_labels", "(", "ast", ")", ":", "result", "=", "True", "visited", "=", "set", "(", ")", "pending", "=", "[", "ast", "]", "while", "pending", ":", "node", "=", "pending", ".", "pop", "(", ")", "if", "node", "is", "None", "or", "...
Iteratively traverses the node looking for ID with no class set, marks them as labels, and check they've been declared. This way we avoid stack overflow for high line-numbered listings.
[ "Iteratively", "traverses", "the", "node", "looking", "for", "ID", "with", "no", "class", "set", "marks", "them", "as", "labels", "and", "check", "they", "ve", "been", "declared", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/check.py#L145-L178
boriel/zxbasic
api/check.py
check_and_make_label
def check_and_make_label(lbl, lineno): """ Checks if the given label (or line number) is valid and, if so, returns a label object. :param lbl: Line number of label (string) :param lineno: Line number in the basic source code for error reporting :return: Label object or None if error. """ if ...
python
def check_and_make_label(lbl, lineno): """ Checks if the given label (or line number) is valid and, if so, returns a label object. :param lbl: Line number of label (string) :param lineno: Line number in the basic source code for error reporting :return: Label object or None if error. """ if ...
[ "def", "check_and_make_label", "(", "lbl", ",", "lineno", ")", ":", "if", "isinstance", "(", "lbl", ",", "float", ")", ":", "if", "lbl", "==", "int", "(", "lbl", ")", ":", "id_", "=", "str", "(", "int", "(", "lbl", ")", ")", "else", ":", "syntax_...
Checks if the given label (or line number) is valid and, if so, returns a label object. :param lbl: Line number of label (string) :param lineno: Line number in the basic source code for error reporting :return: Label object or None if error.
[ "Checks", "if", "the", "given", "label", "(", "or", "line", "number", ")", "is", "valid", "and", "if", "so", "returns", "a", "label", "object", ".", ":", "param", "lbl", ":", "Line", "number", "of", "label", "(", "string", ")", ":", "param", "lineno"...
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/check.py#L181-L197
boriel/zxbasic
api/check.py
is_null
def is_null(*symbols): """ True if no nodes or all the given nodes are either None, NOP or empty blocks. For blocks this applies recursively """ from symbols.symbol_ import Symbol for sym in symbols: if sym is None: continue if not isinstance(sym, Symbol): re...
python
def is_null(*symbols): """ True if no nodes or all the given nodes are either None, NOP or empty blocks. For blocks this applies recursively """ from symbols.symbol_ import Symbol for sym in symbols: if sym is None: continue if not isinstance(sym, Symbol): re...
[ "def", "is_null", "(", "*", "symbols", ")", ":", "from", "symbols", ".", "symbol_", "import", "Symbol", "for", "sym", "in", "symbols", ":", "if", "sym", "is", "None", ":", "continue", "if", "not", "isinstance", "(", "sym", ",", "Symbol", ")", ":", "r...
True if no nodes or all the given nodes are either None, NOP or empty blocks. For blocks this applies recursively
[ "True", "if", "no", "nodes", "or", "all", "the", "given", "nodes", "are", "either", "None", "NOP", "or", "empty", "blocks", ".", "For", "blocks", "this", "applies", "recursively" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/check.py#L203-L221
boriel/zxbasic
api/check.py
is_SYMBOL
def is_SYMBOL(token, *symbols): """ Returns True if ALL of the given argument are AST nodes of the given token (e.g. 'BINARY') """ from symbols.symbol_ import Symbol assert all(isinstance(x, Symbol) for x in symbols) for sym in symbols: if sym.token != token: return False ...
python
def is_SYMBOL(token, *symbols): """ Returns True if ALL of the given argument are AST nodes of the given token (e.g. 'BINARY') """ from symbols.symbol_ import Symbol assert all(isinstance(x, Symbol) for x in symbols) for sym in symbols: if sym.token != token: return False ...
[ "def", "is_SYMBOL", "(", "token", ",", "*", "symbols", ")", ":", "from", "symbols", ".", "symbol_", "import", "Symbol", "assert", "all", "(", "isinstance", "(", "x", ",", "Symbol", ")", "for", "x", "in", "symbols", ")", "for", "sym", "in", "symbols", ...
Returns True if ALL of the given argument are AST nodes of the given token (e.g. 'BINARY')
[ "Returns", "True", "if", "ALL", "of", "the", "given", "argument", "are", "AST", "nodes", "of", "the", "given", "token", "(", "e", ".", "g", ".", "BINARY", ")" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/check.py#L224-L234
boriel/zxbasic
api/check.py
is_const
def is_const(*p): """ A constant in the program, like CONST a = 5 """ return is_SYMBOL('VAR', *p) and all(x.class_ == CLASS.const for x in p)
python
def is_const(*p): """ A constant in the program, like CONST a = 5 """ return is_SYMBOL('VAR', *p) and all(x.class_ == CLASS.const for x in p)
[ "def", "is_const", "(", "*", "p", ")", ":", "return", "is_SYMBOL", "(", "'VAR'", ",", "*", "p", ")", "and", "all", "(", "x", ".", "class_", "==", "CLASS", ".", "const", "for", "x", "in", "p", ")" ]
A constant in the program, like CONST a = 5
[ "A", "constant", "in", "the", "program", "like", "CONST", "a", "=", "5" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/check.py#L245-L248
boriel/zxbasic
api/check.py
is_static
def is_static(*p): """ A static value (does not change at runtime) which is known at compile time """ return all(is_CONST(x) or is_number(x) or is_const(x) for x in p)
python
def is_static(*p): """ A static value (does not change at runtime) which is known at compile time """ return all(is_CONST(x) or is_number(x) or is_const(x) for x in p)
[ "def", "is_static", "(", "*", "p", ")", ":", "return", "all", "(", "is_CONST", "(", "x", ")", "or", "is_number", "(", "x", ")", "or", "is_const", "(", "x", ")", "for", "x", "in", "p", ")" ]
A static value (does not change at runtime) which is known at compile time
[ "A", "static", "value", "(", "does", "not", "change", "at", "runtime", ")", "which", "is", "known", "at", "compile", "time" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/check.py#L258-L265
boriel/zxbasic
api/check.py
is_number
def is_number(*p): """ Returns True if ALL of the arguments are AST nodes containing NUMBER or numeric CONSTANTS """ try: for i in p: if i.token != 'NUMBER' and (i.token != 'ID' or i.class_ != CLASS.const): return False return True except: pass ...
python
def is_number(*p): """ Returns True if ALL of the arguments are AST nodes containing NUMBER or numeric CONSTANTS """ try: for i in p: if i.token != 'NUMBER' and (i.token != 'ID' or i.class_ != CLASS.const): return False return True except: pass ...
[ "def", "is_number", "(", "*", "p", ")", ":", "try", ":", "for", "i", "in", "p", ":", "if", "i", ".", "token", "!=", "'NUMBER'", "and", "(", "i", ".", "token", "!=", "'ID'", "or", "i", ".", "class_", "!=", "CLASS", ".", "const", ")", ":", "ret...
Returns True if ALL of the arguments are AST nodes containing NUMBER or numeric CONSTANTS
[ "Returns", "True", "if", "ALL", "of", "the", "arguments", "are", "AST", "nodes", "containing", "NUMBER", "or", "numeric", "CONSTANTS" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/check.py#L268-L281
boriel/zxbasic
api/check.py
is_unsigned
def is_unsigned(*p): """ Returns false unless all types in p are unsigned """ from symbols.type_ import Type try: for i in p: if not i.type_.is_basic or not Type.is_unsigned(i.type_): return False return True except: pass return False
python
def is_unsigned(*p): """ Returns false unless all types in p are unsigned """ from symbols.type_ import Type try: for i in p: if not i.type_.is_basic or not Type.is_unsigned(i.type_): return False return True except: pass return False
[ "def", "is_unsigned", "(", "*", "p", ")", ":", "from", "symbols", ".", "type_", "import", "Type", "try", ":", "for", "i", "in", "p", ":", "if", "not", "i", ".", "type_", ".", "is_basic", "or", "not", "Type", ".", "is_unsigned", "(", "i", ".", "ty...
Returns false unless all types in p are unsigned
[ "Returns", "false", "unless", "all", "types", "in", "p", "are", "unsigned" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/check.py#L306-L320
boriel/zxbasic
api/check.py
is_type
def is_type(type_, *p): """ True if all args have the same type """ try: for i in p: if i.type_ != type_: return False return True except: pass return False
python
def is_type(type_, *p): """ True if all args have the same type """ try: for i in p: if i.type_ != type_: return False return True except: pass return False
[ "def", "is_type", "(", "type_", ",", "*", "p", ")", ":", "try", ":", "for", "i", "in", "p", ":", "if", "i", ".", "type_", "!=", "type_", ":", "return", "False", "return", "True", "except", ":", "pass", "return", "False" ]
True if all args have the same type
[ "True", "if", "all", "args", "have", "the", "same", "type" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/check.py#L357-L369
boriel/zxbasic
api/check.py
is_dynamic
def is_dynamic(*p): # TODO: Explain this better """ True if all args are dynamic (e.g. Strings, dynamic arrays, etc) The use a ptr (ref) and it might change during runtime. """ from symbols.type_ import Type try: for i in p: if i.scope == SCOPE.global_ and i.is_basic and \ ...
python
def is_dynamic(*p): # TODO: Explain this better """ True if all args are dynamic (e.g. Strings, dynamic arrays, etc) The use a ptr (ref) and it might change during runtime. """ from symbols.type_ import Type try: for i in p: if i.scope == SCOPE.global_ and i.is_basic and \ ...
[ "def", "is_dynamic", "(", "*", "p", ")", ":", "# TODO: Explain this better", "from", "symbols", ".", "type_", "import", "Type", "try", ":", "for", "i", "in", "p", ":", "if", "i", ".", "scope", "==", "SCOPE", ".", "global_", "and", "i", ".", "is_basic",...
True if all args are dynamic (e.g. Strings, dynamic arrays, etc) The use a ptr (ref) and it might change during runtime.
[ "True", "if", "all", "args", "are", "dynamic", "(", "e", ".", "g", ".", "Strings", "dynamic", "arrays", "etc", ")", "The", "use", "a", "ptr", "(", "ref", ")", "and", "it", "might", "change", "during", "runtime", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/check.py#L372-L388
boriel/zxbasic
api/check.py
is_callable
def is_callable(*p): """ True if all the args are functions and / or subroutines """ import symbols return all(isinstance(x, symbols.FUNCTION) for x in p)
python
def is_callable(*p): """ True if all the args are functions and / or subroutines """ import symbols return all(isinstance(x, symbols.FUNCTION) for x in p)
[ "def", "is_callable", "(", "*", "p", ")", ":", "import", "symbols", "return", "all", "(", "isinstance", "(", "x", ",", "symbols", ".", "FUNCTION", ")", "for", "x", "in", "p", ")" ]
True if all the args are functions and / or subroutines
[ "True", "if", "all", "the", "args", "are", "functions", "and", "/", "or", "subroutines" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/check.py#L391-L395
boriel/zxbasic
api/check.py
is_block_accessed
def is_block_accessed(block): """ Returns True if a block is "accessed". A block of code is accessed if it has a LABEL and it is used in a GOTO, GO SUB or @address access :param block: A block of code (AST node) :return: True / False depending if it has labels accessed or not """ if is_LABEL(blo...
python
def is_block_accessed(block): """ Returns True if a block is "accessed". A block of code is accessed if it has a LABEL and it is used in a GOTO, GO SUB or @address access :param block: A block of code (AST node) :return: True / False depending if it has labels accessed or not """ if is_LABEL(blo...
[ "def", "is_block_accessed", "(", "block", ")", ":", "if", "is_LABEL", "(", "block", ")", "and", "block", ".", "accessed", ":", "return", "True", "for", "child", "in", "block", ".", "children", ":", "if", "not", "is_callable", "(", "child", ")", "and", ...
Returns True if a block is "accessed". A block of code is accessed if it has a LABEL and it is used in a GOTO, GO SUB or @address access :param block: A block of code (AST node) :return: True / False depending if it has labels accessed or not
[ "Returns", "True", "if", "a", "block", "is", "accessed", ".", "A", "block", "of", "code", "is", "accessed", "if", "it", "has", "a", "LABEL", "and", "it", "is", "used", "in", "a", "GOTO", "GO", "SUB", "or" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/check.py#L398-L411
boriel/zxbasic
api/check.py
common_type
def common_type(a, b): """ Returns a type which is common for both a and b types. Returns None if no common types allowed. """ from symbols.type_ import SymbolBASICTYPE as BASICTYPE from symbols.type_ import Type as TYPE from symbols.type_ import SymbolTYPE if a is None or b is None: ...
python
def common_type(a, b): """ Returns a type which is common for both a and b types. Returns None if no common types allowed. """ from symbols.type_ import SymbolBASICTYPE as BASICTYPE from symbols.type_ import Type as TYPE from symbols.type_ import SymbolTYPE if a is None or b is None: ...
[ "def", "common_type", "(", "a", ",", "b", ")", ":", "from", "symbols", ".", "type_", "import", "SymbolBASICTYPE", "as", "BASICTYPE", "from", "symbols", ".", "type_", "import", "Type", "as", "TYPE", "from", "symbols", ".", "type_", "import", "SymbolTYPE", "...
Returns a type which is common for both a and b types. Returns None if no common types allowed.
[ "Returns", "a", "type", "which", "is", "common", "for", "both", "a", "and", "b", "types", ".", "Returns", "None", "if", "no", "common", "types", "allowed", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/check.py#L414-L463
boriel/zxbasic
zxb.py
output
def output(memory, ofile=None): """ Filters the output removing useless preprocessor #directives and writes it to the given file or to the screen if no file is passed """ for m in memory: m = m.rstrip('\r\n\t ') # Ensures no trailing newlines (might with upon includes) if m and m[0] == ...
python
def output(memory, ofile=None): """ Filters the output removing useless preprocessor #directives and writes it to the given file or to the screen if no file is passed """ for m in memory: m = m.rstrip('\r\n\t ') # Ensures no trailing newlines (might with upon includes) if m and m[0] == ...
[ "def", "output", "(", "memory", ",", "ofile", "=", "None", ")", ":", "for", "m", "in", "memory", ":", "m", "=", "m", ".", "rstrip", "(", "'\\r\\n\\t '", ")", "# Ensures no trailing newlines (might with upon includes)", "if", "m", "and", "m", "[", "0", "]",...
Filters the output removing useless preprocessor #directives and writes it to the given file or to the screen if no file is passed
[ "Filters", "the", "output", "removing", "useless", "preprocessor", "#directives", "and", "writes", "it", "to", "the", "given", "file", "or", "to", "the", "screen", "if", "no", "file", "is", "passed" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxb.py#L48-L71
boriel/zxbasic
zxb.py
main
def main(args=None): """ Entry point when executed from command line. You can use zxb.py as a module with import, and this function won't be executed. """ api.config.init() zxbpp.init() zxbparser.init() arch.zx48k.backend.init() arch.zx48k.Translator.reset() asmparse.init() ...
python
def main(args=None): """ Entry point when executed from command line. You can use zxb.py as a module with import, and this function won't be executed. """ api.config.init() zxbpp.init() zxbparser.init() arch.zx48k.backend.init() arch.zx48k.Translator.reset() asmparse.init() ...
[ "def", "main", "(", "args", "=", "None", ")", ":", "api", ".", "config", ".", "init", "(", ")", "zxbpp", ".", "init", "(", ")", "zxbparser", ".", "init", "(", ")", "arch", ".", "zx48k", ".", "backend", ".", "init", "(", ")", "arch", ".", "zx48k...
Entry point when executed from command line. You can use zxb.py as a module with import, and this function won't be executed.
[ "Entry", "point", "when", "executed", "from", "command", "line", ".", "You", "can", "use", "zxb", ".", "py", "as", "a", "module", "with", "import", "and", "this", "function", "won", "t", "be", "executed", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxb.py#L74-L351
boriel/zxbasic
arch/zx48k/backend/__16bit.py
_16bit_oper
def _16bit_oper(op1, op2=None, reversed=False): ''' Returns pop sequence for 16 bits operands 1st operand in HL, 2nd operand in DE For subtraction, division, etc. you can swap operators extraction order by setting reversed to True ''' output = [] if op1 is not None: op1 = str(op1) ...
python
def _16bit_oper(op1, op2=None, reversed=False): ''' Returns pop sequence for 16 bits operands 1st operand in HL, 2nd operand in DE For subtraction, division, etc. you can swap operators extraction order by setting reversed to True ''' output = [] if op1 is not None: op1 = str(op1) ...
[ "def", "_16bit_oper", "(", "op1", ",", "op2", "=", "None", ",", "reversed", "=", "False", ")", ":", "output", "=", "[", "]", "if", "op1", "is", "not", "None", ":", "op1", "=", "str", "(", "op1", ")", "# always to str", "if", "op2", "is", "not", "...
Returns pop sequence for 16 bits operands 1st operand in HL, 2nd operand in DE For subtraction, division, etc. you can swap operators extraction order by setting reversed to True
[ "Returns", "pop", "sequence", "for", "16", "bits", "operands", "1st", "operand", "in", "HL", "2nd", "operand", "in", "DE" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__16bit.py#L26-L117
boriel/zxbasic
arch/zx48k/backend/__16bit.py
_add16
def _add16(ins): ''' Pops last 2 bytes from the stack and adds them. Then push the result onto the stack. Optimizations: * If any of the operands is ZERO, then do NOTHING: A + 0 = 0 + A = A * If any of the operands is < 4, then INC is used * If any of the operands is > ...
python
def _add16(ins): ''' Pops last 2 bytes from the stack and adds them. Then push the result onto the stack. Optimizations: * If any of the operands is ZERO, then do NOTHING: A + 0 = 0 + A = A * If any of the operands is < 4, then INC is used * If any of the operands is > ...
[ "def", "_add16", "(", "ins", ")", ":", "op1", ",", "op2", "=", "tuple", "(", "ins", ".", "quad", "[", "2", ":", "]", ")", "if", "_int_ops", "(", "op1", ",", "op2", ")", "is", "not", "None", ":", "op1", ",", "op2", "=", "_int_ops", "(", "op1",...
Pops last 2 bytes from the stack and adds them. Then push the result onto the stack. Optimizations: * If any of the operands is ZERO, then do NOTHING: A + 0 = 0 + A = A * If any of the operands is < 4, then INC is used * If any of the operands is > (65531) (-4), then ...
[ "Pops", "last", "2", "bytes", "from", "the", "stack", "and", "adds", "them", ".", "Then", "push", "the", "result", "onto", "the", "stack", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__16bit.py#L124-L170
boriel/zxbasic
arch/zx48k/backend/__16bit.py
_sub16
def _sub16(ins): ''' Pops last 2 words from the stack and subtract them. Then push the result onto the stack. Top of the stack is subtracted Top -1 Optimizations: * If 2nd op is ZERO, then do NOTHING: A - 0 = A * If any of the operands is < 4, then DEC is used * If a...
python
def _sub16(ins): ''' Pops last 2 words from the stack and subtract them. Then push the result onto the stack. Top of the stack is subtracted Top -1 Optimizations: * If 2nd op is ZERO, then do NOTHING: A - 0 = A * If any of the operands is < 4, then DEC is used * If a...
[ "def", "_sub16", "(", "ins", ")", ":", "op1", ",", "op2", "=", "tuple", "(", "ins", ".", "quad", "[", "2", ":", "4", "]", ")", "if", "is_int", "(", "op2", ")", ":", "op", "=", "int16", "(", "op2", ")", "output", "=", "_16bit_oper", "(", "op1"...
Pops last 2 words from the stack and subtract them. Then push the result onto the stack. Top of the stack is subtracted Top -1 Optimizations: * If 2nd op is ZERO, then do NOTHING: A - 0 = A * If any of the operands is < 4, then DEC is used * If any of the operands is > 6...
[ "Pops", "last", "2", "words", "from", "the", "stack", "and", "subtract", "them", ".", "Then", "push", "the", "result", "onto", "the", "stack", ".", "Top", "of", "the", "stack", "is", "subtracted", "Top", "-", "1" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__16bit.py#L173-L223
boriel/zxbasic
arch/zx48k/backend/__16bit.py
_mul16
def _mul16(ins): ''' Multiplies tow last 16bit values on top of the stack and and returns the value on top of the stack Optimizations: * If any of the ops is ZERO, then do A = 0 ==> XOR A, cause A * 0 = 0 * A = 0 * If any ot the ops is ONE, do NOTHING A * 1 = 1 * A = A *...
python
def _mul16(ins): ''' Multiplies tow last 16bit values on top of the stack and and returns the value on top of the stack Optimizations: * If any of the ops is ZERO, then do A = 0 ==> XOR A, cause A * 0 = 0 * A = 0 * If any ot the ops is ONE, do NOTHING A * 1 = 1 * A = A *...
[ "def", "_mul16", "(", "ins", ")", ":", "op1", ",", "op2", "=", "tuple", "(", "ins", ".", "quad", "[", "2", ":", "]", ")", "if", "_int_ops", "(", "op1", ",", "op2", ")", "is", "not", "None", ":", "# If any of the operands is constant", "op1", ",", "...
Multiplies tow last 16bit values on top of the stack and and returns the value on top of the stack Optimizations: * If any of the ops is ZERO, then do A = 0 ==> XOR A, cause A * 0 = 0 * A = 0 * If any ot the ops is ONE, do NOTHING A * 1 = 1 * A = A * If B is 2^n and B < 16 =...
[ "Multiplies", "tow", "last", "16bit", "values", "on", "top", "of", "the", "stack", "and", "and", "returns", "the", "value", "on", "top", "of", "the", "stack" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__16bit.py#L226-L276
boriel/zxbasic
arch/zx48k/backend/__16bit.py
_divu16
def _divu16(ins): ''' Divides 2 16bit unsigned integers. The result is pushed onto the stack. Optimizations: * If 2nd op is 1 then do nothing * If 2nd op is 2 then Shift Right Logical ''' op1, op2 = tuple(ins.quad[2:]) if is_int(op1) and int(op1) == 0: # 0 / A = 0 ...
python
def _divu16(ins): ''' Divides 2 16bit unsigned integers. The result is pushed onto the stack. Optimizations: * If 2nd op is 1 then do nothing * If 2nd op is 2 then Shift Right Logical ''' op1, op2 = tuple(ins.quad[2:]) if is_int(op1) and int(op1) == 0: # 0 / A = 0 ...
[ "def", "_divu16", "(", "ins", ")", ":", "op1", ",", "op2", "=", "tuple", "(", "ins", ".", "quad", "[", "2", ":", "]", ")", "if", "is_int", "(", "op1", ")", "and", "int", "(", "op1", ")", "==", "0", ":", "# 0 / A = 0", "if", "op2", "[", "0", ...
Divides 2 16bit unsigned integers. The result is pushed onto the stack. Optimizations: * If 2nd op is 1 then do nothing * If 2nd op is 2 then Shift Right Logical
[ "Divides", "2", "16bit", "unsigned", "integers", ".", "The", "result", "is", "pushed", "onto", "the", "stack", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__16bit.py#L279-L333
boriel/zxbasic
arch/zx48k/backend/__16bit.py
_modu16
def _modu16(ins): ''' Reminder of div. 2 16bit unsigned integers. The result is pushed onto the stack. Optimizations: * If 2nd operand is 1 => Return 0 * If 2nd operand = 2^n => do AND (2^n - 1) ''' op1, op2 = tuple(ins.quad[2:]) if is_int(op2): op2 = int16(op2) ...
python
def _modu16(ins): ''' Reminder of div. 2 16bit unsigned integers. The result is pushed onto the stack. Optimizations: * If 2nd operand is 1 => Return 0 * If 2nd operand = 2^n => do AND (2^n - 1) ''' op1, op2 = tuple(ins.quad[2:]) if is_int(op2): op2 = int16(op2) ...
[ "def", "_modu16", "(", "ins", ")", ":", "op1", ",", "op2", "=", "tuple", "(", "ins", ".", "quad", "[", "2", ":", "]", ")", "if", "is_int", "(", "op2", ")", ":", "op2", "=", "int16", "(", "op2", ")", "output", "=", "_16bit_oper", "(", "op1", "...
Reminder of div. 2 16bit unsigned integers. The result is pushed onto the stack. Optimizations: * If 2nd operand is 1 => Return 0 * If 2nd operand = 2^n => do AND (2^n - 1)
[ "Reminder", "of", "div", ".", "2", "16bit", "unsigned", "integers", ".", "The", "result", "is", "pushed", "onto", "the", "stack", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__16bit.py#L395-L438
boriel/zxbasic
arch/zx48k/backend/__16bit.py
_ltu16
def _ltu16(ins): ''' Compares & pops top 2 operands out of the stack, and checks if the 1st operand < 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 16 bit unsigned version ''' output = _16bit_oper(ins.quad[2], ins.quad[3]) output.append('or a') output.append(...
python
def _ltu16(ins): ''' Compares & pops top 2 operands out of the stack, and checks if the 1st operand < 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 16 bit unsigned version ''' output = _16bit_oper(ins.quad[2], ins.quad[3]) output.append('or a') output.append(...
[ "def", "_ltu16", "(", "ins", ")", ":", "output", "=", "_16bit_oper", "(", "ins", ".", "quad", "[", "2", "]", ",", "ins", ".", "quad", "[", "3", "]", ")", "output", ".", "append", "(", "'or a'", ")", "output", ".", "append", "(", "'sbc hl, de'", "...
Compares & pops top 2 operands out of the stack, and checks if the 1st operand < 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 16 bit unsigned version
[ "Compares", "&", "pops", "top", "2", "operands", "out", "of", "the", "stack", "and", "checks", "if", "the", "1st", "operand", "<", "2nd", "operand", "(", "top", "of", "the", "stack", ")", ".", "Pushes", "0", "if", "False", "1", "if", "True", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__16bit.py#L487-L499
boriel/zxbasic
arch/zx48k/backend/__16bit.py
_lti16
def _lti16(ins): ''' Compares & pops top 2 operands out of the stack, and checks if the 1st operand < 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 16 bit signed version ''' output = _16bit_oper(ins.quad[2], ins.quad[3]) output.append('call __LTI16') output.a...
python
def _lti16(ins): ''' Compares & pops top 2 operands out of the stack, and checks if the 1st operand < 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 16 bit signed version ''' output = _16bit_oper(ins.quad[2], ins.quad[3]) output.append('call __LTI16') output.a...
[ "def", "_lti16", "(", "ins", ")", ":", "output", "=", "_16bit_oper", "(", "ins", ".", "quad", "[", "2", "]", ",", "ins", ".", "quad", "[", "3", "]", ")", "output", ".", "append", "(", "'call __LTI16'", ")", "output", ".", "append", "(", "'push af'"...
Compares & pops top 2 operands out of the stack, and checks if the 1st operand < 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 16 bit signed version
[ "Compares", "&", "pops", "top", "2", "operands", "out", "of", "the", "stack", "and", "checks", "if", "the", "1st", "operand", "<", "2nd", "operand", "(", "top", "of", "the", "stack", ")", ".", "Pushes", "0", "if", "False", "1", "if", "True", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__16bit.py#L502-L513
boriel/zxbasic
arch/zx48k/backend/__16bit.py
_gtu16
def _gtu16(ins): ''' Compares & pops top 2 operands out of the stack, and checks if the 1st operand > 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 16 bit unsigned version ''' output = _16bit_oper(ins.quad[2], ins.quad[3], reversed=True) output.append('or a') ...
python
def _gtu16(ins): ''' Compares & pops top 2 operands out of the stack, and checks if the 1st operand > 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 16 bit unsigned version ''' output = _16bit_oper(ins.quad[2], ins.quad[3], reversed=True) output.append('or a') ...
[ "def", "_gtu16", "(", "ins", ")", ":", "output", "=", "_16bit_oper", "(", "ins", ".", "quad", "[", "2", "]", ",", "ins", ".", "quad", "[", "3", "]", ",", "reversed", "=", "True", ")", "output", ".", "append", "(", "'or a'", ")", "output", ".", ...
Compares & pops top 2 operands out of the stack, and checks if the 1st operand > 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 16 bit unsigned version
[ "Compares", "&", "pops", "top", "2", "operands", "out", "of", "the", "stack", "and", "checks", "if", "the", "1st", "operand", ">", "2nd", "operand", "(", "top", "of", "the", "stack", ")", ".", "Pushes", "0", "if", "False", "1", "if", "True", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__16bit.py#L516-L528
boriel/zxbasic
arch/zx48k/backend/__16bit.py
_gti16
def _gti16(ins): ''' Compares & pops top 2 operands out of the stack, and checks if the 1st operand > 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 16 bit signed version ''' output = _16bit_oper(ins.quad[2], ins.quad[3], reversed=True) output.append('call __LTI16...
python
def _gti16(ins): ''' Compares & pops top 2 operands out of the stack, and checks if the 1st operand > 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 16 bit signed version ''' output = _16bit_oper(ins.quad[2], ins.quad[3], reversed=True) output.append('call __LTI16...
[ "def", "_gti16", "(", "ins", ")", ":", "output", "=", "_16bit_oper", "(", "ins", ".", "quad", "[", "2", "]", ",", "ins", ".", "quad", "[", "3", "]", ",", "reversed", "=", "True", ")", "output", ".", "append", "(", "'call __LTI16'", ")", "output", ...
Compares & pops top 2 operands out of the stack, and checks if the 1st operand > 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 16 bit signed version
[ "Compares", "&", "pops", "top", "2", "operands", "out", "of", "the", "stack", "and", "checks", "if", "the", "1st", "operand", ">", "2nd", "operand", "(", "top", "of", "the", "stack", ")", ".", "Pushes", "0", "if", "False", "1", "if", "True", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__16bit.py#L531-L542
boriel/zxbasic
arch/zx48k/backend/__16bit.py
_leu16
def _leu16(ins): ''' Compares & pops top 2 operands out of the stack, and checks if the 1st operand <= 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 16 bit unsigned version ''' output = _16bit_oper(ins.quad[2], ins.quad[3], reversed=True) output.append('or a') ...
python
def _leu16(ins): ''' Compares & pops top 2 operands out of the stack, and checks if the 1st operand <= 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 16 bit unsigned version ''' output = _16bit_oper(ins.quad[2], ins.quad[3], reversed=True) output.append('or a') ...
[ "def", "_leu16", "(", "ins", ")", ":", "output", "=", "_16bit_oper", "(", "ins", ".", "quad", "[", "2", "]", ",", "ins", ".", "quad", "[", "3", "]", ",", "reversed", "=", "True", ")", "output", ".", "append", "(", "'or a'", ")", "output", ".", ...
Compares & pops top 2 operands out of the stack, and checks if the 1st operand <= 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 16 bit unsigned version
[ "Compares", "&", "pops", "top", "2", "operands", "out", "of", "the", "stack", "and", "checks", "if", "the", "1st", "operand", "<", "=", "2nd", "operand", "(", "top", "of", "the", "stack", ")", ".", "Pushes", "0", "if", "False", "1", "if", "True", "...
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__16bit.py#L545-L558
boriel/zxbasic
arch/zx48k/backend/__16bit.py
_lei16
def _lei16(ins): ''' Compares & pops top 2 operands out of the stack, and checks if the 1st operand <= 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 16 bit signed version ''' output = _16bit_oper(ins.quad[2], ins.quad[3]) output.append('call __LEI16') output....
python
def _lei16(ins): ''' Compares & pops top 2 operands out of the stack, and checks if the 1st operand <= 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 16 bit signed version ''' output = _16bit_oper(ins.quad[2], ins.quad[3]) output.append('call __LEI16') output....
[ "def", "_lei16", "(", "ins", ")", ":", "output", "=", "_16bit_oper", "(", "ins", ".", "quad", "[", "2", "]", ",", "ins", ".", "quad", "[", "3", "]", ")", "output", ".", "append", "(", "'call __LEI16'", ")", "output", ".", "append", "(", "'push af'"...
Compares & pops top 2 operands out of the stack, and checks if the 1st operand <= 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 16 bit signed version
[ "Compares", "&", "pops", "top", "2", "operands", "out", "of", "the", "stack", "and", "checks", "if", "the", "1st", "operand", "<", "=", "2nd", "operand", "(", "top", "of", "the", "stack", ")", ".", "Pushes", "0", "if", "False", "1", "if", "True", "...
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__16bit.py#L561-L572
boriel/zxbasic
arch/zx48k/backend/__16bit.py
_geu16
def _geu16(ins): ''' Compares & pops top 2 operands out of the stack, and checks if the 1st operand >= 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 16 bit unsigned version ''' output = _16bit_oper(ins.quad[2], ins.quad[3]) output.append('or a') output.append...
python
def _geu16(ins): ''' Compares & pops top 2 operands out of the stack, and checks if the 1st operand >= 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 16 bit unsigned version ''' output = _16bit_oper(ins.quad[2], ins.quad[3]) output.append('or a') output.append...
[ "def", "_geu16", "(", "ins", ")", ":", "output", "=", "_16bit_oper", "(", "ins", ".", "quad", "[", "2", "]", ",", "ins", ".", "quad", "[", "3", "]", ")", "output", ".", "append", "(", "'or a'", ")", "output", ".", "append", "(", "'sbc hl, de'", "...
Compares & pops top 2 operands out of the stack, and checks if the 1st operand >= 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 16 bit unsigned version
[ "Compares", "&", "pops", "top", "2", "operands", "out", "of", "the", "stack", "and", "checks", "if", "the", "1st", "operand", ">", "=", "2nd", "operand", "(", "top", "of", "the", "stack", ")", ".", "Pushes", "0", "if", "False", "1", "if", "True", "...
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__16bit.py#L575-L588
boriel/zxbasic
arch/zx48k/backend/__16bit.py
_eq16
def _eq16(ins): ''' Compares & pops top 2 operands out of the stack, and checks if the 1st operand == 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 16 bit un/signed version ''' output = _16bit_oper(ins.quad[2], ins.quad[3]) output.append('call __EQ16') output...
python
def _eq16(ins): ''' Compares & pops top 2 operands out of the stack, and checks if the 1st operand == 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 16 bit un/signed version ''' output = _16bit_oper(ins.quad[2], ins.quad[3]) output.append('call __EQ16') output...
[ "def", "_eq16", "(", "ins", ")", ":", "output", "=", "_16bit_oper", "(", "ins", ".", "quad", "[", "2", "]", ",", "ins", ".", "quad", "[", "3", "]", ")", "output", ".", "append", "(", "'call __EQ16'", ")", "output", ".", "append", "(", "'push af'", ...
Compares & pops top 2 operands out of the stack, and checks if the 1st operand == 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 16 bit un/signed version
[ "Compares", "&", "pops", "top", "2", "operands", "out", "of", "the", "stack", "and", "checks", "if", "the", "1st", "operand", "==", "2nd", "operand", "(", "top", "of", "the", "stack", ")", ".", "Pushes", "0", "if", "False", "1", "if", "True", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__16bit.py#L605-L617
boriel/zxbasic
arch/zx48k/backend/__16bit.py
_ne16
def _ne16(ins): ''' Compares & pops top 2 operands out of the stack, and checks if the 1st operand != 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 16 bit un/signed version ''' output = _16bit_oper(ins.quad[2], ins.quad[3]) output.append('or a') # Resets carry f...
python
def _ne16(ins): ''' Compares & pops top 2 operands out of the stack, and checks if the 1st operand != 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 16 bit un/signed version ''' output = _16bit_oper(ins.quad[2], ins.quad[3]) output.append('or a') # Resets carry f...
[ "def", "_ne16", "(", "ins", ")", ":", "output", "=", "_16bit_oper", "(", "ins", ".", "quad", "[", "2", "]", ",", "ins", ".", "quad", "[", "3", "]", ")", "output", ".", "append", "(", "'or a'", ")", "# Resets carry flag", "output", ".", "append", "(...
Compares & pops top 2 operands out of the stack, and checks if the 1st operand != 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 16 bit un/signed version
[ "Compares", "&", "pops", "top", "2", "operands", "out", "of", "the", "stack", "and", "checks", "if", "the", "1st", "operand", "!", "=", "2nd", "operand", "(", "top", "of", "the", "stack", ")", ".", "Pushes", "0", "if", "False", "1", "if", "True", "...
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__16bit.py#L620-L634
boriel/zxbasic
arch/zx48k/backend/__16bit.py
_or16
def _or16(ins): ''' Compares & pops top 2 operands out of the stack, and checks if the 1st operand OR (logical) 2nd operand (top of the stack), pushes 0 if False, 1 if True. 16 bit un/signed version Optimizations: If any of the operators are constants: Returns either 0 or ...
python
def _or16(ins): ''' Compares & pops top 2 operands out of the stack, and checks if the 1st operand OR (logical) 2nd operand (top of the stack), pushes 0 if False, 1 if True. 16 bit un/signed version Optimizations: If any of the operators are constants: Returns either 0 or ...
[ "def", "_or16", "(", "ins", ")", ":", "op1", ",", "op2", "=", "tuple", "(", "ins", ".", "quad", "[", "2", ":", "]", ")", "if", "_int_ops", "(", "op1", ",", "op2", ")", "is", "not", "None", ":", "op1", ",", "op2", "=", "_int_ops", "(", "op1", ...
Compares & pops top 2 operands out of the stack, and checks if the 1st operand OR (logical) 2nd operand (top of the stack), pushes 0 if False, 1 if True. 16 bit un/signed version Optimizations: If any of the operators are constants: Returns either 0 or the other operan...
[ "Compares", "&", "pops", "top", "2", "operands", "out", "of", "the", "stack", "and", "checks", "if", "the", "1st", "operand", "OR", "(", "logical", ")", "2nd", "operand", "(", "top", "of", "the", "stack", ")", "pushes", "0", "if", "False", "1", "if",...
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__16bit.py#L637-L672
boriel/zxbasic
arch/zx48k/backend/__16bit.py
_bor16
def _bor16(ins): ''' Pops top 2 operands out of the stack, and performs 1st operand OR (bitwise) 2nd operand (top of the stack), pushes result (16 bit in HL). 16 bit un/signed version Optimizations: If any of the operators are constants: Returns either 0 or the oth...
python
def _bor16(ins): ''' Pops top 2 operands out of the stack, and performs 1st operand OR (bitwise) 2nd operand (top of the stack), pushes result (16 bit in HL). 16 bit un/signed version Optimizations: If any of the operators are constants: Returns either 0 or the oth...
[ "def", "_bor16", "(", "ins", ")", ":", "op1", ",", "op2", "=", "tuple", "(", "ins", ".", "quad", "[", "2", ":", "]", ")", "if", "_int_ops", "(", "op1", ",", "op2", ")", "is", "not", "None", ":", "op1", ",", "op2", "=", "_int_ops", "(", "op1",...
Pops top 2 operands out of the stack, and performs 1st operand OR (bitwise) 2nd operand (top of the stack), pushes result (16 bit in HL). 16 bit un/signed version Optimizations: If any of the operators are constants: Returns either 0 or the other operand
[ "Pops", "top", "2", "operands", "out", "of", "the", "stack", "and", "performs", "1st", "operand", "OR", "(", "bitwise", ")", "2nd", "operand", "(", "top", "of", "the", "stack", ")", "pushes", "result", "(", "16", "bit", "in", "HL", ")", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__16bit.py#L675-L706
boriel/zxbasic
arch/zx48k/backend/__16bit.py
_not16
def _not16(ins): ''' Negates top (Logical NOT) of the stack (16 bits in HL) ''' output = _16bit_oper(ins.quad[2]) output.append('ld a, h') output.append('or l') output.append('sub 1') output.append('sbc a, a') output.append('push af') return output
python
def _not16(ins): ''' Negates top (Logical NOT) of the stack (16 bits in HL) ''' output = _16bit_oper(ins.quad[2]) output.append('ld a, h') output.append('or l') output.append('sub 1') output.append('sbc a, a') output.append('push af') return output
[ "def", "_not16", "(", "ins", ")", ":", "output", "=", "_16bit_oper", "(", "ins", ".", "quad", "[", "2", "]", ")", "output", ".", "append", "(", "'ld a, h'", ")", "output", ".", "append", "(", "'or l'", ")", "output", ".", "append", "(", "'sub 1'", ...
Negates top (Logical NOT) of the stack (16 bits in HL)
[ "Negates", "top", "(", "Logical", "NOT", ")", "of", "the", "stack", "(", "16", "bits", "in", "HL", ")" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__16bit.py#L852-L861
boriel/zxbasic
arch/zx48k/backend/__16bit.py
_bnot16
def _bnot16(ins): ''' Negates top (Bitwise NOT) of the stack (16 bits in HL) ''' output = _16bit_oper(ins.quad[2]) output.append('call __BNOT16') output.append('push hl') REQUIRES.add('bnot16.asm') return output
python
def _bnot16(ins): ''' Negates top (Bitwise NOT) of the stack (16 bits in HL) ''' output = _16bit_oper(ins.quad[2]) output.append('call __BNOT16') output.append('push hl') REQUIRES.add('bnot16.asm') return output
[ "def", "_bnot16", "(", "ins", ")", ":", "output", "=", "_16bit_oper", "(", "ins", ".", "quad", "[", "2", "]", ")", "output", ".", "append", "(", "'call __BNOT16'", ")", "output", ".", "append", "(", "'push hl'", ")", "REQUIRES", ".", "add", "(", "'bn...
Negates top (Bitwise NOT) of the stack (16 bits in HL)
[ "Negates", "top", "(", "Bitwise", "NOT", ")", "of", "the", "stack", "(", "16", "bits", "in", "HL", ")" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__16bit.py#L864-L871
boriel/zxbasic
arch/zx48k/backend/__16bit.py
_neg16
def _neg16(ins): ''' Negates top of the stack (16 bits in HL) ''' output = _16bit_oper(ins.quad[2]) output.append('call __NEGHL') output.append('push hl') REQUIRES.add('neg16.asm') return output
python
def _neg16(ins): ''' Negates top of the stack (16 bits in HL) ''' output = _16bit_oper(ins.quad[2]) output.append('call __NEGHL') output.append('push hl') REQUIRES.add('neg16.asm') return output
[ "def", "_neg16", "(", "ins", ")", ":", "output", "=", "_16bit_oper", "(", "ins", ".", "quad", "[", "2", "]", ")", "output", ".", "append", "(", "'call __NEGHL'", ")", "output", ".", "append", "(", "'push hl'", ")", "REQUIRES", ".", "add", "(", "'neg1...
Negates top of the stack (16 bits in HL)
[ "Negates", "top", "of", "the", "stack", "(", "16", "bits", "in", "HL", ")" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__16bit.py#L874-L881
boriel/zxbasic
arch/zx48k/backend/__16bit.py
_abs16
def _abs16(ins): ''' Absolute value of top of the stack (16 bits in HL) ''' output = _16bit_oper(ins.quad[2]) output.append('call __ABS16') output.append('push hl') REQUIRES.add('abs16.asm') return output
python
def _abs16(ins): ''' Absolute value of top of the stack (16 bits in HL) ''' output = _16bit_oper(ins.quad[2]) output.append('call __ABS16') output.append('push hl') REQUIRES.add('abs16.asm') return output
[ "def", "_abs16", "(", "ins", ")", ":", "output", "=", "_16bit_oper", "(", "ins", ".", "quad", "[", "2", "]", ")", "output", ".", "append", "(", "'call __ABS16'", ")", "output", ".", "append", "(", "'push hl'", ")", "REQUIRES", ".", "add", "(", "'abs1...
Absolute value of top of the stack (16 bits in HL)
[ "Absolute", "value", "of", "top", "of", "the", "stack", "(", "16", "bits", "in", "HL", ")" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__16bit.py#L884-L891
boriel/zxbasic
arch/zx48k/backend/__16bit.py
_shru16
def _shru16(ins): ''' Logical right shift 16bit unsigned integer. The result is pushed onto the stack. Optimizations: * If 2nd op is 0 then do nothing * If 2nd op is 1 Shift Right Arithmetic ''' op1, op2 = tuple(ins.quad[2:]) if is_int(op2): op = int16(op2) ...
python
def _shru16(ins): ''' Logical right shift 16bit unsigned integer. The result is pushed onto the stack. Optimizations: * If 2nd op is 0 then do nothing * If 2nd op is 1 Shift Right Arithmetic ''' op1, op2 = tuple(ins.quad[2:]) if is_int(op2): op = int16(op2) ...
[ "def", "_shru16", "(", "ins", ")", ":", "op1", ",", "op2", "=", "tuple", "(", "ins", ".", "quad", "[", "2", ":", "]", ")", "if", "is_int", "(", "op2", ")", ":", "op", "=", "int16", "(", "op2", ")", "if", "op", "==", "0", ":", "return", "[",...
Logical right shift 16bit unsigned integer. The result is pushed onto the stack. Optimizations: * If 2nd op is 0 then do nothing * If 2nd op is 1 Shift Right Arithmetic
[ "Logical", "right", "shift", "16bit", "unsigned", "integer", ".", "The", "result", "is", "pushed", "onto", "the", "stack", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__16bit.py#L894-L930
boriel/zxbasic
outfmt/tap.py
TAP.standard_block
def standard_block(self, bytes_): """Adds a standard block of bytes. For TAP files, it's just the Low + Hi byte plus the content (here, the bytes plus the checksum) """ self.out(self.LH(len(bytes_) + 1)) # + 1 for CHECKSUM byte checksum = 0 for i in bytes_: ...
python
def standard_block(self, bytes_): """Adds a standard block of bytes. For TAP files, it's just the Low + Hi byte plus the content (here, the bytes plus the checksum) """ self.out(self.LH(len(bytes_) + 1)) # + 1 for CHECKSUM byte checksum = 0 for i in bytes_: ...
[ "def", "standard_block", "(", "self", ",", "bytes_", ")", ":", "self", ".", "out", "(", "self", ".", "LH", "(", "len", "(", "bytes_", ")", "+", "1", ")", ")", "# + 1 for CHECKSUM byte", "checksum", "=", "0", "for", "i", "in", "bytes_", ":", "checksum...
Adds a standard block of bytes. For TAP files, it's just the Low + Hi byte plus the content (here, the bytes plus the checksum)
[ "Adds", "a", "standard", "block", "of", "bytes", ".", "For", "TAP", "files", "it", "s", "just", "the", "Low", "+", "Hi", "byte", "plus", "the", "content", "(", "here", "the", "bytes", "plus", "the", "checksum", ")" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/outfmt/tap.py#L28-L39
boriel/zxbasic
api/utils.py
read_txt_file
def read_txt_file(fname): """Reads a txt file, regardless of its encoding """ encodings = ['utf-8-sig', 'cp1252'] with open(fname, 'rb') as f: content = bytes(f.read()) for i in encodings: try: result = content.decode(i) if six.PY2: result = r...
python
def read_txt_file(fname): """Reads a txt file, regardless of its encoding """ encodings = ['utf-8-sig', 'cp1252'] with open(fname, 'rb') as f: content = bytes(f.read()) for i in encodings: try: result = content.decode(i) if six.PY2: result = r...
[ "def", "read_txt_file", "(", "fname", ")", ":", "encodings", "=", "[", "'utf-8-sig'", ",", "'cp1252'", "]", "with", "open", "(", "fname", ",", "'rb'", ")", "as", "f", ":", "content", "=", "bytes", "(", "f", ".", "read", "(", ")", ")", "for", "i", ...
Reads a txt file, regardless of its encoding
[ "Reads", "a", "txt", "file", "regardless", "of", "its", "encoding" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/utils.py#L15-L33
boriel/zxbasic
api/utils.py
open_file
def open_file(fname, mode='rb', encoding='utf-8'): """ An open() wrapper for PY2 and PY3 which allows encoding :param fname: file name (string) :param mode: file mode (string) optional :param encoding: optional encoding (string). Ignored in python2 or if not in text mode :return: an open file handle...
python
def open_file(fname, mode='rb', encoding='utf-8'): """ An open() wrapper for PY2 and PY3 which allows encoding :param fname: file name (string) :param mode: file mode (string) optional :param encoding: optional encoding (string). Ignored in python2 or if not in text mode :return: an open file handle...
[ "def", "open_file", "(", "fname", ",", "mode", "=", "'rb'", ",", "encoding", "=", "'utf-8'", ")", ":", "if", "six", ".", "PY2", "or", "'t'", "not", "in", "mode", ":", "kwargs", "=", "{", "}", "else", ":", "kwargs", "=", "{", "'encoding'", ":", "e...
An open() wrapper for PY2 and PY3 which allows encoding :param fname: file name (string) :param mode: file mode (string) optional :param encoding: optional encoding (string). Ignored in python2 or if not in text mode :return: an open file handle
[ "An", "open", "()", "wrapper", "for", "PY2", "and", "PY3", "which", "allows", "encoding", ":", "param", "fname", ":", "file", "name", "(", "string", ")", ":", "param", "mode", ":", "file", "mode", "(", "string", ")", "optional", ":", "param", "encoding...
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/utils.py#L36-L48
boriel/zxbasic
api/utils.py
parse_int
def parse_int(str_num): """ Given an integer number, return its value, or None if it could not be parsed. Allowed formats: DECIMAL, HEXA (0xnnn, $nnnn or nnnnh) :param str_num: (string) the number to be parsed :return: an integer number or None if it could not be parsedd """ str_num = (str_n...
python
def parse_int(str_num): """ Given an integer number, return its value, or None if it could not be parsed. Allowed formats: DECIMAL, HEXA (0xnnn, $nnnn or nnnnh) :param str_num: (string) the number to be parsed :return: an integer number or None if it could not be parsedd """ str_num = (str_n...
[ "def", "parse_int", "(", "str_num", ")", ":", "str_num", "=", "(", "str_num", "or", "\"\"", ")", ".", "strip", "(", ")", ".", "upper", "(", ")", "if", "not", "str_num", ":", "return", "None", "base", "=", "10", "if", "str_num", ".", "startswith", "...
Given an integer number, return its value, or None if it could not be parsed. Allowed formats: DECIMAL, HEXA (0xnnn, $nnnn or nnnnh) :param str_num: (string) the number to be parsed :return: an integer number or None if it could not be parsedd
[ "Given", "an", "integer", "number", "return", "its", "value", "or", "None", "if", "it", "could", "not", "be", "parsed", ".", "Allowed", "formats", ":", "DECIMAL", "HEXA", "(", "0xnnn", "$nnnn", "or", "nnnnh", ")", ":", "param", "str_num", ":", "(", "st...
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/utils.py#L77-L102
boriel/zxbasic
outfmt/tzx.py
TZX.out
def out(self, l): """ Adds a list of bytes to the output string """ if not isinstance(l, list): l = [l] self.output.extend([int(i) & 0xFF for i in l])
python
def out(self, l): """ Adds a list of bytes to the output string """ if not isinstance(l, list): l = [l] self.output.extend([int(i) & 0xFF for i in l])
[ "def", "out", "(", "self", ",", "l", ")", ":", "if", "not", "isinstance", "(", "l", ",", "list", ")", ":", "l", "=", "[", "l", "]", "self", ".", "output", ".", "extend", "(", "[", "int", "(", "i", ")", "&", "0xFF", "for", "i", "in", "l", ...
Adds a list of bytes to the output string
[ "Adds", "a", "list", "of", "bytes", "to", "the", "output", "string" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/outfmt/tzx.py#L52-L58
boriel/zxbasic
outfmt/tzx.py
TZX.standard_block
def standard_block(self, _bytes): """ Adds a standard block of bytes """ self.out(self.BLOCK_STANDARD) # Standard block ID self.out(self.LH(1000)) # 1000 ms standard pause self.out(self.LH(len(_bytes) + 1)) # + 1 for CHECKSUM byte checksum = 0 for i in _bytes:...
python
def standard_block(self, _bytes): """ Adds a standard block of bytes """ self.out(self.BLOCK_STANDARD) # Standard block ID self.out(self.LH(1000)) # 1000 ms standard pause self.out(self.LH(len(_bytes) + 1)) # + 1 for CHECKSUM byte checksum = 0 for i in _bytes:...
[ "def", "standard_block", "(", "self", ",", "_bytes", ")", ":", "self", ".", "out", "(", "self", ".", "BLOCK_STANDARD", ")", "# Standard block ID", "self", ".", "out", "(", "self", ".", "LH", "(", "1000", ")", ")", "# 1000 ms standard pause", "self", ".", ...
Adds a standard block of bytes
[ "Adds", "a", "standard", "block", "of", "bytes" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/outfmt/tzx.py#L60-L72
boriel/zxbasic
outfmt/tzx.py
TZX.dump
def dump(self, fname): """ Saves TZX file to fname """ with open(fname, 'wb') as f: f.write(self.output)
python
def dump(self, fname): """ Saves TZX file to fname """ with open(fname, 'wb') as f: f.write(self.output)
[ "def", "dump", "(", "self", ",", "fname", ")", ":", "with", "open", "(", "fname", ",", "'wb'", ")", "as", "f", ":", "f", ".", "write", "(", "self", ".", "output", ")" ]
Saves TZX file to fname
[ "Saves", "TZX", "file", "to", "fname" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/outfmt/tzx.py#L74-L78
boriel/zxbasic
outfmt/tzx.py
TZX.save_header
def save_header(self, _type, title, length, param1, param2): """ Saves a generic standard header: type: 00 -- Program 01 -- Number Array 02 -- Char Array 03 -- Code title: Name title. ...
python
def save_header(self, _type, title, length, param1, param2): """ Saves a generic standard header: type: 00 -- Program 01 -- Number Array 02 -- Char Array 03 -- Code title: Name title. ...
[ "def", "save_header", "(", "self", ",", "_type", ",", "title", ",", "length", ",", "param1", ",", "param2", ")", ":", "title", "=", "(", "title", "+", "10", "*", "' '", ")", "[", ":", "10", "]", "# Padd it with spaces", "title_bytes", "=", "[", "ord"...
Saves a generic standard header: type: 00 -- Program 01 -- Number Array 02 -- Char Array 03 -- Code title: Name title. Will be truncated to 10 chars and padded with...
[ "Saves", "a", "generic", "standard", "header", ":", "type", ":", "00", "--", "Program", "01", "--", "Number", "Array", "02", "--", "Char", "Array", "03", "--", "Code" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/outfmt/tzx.py#L80-L107
boriel/zxbasic
outfmt/tzx.py
TZX.standard_bytes_header
def standard_bytes_header(self, title, addr, length): """ Generates a standard header block of CODE type """ self.save_header(self.HEADER_TYPE_CODE, title, length, param1=addr, param2=32768)
python
def standard_bytes_header(self, title, addr, length): """ Generates a standard header block of CODE type """ self.save_header(self.HEADER_TYPE_CODE, title, length, param1=addr, param2=32768)
[ "def", "standard_bytes_header", "(", "self", ",", "title", ",", "addr", ",", "length", ")", ":", "self", ".", "save_header", "(", "self", ".", "HEADER_TYPE_CODE", ",", "title", ",", "length", ",", "param1", "=", "addr", ",", "param2", "=", "32768", ")" ]
Generates a standard header block of CODE type
[ "Generates", "a", "standard", "header", "block", "of", "CODE", "type" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/outfmt/tzx.py#L109-L112
boriel/zxbasic
outfmt/tzx.py
TZX.standard_program_header
def standard_program_header(self, title, length, line=32768): """ Generates a standard header block of PROGRAM type """ self.save_header(self.HEADER_TYPE_BASIC, title, length, param1=line, param2=length)
python
def standard_program_header(self, title, length, line=32768): """ Generates a standard header block of PROGRAM type """ self.save_header(self.HEADER_TYPE_BASIC, title, length, param1=line, param2=length)
[ "def", "standard_program_header", "(", "self", ",", "title", ",", "length", ",", "line", "=", "32768", ")", ":", "self", ".", "save_header", "(", "self", ".", "HEADER_TYPE_BASIC", ",", "title", ",", "length", ",", "param1", "=", "line", ",", "param2", "=...
Generates a standard header block of PROGRAM type
[ "Generates", "a", "standard", "header", "block", "of", "PROGRAM", "type" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/outfmt/tzx.py#L114-L117
boriel/zxbasic
outfmt/tzx.py
TZX.save_code
def save_code(self, title, addr, _bytes): """ Saves the given bytes as code. If bytes are strings, its chars will be converted to bytes """ self.standard_bytes_header(title, addr, len(_bytes)) _bytes = [self.BLOCK_TYPE_DATA] + [(int(x) & 0xFF) for x in _bytes] # & 0xFF truncates...
python
def save_code(self, title, addr, _bytes): """ Saves the given bytes as code. If bytes are strings, its chars will be converted to bytes """ self.standard_bytes_header(title, addr, len(_bytes)) _bytes = [self.BLOCK_TYPE_DATA] + [(int(x) & 0xFF) for x in _bytes] # & 0xFF truncates...
[ "def", "save_code", "(", "self", ",", "title", ",", "addr", ",", "_bytes", ")", ":", "self", ".", "standard_bytes_header", "(", "title", ",", "addr", ",", "len", "(", "_bytes", ")", ")", "_bytes", "=", "[", "self", ".", "BLOCK_TYPE_DATA", "]", "+", "...
Saves the given bytes as code. If bytes are strings, its chars will be converted to bytes
[ "Saves", "the", "given", "bytes", "as", "code", ".", "If", "bytes", "are", "strings", "its", "chars", "will", "be", "converted", "to", "bytes" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/outfmt/tzx.py#L119-L125
boriel/zxbasic
outfmt/tzx.py
TZX.save_program
def save_program(self, title, bytes, line=32768): """ Saves the given bytes as a BASIC program. """ self.standard_program_header(title, len(bytes), line) bytes = [self.BLOCK_TYPE_DATA] + [(int(x) & 0xFF) for x in bytes] # & 0xFF truncates to bytes self.standard_block(bytes)
python
def save_program(self, title, bytes, line=32768): """ Saves the given bytes as a BASIC program. """ self.standard_program_header(title, len(bytes), line) bytes = [self.BLOCK_TYPE_DATA] + [(int(x) & 0xFF) for x in bytes] # & 0xFF truncates to bytes self.standard_block(bytes)
[ "def", "save_program", "(", "self", ",", "title", ",", "bytes", ",", "line", "=", "32768", ")", ":", "self", ".", "standard_program_header", "(", "title", ",", "len", "(", "bytes", ")", ",", "line", ")", "bytes", "=", "[", "self", ".", "BLOCK_TYPE_DATA...
Saves the given bytes as a BASIC program.
[ "Saves", "the", "given", "bytes", "as", "a", "BASIC", "program", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/outfmt/tzx.py#L127-L132
boriel/zxbasic
symbols/strslice.py
SymbolSTRSLICE.make_node
def make_node(cls, lineno, s, lower, upper): """ Creates a node for a string slice. S is the string expression Tree. Lower and upper are the bounds, if lower & upper are constants, and s is also constant, then a string constant is returned. If lower > upper, an empty string is returned....
python
def make_node(cls, lineno, s, lower, upper): """ Creates a node for a string slice. S is the string expression Tree. Lower and upper are the bounds, if lower & upper are constants, and s is also constant, then a string constant is returned. If lower > upper, an empty string is returned....
[ "def", "make_node", "(", "cls", ",", "lineno", ",", "s", ",", "lower", ",", "upper", ")", ":", "if", "lower", "is", "None", "or", "upper", "is", "None", "or", "s", "is", "None", ":", "return", "None", "if", "not", "check_type", "(", "lineno", ",", ...
Creates a node for a string slice. S is the string expression Tree. Lower and upper are the bounds, if lower & upper are constants, and s is also constant, then a string constant is returned. If lower > upper, an empty string is returned.
[ "Creates", "a", "node", "for", "a", "string", "slice", ".", "S", "is", "the", "string", "expression", "Tree", ".", "Lower", "and", "upper", "are", "the", "bounds", "if", "lower", "&", "upper", "are", "constants", "and", "s", "is", "also", "constant", "...
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/symbols/strslice.py#L69-L117
boriel/zxbasic
arch/zx48k/backend/__init__.py
init
def init(): """ Initializes this module """ global ASMS global ASMCOUNT global AT_END global FLAG_end_emitted global FLAG_use_function_exit __common.init() ASMS = {} ASMCOUNT = 0 AT_END = [] FLAG_use_function_exit = False FLAG_end_emitted = False # Default code...
python
def init(): """ Initializes this module """ global ASMS global ASMCOUNT global AT_END global FLAG_end_emitted global FLAG_use_function_exit __common.init() ASMS = {} ASMCOUNT = 0 AT_END = [] FLAG_use_function_exit = False FLAG_end_emitted = False # Default code...
[ "def", "init", "(", ")", ":", "global", "ASMS", "global", "ASMCOUNT", "global", "AT_END", "global", "FLAG_end_emitted", "global", "FLAG_use_function_exit", "__common", ".", "init", "(", ")", "ASMS", "=", "{", "}", "ASMCOUNT", "=", "0", "AT_END", "=", "[", ...
Initializes this module
[ "Initializes", "this", "module" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L189-L215
boriel/zxbasic
arch/zx48k/backend/__init__.py
to_byte
def to_byte(stype): """ Returns the instruction sequence for converting from the given type to byte. """ output = [] if stype in ('i8', 'u8'): return [] if is_int_type(stype): output.append('ld a, l') elif stype == 'f16': output.append('ld a, e') elif stype == '...
python
def to_byte(stype): """ Returns the instruction sequence for converting from the given type to byte. """ output = [] if stype in ('i8', 'u8'): return [] if is_int_type(stype): output.append('ld a, l') elif stype == 'f16': output.append('ld a, e') elif stype == '...
[ "def", "to_byte", "(", "stype", ")", ":", "output", "=", "[", "]", "if", "stype", "in", "(", "'i8'", ",", "'u8'", ")", ":", "return", "[", "]", "if", "is_int_type", "(", "stype", ")", ":", "output", ".", "append", "(", "'ld a, l'", ")", "elif", "...
Returns the instruction sequence for converting from the given type to byte.
[ "Returns", "the", "instruction", "sequence", "for", "converting", "from", "the", "given", "type", "to", "byte", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L252-L270
boriel/zxbasic
arch/zx48k/backend/__init__.py
to_word
def to_word(stype): """ Returns the instruction sequence for converting the given type stored in DE,HL to word (unsigned) HL. """ output = [] # List of instructions if stype == 'u8': # Byte to word output.append('ld l, a') output.append('ld h, 0') elif stype == 'i8': # Signe...
python
def to_word(stype): """ Returns the instruction sequence for converting the given type stored in DE,HL to word (unsigned) HL. """ output = [] # List of instructions if stype == 'u8': # Byte to word output.append('ld l, a') output.append('ld h, 0') elif stype == 'i8': # Signe...
[ "def", "to_word", "(", "stype", ")", ":", "output", "=", "[", "]", "# List of instructions", "if", "stype", "==", "'u8'", ":", "# Byte to word", "output", ".", "append", "(", "'ld l, a'", ")", "output", ".", "append", "(", "'ld h, 0'", ")", "elif", "stype"...
Returns the instruction sequence for converting the given type stored in DE,HL to word (unsigned) HL.
[ "Returns", "the", "instruction", "sequence", "for", "converting", "the", "given", "type", "stored", "in", "DE", "HL", "to", "word", "(", "unsigned", ")", "HL", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L273-L296
boriel/zxbasic
arch/zx48k/backend/__init__.py
to_fixed
def to_fixed(stype): """ Returns the instruction sequence for converting the given type stored in DE,HL to fixed DE,HL. """ output = [] # List of instructions if is_int_type(stype): output = to_word(stype) output.append('ex de, hl') output.append('ld hl, 0') # 'Truncate' t...
python
def to_fixed(stype): """ Returns the instruction sequence for converting the given type stored in DE,HL to fixed DE,HL. """ output = [] # List of instructions if is_int_type(stype): output = to_word(stype) output.append('ex de, hl') output.append('ld hl, 0') # 'Truncate' t...
[ "def", "to_fixed", "(", "stype", ")", ":", "output", "=", "[", "]", "# List of instructions", "if", "is_int_type", "(", "stype", ")", ":", "output", "=", "to_word", "(", "stype", ")", "output", ".", "append", "(", "'ex de, hl'", ")", "output", ".", "appe...
Returns the instruction sequence for converting the given type stored in DE,HL to fixed DE,HL.
[ "Returns", "the", "instruction", "sequence", "for", "converting", "the", "given", "type", "stored", "in", "DE", "HL", "to", "fixed", "DE", "HL", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L329-L343
boriel/zxbasic
arch/zx48k/backend/__init__.py
to_float
def to_float(stype): """ Returns the instruction sequence for converting the given type stored in DE,HL to fixed DE,HL. """ output = [] # List of instructions if stype == 'f': return [] # Nothing to do if stype == 'f16': output.append('call __F16TOFREG') REQUIRES.add(...
python
def to_float(stype): """ Returns the instruction sequence for converting the given type stored in DE,HL to fixed DE,HL. """ output = [] # List of instructions if stype == 'f': return [] # Nothing to do if stype == 'f16': output.append('call __F16TOFREG') REQUIRES.add(...
[ "def", "to_float", "(", "stype", ")", ":", "output", "=", "[", "]", "# List of instructions", "if", "stype", "==", "'f'", ":", "return", "[", "]", "# Nothing to do", "if", "stype", "==", "'f16'", ":", "output", ".", "append", "(", "'call __F16TOFREG'", ")"...
Returns the instruction sequence for converting the given type stored in DE,HL to fixed DE,HL.
[ "Returns", "the", "instruction", "sequence", "for", "converting", "the", "given", "type", "stored", "in", "DE", "HL", "to", "fixed", "DE", "HL", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L346-L374
boriel/zxbasic
arch/zx48k/backend/__init__.py
_end
def _end(ins): """ Outputs the ending sequence """ global FLAG_end_emitted output = _16bit_oper(ins.quad[1]) output.append('ld b, h') output.append('ld c, l') if FLAG_end_emitted: return output + ['jp %s' % END_LABEL] FLAG_end_emitted = True output.append('%s:' % END_LABEL...
python
def _end(ins): """ Outputs the ending sequence """ global FLAG_end_emitted output = _16bit_oper(ins.quad[1]) output.append('ld b, h') output.append('ld c, l') if FLAG_end_emitted: return output + ['jp %s' % END_LABEL] FLAG_end_emitted = True output.append('%s:' % END_LABEL...
[ "def", "_end", "(", "ins", ")", ":", "global", "FLAG_end_emitted", "output", "=", "_16bit_oper", "(", "ins", ".", "quad", "[", "1", "]", ")", "output", ".", "append", "(", "'ld b, h'", ")", "output", ".", "append", "(", "'ld c, l'", ")", "if", "FLAG_en...
Outputs the ending sequence
[ "Outputs", "the", "ending", "sequence" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L403-L433
boriel/zxbasic
arch/zx48k/backend/__init__.py
_data
def _data(ins): """ Defines a data item (binary). It's just a constant expression to be converted do binary data "as is" 1st parameter is the type-size (u8 or i8 for byte, u16 or i16 for word, etc) 2nd parameter is the list of expressions. All of them will be converted to the type required. ...
python
def _data(ins): """ Defines a data item (binary). It's just a constant expression to be converted do binary data "as is" 1st parameter is the type-size (u8 or i8 for byte, u16 or i16 for word, etc) 2nd parameter is the list of expressions. All of them will be converted to the type required. ...
[ "def", "_data", "(", "ins", ")", ":", "output", "=", "[", "]", "t", "=", "ins", ".", "quad", "[", "1", "]", "q", "=", "eval", "(", "ins", ".", "quad", "[", "2", "]", ")", "if", "t", "in", "(", "'i8'", ",", "'u8'", ")", ":", "size", "=", ...
Defines a data item (binary). It's just a constant expression to be converted do binary data "as is" 1st parameter is the type-size (u8 or i8 for byte, u16 or i16 for word, etc) 2nd parameter is the list of expressions. All of them will be converted to the type required.
[ "Defines", "a", "data", "item", "(", "binary", ")", ".", "It", "s", "just", "a", "constant", "expression", "to", "be", "converted", "do", "binary", "data", "as", "is" ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L448-L484
boriel/zxbasic
arch/zx48k/backend/__init__.py
_var
def _var(ins): """ Defines a memory variable. """ output = [] output.append('%s:' % ins.quad[1]) output.append('DEFB %s' % ((int(ins.quad[2]) - 1) * '00, ' + '00')) return output
python
def _var(ins): """ Defines a memory variable. """ output = [] output.append('%s:' % ins.quad[1]) output.append('DEFB %s' % ((int(ins.quad[2]) - 1) * '00, ' + '00')) return output
[ "def", "_var", "(", "ins", ")", ":", "output", "=", "[", "]", "output", ".", "append", "(", "'%s:'", "%", "ins", ".", "quad", "[", "1", "]", ")", "output", ".", "append", "(", "'DEFB %s'", "%", "(", "(", "int", "(", "ins", ".", "quad", "[", "...
Defines a memory variable.
[ "Defines", "a", "memory", "variable", "." ]
train
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L487-L494