|
@@ -44,6 +44,31 @@ MISC_INTRINSICS = {
|
|
|
tree_ir.CreateNodeWithValueInstruction(
|
|
|
tree_ir.BinaryInstruction(lhs, '!=', rhs)),
|
|
|
|
|
|
+ # Strings
|
|
|
+ 'string_get' :
|
|
|
+ lambda str_node, index_node:
|
|
|
+ tree_ir.CreateNodeWithValueInstruction(
|
|
|
+ tree_ir.LoadIndexInstruction(
|
|
|
+ tree_ir.ReadValueInstruction(str_node),
|
|
|
+ tree_ir.ReadValueInstruction(index_node))),
|
|
|
+ 'string_len' :
|
|
|
+ lambda str_node:
|
|
|
+ tree_ir.CreateNodeWithValueInstruction(
|
|
|
+ tree_ir.CallInstruction(
|
|
|
+ tree_ir.LoadGlobalInstruction('len'),
|
|
|
+ [tree_ir.ReadValueInstruction(str_node)])),
|
|
|
+ 'string_join' :
|
|
|
+ lambda lhs, rhs:
|
|
|
+ tree_ir.CreateNodeWithValueInstruction(
|
|
|
+ tree_ir.BinaryInstruction(
|
|
|
+ tree_ir.CallInstruction(
|
|
|
+ tree_ir.LoadGlobalInstruction('str'),
|
|
|
+ [tree_ir.ReadValueInstruction(lhs)]),
|
|
|
+ '+',
|
|
|
+ tree_ir.CallInstruction(
|
|
|
+ tree_ir.LoadGlobalInstruction('str'),
|
|
|
+ [tree_ir.ReadValueInstruction(rhs)]))),
|
|
|
+
|
|
|
# State creation
|
|
|
'create_node' : tree_ir.CreateNodeInstruction,
|
|
|
'create_edge' : tree_ir.CreateEdgeInstruction,
|