Graham Northup 5 years ago
parent
commit
f2df4b8cc7
25 changed files with 8116 additions and 4802 deletions
  1. 2
    0
      .gitignore
  2. 2434
    0
      Doxyfile
  3. 1
    1
      build.sh
  4. 14
    2
      builtins.c
  5. 302
    0
      conf.py
  6. 7
    0
      doc.sh
  7. 24
    0
      doc/index.rst
  8. 18
    0
      doc/lang/abs_basics.rst
  9. 20
    0
      doc/lang/index.rst
  10. 26
    0
      doc/lang/simple_exprs.rst
  11. 9
    0
      doc/src/ast_h.rst
  12. 15
    0
      doc/src/index.rst
  13. 9
    0
      doc/src/sol_h.rst
  14. 163
    141
      lex.yy.c
  15. 40
    12
      object.c
  16. 0
    0
      old-sol-gdb.py
  17. 4247
    3949
      parser.output
  18. 491
    447
      parser.tab.c
  19. 53
    52
      parser.tab.h
  20. 12
    1
      parser.y
  21. 1
    1
      runtime.c
  22. 25
    8
      sol.h
  23. 19
    17
      solrun.c
  24. 182
    171
      state.c
  25. 2
    0
      tokenizer.lex

+ 2
- 0
.gitignore View File

@@ -8,3 +8,5 @@ gclog.txt
8 8
 gcstat.txt
9 9
 iss*
10 10
 *.sol
11
+_build
12
+doxyxml

+ 2434
- 0
Doxyfile
File diff suppressed because it is too large
View File


+ 1
- 1
build.sh View File

@@ -9,7 +9,7 @@ if [ -z "$CFLAGS" ]; then
9 9
 	# -DDEBUG_GC : Turn on debug GC (all memory allocates/frees go to a file, use gcstat.py to get statistics)
10 10
 	# -DSOL_ICACHE_MIN : Minimum integer to cache in the state
11 11
 	# -DSOL_ICACHE_MAX : Maximum integer to cache in the state (if MAX < MIN, caching is disabled)
12
-    CFLAGS="-g"
12
+    CFLAGS="-g -DDEBUG_GC"
13 13
 fi
14 14
 
15 15
 gcc -c $CFLAGS dsl/seq.c

+ 14
- 2
builtins.c View File

@@ -100,6 +100,8 @@ sol_object_t *sol_f_try(sol_state_t *state, sol_object_t *args) {
100 100
 		sol_list_insert(state, ls, 0, zero);
101 101
 		sol_obj_free(zero);
102 102
 		sol_list_insert(state, ls, 2, state->traceback);
103
+		sol_obj_free(state->traceback);
104
+		state->traceback = NULL;
103 105
 		return ls;
104 106
 	}
105 107
 	sol_list_insert(state, ls, 0, res);
@@ -2026,13 +2028,23 @@ sol_object_t *sol_f_astnode_tostring(sol_state_t *state, sol_object_t *args) {
2026 2028
 		if(!obj->node) {
2027 2029
 			snprintf(s, 64, "<NULL Stmt>");
2028 2030
 		} else {
2029
-			snprintf(s, 64, "<Stmt[%s]>", sol_StmtNames[((stmt_node *)obj->node)->type]);
2031
+			stmt_t type = ((stmt_node *) obj->node)->type;
2032
+			if(type < sizeof(sol_StmtNames)/sizeof(char *)) {
2033
+				snprintf(s, 64, "<Stmt[%s]>", sol_StmtNames[type]);
2034
+			} else {
2035
+				snprintf(s, 64, "<Invalid Stmt>");
2036
+			}
2030 2037
 		}
2031 2038
 	} else {
2032 2039
 		if(!obj->node) {
2033 2040
 			snprintf(s, 64, "<NULL Expr>");
2034 2041
 		} else {
2035
-			snprintf(s, 64, "<Expr[%s]>", sol_ExprNames[((expr_node *)obj->node)->type]);
2042
+			expr_t type = ((stmt_node *) obj->node)->type;
2043
+			if(type < sizeof(sol_ExprNames)/sizeof(char *)) {
2044
+				snprintf(s, 64, "<Expr[%s]>", sol_ExprNames[type]);
2045
+			} else {
2046
+				snprintf(s, 64, "<Invalid Expr>");
2047
+			}
2036 2048
 		}
2037 2049
 	}
2038 2050
 	sol_obj_free(obj);

+ 302
- 0
conf.py View File

@@ -0,0 +1,302 @@
1
+# -*- coding: utf-8 -*-
2
+#
3
+# Sol documentation build configuration file, created by
4
+# sphinx-quickstart on Mon Oct 19 11:40:28 2015.
5
+#
6
+# This file is execfile()d with the current directory set to its
7
+# containing dir.
8
+#
9
+# Note that not all possible configuration values are present in this
10
+# autogenerated file.
11
+#
12
+# All configuration values have a default; values that are commented out
13
+# serve to show the default.
14
+
15
+import sys
16
+import os
17
+import shlex
18
+
19
+# If extensions (or modules to document with autodoc) are in another directory,
20
+# add these directories to sys.path here. If the directory is relative to the
21
+# documentation root, use os.path.abspath to make it absolute, like shown here.
22
+#sys.path.insert(0, os.path.abspath('.'))
23
+
24
+# -- General configuration ------------------------------------------------
25
+
26
+# If your documentation needs a minimal Sphinx version, state it here.
27
+#needs_sphinx = '1.0'
28
+
29
+# Add any Sphinx extension module names here, as strings. They can be
30
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
31
+# ones.
32
+extensions = [
33
+    'sphinx.ext.autodoc',
34
+    'sphinx.ext.todo',
35
+    'sphinx.ext.coverage',
36
+    'sphinx.ext.mathjax',
37
+    'sphinx.ext.viewcode',
38
+    'breathe',
39
+]
40
+
41
+# Add any paths that contain templates here, relative to this directory.
42
+templates_path = ['_templates']
43
+
44
+# The suffix(es) of source filenames.
45
+# You can specify multiple suffix as a list of string:
46
+# source_suffix = ['.rst', '.md']
47
+source_suffix = '.rst'
48
+
49
+# The encoding of source files.
50
+#source_encoding = 'utf-8-sig'
51
+
52
+# The master toctree document.
53
+master_doc = 'doc/index'
54
+
55
+# General information about the project.
56
+project = u'Sol'
57
+copyright = u'2015, Grissess et. al.'
58
+author = u'Grissess et. al.'
59
+
60
+# The version info for the project you're documenting, acts as replacement for
61
+# |version| and |release|, also used in various other places throughout the
62
+# built documents.
63
+#
64
+# The short X.Y version.
65
+version = '0.1'
66
+# The full version, including alpha/beta/rc tags.
67
+release = '0.1a4'
68
+
69
+# Breathe's own information about the project.
70
+breathe_projects = {
71
+    project: 'doxyxml/xml',
72
+}
73
+breathe_default_project = project
74
+breathe_projects_souce = {
75
+    project: '.',
76
+}
77
+
78
+# The language for content autogenerated by Sphinx. Refer to documentation
79
+# for a list of supported languages.
80
+#
81
+# This is also used if you do content translation via gettext catalogs.
82
+# Usually you set "language" from the command line for these cases.
83
+language = None
84
+
85
+# There are two options for replacing |today|: either, you set today to some
86
+# non-false value, then it is used:
87
+#today = ''
88
+# Else, today_fmt is used as the format for a strftime call.
89
+#today_fmt = '%B %d, %Y'
90
+
91
+# List of patterns, relative to source directory, that match files and
92
+# directories to ignore when looking for source files.
93
+exclude_patterns = ['_build']
94
+
95
+# The reST default role (used for this markup: `text`) to use for all
96
+# documents.
97
+default_role = 'any'
98
+
99
+# If true, '()' will be appended to :func: etc. cross-reference text.
100
+#add_function_parentheses = True
101
+
102
+# If true, the current module name will be prepended to all description
103
+# unit titles (such as .. function::).
104
+#add_module_names = True
105
+
106
+# If true, sectionauthor and moduleauthor directives will be shown in the
107
+# output. They are ignored by default.
108
+#show_authors = False
109
+
110
+# The name of the Pygments (syntax highlighting) style to use.
111
+pygments_style = 'sphinx'
112
+
113
+# A list of ignored prefixes for module index sorting.
114
+#modindex_common_prefix = []
115
+
116
+# If true, keep warnings as "system message" paragraphs in the built documents.
117
+#keep_warnings = False
118
+
119
+# If true, `todo` and `todoList` produce output, else they produce nothing.
120
+todo_include_todos = True
121
+
122
+
123
+# -- Options for HTML output ----------------------------------------------
124
+
125
+# The theme to use for HTML and HTML Help pages.  See the documentation for
126
+# a list of builtin themes.
127
+html_theme = 'alabaster'
128
+
129
+# Theme options are theme-specific and customize the look and feel of a theme
130
+# further.  For a list of options available for each theme, see the
131
+# documentation.
132
+#html_theme_options = {}
133
+
134
+# Add any paths that contain custom themes here, relative to this directory.
135
+#html_theme_path = []
136
+
137
+# The name for this set of Sphinx documents.  If None, it defaults to
138
+# "<project> v<release> documentation".
139
+#html_title = None
140
+
141
+# A shorter title for the navigation bar.  Default is the same as html_title.
142
+#html_short_title = None
143
+
144
+# The name of an image file (relative to this directory) to place at the top
145
+# of the sidebar.
146
+#html_logo = None
147
+
148
+# The name of an image file (within the static path) to use as favicon of the
149
+# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
150
+# pixels large.
151
+#html_favicon = None
152
+
153
+# Add any paths that contain custom static files (such as style sheets) here,
154
+# relative to this directory. They are copied after the builtin static files,
155
+# so a file named "default.css" will overwrite the builtin "default.css".
156
+html_static_path = ['_static']
157
+
158
+# Add any extra paths that contain custom files (such as robots.txt or
159
+# .htaccess) here, relative to this directory. These files are copied
160
+# directly to the root of the documentation.
161
+#html_extra_path = []
162
+
163
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
164
+# using the given strftime format.
165
+#html_last_updated_fmt = '%b %d, %Y'
166
+
167
+# If true, SmartyPants will be used to convert quotes and dashes to
168
+# typographically correct entities.
169
+#html_use_smartypants = True
170
+
171
+# Custom sidebar templates, maps document names to template names.
172
+#html_sidebars = {}
173
+
174
+# Additional templates that should be rendered to pages, maps page names to
175
+# template names.
176
+#html_additional_pages = {}
177
+
178
+# If false, no module index is generated.
179
+#html_domain_indices = True
180
+
181
+# If false, no index is generated.
182
+#html_use_index = True
183
+
184
+# If true, the index is split into individual pages for each letter.
185
+#html_split_index = False
186
+
187
+# If true, links to the reST sources are added to the pages.
188
+#html_show_sourcelink = True
189
+
190
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
191
+#html_show_sphinx = True
192
+
193
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
194
+#html_show_copyright = True
195
+
196
+# If true, an OpenSearch description file will be output, and all pages will
197
+# contain a <link> tag referring to it.  The value of this option must be the
198
+# base URL from which the finished HTML is served.
199
+#html_use_opensearch = ''
200
+
201
+# This is the file name suffix for HTML files (e.g. ".xhtml").
202
+#html_file_suffix = None
203
+
204
+# Language to be used for generating the HTML full-text search index.
205
+# Sphinx supports the following languages:
206
+#   'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
207
+#   'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr'
208
+#html_search_language = 'en'
209
+
210
+# A dictionary with options for the search language support, empty by default.
211
+# Now only 'ja' uses this config value
212
+#html_search_options = {'type': 'default'}
213
+
214
+# The name of a javascript file (relative to the configuration directory) that
215
+# implements a search results scorer. If empty, the default will be used.
216
+#html_search_scorer = 'scorer.js'
217
+
218
+# Output file base name for HTML help builder.
219
+htmlhelp_basename = 'Soldoc'
220
+
221
+# -- Options for LaTeX output ---------------------------------------------
222
+
223
+latex_elements = {
224
+# The paper size ('letterpaper' or 'a4paper').
225
+#'papersize': 'letterpaper',
226
+
227
+# The font size ('10pt', '11pt' or '12pt').
228
+#'pointsize': '10pt',
229
+
230
+# Additional stuff for the LaTeX preamble.
231
+#'preamble': '',
232
+
233
+# Latex figure (float) alignment
234
+#'figure_align': 'htbp',
235
+}
236
+
237
+# Grouping the document tree into LaTeX files. List of tuples
238
+# (source start file, target name, title,
239
+#  author, documentclass [howto, manual, or own class]).
240
+latex_documents = [
241
+  (master_doc, 'Sol.tex', u'Sol Documentation',
242
+   u'Grissess et. al.', 'manual'),
243
+]
244
+
245
+# The name of an image file (relative to this directory) to place at the top of
246
+# the title page.
247
+#latex_logo = None
248
+
249
+# For "manual" documents, if this is true, then toplevel headings are parts,
250
+# not chapters.
251
+#latex_use_parts = False
252
+
253
+# If true, show page references after internal links.
254
+#latex_show_pagerefs = False
255
+
256
+# If true, show URL addresses after external links.
257
+#latex_show_urls = False
258
+
259
+# Documents to append as an appendix to all manuals.
260
+#latex_appendices = []
261
+
262
+# If false, no module index is generated.
263
+#latex_domain_indices = True
264
+
265
+
266
+# -- Options for manual page output ---------------------------------------
267
+
268
+# One entry per manual page. List of tuples
269
+# (source start file, name, description, authors, manual section).
270
+man_pages = [
271
+    (master_doc, 'sol', u'Sol Documentation',
272
+     [author], 1)
273
+]
274
+
275
+# If true, show URL addresses after external links.
276
+#man_show_urls = False
277
+
278
+
279
+# -- Options for Texinfo output -------------------------------------------
280
+
281
+# Grouping the document tree into Texinfo files. List of tuples
282
+# (source start file, target name, title, author,
283
+#  dir menu entry, description, category)
284
+texinfo_documents = [
285
+  (master_doc, 'Sol', u'Sol Documentation',
286
+   author, 'Sol', 'One line description of project.',
287
+   'Miscellaneous'),
288
+]
289
+
290
+# Documents to append as an appendix to all manuals.
291
+#texinfo_appendices = []
292
+
293
+# If false, no module index is generated.
294
+#texinfo_domain_indices = True
295
+
296
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
297
+#texinfo_show_urls = 'footnote'
298
+
299
+# If true, do not generate a @detailmenu in the "Top" node's menu.
300
+#texinfo_no_detailmenu = False
301
+
302
+# Following are site-local extensions for this project:

+ 7
- 0
doc.sh View File

@@ -0,0 +1,7 @@
1
+#!/bin/sh
2
+
3
+# Required PyPI packages: sphinx, breathe
4
+# Required ext packages: doxygen
5
+
6
+doxygen Doxyfile
7
+sphinx-build -b html . ./_build

+ 24
- 0
doc/index.rst View File

@@ -0,0 +1,24 @@
1
+.. Sol documentation master file, created by
2
+   sphinx-quickstart on Mon Oct 19 11:40:28 2015.
3
+
4
+Welcome to Sol's documentation!
5
+===============================
6
+
7
+Sol is an eccentric language modelled on the best of Python and Lua--so it
8
+looks (and performs) a little bit like Javascript! The entire source tree is
9
+fairly small and suitable for static linking, containing just a (featureful)
10
+core runtime and a Bison-Flex parser.
11
+
12
+Sol is an interpreted language that uses a reference-counting garbage
13
+collector; it was initially built for `iiag <https://github.com/iiag/iiag>`_,
14
+and can still be found as a working proof-of-concept for integration in its
15
+`legacy "sol" branch <https://github.com/iiag/iiag-legacy/tree/sol/src>`_.
16
+
17
+Contents:
18
+
19
+.. toctree::
20
+   :maxdepth: 2
21
+
22
+   User's Manual <lang/index>
23
+   Developer's Manual <src/index>
24
+   genindex

+ 18
- 0
doc/lang/abs_basics.rst View File

@@ -0,0 +1,18 @@
1
+Absolute Basics
2
+===============
3
+
4
+This chapter is intended to give you just enough orientation of the Sol language to read the examples to follow.
5
+
6
+Sol has just one comment type, and it is a line comment; it is preceded by two dashes (--), and appears as follows::
7
+
8
+    -- This is a comment
9
+    --Whitespace to the right is recommended, but not required.
10
+    -- Anything to the right of the dashes until the end of the line is completely ignored by the parser.
11
+
12
+Interactively, and in many examples, the `prepr` `function <functions>` is used to print convenient forms of the value or values given to it as parameters::
13
+
14
+    prepr(1)      -- Outputs "1" (without enclosing quotes) to stdout
15
+    prepr(13.3)   -- Outputs "13.3" to stdout"
16
+    prepr("hi!")  -- Outputs '"hi!"' (without enclosing single quotes) to stdout
17
+
18
+Alternatively, the `interpreter` will print the resulting value of any evaluation entered at its prompt.

+ 20
- 0
doc/lang/index.rst View File

@@ -0,0 +1,20 @@
1
+Language Reference
2
+==================
3
+
4
+The Sol language is an interpreted language with fair syntactic similarity to
5
+Lua and Python, but has enough quirks that some constructs might not be clear.
6
+This guide should be considered definitive to the syntax of the language, but
7
+you should be aware that the namespace under which the language is run may
8
+differ between applications, and that you should consult those applications'
9
+manuals for more information. Only under the basic interpreter (`solrun.c`, or
10
+`sol` from the command line), the `standard library <stdlib>` is well
11
+defined.
12
+
13
+.. toctree::
14
+    
15
+    abs_basics
16
+    simple_exprs
17
+    control_flow
18
+    lists_maps
19
+    functions
20
+    stdlib

+ 26
- 0
doc/lang/simple_exprs.rst View File

@@ -0,0 +1,26 @@
1
+Simple Expressions
2
+==================
3
+
4
+Literals
5
+--------
6
+
7
+A *literal* is a leaf in an expression; it is a value in the source of a Sol program which evaluates to itself. Literals in Sol come in exactly four flavors:
8
+
9
+* Integer literals, represented by contiguous digits, possibly preceded by a
10
+  negation, like `0`, `123456`, `-314159`, and the like.
11
+* Floating point literals, represented by a pair of contiguous digits separated
12
+  by one radix mark, again possibly preceded by a negation, like `1.0`,
13
+  `-0.256`, `999.9`, and the like.
14
+* String literals, bound on either side by a single or double quote (they must
15
+  match), and containing every interim character (including newline), like
16
+  `"hello world"`, `'this string has two backslashes: \\'`, and the like.
17
+  Naturally, a string may not contain its own terminator, though it can be
18
+  introduced by concatenating strings with different terminators.
19
+* The special literal `None`, a value only ever equal to itself and which
20
+  cannot be reassigned by the user program. It is frequently used to represent
21
+  the absence of a value, such as the value of a function which does not
22
+  explicitly return a value.
23
+
24
+The following source fragment demonstrates some of the literals::
25
+
26
+    a = 123

+ 9
- 0
doc/src/ast_h.rst View File

@@ -0,0 +1,9 @@
1
+Internal Definitions (ast.h)
2
+============================
3
+
4
+For historical reasons, this header file is called "ast.h"--the definitions of
5
+the AST nodes are not namespace-safe (they aren't prefixed with `sol_`), and so
6
+this file is not generally meant to be included by end users unless strictly
7
+required.
8
+
9
+.. doxygenfile:: ast.h

+ 15
- 0
doc/src/index.rst View File

@@ -0,0 +1,15 @@
1
+Source Documentation
2
+====================
3
+
4
+This section of the documentation is intended for integrators looking to
5
+incorporate Sol into one of their projects, and for developers looking to
6
+extend, maintain, or port Sol.
7
+
8
+Many of the pages in this section are automatically documented from source file
9
+comments; if you are writing or rewriting this documentation, please consult
10
+the documentation on "doxygenfile".
11
+
12
+.. toctree::
13
+    
14
+    sol_h
15
+    ast_h

+ 9
- 0
doc/src/sol_h.rst View File

@@ -0,0 +1,9 @@
1
+User Includes (sol.h)
2
+=====================
3
+
4
+This header file includes all the standard functionality of Sol in such a way
5
+that user applications can safely call into the library. All types and
6
+functions exported from here are prefixed with `sol_` (possibly further
7
+prefixed by a number of underscores), so as to minimize namespace collision.
8
+
9
+.. doxygenfile:: sol.h

+ 163
- 141
lex.yy.c View File

@@ -141,7 +141,15 @@ typedef unsigned int flex_uint32_t;
141 141
 
142 142
 /* Size of default input buffer. */
143 143
 #ifndef YY_BUF_SIZE
144
+#ifdef __ia64__
145
+/* On IA-64, the buffer size is 16k, not 8k.
146
+ * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
147
+ * Ditto for the __ia64__ case accordingly.
148
+ */
149
+#define YY_BUF_SIZE 32768
150
+#else
144 151
 #define YY_BUF_SIZE 16384
152
+#endif /* __ia64__ */
145 153
 #endif
146 154
 
147 155
 /* The state buf must be large enough to hold one state per character in the main buffer.
@@ -361,8 +369,8 @@ static void yy_fatal_error (yyconst char msg[]  );
361 369
 	*yy_cp = '\0'; \
362 370
 	(yy_c_buf_p) = yy_cp;
363 371
 
364
-#define YY_NUM_RULES 62
365
-#define YY_END_OF_BUFFER 63
372
+#define YY_NUM_RULES 63
373
+#define YY_END_OF_BUFFER 64
366 374
 /* This struct is not used in this scanner,
367 375
    but its presence is necessary. */
368 376
 struct yy_trans_info
@@ -370,21 +378,21 @@ struct yy_trans_info
370 378
 	flex_int32_t yy_verify;
371 379
 	flex_int32_t yy_nxt;
372 380
 	};
373
-static yyconst flex_int16_t yy_accept[113] =
381
+static yyconst flex_int16_t yy_accept[119] =
374 382
     {   0,
375
-        0,    0,   63,   62,   61,   30,   62,   58,   22,   24,
376
-       62,   52,   53,   20,   18,   57,   19,   54,   21,    2,
377
-       55,   56,   42,   31,   43,   59,   59,   50,   51,   26,
378
-       59,   59,   59,   59,   59,   59,   59,   59,   59,   48,
379
-       25,   49,   27,   61,   41,    0,    3,   28,   37,    0,
380
-        4,   23,   34,   32,    0,   33,   35,    1,    2,   47,
381
-       44,   40,   45,   46,   59,   59,   39,   59,   59,   11,
382
-       59,   59,   59,   59,    5,   10,   59,   59,   59,   38,
383
-       29,   36,    0,   60,    1,   59,   59,   59,   59,   16,
384
-        9,   59,   59,   59,   59,   17,   59,   59,    7,   12,
385
-
386
-       59,    6,   59,   14,   59,   59,    8,   59,   13,   59,
387
-       15,    0
383
+        0,    0,   64,   63,   62,   31,   63,   59,   23,   25,
384
+       63,   53,   54,   21,   19,   58,   20,   55,   22,    2,
385
+       56,   57,   43,   32,   44,   60,   60,   51,   52,   27,
386
+       60,   60,   60,   60,   60,   60,   60,   60,   60,   60,
387
+       49,   26,   50,   28,   62,   42,    0,    3,   29,   38,
388
+        0,    4,   24,   35,   33,    0,   34,   36,    1,    2,
389
+       48,   45,   41,   46,   47,   60,   60,   40,   60,   60,
390
+       11,   60,   60,   60,   60,    5,   10,   60,   60,   60,
391
+       60,   39,   30,   37,    0,   61,    1,   60,   60,   60,
392
+       60,   17,    9,   60,   60,   60,   60,   60,   18,   60,
393
+
394
+       60,    7,   12,   60,   60,    6,   60,   15,   60,   60,
395
+       60,    8,   60,   13,   14,   60,   16,    0
388 396
     } ;
389 397
 
390 398
 static yyconst flex_int32_t yy_ec[256] =
@@ -400,9 +408,9 @@ static yyconst flex_int32_t yy_ec[256] =
400 408
        24,   24,   24,   24,   24,   24,   24,   24,   24,   24,
401 409
        26,    1,   27,   28,   24,    1,   29,   30,   31,   32,
402 410
 
403
-       33,   34,   24,   35,   36,   24,   37,   38,   24,   39,
404
-       40,   24,   24,   41,   42,   43,   44,   24,   45,   24,
405
-       24,   24,   46,   47,   48,   49,    1,    1,    1,    1,
411
+       33,   34,   24,   35,   36,   24,   37,   38,   39,   40,
412
+       41,   24,   24,   42,   43,   44,   45,   24,   46,   24,
413
+       24,   24,   47,   48,   49,   50,    1,    1,    1,    1,
406 414
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
407 415
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
408 416
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
@@ -419,93 +427,97 @@ static yyconst flex_int32_t yy_ec[256] =
419 427
         1,    1,    1,    1,    1
420 428
     } ;
421 429
 
422
-static yyconst flex_int32_t yy_meta[50] =
430
+static yyconst flex_int32_t yy_meta[51] =
423 431
     {   0,
424 432
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
425 433
         1,    1,    1,    1,    1,    1,    1,    2,    1,    1,
426 434
         1,    1,    1,    2,    2,    1,    1,    1,    2,    2,
427 435
         2,    2,    2,    2,    2,    2,    2,    2,    2,    2,
428
-        2,    2,    2,    2,    2,    1,    1,    1,    1
436
+        2,    2,    2,    2,    2,    2,    1,    1,    1,    1
429 437
     } ;
430 438
 
431
-static yyconst flex_int16_t yy_base[117] =
439
+static yyconst flex_int16_t yy_base[123] =
432 440
     {   0,
433
-        0,    0,  130,  131,   48,  107,  123,  131,  131,   44,
434
-      118,  131,  131,   41,  104,  131,   39,  131,  103,   39,
435
-      131,  131,   37,  102,   42,    0,   83,  131,  131,  100,
436
-       80,   80,   79,   29,   16,   35,   85,   82,   81,  131,
437
-       40,  131,  131,   68,  131,  110,  131,  131,  131,  105,
438
-      131,   91,  131,  131,  109,  131,  131,   93,   57,  131,
439
-      131,  131,  131,  131,    0,   71,  131,   76,   69,    0,
440
-       65,   74,   64,   65,    0,    0,   60,   69,   65,  131,
441
-      131,  131,   97,  131,   81,   65,   68,   53,   62,    0,
442
-        0,   63,   42,   46,   46,    0,   46,   46,    0,    0,
443
-
444
-       40,    0,   47,    0,   40,   39,    0,   33,    0,   43,
445
-        0,  131,   87,   89,   70,   91
441
+        0,    0,  136,  137,   49,  113,  129,  137,  137,   45,
442
+      124,  137,  137,   42,  110,  137,   40,  137,  109,   40,
443
+      137,  137,   38,  108,   43,    0,   88,  137,  137,  106,
444
+       85,   85,   84,   23,   27,   35,   95,   90,   87,   86,
445
+      137,   35,  137,  137,   68,  137,  115,  137,  137,  137,
446
+      110,  137,   96,  137,  137,  114,  137,  137,   98,   58,
447
+      137,  137,  137,  137,  137,    0,   75,  137,   81,   73,
448
+        0,   69,   79,   68,   69,    0,    0,   69,   63,   73,
449
+       69,  137,  137,  137,  101,  137,   85,   69,   72,   56,
450
+       66,    0,    0,   67,   67,   51,   55,   56,    0,   56,
451
+
452
+       56,    0,    0,   59,   48,    0,   49,    0,   41,   51,
453
+       39,    0,   33,    0,    0,   44,    0,  137,   83,   85,
454
+       71,   87
446 455
     } ;
447 456
 
448
-static yyconst flex_int16_t yy_def[117] =
457
+static yyconst flex_int16_t yy_def[123] =
449 458
     {   0,
450
-      112,    1,  112,  112,  112,  112,  113,  112,  112,  112,
451
-      114,  112,  112,  112,  112,  112,  112,  112,  112,  112,
452
-      112,  112,  112,  112,  112,  115,  115,  112,  112,  112,
453
-      115,  115,  115,  115,  115,  115,  115,  115,  115,  112,
454
-      112,  112,  112,  112,  112,  113,  112,  112,  112,  114,
455
-      112,  112,  112,  112,  116,  112,  112,  112,  112,  112,
456
-      112,  112,  112,  112,  115,  115,  112,  115,  115,  115,
457
-      115,  115,  115,  115,  115,  115,  115,  115,  115,  112,
458
-      112,  112,  116,  112,  112,  115,  115,  115,  115,  115,
459
-      115,  115,  115,  115,  115,  115,  115,  115,  115,  115,
460
-
461
-      115,  115,  115,  115,  115,  115,  115,  115,  115,  115,
462
-      115,    0,  112,  112,  112,  112
459
+      118,    1,  118,  118,  118,  118,  119,  118,  118,  118,
460
+      120,  118,  118,  118,  118,  118,  118,  118,  118,  118,
461
+      118,  118,  118,  118,  118,  121,  121,  118,  118,  118,
462
+      121,  121,  121,  121,  121,  121,  121,  121,  121,  121,
463
+      118,  118,  118,  118,  118,  118,  119,  118,  118,  118,
464
+      120,  118,  118,  118,  118,  122,  118,  118,  118,  118,
465
+      118,  118,  118,  118,  118,  121,  121,  118,  121,  121,
466
+      121,  121,  121,  121,  121,  121,  121,  121,  121,  121,
467
+      121,  118,  118,  118,  122,  118,  118,  121,  121,  121,
468
+      121,  121,  121,  121,  121,  121,  121,  121,  121,  121,
469
+
470
+      121,  121,  121,  121,  121,  121,  121,  121,  121,  121,
471
+      121,  121,  121,  121,  121,  121,  121,    0,  118,  118,
472
+      118,  118
463 473
     } ;
464 474
 
465
-static yyconst flex_int16_t yy_nxt[181] =
475
+static yyconst flex_int16_t yy_nxt[188] =
466 476
     {   0,
467 477
         4,    5,    5,    6,    7,    8,    9,   10,   11,   12,
468 478
        13,   14,   15,   16,   17,   18,   19,   20,   21,   22,
469 479
        23,   24,   25,   26,   27,   28,   29,   30,   26,   31,
470
-       32,   33,   34,   35,   26,   36,   26,   26,   26,   26,
471
-       37,   26,   38,   26,   39,   40,   41,   42,   43,   44,
472
-       44,   48,   52,   55,   58,   73,   59,   60,   61,   74,
473
-       56,   80,   53,   63,   64,   49,   71,   72,   75,   44,
474
-       44,   65,   58,   76,   59,  111,  110,  109,  108,  107,
475
-      106,  105,  104,  103,  102,  101,   81,   46,   46,   50,
476
-       50,   83,   83,  100,   99,   98,   97,   96,   85,   84,
477
-
478
-       95,   94,   93,   92,   91,   90,   89,   88,   87,   86,
479
-       85,   84,   82,   51,   47,   79,   78,   77,   70,   69,
480
-       68,   67,   66,   62,   57,   54,   51,   47,   45,  112,
481
-        3,  112,  112,  112,  112,  112,  112,  112,  112,  112,
482
-      112,  112,  112,  112,  112,  112,  112,  112,  112,  112,
483
-      112,  112,  112,  112,  112,  112,  112,  112,  112,  112,
484
-      112,  112,  112,  112,  112,  112,  112,  112,  112,  112,
485
-      112,  112,  112,  112,  112,  112,  112,  112,  112,  112
480
+       32,   33,   34,   35,   26,   36,   26,   37,   26,   26,
481
+       26,   38,   26,   39,   26,   40,   41,   42,   43,   44,
482
+       45,   45,   49,   53,   56,   59,   82,   60,   61,   62,
483
+       72,   57,   73,   54,   64,   65,   50,   74,   76,   45,
484
+       45,   75,   66,   59,   77,   60,  117,  116,  115,  114,
485
+      113,  112,   83,   47,   47,   51,   51,   85,   85,  111,
486
+      110,  109,  108,  107,  106,  105,  104,  103,  102,  101,
487
+
488
+      100,   99,   87,   86,   98,   97,   96,   95,   94,   93,
489
+       92,   91,   90,   89,   88,   87,   86,   84,   52,   48,
490
+       81,   80,   79,   78,   71,   70,   69,   68,   67,   63,
491
+       58,   55,   52,   48,   46,  118,    3,  118,  118,  118,
492
+      118,  118,  118,  118,  118,  118,  118,  118,  118,  118,
493
+      118,  118,  118,  118,  118,  118,  118,  118,  118,  118,
494
+      118,  118,  118,  118,  118,  118,  118,  118,  118,  118,
495
+      118,  118,  118,  118,  118,  118,  118,  118,  118,  118,
496
+      118,  118,  118,  118,  118,  118,  118
486 497
     } ;
487 498
 
488
-static yyconst flex_int16_t yy_chk[181] =
499
+static yyconst flex_int16_t yy_chk[188] =
489 500
     {   0,
490 501
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
491 502
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
492 503
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
493 504
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
494
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    5,
495
-        5,   10,   14,   17,   20,   35,   20,   23,   23,   35,
496
-       17,   41,   14,   25,   25,   10,   34,   34,   36,   44,
497
-       44,  115,   59,   36,   59,  110,  108,  106,  105,  103,
498
-      101,   98,   97,   95,   94,   93,   41,  113,  113,  114,
499
-      114,  116,  116,   92,   89,   88,   87,   86,   85,   83,
500
-
501
-       79,   78,   77,   74,   73,   72,   71,   69,   68,   66,
502
-       58,   55,   52,   50,   46,   39,   38,   37,   33,   32,
503
-       31,   30,   27,   24,   19,   15,   11,    7,    6,    3,
504
-      112,  112,  112,  112,  112,  112,  112,  112,  112,  112,
505
-      112,  112,  112,  112,  112,  112,  112,  112,  112,  112,
506
-      112,  112,  112,  112,  112,  112,  112,  112,  112,  112,
507
-      112,  112,  112,  112,  112,  112,  112,  112,  112,  112,
508
-      112,  112,  112,  112,  112,  112,  112,  112,  112,  112
505
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
506
+        5,    5,   10,   14,   17,   20,   42,   20,   23,   23,
507
+       34,   17,   34,   14,   25,   25,   10,   35,   36,   45,
508
+       45,   35,  121,   60,   36,   60,  116,  113,  111,  110,
509
+      109,  107,   42,  119,  119,  120,  120,  122,  122,  105,
510
+      104,  101,  100,   98,   97,   96,   95,   94,   91,   90,
511
+
512
+       89,   88,   87,   85,   81,   80,   79,   78,   75,   74,
513
+       73,   72,   70,   69,   67,   59,   56,   53,   51,   47,
514
+       40,   39,   38,   37,   33,   32,   31,   30,   27,   24,
515
+       19,   15,   11,    7,    6,    3,  118,  118,  118,  118,
516
+      118,  118,  118,  118,  118,  118,  118,  118,  118,  118,
517
+      118,  118,  118,  118,  118,  118,  118,  118,  118,  118,
518
+      118,  118,  118,  118,  118,  118,  118,  118,  118,  118,
519
+      118,  118,  118,  118,  118,  118,  118,  118,  118,  118,
520
+      118,  118,  118,  118,  118,  118,  118
509 521
     } ;
510 522
 
511 523
 static yy_state_type yy_last_accepting_state;
@@ -597,7 +609,7 @@ static void update_loc(YYLTYPE *yylloc, char *yytext){
597 609
 <STRING>. { str_putc(*yytext); }
598 610
 
599 611
 */
600
-#line 601 "lex.yy.c"
612
+#line 613 "lex.yy.c"
601 613
 
602 614
 #define INITIAL 0
603 615
 
@@ -686,7 +698,12 @@ static int input (void );
686 698
 
687 699
 /* Amount of stuff to slurp up with each read. */
688 700
 #ifndef YY_READ_BUF_SIZE
701
+#ifdef __ia64__
702
+/* On IA-64, the buffer size is 16k, not 8k */
703
+#define YY_READ_BUF_SIZE 16384
704
+#else
689 705
 #define YY_READ_BUF_SIZE 8192
706
+#endif /* __ia64__ */
690 707
 #endif
691 708
 
692 709
 /* Copy whatever the last rule matched to the standard output. */
@@ -827,7 +844,7 @@ YY_DECL
827 844
 #line 85 "tokenizer.lex"
828 845
 
829 846
 
830
-#line 831 "lex.yy.c"
847
+#line 848 "lex.yy.c"
831 848
 
832 849
 	while ( 1 )		/* loops until end-of-file is reached */
833 850
 		{
@@ -854,13 +871,13 @@ yy_match:
854 871
 			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
855 872
 				{
856 873
 				yy_current_state = (int) yy_def[yy_current_state];
857
-				if ( yy_current_state >= 113 )
874
+				if ( yy_current_state >= 119 )
858 875
 					yy_c = yy_meta[(unsigned int) yy_c];
859 876
 				}
860 877
 			yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
861 878
 			++yy_cp;
862 879
 			}
863
-		while ( yy_base[yy_current_state] != 131 );
880
+		while ( yy_base[yy_current_state] != 137 );
864 881
 
865 882
 yy_find_action:
866 883
 		yy_act = yy_accept[yy_current_state];
@@ -949,256 +966,261 @@ YY_RULE_SETUP
949 966
 case 13:
950 967
 YY_RULE_SETUP
951 968
 #line 111 "tokenizer.lex"
952
-{ return RETURN; }
969
+{ return LAMBDA; }
953 970
 	YY_BREAK
954 971
 case 14:
955 972
 YY_RULE_SETUP
956 973
 #line 113 "tokenizer.lex"
957
-{ return BREAK; }
974
+{ return RETURN; }
958 975
 	YY_BREAK
959 976
 case 15:
960 977
 YY_RULE_SETUP
961 978
 #line 115 "tokenizer.lex"
962
-{ return CONTINUE; }
979
+{ return BREAK; }
963 980
 	YY_BREAK
964 981
 case 16:
965 982
 YY_RULE_SETUP
966 983
 #line 117 "tokenizer.lex"
967
-{ return END; }
984
+{ return CONTINUE; }
968 985
 	YY_BREAK
969 986
 case 17:
970 987
 YY_RULE_SETUP
971 988
 #line 119 "tokenizer.lex"
972
-{ return NONE; }
989
+{ return END; }
973 990
 	YY_BREAK
974 991
 case 18:
975 992
 YY_RULE_SETUP
976 993
 #line 121 "tokenizer.lex"
977
-{ return PLUS; }
994
+{ return NONE; }
978 995
 	YY_BREAK
979 996
 case 19:
980 997
 YY_RULE_SETUP
981 998
 #line 123 "tokenizer.lex"
982
-{ return MINUS; }
999
+{ return PLUS; }
983 1000
 	YY_BREAK
984 1001
 case 20:
985 1002
 YY_RULE_SETUP
986 1003
 #line 125 "tokenizer.lex"
987
-{ return STAR; }
1004
+{ return MINUS; }
988 1005
 	YY_BREAK
989 1006
 case 21:
990 1007
 YY_RULE_SETUP
991 1008
 #line 127 "tokenizer.lex"
992
-{ return SLASH; }
1009
+{ return STAR; }
993 1010
 	YY_BREAK
994 1011
 case 22:
995 1012
 YY_RULE_SETUP
996 1013
 #line 129 "tokenizer.lex"
997
-{ return PERCENT; }
1014
+{ return SLASH; }
998 1015
 	YY_BREAK
999 1016
 case 23:
1000 1017
 YY_RULE_SETUP
1001 1018
 #line 131 "tokenizer.lex"
1002
-{ return DSTAR; }
1019
+{ return PERCENT; }
1003 1020
 	YY_BREAK
1004 1021
 case 24:
1005 1022
 YY_RULE_SETUP
1006 1023
 #line 133 "tokenizer.lex"
1007
-{ return BAND; }
1024
+{ return DSTAR; }
1008 1025
 	YY_BREAK
1009 1026
 case 25:
1010 1027
 YY_RULE_SETUP
1011 1028
 #line 135 "tokenizer.lex"
1012
-{ return BOR; }
1029
+{ return BAND; }
1013 1030
 	YY_BREAK
1014 1031
 case 26:
1015 1032
 YY_RULE_SETUP
1016 1033
 #line 137 "tokenizer.lex"
1017
-{ return BXOR; }
1034
+{ return BOR; }
1018 1035
 	YY_BREAK
1019 1036
 case 27:
1020 1037
 YY_RULE_SETUP
1021 1038
 #line 139 "tokenizer.lex"
1022
-{ return BNOT; }
1039
+{ return BXOR; }
1023 1040
 	YY_BREAK
1024 1041
 case 28:
1025 1042
 YY_RULE_SETUP
1026 1043
 #line 141 "tokenizer.lex"
1027
-{ return LAND; }
1044
+{ return BNOT; }
1028 1045
 	YY_BREAK
1029 1046
 case 29:
1030 1047
 YY_RULE_SETUP
1031 1048
 #line 143 "tokenizer.lex"
1032
-{ return LOR; }
1049
+{ return LAND; }
1033 1050
 	YY_BREAK
1034 1051
 case 30:
1035 1052
 YY_RULE_SETUP
1036 1053
 #line 145 "tokenizer.lex"
1037
-{ return LNOT; }
1054
+{ return LOR; }
1038 1055
 	YY_BREAK
1039 1056
 case 31:
1040 1057
 YY_RULE_SETUP
1041 1058
 #line 147 "tokenizer.lex"
1042
-{ return ASSIGN; }
1059
+{ return LNOT; }
1043 1060
 	YY_BREAK
1044 1061
 case 32:
1045 1062
 YY_RULE_SETUP
1046 1063
 #line 149 "tokenizer.lex"
1047
-{ return ASSIGNPLUS; }
1064
+{ return ASSIGN; }
1048 1065
 	YY_BREAK
1049 1066
 case 33:
1050 1067
 YY_RULE_SETUP
1051 1068
 #line 151 "tokenizer.lex"
1052
-{ return ASSIGNMINUS; }
1069
+{ return ASSIGNPLUS; }
1053 1070
 	YY_BREAK
1054 1071
 case 34:
1055 1072
 YY_RULE_SETUP
1056 1073
 #line 153 "tokenizer.lex"
1057
-{ return ASSIGNSTAR; }
1074
+{ return ASSIGNMINUS; }
1058 1075
 	YY_BREAK
1059 1076
 case 35:
1060 1077
 YY_RULE_SETUP
1061 1078
 #line 155 "tokenizer.lex"
1062
-{ return ASSIGNSLASH; }
1079
+{ return ASSIGNSTAR; }
1063 1080
 	YY_BREAK
1064 1081
 case 36:
1065 1082
 YY_RULE_SETUP
1066 1083
 #line 157 "tokenizer.lex"
1067
-{ return ASSIGNDSTAR; }
1084
+{ return ASSIGNSLASH; }
1068 1085
 	YY_BREAK
1069 1086
 case 37:
1070 1087
 YY_RULE_SETUP
1071 1088
 #line 159 "tokenizer.lex"
1072
-{ return ASSIGNBAND; }
1089
+{ return ASSIGNDSTAR; }
1073 1090
 	YY_BREAK
1074 1091
 case 38:
1075 1092
 YY_RULE_SETUP
1076 1093
 #line 161 "tokenizer.lex"
1077
-{ return ASSIGNBOR; }
1094
+{ return ASSIGNBAND; }
1078 1095
 	YY_BREAK
1079 1096
 case 39:
1080 1097
 YY_RULE_SETUP
1081 1098
 #line 163 "tokenizer.lex"
1082
-{ return ASSIGNBXOR; }
1099
+{ return ASSIGNBOR; }
1083 1100
 	YY_BREAK
1084 1101
 case 40:
1085 1102
 YY_RULE_SETUP
1086 1103
 #line 165 "tokenizer.lex"
1087
-{ return EQUAL; }
1104
+{ return ASSIGNBXOR; }
1088 1105
 	YY_BREAK
1089 1106
 case 41:
1090 1107
 YY_RULE_SETUP
1091 1108
 #line 167 "tokenizer.lex"
1092
-{ return NEQUAL; }
1109
+{ return EQUAL; }
1093 1110
 	YY_BREAK
1094 1111
 case 42:
1095 1112
 YY_RULE_SETUP
1096 1113
 #line 169 "tokenizer.lex"
1097
-{ return LESS; }
1114
+{ return NEQUAL; }
1098 1115
 	YY_BREAK
1099 1116
 case 43:
1100 1117
 YY_RULE_SETUP
1101 1118
 #line 171 "tokenizer.lex"
1102
-{ return GREATER; }
1119
+{ return LESS; }
1103 1120
 	YY_BREAK
1104 1121
 case 44:
1105 1122
 YY_RULE_SETUP
1106 1123
 #line 173 "tokenizer.lex"
1107
-{ return LESSEQ; }
1124
+{ return GREATER; }
1108 1125
 	YY_BREAK
1109 1126
 case 45:
1110 1127
 YY_RULE_SETUP
1111 1128
 #line 175 "tokenizer.lex"
1112
-{ return GREATEREQ; }
1129
+{ return LESSEQ; }
1113 1130
 	YY_BREAK
1114 1131
 case 46:
1115 1132
 YY_RULE_SETUP
1116 1133
 #line 177 "tokenizer.lex"
1117
-{ return RSHIFT; }
1134
+{ return GREATEREQ; }
1118 1135
 	YY_BREAK
1119 1136
 case 47:
1120 1137
 YY_RULE_SETUP
1121 1138
 #line 179 "tokenizer.lex"
1122
-{ return LSHIFT; }
1139
+{ return RSHIFT; }
1123 1140
 	YY_BREAK
1124 1141
 case 48:
1125 1142
 YY_RULE_SETUP
1126 1143
 #line 181 "tokenizer.lex"
1127
-{ return LBRACE; }
1144
+{ return LSHIFT; }
1128 1145
 	YY_BREAK
1129 1146
 case 49:
1130 1147
 YY_RULE_SETUP
1131 1148
 #line 183 "tokenizer.lex"
1132
-{ return RBRACE; }
1149
+{ return LBRACE; }
1133 1150
 	YY_BREAK
1134 1151
 case 50:
1135 1152
 YY_RULE_SETUP
1136 1153
 #line 185 "tokenizer.lex"
1137
-{ return LBRACKET; }
1154
+{ return RBRACE; }
1138 1155
 	YY_BREAK
1139 1156
 case 51:
1140 1157
 YY_RULE_SETUP
1141 1158
 #line 187 "tokenizer.lex"
1142
-{ return RBRACKET; }
1159
+{ return LBRACKET; }
1143 1160
 	YY_BREAK
1144 1161
 case 52:
1145 1162
 YY_RULE_SETUP
1146 1163
 #line 189 "tokenizer.lex"
1147
-{ return LPAREN; }
1164
+{ return RBRACKET; }
1148 1165
 	YY_BREAK
1149 1166
 case 53:
1150 1167
 YY_RULE_SETUP
1151 1168
 #line 191 "tokenizer.lex"
1152
-{ return RPAREN; }
1169
+{ return LPAREN; }
1153 1170
 	YY_BREAK
1154 1171
 case 54:
1155 1172
 YY_RULE_SETUP
1156 1173
 #line 193 "tokenizer.lex"
1157
-{ return DOT; }
1174
+{ return RPAREN; }
1158 1175
 	YY_BREAK
1159 1176
 case 55:
1160 1177
 YY_RULE_SETUP
1161 1178
 #line 195 "tokenizer.lex"
1162
-{ return COLON; }
1179
+{ return DOT; }
1163 1180
 	YY_BREAK
1164 1181
 case 56:
1165 1182
 YY_RULE_SETUP
1166 1183
 #line 197 "tokenizer.lex"
1167
-{ return SEMICOLON; }
1184
+{ return COLON; }
1168 1185
 	YY_BREAK
1169 1186
 case 57:
1170 1187
 YY_RULE_SETUP
1171 1188
 #line 199 "tokenizer.lex"
1172
-{ return COMMA; }
1189
+{ return SEMICOLON; }
1173 1190
 	YY_BREAK
1174 1191
 case 58:
1175 1192
 YY_RULE_SETUP
1176 1193
 #line 201 "tokenizer.lex"
1177
-{ return POUND; }
1194
+{ return COMMA; }
1178 1195
 	YY_BREAK
1179 1196
 case 59:
1180 1197
 YY_RULE_SETUP
1181 1198
 #line 203 "tokenizer.lex"
1182
-{ *yylval = (void *) strdup(yytext); return IDENT; }
1199
+{ return POUND; }
1183 1200
 	YY_BREAK
1184 1201
 case 60:
1185
-/* rule 60 can match eol */
1186 1202
 YY_RULE_SETUP
1187 1203
 #line 205 "tokenizer.lex"
1188
-/* Skip comments */
1204
+{ *yylval = (void *) strdup(yytext); return IDENT; }
1189 1205
 	YY_BREAK
1190 1206
 case 61:
1191 1207
 /* rule 61 can match eol */
1192 1208
 YY_RULE_SETUP
1193 1209
 #line 207 "tokenizer.lex"
1194
-/* Skip whitespace */
1210
+/* Skip comments */
1195 1211
 	YY_BREAK
1196 1212
 case 62:
1213
+/* rule 62 can match eol */
1197 1214
 YY_RULE_SETUP
1198 1215
 #line 209 "tokenizer.lex"
1216
+/* Skip whitespace */
1217
+	YY_BREAK
1218
+case 63:
1219
+YY_RULE_SETUP
1220
+#line 211 "tokenizer.lex"
1199 1221
 ECHO;
1200 1222
 	YY_BREAK
1201
-#line 1202 "lex.yy.c"
1223
+#line 1224 "lex.yy.c"
1202 1224
 case YY_STATE_EOF(INITIAL):
1203 1225
 	yyterminate();
1204 1226
 
@@ -1491,7 +1513,7 @@ static int yy_get_next_buffer (void)
1491 1513
 		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1492 1514
 			{
1493 1515
 			yy_current_state = (int) yy_def[yy_current_state];
1494
-			if ( yy_current_state >= 113 )
1516
+			if ( yy_current_state >= 119 )
1495 1517
 				yy_c = yy_meta[(unsigned int) yy_c];
1496 1518
 			}
1497 1519
 		yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -1519,11 +1541,11 @@ static int yy_get_next_buffer (void)
1519 1541
 	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1520 1542
 		{
1521 1543
 		yy_current_state = (int) yy_def[yy_current_state];
1522
-		if ( yy_current_state >= 113 )
1544
+		if ( yy_current_state >= 119 )
1523 1545
 			yy_c = yy_meta[(unsigned int) yy_c];
1524 1546
 		}
1525 1547
 	yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1526
-	yy_is_jam = (yy_current_state == 112);
1548
+	yy_is_jam = (yy_current_state == 118);
1527 1549
 
1528 1550
 		return yy_is_jam ? 0 : yy_current_state;
1529 1551
 }
@@ -2193,7 +2215,7 @@ void yyfree (void * ptr )
2193 2215
 
2194 2216
 #define YYTABLES_NAME "yytables"
2195 2217
 
2196
-#line 209 "tokenizer.lex"
2218
+#line 210 "tokenizer.lex"
2197 2219
 
2198 2220
 
2199 2221
 

+ 40
- 12
object.c View File

@@ -64,6 +64,10 @@ sol_object_t *sol_new_singlet(sol_state_t *state, const char *name) {
64 64
 	return sol_incref(res); // XXX Segfault
65 65
 }
66 66
 
67
+sol_object_t *sol_f_singlet_free(sol_state_t *state, sol_object_t *singlet) {
68
+	free(singlet->str);
69
+}
70
+
67 71
 // And, now, for the rest of the checked stuff...
68 72
 
69 73
 void sol_init_object(sol_state_t *state, sol_object_t *obj) {
@@ -334,24 +338,27 @@ sol_object_t *sol_map_mcell(sol_state_t *state, sol_object_t *map, sol_object_t
334 338
 	dsl_free_seq_iter(iter);
335 339
 	sol_obj_free(list);
336 340
 	if(res) {
337
-		return res;
341
+		return sol_incref(res);
338 342
 	}
339 343
 	return sol_incref(state->None);
340 344
 }
341 345
 
342 346
 int sol_map_has(sol_state_t *state, sol_object_t *map, sol_object_t *key) {
343 347
 	sol_object_t *mcell = sol_map_mcell(state, map, key);
344
-	int res = sol_is_none(state, mcell);
345
-	if(sol_is_none(state, mcell)) sol_decref(mcell);
348
+	int res = !sol_is_none(state, mcell);
349
+	sol_decref(mcell);
346 350
 	return res;
347 351
 }
348 352
 
349 353
 sol_object_t *sol_map_get(sol_state_t *state, sol_object_t *map, sol_object_t *key) {
350
-	sol_object_t *mcell = sol_map_mcell(state, map, key);
354
+	sol_object_t *mcell = sol_map_mcell(state, map, key), *ret;
351 355
 	if(sol_is_none(state, mcell)) {
352
-		return mcell;
356
+		ret = mcell;
357
+	} else {
358
+		ret = mcell->val;
353 359
 	}
354
-	return sol_incref(mcell->val);
360
+	sol_obj_free(mcell);
361
+	return sol_incref(ret);
355 362
 }
356 363
 
357 364
 sol_object_t *sol_map_get_name(sol_state_t *state, sol_object_t *map, char *name) {
@@ -376,6 +383,7 @@ void sol_map_set(sol_state_t *state, sol_object_t *map, sol_object_t *key, sol_o
376 383
 		mcell->val = sol_incref(val);
377 384
 		sol_obj_free(temp);
378 385
 	}
386
+	sol_obj_free(mcell);
379 387
 }
380 388
 
381 389
 void sol_map_set_name(sol_state_t *state, sol_object_t *map, char *name, sol_object_t *val) {
@@ -391,6 +399,7 @@ void sol_map_set_existing(sol_state_t *state, sol_object_t *map, sol_object_t *k
391 399
 		mcell->val = sol_incref(val);
392 400
 		sol_obj_free(temp);
393 401
 	}
402
+	sol_obj_free(mcell);
394 403
 }
395 404
 
396 405
 sol_object_t *sol_map_copy(sol_state_t *state, sol_object_t *map) {
@@ -399,17 +408,19 @@ sol_object_t *sol_map_copy(sol_state_t *state, sol_object_t *map) {
399 408
 
400 409
 void sol_map_merge(sol_state_t *state, sol_object_t *dest, sol_object_t *src) {
401 410
 	dsl_seq_iter *iter = dsl_new_seq_iter(src->seq);
402
-	if(!dsl_seq_iter_is_invalid(iter)) do {
403
-			sol_map_set(state, dest, AS_OBJ(dsl_seq_iter_at(iter))->key, AS_OBJ(dsl_seq_iter_at(iter))->val);
404
-		} while(dsl_seq_iter_next(iter));
411
+	while(!dsl_seq_iter_is_invalid(iter)) {
412
+		sol_map_set(state, dest, AS_OBJ(dsl_seq_iter_at(iter))->key, AS_OBJ(dsl_seq_iter_at(iter))->val);
413
+		dsl_seq_iter_next(iter);
414
+	}
405 415
 	dsl_free_seq_iter(iter);
406 416
 }
407 417
 
408 418
 void sol_map_merge_existing(sol_state_t *state, sol_object_t *dest, sol_object_t *src) {
409 419
 	dsl_seq_iter *iter = dsl_new_seq_iter(src->seq);
410
-	if(!dsl_seq_iter_is_invalid(iter)) do {
411
-			sol_map_set_existing(state, dest, AS_OBJ(dsl_seq_iter_at(iter))->key, AS_OBJ(dsl_seq_iter_at(iter))->val);
412
-		} while(dsl_seq_iter_next(iter));
420
+	while(!dsl_seq_iter_is_invalid(iter)) {
421
+		sol_map_set_existing(state, dest, AS_OBJ(dsl_seq_iter_at(iter))->key, AS_OBJ(dsl_seq_iter_at(iter))->val);
422
+		dsl_seq_iter_next(iter);
423
+	}
413 424
 	dsl_free_seq_iter(iter);
414 425
 }
415 426
 
@@ -434,9 +445,13 @@ sol_object_t *sol_f_map_free(sol_state_t *state, sol_object_t *map) {
434 445
 sol_object_t *sol_f_mcell_free(sol_state_t *state, sol_object_t *mcell) {
435 446
 	if(mcell->key) {
436 447
 		sol_obj_free(mcell->key);
448
+	} else {
449
+		printf("WARNING: Freed mcell with NULL key\n");
437 450
 	}
438 451
 	if(mcell->val) {
439 452
 		sol_obj_free(mcell->val);
453
+	} else {
454
+		printf("WARNING: Freed mcell with NULL value\n");
440 455
 	}
441 456
 	return mcell;
442 457
 }
@@ -480,6 +495,19 @@ sol_object_t *sol_new_cdata(sol_state_t *state, void *cdata, sol_ops_t *ops) {
480 495
 	return res;
481 496
 }
482 497
 
498
+sol_object_t *sol_f_astnode_free(sol_state_t *state, sol_object_t *node) {
499
+	switch(node->type) {
500
+		case SOL_STMT:
501
+			st_free((stmt_node *) node->node);
502
+			break;
503
+
504
+		case SOL_EXPR:
505
+			ex_free((expr_node *) node->node);
506
+			break;
507
+	}
508
+	return node;
509
+}
510
+
483 511
 sol_object_t *sol_new_buffer(sol_state_t *state, void *buffer, ssize_t sz, sol_owntype_t own, sol_freefunc_t freef, sol_movefunc_t movef) {
484 512
 	sol_object_t *res = sol_alloc_object(state);
485 513
 	res->type = SOL_BUFFER;

sol-gdb.py → old-sol-gdb.py View File


+ 4247
- 3949
parser.output
File diff suppressed because it is too large
View File


+ 491
- 447
parser.tab.c
File diff suppressed because it is too large
View File


+ 53
- 52
parser.tab.h View File

@@ -1,8 +1,8 @@
1
-/* A Bison parser, made by GNU Bison 3.0.4.  */
1
+/* A Bison parser, made by GNU Bison 3.0.2.  */
2 2
 
3 3
 /* Bison interface for Yacc-like parsers in C
4 4
 
5
-   Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
5
+   Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
6 6
 
7 7
    This program is free software: you can redistribute it and/or modify
8 8
    it under the terms of the GNU General Public License as published by
@@ -53,56 +53,57 @@ extern int yydebug;
53 53
     IN = 263,
54 54
     DO = 264,
55 55
     FUNC = 265,
56
-    RETURN = 266,
57
-    BREAK = 267,
58
-    CONTINUE = 268,
59
-    END = 269,
60
-    NONE = 270,
61
-    IDENT = 271,
62
-    INT = 272,
63
-    FLOAT = 273,
64
-    STRING = 274,
65
-    PLUS = 275,
66
-    MINUS = 276,
67
-    STAR = 277,
68
-    SLASH = 278,
69
-    PERCENT = 279,
70
-    DSTAR = 280,
71
-    BAND = 281,
72
-    BOR = 282,
73
-    BXOR = 283,
74
-    BNOT = 284,
75
-    LAND = 285,
76
-    LOR = 286,
77
-    LNOT = 287,
78
-    ASSIGN = 288,
79
-    ASSIGNPLUS = 289,
80
-    ASSIGNMINUS = 290,
81
-    ASSIGNSTAR = 291,
82
-    ASSIGNSLASH = 292,
83
-    ASSIGNDSTAR = 293,
84
-    ASSIGNBAND = 294,
85
-    ASSIGNBOR = 295,
86
-    ASSIGNBXOR = 296,
87
-    EQUAL = 297,
88
-    NEQUAL = 298,
89
-    LESS = 299,
90
-    GREATER = 300,
91
-    LESSEQ = 301,
92
-    GREATEREQ = 302,
93
-    RSHIFT = 303,
94
-    LSHIFT = 304,
95
-    LBRACE = 305,
96
-    RBRACE = 306,
97
-    LPAREN = 307,
98
-    RPAREN = 308,
99
-    LBRACKET = 309,
100
-    RBRACKET = 310,
101
-    DOT = 311,
102
-    COLON = 312,
103
-    SEMICOLON = 313,
104
-    COMMA = 314,
105
-    POUND = 315
56
+    LAMBDA = 266,
57
+    RETURN = 267,
58
+    BREAK = 268,
59
+    CONTINUE = 269,
60
+    END = 270,
61
+    NONE = 271,
62
+    IDENT = 272,
63
+    INT = 273,
64
+    FLOAT = 274,
65
+    STRING = 275,
66
+    PLUS = 276,
67
+    MINUS = 277,
68
+    STAR = 278,
69
+    SLASH = 279,
70
+    PERCENT = 280,
71
+    DSTAR = 281,
72
+    BAND = 282,
73
+    BOR = 283,
74
+    BXOR = 284,
75
+    BNOT = 285,
76
+    LAND = 286,
77
+    LOR = 287,
78
+    LNOT = 288,
79
+    ASSIGN = 289,
80
+    ASSIGNPLUS = 290,
81
+    ASSIGNMINUS = 291,
82
+    ASSIGNSTAR = 292,
83
+    ASSIGNSLASH = 293,
84
+    ASSIGNDSTAR = 294,
85
+    ASSIGNBAND = 295,
86
+    ASSIGNBOR = 296,
87
+    ASSIGNBXOR = 297,
88
+    EQUAL = 298,
89
+    NEQUAL = 299,
90
+    LESS = 300,
91
+    GREATER = 301,
92
+    LESSEQ = 302,
93
+    GREATEREQ = 303,
94
+    RSHIFT = 304,
95
+    LSHIFT = 305,
96
+    LBRACE = 306,
97
+    RBRACE = 307,
98
+    LPAREN = 308,
99
+    RPAREN = 309,
100
+    LBRACKET = 310,
101
+    RBRACKET = 311,
102
+    DOT = 312,
103
+    COLON = 313,
104
+    SEMICOLON = 314,
105
+    COMMA = 315,
106
+    POUND = 316
106 107
   };
107 108
 #endif
108 109
 

+ 12
- 1
parser.y View File

@@ -13,7 +13,7 @@
13 13
 
14 14
 %token IF THEN ELSE
15 15
 %token WHILE FOR IN DO
16
-%token FUNC RETURN BREAK CONTINUE
16
+%token FUNC LAMBDA RETURN BREAK CONTINUE
17 17
 %token END NONE
18 18
 %token IDENT
19 19
 %token INT FLOAT STRING
@@ -342,6 +342,17 @@ funcdecl_expr:
342 342
 	AS_EX($$)->funcdecl->args = $3;
343 343
 	AS_EX($$)->funcdecl->body = $5;
344 344
 }
345
+| LAMBDA LPAREN ident_list RPAREN expr END {
346
+	$$ = NEW_EX();
347
+	AS_EX($$)->type = EX_FUNCDECL;
348
+	AS_EX($$)->funcdecl = NEW(funcdecl_node);
349
+	AS_EX($$)->funcdecl->name = NULL;
350
+	AS_EX($$)->funcdecl->args = $3;
351
+	AS_EX($$)->funcdecl->body = NEW_ST();
352
+	AS_EX($$)->funcdecl->body->type = ST_RET;
353
+	AS_EX($$)->funcdecl->body->ret = NEW(ret_node);
354
+	AS_EX($$)->funcdecl->body->ret->ret = $5;
355
+}
345 356
 | index_expr { $$ = $1; }
346 357
 ;
347 358
 

+ 1
- 1
runtime.c View File

@@ -480,7 +480,7 @@ sol_object_t *sol_eval_inner(sol_state_t *state, expr_node *expr, jmp_buf jmp) {
480 480
 			return res;
481 481
 			break;
482 482
 	}
483
-	printf("WARNING: Unhandled expression returning None");
483
+	printf("WARNING: Unhandled expression (type %d) returning None\n", expr->type);
484 484
 	return sol_incref(state->None);
485 485
 }
486 486
 

+ 25
- 8
sol.h View File

@@ -9,8 +9,8 @@
9 9
 #include <stdarg.h>
10 10
 #include "dsl/dsl.h"
11 11
 
12
-#define VERSION "0.1a3"
13
-#define HEXVER 0x0001A03
12
+#define VERSION "0.1a4"
13
+#define HEXVER 0x0001A04
14 14
 
15 15
 #ifndef SOL_ICACHE_MIN
16 16
 #define SOL_ICACHE_MIN -128
@@ -457,7 +457,17 @@ int sol_map_has(sol_state_t *, sol_object_t *, sol_object_t *);
457 457
 sol_object_t *sol_map_get(sol_state_t *, sol_object_t *, sol_object_t *);
458 458
 sol_object_t *sol_map_get_name(sol_state_t *, sol_object_t *, char *);
459 459
 void sol_map_set(sol_state_t *, sol_object_t *, sol_object_t *, sol_object_t *);
460
+#define sol_map_borrow(state, map, key, object) do {\
461
+	sol_object_t *_obj = (object);\
462
+	sol_map_set((state), (map), (key), _obj);\
463
+	sol_obj_free(_obj);\
464
+} while(0)
460 465
 void sol_map_set_name(sol_state_t *, sol_object_t *, char *, sol_object_t *);
466
+#define sol_map_borrow_name(state, map, str, object) do {\
467
+	sol_object_t *_obj = (object);\
468
+	sol_map_set_name((state), (map), (str), _obj);\
469
+	sol_obj_free(_obj);\
470
+} while(0)
461 471
 void sol_map_set_existing(sol_state_t *, sol_object_t *, sol_object_t *, sol_object_t *);
462 472
 sol_object_t *sol_map_copy(sol_state_t *, sol_object_t *);
463 473
 void sol_map_merge(sol_state_t *, sol_object_t *, sol_object_t *);
@@ -486,12 +496,17 @@ size_t sol_stream_fread(sol_state_t *, sol_object_t *, char *, size_t, size_t);
486 496
 size_t sol_stream_fwrite(sol_state_t *, sol_object_t *, char *, size_t, size_t);
487 497
 char *sol_stream_fgets(sol_state_t *, sol_object_t *, char *, size_t);
488 498
 int sol_stream_fputc(sol_state_t *, sol_object_t *, int);
489
-#define sol_printf(state, ...) sol_stream_printf(state, sol_get_stdout(state), __VA_ARGS__)
490
-#define sol_vprintf(state, ...) sol_stream_vprintf(state, sol_get_stdout(state), __VA_ARGS__)
491
-#define sol_scanf(state, ...) sol_stream_scanf(state, sol_get_stdin(state, __VA_ARGS__)
492
-#define sol_fread(state, ...) sol_stream_fread(state, sol_get_stdin(state), __VA_ARGS__)
493
-#define sol_fwrite(state, ...) sol_stream_fwrite(state, sol_get_stdout(state), __VA_ARGS__)
494
-#define sol_putchar(state, ...) sol_stream_fputc(state, sol_get_stdout(state), __VA_ARGS__)
499
+#define _sol_io_on(state, op, strname, ...) do {\
500
+	sol_object_t *str = sol_get_##strname(state);\
501
+	sol_stream_##op((state), str, __VA_ARGS__);\
502
+	sol_obj_free(str);\
503
+} while(0)
504
+#define sol_printf(state, ...) _sol_io_on(state, printf, stdout, __VA_ARGS__)
505
+#define sol_vprintf(state, ...) _sol_io_on(state, vprintf, stdout, __VA_ARGS__)
506
+#define sol_scanf(state, ...) _sol_io_on(state, scanf, stdin, __VA_ARGS__)
507
+#define sol_fread(state, ...) _sol_io_on(state, fread, stdin, __VA_ARGS__)
508
+#define sol_fwrite(state, ...) _sol_io_on(state, fwrite, stdout, __VA_ARGS__)
509
+#define sol_putchar(state, ...) _sol_io_on(state, fputc, stdout, __VA_ARGS__)
495 510
 int sol_stream_feof(sol_state_t *, sol_object_t *);
496 511
 int sol_stream_ferror(sol_state_t *, sol_object_t *);
497 512
 #define sol_stream_ready(state, stream) (!(sol_stream_feof((state), (stream)) || sol_stream_ferror((state), (stream))))
@@ -504,10 +519,12 @@ sol_object_t *sol_cast_float(sol_state_t *, sol_object_t *);
504 519
 sol_object_t *sol_cast_string(sol_state_t *, sol_object_t *);
505 520
 sol_object_t *sol_cast_repr(sol_state_t *, sol_object_t *);
506 521
 
522
+sol_object_t *sol_f_singlet_free(sol_state_t *, sol_object_t *);
507 523
 sol_object_t *sol_f_str_free(sol_state_t *, sol_object_t *);
508 524
 sol_object_t *sol_f_list_free(sol_state_t *, sol_object_t *);
509 525
 sol_object_t *sol_f_map_free(sol_state_t *, sol_object_t *);
510 526
 sol_object_t *sol_f_mcell_free(sol_state_t *, sol_object_t *);
527
+sol_object_t *sol_f_astnode_free(sol_state_t *, sol_object_t *);
511 528
 sol_object_t *sol_f_buffer_free(sol_state_t *, sol_object_t *);
512 529
 sol_object_t *sol_f_dylib_free(sol_state_t *, sol_object_t *);
513 530
 sol_object_t *sol_f_stream_free(sol_state_t *, sol_object_t *);

+ 19
- 17
solrun.c View File

@@ -38,6 +38,11 @@ int main(int argc, char **argv) {
38 38
 	}
39 39
 
40 40
 	program = sol_compile_file(prgstream);
41
+	
42
+	if(!program) {
43
+		printf("NULL program (probably a syntax error)\n");
44
+		return 1;
45
+	}
41 46
 
42 47
 	if(prgstream != stdin) {
43 48
 		fclose(prgstream);
@@ -48,24 +53,21 @@ int main(int argc, char **argv) {
48 53
 		st_print(&state, program);
49 54
 	}
50 55
 
51
-	if(program) {
52
-		sol_exec(&state, program);
53
-		if(sol_has_error(&state)) {
54
-			printf("Error: ");
55
-			ob_print(state.error);
56
-			printf("\n");
57
-		}
58
-		if(state.ret) {
59
-			printf("Toplevel return: ");
60
-			ob_print(state.ret);
61
-			printf("\n");
62
-		}
63
-		//st_free(program);
64
-		sol_state_cleanup(&state);
65
-		return 0;
56
+	sol_exec(&state, program);
57
+
58
+	if(sol_has_error(&state)) {
59
+		printf("Error: ");
60
+		ob_print(state.error);
61
+		printf("\n");
66 62
 	}
67 63
 
68
-	printf("NULL program (probably a syntax error)\n");
64
+	if(state.ret) {
65
+		printf("Toplevel return: ");
66
+		ob_print(state.ret);
67
+		printf("\n");
68
+	}
69
+	st_free(program);
70
+	sol_state_cleanup(&state);
69 71
 
70
-	return 1;
72
+	return 0;
71 73
 }

+ 182
- 171
state.c View File

@@ -58,6 +58,7 @@ int sol_state_init(sol_state_t *state) {
58 58
 
59 59
 	state->SingletOps.tname = "singlet";
60 60
 	state->SingletOps.tostring = sol_f_singlet_tostring;
61
+	state->SingletOps.free = sol_f_singlet_free;
61 62
 
62 63
 	state->IntOps.tname = "int";
63 64
 	state->IntOps.add = sol_f_int_add;
@@ -140,6 +141,7 @@ int sol_state_init(sol_state_t *state) {
140 141
 	state->ASTNodeOps.index = sol_f_astnode_index;
141 142
 	state->ASTNodeOps.setindex = sol_f_astnode_setindex;
142 143
 	state->ASTNodeOps.tostring = sol_f_astnode_tostring;
144
+	state->ASTNodeOps.free = sol_f_astnode_free;
143 145
 
144 146
 	state->BufferOps.tname = "buffer";
145 147
 	state->BufferOps.index = sol_f_buffer_index;
@@ -205,166 +207,166 @@ int sol_state_init(sol_state_t *state) {
205 207
 	state->stderr = sol_new_stream(state, stderr, MODE_WRITE);
206 208
 
207 209
 	// I'm going to buffer all of these together because I can.
208
-	sol_map_set_name(state, globals, "OutOfMemory", state->OutOfMemory);
209
-	sol_map_set_name(state, globals, "StopIteration", state->StopIteration);
210
-	sol_map_set_name(state, globals, "toint", sol_new_cfunc(state, sol_f_toint));
211
-	sol_map_set_name(state, globals, "tofloat", sol_new_cfunc(state, sol_f_tofloat));
212
-	sol_map_set_name(state, globals, "tostring", sol_new_cfunc(state, sol_f_tostring));
213
-	sol_map_set_name(state, globals, "try", sol_new_cfunc(state, sol_f_try));
214
-	sol_map_set_name(state, globals, "error", sol_new_cfunc(state, sol_f_error));
215
-	sol_map_set_name(state, globals, "type", sol_new_cfunc(state, sol_f_type));
216
-	sol_map_set_name(state, globals, "prepr", sol_new_cfunc(state, sol_f_prepr));
217
-	sol_map_set_name(state, globals, "print", sol_new_cfunc(state, sol_f_print));
218
-	sol_map_set_name(state, globals, "rawget", sol_new_cfunc(state, sol_f_rawget));
219
-	sol_map_set_name(state, globals, "rawset", sol_new_cfunc(state, sol_f_rawset));
220
-	sol_map_set_name(state, globals, "range", sol_new_cfunc(state, sol_f_range));
221
-	sol_map_set_name(state, globals, "exec", sol_new_cfunc(state, sol_f_exec));
222
-	sol_map_set_name(state, globals, "eval", sol_new_cfunc(state, sol_f_eval));
223
-	sol_map_set_name(state, globals, "execfile", sol_new_cfunc(state, sol_f_execfile));
224
-	sol_map_set_name(state, globals, "parse", sol_new_cfunc(state, sol_f_parse));
225
-	sol_map_set_name(state, globals, "ord", sol_new_cfunc(state, sol_f_ord));
226
-	sol_map_set_name(state, globals, "chr", sol_new_cfunc(state, sol_f_chr));
210
+	sol_map_borrow_name(state, globals, "OutOfMemory", state->OutOfMemory);
211
+	sol_map_borrow_name(state, globals, "StopIteration", state->StopIteration);
212
+	sol_map_borrow_name(state, globals, "toint", sol_new_cfunc(state, sol_f_toint));
213
+	sol_map_borrow_name(state, globals, "tofloat", sol_new_cfunc(state, sol_f_tofloat));
214
+	sol_map_borrow_name(state, globals, "tostring", sol_new_cfunc(state, sol_f_tostring));
215
+	sol_map_borrow_name(state, globals, "try", sol_new_cfunc(state, sol_f_try));
216
+	sol_map_borrow_name(state, globals, "error", sol_new_cfunc(state, sol_f_error));
217
+	sol_map_borrow_name(state, globals, "type", sol_new_cfunc(state, sol_f_type));
218
+	sol_map_borrow_name(state, globals, "prepr", sol_new_cfunc(state, sol_f_prepr));
219
+	sol_map_borrow_name(state, globals, "print", sol_new_cfunc(state, sol_f_print));
220
+	sol_map_borrow_name(state, globals, "rawget", sol_new_cfunc(state, sol_f_rawget));
221
+	sol_map_borrow_name(state, globals, "rawset", sol_new_cfunc(state, sol_f_rawset));
222
+	sol_map_borrow_name(state, globals, "range", sol_new_cfunc(state, sol_f_range));
223
+	sol_map_borrow_name(state, globals, "exec", sol_new_cfunc(state, sol_f_exec));
224
+	sol_map_borrow_name(state, globals, "eval", sol_new_cfunc(state, sol_f_eval));
225
+	sol_map_borrow_name(state, globals, "execfile", sol_new_cfunc(state, sol_f_execfile));
226
+	sol_map_borrow_name(state, globals, "parse", sol_new_cfunc(state, sol_f_parse));
227
+	sol_map_borrow_name(state, globals, "ord", sol_new_cfunc(state, sol_f_ord));
228
+	sol_map_borrow_name(state, globals, "chr", sol_new_cfunc(state, sol_f_chr));
227 229
 
228 230
 	mod = sol_new_map(state);
229
-	sol_map_set_name(state, mod, "getref", sol_new_cfunc(state, sol_f_debug_getref));
230
-	sol_map_set_name(state, mod, "setref", sol_new_cfunc(state, sol_f_debug_setref));
231
-	sol_map_set_name(state, mod, "closure", sol_new_cfunc(state, sol_f_debug_closure));
232
-	sol_map_set_name(state, mod, "globals", sol_new_cfunc(state, sol_f_debug_globals));
233
-	sol_map_set_name(state, mod, "locals", sol_new_cfunc(state, sol_f_debug_locals));
234
-	sol_map_set_name(state, mod, "scopes", sol_new_cfunc(state, sol_f_debug_scopes));
235
-	sol_map_set_name(state, mod, "version", sol_new_string(state, VERSION));
236
-	sol_map_set_name(state, mod, "hexversion", sol_new_int(state, HEXVER));
231
+	sol_map_borrow_name(state, mod, "getref", sol_new_cfunc(state, sol_f_debug_getref));
232
+	sol_map_borrow_name(state, mod, "setref", sol_new_cfunc(state, sol_f_debug_setref));
233
+	sol_map_borrow_name(state, mod, "closure", sol_new_cfunc(state, sol_f_debug_closure));
234
+	sol_map_borrow_name(state, mod, "globals", sol_new_cfunc(state, sol_f_debug_globals));
235
+	sol_map_borrow_name(state, mod, "locals", sol_new_cfunc(state, sol_f_debug_locals));
236
+	sol_map_borrow_name(state, mod, "scopes", sol_new_cfunc(state, sol_f_debug_scopes));
237
+	sol_map_borrow_name(state, mod, "version", sol_new_string(state, VERSION));
238
+	sol_map_borrow_name(state, mod, "hexversion", sol_new_int(state, HEXVER));
237 239
 #ifdef SOL_ICACHE
238
-	sol_map_set_name(state, mod, "icache_min", sol_new_int(state, SOL_ICACHE_MIN));
239
-	sol_map_set_name(state, mod, "icache_max", sol_new_int(state, SOL_ICACHE_MAX));
240
+	sol_map_borrow_name(state, mod, "icache_min", sol_new_int(state, SOL_ICACHE_MIN));
241
+	sol_map_borrow_name(state, mod, "icache_max", sol_new_int(state, SOL_ICACHE_MAX));
240 242
 #endif
241 243
 	sol_register_module_name(state, "debug", mod);
242 244
 	sol_obj_free(mod);
243 245
 
244 246
 	mod = sol_new_map(state);
245
-	sol_map_set_name(state, mod, "str", sol_new_cfunc(state, sol_f_iter_str));
246
-	sol_map_set_name(state, mod, "list", sol_new_cfunc(state, sol_f_iter_list));
247
-	sol_map_set_name(state, mod, "map", sol_new_cfunc(state, sol_f_iter_map));
247
+	sol_map_borrow_name(state, mod, "str", sol_new_cfunc(state, sol_f_iter_str));
248
+	sol_map_borrow_name(state, mod, "list", sol_new_cfunc(state, sol_f_iter_list));
249
+	sol_map_borrow_name(state, mod, "map", sol_new_cfunc(state, sol_f_iter_map));
248 250
 	sol_register_module_name(state, "iter", mod);
249 251
 	sol_obj_free(mod);
250 252
 
251 253
 	mod = sol_new_map(state);
252
-	sol_map_set_name(state, mod, "ST_EXPR", sol_new_int(state, ST_EXPR));
253
-	sol_map_set_name(state, mod, "ST_IFELSE", sol_new_int(state, ST_IFELSE));
254
-	sol_map_set_name(state, mod, "ST_LOOP", sol_new_int(state, ST_LOOP));
255
-	sol_map_set_name(state, mod, "ST_ITER", sol_new_int(state, ST_ITER));
256
-	sol_map_set_name(state, mod, "ST_LIST", sol_new_int(state, ST_LIST));
257
-	sol_map_set_name(state, mod, "ST_RET", sol_new_int(state, ST_RET));
258
-	sol_map_set_name(state, mod, "ST_CONT", sol_new_int(state, ST_CONT));
259
-	sol_map_set_name(state, mod, "ST_BREAK", sol_new_int(state, ST_BREAK));
260
-	sol_map_set_name(state, mod, "EX_LIT", sol_new_int(state, EX_LIT));
261
-	sol_map_set_name(state, mod, "EX_LISTGEN", sol_new_int(state, EX_LIT));
262
-	sol_map_set_name(state, mod, "EX_MAPGEN", sol_new_int(state, EX_LIT));
263
-	sol_map_set_name(state, mod, "EX_BINOP", sol_new_int(state, EX_LIT));
264
-	sol_map_set_name(state, mod, "EX_UNOP", sol_new_int(state, EX_LIT));
265
-	sol_map_set_name(state, mod, "EX_INDEX", sol_new_int(state, EX_LIT));
266
-	sol_map_set_name(state, mod, "EX_SETINDEX", sol_new_int(state, EX_LIT));
267
-	sol_map_set_name(state, mod, "EX_ASSIGN", sol_new_int(state, EX_LIT));
268
-	sol_map_set_name(state, mod, "EX_REF", sol_new_int(state, EX_LIT));
269
-	sol_map_set_name(state, mod, "EX_CALL", sol_new_int(state, EX_LIT));
270
-	sol_map_set_name(state, mod, "EX_FUNCDECL", sol_new_int(state, EX_LIT));
271
-	sol_map_set_name(state, mod, "OP_ADD", sol_new_int(state, OP_ADD));
272
-	sol_map_set_name(state, mod, "OP_SUB", sol_new_int(state, OP_SUB));
273
-	sol_map_set_name(state, mod, "OP_MUL", sol_new_int(state, OP_MUL));
274
-	sol_map_set_name(state, mod, "OP_DIV", sol_new_int(state, OP_DIV));
275
-	sol_map_set_name(state, mod, "OP_MOD", sol_new_int(state, OP_MOD));
276
-	sol_map_set_name(state, mod, "OP_POW", sol_new_int(state, OP_POW));
277
-	sol_map_set_name(state, mod, "OP_BAND", sol_new_int(state, OP_BAND));
278
-	sol_map_set_name(state, mod, "OP_BOR", sol_new_int(state, OP_BOR));
279
-	sol_map_set_name(state, mod, "OP_BXOR", sol_new_int(state, OP_BXOR));
280
-	sol_map_set_name(state, mod, "OP_LAND", sol_new_int(state, OP_LAND));
281
-	sol_map_set_name(state, mod, "OP_LOR", sol_new_int(state, OP_LOR));
282
-	sol_map_set_name(state, mod, "OP_EQUAL", sol_new_int(state, OP_EQUAL));
283
-	sol_map_set_name(state, mod, "OP_NEQUAL", sol_new_int(state, OP_NEQUAL));
284
-	sol_map_set_name(state, mod, "OP_LESS", sol_new_int(state, OP_LESS));
285
-	sol_map_set_name(state, mod, "OP_GREATER", sol_new_int(state, OP_GREATER));
286
-	sol_map_set_name(state, mod, "OP_LESSEQ", sol_new_int(state, OP_LESSEQ));
287
-	sol_map_set_name(state, mod, "OP_GREATEREQ", sol_new_int(state, OP_GREATEREQ));
288
-	sol_map_set_name(state, mod, "OP_LSHIFT", sol_new_int(state, OP_LSHIFT));
289
-	sol_map_set_name(state, mod, "OP_RSHIFT", sol_new_int(state, OP_RSHIFT));
290
-	sol_map_set_name(state, mod, "OP_NEG", sol_new_int(state, OP_NEG));
291
-	sol_map_set_name(state, mod, "OP_BNOT", sol_new_int(state, OP_BNOT));
292
-	sol_map_set_name(state, mod, "OP_LNOT", sol_new_int(state, OP_LNOT));
293
-	sol_map_set_name(state, mod, "OP_LEN", sol_new_int(state, OP_LEN));
294
-	sol_map_set_name(state, mod, "LIT_INT", sol_new_int(state, LIT_INT));
295
-	sol_map_set_name(state, mod, "LIT_FLOAT", sol_new_int(state, LIT_FLOAT));
296
-	sol_map_set_name(state, mod, "LIT_STRING", sol_new_int(state, LIT_STRING));
297
-	sol_map_set_name(state, mod, "LIT_NONE", sol_new_int(state, LIT_NONE));
254
+	sol_map_borrow_name(state, mod, "ST_EXPR", sol_new_int(state, ST_EXPR));
255
+	sol_map_borrow_name(state, mod, "ST_IFELSE", sol_new_int(state, ST_IFELSE));
256
+	sol_map_borrow_name(state, mod, "ST_LOOP", sol_new_int(state, ST_LOOP));
257
+	sol_map_borrow_name(state, mod, "ST_ITER", sol_new_int(state, ST_ITER));
258
+	sol_map_borrow_name(state, mod, "ST_LIST", sol_new_int(state, ST_LIST));
259
+	sol_map_borrow_name(state, mod, "ST_RET", sol_new_int(state, ST_RET));
260
+	sol_map_borrow_name(state, mod, "ST_CONT", sol_new_int(state, ST_CONT));
261
+	sol_map_borrow_name(state, mod, "ST_BREAK", sol_new_int(state, ST_BREAK));
262
+	sol_map_borrow_name(state, mod, "EX_LIT", sol_new_int(state, EX_LIT));
263
+	sol_map_borrow_name(state, mod, "EX_LISTGEN", sol_new_int(state, EX_LIT));
264
+	sol_map_borrow_name(state, mod, "EX_MAPGEN", sol_new_int(state, EX_LIT));
265
+	sol_map_borrow_name(state, mod, "EX_BINOP", sol_new_int(state, EX_LIT));
266
+	sol_map_borrow_name(state, mod, "EX_UNOP", sol_new_int(state, EX_LIT));
267
+	sol_map_borrow_name(state, mod, "EX_INDEX", sol_new_int(state, EX_LIT));
268
+	sol_map_borrow_name(state, mod, "EX_SETINDEX", sol_new_int(state, EX_LIT));
269
+	sol_map_borrow_name(state, mod, "EX_ASSIGN", sol_new_int(state, EX_LIT));
270
+	sol_map_borrow_name(state, mod, "EX_REF", sol_new_int(state, EX_LIT));
271
+	sol_map_borrow_name(state, mod, "EX_CALL", sol_new_int(state, EX_LIT));
272
+	sol_map_borrow_name(state, mod, "EX_FUNCDECL", sol_new_int(state, EX_LIT));
273
+	sol_map_borrow_name(state, mod, "OP_ADD", sol_new_int(state, OP_ADD));
274
+	sol_map_borrow_name(state, mod, "OP_SUB", sol_new_int(state, OP_SUB));
275
+	sol_map_borrow_name(state, mod, "OP_MUL", sol_new_int(state, OP_MUL));
276
+	sol_map_borrow_name(state, mod, "OP_DIV", sol_new_int(state, OP_DIV));
277
+	sol_map_borrow_name(state, mod, "OP_MOD", sol_new_int(state, OP_MOD));
278
+	sol_map_borrow_name(state, mod, "OP_POW", sol_new_int(state, OP_POW));
279
+	sol_map_borrow_name(state, mod, "OP_BAND", sol_new_int(state, OP_BAND));
280
+	sol_map_borrow_name(state, mod, "OP_BOR", sol_new_int(state, OP_BOR));
281
+	sol_map_borrow_name(state, mod, "OP_BXOR", sol_new_int(state, OP_BXOR));
282
+	sol_map_borrow_name(state, mod, "OP_LAND", sol_new_int(state, OP_LAND));
283
+	sol_map_borrow_name(state, mod, "OP_LOR", sol_new_int(state, OP_LOR));
284
+	sol_map_borrow_name(state, mod, "OP_EQUAL", sol_new_int(state, OP_EQUAL));
285
+	sol_map_borrow_name(state, mod, "OP_NEQUAL", sol_new_int(state, OP_NEQUAL));
286
+	sol_map_borrow_name(state, mod, "OP_LESS", sol_new_int(state, OP_LESS));
287
+	sol_map_borrow_name(state, mod, "OP_GREATER", sol_new_int(state, OP_GREATER));
288
+	sol_map_borrow_name(state, mod, "OP_LESSEQ", sol_new_int(state, OP_LESSEQ));
289
+	sol_map_borrow_name(state, mod, "OP_GREATEREQ", sol_new_int(state, OP_GREATEREQ));
290
+	sol_map_borrow_name(state, mod, "OP_LSHIFT", sol_new_int(state, OP_LSHIFT));
291
+	sol_map_borrow_name(state, mod, "OP_RSHIFT", sol_new_int(state, OP_RSHIFT));
292
+	sol_map_borrow_name(state, mod, "OP_NEG", sol_new_int(state, OP_NEG));
293
+	sol_map_borrow_name(state, mod, "OP_BNOT", sol_new_int(state, OP_BNOT));
294
+	sol_map_borrow_name(state, mod, "OP_LNOT", sol_new_int(state, OP_LNOT));
295
+	sol_map_borrow_name(state, mod, "OP_LEN", sol_new_int(state, OP_LEN));
296
+	sol_map_borrow_name(state, mod, "LIT_INT", sol_new_int(state, LIT_INT));
297
+	sol_map_borrow_name(state, mod, "LIT_FLOAT", sol_new_int(state, LIT_FLOAT));
298
+	sol_map_borrow_name(state, mod, "LIT_STRING", sol_new_int(state, LIT_STRING));
299
+	sol_map_borrow_name(state, mod, "LIT_NONE", sol_new_int(state, LIT_NONE));
298 300
 	sol_map_invert(state, mod);
299
-	sol_map_set_name(state, mod, "print", sol_new_cfunc(state, sol_f_ast_print));
301
+	sol_map_borrow_name(state, mod, "print", sol_new_cfunc(state, sol_f_ast_print));
300 302
 	sol_register_module_name(state, "ast", mod);
301 303
 
302 304
 	btype = sol_new_map(state);
303
-	sol_map_set_name(state, btype, "none", sol_new_int(state, BUF_NONE));
304
-	sol_map_set_name(state, btype, "uint8", sol_new_int(state, BUF_UINT8));
305
-	sol_map_set_name(state, btype, "uint16", sol_new_int(state, BUF_UINT16));
306
-	sol_map_set_name(state, btype, "uint32", sol_new_int(state, BUF_UINT32));
307
-	sol_map_set_name(state, btype, "uint64", sol_new_int(state, BUF_UINT64));
308
-	sol_map_set_name(state, btype, "int8", sol_new_int(state, BUF_INT8));
309
-	sol_map_set_name(state, btype, "int16", sol_new_int(state, BUF_INT16));
310
-	sol_map_set_name(state, btype, "int32", sol_new_int(state, BUF_INT32));
311
-	sol_map_set_name(state, btype, "int64", sol_new_int(state, BUF_INT64));
312
-	sol_map_set_name(state, btype, "char", sol_new_int(state, BUF_CHAR));
313
-	sol_map_set_name(state, btype, "byte", sol_new_int(state, BUF_BYTE));
314
-	sol_map_set_name(state, btype, "int", sol_new_int(state, BUF_INT));
315
-	sol_map_set_name(state, btype, "uint", sol_new_int(state, BUF_UINT));
316
-	sol_map_set_name(state, btype, "long", sol_new_int(state, BUF_LONG));
317
-	sol_map_set_name(state, btype, "ulong", sol_new_int(state, BUF_ULONG));
318
-	sol_map_set_name(state, btype, "float", sol_new_int(state, BUF_FLOAT));
319
-	sol_map_set_name(state, btype, "double", sol_new_int(state, BUF_DOUBLE));
320
-	sol_map_set_name(state, btype, "cstr", sol_new_int(state, BUF_CSTR));
321
-	sol_map_set_name(state, btype, "ptr", sol_new_int(state, BUF_PTR));
305
+	sol_map_borrow_name(state, btype, "none", sol_new_int(state, BUF_NONE));
306
+	sol_map_borrow_name(state, btype, "uint8", sol_new_int(state, BUF_UINT8));
307
+	sol_map_borrow_name(state, btype, "uint16", sol_new_int(state, BUF_UINT16));
308
+	sol_map_borrow_name(state, btype, "uint32", sol_new_int(state, BUF_UINT32));
309
+	sol_map_borrow_name(state, btype, "uint64", sol_new_int(state, BUF_UINT64));
310
+	sol_map_borrow_name(state, btype, "int8", sol_new_int(state, BUF_INT8));
311
+	sol_map_borrow_name(state, btype, "int16", sol_new_int(state, BUF_INT16));
312
+	sol_map_borrow_name(state, btype, "int32", sol_new_int(state, BUF_INT32));
313
+	sol_map_borrow_name(state, btype, "int64", sol_new_int(state, BUF_INT64));
314
+	sol_map_borrow_name(state, btype, "char", sol_new_int(state, BUF_CHAR));
315
+	sol_map_borrow_name(state, btype, "byte", sol_new_int(state, BUF_BYTE));
316
+	sol_map_borrow_name(state, btype, "int", sol_new_int(state, BUF_INT));
317
+	sol_map_borrow_name(state, btype, "uint", sol_new_int(state, BUF_UINT));
318
+	sol_map_borrow_name(state, btype, "long", sol_new_int(state, BUF_LONG));
319
+	sol_map_borrow_name(state, btype, "ulong", sol_new_int(state, BUF_ULONG));
320
+	sol_map_borrow_name(state, btype, "float", sol_new_int(state, BUF_FLOAT));
321
+	sol_map_borrow_name(state, btype, "double", sol_new_int(state, BUF_DOUBLE));
322
+	sol_map_borrow_name(state, btype, "cstr", sol_new_int(state, BUF_CSTR));
323
+	sol_map_borrow_name(state, btype, "ptr", sol_new_int(state, BUF_PTR));
322 324
 	sol_map_invert(state, btype);
323 325
 
324 326
 	bsize = sol_new_map(state);
325
-	sol_map_set_name(state, bsize, "uint8", sol_new_int(state, sizeof(uint8_t)));
326
-	sol_map_set_name(state, bsize, "uint16", sol_new_int(state, sizeof(uint16_t)));
327
-	sol_map_set_name(state, bsize, "uint32", sol_new_int(state, sizeof(uint32_t)));
328
-	sol_map_set_name(state, bsize, "uint64", sol_new_int(state, sizeof(uint64_t)));
329
-	sol_map_set_name(state, bsize, "int8", sol_new_int(state, sizeof(int8_t)));
330
-	sol_map_set_name(state, bsize, "int16", sol_new_int(state, sizeof(int16_t)));
331
-	sol_map_set_name(state, bsize, "int32", sol_new_int(state, sizeof(int32_t)));
332
-	sol_map_set_name(state, bsize, "int64", sol_new_int(state, sizeof(int64_t)));
333
-	sol_map_set_name(state, bsize, "char", sol_new_int(state, sizeof(char)));
334
-	sol_map_set_name(state, bsize, "byte", sol_new_int(state, sizeof(unsigned char)));
335
-	sol_map_set_name(state, bsize, "int", sol_new_int(state, sizeof(int)));
336
-	sol_map_set_name(state, bsize, "uint", sol_new_int(state, sizeof(unsigned int)));
337
-	sol_map_set_name(state, bsize, "long", sol_new_int(state, sizeof(long)));
338
-	sol_map_set_name(state, bsize, "ulong", sol_new_int(state, sizeof(unsigned long)));
339
-	sol_map_set_name(state, bsize, "float", sol_new_int(state, sizeof(float)));
340
-	sol_map_set_name(state, bsize, "double", sol_new_int(state, sizeof(double)));
341
-	sol_map_set_name(state, bsize, "cstr", sol_new_int(state, sizeof(char *)));
342
-	sol_map_set_name(state, bsize, "ptr", sol_new_int(state, sizeof(void *)));
327
+	sol_map_borrow_name(state, bsize, "uint8", sol_new_int(state, sizeof(uint8_t)));
328
+	sol_map_borrow_name(state, bsize, "uint16", sol_new_int(state, sizeof(uint16_t)));
329
+	sol_map_borrow_name(state, bsize, "uint32", sol_new_int(state, sizeof(uint32_t)));
330
+	sol_map_borrow_name(state, bsize, "uint64", sol_new_int(state, sizeof(uint64_t)));
331
+	sol_map_borrow_name(state, bsize, "int8", sol_new_int(state, sizeof(int8_t)));
332
+	sol_map_borrow_name(state, bsize, "int16", sol_new_int(state, sizeof(int16_t)));
333
+	sol_map_borrow_name(state, bsize, "int32", sol_new_int(state, sizeof(int32_t)));
334
+	sol_map_borrow_name(state, bsize, "int64", sol_new_int(state, sizeof(int64_t)));
335
+	sol_map_borrow_name(state, bsize, "char", sol_new_int(state, sizeof(char)));
336
+	sol_map_borrow_name(state, bsize, "byte", sol_new_int(state, sizeof(unsigned char)));
337
+	sol_map_borrow_name(state, bsize, "int", sol_new_int(state, sizeof(int)));
338
+	sol_map_borrow_name(state, bsize, "uint", sol_new_int(state, sizeof(unsigned int)));
339
+	sol_map_borrow_name(state, bsize, "long", sol_new_int(state, sizeof(long)));
340
+	sol_map_borrow_name(state, bsize, "ulong", sol_new_int(state, sizeof(unsigned long)));
341
+	sol_map_borrow_name(state, bsize, "float", sol_new_int(state, sizeof(float)));
342
+	sol_map_borrow_name(state, bsize, "double", sol_new_int(state, sizeof(double)));
343
+	sol_map_borrow_name(state, bsize, "cstr", sol_new_int(state, sizeof(char *)));
344
+	sol_map_borrow_name(state, bsize, "ptr", sol_new_int(state, sizeof(void *)));
343 345
 
344 346
 	bobj = sol_new_map(state);
345
-	sol_map_set_name(state, bobj, "SOL_SINGLET", sol_new_int(state, SOL_SINGLET));
346
-	sol_map_set_name(state, bobj, "SOL_INTEGER", sol_new_int(state, SOL_INTEGER));
347
-	sol_map_set_name(state, bobj, "SOL_FLOAT", sol_new_int(state, SOL_FLOAT));
348
-	sol_map_set_name(state, bobj, "SOL_STRING", sol_new_int(state, SOL_STRING));
349
-	sol_map_set_name(state, bobj, "SOL_LIST", sol_new_int(state, SOL_LIST));
350
-	sol_map_set_name(state, bobj, "SOL_MAP", sol_new_int(state, SOL_MAP));
351
-	sol_map_set_name(state, bobj, "SOL_MCELL", sol_new_int(state, SOL_MCELL));
352
-	sol_map_set_name(state, bobj, "SOL_FUNCTION", sol_new_int(state, SOL_FUNCTION));
353
-	sol_map_set_name(state, bobj, "SOL_CFUNCTION", sol_new_int(state, SOL_CFUNCTION));
354
-	sol_map_set_name(state, bobj, "SOL_STMT", sol_new_int(state, SOL_STMT));
355
-	sol_map_set_name(state, bobj, "SOL_EXPR", sol_new_int(state, SOL_EXPR));
356
-	sol_map_set_name(state, bobj, "SOL_BUFFER", sol_new_int(state, SOL_BUFFER));
357
-	sol_map_set_name(state, bobj, "SOL_DYLIB", sol_new_int(state, SOL_DYLIB));
358
-	sol_map_set_name(state, bobj, "SOL_DYSYM", sol_new_int(state, SOL_DYSYM));
359
-	sol_map_set_name(state, bobj, "SOL_STREAM", sol_new_int(state, SOL_STREAM));
360
-	sol_map_set_name(state, bobj, "SOL_CDATA", sol_new_int(state, SOL_CDATA));
347
+	sol_map_borrow_name(state, bobj, "SOL_SINGLET", sol_new_int(state, SOL_SINGLET));
348
+	sol_map_borrow_name(state, bobj, "SOL_INTEGER", sol_new_int(state, SOL_INTEGER));
349
+	sol_map_borrow_name(state, bobj, "SOL_FLOAT", sol_new_int(state, SOL_FLOAT));
350
+	sol_map_borrow_name(state, bobj, "SOL_STRING", sol_new_int(state, SOL_STRING));
351
+	sol_map_borrow_name(state, bobj, "SOL_LIST", sol_new_int(state, SOL_LIST));
352
+	sol_map_borrow_name(state, bobj, "SOL_MAP", sol_new_int(state, SOL_MAP));
353
+	sol_map_borrow_name(state, bobj, "SOL_MCELL", sol_new_int(state, SOL_MCELL));
354
+	sol_map_borrow_name(state, bobj, "SOL_FUNCTION", sol_new_int(state, SOL_FUNCTION));
355
+	sol_map_borrow_name(state, bobj, "SOL_CFUNCTION", sol_new_int(state, SOL_CFUNCTION));
356
+	sol_map_borrow_name(state, bobj, "SOL_STMT", sol_new_int(state, SOL_STMT));
357
+	sol_map_borrow_name(state, bobj, "SOL_EXPR", sol_new_int(state, SOL_EXPR));
358
+	sol_map_borrow_name(state, bobj, "SOL_BUFFER", sol_new_int(state, SOL_BUFFER));
359
+	sol_map_borrow_name(state, bobj, "SOL_DYLIB", sol_new_int(state, SOL_DYLIB));
360
+	sol_map_borrow_name(state, bobj, "SOL_DYSYM", sol_new_int(state, SOL_DYSYM));
361
+	sol_map_borrow_name(state, bobj, "SOL_STREAM", sol_new_int(state, SOL_STREAM));
362
+	sol_map_borrow_name(state, bobj, "SOL_CDATA", sol_new_int(state, SOL_CDATA));
361 363
 	sol_map_invert(state, bobj);
362 364
 
363 365
 	mod = sol_new_map(state);
364
-	sol_map_set_name(state, mod, "new", sol_new_cfunc(state, sol_f_buffer_new));
365
-	sol_map_set_name(state, mod, "fromstring", sol_new_cfunc(state, sol_f_buffer_fromstring));
366
-	sol_map_set_name(state, mod, "fromobject", sol_new_cfunc(state, sol_f_buffer_fromobject));
367
-	sol_map_set_name(state, mod, "fromaddress", sol_new_cfunc(state, sol_f_buffer_fromaddress));
366
+	sol_map_borrow_name(state, mod, "new", sol_new_cfunc(state, sol_f_buffer_new));
367
+	sol_map_borrow_name(state, mod, "fromstring", sol_new_cfunc(state, sol_f_buffer_fromstring));
368
+	sol_map_borrow_name(state, mod, "fromobject", sol_new_cfunc(state, sol_f_buffer_fromobject));
369
+	sol_map_borrow_name(state, mod, "fromaddress", sol_new_cfunc(state, sol_f_buffer_fromaddress));
368 370
 	sol_map_set_name(state, mod, "type", btype);
369 371
 	sol_map_set_name(state, mod, "sizeof", bsize);
370 372
 	sol_map_set_name(state, mod, "objtype", bobj);
@@ -375,56 +377,56 @@ int sol_state_init(sol_state_t *state) {
375 377
 	sol_obj_free(btype);
376 378
 
377 379
 	mod = sol_new_map(state);
378
-	sol_map_set_name(state, mod, "MODE_READ", sol_new_int(state, MODE_READ));
379
-	sol_map_set_name(state, mod, "MODE_WRITE", sol_new_int(state, MODE_WRITE));
380
-	sol_map_set_name(state, mod, "MODE_APPEND", sol_new_int(state, MODE_APPEND));
381
-	sol_map_set_name(state, mod, "MODE_TRUNCATE", sol_new_int(state, MODE_TRUNCATE));
382
-	sol_map_set_name(state, mod, "MODE_BINARY", sol_new_int(state, MODE_BINARY));
383
-	sol_map_set_name(state, mod, "SEEK_SET", sol_new_int(state, SEEK_SET));
384
-	sol_map_set_name(state, mod, "SEEK_CUR", sol_new_int(state, SEEK_CUR));
385
-	sol_map_set_name(state, mod, "SEEK_END", sol_new_int(state, SEEK_END));
386
-	sol_map_set_name(state, mod, "ALL", sol_new_string(state, "ALL"));
387
-	sol_map_set_name(state, mod, "LINE", sol_new_string(state, "LINE"));
388
-	sol_map_set_name(state, mod, "stdin", sol_new_stream(state, stdin, MODE_READ));
389
-	sol_map_set_name(state, mod, "stdout", sol_new_stream(state, stdout, MODE_WRITE));
390
-	sol_map_set_name(state, mod, "stderr", sol_new_stream(state, stderr, MODE_WRITE));
391
-	sol_map_set_name(state, mod, "open", sol_new_cfunc(state, sol_f_stream_open));
392
-	sol_map_set_name(state, mod, "__setindex", sol_new_cfunc(state, sol_f_io_setindex));
380
+	sol_map_borrow_name(state, mod, "MODE_READ", sol_new_int(state, MODE_READ));
381
+	sol_map_borrow_name(state, mod, "MODE_WRITE", sol_new_int(state, MODE_WRITE));
382
+	sol_map_borrow_name(state, mod, "MODE_APPEND", sol_new_int(state, MODE_APPEND));
383
+	sol_map_borrow_name(state, mod, "MODE_TRUNCATE", sol_new_int(state, MODE_TRUNCATE));
384
+	sol_map_borrow_name(state, mod, "MODE_BINARY", sol_new_int(state, MODE_BINARY));
385
+	sol_map_borrow_name(state, mod, "SEEK_SET", sol_new_int(state, SEEK_SET));
386
+	sol_map_borrow_name(state, mod, "SEEK_CUR", sol_new_int(state, SEEK_CUR));
387
+	sol_map_borrow_name(state, mod, "SEEK_END", sol_new_int(state, SEEK_END));
388
+	sol_map_borrow_name(state, mod, "ALL", sol_new_string(state, "ALL"));
389
+	sol_map_borrow_name(state, mod, "LINE", sol_new_string(state, "LINE"));
390
+	sol_map_borrow_name(state, mod, "stdin", sol_new_stream(state, stdin, MODE_READ));
391
+	sol_map_borrow_name(state, mod, "stdout", sol_new_stream(state, stdout, MODE_WRITE));
392
+	sol_map_borrow_name(state, mod, "stderr", sol_new_stream(state, stderr, MODE_WRITE));
393
+	sol_map_borrow_name(state, mod, "open", sol_new_cfunc(state, sol_f_stream_open));
394
+	sol_map_borrow_name(state, mod, "__setindex", sol_new_cfunc(state, sol_f_io_setindex));
393 395
 	sol_register_module_name(state, "io", mod);
394 396
 	sol_obj_free(mod);
395 397
 
396 398
 	meths = sol_new_map(state);
397
-	sol_map_set_name(state, meths, "get", sol_new_cfunc(state, sol_f_buffer_get));
398
-	sol_map_set_name(state, meths, "set", sol_new_cfunc(state, sol_f_buffer_set));
399
-	sol_map_set_name(state, meths, "address", sol_new_cfunc(state, sol_f_buffer_address));
400
-	sol_map_set_name(state, meths, "size", sol_new_cfunc(state, sol_f_buffer_size));
399
+	sol_map_borrow_name(state, meths, "get", sol_new_cfunc(state, sol_f_buffer_get));
400
+	sol_map_borrow_name(state, meths, "set", sol_new_cfunc(state, sol_f_buffer_set));
401
+	sol_map_borrow_name(state, meths, "address", sol_new_cfunc(state, sol_f_buffer_address));
402
+	sol_map_borrow_name(state, meths, "size", sol_new_cfunc(state, sol_f_buffer_size));
401 403
 	sol_register_methods_name(state, "buffer", meths);
402 404
 	sol_obj_free(meths);
403 405
 
404 406
 	meths = sol_new_map(state);
405
-	sol_map_set_name(state, meths, "copy", sol_new_cfunc(state, sol_f_list_copy));
406
-	sol_map_set_name(state, meths, "insert", sol_new_cfunc(state, sol_f_list_insert));
407
-	sol_map_set_name(state, meths, "remove", sol_new_cfunc(state, sol_f_list_remove));
408
-	sol_map_set_name(state, meths, "truncate", sol_new_cfunc(state, sol_f_list_truncate));
409
-	sol_map_set_name(state, meths, "map", sol_new_cfunc(state, sol_f_list_map));
410
-	sol_map_set_name(state, meths, "filter", sol_new_cfunc(state, sol_f_list_filter));
407
+	sol_map_borrow_name(state, meths, "copy", sol_new_cfunc(state, sol_f_list_copy));
408
+	sol_map_borrow_name(state, meths, "insert", sol_new_cfunc(state, sol_f_list_insert));
409
+	sol_map_borrow_name(state, meths, "remove", sol_new_cfunc(state, sol_f_list_remove));
410
+	sol_map_borrow_name(state, meths, "truncate", sol_new_cfunc(state, sol_f_list_truncate));
411
+	sol_map_borrow_name(state, meths, "map", sol_new_cfunc(state, sol_f_list_map));
412
+	sol_map_borrow_name(state, meths, "filter", sol_new_cfunc(state, sol_f_list_filter));
411 413
 	sol_register_methods_name(state, "list", meths);
412 414
 	sol_obj_free(meths);
413 415
 
414 416
 	meths = sol_new_map(state);
415
-	sol_map_set_name(state, meths, "read", sol_new_cfunc(state, sol_f_stream_read));
416
-	sol_map_set_name(state, meths, "write", sol_new_cfunc(state, sol_f_stream_write));
417
-	sol_map_set_name(state, meths, "seek", sol_new_cfunc(state, sol_f_stream_seek));
418
-	sol_map_set_name(state, meths, "tell", sol_new_cfunc(state, sol_f_stream_tell));
419
-	sol_map_set_name(state, meths, "flush", sol_new_cfunc(state, sol_f_stream_flush));
420
-	sol_map_set_name(state, meths, "eof", sol_new_cfunc(state, sol_f_stream_eof));
417
+	sol_map_borrow_name(state, meths, "read", sol_new_cfunc(state, sol_f_stream_read));
418
+	sol_map_borrow_name(state, meths, "write", sol_new_cfunc(state, sol_f_stream_write));
419
+	sol_map_borrow_name(state, meths, "seek", sol_new_cfunc(state, sol_f_stream_seek));
420
+	sol_map_borrow_name(state, meths, "tell", sol_new_cfunc(state, sol_f_stream_tell));
421
+	sol_map_borrow_name(state, meths, "flush", sol_new_cfunc(state, sol_f_stream_flush));
422
+	sol_map_borrow_name(state, meths, "eof", sol_new_cfunc(state, sol_f_stream_eof));
421 423
 	sol_register_methods_name(state, "stream", meths);
422 424
 	sol_obj_free(meths);
423 425
 
424 426
 	meths = sol_new_map(state);
425
-	sol_map_set_name(state, meths, "sub", sol_new_cfunc(state, sol_f_str_sub));
426
-	sol_map_set_name(state, meths, "split", sol_new_cfunc(state, sol_f_str_split));
427
-	sol_map_set_name(state, meths, "find", sol_new_cfunc(state, sol_f_str_find));
427
+	sol_map_borrow_name(state, meths, "sub", sol_new_cfunc(state, sol_f_str_sub));
428
+	sol_map_borrow_name(state, meths, "split", sol_new_cfunc(state, sol_f_str_split));
429
+	sol_map_borrow_name(state, meths, "find", sol_new_cfunc(state, sol_f_str_find));
428 430
 	sol_register_methods_name(state, "string", meths);
429 431
 	sol_obj_free(meths);
430 432
 
@@ -443,14 +445,23 @@ cleanup:
443 445
 }
444 446
 
445 447
 void sol_state_cleanup(sol_state_t *state) {
448
+	long i;
446 449
 	sol_obj_free(state->scopes);
447 450
 	sol_obj_free(state->error);
448 451
 	sol_obj_free(state->None);
449 452
 	sol_obj_free(state->OutOfMemory);
450 453
 	sol_obj_free(state->StopIteration);
454
+	sol_obj_free(state->stdin);
455
+	sol_obj_free(state->stdout);
456
+	sol_obj_free(state->stderr);
451 457
 	if(state->ret) {
452 458
 		sol_obj_free(state->ret);
453 459
 	}
460
+#ifdef SOL_ICACHE
461
+	for(i = 0; i <= (SOL_ICACHE_MAX - SOL_ICACHE_MIN); i++) {
462
+		sol_obj_free(state->icache[i]);
463
+	}
464
+#endif
454 465
 	sol_obj_free(state->modules);
455 466
 	sol_obj_free(state->methods);
456 467
 	sol_mm_finalize(state);
@@ -480,7 +491,7 @@ sol_object_t *sol_state_resolve(sol_state_t *state, sol_object_t *key) {
480 491
 	if(!sol_is_none(state, temp)) {
481 492
 		return temp;
482 493
 	}
483
-	// sol_obj_free(temp);
494
+	sol_obj_free(temp);
484 495
 
485 496
 	return sol_incref(state->None);
486 497
 }

+ 2
- 0
tokenizer.lex View File

@@ -108,6 +108,8 @@ do { return DO; }
108 108
 
109 109
 func { return FUNC; }
110 110
 
111
+lambda { return LAMBDA; }
112
+
111 113
 return { return RETURN; }
112 114
 
113 115
 break { return BREAK; }

Loading…
Cancel
Save