builtin.c(Ver.0.4)
1: #include <stdio.h>
2: #include "CRB.h"
3:
4: static char *st_builtin_src[] = {
5: "function create_exception_class(parent) {\n",
6: " this = new_object();\n",
7: " this.parent = parent;\n",
8: " this.create = closure(message) {\n",
9: " e = new_exception(message);\n",
10: " e.stack_trace.remove(0);\n",
11: " e.child_of = this.child_of;\n",
12: " return e;\n",
13: " };\n",
14: " this.child_of = closure(o) {\n",
15: " for (p = this; p != null; p = p.parent) {\n",
16: " if (p == o) {\n",
17: " return true;\n",
18: " }\n",
19: " }\n",
20: " return false;\n",
21: " };\n",
22: " return this;\n",
23: "}\n",
24: "\n",
25: "RootException = create_exception_class(null);\n",
26: "BugException = create_exception_class(RootException);\n",
27: "RuntimeException = create_exception_class(RootException);\n",
28: "ArithmeticException = create_exception_class(RuntimeException);\n",
29: "VariableNotFoundException = create_exception_class(BugException);\n",
30: "ArgumentTooManyException = create_exception_class(BugException);\n",
31: "ArgumentTooFewException = create_exception_class(BugException);\n",
32: "NotBooleanException = create_exception_class(BugException);\n",
33: "MinusOperandTypeException = create_exception_class(BugException);\n",
34: "BadOperandTypeException = create_exception_class(BugException);\n",
35: "LogicalOperatorDoubleOperandException = create_exception_class(BugException);\n",
36: "LogicalOperatorIntegerOperandException = create_exception_class(BugException);\n",
37: "NotBooleanOperatorException = create_exception_class(BugException);\n",
38: "NotNullOperatorException = create_exception_class(BugException);\n",
39: "NotLValueException = create_exception_class(BugException);\n",
40: "IndexOperandNotArrayException = create_exception_class(BugException);\n",
41: "IndexOperandNotIntException = create_exception_class(BugException);\n",
42: "ArrayIndexOutOfBoundsException = create_exception_class(BugException);\n",
43: "NoSuchMethodException = create_exception_class(BugException);\n",
44: "IncDecOperandTypeException = create_exception_class(BugException);\n",
45: "IncDecOperandNotExistException = create_exception_class(BugException);\n",
46: "NotFunctionException = create_exception_class(BugException);\n",
47: "NotObjectMemberUpdateException = create_exception_class(BugException);\n",
48: "NotObjectMemberAssignException = create_exception_class(BugException);\n",
49: "NoSuchMemberException = create_exception_class(BugException);\n",
50: "NoMemberTypeException = create_exception_class(BugException);\n",
51: "BadOperatorForStringException = create_exception_class(BugException);\n",
52: "DivisionByZeroException = create_exception_class(ArithmeticException);\n",
53: "GlobalVariableNotFoundException = create_exception_class(BugException);\n",
54: "GlobalStatementInToplevelException = create_exception_class(BugException);\n",
55: "FunctionExistsException = create_exception_class(BugException);\n",
56: "ArrayResizeArgumentException = create_exception_class(BugException);\n",
57: "ArrayInsertArgumentException = create_exception_class(BugException);\n",
58: "ArrayRemoveArgumentException = create_exception_class(BugException);\n",
59: "StringPositionOutOfBoundsException = create_exception_class(BugException);\n",
60: "StringSubstrLengthException = create_exception_class(BugException);\n",
61: "StringSubstrArgumentException = create_exception_class(BugException);\n",
62: "ExceptionHasNoMessageException = create_exception_class(BugException);\n",
63: "ExceptionMessageIsNotStringException = create_exception_class(BugException);\n",
64: "ExceptionHasNoStackTraceException = create_exception_class(BugException);\n",
65: "StackTraceIsNotArrayException = create_exception_class(BugException);\n",
66: "StackTraceLineIsNotAssocException = create_exception_class(BugException);\n",
67: "StackTraceLineHasNoLineNumberException = create_exception_class(BugException);\n",
68: "StackTraceLineHasNoFuncNameException = create_exception_class(BugException);\n",
69: "ExceptionIsNotAssocException = create_exception_class(BugException);\n",
70: "\n",
71: "ExceptionHasNoPrintStackTraceMethodException\n",
72: " = create_exception_class(BugException);\n",
73: "PrintStackTraceIsNotClosureException = create_exception_class(BugException);\n",
74: "BadMultibyteCharacterException = create_exception_class(RuntimeException);\n",
75: "ExceptionClassIsNotAssocException = create_exception_class(BugException);\n",
76: "ExceptionClassHasNoCreateMethodException\n",
77: " = create_exception_class(BugException);\n",
78: "ArgumentTypeMismatchException = create_exception_class(BugException);\n",
79: "UnexpectedWideStringException = create_exception_class(RuntimeException);\n",
80: "OnigSearchFailException = create_exception_class(RuntimeException);\n",
81: "GroupIndexOverflowException = create_exception_class(BugException);\n",
82: "\n",
83: "# native.c\n",
84: "FOpenArgumentTypeException = create_exception_class(BugException);\n",
85: "FCloseArgumentTypeException = create_exception_class(BugException);\n",
86: "FGetsArgumentTypeException = create_exception_class(BugException);\n",
87: "FileAlreadyClosedException = create_exception_class(BugException);\n",
88: "FPutsArgumentTypeException = create_exception_class(BugException);\n",
89: "NewArrayArgumentTypeException = create_exception_class(BugException);\n",
90: "NewArrayArgumentTooFewException = create_exception_class(BugException);\n",
91: "ExitArgumentTypeException = create_exception_class(BugException);\n",
92: "NewExceptionArgumentException = create_exception_class(BugException);\n",
93: "FGetsBadMultibyteCharacterException\n",
94: " = create_exception_class(BadMultibyteCharacterException);\n",
95: "\n",
96: NULL};
97:
98: static char **st_src_array[] = {
99: st_builtin_src,
100: };
101:
102: void
103: crb_compile_built_in_script(CRB_Interpreter *inter)
104: {
105: int i;
106:
107: for (i = 0; i < sizeof(st_src_array) / sizeof(st_src_array[0]); i++) {
108: CRB_compile_string(inter, st_src_array[i]);
109: }
110: }
戻る